Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: chrome/views/hwnd_view.cc

Issue 13235: Cleanup adding BoundsInWidget to View to convert callers... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/views/hwnd_view.h" 5 #include "chrome/views/hwnd_view.h"
6 6
7 #include "chrome/common/gfx/chrome_canvas.h" 7 #include "chrome/common/gfx/chrome_canvas.h"
8 #include "chrome/common/win_util.h" 8 #include "chrome/common/win_util.h"
9 #include "chrome/views/focus_manager.h" 9 #include "chrome/views/focus_manager.h"
10 #include "chrome/views/scroll_view.h" 10 #include "chrome/views/scroll_view.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } 63 }
64 64
65 void HWNDView::UpdateHWNDBounds() { 65 void HWNDView::UpdateHWNDBounds() {
66 if (!hwnd_) 66 if (!hwnd_)
67 return; 67 return;
68 68
69 // Since HWNDs know nothing about the View hierarchy (they are direct 69 // Since HWNDs know nothing about the View hierarchy (they are direct
70 // children of the Widget that hosts our View hierarchy) they need to be 70 // children of the Widget that hosts our View hierarchy) they need to be
71 // positioned in the coordinate system of the Widget, not the current 71 // positioned in the coordinate system of the Widget, not the current
72 // view. 72 // view.
73 gfx::Point top_left; 73 gfx::Rect widget_bounds = BoundsInWidget();
74 ConvertPointToWidget(this, &top_left);
75 74
76 gfx::Rect vis_bounds = GetVisibleBounds(); 75 gfx::Rect vis_bounds = GetVisibleBounds();
77 bool visible = !vis_bounds.IsEmpty(); 76 bool visible = !vis_bounds.IsEmpty();
78 77
79 if (visible && !fast_resize_) { 78 if (visible && !fast_resize_) {
80 if (vis_bounds.size() != size()) { 79 if (vis_bounds.size() != size()) {
81 // Only a portion of the HWND is really visible. 80 // Only a portion of the HWND is really visible.
82 int x = vis_bounds.x(); 81 int x = vis_bounds.x();
83 int y = vis_bounds.y(); 82 int y = vis_bounds.y();
84 HRGN clip_region = CreateRectRgn(x, y, x + vis_bounds.width(), 83 HRGN clip_region = CreateRectRgn(x, y, x + vis_bounds.width(),
(...skipping 18 matching lines...) Expand all
103 SWP_NOOWNERZORDER | 102 SWP_NOOWNERZORDER |
104 SWP_NOZORDER; 103 SWP_NOZORDER;
105 // Only send the SHOWWINDOW flag if we're invisible, to avoid flashing. 104 // Only send the SHOWWINDOW flag if we're invisible, to avoid flashing.
106 if (!::IsWindowVisible(hwnd_)) 105 if (!::IsWindowVisible(hwnd_))
107 swp_flags = (swp_flags | SWP_SHOWWINDOW) & ~SWP_NOREDRAW; 106 swp_flags = (swp_flags | SWP_SHOWWINDOW) & ~SWP_NOREDRAW;
108 107
109 if (fast_resize_) { 108 if (fast_resize_) {
110 // In a fast resize, we move the window and clip it with SetWindowRgn. 109 // In a fast resize, we move the window and clip it with SetWindowRgn.
111 CRect rect; 110 CRect rect;
112 GetWindowRect(hwnd_, &rect); 111 GetWindowRect(hwnd_, &rect);
113 ::SetWindowPos(hwnd_, 0, top_left.x(), top_left.y(), rect.Width(), 112 ::SetWindowPos(hwnd_, 0, widget_bounds.x(), widget_bounds.y(),
114 rect.Height(), swp_flags); 113 rect.Width(), rect.Height(), swp_flags);
115 114
116 HRGN clip_region = CreateRectRgn(0, 0, width(), height()); 115 HRGN clip_region = CreateRectRgn(0, 0, width(), height());
117 SetWindowRgn(hwnd_, clip_region, FALSE); 116 SetWindowRgn(hwnd_, clip_region, FALSE);
118 installed_clip_ = true; 117 installed_clip_ = true;
119 } else { 118 } else {
120 ::SetWindowPos(hwnd_, 0, top_left.x(), top_left.y(), width(), height(), 119 ::SetWindowPos(hwnd_, 0, widget_bounds.x(), widget_bounds.y(), width(),
121 swp_flags); 120 height(), swp_flags);
122 } 121 }
123 } else if (::IsWindowVisible(hwnd_)) { 122 } else if (::IsWindowVisible(hwnd_)) {
124 // The window is currently visible, but its clipped by another view. Hide 123 // The window is currently visible, but its clipped by another view. Hide
125 // it. 124 // it.
126 ::SetWindowPos(hwnd_, 0, 0, 0, 0, 0, 125 ::SetWindowPos(hwnd_, 0, 0, 0, 0, 0,
127 SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | 126 SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
128 SWP_NOREDRAW | SWP_NOOWNERZORDER ); 127 SWP_NOREDRAW | SWP_NOOWNERZORDER );
129 } 128 }
130 } 129 }
131 130
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 if (installed_clip_) 183 if (installed_clip_)
185 canvas->FillRectInt(SkColorSetRGB(255, 255, 255), 0, 0, width(), height()); 184 canvas->FillRectInt(SkColorSetRGB(255, 255, 255), 0, 0, width(), height());
186 } 185 }
187 186
188 std::string HWNDView::GetClassName() const { 187 std::string HWNDView::GetClassName() const {
189 return kViewClassName; 188 return kViewClassName;
190 } 189 }
191 190
192 } // namespace views 191 } // namespace views
193 192
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698