summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-16 18:17:47 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-16 18:17:47 +0000
commit80f8b9f5cf620c37e9d1408a114dc90699584d89 (patch)
tree9e2f5fcacbb18cd86690bc47e0d22ea8f10ac317
parentf377cebc8bb25bb9f6708adbfda567a95c296642 (diff)
downloadchromium_src-80f8b9f5cf620c37e9d1408a114dc90699584d89.zip
chromium_src-80f8b9f5cf620c37e9d1408a114dc90699584d89.tar.gz
chromium_src-80f8b9f5cf620c37e9d1408a114dc90699584d89.tar.bz2
Make View::SetBounds take a const gfx::Rect& instead of a const CRect&
Make View::DidChangeBounds call Layout by default, eliminating this function from most places. http://crbug.com/2186 Review URL: http://codereview.chromium.org/7429 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3471 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/gfx/rect.cc7
-rw-r--r--base/gfx/rect.h3
-rw-r--r--chrome/browser/automation/automation_provider.cc11
-rw-r--r--chrome/browser/debugger/debugger_view.cc7
-rw-r--r--chrome/browser/debugger/debugger_view.h1
-rw-r--r--chrome/browser/drag_utils.cc2
-rw-r--r--chrome/browser/find_in_page_controller.cc8
-rw-r--r--chrome/browser/find_in_page_view.cc16
-rw-r--r--chrome/browser/find_in_page_view.h2
-rw-r--r--chrome/browser/history_view.cc8
-rw-r--r--chrome/browser/history_view.h3
-rw-r--r--chrome/browser/task_manager.cc37
-rw-r--r--chrome/browser/views/about_chrome_view.cc7
-rw-r--r--chrome/browser/views/bookmark_bar_view.cc4
-rw-r--r--chrome/browser/views/bookmark_bar_view.h3
-rw-r--r--chrome/browser/views/bookmark_bubble_view.cc4
-rw-r--r--chrome/browser/views/bookmark_bubble_view.h3
-rw-r--r--chrome/browser/views/bookmark_editor_view.cc10
-rw-r--r--chrome/browser/views/bookmark_editor_view.h1
-rw-r--r--chrome/browser/views/clear_browsing_data.cc5
-rw-r--r--chrome/browser/views/constrained_window_impl.cc2
-rw-r--r--chrome/browser/views/delay_view.cc11
-rw-r--r--chrome/browser/views/download_item_view.cc7
-rw-r--r--chrome/browser/views/download_item_view.h1
-rw-r--r--chrome/browser/views/download_shelf_view.cc5
-rw-r--r--chrome/browser/views/download_shelf_view.h2
-rw-r--r--chrome/browser/views/download_tab_view.cc12
-rw-r--r--chrome/browser/views/download_tab_view.h2
-rw-r--r--chrome/browser/views/first_run_bubble.cc5
-rw-r--r--chrome/browser/views/frame/aero_glass_non_client_view.cc10
-rw-r--r--chrome/browser/views/frame/aero_glass_non_client_view.h1
-rw-r--r--chrome/browser/views/frame/browser_view.cc5
-rw-r--r--chrome/browser/views/frame/browser_view.h1
-rw-r--r--chrome/browser/views/frame/browser_view2.cc7
-rw-r--r--chrome/browser/views/frame/browser_view2.h1
-rw-r--r--chrome/browser/views/frame/opaque_non_client_view.cc12
-rw-r--r--chrome/browser/views/frame/opaque_non_client_view.h1
-rw-r--r--chrome/browser/views/hung_renderer_view.cc4
-rw-r--r--chrome/browser/views/info_bar_item_view.cc4
-rw-r--r--chrome/browser/views/info_bar_item_view.h3
-rw-r--r--chrome/browser/views/info_bar_view.cc5
-rw-r--r--chrome/browser/views/info_bar_view.h2
-rw-r--r--chrome/browser/views/info_bubble.h4
-rw-r--r--chrome/browser/views/keyword_editor_view.cc5
-rw-r--r--chrome/browser/views/keyword_editor_view.h1
-rw-r--r--chrome/browser/views/location_bar_view.cc16
-rw-r--r--chrome/browser/views/location_bar_view.h5
-rw-r--r--chrome/browser/views/old_frames/vista_frame.cc2
-rw-r--r--chrome/browser/views/old_frames/xp_frame.cc2
-rw-r--r--chrome/browser/views/options/advanced_contents_view.cc30
-rw-r--r--chrome/browser/views/options/cookies_view.cc5
-rw-r--r--chrome/browser/views/options/options_group_view.h14
-rw-r--r--chrome/browser/views/page_info_window.cc6
-rw-r--r--chrome/browser/views/password_manager_view.cc6
-rw-r--r--chrome/browser/views/sad_tab_view.cc4
-rw-r--r--chrome/browser/views/sad_tab_view.h1
-rw-r--r--chrome/browser/views/shelf_item_dialog.cc5
-rw-r--r--chrome/browser/views/shelf_item_dialog.h1
-rw-r--r--chrome/browser/views/tabs/dragged_tab_controller.cc7
-rw-r--r--chrome/browser/views/tabs/dragged_tab_view.cc7
-rw-r--r--chrome/browser/views/tabs/tab_renderer.cc31
-rw-r--r--chrome/browser/views/tabs/tab_renderer.h1
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc15
-rw-r--r--chrome/browser/views/tabs/tab_strip.h1
-rw-r--r--chrome/browser/views/toolbar_view.cc5
-rw-r--r--chrome/browser/views/toolbar_view.h1
-rw-r--r--chrome/browser/web_contents_view_win.cc2
-rw-r--r--chrome/views/bitmap_scroll_bar.cc11
-rw-r--r--chrome/views/bitmap_scroll_bar.h1
-rw-r--r--chrome/views/button_dropdown.cc9
-rw-r--r--chrome/views/checkbox.cc2
-rw-r--r--chrome/views/chrome_menu.cc6
-rw-r--r--chrome/views/chrome_menu.h3
-rw-r--r--chrome/views/client_view.cc4
-rw-r--r--chrome/views/client_view.h1
-rw-r--r--chrome/views/container_win.cc4
-rw-r--r--chrome/views/custom_frame_window.cc5
-rw-r--r--chrome/views/decision.cc26
-rw-r--r--chrome/views/decision.h4
-rw-r--r--chrome/views/dialog_client_view.cc64
-rw-r--r--chrome/views/dialog_client_view.h1
-rw-r--r--chrome/views/hwnd_view.cc19
-rw-r--r--chrome/views/hwnd_view.h3
-rw-r--r--chrome/views/label.cc4
-rw-r--r--chrome/views/menu_button.cc7
-rw-r--r--chrome/views/native_control.cc24
-rw-r--r--chrome/views/native_control.h1
-rw-r--r--chrome/views/native_scroll_bar.cc12
-rw-r--r--chrome/views/native_scroll_bar.h1
-rw-r--r--chrome/views/root_view.cc3
-rw-r--r--chrome/views/scroll_view.cc61
-rw-r--r--chrome/views/scroll_view.h7
-rw-r--r--chrome/views/table_view.cc15
-rw-r--r--chrome/views/table_view.h3
-rw-r--r--chrome/views/text_field.cc8
-rw-r--r--chrome/views/text_field.h1
-rw-r--r--chrome/views/view.cc85
-rw-r--r--chrome/views/view.h41
-rw-r--r--chrome/views/view_unittest.cc12
99 files changed, 298 insertions, 572 deletions
diff --git a/base/gfx/rect.cc b/base/gfx/rect.cc
index 0f9708c..fa81023 100644
--- a/base/gfx/rect.cc
+++ b/base/gfx/rect.cc
@@ -115,6 +115,13 @@ void Rect::Inset(int horizontal, int vertical) {
set_height(std::max(height() - (vertical * 2), 0));
}
+void Rect::Inset(int left, int top, int right, int bottom) {
+ set_width(std::max(width() - left - right, 0));
+ set_height(std::max(height() - top - bottom, 0));
+ set_x(left);
+ set_y(top);
+}
+
void Rect::Offset(int horizontal, int vertical) {
set_x(x() + horizontal);
set_y(y() + vertical);
diff --git a/base/gfx/rect.h b/base/gfx/rect.h
index a7a3d9c..ac730bd 100644
--- a/base/gfx/rect.h
+++ b/base/gfx/rect.h
@@ -74,6 +74,9 @@ class Rect {
// Shrink the rectangle by a horizontal and vertical distance on all sides.
void Inset(int horizontal, int vertical);
+ // Shrink the rectangle by the specified amount on each side.
+ void Inset(int left, int top, int right, int bottom);
+
// Move the rectangle by a horizontal and vertical distance.
void Offset(int horizontal, int vertical);
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index e4b4bf6..716e3e1 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -1136,8 +1136,7 @@ void AutomationProvider::WindowGetViewBounds(const IPC::Message& message,
int view_id,
bool screen_coordinates) {
bool succeeded = false;
- CRect bounds;
- bounds.SetRect(0, 0, 0, 0);
+ gfx::Rect bounds;
void* iter = NULL;
if (window_tracker_->ContainsHandle(handle)) {
@@ -1153,14 +1152,14 @@ void AutomationProvider::WindowGetViewBounds(const IPC::Message& message,
ChromeViews::View::ConvertPointToScreen(view, &point);
else
ChromeViews::View::ConvertPointToView(view, root_view, &point);
- view->GetLocalBounds(&bounds, false);
- bounds.MoveToXY(point.x(), point.y());
+ bounds = view->GetLocalBounds(false);
+ bounds.set_origin(point);
}
}
}
- Send(new AutomationMsg_WindowViewBoundsResponse(
- message.routing_id(), succeeded, gfx::Rect(bounds)));
+ Send(new AutomationMsg_WindowViewBoundsResponse(message.routing_id(),
+ succeeded, bounds));
}
// This task enqueues a mouse event on the event loop, so that the view
diff --git a/chrome/browser/debugger/debugger_view.cc b/chrome/browser/debugger/debugger_view.cc
index f6cac90..704be14 100644
--- a/chrome/browser/debugger/debugger_view.cc
+++ b/chrome/browser/debugger/debugger_view.cc
@@ -46,10 +46,6 @@ void DebuggerView::Layout() {
web_container_->SetBounds(0, 0, width(), height());
}
-void DebuggerView::DidChangeBounds(const CRect& previous,
- const CRect& current) {
- Layout();
-}
void DebuggerView::ViewHierarchyChanged(bool is_add,
ChromeViews::View* parent,
@@ -63,8 +59,7 @@ void DebuggerView::ViewHierarchyChanged(bool is_add,
void DebuggerView::Paint(ChromeCanvas* canvas) {
#ifndef NDEBUG
SkPaint paint;
- canvas->FillRectInt(SK_ColorCYAN, bounds_.left, bounds_.top,
- bounds_.Width(), bounds_.Height());
+ canvas->FillRectInt(SK_ColorCYAN, x(), y(), width(), height());
#endif
}
diff --git a/chrome/browser/debugger/debugger_view.h b/chrome/browser/debugger/debugger_view.h
index ecb9e7a..72544b4 100644
--- a/chrome/browser/debugger/debugger_view.h
+++ b/chrome/browser/debugger/debugger_view.h
@@ -50,7 +50,6 @@ class DebuggerView : public ChromeViews::View,
virtual gfx::Size GetPreferredSize();
virtual void Layout();
virtual void Paint(ChromeCanvas* canvas);
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual void ViewHierarchyChanged(bool is_add,
ChromeViews::View* parent,
ChromeViews::View* child);
diff --git a/chrome/browser/drag_utils.cc b/chrome/browser/drag_utils.cc
index 5eb1c27..8ba82af 100644
--- a/chrome/browser/drag_utils.cc
+++ b/chrome/browser/drag_utils.cc
@@ -150,7 +150,7 @@ void SetURLAndDragImage(const GURL& url,
button.SetIcon(icon);
}
gfx::Size prefsize = button.GetPreferredSize();
- button.SetBounds(gfx::Point(), prefsize);
+ button.SetBounds(0, 0, prefsize.width(), prefsize.height());
// Render the image.
ChromeCanvas canvas(prefsize.width(), prefsize.height(), false);
diff --git a/chrome/browser/find_in_page_controller.cc b/chrome/browser/find_in_page_controller.cc
index 0646ced..0f05267 100644
--- a/chrome/browser/find_in_page_controller.cc
+++ b/chrome/browser/find_in_page_controller.cc
@@ -480,12 +480,10 @@ void FindInPageController::GetDialogBounds(gfx::Rect* bounds) {
// Find the dimensions of the toolbar and the BookmarkBar.
gfx::Rect toolbar_bounds, bookmark_bar_bounds;
if (toolbar) {
- if (!g_browser_process->IsUsingNewFrames())
+ if (!g_browser_process->IsUsingNewFrames()) {
toolbar_bounds = toolbar->bounds();
- else {
- CRect local_bounds;
- toolbar->GetLocalBounds(&local_bounds, false);
- toolbar_bounds = gfx::Rect(local_bounds);
+ } else {
+ toolbar_bounds = toolbar->GetLocalBounds(false);
}
// Need to convert toolbar bounds into Container coords because the toolbar
// is the child of another view that isn't the top level view. This is
diff --git a/chrome/browser/find_in_page_view.cc b/chrome/browser/find_in_page_view.cc
index da14afe..2c3aa19 100644
--- a/chrome/browser/find_in_page_view.cc
+++ b/chrome/browser/find_in_page_view.cc
@@ -244,8 +244,7 @@ void FindInPageView::Paint(ChromeCanvas* canvas) {
SkPaint paint;
// Get the local bounds so that we now how much to stretch the background.
- CRect lb;
- GetLocalBounds(&lb, true);
+ gfx::Rect lb = GetLocalBounds(true);
// First, we draw the background image for the whole dialog (3 images: left,
// middle and right). Note, that the window region has been set by the
@@ -270,13 +269,13 @@ void FindInPageView::Paint(ChromeCanvas* canvas) {
canvas->TileImageInt(*bg_middle,
bg_left->width(),
0,
- lb.Width() -
+ lb.width() -
bg_left->width() -
bg_right->width(),
bg_middle->height());
canvas->TileImageInt(*bg_right,
- lb.right - bg_right->width(),
+ lb.right() - bg_right->width(),
0,
bg_right->width(),
bg_right->height());
@@ -322,12 +321,12 @@ void FindInPageView::Paint(ChromeCanvas* canvas) {
// While animating we draw the curved edges at the point where the
// controller told us the top of the window is: |animation_offset_|.
canvas->TileImageInt(*bg_left,
- lb.TopLeft().x,
+ lb.x(),
animation_offset_,
bg_left->width(),
kAnimatingEdgeHeight);
canvas->TileImageInt(*bg_right,
- lb.BottomRight().x - bg_right->width(),
+ lb.right() - bg_right->width(),
animation_offset_,
bg_right->width(),
kAnimatingEdgeHeight);
@@ -399,11 +398,6 @@ void FindInPageView::Layout() {
find_previous_button_->height());
}
-void FindInPageView::DidChangeBounds(const CRect& old_bounds,
- const CRect& new_bounds) {
- Layout();
-}
-
void FindInPageView::ViewHierarchyChanged(bool is_add,
View *parent,
View *child) {
diff --git a/chrome/browser/find_in_page_view.h b/chrome/browser/find_in_page_view.h
index 834568e..4f09ae0 100644
--- a/chrome/browser/find_in_page_view.h
+++ b/chrome/browser/find_in_page_view.h
@@ -68,8 +68,6 @@ class FindInPageView : public ChromeViews::View,
// Overridden from ChromeViews::View:
virtual void Paint(ChromeCanvas* canvas);
virtual void Layout();
- virtual void DidChangeBounds(const CRect& old_bounds,
- const CRect& new_bounds);
virtual gfx::Size GetPreferredSize();
virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
diff --git a/chrome/browser/history_view.cc b/chrome/browser/history_view.cc
index ef439eb..7ff4225 100644
--- a/chrome/browser/history_view.cc
+++ b/chrome/browser/history_view.cc
@@ -840,7 +840,8 @@ bool HistoryView::IsVisible() {
return vc && vc->IsVisible();
}
-void HistoryView::DidChangeBounds(const CRect& previous, const CRect& current) {
+void HistoryView::DidChangeBounds(const gfx::Rect& previous,
+ const gfx::Rect& current) {
SchedulePaint();
}
@@ -851,14 +852,13 @@ void HistoryView::Layout() {
if (!parent)
return;
- CRect bounds;
- parent->GetLocalBounds(&bounds, true);
+ gfx::Rect bounds = parent->GetLocalBounds(true);
// If not visible, have zero size so we don't compute anything.
int width = 0;
int height = 0;
if (IsVisible()) {
- width = bounds.Width();
+ width = bounds.width();
height = std::max(GetLastEntryMaxY(),
kEntryPadding + kNoResultTextHeight);
}
diff --git a/chrome/browser/history_view.h b/chrome/browser/history_view.h
index b5c0725..8f5998c 100644
--- a/chrome/browser/history_view.h
+++ b/chrome/browser/history_view.h
@@ -33,7 +33,8 @@ class HistoryView : public ChromeViews::View,
bool IsVisible();
// Overridden for layout purposes.
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
+ virtual void DidChangeBounds(const gfx::Rect& previous,
+ const gfx::Rect& current);
virtual void Layout();
virtual bool GetFloatingViewIDForPoint(int x, int y, int* id);
diff --git a/chrome/browser/task_manager.cc b/chrome/browser/task_manager.cc
index 0f593b1..e08db35 100644
--- a/chrome/browser/task_manager.cc
+++ b/chrome/browser/task_manager.cc
@@ -667,7 +667,6 @@ class TaskManagerContents : public ChromeViews::View,
void Init(TaskManagerTableModel* table_model);
virtual void Layout();
virtual gfx::Size GetPreferredSize();
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual void ViewHierarchyChanged(bool is_add, ChromeViews::View* parent,
ChromeViews::View* child);
void GetSelection(std::vector<int>* selection);
@@ -809,11 +808,6 @@ void TaskManagerContents::UpdateStatsCounters() {
}
}
-void TaskManagerContents::DidChangeBounds(const CRect& previous,
- const CRect& current) {
- Layout();
-}
-
void TaskManagerContents::ViewHierarchyChanged(bool is_add,
ChromeViews::View* parent,
ChromeViews::View* child) {
@@ -839,31 +833,24 @@ void TaskManagerContents::ViewHierarchyChanged(bool is_add,
void TaskManagerContents::Layout() {
// kPanelHorizMargin is too big.
const int kTableButtonSpacing = 12;
- CRect bounds;
- GetLocalBounds(&bounds, true);
- int x = bounds.left;
- int y = bounds.top;
gfx::Size size = kill_button_->GetPreferredSize();
int prefered_width = size.width();
int prefered_height = size.height();
- tab_table_->SetBounds(
- x + kPanelHorizMargin,
- y + kPanelVertMargin,
- bounds.Width() - 2 * kPanelHorizMargin,
- bounds.Height() - 2 * kPanelVertMargin - prefered_height);
-
+ tab_table_->SetBounds(x() + kPanelHorizMargin,
+ y() + kPanelVertMargin,
+ width() - 2 * kPanelHorizMargin,
+ height() - 2 * kPanelVertMargin - prefered_height);
+
// y-coordinate of button top left.
- CRect parent_bounds;
- GetParent()->GetLocalBounds(&parent_bounds, false);
- int y_buttons = parent_bounds.bottom - prefered_height - kButtonVEdgeMargin;
+ gfx::Rect parent_bounds = GetParent()->GetLocalBounds(false);
+ int y_buttons = parent_bounds.bottom() - prefered_height - kButtonVEdgeMargin;
- kill_button_->SetBounds(
- x + bounds.Width() - prefered_width - kPanelHorizMargin,
- y_buttons,
- prefered_width,
- prefered_height);
+ kill_button_->SetBounds(x() + width() - prefered_width - kPanelHorizMargin,
+ y_buttons,
+ prefered_width,
+ prefered_height);
size = about_memory_link_->GetPreferredSize();
int link_prefered_width = size.width();
@@ -872,7 +859,7 @@ void TaskManagerContents::Layout() {
// bottom of buttons vertically.
int link_y_offset = std::max(0, prefered_height - link_prefered_height) / 2;
about_memory_link_->SetBounds(
- x + kPanelHorizMargin,
+ x() + kPanelHorizMargin,
y_buttons + prefered_height - link_prefered_height - link_y_offset,
link_prefered_width,
link_prefered_height);
diff --git a/chrome/browser/views/about_chrome_view.cc b/chrome/browser/views/about_chrome_view.cc
index e5a8262..d5627e5 100644
--- a/chrome/browser/views/about_chrome_view.cc
+++ b/chrome/browser/views/about_chrome_view.cc
@@ -266,12 +266,11 @@ void AboutChromeView::Layout() {
// Get the y-coordinate of our parent so we can position the text left of the
// buttons at the bottom.
- CRect parent_bounds;
- GetParent()->GetLocalBounds(&parent_bounds, false);
+ gfx::Rect parent_bounds = GetParent()->GetLocalBounds(false);
sz = throbber_->GetPreferredSize();
int throbber_topleft_x = kPanelHorizMargin;
- int throbber_topleft_y = parent_bounds.bottom - sz.height() -
+ int throbber_topleft_y = parent_bounds.bottom() - sz.height() -
kButtonVEdgeMargin - 3;
throbber_->SetBounds(throbber_topleft_x, throbber_topleft_y,
sz.width(), sz.height());
@@ -300,7 +299,7 @@ void AboutChromeView::Layout() {
update_label_.SetHorizontalAlignment(ChromeViews::Label::ALIGN_LEFT);
update_label_.SetBounds(update_label_x,
throbber_topleft_y + 1,
- parent_bounds.Width() - update_label_x,
+ parent_bounds.width() - update_label_x,
sz.height());
}
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc
index ca3267b..f3118b5 100644
--- a/chrome/browser/views/bookmark_bar_view.cc
+++ b/chrome/browser/views/bookmark_bar_view.cc
@@ -847,8 +847,8 @@ void BookmarkBarView::Layout() {
x += other_bookmarked_pref.width() + kButtonPadding;
}
-void BookmarkBarView::DidChangeBounds(const CRect& previous,
- const CRect& current) {
+void BookmarkBarView::DidChangeBounds(const gfx::Rect& previous,
+ const gfx::Rect& current) {
Layout();
}
diff --git a/chrome/browser/views/bookmark_bar_view.h b/chrome/browser/views/bookmark_bar_view.h
index ae20fae..ee978e3 100644
--- a/chrome/browser/views/bookmark_bar_view.h
+++ b/chrome/browser/views/bookmark_bar_view.h
@@ -88,7 +88,8 @@ class BookmarkBarView : public ChromeViews::View,
// View methods:
virtual gfx::Size GetPreferredSize();
virtual void Layout();
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
+ virtual void DidChangeBounds(const gfx::Rect& previous,
+ const gfx::Rect& current);
virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
virtual void Paint(ChromeCanvas* canvas);
virtual void PaintChildren(ChromeCanvas* canvas);
diff --git a/chrome/browser/views/bookmark_bubble_view.cc b/chrome/browser/views/bookmark_bubble_view.cc
index f6021ef..7e0d0fc 100644
--- a/chrome/browser/views/bookmark_bubble_view.cc
+++ b/chrome/browser/views/bookmark_bubble_view.cc
@@ -130,8 +130,8 @@ BookmarkBubbleView::~BookmarkBubbleView() {
SetNodeTitleFromTextField();
}
-void BookmarkBubbleView::DidChangeBounds(const CRect& previous,
- const CRect& current) {
+void BookmarkBubbleView::DidChangeBounds(const gfx::Rect& previous,
+ const gfx::Rect& current) {
Layout();
}
diff --git a/chrome/browser/views/bookmark_bubble_view.h b/chrome/browser/views/bookmark_bubble_view.h
index 2b3fc9f..89594a1 100644
--- a/chrome/browser/views/bookmark_bubble_view.h
+++ b/chrome/browser/views/bookmark_bubble_view.h
@@ -43,7 +43,8 @@ class BookmarkBubbleView : public ChromeViews::View,
virtual ~BookmarkBubbleView();
// Overriden to force a layout.
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
+ virtual void DidChangeBounds(const gfx::Rect& previous,
+ const gfx::Rect& current);
// Invoked after the bubble has been shown.
virtual void BubbleShown();
diff --git a/chrome/browser/views/bookmark_editor_view.cc b/chrome/browser/views/bookmark_editor_view.cc
index b93e8a6..2c8a3cc 100644
--- a/chrome/browser/views/bookmark_editor_view.cc
+++ b/chrome/browser/views/bookmark_editor_view.cc
@@ -108,10 +108,9 @@ void BookmarkEditorView::Layout() {
// Manually lay out the New Folder button in the same row as the OK/Cancel
// buttons...
- CRect parent_bounds;
- GetParent()->GetLocalBounds(&parent_bounds, false);
+ gfx::Rect parent_bounds = GetParent()->GetLocalBounds(false);
gfx::Size prefsize = new_group_button_.GetPreferredSize();
- int button_y = parent_bounds.bottom - prefsize.height() - kButtonVEdgeMargin;
+ int button_y = parent_bounds.bottom() - prefsize.height() - kButtonVEdgeMargin;
new_group_button_.SetBounds(kPanelHorizMargin, button_y, prefsize.width(),
prefsize.height());
}
@@ -122,11 +121,6 @@ gfx::Size BookmarkEditorView::GetPreferredSize() {
IDS_EDITBOOKMARK_DIALOG_HEIGHT_LINES));
}
-void BookmarkEditorView::DidChangeBounds(const CRect& previous,
- const CRect& current) {
- Layout();
-}
-
void BookmarkEditorView::ViewHierarchyChanged(bool is_add,
ChromeViews::View* parent,
ChromeViews::View* child) {
diff --git a/chrome/browser/views/bookmark_editor_view.h b/chrome/browser/views/bookmark_editor_view.h
index 7c432d2..51f3769 100644
--- a/chrome/browser/views/bookmark_editor_view.h
+++ b/chrome/browser/views/bookmark_editor_view.h
@@ -72,7 +72,6 @@ class BookmarkEditorView : public ChromeViews::View,
// View methods.
virtual void Layout();
virtual gfx::Size GetPreferredSize();
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual void ViewHierarchyChanged(bool is_add, ChromeViews::View* parent,
ChromeViews::View* child);
diff --git a/chrome/browser/views/clear_browsing_data.cc b/chrome/browser/views/clear_browsing_data.cc
index 0bf697d..30c331f 100644
--- a/chrome/browser/views/clear_browsing_data.cc
+++ b/chrome/browser/views/clear_browsing_data.cc
@@ -176,12 +176,11 @@ void ClearBrowsingDataView::Layout() {
// Get the y-coordinate of our parent so we can position the throbber and
// status message at the bottom of the panel.
- CRect parent_bounds;
- GetParent()->GetLocalBounds(&parent_bounds, false);
+ gfx::Rect parent_bounds = GetParent()->GetLocalBounds(false);
sz = throbber_->GetPreferredSize();
int throbber_topleft_x = kPanelHorizMargin;
- int throbber_topleft_y = parent_bounds.bottom - sz.height() -
+ int throbber_topleft_y = parent_bounds.bottom() - sz.height() -
kButtonVEdgeMargin - 3;
throbber_->SetBounds(throbber_topleft_x, throbber_topleft_y, sz.width(),
sz.height());
diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc
index 11f635a..9cbd04f 100644
--- a/chrome/browser/views/constrained_window_impl.cc
+++ b/chrome/browser/views/constrained_window_impl.cc
@@ -613,7 +613,7 @@ void ConstrainedWindowNonClientView::Layout() {
location_bar_height);
location_bar_->Layout();
}
- container_->client_view()->SetBounds(client_bounds_.ToRECT());
+ container_->client_view()->SetBounds(client_bounds_);
}
gfx::Size ConstrainedWindowNonClientView::GetPreferredSize() {
diff --git a/chrome/browser/views/delay_view.cc b/chrome/browser/views/delay_view.cc
index 76c8322..a841580 100644
--- a/chrome/browser/views/delay_view.cc
+++ b/chrome/browser/views/delay_view.cc
@@ -50,14 +50,13 @@ void DelayView::Layout() {
if (!GetParent())
return;
- CSize available;
- GetParent()->GetSize(&available);
+ gfx::Size available = GetParent()->size();
if (cancel_button_) {
gfx::Size button_size = cancel_button_->GetPreferredSize();
- cancel_button_->SetBounds(available.cx - kWindowMargin -
+ cancel_button_->SetBounds(available.width() - kWindowMargin -
button_size.width(),
- available.cy - kWindowMargin -
+ available.height() - kWindowMargin -
button_size.height(),
button_size.width(), button_size.height());
}
@@ -73,8 +72,8 @@ void DelayView::Layout() {
label_size.width(),
std::max(throbber_size.height(), label_size.height()));
- main_rect.set_x((available.cx / 2) - (main_rect.width() / 2));
- main_rect.set_y((available.cy / 2) - (main_rect.height() / 2));
+ main_rect.set_x((available.width() / 2) - (main_rect.width() / 2));
+ main_rect.set_y((available.height() / 2) - (main_rect.height() / 2));
label_->SetBounds(main_rect.x() + throbber_size.width() +
kThrobberLabelSpace,
diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc
index 66f4c55..ec88049 100644
--- a/chrome/browser/views/download_item_view.cc
+++ b/chrome/browser/views/download_item_view.cc
@@ -311,11 +311,6 @@ void DownloadItemView::Layout() {
}
}
-void DownloadItemView::DidChangeBounds(const CRect& previous,
- const CRect& current) {
- Layout();
-}
-
void DownloadItemView::ButtonPressed(ChromeViews::NativeButton* sender) {
if (sender == discard_button_) {
if (download_->state() == DownloadItem::IN_PROGRESS)
@@ -790,6 +785,6 @@ void DownloadItemView::SizeLabelToMinWidth() {
if (min_width == -1)
size = dangerous_download_label_->GetPreferredSize();
- dangerous_download_label_->SetBounds(gfx::Point(), size);
+ dangerous_download_label_->SetBounds(0, 0, size.width(), size.height());
dangerous_download_label_sized_ = true;
} \ No newline at end of file
diff --git a/chrome/browser/views/download_item_view.h b/chrome/browser/views/download_item_view.h
index e67697e..0fefcea 100644
--- a/chrome/browser/views/download_item_view.h
+++ b/chrome/browser/views/download_item_view.h
@@ -69,7 +69,6 @@ class DownloadItemView : public ChromeViews::NativeButton::Listener,
virtual void OnMouseReleased(const ChromeViews::MouseEvent& event,
bool canceled);
virtual bool OnMouseDragged(const ChromeViews::MouseEvent& event);
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
// NativeButton::Listener implementation.
virtual void ButtonPressed(ChromeViews::NativeButton* sender);
diff --git a/chrome/browser/views/download_shelf_view.cc b/chrome/browser/views/download_shelf_view.cc
index a966dcc..ed6b074 100644
--- a/chrome/browser/views/download_shelf_view.cc
+++ b/chrome/browser/views/download_shelf_view.cc
@@ -177,11 +177,6 @@ gfx::Size DownloadShelfView::GetPreferredSize() {
return prefsize;
}
-void DownloadShelfView::DidChangeBounds(const CRect& previous,
- const CRect& current) {
- Layout();
-}
-
void DownloadShelfView::AnimationProgressed(const Animation *animation) {
if (animation == new_item_animation_.get()) {
Layout();
diff --git a/chrome/browser/views/download_shelf_view.h b/chrome/browser/views/download_shelf_view.h
index 0ac607d..35e5b2c 100644
--- a/chrome/browser/views/download_shelf_view.h
+++ b/chrome/browser/views/download_shelf_view.h
@@ -44,8 +44,6 @@ class DownloadShelfView : public ChromeViews::View,
// PaintBackground, PaintBorder and PaintSeparators.
virtual void Paint(ChromeCanvas* canvas);
- void DidChangeBounds(const CRect& previous, const CRect& current);
-
// AnimationDelegate implementations
virtual void AnimationProgressed(const Animation* animation);
virtual void AnimationEnded(const Animation* animation);
diff --git a/chrome/browser/views/download_tab_view.cc b/chrome/browser/views/download_tab_view.cc
index 61f5164..fb65c1f 100644
--- a/chrome/browser/views/download_tab_view.cc
+++ b/chrome/browser/views/download_tab_view.cc
@@ -670,11 +670,6 @@ void DownloadItemTabView::PaintBackground(ChromeCanvas* canvas) {
}
}
-void DownloadItemTabView::DidChangeBounds(const CRect& previous,
- const CRect& current) {
- Layout();
-}
-
bool DownloadItemTabView::OnMousePressed(const ChromeViews::MouseEvent& event) {
gfx::Point point(event.location());
@@ -819,13 +814,7 @@ void DownloadTabView::UpdateDownloadProgress() {
SchedulePaint();
}
-void DownloadTabView::DidChangeBounds(const CRect& previous,
- const CRect& current) {
- Layout();
-}
-
void DownloadTabView::Layout() {
- CRect r;
DetachAllFloatingViews();
// Dangerous downloads items use NativeButtons, so they need to be attached
// as NativeControls are not supported yet in floating views.
@@ -844,7 +833,6 @@ void DownloadTabView::Layout() {
}
View* v = GetParent();
if (v) {
- v->GetLocalBounds(&r, true);
int h = static_cast<int>(downloads_.size()) *
(download_util::kBigProgressIconSize + kSpacer) + kSpacer;
SetBounds(x(), y(), v->width(), h);
diff --git a/chrome/browser/views/download_tab_view.h b/chrome/browser/views/download_tab_view.h
index 8c59089..6152908 100644
--- a/chrome/browser/views/download_tab_view.h
+++ b/chrome/browser/views/download_tab_view.h
@@ -36,7 +36,6 @@ class DownloadItemTabView : public ChromeViews::View,
virtual void Paint(ChromeCanvas* canvas);
void PaintBackground(ChromeCanvas* canvas);
virtual gfx::Size GetPreferredSize();
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual bool OnMousePressed(const ChromeViews::MouseEvent& event);
virtual bool OnMouseDragged(const ChromeViews::MouseEvent& event);
@@ -111,7 +110,6 @@ class DownloadTabView : public ChromeViews::View,
DownloadManager* model() const { return model_; }
// View overrides
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual void Layout();
virtual void Paint(ChromeCanvas* canvas);
virtual bool GetFloatingViewIDForPoint(int x, int y, int* id);
diff --git a/chrome/browser/views/first_run_bubble.cc b/chrome/browser/views/first_run_bubble.cc
index 4dc3812b..1032a07 100644
--- a/chrome/browser/views/first_run_bubble.cc
+++ b/chrome/browser/views/first_run_bubble.cc
@@ -95,11 +95,6 @@ class FirstRunBubbleView : public ChromeViews::View,
AddChildView(change_button_);
}
- // Overridden from ChromeViews::View.
- virtual void DidChangeBounds(const CRect& previous, const CRect& current) {
- Layout();
- }
-
// Overridden from NativeButton::Listener.
virtual void ButtonPressed(ChromeViews::NativeButton* sender) {
bubble_window_->Close();
diff --git a/chrome/browser/views/frame/aero_glass_non_client_view.cc b/chrome/browser/views/frame/aero_glass_non_client_view.cc
index 5155634..65b9f9d 100644
--- a/chrome/browser/views/frame/aero_glass_non_client_view.cc
+++ b/chrome/browser/views/frame/aero_glass_non_client_view.cc
@@ -250,11 +250,6 @@ gfx::Size AeroGlassNonClientView::GetPreferredSize() {
return prefsize;
}
-void AeroGlassNonClientView::DidChangeBounds(const CRect& previous,
- const CRect& current) {
- Layout();
-}
-
void AeroGlassNonClientView::ViewHierarchyChanged(bool is_add,
ChromeViews::View* parent,
ChromeViews::View* child) {
@@ -413,9 +408,8 @@ void AeroGlassNonClientView::LayoutDistributorLogo() {
}
void AeroGlassNonClientView::LayoutClientView() {
- gfx::Rect client_bounds(
- CalculateClientAreaBounds(width(), height()));
- frame_->client_view()->SetBounds(client_bounds.ToRECT());
+ gfx::Rect client_bounds = CalculateClientAreaBounds(width(), height());
+ frame_->client_view()->SetBounds(client_bounds);
}
// static
diff --git a/chrome/browser/views/frame/aero_glass_non_client_view.h b/chrome/browser/views/frame/aero_glass_non_client_view.h
index 2412a63..2814918 100644
--- a/chrome/browser/views/frame/aero_glass_non_client_view.h
+++ b/chrome/browser/views/frame/aero_glass_non_client_view.h
@@ -34,7 +34,6 @@ class AeroGlassNonClientView : public ChromeViews::NonClientView {
virtual void Paint(ChromeCanvas* canvas);
virtual void Layout();
virtual gfx::Size GetPreferredSize();
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual void ViewHierarchyChanged(bool is_add,
ChromeViews::View* parent,
ChromeViews::View* child);
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 5a8b495..7e8303d 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -220,11 +220,6 @@ void BrowserView::Layout() {
toolbar_->SetBounds(0, 0, width(), height());
}
-void BrowserView::DidChangeBounds(const CRect& previous,
- const CRect& current) {
- Layout();
-}
-
void BrowserView::ViewHierarchyChanged(bool is_add,
ChromeViews::View* parent,
ChromeViews::View* child) {
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index 5d48fc7..704d6a7 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -79,7 +79,6 @@ class BrowserView : public BrowserWindow,
// Overridden from ChromeViews::View:
virtual void Layout();
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual void ViewHierarchyChanged(bool is_add,
ChromeViews::View* parent,
ChromeViews::View* child);
diff --git a/chrome/browser/views/frame/browser_view2.cc b/chrome/browser/views/frame/browser_view2.cc
index f3f8800..c1e3588 100644
--- a/chrome/browser/views/frame/browser_view2.cc
+++ b/chrome/browser/views/frame/browser_view2.cc
@@ -782,11 +782,6 @@ void BrowserView2::Layout() {
SchedulePaint();
}
-void BrowserView2::DidChangeBounds(const CRect& previous,
- const CRect& current) {
- Layout();
-}
-
void BrowserView2::ViewHierarchyChanged(bool is_add,
ChromeViews::View* parent,
ChromeViews::View* child) {
@@ -1046,7 +1041,7 @@ bool BrowserView2::UpdateChildViewAndLayout(ChromeViews::View* new_view,
} else if (new_view && *old_view) {
// The view changed, but the new view wants the same size, give it the
// bounds of the last view and have it repaint.
- new_view->SetBounds((*old_view)->bounds().ToRECT());
+ new_view->SetBounds((*old_view)->bounds());
new_view->SchedulePaint();
} else if (new_view) {
DCHECK(new_height == 0);
diff --git a/chrome/browser/views/frame/browser_view2.h b/chrome/browser/views/frame/browser_view2.h
index 6f1329d..dbe4f5d 100644
--- a/chrome/browser/views/frame/browser_view2.h
+++ b/chrome/browser/views/frame/browser_view2.h
@@ -221,7 +221,6 @@ class BrowserView2 : public BrowserWindow,
protected:
// Overridden from ChromeViews::View:
virtual void Layout();
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual void ViewHierarchyChanged(bool is_add,
ChromeViews::View* parent,
ChromeViews::View* child);
diff --git a/chrome/browser/views/frame/opaque_non_client_view.cc b/chrome/browser/views/frame/opaque_non_client_view.cc
index 72b2215..ac29c56 100644
--- a/chrome/browser/views/frame/opaque_non_client_view.cc
+++ b/chrome/browser/views/frame/opaque_non_client_view.cc
@@ -651,11 +651,6 @@ ChromeViews::View* OpaqueNonClientView::GetViewForPoint(
return View::GetViewForPoint(point, can_create_floating);
}
-void OpaqueNonClientView::DidChangeBounds(const CRect& previous,
- const CRect& current) {
- Layout();
-}
-
void OpaqueNonClientView::ViewHierarchyChanged(bool is_add,
ChromeViews::View* parent,
ChromeViews::View* child) {
@@ -1007,13 +1002,12 @@ void OpaqueNonClientView::LayoutTitleBar() {
// Do this last, after the icon has been moved.
if (window_icon_)
- window_icon_->SetBounds(icon_bounds_.ToRECT());
+ window_icon_->SetBounds(icon_bounds_);
}
void OpaqueNonClientView::LayoutClientView() {
- gfx::Rect client_bounds(
- CalculateClientAreaBounds(width(), height()));
- frame_->client_view()->SetBounds(client_bounds.ToRECT());
+ gfx::Rect client_bounds = CalculateClientAreaBounds(width(), height());
+ frame_->client_view()->SetBounds(client_bounds);
}
// static
diff --git a/chrome/browser/views/frame/opaque_non_client_view.h b/chrome/browser/views/frame/opaque_non_client_view.h
index 5b9bc54..830ba76 100644
--- a/chrome/browser/views/frame/opaque_non_client_view.h
+++ b/chrome/browser/views/frame/opaque_non_client_view.h
@@ -59,7 +59,6 @@ class OpaqueNonClientView : public ChromeViews::NonClientView,
virtual gfx::Size GetPreferredSize();
virtual ChromeViews::View* GetViewForPoint(const gfx::Point& point,
bool can_create_floating);
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual void ViewHierarchyChanged(bool is_add,
ChromeViews::View* parent,
ChromeViews::View* child);
diff --git a/chrome/browser/views/hung_renderer_view.cc b/chrome/browser/views/hung_renderer_view.cc
index bd0c289..895c4dd 100644
--- a/chrome/browser/views/hung_renderer_view.cc
+++ b/chrome/browser/views/hung_renderer_view.cc
@@ -161,10 +161,6 @@ class HungRendererWarningView : public ChromeViews::View,
public:
ButtonContainer() {}
virtual ~ButtonContainer() {}
-
- virtual void DidChangeBounds(const CRect& previous, const CRect& current) {
- Layout();
- }
private:
DISALLOW_EVIL_CONSTRUCTORS(ButtonContainer);
};
diff --git a/chrome/browser/views/info_bar_item_view.cc b/chrome/browser/views/info_bar_item_view.cc
index b7c0d3b..71b5c4e 100644
--- a/chrome/browser/views/info_bar_item_view.cc
+++ b/chrome/browser/views/info_bar_item_view.cc
@@ -132,8 +132,8 @@ void InfoBarItemView::Layout() {
}
}
-void InfoBarItemView::DidChangeBounds(const CRect& previous,
- const CRect& current) {
+void InfoBarItemView::DidChangeBounds(const gfx::Rect& previous,
+ const gfx::Rect& current) {
if (GetParent() != NULL)
Layout();
}
diff --git a/chrome/browser/views/info_bar_item_view.h b/chrome/browser/views/info_bar_item_view.h
index c5b99ab..4e38e7c 100644
--- a/chrome/browser/views/info_bar_item_view.h
+++ b/chrome/browser/views/info_bar_item_view.h
@@ -48,7 +48,8 @@ class InfoBarItemView : public ChromeViews::View,
// Lays out all child views of the info bar from trailing to leading.
virtual void Layout();
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
+ virtual void DidChangeBounds(const gfx::Rect& previous,
+ const gfx::Rect& current);
// Starts the close animation, which will end in the bar closing itself.
void BeginClose();
diff --git a/chrome/browser/views/info_bar_view.cc b/chrome/browser/views/info_bar_view.cc
index a5955a2..3d69eaa 100644
--- a/chrome/browser/views/info_bar_view.cc
+++ b/chrome/browser/views/info_bar_view.cc
@@ -93,11 +93,6 @@ void InfoBarView::Paint(ChromeCanvas* canvas) {
PaintSeparators(canvas);
}
-void InfoBarView::DidChangeBounds(const CRect& previous,
- const CRect& current) {
- Layout();
-}
-
void InfoBarView::ChildAnimationProgressed() {
if (web_contents_)
web_contents_->ToolbarSizeChanged(true);
diff --git a/chrome/browser/views/info_bar_view.h b/chrome/browser/views/info_bar_view.h
index 52a91c5..6091867 100644
--- a/chrome/browser/views/info_bar_view.h
+++ b/chrome/browser/views/info_bar_view.h
@@ -42,8 +42,6 @@ class InfoBarView : public ChromeViews::View,
// PaintBackground, PaintBorder and PaintSeparators.
virtual void Paint(ChromeCanvas* canvas);
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
-
WebContents* web_contents() { return web_contents_; }
protected:
diff --git a/chrome/browser/views/info_bubble.h b/chrome/browser/views/info_bubble.h
index bb8933b..1c49a8d 100644
--- a/chrome/browser/views/info_bubble.h
+++ b/chrome/browser/views/info_bubble.h
@@ -112,10 +112,6 @@ class InfoBubble : public ChromeViews::ContainerWin,
// Positions the content relative to the border.
virtual void Layout();
- virtual void DidChangeBounds(const CRect& previous, const CRect& current) {
- Layout();
- }
-
// Return the mask for the content view.
HRGN GetMask(const CSize& size);
diff --git a/chrome/browser/views/keyword_editor_view.cc b/chrome/browser/views/keyword_editor_view.cc
index a49801a..043a9c6 100644
--- a/chrome/browser/views/keyword_editor_view.cc
+++ b/chrome/browser/views/keyword_editor_view.cc
@@ -421,11 +421,6 @@ void KeywordEditorView::ModifyTemplateURL(const TemplateURL* template_url,
UserMetrics::RecordAction(L"KeywordEditor_ModifiedKeyword", profile_);
}
-void KeywordEditorView::DidChangeBounds(const CRect& previous,
- const CRect& current) {
- Layout();
-}
-
gfx::Size KeywordEditorView::GetPreferredSize() {
return gfx::Size(ChromeViews::Window::GetLocalizedContentsSize(
IDS_SEARCHENGINES_DIALOG_WIDTH_CHARS,
diff --git a/chrome/browser/views/keyword_editor_view.h b/chrome/browser/views/keyword_editor_view.h
index 41773ad..2d5b809 100644
--- a/chrome/browser/views/keyword_editor_view.h
+++ b/chrome/browser/views/keyword_editor_view.h
@@ -146,7 +146,6 @@ class KeywordEditorView : public ChromeViews::View,
const std::wstring& url);
// Overriden to invoke Layout.
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual gfx::Size GetPreferredSize();
// DialogDelegate methods:
diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc
index 51081bd..bd9774c 100644
--- a/chrome/browser/views/location_bar_view.cc
+++ b/chrome/browser/views/location_bar_view.cc
@@ -213,11 +213,6 @@ gfx::Size LocationBarView::GetPreferredSize() {
security_image_view_.GetPreferredSize().width()));
}
-void LocationBarView::DidChangeBounds(const CRect& previous,
- const CRect& current) {
- Layout();
-}
-
void LocationBarView::Layout() {
DoLayout(true);
}
@@ -646,12 +641,6 @@ gfx::Size LocationBarView::SelectedKeywordView::GetMinimumSize() {
return partial_label_.GetMinimumSize();
}
-void LocationBarView::SelectedKeywordView::DidChangeBounds(
- const CRect& previous,
- const CRect& current) {
- Layout();
-}
-
void LocationBarView::SelectedKeywordView::Layout() {
gfx::Size pref = GetPreferredSize();
bool at_pref = (width() == pref.width());
@@ -804,11 +793,6 @@ void LocationBarView::KeywordHintView::Layout() {
}
}
-void LocationBarView::KeywordHintView::DidChangeBounds(const CRect& previous,
- const CRect& current) {
- Layout();
-}
-
// We don't translate accelerators for ALT + numpad digit, they are used for
// entering special characters.
bool LocationBarView::ShouldLookupAccelerators(const ChromeViews::KeyEvent& e) {
diff --git a/chrome/browser/views/location_bar_view.h b/chrome/browser/views/location_bar_view.h
index cec73af..2c138f5 100644
--- a/chrome/browser/views/location_bar_view.h
+++ b/chrome/browser/views/location_bar_view.h
@@ -70,7 +70,6 @@ class LocationBarView : public ChromeViews::View,
virtual gfx::Size GetPreferredSize();
// Layout and Painting functions
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual void Layout();
virtual void Paint(ChromeCanvas* canvas);
@@ -155,7 +154,6 @@ class LocationBarView : public ChromeViews::View,
virtual gfx::Size GetPreferredSize();
virtual gfx::Size GetMinimumSize();
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual void Layout();
// The current keyword, or an empty string if no keyword is displayed.
@@ -212,8 +210,7 @@ class LocationBarView : public ChromeViews::View,
// The minimum size is just big enough to show the tab.
virtual gfx::Size GetMinimumSize();
virtual void Layout();
- void DidChangeBounds(const CRect& previous, const CRect& current);
-
+
void set_profile(Profile* profile) { profile_ = profile; }
private:
diff --git a/chrome/browser/views/old_frames/vista_frame.cc b/chrome/browser/views/old_frames/vista_frame.cc
index fe1f0b4..d381731 100644
--- a/chrome/browser/views/old_frames/vista_frame.cc
+++ b/chrome/browser/views/old_frames/vista_frame.cc
@@ -1471,7 +1471,7 @@ bool VistaFrame::UpdateChildViewAndLayout(ChromeViews::View* new_view,
} else if (new_view && *view) {
// The view changed, but the new view wants the same size, give it the
// bounds of the last view and have it repaint.
- new_view->SetBounds((*view)->bounds().ToRECT());
+ new_view->SetBounds((*view)->bounds());
new_view->SchedulePaint();
} else if (new_view) {
DCHECK(new_height == 0);
diff --git a/chrome/browser/views/old_frames/xp_frame.cc b/chrome/browser/views/old_frames/xp_frame.cc
index 24f614d..4fddbe8 100644
--- a/chrome/browser/views/old_frames/xp_frame.cc
+++ b/chrome/browser/views/old_frames/xp_frame.cc
@@ -2328,7 +2328,7 @@ bool XPFrame::UpdateChildViewAndLayout(ChromeViews::View* new_view,
} else if (new_view && *view) {
// The view changed, but the new view wants the same size, give it the
// bounds of the last view and have it repaint.
- new_view->SetBounds((*view)->bounds().ToRECT());
+ new_view->SetBounds((*view)->bounds());
new_view->SchedulePaint();
} else if (new_view) {
DCHECK(new_height == 0);
diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc
index a6fbec6..b8a759c 100644
--- a/chrome/browser/views/options/advanced_contents_view.cc
+++ b/chrome/browser/views/options/advanced_contents_view.cc
@@ -61,9 +61,8 @@ class ListBackground : public ChromeViews::Background {
virtual void Paint(ChromeCanvas* canvas, ChromeViews::View* view) const {
HDC dc = canvas->beginPlatformPaint();
- CRect lb;
- view->GetLocalBounds(&lb, true);
- gfx::NativeTheme::instance()->PaintListBackground(dc, true, &lb);
+ RECT native_lb = view->GetLocalBounds(true).ToRECT();
+ gfx::NativeTheme::instance()->PaintListBackground(dc, true, &native_lb);
canvas->endPlatformPaint();
}
@@ -82,7 +81,8 @@ class AdvancedSection : public OptionsPageView {
AdvancedSection(Profile* profile, const std::wstring& title);
virtual ~AdvancedSection() {}
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
+ virtual void DidChangeBounds(const gfx::Rect& previous,
+ const gfx::Rect& current);
protected:
// Convenience helpers to add different kinds of ColumnSets for specific
@@ -151,8 +151,8 @@ AdvancedSection::AdvancedSection(Profile* profile,
title_label_->SetColor(title_color);
}
-void AdvancedSection::DidChangeBounds(const CRect& previous,
- const CRect& current) {
+void AdvancedSection::DidChangeBounds(const gfx::Rect& previous,
+ const gfx::Rect& current) {
Layout();
contents_->Layout();
}
@@ -1077,7 +1077,9 @@ class AdvancedContentsView : public OptionsPageView {
// ChromeViews::View overrides:
virtual int GetLineScrollIncrement(ChromeViews::ScrollView* scroll_view,
bool is_horizontal, bool is_positive);
- void Layout();
+ virtual void Layout();
+ virtual void DidChangeBounds(const gfx::Rect& previous,
+ const gfx::Rect& current);
protected:
// OptionsPageView implementation:
@@ -1125,11 +1127,18 @@ void AdvancedContentsView::Layout() {
const int height = GetHeightForWidth(width);
SetBounds(0, 0, width, height);
} else {
- SetBounds(gfx::Point(), GetPreferredSize());
+ gfx::Size prefsize = GetPreferredSize();
+ SetBounds(0, 0, prefsize.width(), prefsize.height());
}
View::Layout();
}
+void AdvancedContentsView::DidChangeBounds(const gfx::Rect& previous,
+ const gfx::Rect& current) {
+ // Override to do nothing. Calling Layout() interferes with our scrolling.
+}
+
+
////////////////////////////////////////////////////////////////////////////////
// AdvancedContentsView, OptionsPageView implementation:
@@ -1185,12 +1194,11 @@ AdvancedScrollViewContainer::~AdvancedScrollViewContainer() {
// AdvancedScrollViewContainer, ChromeViews::View overrides:
void AdvancedScrollViewContainer::Layout() {
- CRect lb;
- GetLocalBounds(&lb, false);
+ gfx::Rect lb = GetLocalBounds(false);
gfx::Size border = gfx::NativeTheme::instance()->GetThemeBorderSize(
gfx::NativeTheme::LIST);
- lb.DeflateRect(border.ToSIZE());
+ lb.Inset(border.width(), border.height());
scroll_view_->SetBounds(lb);
scroll_view_->Layout();
}
diff --git a/chrome/browser/views/options/cookies_view.cc b/chrome/browser/views/options/cookies_view.cc
index cf0d5ee..41a8968 100644
--- a/chrome/browser/views/options/cookies_view.cc
+++ b/chrome/browser/views/options/cookies_view.cc
@@ -642,9 +642,8 @@ ChromeViews::View* CookiesView::GetContentsView() {
void CookiesView::Layout() {
// Lay out the Remove/Remove All buttons in the parent view.
gfx::Size ps = remove_button_->GetPreferredSize();
- CRect parent_bounds;
- GetParent()->GetLocalBounds(&parent_bounds, false);
- int y_buttons = parent_bounds.bottom - ps.height() - kButtonVEdgeMargin;
+ gfx::Rect parent_bounds = GetParent()->GetLocalBounds(false);
+ int y_buttons = parent_bounds.bottom() - ps.height() - kButtonVEdgeMargin;
remove_button_->SetBounds(kPanelHorizMargin, y_buttons, ps.width(),
ps.height());
diff --git a/chrome/browser/views/options/options_group_view.h b/chrome/browser/views/options/options_group_view.h
index d40239d..e1d98d1 100644
--- a/chrome/browser/views/options/options_group_view.h
+++ b/chrome/browser/views/options/options_group_view.h
@@ -32,20 +32,6 @@ class OptionsGroupView : public ChromeViews::View {
// Retrieves the width of the ContentsView. Used to help size wrapping items.
int GetContentsWidth() const;
- class ContentsView : public ChromeViews::View {
- public:
- virtual ~ContentsView() {}
-
- // ChromeViews::View overrides:
- virtual void DidChangeBounds(const CRect& prev_bounds,
- const CRect& next_bounds) {
- Layout();
- }
-
- private:
- DISALLOW_EVIL_CONSTRUCTORS(ContentsView);
- };
-
protected:
// ChromeViews::View overrides:
virtual void Paint(ChromeCanvas* canvas);
diff --git a/chrome/browser/views/page_info_window.cc b/chrome/browser/views/page_info_window.cc
index 79e697a..3a45c3f 100644
--- a/chrome/browser/views/page_info_window.cc
+++ b/chrome/browser/views/page_info_window.cc
@@ -450,9 +450,9 @@ class PageInfoContentView : public ChromeViews::View {
if (cert_viewer_button_) {
gfx::Size ps = cert_viewer_button_->GetPreferredSize();
- CRect parent_bounds;
- GetParent()->GetLocalBounds(&parent_bounds, false);
- int y_buttons = parent_bounds.bottom - ps.height() - kButtonVEdgeMargin;
+ gfx::Rect parent_bounds = GetParent()->GetLocalBounds(false);
+ int y_buttons =
+ parent_bounds.bottom() - ps.height() - kButtonVEdgeMargin;
cert_viewer_button_->SetBounds(kPanelHorizMargin, y_buttons, ps.width(),
ps.height());
}
diff --git a/chrome/browser/views/password_manager_view.cc b/chrome/browser/views/password_manager_view.cc
index e39d67b..13965eb 100644
--- a/chrome/browser/views/password_manager_view.cc
+++ b/chrome/browser/views/password_manager_view.cc
@@ -293,10 +293,10 @@ void PasswordManagerView::Layout() {
// Manually lay out the Remove All button in the same row as
// the close button.
- CRect parent_bounds;
- GetParent()->GetLocalBounds(&parent_bounds, false);
+ gfx::Rect parent_bounds = GetParent()->GetLocalBounds(false);
gfx::Size prefsize = remove_all_button_.GetPreferredSize();
- int button_y = parent_bounds.bottom - prefsize.height() - kButtonVEdgeMargin;
+ int button_y =
+ parent_bounds.bottom() - prefsize.height() - kButtonVEdgeMargin;
remove_all_button_.SetBounds(kPanelHorizMargin, button_y, prefsize.width(),
prefsize.height());
}
diff --git a/chrome/browser/views/sad_tab_view.cc b/chrome/browser/views/sad_tab_view.cc
index dbcfbfe..7b34bcb 100644
--- a/chrome/browser/views/sad_tab_view.cc
+++ b/chrome/browser/views/sad_tab_view.cc
@@ -88,10 +88,6 @@ void SadTabView::Layout() {
message_bounds_.SetRect(message_x, message_y, message_width, message_height);
}
-void SadTabView::DidChangeBounds(const CRect&, const CRect&) {
- Layout();
-}
-
// static
void SadTabView::InitClass() {
static bool initialized = false;
diff --git a/chrome/browser/views/sad_tab_view.h b/chrome/browser/views/sad_tab_view.h
index 2486224..4f27199 100644
--- a/chrome/browser/views/sad_tab_view.h
+++ b/chrome/browser/views/sad_tab_view.h
@@ -31,7 +31,6 @@ class SadTabView : public ChromeViews::View {
// Overridden from ChromeViews::View:
virtual void Paint(ChromeCanvas* canvas);
virtual void Layout();
- virtual void DidChangeBounds(const CRect&, const CRect&);
private:
static void InitClass();
diff --git a/chrome/browser/views/shelf_item_dialog.cc b/chrome/browser/views/shelf_item_dialog.cc
index 306922f..7e1db6b 100644
--- a/chrome/browser/views/shelf_item_dialog.cc
+++ b/chrome/browser/views/shelf_item_dialog.cc
@@ -480,11 +480,6 @@ bool ShelfItemDialog::AcceleratorPressed(
return true;
}
-void ShelfItemDialog::DidChangeBounds(const CRect& previous,
- const CRect& current) {
- Layout();
-}
-
void ShelfItemDialog::OnSelectionChanged() {
int selection = url_table_->FirstSelectedRow();
if (selection >= 0 && selection < url_table_model_->RowCount()) {
diff --git a/chrome/browser/views/shelf_item_dialog.h b/chrome/browser/views/shelf_item_dialog.h
index 744e6f6..6c0c587 100644
--- a/chrome/browser/views/shelf_item_dialog.h
+++ b/chrome/browser/views/shelf_item_dialog.h
@@ -73,7 +73,6 @@ class ShelfItemDialog : public ChromeViews::View,
UINT flags) {}
// Overridden from View.
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual gfx::Size GetPreferredSize();
virtual bool AcceleratorPressed(const ChromeViews::Accelerator& accelerator);
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc
index b174dc8..cdbcd98 100644
--- a/chrome/browser/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/views/tabs/dragged_tab_controller.cc
@@ -727,10 +727,9 @@ gfx::Rect DraggedTabController::GetViewScreenBounds(
ChromeViews::View* view) const {
gfx::Point view_topleft;
ChromeViews::View::ConvertPointToScreen(view, &view_topleft);
- CRect view_screen_bounds;
- view->GetLocalBounds(&view_screen_bounds, true);
- view_screen_bounds.OffsetRect(view_topleft.ToPOINT());
- return gfx::Rect(view_screen_bounds);
+ gfx::Rect view_screen_bounds = view->GetLocalBounds(true);
+ view_screen_bounds.Offset(view_topleft.x(), view_topleft.y());
+ return view_screen_bounds;
}
int DraggedTabController::NormalizeIndexToAttachedTabStrip(int index) const {
diff --git a/chrome/browser/views/tabs/dragged_tab_view.cc b/chrome/browser/views/tabs/dragged_tab_view.cc
index 2c326ba..ecbcadc 100644
--- a/chrome/browser/views/tabs/dragged_tab_view.cc
+++ b/chrome/browser/views/tabs/dragged_tab_view.cc
@@ -150,13 +150,14 @@ void DraggedTabView::Paint(ChromeCanvas* canvas) {
void DraggedTabView::Layout() {
if (attached_) {
- renderer_->SetBounds(gfx::Point(), GetPreferredSize());
+ gfx::Size prefsize = GetPreferredSize();
+ renderer_->SetBounds(0, 0, prefsize.width(), prefsize.height());
} else {
int left = 0;
if (UILayoutIsRightToLeft())
left = GetPreferredSize().width() - attached_tab_size_.width();
- renderer_->SetBounds(CRect(left, 0, left + attached_tab_size_.width(),
- attached_tab_size_.height()));
+ renderer_->SetBounds(left, 0, left + attached_tab_size_.width(),
+ attached_tab_size_.height());
}
}
diff --git a/chrome/browser/views/tabs/tab_renderer.cc b/chrome/browser/views/tabs/tab_renderer.cc
index 876c57e..99548a0 100644
--- a/chrome/browser/views/tabs/tab_renderer.cc
+++ b/chrome/browser/views/tabs/tab_renderer.cc
@@ -439,15 +439,10 @@ void TabRenderer::Paint(ChromeCanvas* canvas) {
}
void TabRenderer::Layout() {
- CRect lb;
- GetLocalBounds(&lb, false);
- if (lb.IsRectEmpty())
+ gfx::Rect lb = GetLocalBounds(false);
+ if (lb.IsEmpty())
return;
-
- lb.left += kLeftPadding;
- lb.top += kTopPadding;
- lb.bottom -= kBottomPadding;
- lb.right -= kRightPadding;
+ lb.Inset(kLeftPadding, kTopPadding, kRightPadding, kBottomPadding);
// First of all, figure out who is tallest.
int content_height = GetContentHeight();
@@ -456,17 +451,17 @@ void TabRenderer::Layout() {
showing_icon_ = ShouldShowIcon();
if (showing_icon_) {
int favicon_top = kTopPadding + (content_height - kFaviconSize) / 2;
- favicon_bounds_.SetRect(lb.left, favicon_top, kFaviconSize, kFaviconSize);
+ favicon_bounds_.SetRect(lb.x(), favicon_top, kFaviconSize, kFaviconSize);
} else {
- favicon_bounds_.SetRect(lb.left, lb.top, 0, 0);
+ favicon_bounds_.SetRect(lb.x(), lb.y(), 0, 0);
}
// Size the download icon.
showing_download_icon_ = data_.show_download_icon;
if (showing_download_icon_) {
- int icon_top = kTopPadding + (content_height - download_icon_height) / 2;
- download_icon_bounds_.SetRect(lb.Width() - download_icon_width, icon_top,
- download_icon_width, download_icon_height);
+ int icon_top = kTopPadding + (content_height - download_icon_height) / 2;
+ download_icon_bounds_.SetRect(lb.width() - download_icon_width, icon_top,
+ download_icon_width, download_icon_height);
}
// Size the Close button.
@@ -476,7 +471,7 @@ void TabRenderer::Layout() {
kTopPadding + kCloseButtonVertFuzz +
(content_height - close_button_height) / 2;
// If the ratio of the close button size to tab width exceeds the maximum.
- close_button_->SetBounds(lb.Width() + kCloseButtonHorzFuzz,
+ close_button_->SetBounds(lb.width() + kCloseButtonHorzFuzz,
close_button_top, close_button_width,
close_button_height);
close_button_->SetVisible(true);
@@ -502,7 +497,7 @@ void TabRenderer::Layout() {
title_width = std::max(close_button_->x() -
kTitleCloseButtonSpacing - title_left, 0);
} else {
- title_width = std::max(lb.Width() - title_left, 0);
+ title_width = std::max(lb.width() - title_left, 0);
}
if (data_.show_download_icon)
title_width = std::max(title_width - download_icon_width, 0);
@@ -521,12 +516,6 @@ void TabRenderer::Layout() {
download_icon_bounds_.set_x(MirroredLeftPointForRect(download_icon_bounds_));
}
-void TabRenderer::DidChangeBounds(const CRect& previous,
- const CRect& current) {
- Layout();
-}
-
-
void TabRenderer::OnMouseEntered(const ChromeViews::MouseEvent& e) {
hover_animation_->SetTweenType(SlideAnimation::EASE_OUT);
hover_animation_->Show();
diff --git a/chrome/browser/views/tabs/tab_renderer.h b/chrome/browser/views/tabs/tab_renderer.h
index 1c0a9f5..a956b1b 100644
--- a/chrome/browser/views/tabs/tab_renderer.h
+++ b/chrome/browser/views/tabs/tab_renderer.h
@@ -74,7 +74,6 @@ class TabRenderer : public ChromeViews::View,
// Overridden from ChromeViews::View:
virtual void Paint(ChromeCanvas* canvas);
virtual void Layout();
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual void OnMouseEntered(const ChromeViews::MouseEvent& event);
virtual void OnMouseExited(const ChromeViews::MouseEvent& event);
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index c4e1371..f487074 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -633,10 +633,6 @@ void TabStrip::PaintChildren(ChromeCanvas* canvas) {
newtab_button_->ProcessPaint(canvas);
}
-void TabStrip::DidChangeBounds(const CRect& prev, const CRect& curr) {
- Layout();
-}
-
// Overridden to support automation. See automation_proxy_uitest.cc.
ChromeViews::View* TabStrip::GetViewByID(int view_id) const {
if (GetTabCount() > 0) {
@@ -1235,17 +1231,16 @@ void TabStrip::ResizeLayoutTabs() {
}
bool TabStrip::IsCursorInTabStripZone() {
- CRect bounds;
- GetLocalBounds(&bounds, true);
- gfx::Point tabstrip_topleft(bounds.TopLeft());
+ gfx::Rect bounds = GetLocalBounds(true);
+ gfx::Point tabstrip_topleft(bounds.origin());
View::ConvertPointToScreen(this, &tabstrip_topleft);
- bounds.MoveToXY(tabstrip_topleft.ToPOINT());
- bounds.bottom += kTabStripAnimationVSlop;
+ bounds.set_origin(tabstrip_topleft);
+ bounds.set_height(bounds.height() + kTabStripAnimationVSlop);
CPoint cursor_point;
GetCursorPos(&cursor_point);
- return !!bounds.PtInRect(cursor_point);
+ return bounds.Contains(cursor_point.x, cursor_point.y);
}
void TabStrip::AddMessageLoopObserver() {
diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h
index b00268db..3f464a8 100644
--- a/chrome/browser/views/tabs/tab_strip.h
+++ b/chrome/browser/views/tabs/tab_strip.h
@@ -98,7 +98,6 @@ class TabStrip : public ChromeViews::View,
// ChromeViews::View overrides:
virtual void PaintChildren(ChromeCanvas* canvas);
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual ChromeViews::View* GetViewByID(int id) const;
virtual void Layout();
virtual gfx::Size GetPreferredSize();
diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc
index 45d4354..0554b06 100644
--- a/chrome/browser/views/toolbar_view.cc
+++ b/chrome/browser/views/toolbar_view.cc
@@ -342,11 +342,6 @@ void BrowserToolbarView::Layout() {
}
}
-void BrowserToolbarView::DidChangeBounds(const CRect& previous,
- const CRect& current) {
- Layout();
-}
-
void BrowserToolbarView::DidGainFocus() {
// Find first accessible child (-1 for start search at parent).
int first_acc_child = GetNextAccessibleViewIndex(-1, false);
diff --git a/chrome/browser/views/toolbar_view.h b/chrome/browser/views/toolbar_view.h
index aa4040f..104dcfae 100644
--- a/chrome/browser/views/toolbar_view.h
+++ b/chrome/browser/views/toolbar_view.h
@@ -47,7 +47,6 @@ class BrowserToolbarView : public ChromeViews::View,
// ChromeViews::View
virtual void Layout();
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual void DidGainFocus();
virtual void WillLoseFocus();
virtual bool OnKeyPressed(const ChromeViews::KeyEvent& e);
diff --git a/chrome/browser/web_contents_view_win.cc b/chrome/browser/web_contents_view_win.cc
index 4891b6f..44eb993 100644
--- a/chrome/browser/web_contents_view_win.cc
+++ b/chrome/browser/web_contents_view_win.cc
@@ -262,7 +262,7 @@ void WebContentsViewWin::OnPaint(HDC junk_dc) {
web_contents_->sad_tab_.reset(new SadTabView);
CRect cr;
GetClientRect(&cr);
- web_contents_->sad_tab_->SetBounds(cr);
+ web_contents_->sad_tab_->SetBounds(gfx::Rect(cr));
ChromeCanvasPaint canvas(GetHWND(), true);
web_contents_->sad_tab_->ProcessPaint(&canvas);
return;
diff --git a/chrome/views/bitmap_scroll_bar.cc b/chrome/views/bitmap_scroll_bar.cc
index 87b1c5a..117397f 100644
--- a/chrome/views/bitmap_scroll_bar.cc
+++ b/chrome/views/bitmap_scroll_bar.cc
@@ -98,7 +98,7 @@ class BitmapScrollBarThumb : public View {
} else {
thumb_bounds.set_height(size);
}
- SetBounds(thumb_bounds.ToRECT());
+ SetBounds(thumb_bounds);
}
// Retrieves the size (width or height) of the thumb.
@@ -117,7 +117,7 @@ class BitmapScrollBarThumb : public View {
} else {
thumb_bounds.set_x(track_bounds.y() + position);
}
- SetBounds(thumb_bounds.ToRECT());
+ SetBounds(thumb_bounds);
}
// Gets the position of the thumb on the x or y axis.
@@ -401,7 +401,7 @@ void BitmapScrollBar::Layout() {
// Size and place the two scroll buttons.
if (show_scroll_buttons_) {
gfx::Size prefsize = prev_button_->GetPreferredSize();
- prev_button_->SetBounds(gfx::Point(), prefsize);
+ prev_button_->SetBounds(0, 0, prefsize.width(), prefsize.height());
prefsize = next_button_->GetPreferredSize();
if (IsHorizontal()) {
next_button_->SetBounds(width() - prefsize.width(), 0, prefsize.width(),
@@ -441,11 +441,6 @@ void BitmapScrollBar::Layout() {
}
}
-void BitmapScrollBar::DidChangeBounds(const CRect& previous,
- const CRect& current) {
- Layout();
-}
-
bool BitmapScrollBar::OnMousePressed(const MouseEvent& event) {
if (event.IsOnlyLeftMouseButton()) {
SetThumbTrackState(BaseButton::BS_PUSHED);
diff --git a/chrome/views/bitmap_scroll_bar.h b/chrome/views/bitmap_scroll_bar.h
index 03f2a9a..24a1a18 100644
--- a/chrome/views/bitmap_scroll_bar.h
+++ b/chrome/views/bitmap_scroll_bar.h
@@ -90,7 +90,6 @@ class BitmapScrollBar : public ScrollBar,
virtual gfx::Size GetPreferredSize();
virtual void Paint(ChromeCanvas* canvas);
virtual void Layout();
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual bool OnMousePressed(const MouseEvent& event);
virtual void OnMouseReleased(const MouseEvent& event, bool canceled);
virtual bool OnMouseWheel(const MouseWheelEvent& event);
diff --git a/chrome/views/button_dropdown.cc b/chrome/views/button_dropdown.cc
index bea4001..00d9cdc 100644
--- a/chrome/views/button_dropdown.cc
+++ b/chrome/views/button_dropdown.cc
@@ -107,15 +107,14 @@ bool ButtonDropDown::OnMouseDragged(const ChromeViews::MouseEvent& e) {
void ButtonDropDown::ShowDropDownMenu(HWND window) {
if (menu_delegate_) {
- CRect lb;
- GetLocalBounds(&lb, true);
+ gfx::Rect lb = GetLocalBounds(true);
// Both the menu position and the menu anchor type change if the UI layout
// is right-to-left.
- gfx::Point menu_position(lb.TopLeft());
- menu_position.Offset(0, lb.Height() - 1);
+ gfx::Point menu_position(lb.origin());
+ menu_position.Offset(0, lb.height() - 1);
if (UILayoutIsRightToLeft())
- menu_position.Offset(lb.Width() - 1, 0);
+ menu_position.Offset(lb.width() - 1, 0);
Menu::AnchorPoint anchor = Menu::TOPLEFT;
if (UILayoutIsRightToLeft())
diff --git a/chrome/views/checkbox.cc b/chrome/views/checkbox.cc
index ebfa179..192dbaf 100644
--- a/chrome/views/checkbox.cc
+++ b/chrome/views/checkbox.cc
@@ -61,7 +61,7 @@ std::string CheckBox::GetClassName() const {
void CheckBox::Layout() {
int label_x = GetTextIndent();
- label_->SetBounds(label_x, 0, width() - label_x, height());
+ label_->SetBounds(label_x, 0, std::max(0, width() - label_x), height());
if (hwnd_view_) {
int first_line_height = label_->GetFont().height();
hwnd_view_->SetBounds(0, ((first_line_height - kCheckBoxHeight) / 2) + 1,
diff --git a/chrome/views/chrome_menu.cc b/chrome/views/chrome_menu.cc
index 72519d5..1b8cb4d 100644
--- a/chrome/views/chrome_menu.cc
+++ b/chrome/views/chrome_menu.cc
@@ -442,7 +442,8 @@ class MenuScrollViewContainer : public View {
scroll_view_->Layout();
}
- virtual void DidChangeBounds(const CRect& previous, const CRect& current) {
+ virtual void DidChangeBounds(const gfx::Rect& previous,
+ const gfx::Rect& current) {
gfx::Size content_pref = scroll_view_->GetContents()->GetPreferredSize();
scroll_up_button_->SetVisible(content_pref.height() > height());
scroll_down_button_->SetVisible(content_pref.height() > height());
@@ -829,7 +830,8 @@ gfx::Size SubmenuView::GetPreferredSize() {
return gfx::Size(max_width + insets.width(), height + insets.height());
}
-void SubmenuView::DidChangeBounds(const CRect& previous, const CRect& current) {
+void SubmenuView::DidChangeBounds(const gfx::Rect& previous,
+ const gfx::Rect& current) {
SchedulePaint();
}
diff --git a/chrome/views/chrome_menu.h b/chrome/views/chrome_menu.h
index 75bec86..9cd59bf 100644
--- a/chrome/views/chrome_menu.h
+++ b/chrome/views/chrome_menu.h
@@ -504,7 +504,8 @@ class SubmenuView : public View {
// View method. Overriden to schedule a paint. We do this so that when
// scrolling occurs, everything is repainted correctly.
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
+ virtual void DidChangeBounds(const gfx::Rect& previous,
+ const gfx::Rect& current);
// Painting.
void PaintChildren(ChromeCanvas* canvas);
diff --git a/chrome/views/client_view.cc b/chrome/views/client_view.cc
index 29953cc..8e7971c 100644
--- a/chrome/views/client_view.cc
+++ b/chrome/views/client_view.cc
@@ -38,10 +38,6 @@ void ClientView::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
}
}
-void ClientView::DidChangeBounds(const CRect& previous, const CRect& current) {
- Layout();
-}
-
void ClientView::Layout() {
// |contents_view_| is allowed to be NULL up until the point where this view
// is attached to a Container.
diff --git a/chrome/views/client_view.h b/chrome/views/client_view.h
index 2d4ca51..0d1bcd0 100644
--- a/chrome/views/client_view.h
+++ b/chrome/views/client_view.h
@@ -55,7 +55,6 @@ class ClientView : public View {
protected:
// Overridden from View:
virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual void Layout();
// Accessors for private data members.
diff --git a/chrome/views/container_win.cc b/chrome/views/container_win.cc
index 4506b80..eecc228 100644
--- a/chrome/views/container_win.cc
+++ b/chrome/views/container_win.cc
@@ -56,7 +56,7 @@ void FillLayout::Layout(View* host) {
return;
View* frame_view = host->GetChildViewAt(0);
- frame_view->SetBounds(CRect(CPoint(0, 0), bounds.Size()));
+ frame_view->SetBounds(0, 0, bounds.Width(), bounds.Height());
}
gfx::Size FillLayout::GetPreferredSize(View* host) {
@@ -800,7 +800,7 @@ void ContainerWin::ChangeSize(UINT size_param, const CSize& size) {
// Resizing changes the size of the view hierarchy and thus forces a
// complete relayout.
- root_view_->SetBounds(CRect(CPoint(0,0), rect.Size()));
+ root_view_->SetBounds(0, 0, rect.Width(), rect.Height());
root_view_->Layout();
root_view_->SchedulePaint();
diff --git a/chrome/views/custom_frame_window.cc b/chrome/views/custom_frame_window.cc
index 9bd9758..ef5e3b7 100644
--- a/chrome/views/custom_frame_window.cc
+++ b/chrome/views/custom_frame_window.cc
@@ -819,9 +819,8 @@ void DefaultNonClientView::LayoutTitleBar() {
}
void DefaultNonClientView::LayoutClientView() {
- gfx::Rect client_bounds(
- CalculateClientAreaBounds(width(), height()));
- container_->client_view()->SetBounds(client_bounds.ToRECT());
+ gfx::Rect client_bounds = CalculateClientAreaBounds(width(), height());
+ container_->client_view()->SetBounds(client_bounds);
}
// static
diff --git a/chrome/views/decision.cc b/chrome/views/decision.cc
index e6c57b4..39eb9fb 100644
--- a/chrome/views/decision.cc
+++ b/chrome/views/decision.cc
@@ -59,11 +59,6 @@ void Decision::AppendOption(int command_id,
AddChildView(option);
}
-void Decision::DidChangeBounds(const CRect& old_bounds,
- const CRect& new_bounds) {
- Layout();
-}
-
void Decision::ViewHierarchyChanged(bool is_add, View *parent, View *child) {
if (is_add && child == this) {
// Layout when this is added so that the buttons are laid out correctly.
@@ -72,29 +67,28 @@ void Decision::ViewHierarchyChanged(bool is_add, View *parent, View *child) {
}
void Decision::Layout() {
- CRect lb;
- GetLocalBounds(&lb, false);
+ gfx::Rect lb = GetLocalBounds(false);
// Resize for padding.
- lb.DeflateRect(kPaddingEdge, kPaddingEdge);
- int width = lb.Width();
+ lb.Inset(kPaddingEdge, kPaddingEdge);
+ int width = lb.width();
- CPoint position(lb.TopLeft());
+ gfx::Point position = lb.origin();
gfx::Size size = title_label_->GetPreferredSize();
- title_label_->SetBounds(position.x, position.y, width, size.height());
- position.y += size.height() + kSpacingInfoBottom;
+ title_label_->SetBounds(position.x(), position.y(), width, size.height());
+ position.set_y(position.y() + size.height() + kSpacingInfoBottom);
size.set_height(details_label_->GetHeightForWidth(width));
- details_label_->SetBounds(position.x, position.y, width, size.height());
- position.y += size.height() + kSpacingInfoBottom;
+ details_label_->SetBounds(position.x(), position.y(), width, size.height());
+ position.set_y(position.y() + size.height() + kSpacingInfoBottom);
for (std::vector<Option*>::const_iterator iter = options_.begin();
iter != options_.end(); ++iter) {
Option* option = *iter;
size = option->GetPreferredSize();
- option->SetBounds(position.x, position.y, width, size.height());
+ option->SetBounds(position.x(), position.y(), width, size.height());
option->Layout();
- position.y += size.height() + kSpacingInfoBottom;
+ position.set_y(position.y() + size.height() + kSpacingInfoBottom);
}
}
diff --git a/chrome/views/decision.h b/chrome/views/decision.h
index 007d0f3..40eda44 100644
--- a/chrome/views/decision.h
+++ b/chrome/views/decision.h
@@ -36,10 +36,6 @@ class Decision : public View {
const std::wstring& description,
const std::wstring& action);
- // Need to override this to call layout.
- virtual void DidChangeBounds(const CRect& old_bounds,
- const CRect& new_bounds);
-
// Overridden from View for custom layout.
virtual void Layout();
virtual gfx::Size GetPreferredSize();
diff --git a/chrome/views/dialog_client_view.cc b/chrome/views/dialog_client_view.cc
index 559bc2e..f46608c 100644
--- a/chrome/views/dialog_client_view.cc
+++ b/chrome/views/dialog_client_view.cc
@@ -234,10 +234,6 @@ void DialogClientView::ViewHierarchyChanged(bool is_add, View* parent, View* chi
}
}
-void DialogClientView::DidChangeBounds(const CRect& prev, const CRect& next) {
- Layout();
-}
-
gfx::Size DialogClientView::GetPreferredSize() {
gfx::Size prefsize = contents_view()->GetPreferredSize();
int button_height = 0;
@@ -288,13 +284,12 @@ void DialogClientView::PaintSizeBox(ChromeCanvas* canvas) {
// a theme-supplied gripper. We should probably improvise
// something, which would also require changing |gripper_size|
// to have different default values, too...
- CRect gripper_bounds;
- GetLocalBounds(&gripper_bounds, false);
- gripper_bounds.left = gripper_bounds.right - gripper_size.cx;
- gripper_bounds.top = gripper_bounds.bottom - gripper_size.cy;
- size_box_bounds_ = gripper_bounds;
+ size_box_bounds_ = GetLocalBounds(false);
+ size_box_bounds_.set_x(size_box_bounds_.right() - gripper_size.cx);
+ size_box_bounds_.set_y(size_box_bounds_.bottom() - gripper_size.cy);
+ RECT native_bounds = size_box_bounds_.ToRECT();
gfx::NativeTheme::instance()->PaintStatusGripper(
- dc, SP_PANE, 1, 0, gripper_bounds);
+ dc, SP_PANE, 1, 0, &native_bounds);
canvas->endPlatformPaint();
}
}
@@ -318,54 +313,45 @@ int DialogClientView::GetButtonsHeight() const {
}
void DialogClientView::LayoutDialogButtons() {
- CRect extra_bounds;
+ gfx::Rect extra_bounds;
if (cancel_button_) {
gfx::Size ps = cancel_button_->GetPreferredSize();
- CRect lb;
- GetLocalBounds(&lb, false);
+ gfx::Rect lb = GetLocalBounds(false);
int button_width = GetButtonWidth(DialogDelegate::DIALOGBUTTON_CANCEL);
- CRect bounds;
- bounds.left = lb.right - button_width - kButtonHEdgeMargin;
- bounds.top = lb.bottom - ps.height() - kButtonVEdgeMargin;
- bounds.right = bounds.left + button_width;
- bounds.bottom = bounds.top + ps.height();
- cancel_button_->SetBounds(bounds);
+ int button_x = lb.right() - button_width - kButtonHEdgeMargin;
+ int button_y = lb.bottom() - ps.height() - kButtonVEdgeMargin;
+ cancel_button_->SetBounds(button_x, button_y, button_width, ps.height());
// The extra view bounds are dependent on this button.
- extra_bounds.right = bounds.left;
- extra_bounds.top = bounds.top;
+ extra_bounds.set_width(std::max(0, cancel_button_->x()));
+ extra_bounds.set_y(cancel_button_->y());
}
if (ok_button_) {
gfx::Size ps = ok_button_->GetPreferredSize();
- CRect lb;
- GetLocalBounds(&lb, false);
+ gfx::Rect lb = GetLocalBounds(false);
int button_width = GetButtonWidth(DialogDelegate::DIALOGBUTTON_OK);
- int ok_button_right = lb.right - kButtonHEdgeMargin;
+ int ok_button_right = lb.right() - kButtonHEdgeMargin;
if (cancel_button_)
ok_button_right = cancel_button_->x() - kRelatedButtonHSpacing;
- CRect bounds;
- bounds.left = ok_button_right - button_width;
- bounds.top = lb.bottom - ps.height() - kButtonVEdgeMargin;
- bounds.right = ok_button_right;
- bounds.bottom = bounds.top + ps.height();
- ok_button_->SetBounds(bounds);
+ int button_x = ok_button_right - button_width;
+ int button_y = lb.bottom() - ps.height() - kButtonVEdgeMargin;
+ ok_button_->SetBounds(button_x, button_y, ok_button_right - button_x,
+ ps.height());
// The extra view bounds are dependent on this button.
- extra_bounds.right = bounds.left;
- extra_bounds.top = bounds.top;
+ extra_bounds.set_width(std::max(0, ok_button_->x()));
+ extra_bounds.set_y(ok_button_->y());
}
if (extra_view_) {
gfx::Size ps = extra_view_->GetPreferredSize();
- CRect lb;
- GetLocalBounds(&lb, false);
- extra_bounds.left = lb.left + kButtonHEdgeMargin;
- extra_bounds.bottom = extra_bounds.top + ps.height();
+ gfx::Rect lb = GetLocalBounds(false);
+ extra_bounds.set_x(lb.x() + kButtonHEdgeMargin);
+ extra_bounds.set_height(ps.height());
extra_view_->SetBounds(extra_bounds);
}
}
void DialogClientView::LayoutContentsView() {
- CRect lb;
- GetLocalBounds(&lb, false);
- lb.bottom = std::max(0, static_cast<int>(lb.bottom - GetButtonsHeight()));
+ gfx::Rect lb = GetLocalBounds(false);
+ lb.set_height(std::max(0, lb.height() - GetButtonsHeight()));
contents_view()->SetBounds(lb);
contents_view()->Layout();
}
diff --git a/chrome/views/dialog_client_view.h b/chrome/views/dialog_client_view.h
index b398823..cae6344 100644
--- a/chrome/views/dialog_client_view.h
+++ b/chrome/views/dialog_client_view.h
@@ -58,7 +58,6 @@ class DialogClientView : public ClientView,
virtual void PaintChildren(ChromeCanvas* canvas);
virtual void Layout();
virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
- virtual void DidChangeBounds(const CRect& prev, const CRect& next);
virtual gfx::Size GetPreferredSize();
virtual bool AcceleratorPressed(const Accelerator& accelerator);
diff --git a/chrome/views/hwnd_view.cc b/chrome/views/hwnd_view.cc
index 6c66851..d6976a3 100644
--- a/chrome/views/hwnd_view.cc
+++ b/chrome/views/hwnd_view.cc
@@ -77,8 +77,7 @@ void HWNDView::UpdateHWNDBounds() {
bool visible = !vis_bounds.IsEmpty();
if (visible && !fast_resize_) {
- if (vis_bounds.width() != bounds_.Width() ||
- vis_bounds.height() != bounds_.Height()) {
+ if (vis_bounds.size() != size()) {
// Only a portion of the HWND is really visible.
int x = vis_bounds.x();
int y = vis_bounds.y();
@@ -114,14 +113,12 @@ void HWNDView::UpdateHWNDBounds() {
::SetWindowPos(hwnd_, 0, top_left.x(), top_left.y(), rect.Width(),
rect.Height(), swp_flags);
- HRGN clip_region = CreateRectRgn(0, 0,
- bounds_.Width(),
- bounds_.Height());
+ HRGN clip_region = CreateRectRgn(0, 0, width(), height());
SetWindowRgn(hwnd_, clip_region, FALSE);
installed_clip_ = true;
} else {
- ::SetWindowPos(hwnd_, 0, top_left.x(), top_left.y(), bounds_.Width(),
- bounds_.Height(), swp_flags);
+ ::SetWindowPos(hwnd_, 0, top_left.x(), top_left.y(), width(), height(),
+ swp_flags);
}
} else if (::IsWindowVisible(hwnd_)) {
// The window is currently visible, but its clipped by another view. Hide
@@ -132,7 +129,10 @@ void HWNDView::UpdateHWNDBounds() {
}
}
-void HWNDView::DidChangeBounds(const CRect& previous, const CRect& current) {
+void HWNDView::DidChangeBounds(const gfx::Rect& previous,
+ const gfx::Rect& current) {
+ // TODO(beng): (Cleanup) Could UpdateHWNDBounds be replaced by a Layout
+ // method and this function gotten rid of?
UpdateHWNDBounds();
}
@@ -183,8 +183,7 @@ void HWNDView::Paint(ChromeCanvas* canvas) {
// It would be nice if this used some approximation of the page's
// current background color.
if (installed_clip_ && win_util::ShouldUseVistaFrame())
- canvas->FillRectInt(SkColorSetRGB(255, 255, 255), 0, 0,
- bounds_.Width(), bounds_.Height());
+ canvas->FillRectInt(SkColorSetRGB(255, 255, 255), 0, 0, width(), height());
}
std::string HWNDView::GetClassName() const {
diff --git a/chrome/views/hwnd_view.h b/chrome/views/hwnd_view.h
index 2af1aa5..bf2a2e2 100644
--- a/chrome/views/hwnd_view.h
+++ b/chrome/views/hwnd_view.h
@@ -38,7 +38,8 @@ class HWNDView : public View {
// Detach the attached window handle. It will no longer be updated
void Detach();
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
+ virtual void DidChangeBounds(const gfx::Rect& previous,
+ const gfx::Rect& current);
virtual void VisibilityChanged(View* starting_from, bool is_visible);
HWND GetHWND() const;
diff --git a/chrome/views/label.cc b/chrome/views/label.cc
index d918cd5..2f46b34 100644
--- a/chrome/views/label.cc
+++ b/chrome/views/label.cc
@@ -90,9 +90,7 @@ void Label::Paint(ChromeCanvas* canvas) {
if (url_set_) {
// TODO(jungshik) : Figure out how to get 'intl.accept_languages'
// preference and use it when calling ElideUrl.
- paint_text = gfx::ElideUrl(url_, font_, bounds_.right - bounds_.left,
- std::wstring());
-
+ paint_text = gfx::ElideUrl(url_, font_, width(), std::wstring());
// An URLs is always treated as an LTR text and therefore we should
// explicitly mark it as such if the locale is RTL so that URLs containing
diff --git a/chrome/views/menu_button.cc b/chrome/views/menu_button.cc
index 847239a..038faa0 100644
--- a/chrome/views/menu_button.cc
+++ b/chrome/views/menu_button.cc
@@ -126,14 +126,13 @@ bool MenuButton::Activate() {
// after the menu closes.
PaintNow();
if (menu_delegate_) {
- CRect lb;
- GetLocalBounds(&lb, true);
+ gfx::Rect lb = GetLocalBounds(true);
// The position of the menu depends on whether or not the locale is
// right-to-left.
- gfx::Point menu_position(lb.BottomRight());
+ gfx::Point menu_position(lb.right(), lb.bottom());
if (UILayoutIsRightToLeft())
- menu_position.set_x(lb.left);
+ menu_position.set_x(lb.x());
View::ConvertPointToScreen(this, &menu_position);
if (UILayoutIsRightToLeft())
diff --git a/chrome/views/native_control.cc b/chrome/views/native_control.cc
index 5c14c57..18a1324 100644
--- a/chrome/views/native_control.cc
+++ b/chrome/views/native_control.cc
@@ -210,13 +210,12 @@ void NativeControl::Layout() {
ValidateNativeControl();
if (hwnd_view_) {
- CRect lb;
- GetLocalBounds(&lb, false);
+ gfx::Rect lb = GetLocalBounds(false);
- int x = lb.left;
- int y = lb.top;
- int width = lb.Width();
- int height = lb.Height();
+ int x = lb.x();
+ int y = lb.y();
+ int width = lb.width();
+ int height = lb.height();
if (fixed_width_ > 0) {
width = std::min(fixed_width_, width);
switch (horizontal_alignment_) {
@@ -224,10 +223,10 @@ void NativeControl::Layout() {
// Nothing to do.
break;
case CENTER:
- x += (lb.Width() - width) / 2;
+ x += (lb.width() - width) / 2;
break;
case TRAILING:
- x = x + lb.Width() - width;
+ x = x + lb.width() - width;
break;
default:
NOTREACHED();
@@ -241,10 +240,10 @@ void NativeControl::Layout() {
// Nothing to do.
break;
case CENTER:
- y += (lb.Height() - height) / 2;
+ y += (lb.height() - height) / 2;
break;
case TRAILING:
- y = y + lb.Height() - height;
+ y = y + lb.height() - height;
break;
default:
NOTREACHED();
@@ -255,11 +254,6 @@ void NativeControl::Layout() {
}
}
-void NativeControl::DidChangeBounds(const CRect& previous,
- const CRect& current) {
- Layout();
-}
-
void NativeControl::Focus() {
if (container_) {
DCHECK(container_->GetControl());
diff --git a/chrome/views/native_control.h b/chrome/views/native_control.h
index edd93d0..29a57cf 100644
--- a/chrome/views/native_control.h
+++ b/chrome/views/native_control.h
@@ -32,7 +32,6 @@ class NativeControl : public View {
virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child);
virtual void Layout();
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
// Overridden to properly set the native control state.
virtual void SetVisible(bool f);
diff --git a/chrome/views/native_scroll_bar.cc b/chrome/views/native_scroll_bar.cc
index 53c5189..5d69c43 100644
--- a/chrome/views/native_scroll_bar.cc
+++ b/chrome/views/native_scroll_bar.cc
@@ -238,16 +238,8 @@ void NativeScrollBar::ViewHierarchyChanged(bool is_add, View *parent,
}
void NativeScrollBar::Layout() {
- if (sb_view_) {
- CRect lb;
- GetLocalBounds(&lb, true);
- sb_view_->SetBounds(0, 0, lb.Width(), lb.Height());
- }
-}
-
-void NativeScrollBar::DidChangeBounds(const CRect& previous,
- const CRect& current) {
- Layout();
+ if (sb_view_)
+ sb_view_->SetBounds(GetLocalBounds(true));
}
gfx::Size NativeScrollBar::GetPreferredSize() {
diff --git a/chrome/views/native_scroll_bar.h b/chrome/views/native_scroll_bar.h
index ad514b4..8eee019 100644
--- a/chrome/views/native_scroll_bar.h
+++ b/chrome/views/native_scroll_bar.h
@@ -31,7 +31,6 @@ class NativeScrollBar : public ScrollBar {
// Overridden for layout purpose
virtual void Layout();
virtual gfx::Size GetPreferredSize();
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
// Overridden for keyboard UI purpose
virtual bool OnKeyPressed(const KeyEvent& event);
diff --git a/chrome/views/root_view.cc b/chrome/views/root_view.cc
index 5e7beff..db6c80a 100644
--- a/chrome/views/root_view.cc
+++ b/chrome/views/root_view.cc
@@ -203,8 +203,7 @@ CRect RootView::GetScheduledPaintRectConstrainedToSize() {
if (invalid_rect_.IsRectEmpty())
return invalid_rect_;
- CRect local_bounds;
- GetLocalBounds(&local_bounds, true);
+ CRect local_bounds = GetLocalBounds(true).ToRECT();
CRect invalid_rect;
invalid_rect.IntersectRect(&invalid_rect_, &local_bounds);
return invalid_rect;
diff --git a/chrome/views/scroll_view.cc b/chrome/views/scroll_view.cc
index 6b43fb4..7a96681 100644
--- a/chrome/views/scroll_view.cc
+++ b/chrome/views/scroll_view.cc
@@ -118,19 +118,20 @@ void ScrollView::SetControlVisibility(View* control, bool should_show) {
}
}
-void ScrollView::ComputeScrollBarsVisibility(const CSize& vp_size,
- const CSize& content_size,
+void ScrollView::ComputeScrollBarsVisibility(const gfx::Size& vp_size,
+ const gfx::Size& content_size,
bool* horiz_is_shown,
bool* vert_is_shown) const {
// Try to fit both ways first, then try vertical bar only, then horizontal
// bar only, then defaults to both shown.
- if (content_size.cx <= vp_size.cx && content_size.cy <= vp_size.cy) {
+ if (content_size.width() <= vp_size.width() &&
+ content_size.height() <= vp_size.height()) {
*horiz_is_shown = false;
*vert_is_shown = false;
- } else if (content_size.cx <= vp_size.cx - GetScrollBarWidth()) {
+ } else if (content_size.width() <= vp_size.width() - GetScrollBarWidth()) {
*horiz_is_shown = false;
*vert_is_shown = true;
- } else if (content_size.cy <= vp_size.cy - GetScrollBarHeight()) {
+ } else if (content_size.height() <= vp_size.height() - GetScrollBarHeight()) {
*horiz_is_shown = true;
*vert_is_shown = false;
} else {
@@ -148,14 +149,12 @@ void ScrollView::Layout() {
// override this default behavior, the inner view has to calculate the
// available space, used ComputeScrollBarsVisibility() to use the same
// calculation that is done here and sets its bound to fit within.
- WTL::CRect viewport_bounds;
- GetLocalBounds(&viewport_bounds, true);
+ gfx::Rect viewport_bounds = GetLocalBounds(true);
// Realign it to 0 so it can be used as-is for SetBounds().
- viewport_bounds.MoveToXY(0, 0);
- // viewport_size is the total client space available.
- WTL::CSize viewport_size(viewport_bounds.right,
- viewport_bounds.bottom);
- if (viewport_size.cx == 0 || viewport_size.cy == 0) {
+ viewport_bounds.set_origin(gfx::Point(0, 0));
+ // viewport_size is the total client space available.
+ gfx::Size viewport_size = viewport_bounds.size();
+ if (viewport_bounds.IsEmpty()) {
// There's nothing to layout.
return;
}
@@ -164,20 +163,20 @@ void ScrollView::Layout() {
// this.
int horiz_sb_height = GetScrollBarHeight();
int vert_sb_width = GetScrollBarWidth();
- viewport_bounds.right -= vert_sb_width;
+ viewport_bounds.set_width(viewport_bounds.width() - vert_sb_width);
// Update the bounds right now so the inner views can fit in it.
viewport_->SetBounds(viewport_bounds);
- // Give contents_ a chance to update its bounds if it depends on the viewport.
- if (contents_) {
+ // Give contents_ a chance to update its bounds if it depends on the
+ // viewport.
+ if (contents_)
contents_->Layout();
- }
bool should_layout_contents = false;
bool horiz_sb_required = false;
bool vert_sb_required = false;
if (contents_) {
- WTL::CSize content_size(contents_->width(), contents_->height());
+ gfx::Size content_size = contents_->size();
ComputeScrollBarsVisibility(viewport_size,
content_size,
&horiz_sb_required,
@@ -192,31 +191,31 @@ void ScrollView::Layout() {
// Non-default.
if (horiz_sb_required) {
- viewport_bounds.bottom -= horiz_sb_height;
+ viewport_bounds.set_height(viewport_bounds.height() - horiz_sb_height);
should_layout_contents = true;
}
// Default.
if (!vert_sb_required) {
- viewport_bounds.right += vert_sb_width;
+ viewport_bounds.set_width(viewport_bounds.width() + vert_sb_width);
should_layout_contents = true;
}
if (horiz_sb_required) {
horiz_sb_->SetBounds(0,
- viewport_bounds.bottom,
- viewport_bounds.right,
+ viewport_bounds.bottom(),
+ viewport_bounds.right(),
horiz_sb_height);
}
if (vert_sb_required) {
- vert_sb_->SetBounds(viewport_bounds.right,
+ vert_sb_->SetBounds(viewport_bounds.right(),
0,
vert_sb_width,
- viewport_bounds.bottom);
+ viewport_bounds.bottom());
}
if (resize_corner_required) {
// Show the resize corner.
- resize_corner_->SetBounds(viewport_bounds.right,
- viewport_bounds.bottom,
+ resize_corner_->SetBounds(viewport_bounds.right(),
+ viewport_bounds.bottom(),
vert_sb_width,
horiz_sb_height);
}
@@ -258,10 +257,6 @@ void ScrollView::CheckScrollBounds() {
}
}
-void ScrollView::DidChangeBounds(const CRect& previous, const CRect& current) {
- Layout();
-}
-
gfx::Rect ScrollView::GetVisibleRect() const {
if (!contents_)
return gfx::Rect();
@@ -342,9 +337,7 @@ void ScrollView::ScrollToPosition(ScrollBar* source, int position) {
else if (position > max_pos)
position = max_pos;
contents_->SetX(-position);
- CRect bounds;
- contents_->GetLocalBounds(&bounds, true);
- contents_->SchedulePaint(bounds, true);
+ contents_->SchedulePaint(contents_->GetLocalBounds(true).ToRECT(), true);
}
} else if (source == vert_sb_ && vert_sb_->IsVisible()) {
int vh = viewport_->height();
@@ -357,9 +350,7 @@ void ScrollView::ScrollToPosition(ScrollBar* source, int position) {
else if (position > max_pos)
position = max_pos;
contents_->SetY(-position);
- CRect bounds;
- contents_->GetLocalBounds(&bounds, true);
- contents_->SchedulePaint(bounds, true);
+ contents_->SchedulePaint(contents_->GetLocalBounds(true).ToRECT(), true);
}
}
}
diff --git a/chrome/views/scroll_view.h b/chrome/views/scroll_view.h
index e855da4..c41ad87 100644
--- a/chrome/views/scroll_view.h
+++ b/chrome/views/scroll_view.h
@@ -42,8 +42,7 @@ class ScrollView : public View,
// Overridden to layout the viewport and scrollbars.
virtual void Layout();
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
-
+
// Returns the visible region of the content View.
gfx::Rect GetVisibleRect() const;
@@ -87,8 +86,8 @@ class ScrollView : public View,
// Computes the visibility of both scrollbars, taking in account the view port
// and content sizes.
- void ComputeScrollBarsVisibility(const CSize& viewport_size,
- const CSize& content_size,
+ void ComputeScrollBarsVisibility(const gfx::Size& viewport_size,
+ const gfx::Size& content_size,
bool* horiz_is_shown,
bool* vert_is_shown) const;
diff --git a/chrome/views/table_view.cc b/chrome/views/table_view.cc
index ab33ebf..398145c 100644
--- a/chrome/views/table_view.cc
+++ b/chrome/views/table_view.cc
@@ -146,8 +146,8 @@ void TableView::SetSortDescriptors(const SortDescriptors& sort_descriptors) {
SendMessage(list_view_, WM_SETREDRAW, static_cast<WPARAM>(TRUE), 0);
}
-void TableView::DidChangeBounds(const CRect& previous,
- const CRect& current) {
+void TableView::DidChangeBounds(const gfx::Rect& previous,
+ const gfx::Rect& current) {
if (!list_view_)
return;
SendMessage(list_view_, WM_SETREDRAW, static_cast<WPARAM>(FALSE), 0);
@@ -1039,13 +1039,12 @@ void TableView::ResetColumnSizes() {
return;
// See comment in TableColumn for what this does.
- CRect bounds;
- GetLocalBounds(&bounds, false); // false so it doesn't include the border.
- int width = bounds.Width();
- if (GetClientRect(GetNativeControlHWND(), &bounds) &&
- bounds.Width() > 0) {
+ int width = this->width();
+ CRect native_bounds;
+ if (GetClientRect(GetNativeControlHWND(), &native_bounds) &&
+ native_bounds.Width() > 0) {
// Prefer the bounds of the window over our bounds, which may be different.
- width = bounds.Width();
+ width = native_bounds.Width();
}
float percent = 0;
diff --git a/chrome/views/table_view.h b/chrome/views/table_view.h
index 7f8422b..4e1c943 100644
--- a/chrome/views/table_view.h
+++ b/chrome/views/table_view.h
@@ -340,7 +340,8 @@ class TableView : public NativeControl,
// Current sort.
const SortDescriptors& sort_descriptors() const { return sort_descriptors_; }
- void DidChangeBounds(const CRect& previous, const CRect& current);
+ void DidChangeBounds(const gfx::Rect& previous,
+ const gfx::Rect& current);
// Returns the number of rows in the TableView.
int RowCount();
diff --git a/chrome/views/text_field.cc b/chrome/views/text_field.cc
index 2991040..517968a 100644
--- a/chrome/views/text_field.cc
+++ b/chrome/views/text_field.cc
@@ -839,17 +839,11 @@ void TextField::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
void TextField::Layout() {
if (native_view_) {
- CRect lb;
- GetLocalBounds(&lb, true);
- native_view_->SetBounds(0, 0, lb.Width(), lb.Height());
+ native_view_->SetBounds(GetLocalBounds(true));
native_view_->UpdateHWNDBounds();
}
}
-void TextField::DidChangeBounds(const CRect& previous, const CRect& current) {
- Layout();
-}
-
gfx::Size TextField::GetPreferredSize() {
gfx::Insets insets;
CalculateInsets(&insets);
diff --git a/chrome/views/text_field.h b/chrome/views/text_field.h
index 9d7539c..e9685fd 100644
--- a/chrome/views/text_field.h
+++ b/chrome/views/text_field.h
@@ -73,7 +73,6 @@ class TextField : public View {
// Overridden for layout purposes
virtual void Layout();
virtual gfx::Size GetPreferredSize();
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
// Controller accessors
void SetController(Controller* controller);
diff --git a/chrome/views/view.cc b/chrome/views/view.cc
index 6b8f53e..2dfedd8e 100644
--- a/chrome/views/view.cc
+++ b/chrome/views/view.cc
@@ -129,69 +129,34 @@ gfx::Rect View::GetBounds(PositionMirroringSettings settings) const {
// y(), width() and height() are agnostic to the RTL UI layout of the
// parent view. x(), on the other hand, is not.
int View::GetX(PositionMirroringSettings settings) const {
- if (settings == IGNORE_MIRRORING_TRANSFORMATION) {
- return bounds_.left;
- }
- return MirroredX();
+ return settings == IGNORE_MIRRORING_TRANSFORMATION ? x() : MirroredX();
}
-void View::SetBounds(const CRect& bounds) {
- if (bounds.left == bounds_.left &&
- bounds.top == bounds_.top &&
- bounds.Width() == bounds_.Width() &&
- bounds.Height() == bounds_.Height()) {
+void View::SetBounds(const gfx::Rect& bounds) {
+ if (bounds == bounds_)
return;
- }
- CRect prev = bounds_;
+ gfx::Rect prev = bounds_;
bounds_ = bounds;
- if (bounds_.right < bounds_.left)
- bounds_.right = bounds_.left;
-
- if (bounds_.bottom < bounds_.top)
- bounds_.bottom = bounds_.top;
-
DidChangeBounds(prev, bounds_);
RootView* root = GetRootView();
if (root) {
- bool size_changed = (prev.Width() != bounds_.Width() ||
- prev.Height() != bounds_.Height());
- bool position_changed = (prev.left != bounds_.left ||
- prev.top != bounds_.top);
+ bool size_changed = prev.size() != bounds_.size();
+ bool position_changed = prev.origin() != bounds_.origin();
if (size_changed || position_changed)
root->ViewBoundsChanged(this, size_changed, position_changed);
}
}
-void View::SetBounds(int x, int y, int width, int height) {
- CRect tmp(x, y, x + width, y + height);
- SetBounds(tmp);
-}
-
-void View::SetBounds(const gfx::Point& origin, const gfx::Size& size) {
- SetBounds(origin.x(), origin.y(), size.width(), size.height());
-}
+gfx::Rect View::GetLocalBounds(bool include_border) const {
+ if (include_border || border_ == NULL)
+ return gfx::Rect(0, 0, width(), height());
-void View::GetLocalBounds(CRect* out, bool include_border) const {
- if (include_border || border_ == NULL) {
- out->left = 0;
- out->top = 0;
- out->right = width();
- out->bottom = height();
- } else {
- gfx::Insets insets;
- border_->GetInsets(&insets);
- out->left = insets.left();
- out->top = insets.top();
- out->right = width() - insets.left();
- out->bottom = height() - insets.top();
- }
-}
-
-void View::GetSize(CSize* sz) const {
- sz->cx = width();
- sz->cy = height();
+ gfx::Insets insets;
+ border_->GetInsets(&insets);
+ return gfx::Rect(insets.left(), insets.top(),
+ width() - insets.width(), height() - insets.height());
}
void View::GetPosition(CPoint* p) const {
@@ -222,7 +187,9 @@ int View::GetHeightForWidth(int w) {
return GetPreferredSize().height();
}
-void View::DidChangeBounds(const CRect& previous, const CRect& current) {
+void View::DidChangeBounds(const gfx::Rect& previous,
+ const gfx::Rect& current) {
+ Layout();
}
void View::ScrollRectToVisible(int x, int y, int width, int height) {
@@ -284,10 +251,9 @@ bool View::UILayoutIsRightToLeft() const {
inline int View::MirroredX() const {
// TODO(beng): reimplement in terms of MirroredLeftPointForRect.
View* parent = GetParent();
- if (parent && parent->UILayoutIsRightToLeft()) {
- return parent->width() - bounds_.left - width();
- }
- return bounds_.left;
+ if (parent && parent->UILayoutIsRightToLeft())
+ return parent->width() - x() - width();
+ return x();
}
int View::MirroredLeftPointForRect(const gfx::Rect& bounds) const {
@@ -368,9 +334,7 @@ void View::SchedulePaint(const CRect& r, bool urgent) {
}
void View::SchedulePaint() {
- CRect lb;
- GetLocalBounds(&lb, true);
- SchedulePaint(lb, false);
+ SchedulePaint(GetLocalBounds(true).ToRECT(), false);
}
void View::SchedulePaint(int x, int y, int w, int h) {
@@ -426,11 +390,10 @@ void View::ProcessPaint(ChromeCanvas* canvas) {
// Note that the X (or left) position we pass to ClipRectInt takes into
// consideration whether or not the view uses a right-to-left layout so that
// we paint our view in its mirrored position if need be.
- if (canvas->ClipRectInt(MirroredX(), bounds_.top, bounds_.Width(),
- bounds_.Height())) {
+ if (canvas->ClipRectInt(MirroredX(), y(), width(), height())) {
// Non-empty clip, translate the graphics such that 0,0 corresponds to
// where this view is located (related to its parent).
- canvas->TranslateInt(MirroredX(), bounds_.top);
+ canvas->TranslateInt(MirroredX(), y());
// Save the state again, so that any changes don't effect PaintChildren.
canvas->save();
@@ -967,8 +930,8 @@ void View::PrintViewHierarchyImp(int indent) {
buf << L' ';
buf << GetID();
buf << L' ';
- buf << bounds_.left << L"," << bounds_.top << L",";
- buf << bounds_.right << L"," << bounds_.bottom;
+ buf << bounds_.x() << L"," << bounds_.y() << L",";
+ buf << bounds_.right() << L"," << bounds_.bottom();
buf << L' ';
buf << this;
diff --git a/chrome/views/view.h b/chrome/views/view.h
index 2d0f21e..738e8b5 100644
--- a/chrome/views/view.h
+++ b/chrome/views/view.h
@@ -141,7 +141,10 @@ class View : public AcceleratorTarget {
// the bounds of one of their child views (for example, when implementing
// View::Layout()).
// TODO(beng): Convert |bounds_| to a gfx::Rect.
- gfx::Rect bounds() const { return gfx::Rect(bounds_); }
+ gfx::Rect bounds() const { return bounds_; }
+
+ // Get the size of the View.
+ gfx::Size size() const { return bounds_.size(); }
// Return the bounds of the View, relative to the parent. If
// |settings| is IGNORE_MIRRORING_TRANSFORMATION, the function returns the
@@ -157,14 +160,15 @@ class View : public AcceleratorTarget {
gfx::Rect GetBounds(PositionMirroringSettings settings) const;
// Set the bounds in the parent's coordinate system.
- void SetBounds(const CRect& bounds);
- void SetBounds(const gfx::Point& origin, const gfx::Size& size);
- void SetBounds(int x, int y, int width, int height);
+ void SetBounds(const gfx::Rect& bounds);
+ void SetBounds(int x, int y, int width, int height) {
+ SetBounds(gfx::Rect(x, y, std::max(0, width), std::max(0, height)));
+ }
void SetX(int x) { SetBounds(x, y(), width(), height()); }
void SetY(int y) { SetBounds(x(), y, width(), height()); }
// Returns the left coordinate of the View, relative to the parent View,
- // which is the value of bounds_.left.
+ // which is the value of bounds_.x().
//
// This is the function subclasses should use whenever they need to obtain
// the left position of one of their child views (for example, when
@@ -172,14 +176,14 @@ class View : public AcceleratorTarget {
int x() const {
// This is equivalent to GetX(IGNORE_MIRRORING_TRANSFORMATION), but
// inlinable.
- return bounds_.left;
+ return bounds_.x();
};
// Return the left coordinate of the View, relative to the parent. If
// |settings| is IGNORE_MIRRORING_SETTINGS, the function returns the value of
- // bounds_.left. If |settings| is APPLY_MIRRORING_SETTINGS AND the parent
+ // bounds_.x(). If |settings| is APPLY_MIRRORING_SETTINGS AND the parent
// View is using a right-to-left UI layout, then the function returns the
- // mirrored value of bounds_.left.
+ // mirrored value of bounds_.x().
//
// NOTE: in the vast majority of the cases, the mirroring implementation is
// transparent to the View subclasses and therefore you should use the
@@ -188,22 +192,19 @@ class View : public AcceleratorTarget {
int GetX(PositionMirroringSettings settings) const;
int y() const {
- return bounds_.top;
+ return bounds_.y();
};
int width() const {
- return bounds_.Width();
+ return bounds_.width();
};
int height() const {
- return bounds_.Height();
+ return bounds_.height();
};
// Return this control local bounds. If include_border is true, local bounds
// is the rectangle {0, 0, width(), height()}, otherwise, it does not
// include the area where the border (if any) is painted.
- void GetLocalBounds(CRect* out, bool include_border) const;
-
- // Get the size of the View
- void GetSize(CSize* out) const;
+ gfx::Rect GetLocalBounds(bool include_border) const;
// Get the position of the View, relative to the parent.
//
@@ -230,7 +231,8 @@ class View : public AcceleratorTarget {
// This method is invoked when this object size or position changes.
// The default implementation does nothing.
- virtual void DidChangeBounds(const CRect& previous, const CRect& current);
+ virtual void DidChangeBounds(const gfx::Rect& previous,
+ const gfx::Rect& current);
// Set whether the receiving view is visible. Painting is scheduled as needed
virtual void SetVisible(bool flag);
@@ -971,10 +973,6 @@ class View : public AcceleratorTarget {
bool is_horizontal, bool is_positive);
protected:
- // TODO(beng): these members should NOT be protected per style guide.
- // This View's bounds in the parent coordinate system.
- CRect bounds_;
-
// The id of this View. Used to find this View.
int id_;
@@ -1221,6 +1219,9 @@ class View : public AcceleratorTarget {
// |start| view.
static View* GetViewForPath(View* start, const std::vector<int>& path);
+ // This View's bounds in the parent coordinate system.
+ gfx::Rect bounds_;
+
// This view's parent
View *parent_;
diff --git a/chrome/views/view_unittest.cc b/chrome/views/view_unittest.cc
index 38df3bd..0819d66 100644
--- a/chrome/views/view_unittest.cc
+++ b/chrome/views/view_unittest.cc
@@ -124,8 +124,8 @@ class TestView : public View {
// DidChangeBounds test
bool did_change_bounds_;
- CRect previous_bounds_;
- CRect new_bounds_;
+ gfx::Rect previous_bounds_;
+ gfx::Rect new_bounds_;
// AddRemoveNotifications test
bool child_added_;
@@ -154,8 +154,8 @@ void TestView::DidChangeBounds(const CRect& previous, const CRect& current) {
TEST_F(ViewTest, DidChangeBounds) {
TestView* v = new TestView();
- CRect prev_rect(0, 0, 200, 200);
- CRect new_rect(100, 100, 250, 250);
+ gfx::Rect prev_rect(0, 0, 200, 200);
+ gfx::Rect new_rect(100, 100, 250, 250);
v->SetBounds(prev_rect);
v->Reset();
@@ -552,12 +552,12 @@ TEST_F(ViewTest, HitTestMasks) {
gfx::Rect v1_bounds = gfx::Rect(0, 0, 100, 100);
HitTestView* v1 = new HitTestView(false);
- v1->SetBounds(v1_bounds.ToRECT());
+ v1->SetBounds(v1_bounds);
root_view->AddChildView(v1);
gfx::Rect v2_bounds = gfx::Rect(105, 0, 100, 100);
HitTestView* v2 = new HitTestView(true);
- v2->SetBounds(v2_bounds.ToRECT());
+ v2->SetBounds(v2_bounds);
root_view->AddChildView(v2);
gfx::Point v1_centerpoint = v1_bounds.CenterPoint();