summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
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 /chrome/browser/views
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
Diffstat (limited to 'chrome/browser/views')
-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
9 files changed, 58 insertions, 82 deletions
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;
}