summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-14 17:03:07 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-14 17:03:07 +0000
commit0d8ea70525f3c0805b0a474838917d0d1b5cd6a9 (patch)
tree6cbf491f10dae971bebe975e3fb623fc8a97a33b
parent017b3cc2a4ade9e4e69f15bbd4721f149642d8a6 (diff)
downloadchromium_src-0d8ea70525f3c0805b0a474838917d0d1b5cd6a9.zip
chromium_src-0d8ea70525f3c0805b0a474838917d0d1b5cd6a9.tar.gz
chromium_src-0d8ea70525f3c0805b0a474838917d0d1b5cd6a9.tar.bz2
Replace View::GetBounds(CRect* bounds) const; with gfx::Rect bounds() const.
http://crbug.com/2186 Review URL: http://codereview.chromium.org/7136 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3348 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/gfx/rect.h5
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup.cc3
-rw-r--r--chrome/browser/find_in_page_controller.cc23
-rw-r--r--chrome/browser/find_in_page_view.cc28
-rw-r--r--chrome/browser/history_view.cc10
-rw-r--r--chrome/browser/views/about_chrome_view.cc30
-rw-r--r--chrome/browser/views/about_chrome_view.h6
-rw-r--r--chrome/browser/views/constrained_window_impl.cc14
-rw-r--r--chrome/browser/views/first_run_view_base.cc5
-rw-r--r--chrome/browser/views/frame/browser_view2.cc29
-rw-r--r--chrome/browser/views/frame/opaque_non_client_view.cc31
-rw-r--r--chrome/browser/views/old_frames/vista_frame.cc5
-rw-r--r--chrome/browser/views/old_frames/xp_frame.cc16
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc4
-rw-r--r--chrome/views/accessibility/view_accessibility.cc19
-rw-r--r--chrome/views/bitmap_scroll_bar.cc54
-rw-r--r--chrome/views/chrome_menu.cc4
-rw-r--r--chrome/views/client_view.cc6
-rw-r--r--chrome/views/custom_frame_window.cc80
-rw-r--r--chrome/views/grid_layout_unittest.cc2
-rw-r--r--chrome/views/label.cc10
-rw-r--r--chrome/views/text_button.cc27
-rw-r--r--chrome/views/tooltip_manager.cc9
-rw-r--r--chrome/views/view.cc11
-rw-r--r--chrome/views/view.h7
-rw-r--r--chrome/views/view_unittest.cc4
26 files changed, 196 insertions, 246 deletions
diff --git a/base/gfx/rect.h b/base/gfx/rect.h
index 2f1a498..963470a 100644
--- a/base/gfx/rect.h
+++ b/base/gfx/rect.h
@@ -91,6 +91,11 @@ class Rect {
// point (x + width, y + height) is not.
bool Contains(int point_x, int point_y) const;
+ // Returns true if the specified point is contained by this rectangle.
+ bool Contains(const gfx::Point& point) const {
+ return Contains(point.x(), point.y());
+ }
+
// Returns true if this rectangle contains the specified rectangle.
bool Contains(const Rect& rect) const;
diff --git a/chrome/browser/autocomplete/autocomplete_popup.cc b/chrome/browser/autocomplete/autocomplete_popup.cc
index 9dcc1b4..c9ca6a1 100644
--- a/chrome/browser/autocomplete/autocomplete_popup.cc
+++ b/chrome/browser/autocomplete/autocomplete_popup.cc
@@ -169,8 +169,7 @@ void AutocompletePopupView::UpdatePopupAppearance() {
// to its parent.
// TODO(pkasting): http://b/1345937 All this use of editor accessors should
// die once this class is a true ChromeView.
- CRect rc;
- edit_view_->parent_view()->GetBounds(&rc);
+ CRect rc = edit_view_->parent_view()->bounds().ToRECT();
// Subtract the top left corner to make the coordinates relative to the
// location bar view itself, and convert to screen coordinates.
CPoint top_left(-rc.TopLeft());
diff --git a/chrome/browser/find_in_page_controller.cc b/chrome/browser/find_in_page_controller.cc
index baa4973..67c819c 100644
--- a/chrome/browser/find_in_page_controller.cc
+++ b/chrome/browser/find_in_page_controller.cc
@@ -478,19 +478,22 @@ void FindInPageController::GetDialogBounds(gfx::Rect* bounds) {
*bounds = gfx::Rect(browser_client_rect);
// Find the dimensions of the toolbar and the BookmarkBar.
- CRect toolbar_bounds, bookmark_bar_bounds;
+ gfx::Rect toolbar_bounds, bookmark_bar_bounds;
if (toolbar) {
if (!g_browser_process->IsUsingNewFrames())
- toolbar->GetBounds(&toolbar_bounds);
- else
- toolbar->GetLocalBounds(&toolbar_bounds, false);
+ toolbar_bounds = toolbar->bounds();
+ else {
+ CRect local_bounds;
+ toolbar->GetLocalBounds(&local_bounds, false);
+ toolbar_bounds = gfx::Rect(local_bounds);
+ }
// Need to convert toolbar bounds into ViewContainer coords because the
// toolbar is the child of another view that isn't the top level view.
// This is required to ensure correct positioning relative to the top,left
// of the window.
CPoint topleft(0, 0);
ChromeViews::View::ConvertPointToViewContainer(toolbar, &topleft);
- toolbar_bounds.OffsetRect(topleft);
+ toolbar_bounds.Offset(topleft.x, topleft.y);
}
// If the bookmarks bar is available, we need to update our
@@ -509,7 +512,7 @@ void FindInPageController::GetDialogBounds(gfx::Rect* bounds) {
// the bookmarks bar (this works even if the bar is hidden).
if (!bookmark_bar->IsNewTabPage() ||
bookmark_bar->IsAlwaysShown()) {
- bookmark_bar->GetBounds(&bookmark_bar_bounds);
+ bookmark_bar_bounds = bookmark_bar->bounds();
}
} else {
view_->SetToolbarBlend(true);
@@ -522,13 +525,13 @@ void FindInPageController::GetDialogBounds(gfx::Rect* bounds) {
// window or a Chrome application so we want to draw at the top of the page
// content (right beneath the title bar).
int y_pos_offset = 0;
- if (!toolbar_bounds.IsRectEmpty()) {
+ if (!toolbar_bounds.IsEmpty()) {
// We have a toolbar (chrome), so overlap it by one pixel.
- y_pos_offset = toolbar_bounds.BottomRight().y - 1;
+ y_pos_offset = toolbar_bounds.bottom() - 1;
// If there is a bookmark bar attached to the toolbar we should appear
// attached to it instead of the toolbar.
- if (!bookmark_bar_bounds.IsRectEmpty())
- y_pos_offset += bookmark_bar_bounds.Height() - 1;
+ if (!bookmark_bar_bounds.IsEmpty())
+ y_pos_offset += bookmark_bar_bounds.height() - 1;
} else {
// There is no toolbar, so this is probably a constrained window or a Chrome
// Application. This means we draw the Find window at the top of the page
diff --git a/chrome/browser/find_in_page_view.cc b/chrome/browser/find_in_page_view.cc
index c6507f4..ac75944 100644
--- a/chrome/browser/find_in_page_view.cc
+++ b/chrome/browser/find_in_page_view.cc
@@ -284,28 +284,28 @@ void FindInPageView::Paint(ChromeCanvas* canvas) {
// Then we draw the background image for the Find TextField. We start by
// calculating the position of background images for the Find text box.
- CRect find_text_rect;
- CRect back_button_rect;
+ gfx::Rect find_text_rect;
+ gfx::Rect back_button_rect;
int x = 0; // x coordinate of the curved edge background image.
int w = 0; // width of the background image for the text field.
if (UILayoutIsRightToLeft()) {
- find_text_->GetBounds(&find_text_rect, APPLY_MIRRORING_TRANSFORMATION);
- find_previous_button_->GetBounds(&back_button_rect,
- APPLY_MIRRORING_TRANSFORMATION);
- x = find_text_rect.right;
- w = find_text_rect.right - back_button_rect.right;
+ find_text_rect = find_text_->GetBounds(APPLY_MIRRORING_TRANSFORMATION);
+ back_button_rect =
+ find_previous_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION);
+ x = find_text_rect.right();
+ w = find_text_rect.right() - back_button_rect.right();
} else {
- find_text_->GetBounds(&find_text_rect);
- find_previous_button_->GetBounds(&back_button_rect);
- x = find_text_rect.left - kBackground_left->width();
- w = back_button_rect.left - find_text_rect.left;
+ find_text_rect = find_text_->bounds();
+ back_button_rect = find_previous_button_->bounds();
+ x = find_text_rect.x() - kBackground_left->width();
+ w = back_button_rect.x() - find_text_rect.x();
}
// Draw the image to the left that creates a curved left edge for the box
// (drawn on the right for RTL languages).
canvas->TileImageInt(*kBackground_left,
x,
- back_button_rect.top,
+ back_button_rect.y(),
kBackground_left->width(),
kBackground_left->height());
@@ -314,8 +314,8 @@ void FindInPageView::Paint(ChromeCanvas* canvas) {
int background_height = kBackground->height();
canvas->TileImageInt(*kBackground,
UILayoutIsRightToLeft() ?
- back_button_rect.right : find_text_rect.left,
- back_button_rect.top,
+ back_button_rect.right() : find_text_rect.x(),
+ back_button_rect.y(),
w,
background_height);
diff --git a/chrome/browser/history_view.cc b/chrome/browser/history_view.cc
index 737eedf..064e215 100644
--- a/chrome/browser/history_view.cc
+++ b/chrome/browser/history_view.cc
@@ -394,13 +394,10 @@ void HistoryItemRenderer::Paint(ChromeCanvas* canvas) {
if (favicon) {
// WARNING: if you change these values, update the code that determines
// whether we should allow a drag (GetDragRegion).
- CRect title_bounds;
- title_link_->GetBounds(&title_bounds);
// We need to tweak the favicon position if the UI layout is RTL.
gfx::Rect favicon_bounds;
- favicon_bounds.set_x(
- title_bounds.left - kIconPadding - kFavIconSize);
+ favicon_bounds.set_x(title_link_->x() - kIconPadding - kFavIconSize);
favicon_bounds.set_y(kEntryPadding);
favicon_bounds.set_width(favicon->width());
favicon_bounds.set_height(favicon->height());
@@ -602,14 +599,11 @@ HistoryItemRenderer::DragRegion HistoryItemRenderer::GetDragRegion(int x,
int y) {
// Is the location over the favicon?
SkBitmap* favicon = model_->GetFavicon(model_index_);
- CRect title_bounds;
- title_link_->GetBounds(&title_bounds);
if (favicon) {
// If the UI layout is right-to-left, we must make sure we mirror the
// favicon position before doing any hit testing.
gfx::Rect favicon_bounds;
- favicon_bounds.set_x(
- title_bounds.left - kIconPadding - kFavIconSize);
+ favicon_bounds.set_x(title_link_->x() - kIconPadding - kFavIconSize);
favicon_bounds.set_y(kEntryPadding);
favicon_bounds.set_width(favicon->width());
favicon_bounds.set_height(favicon->height());
diff --git a/chrome/browser/views/about_chrome_view.cc b/chrome/browser/views/about_chrome_view.cc
index d642aa7..2094372 100644
--- a/chrome/browser/views/about_chrome_view.cc
+++ b/chrome/browser/views/about_chrome_view.cc
@@ -312,8 +312,7 @@ void AboutChromeView::Paint(ChromeCanvas* canvas) {
ChromeFont font =
ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont);
- CRect bounds;
- main_text_label_->GetBounds(&bounds);
+ const gfx::Rect label_bounds = main_text_label_->bounds();
ChromeViews::Link* link1 =
chromium_url_appears_first_ ? chromium_url_ : open_source_url_;
@@ -330,12 +329,13 @@ void AboutChromeView::Paint(ChromeCanvas* canvas) {
CSize position;
// Draw the first text chunk and position the Chromium url.
DrawTextAndPositionUrl(canvas, main_label_chunk1_, link1,
- rect1, &position, bounds, font);
+ rect1, &position, label_bounds, font);
// Draw the second text chunk and position the Open Source url.
DrawTextAndPositionUrl(canvas, main_label_chunk2_, link2,
- rect2, &position, bounds, font);
+ rect2, &position, label_bounds, font);
// Draw the third text chunk.
- DrawTextStartingFrom(canvas, main_label_chunk3_, &position, bounds, font);
+ DrawTextStartingFrom(canvas, main_label_chunk3_, &position, label_bounds,
+ font);
#if defined(GOOGLE_CHROME_BUILD)
// Insert a line break and some whitespace.
@@ -344,9 +344,11 @@ void AboutChromeView::Paint(ChromeCanvas* canvas) {
// And now the Terms of Service and position the TOS url.
DrawTextAndPositionUrl(canvas, main_label_chunk4_, terms_of_service_url_,
- &terms_of_service_url_rect_, &position, bounds, font);
+ &terms_of_service_url_rect_, &position, label_bounds,
+ font);
// The last text chunk doesn't have a URL associated with it.
- DrawTextStartingFrom(canvas, main_label_chunk5_, &position, bounds, font);
+ DrawTextStartingFrom(canvas, main_label_chunk5_, &position, label_bounds,
+ font);
#endif
// Save the height so we can set the bounds correctly.
@@ -358,7 +360,7 @@ void AboutChromeView::DrawTextAndPositionUrl(ChromeCanvas* canvas,
ChromeViews::Link* link,
gfx::Rect* rect,
CSize* position,
- const CRect& bounds,
+ const gfx::Rect& bounds,
const ChromeFont& font) {
DCHECK(canvas && link && rect && position);
// Draw the text chunk.
@@ -371,7 +373,7 @@ void AboutChromeView::DrawTextAndPositionUrl(ChromeCanvas* canvas,
*rect = gfx::Rect(position->cx, position->cy, sz.cx, sz.cy);
// Going from relative to absolute pixel coordinates again.
- rect->Offset(bounds.TopLeft().x, bounds.TopLeft().y);
+ rect->Offset(bounds.x(), bounds.y());
// And leave some space to draw the link in.
position->cx += sz.cx;
}
@@ -379,7 +381,7 @@ void AboutChromeView::DrawTextAndPositionUrl(ChromeCanvas* canvas,
void AboutChromeView::DrawTextStartingFrom(ChromeCanvas* canvas,
const std::wstring& text,
CSize* position,
- const CRect& bounds,
+ const gfx::Rect& bounds,
const ChromeFont& font) {
// Iterate through line breaking opportunities (which in English would be
// spaces and such. This tells us where to wrap.
@@ -407,8 +409,8 @@ void AboutChromeView::DrawTextStartingFrom(ChromeCanvas* canvas,
// Draw the word on the screen (mirrored if RTL locale).
canvas->DrawStringInt(word, font, SK_ColorBLACK,
main_text_label_->MirroredXCoordinateInsideView(
- position->cx + bounds.TopLeft().x),
- position->cy + bounds.TopLeft().y,
+ position->cx + bounds.x()),
+ position->cy + bounds.y(),
w, h, flags);
if (word.size() > 0 && word[word.size() - 1] == L'\x0a') {
@@ -425,8 +427,8 @@ void AboutChromeView::DrawTextStartingFrom(ChromeCanvas* canvas,
void AboutChromeView::WrapIfWordDoesntFit(int word_width,
int font_height,
CSize* position,
- const CRect& bounds) {
- if (position->cx + word_width > bounds.right) {
+ const gfx::Rect& bounds) {
+ if (position->cx + word_width > bounds.right()) {
position->cx = 0;
position->cy += font_height;
}
diff --git a/chrome/browser/views/about_chrome_view.h b/chrome/browser/views/about_chrome_view.h
index 4de351f..1a1b704 100644
--- a/chrome/browser/views/about_chrome_view.h
+++ b/chrome/browser/views/about_chrome_view.h
@@ -96,7 +96,7 @@ class AboutChromeView : public ChromeViews::View,
ChromeViews::Link* link,
gfx::Rect* rect,
CSize* position,
- const CRect& bounds,
+ const gfx::Rect& bounds,
const ChromeFont& font);
// A helper function for DrawTextAndPositionUrl, which simply draws the text
@@ -105,7 +105,7 @@ class AboutChromeView : public ChromeViews::View,
void DrawTextStartingFrom(ChromeCanvas* canvas,
const std::wstring& text,
CSize* position,
- const CRect& bounds,
+ const gfx::Rect& bounds,
const ChromeFont& font);
// A simply utility function that calculates whether a word of width
@@ -114,7 +114,7 @@ class AboutChromeView : public ChromeViews::View,
void WrapIfWordDoesntFit(int word_width,
int font_height,
CSize* position,
- const CRect& bounds);
+ const gfx::Rect& bounds);
Profile* profile_;
diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc
index 76e3eb1..34ce0d0 100644
--- a/chrome/browser/views/constrained_window_impl.cc
+++ b/chrome/browser/views/constrained_window_impl.cc
@@ -502,9 +502,6 @@ CPoint ConstrainedWindowNonClientView::GetSystemMenuPoint() const {
}
int ConstrainedWindowNonClientView::NonClientHitTest(const gfx::Point& point) {
- CRect bounds;
- CPoint test_point = point.ToPOINT();
-
// First see if it's within the grow box area, since that overlaps the client
// bounds.
int component = container_->client_view()->NonClientHitTest(point);
@@ -512,11 +509,11 @@ int ConstrainedWindowNonClientView::NonClientHitTest(const gfx::Point& point) {
return component;
// Then see if the point is within any of the window controls.
- close_button_->GetBounds(&bounds);
- if (bounds.PtInRect(test_point))
+ gfx::Rect button_bounds =
+ close_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION);
+ if (button_bounds.Contains(point))
return HTCLOSE;
- bounds = icon_bounds_.ToRECT();
- if (bounds.PtInRect(test_point))
+ if (icon_bounds_.Contains(point))
return HTSYSMENU;
component = GetHTComponentForFrame(point, kResizeAreaSize,
@@ -525,8 +522,7 @@ int ConstrainedWindowNonClientView::NonClientHitTest(const gfx::Point& point) {
window_delegate_->CanResize());
if (component == HTNOWHERE) {
// Finally fall back to the caption.
- GetBounds(&bounds, APPLY_MIRRORING_TRANSFORMATION);
- if (bounds.PtInRect(test_point))
+ if (bounds().Contains(point))
component = HTCAPTION;
// Otherwise, the point is outside the window's bounds.
}
diff --git a/chrome/browser/views/first_run_view_base.cc b/chrome/browser/views/first_run_view_base.cc
index 81e72fee..51feba4 100644
--- a/chrome/browser/views/first_run_view_base.cc
+++ b/chrome/browser/views/first_run_view_base.cc
@@ -108,11 +108,10 @@ void FirstRunViewBase::SetupControls() {
}
void FirstRunViewBase::AdjustDialogWidth(const ChromeViews::View* sub_view) {
- CRect bounds;
- sub_view->GetBounds(&bounds);
+ gfx::Rect sub_view_bounds = sub_view->bounds();
preferred_width_ =
std::max(preferred_width_,
- static_cast<int>(bounds.right) + kPanelHorizMargin);
+ static_cast<int>(sub_view_bounds.right()) + kPanelHorizMargin);
}
void FirstRunViewBase::SetMinimumDialogWidth(int width) {
diff --git a/chrome/browser/views/frame/browser_view2.cc b/chrome/browser/views/frame/browser_view2.cc
index e4a81c1..6ed9661 100644
--- a/chrome/browser/views/frame/browser_view2.cc
+++ b/chrome/browser/views/frame/browser_view2.cc
@@ -120,16 +120,13 @@ void BrowserView2::WindowMoved() {
}
gfx::Rect BrowserView2::GetToolbarBounds() const {
- CRect bounds;
- toolbar_->GetBounds(&bounds);
- return gfx::Rect(bounds);
+ return toolbar_->bounds();
}
gfx::Rect BrowserView2::GetClientAreaBounds() const {
- CRect bounds;
- contents_container_->GetBounds(&bounds);
- bounds.OffsetRect(x(), y());
- return gfx::Rect(bounds);
+ gfx::Rect container_bounds = contents_container_->bounds();
+ container_bounds.Offset(x(), y());
+ return container_bounds;
}
int BrowserView2::GetTabStripHeight() const {
@@ -742,10 +739,9 @@ int BrowserView2::NonClientHitTest(const gfx::Point& point) {
// If the point's y coordinate is below the top of the toolbar and otherwise
// within the bounds of this view, the point is considered to be within the
// client area.
- CRect bounds;
- GetBounds(&bounds);
- bounds.top += toolbar_->y();
- if (gfx::Rect(bounds).Contains(point.x(), point.y()))
+ gfx::Rect bv_bounds = bounds();
+ bv_bounds.Offset(0, toolbar_->y());
+ if (bv_bounds.Contains(point))
return HTCLIENT;
// If the point's y coordinate is above the top of the toolbar, but not in
@@ -758,9 +754,9 @@ int BrowserView2::NonClientHitTest(const gfx::Point& point) {
// window controls not to work. So we return HTNOWHERE so that the caller
// will hit-test the window controls before finally falling back to
// HTCAPTION.
- GetBounds(&bounds);
- bounds.bottom = y() + toolbar_->y();
- if (gfx::Rect(bounds).Contains(point.x(), point.y()))
+ bv_bounds = bounds();
+ bv_bounds.set_height(toolbar_->y());
+ if (bv_bounds.Contains(point))
return HTNOWHERE;
// If the point is somewhere else, delegate to the default implementation.
@@ -1060,10 +1056,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.
- CRect last_bounds;
- (*old_view)->GetBounds(&last_bounds);
- new_view->SetBounds(last_bounds.left, last_bounds.top,
- last_bounds.Width(), last_bounds.Height());
+ new_view->SetBounds((*old_view)->bounds().ToRECT());
new_view->SchedulePaint();
} else if (new_view) {
DCHECK(new_height == 0);
diff --git a/chrome/browser/views/frame/opaque_non_client_view.cc b/chrome/browser/views/frame/opaque_non_client_view.cc
index f3b3afa..5bde0e6 100644
--- a/chrome/browser/views/frame/opaque_non_client_view.cc
+++ b/chrome/browser/views/frame/opaque_non_client_view.cc
@@ -527,9 +527,6 @@ CPoint OpaqueNonClientView::GetSystemMenuPoint() const {
}
int OpaqueNonClientView::NonClientHitTest(const gfx::Point& point) {
- CRect bounds;
- CPoint test_point = point.ToPOINT();
-
// First see if it's within the grow box area, since that overlaps the client
// bounds.
int component = frame_->client_view()->NonClientHitTest(point);
@@ -537,21 +534,22 @@ int OpaqueNonClientView::NonClientHitTest(const gfx::Point& point) {
return component;
// Then see if the point is within any of the window controls.
- close_button_->GetBounds(&bounds, APPLY_MIRRORING_TRANSFORMATION);
- if (bounds.PtInRect(test_point))
+ gfx::Rect button_bounds =
+ close_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION);
+ if (button_bounds.Contains(point))
return HTCLOSE;
- restore_button_->GetBounds(&bounds, APPLY_MIRRORING_TRANSFORMATION);
- if (bounds.PtInRect(test_point))
+ button_bounds = restore_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION);
+ if (button_bounds.Contains(point))
return HTMAXBUTTON;
- maximize_button_->GetBounds(&bounds, APPLY_MIRRORING_TRANSFORMATION);
- if (bounds.PtInRect(test_point))
+ button_bounds = maximize_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION);
+ if (button_bounds.Contains(point))
return HTMAXBUTTON;
- minimize_button_->GetBounds(&bounds, APPLY_MIRRORING_TRANSFORMATION);
- if (bounds.PtInRect(test_point))
+ button_bounds = minimize_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION);
+ if (button_bounds.Contains(point))
return HTMINBUTTON;
if (window_icon_) {
- window_icon_->GetBounds(&bounds, APPLY_MIRRORING_TRANSFORMATION);
- if (bounds.PtInRect(test_point))
+ button_bounds = window_icon_->GetBounds(APPLY_MIRRORING_TRANSFORMATION);
+ if (button_bounds.Contains(point))
return HTSYSMENU;
}
@@ -563,8 +561,7 @@ int OpaqueNonClientView::NonClientHitTest(const gfx::Point& point) {
frame_->window_delegate()->CanResize());
if (component == HTNOWHERE) {
// Finally fall back to the caption.
- GetBounds(&bounds, APPLY_MIRRORING_TRANSFORMATION);
- if (bounds.PtInRect(test_point))
+ if (bounds().Contains(point))
component = HTCAPTION;
// Otherwise, the point is outside the window's bounds.
}
@@ -647,9 +644,7 @@ ChromeViews::View* OpaqueNonClientView::GetViewForPoint(
for (int i = 0; i < arraysize(views); ++i) {
if (!views[i]->IsVisible())
continue;
- CRect bounds;
- views[i]->GetBounds(&bounds);
- if (bounds.PtInRect(point))
+ if (views[i]->bounds().Contains(gfx::Point(point)))
return views[i];
}
return View::GetViewForPoint(point, can_create_floating);
diff --git a/chrome/browser/views/old_frames/vista_frame.cc b/chrome/browser/views/old_frames/vista_frame.cc
index 592237a..e7cf71d 100644
--- a/chrome/browser/views/old_frames/vista_frame.cc
+++ b/chrome/browser/views/old_frames/vista_frame.cc
@@ -1479,10 +1479,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.
- CRect last_bounds;
- (*view)->GetBounds(&last_bounds);
- new_view->SetBounds(last_bounds.left, last_bounds.top,
- last_bounds.Width(), last_bounds.Height());
+ new_view->SetBounds((*view)->bounds().ToRECT());
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 5672ec2..36f6111 100644
--- a/chrome/browser/views/old_frames/xp_frame.cc
+++ b/chrome/browser/views/old_frames/xp_frame.cc
@@ -2337,10 +2337,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.
- CRect last_bounds;
- (*view)->GetBounds(&last_bounds);
- new_view->SetBounds(last_bounds.left, last_bounds.top,
- last_bounds.Width(), last_bounds.Height());
+ new_view->SetBounds((*view)->bounds().ToRECT());
new_view->SchedulePaint();
} else if (new_view) {
DCHECK(new_height == 0);
@@ -2432,14 +2429,13 @@ void XPFrame::SizeToContents(const gfx::Rect& contents_bounds) {
// Then we calculate the size of the window chrome, this is the stuff that
// needs to be positioned around the edges of contents_bounds.
- CRect bounds;
- tab_contents_container_->GetBounds(&bounds);
+ gfx::Rect bounds = tab_contents_container_->bounds();
CRect cr;
GetClientRect(&cr);
- int toolbar_height = bounds.top;
- int left_edge_width = bounds.left;
- int right_edge_width = cr.Width() - bounds.right;
- int bottom_edge_height = cr.Height() - bounds.bottom;
+ int toolbar_height = bounds.y();
+ int left_edge_width = bounds.x();
+ int right_edge_width = cr.Width() - bounds.right();
+ int bottom_edge_height = cr.Height() - bounds.bottom();
// Now resize the window. This will result in Layout() getting called again
// and the contents getting sized to the value specified in |contents_bounds|
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index ec1a705..083036b 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -543,11 +543,9 @@ bool TabStrip::PointIsWithinWindowCaption(const CPoint& point) {
// Check to see if the point is within the non-button parts of the new tab
// button. The button has a non-rectangular shape, so if it's not in the
// visual portions of the button we treat it as a click to the caption.
- CRect bounds;
- newtab_button_->GetBounds(&bounds);
CPoint point_in_newtab_coords(point);
View::ConvertPointToView(this, newtab_button_, &point_in_newtab_coords);
- if (bounds.PtInRect(point) &&
+ if (newtab_button_->bounds().Contains(gfx::Point(point)) &&
!newtab_button_->HitTest(point_in_newtab_coords)) {
return true;
}
diff --git a/chrome/views/accessibility/view_accessibility.cc b/chrome/views/accessibility/view_accessibility.cc
index 2790bb1..259eb5c 100644
--- a/chrome/views/accessibility/view_accessibility.cc
+++ b/chrome/views/accessibility/view_accessibility.cc
@@ -446,7 +446,7 @@ STDMETHODIMP ViewAccessibility::accLocation(LONG* x_left, LONG* y_top,
return E_INVALIDARG;
}
- CRect view_bounds(0, 0, 0, 0);
+ gfx::Rect view_bounds;
// Retrieving the parent View to be used for converting from view-to-screen
// coordinates.
ChromeViews::View* parent = view_->GetParent();
@@ -458,25 +458,26 @@ STDMETHODIMP ViewAccessibility::accLocation(LONG* x_left, LONG* y_top,
if (var_id.lVal == CHILDID_SELF) {
// Retrieve active View's bounds.
- view_->GetBounds(&view_bounds);
+ view_bounds = view_->bounds();
} else {
// Check to see if child is out-of-bounds.
if (!IsValidChild((var_id.lVal - 1), view_)) {
return E_INVALIDARG;
}
// Retrieve child bounds.
- view_->GetChildViewAt(var_id.lVal - 1)->GetBounds(&view_bounds);
+ view_bounds = view_->GetChildViewAt(var_id.lVal - 1)->bounds();
// Parent View is current View.
parent = view_;
}
- if (!view_bounds.IsRectNull()) {
- *width = view_bounds.Width();
- *height = view_bounds.Height();
+ if (!view_bounds.IsEmpty()) {
+ *width = view_bounds.width();
+ *height = view_bounds.height();
- ChromeViews::View::ConvertPointToScreen(parent, &view_bounds.TopLeft());
- *x_left = view_bounds.left;
- *y_top = view_bounds.top;
+ CPoint topleft = view_bounds.origin().ToPOINT();
+ ChromeViews::View::ConvertPointToScreen(parent, &topleft);
+ *x_left = topleft.x;
+ *y_top = topleft.y;
} else {
return E_FAIL;
}
diff --git a/chrome/views/bitmap_scroll_bar.cc b/chrome/views/bitmap_scroll_bar.cc
index 7dcf18e..948846bd 100644
--- a/chrome/views/bitmap_scroll_bar.cc
+++ b/chrome/views/bitmap_scroll_bar.cc
@@ -90,46 +90,40 @@ class BitmapScrollBarThumb : public View {
size = std::max(size,
static_cast<int>(scroll_bar_->IsHorizontal() ?
prefsize.cx : prefsize.cy));
- CRect bounds;
- GetBounds(&bounds);
+ gfx::Rect thumb_bounds = bounds();
if (scroll_bar_->IsHorizontal()) {
- bounds.right = bounds.left + size;
+ thumb_bounds.set_width(size);
} else {
- bounds.bottom = bounds.top + size;
+ thumb_bounds.set_height(size);
}
- SetBounds(bounds);
+ SetBounds(thumb_bounds.ToRECT());
}
// Retrieves the size (width or height) of the thumb.
int GetSize() const {
- CRect bounds;
- GetBounds(&bounds);
if (scroll_bar_->IsHorizontal())
- return bounds.Width();
- return bounds.Height();
+ return width();
+ return height();
}
// Sets the position of the thumb on the x or y axis.
void SetPosition(int position) {
- CRect bounds;
- GetBounds(&bounds);
+ gfx::Rect thumb_bounds = bounds();
gfx::Rect track_bounds = scroll_bar_->GetTrackBounds();
if (scroll_bar_->IsHorizontal()) {
- bounds.MoveToX(track_bounds.x() + position);
+ thumb_bounds.set_x(track_bounds.x() + position);
} else {
- bounds.MoveToY(track_bounds.y() + position);
+ thumb_bounds.set_x(track_bounds.y() + position);
}
- SetBounds(bounds);
+ SetBounds(thumb_bounds.ToRECT());
}
// Gets the position of the thumb on the x or y axis.
int GetPosition() const {
- CRect bounds;
- GetBounds(&bounds);
gfx::Rect track_bounds = scroll_bar_->GetTrackBounds();
if (scroll_bar_->IsHorizontal())
- return bounds.left - track_bounds.x();
- return bounds.top - track_bounds.y();
+ return x() - track_bounds.x();
+ return y() - track_bounds.y();
}
// View overrides:
@@ -380,11 +374,8 @@ void BitmapScrollBar::ScrollByContentsOffset(int contents_offset) {
}
void BitmapScrollBar::TrackClicked() {
- if (last_scroll_amount_ != SCROLL_NONE) {
- CRect thumb_bounds;
- thumb_->GetBounds(&thumb_bounds);
+ if (last_scroll_amount_ != SCROLL_NONE)
ScrollByAmount(last_scroll_amount_);
- }
}
///////////////////////////////////////////////////////////////////////////////
@@ -436,14 +427,12 @@ void BitmapScrollBar::Layout() {
// Preserve the height/width of the thumb (depending on orientation) as set
// by the last call to |Update|, but coerce the width/height to be the
// appropriate value for the bitmaps provided.
- CRect bounds;
- thumb_->GetBounds(&bounds);
if (IsHorizontal()) {
- thumb_->SetBounds(bounds.left, bounds.top, bounds.Width(),
+ thumb_->SetBounds(thumb_->x(), thumb_->y(), thumb_->width(),
thumb_prefsize.cy);
} else {
- thumb_->SetBounds(bounds.left, bounds.top, thumb_prefsize.cx,
- bounds.Height());
+ thumb_->SetBounds(thumb_->x(), thumb_->y(), thumb_prefsize.cx,
+ thumb_->height());
}
// Hide the thumb if the track isn't tall enough to display even a tiny
@@ -465,18 +454,17 @@ void BitmapScrollBar::DidChangeBounds(const CRect& previous,
bool BitmapScrollBar::OnMousePressed(const MouseEvent& event) {
if (event.IsOnlyLeftMouseButton()) {
SetThumbTrackState(BaseButton::BS_PUSHED);
- CRect thumb_bounds;
- thumb_->GetBounds(&thumb_bounds);
+ gfx::Rect thumb_bounds = thumb_->bounds();
if (IsHorizontal()) {
- if (event.x() < thumb_bounds.left) {
+ if (event.x() < thumb_bounds.x()) {
last_scroll_amount_ = SCROLL_PREV_PAGE;
- } else if (event.x() > thumb_bounds.right) {
+ } else if (event.x() > thumb_bounds.right()) {
last_scroll_amount_ = SCROLL_NEXT_PAGE;
}
} else {
- if (event.y() < thumb_bounds.top) {
+ if (event.y() < thumb_bounds.y()) {
last_scroll_amount_ = SCROLL_PREV_PAGE;
- } else if (event.y() > thumb_bounds.bottom) {
+ } else if (event.y() > thumb_bounds.bottom()) {
last_scroll_amount_ = SCROLL_NEXT_PAGE;
}
}
diff --git a/chrome/views/chrome_menu.cc b/chrome/views/chrome_menu.cc
index 537503f..f51e964 100644
--- a/chrome/views/chrome_menu.cc
+++ b/chrome/views/chrome_menu.cc
@@ -1016,9 +1016,7 @@ gfx::Rect SubmenuView::CalculateDropIndicatorBounds(
MenuItemView* item,
MenuDelegate::DropPosition position) {
DCHECK(position != MenuDelegate::DROP_NONE);
- CRect item_bounds_c;
- item->GetBounds(&item_bounds_c);
- gfx::Rect item_bounds(item_bounds_c);
+ gfx::Rect item_bounds = item->bounds();
switch (position) {
case MenuDelegate::DROP_BEFORE:
item_bounds.Offset(0, -kDropIndicatorHeight / 2);
diff --git a/chrome/views/client_view.cc b/chrome/views/client_view.cc
index bf66d90..ba994cd 100644
--- a/chrome/views/client_view.cc
+++ b/chrome/views/client_view.cc
@@ -16,11 +16,7 @@ ClientView::ClientView(Window* window, View* contents_view)
}
int ClientView::NonClientHitTest(const gfx::Point& point) {
- CRect bounds;
- GetBounds(&bounds, APPLY_MIRRORING_TRANSFORMATION);
- if (gfx::Rect(bounds).Contains(point.x(), point.y()))
- return HTCLIENT;
- return HTNOWHERE;
+ return bounds().Contains(point) ? HTCLIENT : HTNOWHERE;
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/views/custom_frame_window.cc b/chrome/views/custom_frame_window.cc
index 018a188..ebd705f 100644
--- a/chrome/views/custom_frame_window.cc
+++ b/chrome/views/custom_frame_window.cc
@@ -425,9 +425,6 @@ CPoint DefaultNonClientView::GetSystemMenuPoint() const {
// why this function passes APPLY_MIRRORING_TRANSFORMATION as the |settings|
// whenever it calls GetBounds().
int DefaultNonClientView::NonClientHitTest(const gfx::Point& point) {
- CRect bounds;
- CPoint test_point = point.ToPOINT();
-
// First see if it's within the grow box area, since that overlaps the client
// bounds.
int component = container_->client_view()->NonClientHitTest(point);
@@ -435,20 +432,22 @@ int DefaultNonClientView::NonClientHitTest(const gfx::Point& point) {
return component;
// Then see if the point is within any of the window controls.
- close_button_->GetBounds(&bounds, APPLY_MIRRORING_TRANSFORMATION);
- if (bounds.PtInRect(test_point))
+ gfx::Rect button_bounds =
+ close_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION);
+ if (button_bounds.Contains(point))
return HTCLOSE;
- restore_button_->GetBounds(&bounds, APPLY_MIRRORING_TRANSFORMATION);
- if (bounds.PtInRect(test_point))
+ button_bounds = restore_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION);
+ if (button_bounds.Contains(point))
return HTMAXBUTTON;
- maximize_button_->GetBounds(&bounds, APPLY_MIRRORING_TRANSFORMATION);
- if (bounds.PtInRect(test_point))
+ button_bounds = maximize_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION);
+ if (button_bounds.Contains(point))
return HTMAXBUTTON;
- minimize_button_->GetBounds(&bounds, APPLY_MIRRORING_TRANSFORMATION);
- if (bounds.PtInRect(test_point))
+ button_bounds = minimize_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION);
+ if (button_bounds.Contains(point))
return HTMINBUTTON;
- system_menu_button_->GetBounds(&bounds, APPLY_MIRRORING_TRANSFORMATION);
- if (bounds.PtInRect(test_point))
+ button_bounds =
+ system_menu_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION);
+ if (button_bounds.Contains(point))
return HTSYSMENU;
component = GetHTComponentForFrame(
@@ -459,8 +458,7 @@ int DefaultNonClientView::NonClientHitTest(const gfx::Point& point) {
container_->window_delegate()->CanResize());
if (component == HTNOWHERE) {
// Finally fall back to the caption.
- GetBounds(&bounds, APPLY_MIRRORING_TRANSFORMATION);
- if (bounds.PtInRect(test_point))
+ if (bounds().Contains(point))
component = HTCAPTION;
// Otherwise, the point is outside the window's bounds.
}
@@ -633,32 +631,31 @@ void DefaultNonClientView::PaintClientEdge(ChromeCanvas* canvas) {
resources()->GetPartBitmap(FRAME_CLIENT_EDGE_BOTTOM_LEFT);
SkBitmap* left = resources()->GetPartBitmap(FRAME_CLIENT_EDGE_LEFT);
- CRect client_area_bounds;
- container_->client_view()->GetBounds(&client_area_bounds);
-
- canvas->DrawBitmapInt(*top_left, client_area_bounds.left - top_left->width(),
- client_area_bounds.top - top->height());
- canvas->TileImageInt(*top, client_area_bounds.left,
- client_area_bounds.top - top->height(),
- client_area_bounds.Width(), top->height());
- canvas->DrawBitmapInt(*top_right, client_area_bounds.right,
- client_area_bounds.top - top->height());
- canvas->TileImageInt(*right, client_area_bounds.right,
- client_area_bounds.top - top->height() +
+ gfx::Rect client_area_bounds = container_->client_view()->bounds();
+
+ canvas->DrawBitmapInt(*top_left, client_area_bounds.x() - top_left->width(),
+ client_area_bounds.y() - top->height());
+ canvas->TileImageInt(*top, client_area_bounds.x(),
+ client_area_bounds.y() - top->height(),
+ client_area_bounds.width(), top->height());
+ canvas->DrawBitmapInt(*top_right, client_area_bounds.right(),
+ client_area_bounds.y() - top->height());
+ canvas->TileImageInt(*right, client_area_bounds.right(),
+ client_area_bounds.y() - top->height() +
top_right->height(),
- right->width(), client_area_bounds.Height());
- canvas->DrawBitmapInt(*bottom_right, client_area_bounds.right,
- client_area_bounds.bottom);
- canvas->TileImageInt(*bottom, client_area_bounds.left,
- client_area_bounds.bottom,
- client_area_bounds.Width(), bottom_right->height());
+ right->width(), client_area_bounds.height());
+ canvas->DrawBitmapInt(*bottom_right, client_area_bounds.right(),
+ client_area_bounds.bottom());
+ canvas->TileImageInt(*bottom, client_area_bounds.x(),
+ client_area_bounds.bottom(),
+ client_area_bounds.width(), bottom_right->height());
canvas->DrawBitmapInt(*bottom_left,
- client_area_bounds.left - bottom_left->width(),
- client_area_bounds.bottom);
- canvas->TileImageInt(*left, client_area_bounds.left - left->width(),
- client_area_bounds.top - top->height() +
+ client_area_bounds.x() - bottom_left->width(),
+ client_area_bounds.bottom());
+ canvas->TileImageInt(*left, client_area_bounds.x() - left->width(),
+ client_area_bounds.y() - top->height() +
top_left->height(),
- left->width(), client_area_bounds.Height());
+ left->width(), client_area_bounds.height());
}
void DefaultNonClientView::LayoutWindowControls() {
@@ -780,14 +777,13 @@ void DefaultNonClientView::LayoutTitleBar() {
// Size the title, if visible.
if (d->ShouldShowWindowTitle()) {
- CRect system_menu_bounds;
- system_menu_button_->GetBounds(&system_menu_bounds);
+ gfx::Rect system_menu_bounds = system_menu_button_->bounds();
int spacing = d->ShouldShowWindowIcon() ? kWindowIconTitleSpacing : 0;
int title_right = should_show_minmax_buttons_ ?
minimize_button_->x() : close_button_->x();
- int title_left = system_menu_bounds.right + spacing;
+ int title_left = system_menu_bounds.right() + spacing;
title_bounds_.SetRect(title_left, kTitleTopOffset + top_offset,
- std::max(0, static_cast<int>(title_right - system_menu_bounds.right)),
+ std::max(0, static_cast<int>(title_right - system_menu_bounds.right())),
title_font_.height());
// We draw the custom frame window's title directly rather than using a
diff --git a/chrome/views/grid_layout_unittest.cc b/chrome/views/grid_layout_unittest.cc
index 080cddb..4abfced 100644
--- a/chrome/views/grid_layout_unittest.cc
+++ b/chrome/views/grid_layout_unittest.cc
@@ -89,7 +89,7 @@ class GridLayoutAlignmentTest : public testing::Test {
EXPECT_TRUE(CSize(10, 20) == pref);
host.SetBounds(0, 0, 100, 100);
layout->Layout(&host);
- v1.GetBounds(bounds);
+ *bounds = v1.bounds().ToRECT();
RemoveAll();
}
diff --git a/chrome/views/label.cc b/chrome/views/label.cc
index 31053ac..ec6e5cb 100644
--- a/chrome/views/label.cc
+++ b/chrome/views/label.cc
@@ -346,18 +346,16 @@ void Label::SizeToFit(int max_width) {
std::vector<std::wstring> lines;
SplitString(text_, L'\n', &lines);
- int width = 0;
+ int label_width = 0;
for (std::vector<std::wstring>::const_iterator iter = lines.begin();
iter != lines.end(); ++iter) {
- width = std::max(width, font_.GetStringWidth(*iter));
+ label_width = std::max(label_width, font_.GetStringWidth(*iter));
}
if (max_width > 0)
- width = std::min(width, max_width);
+ label_width = std::min(label_width, max_width);
- CRect out;
- GetBounds(&out);
- SetBounds(out.left, out.top, width, 0);
+ SetBounds(x(), y(), width(), 0);
SizeToPreferredSize();
}
diff --git a/chrome/views/text_button.cc b/chrome/views/text_button.cc
index e4e7225..617860d 100644
--- a/chrome/views/text_button.cc
+++ b/chrome/views/text_button.cc
@@ -81,8 +81,7 @@ void TextButtonBorder::Paint(const View& view, ChromeCanvas* canvas) const {
set = &pushed_set_;
if (set) {
- CRect bounds;
- view.GetBounds(&bounds);
+ gfx::Rect bounds = view.bounds();
// Draw the top left image
canvas->DrawBitmapInt(*set->top_left, 0, 0);
@@ -90,43 +89,43 @@ void TextButtonBorder::Paint(const View& view, ChromeCanvas* canvas) const {
// Tile the top image
canvas->TileImageInt(*set->top,
set->top_left->width(), 0,
- bounds.Width() - set->top_right->width() - set->top_left->width(),
+ bounds.width() - set->top_right->width() - set->top_left->width(),
set->top->height());
// Draw the top right image
canvas->DrawBitmapInt(*set->top_right,
- bounds.Width() - set->top_right->width(), 0);
+ bounds.width() - set->top_right->width(), 0);
// Tile the left image
canvas->TileImageInt(*set->left,
0, set->top_left->height(),
set->top_left->width(),
- bounds.Height() - set->top->height() - set->bottom_left->height());
+ bounds.height() - set->top->height() - set->bottom_left->height());
// Tile the center image
canvas->TileImageInt(*set->center,
set->left->width(), set->top->height(),
- bounds.Width() - set->right->width() - set->left->width(),
- bounds.Height() - set->bottom->height() - set->top->height());
+ bounds.width() - set->right->width() - set->left->width(),
+ bounds.height() - set->bottom->height() - set->top->height());
// Tile the right image
canvas->TileImageInt(*set->right,
- bounds.Width() - set->right->width(), set->top_right->height(),
- bounds.Width(), bounds.Height() - set->bottom_right->height() - set->top_right->height());
+ bounds.width() - set->right->width(), set->top_right->height(),
+ bounds.width(), bounds.height() - set->bottom_right->height() - set->top_right->height());
// Draw the bottom left image
- canvas->DrawBitmapInt(*set->bottom_left, 0, bounds.Height() - set->bottom_left->height());
+ canvas->DrawBitmapInt(*set->bottom_left, 0, bounds.height() - set->bottom_left->height());
// Tile the bottom image
canvas->TileImageInt(*set->bottom,
- set->bottom_left->width(), bounds.Height() - set->bottom->height(),
- bounds.Width() - set->bottom_right->width() - set->bottom_left->width(),
+ set->bottom_left->width(), bounds.height() - set->bottom->height(),
+ bounds.width() - set->bottom_right->width() - set->bottom_left->width(),
set->bottom->height());
// Draw the bottom right image
canvas->DrawBitmapInt(*set->bottom_right,
- bounds.Width() - set->bottom_right->width(),
- bounds.Height() - set->bottom_right->height());
+ bounds.width() - set->bottom_right->width(),
+ bounds.height() - set->bottom_right->height());
} else {
// Do nothing
}
diff --git a/chrome/views/tooltip_manager.cc b/chrome/views/tooltip_manager.cc
index 112d380..a146933 100644
--- a/chrome/views/tooltip_manager.cc
+++ b/chrome/views/tooltip_manager.cc
@@ -379,9 +379,8 @@ void TooltipManager::ShowKeyboardTooltip(View* focused_view) {
HideKeyboardTooltip();
std::wstring tooltip_text;
if (!focused_view->GetTooltipText(0, 0, &tooltip_text))
- return ;
- CRect bounds;
- focused_view->GetBounds(&bounds);
+ return;
+ gfx::Rect focused_bounds = focused_view->bounds();
CPoint screen_point;
focused_view->ConvertPointToScreen(focused_view, &screen_point);
CPoint relative_point_coordinates;
@@ -409,9 +408,9 @@ void TooltipManager::ShowKeyboardTooltip(View* focused_view) {
reinterpret_cast<LPARAM>(&keyboard_toolinfo));
if (!tooltip_height_)
tooltip_height_ = CalcTooltipHeight();
- RECT rect_bounds = {screen_point.x, screen_point.y + bounds.Height(),
+ RECT rect_bounds = {screen_point.x, screen_point.y + focused_bounds.height(),
screen_point.x + tooltip_width,
- screen_point.y + bounds.Height() +
+ screen_point.y + focused_bounds.height() +
line_count * tooltip_height_ };
gfx::Rect monitor_bounds =
win_util::GetMonitorBoundsForRect(gfx::Rect(rect_bounds));
diff --git a/chrome/views/view.cc b/chrome/views/view.cc
index 9f107be..def0ec6 100644
--- a/chrome/views/view.cc
+++ b/chrome/views/view.cc
@@ -114,15 +114,16 @@ View::~View() {
//
/////////////////////////////////////////////////////////////////////////////
-void View::GetBounds(CRect* out, PositionMirroringSettings settings) const {
- *out = bounds_;
+gfx::Rect View::GetBounds(PositionMirroringSettings settings) const {
+ gfx::Rect bounds(bounds_);
// If the parent uses an RTL UI layout and if we are asked to transform the
// bounds to their mirrored position if necessary, then we should shift the
// rectangle appropriately.
- if (settings == APPLY_MIRRORING_TRANSFORMATION) {
- out->MoveToX(MirroredX());
- }
+ if (settings == APPLY_MIRRORING_TRANSFORMATION)
+ bounds.set_x(MirroredX());
+
+ return bounds;
}
// y(), width() and height() are agnostic to the RTL UI layout of the
diff --git a/chrome/views/view.h b/chrome/views/view.h
index 072e84d..6e46336 100644
--- a/chrome/views/view.h
+++ b/chrome/views/view.h
@@ -140,9 +140,8 @@ class View : public AcceleratorTarget {
// This is the function subclasses should use whenever they need to obtain
// the bounds of one of their child views (for example, when implementing
// View::Layout()).
- void GetBounds(CRect *out) const {
- GetBounds(out, IGNORE_MIRRORING_TRANSFORMATION);
- };
+ // TODO(beng): Convert |bounds_| to a gfx::Rect.
+ gfx::Rect bounds() const { return gfx::Rect(bounds_); }
// Return the bounds of the View, relative to the parent. If
// |settings| is IGNORE_MIRRORING_TRANSFORMATION, the function returns the
@@ -155,7 +154,7 @@ class View : public AcceleratorTarget {
// transparent to the View subclasses and therefore you should use the
// version of GetBounds() which does not take a transformation settings
// parameter.
- void GetBounds(CRect *out, PositionMirroringSettings settings) const;
+ gfx::Rect GetBounds(PositionMirroringSettings settings) const;
// Set the bounds in the parent's coordinate system.
void SetBounds(const CRect& bounds);
diff --git a/chrome/views/view_unittest.cc b/chrome/views/view_unittest.cc
index 4894525..94de4d2 100644
--- a/chrome/views/view_unittest.cc
+++ b/chrome/views/view_unittest.cc
@@ -165,9 +165,7 @@ TEST_F(ViewTest, DidChangeBounds) {
EXPECT_EQ(v->previous_bounds_, prev_rect);
EXPECT_EQ(v->new_bounds_, new_rect);
- CRect r;
- v->GetBounds(&r);
- EXPECT_EQ(r, new_rect);
+ EXPECT_EQ(v->bounds(), gfx::Rect(new_rect));
delete v;
}