summaryrefslogtreecommitdiffstats
path: root/chrome/views
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 /chrome/views
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
Diffstat (limited to 'chrome/views')
-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
32 files changed, 170 insertions, 278 deletions
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();