summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-15 18:02:30 +0000
committerbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-15 18:02:30 +0000
commit154f8bcac65142d7ae6733204c15ae52cfa320c6 (patch)
treed7375c1119946c2914ee79ef2c0e8aa195b1fbe9 /chrome
parent8144d0cea4e142ff7d7a75c84240a4bb8a7fb3a4 (diff)
downloadchromium_src-154f8bcac65142d7ae6733204c15ae52cfa320c6.zip
chromium_src-154f8bcac65142d7ae6733204c15ae52cfa320c6.tar.gz
chromium_src-154f8bcac65142d7ae6733204c15ae52cfa320c6.tar.bz2
Convert GetPreferredSize from:
void GetPreferredSize(CSize* out); to: gfx::Size GetPreferredSize(); .. and update some other places to use gfx::Size as well. http://crbug.com/2186 Review URL: http://codereview.chromium.org/7344 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3400 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/debugger/debugger_view.cc5
-rw-r--r--chrome/browser/debugger/debugger_view.h2
-rw-r--r--chrome/browser/drag_utils.cc10
-rw-r--r--chrome/browser/find_in_page_controller.cc9
-rw-r--r--chrome/browser/find_in_page_view.cc80
-rw-r--r--chrome/browser/find_in_page_view.h2
-rw-r--r--chrome/browser/history_view.cc29
-rw-r--r--chrome/browser/native_ui_contents.cc12
-rw-r--r--chrome/browser/task_manager.cc20
-rw-r--r--chrome/browser/views/about_chrome_view.cc103
-rw-r--r--chrome/browser/views/about_chrome_view.h8
-rw-r--r--chrome/browser/views/bookmark_bar_view.cc86
-rw-r--r--chrome/browser/views/bookmark_bar_view.h2
-rw-r--r--chrome/browser/views/bookmark_bar_view_test.cc4
-rw-r--r--chrome/browser/views/bookmark_editor_view.cc16
-rw-r--r--chrome/browser/views/bookmark_editor_view.h2
-rw-r--r--chrome/browser/views/bug_report_view.cc7
-rw-r--r--chrome/browser/views/bug_report_view.h2
-rw-r--r--chrome/browser/views/clear_browsing_data.cc61
-rw-r--r--chrome/browser/views/clear_browsing_data.h2
-rw-r--r--chrome/browser/views/constrained_window_impl.cc34
-rw-r--r--chrome/browser/views/delay_view.cc46
-rw-r--r--chrome/browser/views/download_item_view.cc75
-rw-r--r--chrome/browser/views/download_item_view.h6
-rw-r--r--chrome/browser/views/download_shelf_view.cc82
-rw-r--r--chrome/browser/views/download_shelf_view.h2
-rw-r--r--chrome/browser/views/download_started_animation.cc13
-rw-r--r--chrome/browser/views/download_tab_view.cc163
-rw-r--r--chrome/browser/views/download_tab_view.h2
-rw-r--r--chrome/browser/views/first_run_bubble.cc55
-rw-r--r--chrome/browser/views/first_run_customize_view.cc40
-rw-r--r--chrome/browser/views/first_run_customize_view.h2
-rw-r--r--chrome/browser/views/first_run_view.cc20
-rw-r--r--chrome/browser/views/first_run_view.h2
-rw-r--r--chrome/browser/views/first_run_view_base.cc22
-rw-r--r--chrome/browser/views/frame/aero_glass_non_client_view.cc11
-rw-r--r--chrome/browser/views/frame/aero_glass_non_client_view.h2
-rw-r--r--chrome/browser/views/frame/browser_view.cc4
-rw-r--r--chrome/browser/views/frame/opaque_non_client_view.cc76
-rw-r--r--chrome/browser/views/frame/opaque_non_client_view.h2
-rw-r--r--chrome/browser/views/html_dialog_view.cc6
-rw-r--r--chrome/browser/views/html_dialog_view.h2
-rw-r--r--chrome/browser/views/hung_renderer_view.cc4
-rw-r--r--chrome/browser/views/importer_lock_view.cc7
-rw-r--r--chrome/browser/views/importer_lock_view.h2
-rw-r--r--chrome/browser/views/importer_view.cc7
-rw-r--r--chrome/browser/views/importer_view.h2
-rw-r--r--chrome/browser/views/importing_progress_view.cc12
-rw-r--r--chrome/browser/views/importing_progress_view.h2
-rw-r--r--chrome/browser/views/info_bar_item_view.cc38
-rw-r--r--chrome/browser/views/info_bar_item_view.h2
-rw-r--r--chrome/browser/views/info_bar_view.cc25
-rw-r--r--chrome/browser/views/info_bar_view.h2
-rw-r--r--chrome/browser/views/info_bubble.cc22
-rw-r--r--chrome/browser/views/info_bubble.h2
-rw-r--r--chrome/browser/views/keyword_editor_view.cc7
-rw-r--r--chrome/browser/views/keyword_editor_view.h2
-rw-r--r--chrome/browser/views/location_bar_view.cc114
-rw-r--r--chrome/browser/views/location_bar_view.h10
-rw-r--r--chrome/browser/views/old_frames/simple_vista_frame.cc5
-rw-r--r--chrome/browser/views/old_frames/simple_xp_frame.cc34
-rw-r--r--chrome/browser/views/old_frames/simple_xp_frame.h2
-rw-r--r--chrome/browser/views/old_frames/vista_frame.cc79
-rw-r--r--chrome/browser/views/old_frames/xp_frame.cc127
-rw-r--r--chrome/browser/views/options/advanced_contents_view.cc4
-rw-r--r--chrome/browser/views/options/content_page_view.cc16
-rw-r--r--chrome/browser/views/options/cookies_view.cc20
-rw-r--r--chrome/browser/views/options/cookies_view.h2
-rw-r--r--chrome/browser/views/options/fonts_languages_window_view.cc7
-rw-r--r--chrome/browser/views/options/fonts_languages_window_view.h2
-rw-r--r--chrome/browser/views/options/fonts_page_view.cc11
-rw-r--r--chrome/browser/views/options/languages_page_view.cc15
-rw-r--r--chrome/browser/views/options/options_window_view.cc9
-rw-r--r--chrome/browser/views/page_info_window.cc49
-rw-r--r--chrome/browser/views/password_manager_view.cc29
-rw-r--r--chrome/browser/views/password_manager_view.h6
-rw-r--r--chrome/browser/views/shelf_item_dialog.cc7
-rw-r--r--chrome/browser/views/shelf_item_dialog.h2
-rw-r--r--chrome/browser/views/star_toggle.cc5
-rw-r--r--chrome/browser/views/star_toggle.h2
-rw-r--r--chrome/browser/views/tab_icon_view.cc4
-rw-r--r--chrome/browser/views/tab_icon_view.h2
-rw-r--r--chrome/browser/views/tabs/dragged_tab_view.cc56
-rw-r--r--chrome/browser/views/tabs/dragged_tab_view.h2
-rw-r--r--chrome/browser/views/tabs/tab_renderer.cc13
-rw-r--r--chrome/browser/views/tabs/tab_renderer.h2
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc19
-rw-r--r--chrome/browser/views/tabs/tab_strip.h2
-rw-r--r--chrome/browser/views/toolbar_view.cc69
-rw-r--r--chrome/browser/views/toolbar_view.h2
-rw-r--r--chrome/test/interactive_ui/view_event_test_base.cc7
-rw-r--r--chrome/views/bitmap_scroll_bar.cc76
-rw-r--r--chrome/views/bitmap_scroll_bar.h2
-rw-r--r--chrome/views/button.cc12
-rw-r--r--chrome/views/button.h2
-rw-r--r--chrome/views/checkbox.cc18
-rw-r--r--chrome/views/checkbox.h2
-rw-r--r--chrome/views/chrome_menu.cc131
-rw-r--r--chrome/views/chrome_menu.h4
-rw-r--r--chrome/views/client_view.cc6
-rw-r--r--chrome/views/client_view.h2
-rw-r--r--chrome/views/combo_box.cc16
-rw-r--r--chrome/views/combo_box.h2
-rw-r--r--chrome/views/custom_frame_window.cc98
-rw-r--r--chrome/views/decision.cc39
-rw-r--r--chrome/views/decision.h2
-rw-r--r--chrome/views/dialog_client_view.cc27
-rw-r--r--chrome/views/dialog_client_view.h2
-rw-r--r--chrome/views/grid_layout.cc19
-rw-r--r--chrome/views/grid_layout.h2
-rw-r--r--chrome/views/grid_layout_unittest.cc138
-rw-r--r--chrome/views/hwnd_view.cc10
-rw-r--r--chrome/views/hwnd_view.h6
-rw-r--r--chrome/views/hwnd_view_container.cc4
-rw-r--r--chrome/views/hwnd_view_container.h2
-rw-r--r--chrome/views/image_view.cc22
-rw-r--r--chrome/views/image_view.h8
-rw-r--r--chrome/views/label.cc40
-rw-r--r--chrome/views/label.h8
-rw-r--r--chrome/views/layout_manager.cc4
-rw-r--r--chrome/views/layout_manager.h6
-rw-r--r--chrome/views/menu_button.cc10
-rw-r--r--chrome/views/menu_button.h2
-rw-r--r--chrome/views/message_box_view.cc11
-rw-r--r--chrome/views/native_button.cc5
-rw-r--r--chrome/views/native_button.h2
-rw-r--r--chrome/views/native_scroll_bar.cc13
-rw-r--r--chrome/views/native_scroll_bar.h2
-rw-r--r--chrome/views/radio_button.cc12
-rw-r--r--chrome/views/radio_button.h2
-rw-r--r--chrome/views/separator.cc6
-rw-r--r--chrome/views/separator.h2
-rw-r--r--chrome/views/table_view.cc9
-rw-r--r--chrome/views/table_view.h6
-rw-r--r--chrome/views/text_button.cc38
-rw-r--r--chrome/views/text_button.h8
-rw-r--r--chrome/views/text_field.cc7
-rw-r--r--chrome/views/text_field.h2
-rw-r--r--chrome/views/throbber.cc6
-rw-r--r--chrome/views/throbber.h2
-rw-r--r--chrome/views/view.cc29
-rw-r--r--chrome/views/view.h5
-rw-r--r--chrome/views/window.cc11
143 files changed, 1379 insertions, 1521 deletions
diff --git a/chrome/browser/debugger/debugger_view.cc b/chrome/browser/debugger/debugger_view.cc
index 494a23f..34b4de5 100644
--- a/chrome/browser/debugger/debugger_view.cc
+++ b/chrome/browser/debugger/debugger_view.cc
@@ -38,9 +38,8 @@ DebuggerView::DebuggerView() : output_ready_(false) {
DebuggerView::~DebuggerView() {
}
-void DebuggerView::GetPreferredSize(CSize* out) {
- out->cx = 700;
- out->cy = 400;
+gfx::Size DebuggerView::GetPreferredSize() {
+ return gfx::Size(700, 400);
}
void DebuggerView::Layout() {
diff --git a/chrome/browser/debugger/debugger_view.h b/chrome/browser/debugger/debugger_view.h
index 78931b8..ecb9e7a 100644
--- a/chrome/browser/debugger/debugger_view.h
+++ b/chrome/browser/debugger/debugger_view.h
@@ -47,7 +47,7 @@ class DebuggerView : public ChromeViews::View,
virtual std::string GetClassName() const {
return "DebuggerView";
}
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
virtual void Layout();
virtual void Paint(ChromeCanvas* canvas);
virtual void DidChangeBounds(const CRect& previous, const CRect& current);
diff --git a/chrome/browser/drag_utils.cc b/chrome/browser/drag_utils.cc
index f0be9be..5eb1c27 100644
--- a/chrome/browser/drag_utils.cc
+++ b/chrome/browser/drag_utils.cc
@@ -149,14 +149,14 @@ void SetURLAndDragImage(const GURL& url,
} else {
button.SetIcon(icon);
}
- CSize pref;
- button.GetPreferredSize(&pref);
- button.SetBounds(0, 0, pref.cx, pref.cy);
+ gfx::Size prefsize = button.GetPreferredSize();
+ button.SetBounds(gfx::Point(), prefsize);
// Render the image.
- ChromeCanvas canvas(pref.cx, pref.cy, false);
+ ChromeCanvas canvas(prefsize.width(), prefsize.height(), false);
button.Paint(&canvas, true);
- SetDragImageOnDataObject(canvas, pref.cx, pref.cy, pref.cx / 2, pref.cy / 2,
+ SetDragImageOnDataObject(canvas, prefsize.width(), prefsize.height(),
+ prefsize.width() / 2, prefsize.height() / 2,
data);
}
diff --git a/chrome/browser/find_in_page_controller.cc b/chrome/browser/find_in_page_controller.cc
index 916dc7d..86f7e84 100644
--- a/chrome/browser/find_in_page_controller.cc
+++ b/chrome/browser/find_in_page_controller.cc
@@ -562,21 +562,20 @@ gfx::Rect FindInPageController::GetDialogPosition(
return gfx::Rect();
// Ask the view how large an area it needs to draw on.
- CSize prefsize;
- view_->GetPreferredSize(&prefsize);
+ gfx::Size prefsize = view_->GetPreferredSize();
// Place the view in the top right corner of the dialog boundaries (top left
// for RTL languages).
gfx::Rect view_location;
int x = view_->UILayoutIsRightToLeft() ?
- dialog_bounds.x() : dialog_bounds.width() - prefsize.cx;
+ dialog_bounds.x() : dialog_bounds.width() - prefsize.width();
int y = dialog_bounds.y();
- view_location.SetRect(x, y, prefsize.cx, prefsize.cy);
+ view_location.SetRect(x, y, prefsize.width(), prefsize.height());
// Make sure we don't go out of bounds to the left (right in RTL) if the
// window is too small to fit our dialog.
if (view_->UILayoutIsRightToLeft()) {
- int boundary = dialog_bounds.width() - prefsize.cx;
+ int boundary = dialog_bounds.width() - prefsize.width();
view_location.set_x(std::min(view_location.x(), boundary));
} else {
view_location.set_x(std::max(view_location.x(), dialog_bounds.x()));
diff --git a/chrome/browser/find_in_page_view.cc b/chrome/browser/find_in_page_view.cc
index ac75944..813dc10 100644
--- a/chrome/browser/find_in_page_view.cc
+++ b/chrome/browser/find_in_page_view.cc
@@ -336,56 +336,56 @@ void FindInPageView::Paint(ChromeCanvas* canvas) {
}
void FindInPageView::Layout() {
- CSize panel_size, sz;
- GetPreferredSize(&panel_size);
+ gfx::Size panel_size = GetPreferredSize();
// First we draw the close button on the far right.
- close_button_->GetPreferredSize(&sz);
- close_button_->SetBounds(panel_size.cx - sz.cx - kMarginRightOfCloseButton,
- (height() - sz.cy) / 2,
- sz.cx,
- sz.cy);
+ gfx::Size sz = close_button_->GetPreferredSize();
+ close_button_->SetBounds(panel_size.width() - sz.width() -
+ kMarginRightOfCloseButton,
+ (height() - sz.height()) / 2,
+ sz.width(),
+ sz.height());
close_button_->SetListener(this, CLOSE_TAG);
// Next, the FindNext button to the left the close button.
- find_next_button_->GetPreferredSize(&sz);
+ sz = find_next_button_->GetPreferredSize();
find_next_button_->SetBounds(close_button_->x() -
find_next_button_->width() -
kMarginLeftOfCloseButton,
- (height() - sz.cy) / 2,
- sz.cx,
- sz.cy);
+ (height() - sz.height()) / 2,
+ sz.width(),
+ sz.height());
find_next_button_->SetListener(this, FIND_NEXT_TAG);
// Then, the FindPrevious button to the left the FindNext button.
- find_previous_button_->GetPreferredSize(&sz);
+ sz = find_previous_button_->GetPreferredSize();
find_previous_button_->SetBounds(find_next_button_->x() -
find_previous_button_->width(),
- (height() - sz.cy) / 2,
- sz.cx,
- sz.cy);
+ (height() - sz.height()) / 2,
+ sz.width(),
+ sz.height());
find_previous_button_->SetListener(this, FIND_PREVIOUS_TAG);
// Then the label showing the match count number.
- match_count_text_->GetPreferredSize(&sz);
+ sz = match_count_text_->GetPreferredSize();
// We extend the label bounds a bit to give the background highlighting a bit
// of breathing room (margins around the text).
- sz.cx += kMatchCountExtraWidth;
- sz.cx = std::max(kMatchCountMinWidth, static_cast<int>(sz.cx));
+ sz.Enlarge(kMatchCountExtraWidth, 0);
+ sz.set_width(std::max(kMatchCountMinWidth, static_cast<int>(sz.width())));
match_count_text_->SetBounds(find_previous_button_->x() -
kWhiteSpaceAfterMatchCountLabel -
- sz.cx,
- (height() - sz.cy) / 2 + 1,
- sz.cx,
- sz.cy);
+ sz.width(),
+ (height() - sz.height()) / 2 + 1,
+ sz.width(),
+ sz.height());
// And whatever space is left in between, gets filled up by the find edit box.
- find_text_->GetPreferredSize(&sz);
- sz.cx = match_count_text_->x() - kMarginLeftOfFindTextField;
- find_text_->SetBounds(match_count_text_->x() - sz.cx,
- (height() - sz.cy) / 2 + 1,
- sz.cx,
- sz.cy);
+ sz = find_text_->GetPreferredSize();
+ sz.set_width(match_count_text_->x() - kMarginLeftOfFindTextField);
+ find_text_->SetBounds(match_count_text_->x() - sz.width(),
+ (height() - sz.height()) / 2 + 1,
+ sz.width(),
+ sz.height());
find_text_->SetController(this);
find_text_->RequestFocus();
@@ -414,22 +414,18 @@ void FindInPageView::ViewHierarchyChanged(bool is_add,
}
}
-void FindInPageView::GetPreferredSize(CSize* out) {
- DCHECK(out);
-
- find_text_->GetPreferredSize(out);
- out->cy = kDlgBackground_middle->height();
+gfx::Size FindInPageView::GetPreferredSize() {
+ gfx::Size prefsize = find_text_->GetPreferredSize();
+ prefsize.set_height(kDlgBackground_middle->height());
// Add up all the preferred sizes and margins of the rest of the controls.
- out->cx += kMarginLeftOfCloseButton + kMarginRightOfCloseButton +
- kMarginLeftOfFindTextField;
- CSize sz;
- find_previous_button_->GetPreferredSize(&sz);
- out->cx += sz.cx;
- find_next_button_->GetPreferredSize(&sz);
- out->cx += sz.cx;
- close_button_->GetPreferredSize(&sz);
- out->cx += sz.cx;
+ prefsize.Enlarge(kMarginLeftOfCloseButton + kMarginRightOfCloseButton +
+ kMarginLeftOfFindTextField,
+ 0);
+ prefsize.Enlarge(find_previous_button_->GetPreferredSize().width(), 0);
+ prefsize.Enlarge(find_next_button_->GetPreferredSize().width(), 0);
+ prefsize.Enlarge(close_button_->GetPreferredSize().width(), 0);
+ return prefsize;
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/find_in_page_view.h b/chrome/browser/find_in_page_view.h
index 5b8e603..834568e 100644
--- a/chrome/browser/find_in_page_view.h
+++ b/chrome/browser/find_in_page_view.h
@@ -70,7 +70,7 @@ class FindInPageView : public ChromeViews::View,
virtual void Layout();
virtual void DidChangeBounds(const CRect& old_bounds,
const CRect& new_bounds);
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
// Overridden from ChromeViews::ButtonListener::ButtonPressed:
diff --git a/chrome/browser/history_view.cc b/chrome/browser/history_view.cc
index bdf29ba..6cac8f1 100644
--- a/chrome/browser/history_view.cc
+++ b/chrome/browser/history_view.cc
@@ -435,12 +435,10 @@ void HistoryItemRenderer::Layout() {
int title_x = kPageTitleOffset;
// We calculate the size of the star.
- CSize star_size;
- star_toggle_->GetPreferredSize(&star_size);
+ gfx::Size star_size = star_toggle_->GetPreferredSize();
// Measure and lay out the time label, and potentially move
// our title to suit.
- CSize time_size;
Time visit_time = model_->GetVisitTime(model_index_);
int time_x = kTimeOffset;
if (visit_time.is_null()) {
@@ -453,10 +451,10 @@ void HistoryItemRenderer::Layout() {
} else {
time_label_->SetText(base::TimeFormatTimeOfDay(visit_time));
}
- time_label_->GetPreferredSize(&time_size);
+ gfx::Size time_size = time_label_->GetPreferredSize();
time_label_->SetBounds(time_x, kEntryPadding,
- time_size.cx, time_size.cy);
+ time_size.width(), time_size.height());
// Calculate the position of the favicon.
int favicon_x = title_x - kFavIconSize - kIconPadding;
@@ -464,7 +462,7 @@ void HistoryItemRenderer::Layout() {
// Now we look to see if the favicon overlaps the time label,
// and if so, we push the title to the right. If we're not
// showing the time label, then ignore this step.
- int overlap = favicon_x - (time_x + time_size.cx + kIconPadding);
+ int overlap = favicon_x - (time_x + time_size.width() + kIconPadding);
if (overlap < 0) {
title_x -= overlap;
}
@@ -475,25 +473,25 @@ void HistoryItemRenderer::Layout() {
title_link_->SetText(title);
else
title_link_->SetText(l10n_util::GetString(IDS_HISTORY_UNTITLED_TITLE));
- CSize title_size;
- title_link_->GetPreferredSize(&title_size);
+ gfx::Size title_size = title_link_->GetPreferredSize();
// Lay out the title label.
int max_title_x;
max_title_x = std::max(0, max_x - title_x);
- if (title_size.cx + kEntryPadding > max_title_x) {
+ if (title_size.width() + kEntryPadding > max_title_x) {
// We need to shrink the title to make everything fit.
- title_size.cx = max_title_x - kEntryPadding;
+ title_size.set_width(max_title_x - kEntryPadding);
}
title_link_->SetBounds(title_x, kEntryPadding,
- title_size.cx, title_size.cy);
+ title_size.width(), title_size.height());
// Lay out the star.
if (model_->IsStarred(model_index_)) {
- star_toggle_->SetBounds(title_x + title_size.cx + kIconPadding,
- kEntryPadding, star_size.cx, star_size.cy);
+ star_toggle_->SetBounds(title_x + title_size.width() + kIconPadding,
+ kEntryPadding, star_size.width(),
+ star_size.height());
star_toggle_->SetState(true);
star_toggle_->SetVisible(true);
} else {
@@ -1293,10 +1291,9 @@ int HistoryView::CalculateDeleteOffset(
int HistoryView::GetDeleteControlWidth() {
if (delete_control_width_)
return delete_control_width_;
- CSize pref;
EnsureRenderer();
- delete_renderer_->GetPreferredSize(&pref);
- delete_control_width_ = pref.cx;
+ gfx::Size pref = delete_renderer_->GetPreferredSize();
+ delete_control_width_ = pref.width();
return delete_control_width_;
}
diff --git a/chrome/browser/native_ui_contents.cc b/chrome/browser/native_ui_contents.cc
index b54865c..ef81dbd 100644
--- a/chrome/browser/native_ui_contents.cc
+++ b/chrome/browser/native_ui_contents.cc
@@ -593,23 +593,21 @@ ChromeViews::View* SearchableUIContainer::GetContents() {
void SearchableUIContainer::Layout() {
View::Layout();
- CSize search_button_size;
- search_button_->GetPreferredSize(&search_button_size);
-
- CSize product_logo_size;
- product_logo_->GetPreferredSize(&product_logo_size);
+ gfx::Size search_button_size = search_button_->GetPreferredSize();
+ gfx::Size product_logo_size = product_logo_->GetPreferredSize();
int field_width = kDestinationSearchOffset +
kDestinationSearchWidth +
kDestinationSmallerMargin +
- static_cast<int>(search_button_size.cx) +
+ static_cast<int>(search_button_size.width()) +
kDestinationSmallerMargin;
product_logo_->SetBounds(std::max(width() - kProductLogo->width() -
kProductLogoPadding,
field_width),
kProductLogoPadding,
- product_logo_size.cx, product_logo_size.cy);
+ product_logo_size.width(),
+ product_logo_size.height());
}
void SearchableUIContainer::Paint(ChromeCanvas* canvas) {
diff --git a/chrome/browser/task_manager.cc b/chrome/browser/task_manager.cc
index bbe758e..82afafc 100644
--- a/chrome/browser/task_manager.cc
+++ b/chrome/browser/task_manager.cc
@@ -666,7 +666,7 @@ class TaskManagerContents : public ChromeViews::View,
void Init(TaskManagerTableModel* table_model);
virtual void Layout();
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual void ViewHierarchyChanged(bool is_add, ChromeViews::View* parent,
ChromeViews::View* child);
@@ -844,10 +844,9 @@ void TaskManagerContents::Layout() {
int x = bounds.left;
int y = bounds.top;
- CSize size;
- kill_button_->GetPreferredSize(&size);
- int prefered_width = size.cx;
- int prefered_height = size.cy;
+ gfx::Size size = kill_button_->GetPreferredSize();
+ int prefered_width = size.width();
+ int prefered_height = size.height();
tab_table_->SetBounds(
x + kPanelHorizMargin,
@@ -866,9 +865,9 @@ void TaskManagerContents::Layout() {
prefered_width,
prefered_height);
- about_memory_link_->GetPreferredSize(&size);
- int link_prefered_width = size.cx;
- int link_prefered_height = size.cy;
+ size = about_memory_link_->GetPreferredSize();
+ int link_prefered_width = size.width();
+ int link_prefered_height = size.height();
// center between the two buttons horizontally, and line up with
// bottom of buttons vertically.
int link_y_offset = std::max(0, prefered_height - link_prefered_height) / 2;
@@ -879,9 +878,8 @@ void TaskManagerContents::Layout() {
link_prefered_height);
}
-void TaskManagerContents::GetPreferredSize(CSize* out) {
- out->cx = kDefaultWidth;
- out->cy = kDefaultHeight;
+gfx::Size TaskManagerContents::GetPreferredSize() {
+ return gfx::Size(kDefaultWidth, kDefaultHeight);
}
void TaskManagerContents::GetSelection(std::vector<int>* selection) {
diff --git a/chrome/browser/views/about_chrome_view.cc b/chrome/browser/views/about_chrome_view.cc
index 2094372..e5a8262 100644
--- a/chrome/browser/views/about_chrome_view.cc
+++ b/chrome/browser/views/about_chrome_view.cc
@@ -189,62 +189,60 @@ void AboutChromeView::Init() {
////////////////////////////////////////////////////////////////////////////////
// AboutChromeView, ChromeViews::View implementation:
-void AboutChromeView::GetPreferredSize(CSize *out) {
- DCHECK(out);
- *out = ChromeViews::Window::GetLocalizedContentsSize(
+gfx::Size AboutChromeView::GetPreferredSize() {
+ gfx::Size prefsize(ChromeViews::Window::GetLocalizedContentsSize(
IDS_ABOUT_DIALOG_WIDTH_CHARS,
- IDS_ABOUT_DIALOG_HEIGHT_LINES).ToSIZE();
+ IDS_ABOUT_DIALOG_HEIGHT_LINES));
// We compute the height of the dialog based on the size of the image (it
// would be nice to not hard code this), the text in the about dialog and the
// margins around the text.
- out->cy += 145 + (kPanelVertMargin * 2);
+ prefsize.Enlarge(0, 145 + (kPanelVertMargin * 2));
// TODO(beng): Eventually the image should be positioned such that hard-
// coding the width isn't necessary. This breaks with fonts
// that are large and cause wrapping.
- out->cx = 422;
+ prefsize.set_width(422);
+ return prefsize;
}
void AboutChromeView::Layout() {
- CSize panel_size;
- GetPreferredSize(&panel_size);
-
- CSize sz;
+ gfx::Size panel_size = GetPreferredSize();
// Background image for the dialog.
- about_dlg_background_->GetPreferredSize(&sz);
- int background_image_height = sz.cy; // used to position main text below.
- about_dlg_background_->SetBounds(0, 0, sz.cx, sz.cy);
+ gfx::Size sz = about_dlg_background_->GetPreferredSize();
+ // used to position main text below.
+ int background_image_height = sz.height();
+ about_dlg_background_->SetBounds(0, 0, sz.width(), sz.height());
// First label goes to the top left corner.
- about_title_label_->GetPreferredSize(&sz);
+ sz = about_title_label_->GetPreferredSize();
about_title_label_->SetBounds(kPanelHorizMargin, kPanelVertMargin,
- sz.cx, sz.cy);
+ sz.width(), sz.height());
// Then we have the version number right below it.
- version_label_->GetPreferredSize(&sz);
+ sz = version_label_->GetPreferredSize();
version_label_->SetBounds(kPanelHorizMargin,
about_title_label_->y() +
about_title_label_->height() +
kRelatedControlVerticalSpacing,
kVersionFieldWidth,
- sz.cy);
+ sz.height());
// For the width of the main text label we want to use up the whole panel
// width and remaining height, minus a little margin on each side.
int y_pos = background_image_height + kRelatedControlVerticalSpacing;
- sz.cx = panel_size.cx - 2 * kPanelHorizMargin;
+ sz.set_width(panel_size.width() - 2 * kPanelHorizMargin);
// Draw the text right below the background image.
copyright_label_->SetBounds(kPanelHorizMargin,
y_pos,
- sz.cx,
- sz.cy);
+ sz.width(),
+ sz.height());
// Then the main_text_label.
main_text_label_->SetBounds(kPanelHorizMargin,
copyright_label_->y() +
copyright_label_->height(),
- sz.cx,
+ sz.width(),
main_text_label_height_);
// Position the URLs within the main label. The rects here are calculated when
@@ -271,38 +269,39 @@ void AboutChromeView::Layout() {
CRect parent_bounds;
GetParent()->GetLocalBounds(&parent_bounds, false);
- throbber_->GetPreferredSize(&sz);
+ sz = throbber_->GetPreferredSize();
int throbber_topleft_x = kPanelHorizMargin;
- int throbber_topleft_y = parent_bounds.bottom - sz.cy -
+ int throbber_topleft_y = parent_bounds.bottom - sz.height() -
kButtonVEdgeMargin - 3;
- throbber_->SetBounds(throbber_topleft_x, throbber_topleft_y, sz.cx, sz.cy);
+ throbber_->SetBounds(throbber_topleft_x, throbber_topleft_y,
+ sz.width(), sz.height());
// This image is hidden (see ViewHierarchyChanged) and displayed on demand.
- success_indicator_.GetPreferredSize(&sz);
+ sz = success_indicator_.GetPreferredSize();
success_indicator_.SetBounds(throbber_topleft_x, throbber_topleft_y,
- sz.cx, sz.cy);
+ sz.width(), sz.height());
// This image is hidden (see ViewHierarchyChanged) and displayed on demand.
- update_available_indicator_.GetPreferredSize(&sz);
+ sz = update_available_indicator_.GetPreferredSize();
update_available_indicator_.SetBounds(throbber_topleft_x, throbber_topleft_y,
- sz.cx, sz.cy);
+ sz.width(), sz.height());
// This image is hidden (see ViewHierarchyChanged) and displayed on demand.
- timeout_indicator_.GetPreferredSize(&sz);
+ sz = timeout_indicator_.GetPreferredSize();
timeout_indicator_.SetBounds(throbber_topleft_x, throbber_topleft_y,
- sz.cx, sz.cy);
+ sz.width(), sz.height());
// The update label should be at the bottom of the screen, to the right of
// the throbber. We specify width to the end of the dialog because it contains
// variable length messages.
- update_label_.GetPreferredSize(&sz);
+ sz = update_label_.GetPreferredSize();
int update_label_x = throbber_->x() + throbber_->width() +
kRelatedControlHorizontalSpacing;
update_label_.SetHorizontalAlignment(ChromeViews::Label::ALIGN_LEFT);
update_label_.SetBounds(update_label_x,
throbber_topleft_y + 1,
parent_bounds.Width() - update_label_x,
- sz.cy);
+ sz.height());
}
@@ -326,7 +325,7 @@ void AboutChromeView::Paint(ChromeCanvas* canvas) {
// This struct keeps track of where to write the next word (which x,y
// pixel coordinate). This struct is updated after drawing text and checking
// if we need to wrap.
- CSize position;
+ gfx::Size position;
// Draw the first text chunk and position the Chromium url.
DrawTextAndPositionUrl(canvas, main_label_chunk1_, link1,
rect1, &position, label_bounds, font);
@@ -339,8 +338,8 @@ void AboutChromeView::Paint(ChromeCanvas* canvas) {
#if defined(GOOGLE_CHROME_BUILD)
// Insert a line break and some whitespace.
- position.cx = 0;
- position.cy += font.height() + kRelatedControlVerticalSpacing;
+ position.set_width(0);
+ position.Enlarge(0, font.height() + kRelatedControlVerticalSpacing);
// And now the Terms of Service and position the TOS url.
DrawTextAndPositionUrl(canvas, main_label_chunk4_, terms_of_service_url_,
@@ -352,14 +351,14 @@ void AboutChromeView::Paint(ChromeCanvas* canvas) {
#endif
// Save the height so we can set the bounds correctly.
- main_text_label_height_ = position.cy + font.height();
+ main_text_label_height_ = position.height() + font.height();
}
void AboutChromeView::DrawTextAndPositionUrl(ChromeCanvas* canvas,
const std::wstring& text,
ChromeViews::Link* link,
gfx::Rect* rect,
- CSize* position,
+ gfx::Size* position,
const gfx::Rect& bounds,
const ChromeFont& font) {
DCHECK(canvas && link && rect && position);
@@ -367,20 +366,20 @@ void AboutChromeView::DrawTextAndPositionUrl(ChromeCanvas* canvas,
DrawTextStartingFrom(canvas, text, position, bounds, font);
// And then position the link after it.
- CSize sz;
- link->GetPreferredSize(&sz);
- WrapIfWordDoesntFit(sz.cx, font.height(), position, bounds);
- *rect = gfx::Rect(position->cx, position->cy, sz.cx, sz.cy);
+ gfx::Size sz = link->GetPreferredSize();
+ WrapIfWordDoesntFit(sz.width(), font.height(), position, bounds);
+ *rect = gfx::Rect(position->width(), position->height(), sz.width(),
+ sz.height());
// Going from relative to absolute pixel coordinates again.
rect->Offset(bounds.x(), bounds.y());
// And leave some space to draw the link in.
- position->cx += sz.cx;
+ position->Enlarge(sz.width(), 0);
}
void AboutChromeView::DrawTextStartingFrom(ChromeCanvas* canvas,
const std::wstring& text,
- CSize* position,
+ gfx::Size* position,
const gfx::Rect& bounds,
const ChromeFont& font) {
// Iterate through line breaking opportunities (which in English would be
@@ -409,28 +408,28 @@ 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.x()),
- position->cy + bounds.y(),
+ position->width() + bounds.x()),
+ position->height() + bounds.y(),
w, h, flags);
if (word.size() > 0 && word[word.size() - 1] == L'\x0a') {
// When we come across '\n', we move to the beginning of the next line.
- position->cx = 0;
- position->cy += font.height();
+ position->set_width(0);
+ position->Enlarge(0, font.height());
} else {
// Otherwise, we advance position to the next word.
- position->cx += w;
+ position->Enlarge(w, 0);
}
}
}
void AboutChromeView::WrapIfWordDoesntFit(int word_width,
int font_height,
- CSize* position,
+ gfx::Size* position,
const gfx::Rect& bounds) {
- if (position->cx + word_width > bounds.right()) {
- position->cx = 0;
- position->cy += font_height;
+ if (position->width() + word_width > bounds.right()) {
+ position->set_width(0);
+ position->Enlarge(0, font_height);
}
}
diff --git a/chrome/browser/views/about_chrome_view.h b/chrome/browser/views/about_chrome_view.h
index 1a1b704..eaa35c2 100644
--- a/chrome/browser/views/about_chrome_view.h
+++ b/chrome/browser/views/about_chrome_view.h
@@ -39,7 +39,7 @@ class AboutChromeView : public ChromeViews::View,
void Init();
// Overridden from ChromeViews::View:
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
virtual void Layout();
virtual void Paint(ChromeCanvas* canvas);
virtual void ViewHierarchyChanged(bool is_add,
@@ -95,7 +95,7 @@ class AboutChromeView : public ChromeViews::View,
const std::wstring& text,
ChromeViews::Link* link,
gfx::Rect* rect,
- CSize* position,
+ gfx::Size* position,
const gfx::Rect& bounds,
const ChromeFont& font);
@@ -104,7 +104,7 @@ class AboutChromeView : public ChromeViews::View,
// details on the parameters, see DrawTextAndPositionUrl.
void DrawTextStartingFrom(ChromeCanvas* canvas,
const std::wstring& text,
- CSize* position,
+ gfx::Size* position,
const gfx::Rect& bounds,
const ChromeFont& font);
@@ -113,7 +113,7 @@ class AboutChromeView : public ChromeViews::View,
// not, |position| is updated to wrap to the beginning of the next line.
void WrapIfWordDoesntFit(int word_width,
int font_height,
- CSize* position,
+ gfx::Size* position,
const gfx::Rect& bounds);
Profile* profile_;
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc
index 8b628f6..dce6d08 100644
--- a/chrome/browser/views/bookmark_bar_view.cc
+++ b/chrome/browser/views/bookmark_bar_view.cc
@@ -628,10 +628,10 @@ class ButtonSeparatorView : public ChromeViews::View {
canvas->drawRect(rc_down, paint_down);
}
- virtual void GetPreferredSize(CSize* out) {
+ virtual gfx::Size GetPreferredSize() {
// We get the full height of the bookmark bar, so that the height returned
// here doesn't matter.
- out->SetSize(kSeparatorWidth, 1);
+ return gfx::Size(kSeparatorWidth, 1);
}
private:
@@ -739,25 +739,29 @@ void BookmarkBarView::SetPageNavigator(PageNavigator* navigator) {
page_navigator_ = navigator;
}
-void BookmarkBarView::GetPreferredSize(CSize *out) {
+gfx::Size BookmarkBarView::GetPreferredSize() {
if (!prefButtonHeight) {
ChromeViews::TextButton text_button(L"X");
- CSize text_button_pref;
- text_button.GetMinimumSize(&text_button_pref);
- prefButtonHeight = static_cast<int>(text_button_pref.cy);
+ gfx::Size text_button_pref = text_button.GetMinimumSize();
+ prefButtonHeight = static_cast<int>(text_button_pref.height());
}
+ gfx::Size prefsize;
if (IsNewTabPage()) {
- out->cy = kBarHeight + static_cast<int>(static_cast<double>
- (kNewtabBarHeight - kBarHeight) *
- (1 - size_animation_->GetCurrentValue()));
+ prefsize.set_height(kBarHeight + static_cast<int>(static_cast<double>
+ (kNewtabBarHeight - kBarHeight) *
+ (1 - size_animation_->GetCurrentValue())));
} else {
- out->cy = std::max(static_cast<int>(static_cast<double>(kBarHeight) *
- size_animation_->GetCurrentValue()), 1);
+ prefsize.set_height(
+ std::max(static_cast<int>(static_cast<double>(kBarHeight) *
+ size_animation_->GetCurrentValue()), 1));
}
- // Width doesn't matter, we're always given a width based on the browser size.
- out->cx = 1;
+ // Width doesn't matter, we're always given a width based on the browser
+ // size.
+ prefsize.set_width(1);
+
+ return prefsize;
}
void BookmarkBarView::Layout() {
@@ -786,33 +790,32 @@ void BookmarkBarView::Layout() {
(kSeparatorMargin) * current_state);
}
- CSize other_bookmarked_pref;
- other_bookmarked_button_->GetPreferredSize(&other_bookmarked_pref);
- CSize overflow_pref;
- overflow_button_->GetPreferredSize(&overflow_pref);
- CSize bookmarks_separator_pref;
- bookmarks_separator_view_->GetPreferredSize(&bookmarks_separator_pref);
- const int max_x = width - other_bookmarked_pref.cx - kButtonPadding -
- overflow_pref.cx - kButtonPadding -
- bookmarks_separator_pref.cx;
+ gfx::Size other_bookmarked_pref =
+ other_bookmarked_button_->GetPreferredSize();
+ gfx::Size overflow_pref = overflow_button_->GetPreferredSize();
+ gfx::Size bookmarks_separator_pref =
+ bookmarks_separator_view_->GetPreferredSize();
+ const int max_x = width - other_bookmarked_pref.width() - kButtonPadding -
+ overflow_pref.width() - kButtonPadding -
+ bookmarks_separator_pref.width();
if (GetBookmarkButtonCount() == 0 && model_ && model_->IsLoaded()) {
- CSize pref;
- instructions_->GetPreferredSize(&pref);
- instructions_->SetBounds(x + kInstructionsPadding, y,
- std::min(static_cast<int>(pref.cx), max_x - x),
- height);
+ gfx::Size pref = instructions_->GetPreferredSize();
+ instructions_->SetBounds(
+ x + kInstructionsPadding, y,
+ std::min(static_cast<int>(pref.width()),
+ max_x - x),
+ height);
instructions_->SetVisible(true);
} else {
instructions_->SetVisible(false);
for (int i = 0; i < GetBookmarkButtonCount(); ++i) {
ChromeViews::View* child = GetChildViewAt(i);
- CSize pref;
- child->GetPreferredSize(&pref);
- int next_x = x + pref.cx + kButtonPadding;
+ gfx::Size pref = child->GetPreferredSize();
+ int next_x = x + pref.width() + kButtonPadding;
child->SetVisible(next_x < max_x);
- child->SetBounds(x, y, pref.cx, height);
+ child->SetBounds(x, y, pref.width(), height);
x = next_x;
}
}
@@ -826,21 +829,22 @@ void BookmarkBarView::Layout() {
x = max_x + kButtonPadding;
// The overflow button.
- overflow_button_->SetBounds(x, y, overflow_pref.cx, height);
+ overflow_button_->SetBounds(x, y, overflow_pref.width(), height);
overflow_button_->SetVisible(!all_visible);
- x += overflow_pref.cx;
+ x += overflow_pref.height();
// Separator.
bookmarks_separator_view_->SetBounds(x,
y - kTopMargin,
- bookmarks_separator_pref.cx,
+ bookmarks_separator_pref.width(),
height + kTopMargin + kBottomMargin -
separator_margin);
- x += bookmarks_separator_pref.cx;
+ x += bookmarks_separator_pref.width();
- other_bookmarked_button_->SetBounds(x, y, other_bookmarked_pref.cx, height);
- x += other_bookmarked_pref.cx + kButtonPadding;
+ other_bookmarked_button_->SetBounds(x, y, other_bookmarked_pref.width(),
+ height);
+ x += other_bookmarked_pref.width() + kButtonPadding;
}
void BookmarkBarView::DidChangeBounds(const CRect& previous,
@@ -1298,12 +1302,10 @@ void BookmarkBarView::BookmarkNodeChangedImpl(BookmarkModel* model,
int index = model_->GetBookmarkBarNode()->IndexOfChild(node);
DCHECK(index != -1);
ChromeViews::TextButton* button = GetBookmarkButton(index);
- CSize old_pref;
- button->GetPreferredSize(&old_pref);
+ gfx::Size old_pref = button->GetPreferredSize();
ConfigureButton(node, button);
- CSize new_pref;
- button->GetPreferredSize(&new_pref);
- if (old_pref.cx != new_pref.cx) {
+ gfx::Size new_pref = button->GetPreferredSize();
+ if (old_pref.width() != new_pref.width()) {
Layout();
SchedulePaint();
} else if (button->IsVisible()) {
diff --git a/chrome/browser/views/bookmark_bar_view.h b/chrome/browser/views/bookmark_bar_view.h
index 605322b..ae20fae 100644
--- a/chrome/browser/views/bookmark_bar_view.h
+++ b/chrome/browser/views/bookmark_bar_view.h
@@ -86,7 +86,7 @@ class BookmarkBarView : public ChromeViews::View,
void SetPageNavigator(PageNavigator* navigator);
// View methods:
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
virtual void Layout();
virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
diff --git a/chrome/browser/views/bookmark_bar_view_test.cc b/chrome/browser/views/bookmark_bar_view_test.cc
index 2fc0d30..9d2016a 100644
--- a/chrome/browser/views/bookmark_bar_view_test.cc
+++ b/chrome/browser/views/bookmark_bar_view_test.cc
@@ -97,10 +97,8 @@ class BookmarkBarViewEventTestBase : public ViewEventTestBase {
tmp_parent.AddChildView(bb_view_);
- CSize bb_view_pref;
- bb_view_->GetPreferredSize(&bb_view_pref);
+ bb_view_pref_ = bb_view_->GetPreferredSize();
bb_view_pref_.set_width(1000);
- bb_view_pref_.set_height(bb_view_pref.cy);
ChromeViews::TextButton* button = bb_view_->GetBookmarkButton(4);
while (button->IsVisible()) {
bb_view_pref_.set_width(bb_view_pref_.width() - 25);
diff --git a/chrome/browser/views/bookmark_editor_view.cc b/chrome/browser/views/bookmark_editor_view.cc
index e963b6b..f73b4dd 100644
--- a/chrome/browser/views/bookmark_editor_view.cc
+++ b/chrome/browser/views/bookmark_editor_view.cc
@@ -110,18 +110,16 @@ void BookmarkEditorView::Layout() {
// buttons...
CRect parent_bounds;
GetParent()->GetLocalBounds(&parent_bounds, false);
- CSize prefsize;
- new_group_button_.GetPreferredSize(&prefsize);
- int button_y = parent_bounds.bottom - prefsize.cy - kButtonVEdgeMargin;
- new_group_button_.SetBounds(kPanelHorizMargin, button_y, prefsize.cx,
- prefsize.cy);
+ gfx::Size prefsize = new_group_button_.GetPreferredSize();
+ int button_y = parent_bounds.bottom - prefsize.height() - kButtonVEdgeMargin;
+ new_group_button_.SetBounds(kPanelHorizMargin, button_y, prefsize.width(),
+ prefsize.height());
}
-void BookmarkEditorView::GetPreferredSize(CSize *out) {
- DCHECK(out);
- *out = ChromeViews::Window::GetLocalizedContentsSize(
+gfx::Size BookmarkEditorView::GetPreferredSize() {
+ return gfx::Size(ChromeViews::Window::GetLocalizedContentsSize(
IDS_EDITBOOKMARK_DIALOG_WIDTH_CHARS,
- IDS_EDITBOOKMARK_DIALOG_HEIGHT_LINES).ToSIZE();
+ IDS_EDITBOOKMARK_DIALOG_HEIGHT_LINES));
}
void BookmarkEditorView::DidChangeBounds(const CRect& previous,
diff --git a/chrome/browser/views/bookmark_editor_view.h b/chrome/browser/views/bookmark_editor_view.h
index 1f2f3fe..7c432d2 100644
--- a/chrome/browser/views/bookmark_editor_view.h
+++ b/chrome/browser/views/bookmark_editor_view.h
@@ -71,7 +71,7 @@ class BookmarkEditorView : public ChromeViews::View,
// View methods.
virtual void Layout();
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual void ViewHierarchyChanged(bool is_add, ChromeViews::View* parent,
ChromeViews::View* child);
diff --git a/chrome/browser/views/bug_report_view.cc b/chrome/browser/views/bug_report_view.cc
index 77a0d31..0cdd34f 100644
--- a/chrome/browser/views/bug_report_view.cc
+++ b/chrome/browser/views/bug_report_view.cc
@@ -225,11 +225,10 @@ void BugReportView::SetupControl() {
layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing);
}
-void BugReportView::GetPreferredSize(CSize *out) {
- DCHECK(out);
- *out = ChromeViews::Window::GetLocalizedContentsSize(
+gfx::Size BugReportView::GetPreferredSize() {
+ return gfx::Size(ChromeViews::Window::GetLocalizedContentsSize(
IDS_BUGREPORT_DIALOG_WIDTH_CHARS,
- IDS_BUGREPORT_DIALOG_HEIGHT_LINES).ToSIZE();
+ IDS_BUGREPORT_DIALOG_HEIGHT_LINES));
}
void BugReportView::ItemChanged(ChromeViews::ComboBox* combo_box,
diff --git a/chrome/browser/views/bug_report_view.h b/chrome/browser/views/bug_report_view.h
index 87dd530..7391349 100644
--- a/chrome/browser/views/bug_report_view.h
+++ b/chrome/browser/views/bug_report_view.h
@@ -49,7 +49,7 @@ class BugReportView : public ChromeViews::View,
};
// Overridden from ChromeViews::View:
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
// ChromeViews::TextField::Controller implementation:
virtual void ContentsChanged(ChromeViews::TextField* sender,
diff --git a/chrome/browser/views/clear_browsing_data.cc b/chrome/browser/views/clear_browsing_data.cc
index 328cf6f..0bf697d 100644
--- a/chrome/browser/views/clear_browsing_data.cc
+++ b/chrome/browser/views/clear_browsing_data.cc
@@ -104,101 +104,98 @@ void ClearBrowsingDataView::Init() {
////////////////////////////////////////////////////////////////////////////////
// ClearBrowsingDataView, ChromeViews::View implementation:
-void ClearBrowsingDataView::GetPreferredSize(CSize *out) {
- DCHECK(out);
- *out = ChromeViews::Window::GetLocalizedContentsSize(
+gfx::Size ClearBrowsingDataView::GetPreferredSize() {
+ return gfx::Size(ChromeViews::Window::GetLocalizedContentsSize(
IDS_CLEARDATA_DIALOG_WIDTH_CHARS,
- IDS_CLEARDATA_DIALOG_HEIGHT_LINES).ToSIZE();
+ IDS_CLEARDATA_DIALOG_HEIGHT_LINES));
}
void ClearBrowsingDataView::Layout() {
- CSize panel_size;
- GetPreferredSize(&panel_size);
-
- CSize sz;
+ gfx::Size panel_size = GetPreferredSize();
// Delete All label goes to the top left corner.
- delete_all_label_->GetPreferredSize(&sz);
+ gfx::Size sz = delete_all_label_->GetPreferredSize();
delete_all_label_->SetBounds(kPanelHorizMargin, kPanelVertMargin,
- sz.cx, sz.cy);
+ sz.width(), sz.height());
// Check-boxes go beneath it (with a little indentation).
- del_history_checkbox_->GetPreferredSize(&sz);
+ sz = del_history_checkbox_->GetPreferredSize();
del_history_checkbox_->SetBounds(2 * kPanelHorizMargin,
delete_all_label_->y() +
delete_all_label_->height() +
kRelatedControlVerticalSpacing,
- sz.cx, sz.cy);
+ sz.width(), sz.height());
- del_downloads_checkbox_->GetPreferredSize(&sz);
+ sz = del_downloads_checkbox_->GetPreferredSize();
del_downloads_checkbox_->SetBounds(2 * kPanelHorizMargin,
del_history_checkbox_->y() +
del_history_checkbox_->height() +
kRelatedControlVerticalSpacing,
- sz.cx, sz.cy);
+ sz.width(), sz.height());
- del_cache_checkbox_->GetPreferredSize(&sz);
+ sz = del_cache_checkbox_->GetPreferredSize();
del_cache_checkbox_->SetBounds(2 * kPanelHorizMargin,
del_downloads_checkbox_->y() +
del_downloads_checkbox_->height() +
kRelatedControlVerticalSpacing,
- sz.cx, sz.cy);
+ sz.width(), sz.height());
- del_cookies_checkbox_->GetPreferredSize(&sz);
+ sz = del_cookies_checkbox_->GetPreferredSize();
del_cookies_checkbox_->SetBounds(2 * kPanelHorizMargin,
del_cache_checkbox_->y() +
del_cache_checkbox_->height() +
kRelatedControlVerticalSpacing,
- sz.cx, sz.cy);
+ sz.width(), sz.height());
- del_passwords_checkbox_->GetPreferredSize(&sz);
+ sz = del_passwords_checkbox_->GetPreferredSize();
del_passwords_checkbox_->SetBounds(2 * kPanelHorizMargin,
del_cookies_checkbox_->y() +
del_cookies_checkbox_->height() +
kRelatedControlVerticalSpacing,
- sz.cx, sz.cy);
+ sz.width(), sz.height());
// Time period label is next below the combo boxes.
- time_period_label_->GetPreferredSize(&sz);
+ sz = time_period_label_->GetPreferredSize();
time_period_label_->SetBounds(kPanelHorizMargin,
del_passwords_checkbox_->y() +
del_passwords_checkbox_->height() +
kRelatedControlVerticalSpacing +
kExtraMarginForTimePeriodLabel,
- sz.cx, sz.cy);
+ sz.width(), sz.height());
// Time period combo box goes on the right of the label, and we align it
// vertically to the label as well.
- int label_y_size = sz.cy;
- time_period_combobox_->GetPreferredSize(&sz);
+ int label_y_size = sz.height();
+ sz = time_period_combobox_->GetPreferredSize();
time_period_combobox_->SetBounds(time_period_label_->x() +
time_period_label_->width() +
kRelatedControlVerticalSpacing,
time_period_label_->y() -
- ((sz.cy - label_y_size) / 2),
- sz.cx, sz.cy);
+ ((sz.height() - label_y_size) / 2),
+ sz.width(), sz.height());
// Get the y-coordinate of our parent so we can position the throbber and
// status message at the bottom of the panel.
CRect parent_bounds;
GetParent()->GetLocalBounds(&parent_bounds, false);
- throbber_->GetPreferredSize(&sz);
+ sz = throbber_->GetPreferredSize();
int throbber_topleft_x = kPanelHorizMargin;
- int throbber_topleft_y = parent_bounds.bottom - sz.cy -
+ int throbber_topleft_y = parent_bounds.bottom - sz.height() -
kButtonVEdgeMargin - 3;
- throbber_->SetBounds(throbber_topleft_x, throbber_topleft_y, sz.cx, sz.cy);
+ throbber_->SetBounds(throbber_topleft_x, throbber_topleft_y, sz.width(),
+ sz.height());
// The status label should be at the bottom of the screen, to the right of
// the throbber.
- status_label_.GetPreferredSize(&sz);
+ sz = status_label_.GetPreferredSize();
int status_label_x = throbber_->x() + throbber_->width() +
kRelatedControlHorizontalSpacing;
status_label_.SetHorizontalAlignment(ChromeViews::Label::ALIGN_LEFT);
status_label_.SetBounds(status_label_x,
throbber_topleft_y + 1,
- sz.cx,
- sz.cy);
+ sz.width(),
+ sz.height());
}
void ClearBrowsingDataView::ViewHierarchyChanged(bool is_add,
diff --git a/chrome/browser/views/clear_browsing_data.h b/chrome/browser/views/clear_browsing_data.h
index 2b057a5..a1eac38 100644
--- a/chrome/browser/views/clear_browsing_data.h
+++ b/chrome/browser/views/clear_browsing_data.h
@@ -43,7 +43,7 @@ class ClearBrowsingDataView : public ChromeViews::View,
void Init();
// Overridden from ChromeViews::View:
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
virtual void Layout();
void ViewHierarchyChanged(bool is_add,
ChromeViews::View* parent,
diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc
index 34ce0d0..4666e1f 100644
--- a/chrome/browser/views/constrained_window_impl.cc
+++ b/chrome/browser/views/constrained_window_impl.cc
@@ -217,7 +217,7 @@ class ConstrainedWindowNonClientView
// Overridden from ChromeViews::View:
virtual void Paint(ChromeCanvas* canvas);
virtual void Layout();
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child);
// Overridden from ChromeViews::BaseButton::ButtonListener:
@@ -425,12 +425,8 @@ int ConstrainedWindowNonClientView::CalculateTitlebarHeight() const {
int ConstrainedWindowNonClientView::CalculateNonClientHeight(
bool with_url_field) const {
int r = CalculateTitlebarHeight();
-
- if (with_url_field) {
- CSize s;
- location_bar_->GetPreferredSize(&s);
- r += s.cy;
- }
+ if (with_url_field)
+ r += location_bar_->GetPreferredSize().height();
return r;
}
@@ -572,15 +568,15 @@ void ConstrainedWindowNonClientView::Layout() {
}
int location_bar_height = 0;
- CSize ps;
+ gfx::Size ps;
if (should_display_url_field) {
- location_bar_->GetPreferredSize(&ps);
- location_bar_height = ps.cy;
+ ps = location_bar_->GetPreferredSize();
+ location_bar_height = ps.height();
}
- close_button_->GetPreferredSize(&ps);
- close_button_->SetBounds(width() - ps.cx - kWindowControlsRightOffset,
- kWindowControlsTopOffset, ps.cx, ps.cy);
+ ps = close_button_->GetPreferredSize();
+ close_button_->SetBounds(width() - ps.width() - kWindowControlsRightOffset,
+ kWindowControlsTopOffset, ps.width(), ps.height());
int titlebar_height = CalculateTitlebarHeight();
if (window_delegate_) {
@@ -620,12 +616,12 @@ void ConstrainedWindowNonClientView::Layout() {
container_->client_view()->SetBounds(client_bounds_.ToRECT());
}
-void ConstrainedWindowNonClientView::GetPreferredSize(CSize* out) {
- DCHECK(out);
- container_->client_view()->GetPreferredSize(out);
- out->cx += 2 * kWindowHorizontalBorderSize;
- out->cy += CalculateNonClientHeight(ShouldDisplayURLField()) +
- kWindowVerticalBorderSize;
+gfx::Size ConstrainedWindowNonClientView::GetPreferredSize() {
+ gfx::Size prefsize = container_->client_view()->GetPreferredSize();
+ prefsize.Enlarge(2 * kWindowHorizontalBorderSize,
+ CalculateNonClientHeight(ShouldDisplayURLField()) +
+ kWindowVerticalBorderSize);
+ return prefsize;
}
void ConstrainedWindowNonClientView::ViewHierarchyChanged(bool is_add,
diff --git a/chrome/browser/views/delay_view.cc b/chrome/browser/views/delay_view.cc
index cdd5a9c..76c8322 100644
--- a/chrome/browser/views/delay_view.cc
+++ b/chrome/browser/views/delay_view.cc
@@ -54,36 +54,38 @@ void DelayView::Layout() {
GetParent()->GetSize(&available);
if (cancel_button_) {
- CSize button_size;
- cancel_button_->GetPreferredSize(&button_size);
- cancel_button_->SetBounds(available.cx - kWindowMargin - button_size.cx,
- available.cy - kWindowMargin - button_size.cy,
- button_size.cx, button_size.cy);
+ gfx::Size button_size = cancel_button_->GetPreferredSize();
+ cancel_button_->SetBounds(available.cx - kWindowMargin -
+ button_size.width(),
+ available.cy - kWindowMargin -
+ button_size.height(),
+ button_size.width(), button_size.height());
}
DCHECK(label_);
- CSize label_size;
- label_->GetPreferredSize(&label_size);
+ gfx::Size label_size = label_->GetPreferredSize();
DCHECK(throbber_);
- CSize throbber_size;
- throbber_->GetPreferredSize(&throbber_size);
+ gfx::Size throbber_size = throbber_->GetPreferredSize();
- CRect main_rect(0, 0,
- throbber_size.cx + kThrobberLabelSpace + label_size.cx,
- std::max(throbber_size.cy, label_size.cy));
+ gfx::Rect main_rect(0, 0,
+ throbber_size.width() + kThrobberLabelSpace +
+ label_size.width(),
+ std::max(throbber_size.height(), label_size.height()));
- main_rect.MoveToXY((available.cx / 2) - (main_rect.Width() / 2),
- (available.cy / 2) - (main_rect.Height() / 2));
+ main_rect.set_x((available.cx / 2) - (main_rect.width() / 2));
+ main_rect.set_y((available.cy / 2) - (main_rect.height() / 2));
- label_->SetBounds(main_rect.left + throbber_size.cx + kThrobberLabelSpace,
- main_rect.top + main_rect.Height() / 2 - label_size.cy / 2,
- label_size.cx,
- label_size.cy);
+ label_->SetBounds(main_rect.x() + throbber_size.width() +
+ kThrobberLabelSpace,
+ main_rect.y() + main_rect.height() / 2 -
+ label_size.height() / 2,
+ label_size.width(),
+ label_size.height());
throbber_->SetBounds(
- main_rect.left,
- main_rect.top + main_rect.Height() / 2 - throbber_size.cy / 2,
- throbber_size.cx,
- throbber_size.cy);
+ main_rect.x(),
+ main_rect.y() + main_rect.height() / 2 - throbber_size.height() / 2,
+ throbber_size.width(),
+ throbber_size.height());
}
diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc
index 256b727..1738463 100644
--- a/chrome/browser/views/download_item_view.cc
+++ b/chrome/browser/views/download_item_view.cc
@@ -73,8 +73,7 @@ DownloadItemView::DownloadItemView(DownloadItem* download,
save_button_(NULL),
discard_button_(NULL),
dangerous_download_label_(NULL),
- dangerous_download_label_sized_(false),
- cached_button_size_(0, 0) {
+ dangerous_download_label_sized_(false) {
// TODO(idana) Bug# 1163334
//
// We currently do not mirror each download item on the download shelf (even
@@ -178,9 +177,8 @@ DownloadItemView::DownloadItemView(DownloadItem* download,
else
box_y_ = kVerticalPadding;
- CSize size;
- GetPreferredSize(&size);
- drop_down_x_ = size.cx - normal_drop_down_image_set_.top->width();
+ gfx::Size size = GetPreferredSize();
+ drop_down_x_ = size.width() - normal_drop_down_image_set_.top->width();
body_hover_animation_.reset(new SlideAnimation(this));
drop_hover_animation_.reset(new SlideAnimation(this));
@@ -303,13 +301,13 @@ void DownloadItemView::Layout() {
dangerous_download_label_->SetBounds(x, y,
dangerous_download_label_->width(),
dangerous_download_label_->height());
- CSize button_size;
- GetButtonSize(&button_size);
+ gfx::Size button_size = GetButtonSize();
x += dangerous_download_label_->width() + kLabelPadding;
- y = (height() - button_size.cy) / 2;
- save_button_->SetBounds(x, y, button_size.cx, button_size.cy);
- x += button_size.cx + kButtonPadding;
- discard_button_->SetBounds(x, y, button_size.cx, button_size.cy);
+ y = (height() - button_size.height()) / 2;
+ save_button_->SetBounds(x, y, button_size.width(), button_size.height());
+ x += button_size.width() + kButtonPadding;
+ discard_button_->SetBounds(x, y, button_size.width(),
+ button_size.height());
}
}
@@ -550,20 +548,20 @@ void DownloadItemView::ClearDangerousMode() {
parent_->SchedulePaint();
}
-void DownloadItemView::GetPreferredSize(CSize* out) {
+gfx::Size DownloadItemView::GetPreferredSize() {
int width, height;
if (IsDangerousMode()) {
width = kLeftPadding + dangerous_mode_body_image_set_.top_left->width();
width += warning_icon_->width() + kLabelPadding;
width += dangerous_download_label_->width() + kLabelPadding;
- CSize button_size;
- GetButtonSize(&button_size);
- width += button_size.cx * 2 + kButtonPadding;
+ gfx::Size button_size = GetButtonSize();
+ width += button_size.width() * 2 + kButtonPadding;
width += dangerous_mode_body_image_set_.top_right->width();
height = std::max<int>(2 * kVerticalPadding + 2 * font_.height() +
kVerticalTextPadding,
2 * kVerticalPadding + warning_icon_->height());
- height = std::max<int>(height, 2 * kVerticalPadding + button_size.cy);
+ height = std::max<int>(height,
+ 2 * kVerticalPadding + button_size.height());
} else {
width = kLeftPadding + normal_body_image_set_.top_left->width();
width += download_util::kSmallProgressIconSize;
@@ -574,8 +572,7 @@ void DownloadItemView::GetPreferredSize(CSize* out) {
kVerticalTextPadding,
download_util::kSmallProgressIconSize);
}
- out->cx = width;
- out->cy = height;
+ return gfx::Size(width, height);
}
void DownloadItemView::OnMouseExited(const ChromeViews::MouseEvent& event) {
@@ -728,27 +725,27 @@ void DownloadItemView::LoadIcon() {
NewCallback(this, &DownloadItemView::OnExtractIconComplete));
}
-void DownloadItemView::GetButtonSize(CSize* size) {
+gfx::Size DownloadItemView::GetButtonSize() {
DCHECK(save_button_ && discard_button_);
+ gfx::Size size;
+
// We cache the size when successfully retrieved, not for performance reasons
// but because if this DownloadItemView is being animated while the tab is
// not showing, the native buttons are not parented and their preferred size
// is 0, messing-up the layout.
- if (cached_button_size_.cx != 0) {
- *size = cached_button_size_;
- }
+ if (cached_button_size_.width() != 0)
+ size = cached_button_size_;
- CSize tmp_size;
- save_button_->GetMinimumSize(size);
- discard_button_->GetMinimumSize(&tmp_size);
+ size = save_button_->GetMinimumSize();
+ gfx::Size discard_size = discard_button_->GetMinimumSize();
- size->cx = std::max(size->cx, tmp_size.cx);
- size->cy = std::max(size->cy, tmp_size.cy);
+ size.SetSize(std::max(size.width(), discard_size.width()),
+ std::max(size.height(), discard_size.height()));
- if (size->cx != 0) {
- cached_button_size_.cx = size->cx;
- cached_button_size_.cy = size->cy;
- }
+ if (size.width() != 0)
+ cached_button_size_ = size;
+
+ return size;
}
// This method computes the miminum width of the label for diplaying its text
@@ -766,22 +763,22 @@ void DownloadItemView::SizeLabelToMinWidth() {
// current width.
dangerous_download_label_->SetBounds(0, 0, 1000, 1000);
- CSize size(0, 0);
+ gfx::Size size;
int min_width = -1;
int sp_index = text.find(L" ");
while (sp_index != std::wstring::npos) {
text.replace(sp_index, 1, L"\n");
dangerous_download_label_->SetText(text);
- dangerous_download_label_->GetPreferredSize(&size);
+ size = dangerous_download_label_->GetPreferredSize();
if (min_width == -1)
- min_width = size.cx;
+ min_width = size.width();
- // If thw width is growing again, it means we passed the optimal width spot.
- if (size.cx > min_width)
+ // If the width is growing again, it means we passed the optimal width spot.
+ if (size.width() > min_width)
break;
else
- min_width = size.cx;
+ min_width = size.width();
// Restore the string.
text.replace(sp_index, 1, L" ");
@@ -791,8 +788,8 @@ void DownloadItemView::SizeLabelToMinWidth() {
// If we have a line with no space, we won't cut it.
if (min_width == -1)
- dangerous_download_label_->GetPreferredSize(&size);
+ size = dangerous_download_label_->GetPreferredSize();
- dangerous_download_label_->SetBounds(0, 0, size.cx, size.cy);
+ dangerous_download_label_->SetBounds(gfx::Point(), size);
dangerous_download_label_sized_ = true;
} \ No newline at end of file
diff --git a/chrome/browser/views/download_item_view.h b/chrome/browser/views/download_item_view.h
index c29a154..e67697e 100644
--- a/chrome/browser/views/download_item_view.h
+++ b/chrome/browser/views/download_item_view.h
@@ -62,7 +62,7 @@ class DownloadItemView : public ChromeViews::NativeButton::Listener,
// View overrides
virtual void Layout();
virtual void Paint(ChromeCanvas* canvas);
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
virtual void OnMouseExited(const ChromeViews::MouseEvent& event);
virtual void OnMouseMoved(const ChromeViews::MouseEvent& event);
virtual bool OnMousePressed(const ChromeViews::MouseEvent& event);
@@ -139,7 +139,7 @@ class DownloadItemView : public ChromeViews::NativeButton::Listener,
// Sets |size| with the size of the Save and Discard buttons (they have the
// same size).
- void GetButtonSize(CSize* size);
+ gfx::Size GetButtonSize();
// Sizes the dangerous download label to a minimum width available using 2
// lines. The size is computed only the first time this method is invoked
@@ -228,7 +228,7 @@ class DownloadItemView : public ChromeViews::NativeButton::Listener,
bool dangerous_download_label_sized_;
// The size of the buttons. Cached so animation works when hidden.
- CSize cached_button_size_;
+ gfx::Size cached_button_size_;
DISALLOW_EVIL_CONSTRUCTORS(DownloadItemView);
};
diff --git a/chrome/browser/views/download_shelf_view.cc b/chrome/browser/views/download_shelf_view.cc
index 4ab60d1..a966dcc 100644
--- a/chrome/browser/views/download_shelf_view.cc
+++ b/chrome/browser/views/download_shelf_view.cc
@@ -60,13 +60,13 @@ static const int kShelfAnimationDurationMs = 120;
namespace {
-// Sets size->cx to view's preferred width + size->cx.
-// Sets size->cy to the max of the view's preferred height and size->cy;
-void AdjustSize(ChromeViews::View* view, CSize* size) {
- CSize view_preferred;
- view->GetPreferredSize(&view_preferred);
- size->cx += view_preferred.cx;
- size->cy = std::max(view_preferred.cy, size->cy);
+// Sets size->width() to view's preferred width + size->width().s
+// Sets size->height() to the max of the view's preferred height and
+// size->height();
+void AdjustSize(ChromeViews::View* view, gfx::Size* size) {
+ gfx::Size view_preferred = view->GetPreferredSize();
+ size->Enlarge(view_preferred.width(), 0);
+ size->set_height(std::max(view_preferred.height(), size->height()));
}
int CenterPosition(int size, int target_size) {
@@ -159,21 +159,22 @@ void DownloadShelfView::PaintBorder(ChromeCanvas* canvas) {
canvas->FillRectInt(kBorderColor, 0, 0, width(), 1);
}
-void DownloadShelfView::GetPreferredSize(CSize *out) {
- out->cx = kRightPadding + kLeftPadding + kCloseAndLinkPadding;
- out->cy = 0;
- AdjustSize(close_button_, out);
- AdjustSize(show_all_view_, out);
+gfx::Size DownloadShelfView::GetPreferredSize() {
+ gfx::Size prefsize(kRightPadding + kLeftPadding + kCloseAndLinkPadding, 0);
+ AdjustSize(close_button_, &prefsize);
+ AdjustSize(show_all_view_, &prefsize);
// Add one download view to the preferred size.
if (download_views_.size() > 0) {
- AdjustSize(*download_views_.begin(), out);
- out->cx += kDownloadPadding;
+ AdjustSize(*download_views_.begin(), &prefsize);
+ prefsize.Enlarge(kDownloadPadding, 0);
}
- out->cy += kTopBottomPadding + kTopBottomPadding;
+ prefsize.Enlarge(0, kTopBottomPadding + kTopBottomPadding);
if (shelf_animation_->IsAnimating()) {
- out->cy = static_cast<int>(static_cast<double>(out->cy) *
- shelf_animation_->GetCurrentValue());
+ prefsize.set_height(static_cast<int>(
+ static_cast<double>(prefsize.height()) *
+ shelf_animation_->GetCurrentValue()));
}
+ return prefsize;
}
void DownloadShelfView::DidChangeBounds(const CRect& previous,
@@ -203,43 +204,40 @@ void DownloadShelfView::AnimationEnded(const Animation *animation) {
}
void DownloadShelfView::Layout() {
- CSize image_size;
- arrow_image_->GetPreferredSize(&image_size);
- CSize close_button_size;
- close_button_->GetPreferredSize(&close_button_size);
- CSize show_all_size;
- show_all_view_->GetPreferredSize(&show_all_size);
+ gfx::Size image_size = arrow_image_->GetPreferredSize();
+ gfx::Size close_button_size = close_button_->GetPreferredSize();
+ gfx::Size show_all_size = show_all_view_->GetPreferredSize();
int max_download_x =
- std::max<int>(0, width() - kRightPadding - close_button_size.cx -
- kCloseAndLinkPadding - show_all_size.cx -
- image_size.cx - kDownloadPadding);
+ std::max<int>(0, width() - kRightPadding - close_button_size.width() -
+ kCloseAndLinkPadding - show_all_size.width() -
+ image_size.width() - kDownloadPadding);
int next_x = max_download_x + kDownloadPadding;
// Align vertically with show_all_view_.
- arrow_image_->SetBounds(next_x, CenterPosition(show_all_size.cy, height()),
- image_size.cx, image_size.cy);
- next_x += image_size.cx + kDownloadsTitlePadding;
+ arrow_image_->SetBounds(next_x,
+ CenterPosition(show_all_size.height(), height()),
+ image_size.width(), image_size.height());
+ next_x += image_size.width() + kDownloadsTitlePadding;
show_all_view_->SetBounds(next_x,
- CenterPosition(show_all_size.cy, height()),
- show_all_size.cx,
- show_all_size.cy);
- next_x += show_all_size.cx + kCloseAndLinkPadding;
+ CenterPosition(show_all_size.height(), height()),
+ show_all_size.width(),
+ show_all_size.height());
+ next_x += show_all_size.width() + kCloseAndLinkPadding;
close_button_->SetBounds(next_x,
- CenterPosition(close_button_size.cy, height()),
- close_button_size.cx,
- close_button_size.cy);
+ CenterPosition(close_button_size.height(), height()),
+ close_button_size.width(),
+ close_button_size.height());
next_x = kLeftPadding;
std::vector<View*>::reverse_iterator ri;
for (ri = download_views_.rbegin(); ri != download_views_.rend(); ++ri) {
- CSize view_size;
- (*ri)->GetPreferredSize(&view_size);
+ gfx::Size view_size = (*ri)->GetPreferredSize();
int x = next_x;
// Figure out width of item.
- int item_width = view_size.cx;
+ int item_width = view_size.width();
if (new_item_animation_->IsAnimating() && ri == download_views_.rbegin()) {
- item_width = static_cast<int>(static_cast<double>(view_size.cx) *
+ item_width = static_cast<int>(static_cast<double>(view_size.width()) *
new_item_animation_->GetCurrentValue());
}
@@ -248,8 +246,8 @@ void DownloadShelfView::Layout() {
// Make sure our item can be contained within the shelf.
if (next_x < max_download_x) {
(*ri)->SetVisible(true);
- (*ri)->SetBounds(x, CenterPosition(view_size.cy, height()), item_width,
- view_size.cy);
+ (*ri)->SetBounds(x, CenterPosition(view_size.height(), height()),
+ item_width, view_size.height());
} else {
(*ri)->SetVisible(false);
}
diff --git a/chrome/browser/views/download_shelf_view.h b/chrome/browser/views/download_shelf_view.h
index e99a388..0ac607d 100644
--- a/chrome/browser/views/download_shelf_view.h
+++ b/chrome/browser/views/download_shelf_view.h
@@ -36,7 +36,7 @@ class DownloadShelfView : public ChromeViews::View,
// A new download has started, so add it to our shelf.
void AddDownload(DownloadItem* download);
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
virtual void Layout();
diff --git a/chrome/browser/views/download_started_animation.cc b/chrome/browser/views/download_started_animation.cc
index d038372..f95b13c 100644
--- a/chrome/browser/views/download_started_animation.cc
+++ b/chrome/browser/views/download_started_animation.cc
@@ -63,12 +63,13 @@ void DownloadStartedAnimation::Reposition() {
// Align the image with the bottom left of the web contents (so that it
// points to the newly created download).
- CSize size;
- GetPreferredSize(&size);
- popup_->MoveWindow(tab_contents_bounds_.x(),
- static_cast<int>(tab_contents_bounds_.bottom() - size.cy -
- size.cy * (1 - GetCurrentValue())),
- size.cx, size.cy);
+ gfx::Size size = GetPreferredSize();
+ popup_->MoveWindow(
+ tab_contents_bounds_.x(),
+ static_cast<int>(tab_contents_bounds_.bottom() -
+ size.height() - size.height() * (1 - GetCurrentValue())),
+ size.width(),
+ size.height());
}
void DownloadStartedAnimation::Close() {
diff --git a/chrome/browser/views/download_tab_view.cc b/chrome/browser/views/download_tab_view.cc
index e4edec9..1deaf60 100644
--- a/chrome/browser/views/download_tab_view.cc
+++ b/chrome/browser/views/download_tab_view.cc
@@ -194,22 +194,19 @@ void DownloadItemTabView::SetModel(DownloadItem* model,
parent_->LookupIcon(model_);
}
-void DownloadItemTabView::GetPreferredSize(CSize* out) {
- CSize pause_size;
- pause_->GetPreferredSize(&pause_size);
- CSize cancel_size;
- cancel_->GetPreferredSize(&cancel_size);
- CSize show_size;
- show_->GetPreferredSize(&show_size);
-
- out->cx = download_util::kBigProgressIconSize +
- 2 * kSpacer +
- kHorizontalLinkPadding +
- kFilenameSize +
- std::max(pause_size.cx + cancel_size.cx + kHorizontalLinkPadding,
- show_size.cx);
-
- out->cy = download_util::kBigProgressIconSize;
+gfx::Size DownloadItemTabView::GetPreferredSize() {
+ gfx::Size pause_size = pause_->GetPreferredSize();
+ gfx::Size cancel_size = cancel_->GetPreferredSize();
+ gfx::Size show_size = show_->GetPreferredSize();
+ return gfx::Size(
+ download_util::kBigProgressIconSize +
+ 2 * kSpacer +
+ kHorizontalLinkPadding +
+ kFilenameSize +
+ std::max(pause_size.width() + cancel_size.width() +
+ kHorizontalLinkPadding,
+ show_size.width()),
+ download_util::kBigProgressIconSize);
}
// Each DownloadItemTabView has reasonably complex layout requirements
@@ -250,20 +247,17 @@ void DownloadItemTabView::LayoutDate() {
return;
}
- CSize since_size;
-
since_->SetText(TimeFormat::RelativeDate(model_->start_time(), NULL));
- since_->GetPreferredSize(&since_size);
+ gfx::Size since_size = since_->GetPreferredSize();
since_->SetBounds(kLeftMargin, download_util::kBigProgressIconOffset,
- kDateSize, since_size.cy);
+ kDateSize, since_size.height());
since_->SetVisible(true);
- CSize date_size;
date_->SetText(base::TimeFormatShortDate(model_->start_time()));
- date_->GetPreferredSize(&date_size);
- date_->SetBounds(kLeftMargin, since_size.cy + kVerticalPadding +
- download_util::kBigProgressIconOffset,
- kDateSize, date_size.cy);
+ gfx::Size date_size = date_->GetPreferredSize();
+ date_->SetBounds(kLeftMargin, since_size.height() + kVerticalPadding +
+ download_util::kBigProgressIconOffset,
+ kDateSize, date_size.height());
date_->SetVisible(true);
}
@@ -287,35 +281,32 @@ void DownloadItemTabView::LayoutComplete() {
download_util::kBigProgressIconSize + kInfoPadding;
// File name and URL
- CSize file_name_size;
file_name_->SetText(model_->file_name());
- file_name_->GetPreferredSize(&file_name_size);
+ gfx::Size file_name_size = file_name_->GetPreferredSize();
file_name_->SetBounds(dx, download_util::kBigProgressIconOffset,
std::min(kFilenameSize,
- static_cast<int>(file_name_size.cx)),
- file_name_size.cy);
+ static_cast<int>(file_name_size.width())),
+ file_name_size.height());
file_name_->SetVisible(true);
file_name_->SetEnabled(true);
GURL url(model_->url());
download_url_->SetURL(url);
- CSize url_size;
- download_url_->GetPreferredSize(&url_size);
+ gfx::Size url_size = download_url_->GetPreferredSize();
download_url_->SetBounds(dx,
- file_name_size.cy + kVerticalPadding +
- download_util::kBigProgressIconOffset,
+ file_name_size.height() + kVerticalPadding +
+ download_util::kBigProgressIconOffset,
std::min(kFilenameSize,
static_cast<int>(width() - dx)),
- url_size.cy);
+ url_size.height());
download_url_->SetVisible(true);
dx += kFilenameSize + kSpacer;
// Action button (text is constant and set in constructor)
- CSize show_size;
- show_->GetPreferredSize(&show_size);
- show_->SetBounds(dx, ((file_name_size.cy + url_size.cy) / 2) +
+ gfx::Size show_size = show_->GetPreferredSize();
+ show_->SetBounds(dx, ((file_name_size.height() + url_size.height()) / 2) +
download_util::kBigProgressIconOffset,
- show_size.cx, show_size.cy);
+ show_size.width(), show_size.height());
show_->SetVisible(true);
show_->SetEnabled(true);
}
@@ -340,36 +331,33 @@ void DownloadItemTabView::LayoutCancelled() {
download_util::kBigProgressIconSize + kInfoPadding;
// File name and URL, truncated to show cancelled status
- CSize file_name_size;
file_name_->SetText(model_->file_name());
- file_name_->GetPreferredSize(&file_name_size);
+ gfx::Size file_name_size = file_name_->GetPreferredSize();
file_name_->SetBounds(dx, download_util::kBigProgressIconOffset,
kFilenameSize - kProgressSize - kSpacer,
- file_name_size.cy);
+ file_name_size.height());
file_name_->SetVisible(true);
file_name_->SetEnabled(false);
GURL url(model_->url());
download_url_->SetURL(url);
- CSize url_size;
- download_url_->GetPreferredSize(&url_size);
+ gfx::Size url_size = download_url_->GetPreferredSize();
download_url_->SetBounds(dx,
- file_name_size.cy + kVerticalPadding +
+ file_name_size.height() + kVerticalPadding +
download_util::kBigProgressIconOffset,
std::min(kFilenameSize - kProgressSize - kSpacer,
static_cast<int>(width() - dx)),
- url_size.cy);
+ url_size.height());
download_url_->SetVisible(true);
dx += kFilenameSize - kProgressSize;
// Display cancelled status
- CSize cancel_size;
time_remaining_->SetColor(kStatusColor);
time_remaining_->SetText(l10n_util::GetString(IDS_DOWNLOAD_TAB_CANCELLED));
- time_remaining_->GetPreferredSize(&cancel_size);
+ gfx::Size cancel_size = time_remaining_->GetPreferredSize();
time_remaining_->SetBounds(dx, download_util::kBigProgressIconOffset,
- kProgressSize, cancel_size.cy);
+ kProgressSize, cancel_size.height());
time_remaining_->SetVisible(true);
// Display received size, we may not know the total size if the server didn't
@@ -404,14 +392,13 @@ void DownloadItemTabView::LayoutCancelled() {
total_text);
}
- CSize byte_size;
download_progress_->SetText(amount);
- download_progress_->GetPreferredSize(&byte_size);
+ gfx::Size byte_size = download_progress_->GetPreferredSize();
download_progress_->SetBounds(dx,
- file_name_size.cy + kVerticalPadding +
+ file_name_size.height() + kVerticalPadding +
download_util::kBigProgressIconOffset,
kProgressSize,
- byte_size.cy);
+ byte_size.height());
download_progress_->SetVisible(true);
}
@@ -432,24 +419,22 @@ void DownloadItemTabView::LayoutInProgress() {
kInfoPadding;
// File name and URL, truncated to show progress status
- CSize file_name_size;
file_name_->SetText(model_->GetFileName());
- file_name_->GetPreferredSize(&file_name_size);
+ gfx::Size file_name_size = file_name_->GetPreferredSize();
file_name_->SetBounds(dx, download_util::kBigProgressIconOffset,
kFilenameSize - kProgressSize - kSpacer,
- file_name_size.cy);
+ file_name_size.height());
file_name_->SetVisible(true);
file_name_->SetEnabled(false);
GURL url(model_->url());
download_url_->SetURL(url);
- CSize url_size;
- download_url_->GetPreferredSize(&url_size);
- download_url_->SetBounds(dx, file_name_size.cy + kVerticalPadding +
+ gfx::Size url_size = download_url_->GetPreferredSize();
+ download_url_->SetBounds(dx, file_name_size.height() + kVerticalPadding +
download_util::kBigProgressIconOffset,
std::min(kFilenameSize - kProgressSize - kSpacer,
static_cast<int>(width() - dx)),
- url_size.cy);
+ url_size.height());
download_url_->SetVisible(true);
dx += kFilenameSize - kProgressSize;
@@ -518,41 +503,40 @@ void DownloadItemTabView::LayoutInProgress() {
}
// Time remaining
- int y_pos = file_name_size.cy + kVerticalPadding +
+ int y_pos = file_name_size.height() + kVerticalPadding +
download_util::kBigProgressIconOffset;
- CSize time_size;
+ gfx::Size time_size;
time_remaining_->SetColor(kStatusColor);
if (model_->is_paused()) {
time_remaining_->SetColor(kPauseColor);
time_remaining_->SetText(
l10n_util::GetString(IDS_DOWNLOAD_PROGRESS_PAUSED));
- time_remaining_->GetPreferredSize(&time_size);
+ time_size = time_remaining_->GetPreferredSize();
time_remaining_->SetBounds(dx, download_util::kBigProgressIconOffset,
- kProgressSize, time_size.cy);
+ kProgressSize, time_size.height());
time_remaining_->SetVisible(true);
} else if (total > 0) {
TimeDelta remaining;
if (model_->TimeRemaining(&remaining))
time_remaining_->SetText(TimeFormat::TimeRemaining(remaining));
- time_remaining_->GetPreferredSize(&time_size);
+ time_size = time_remaining_->GetPreferredSize();
time_remaining_->SetBounds(dx, download_util::kBigProgressIconOffset,
- kProgressSize, time_size.cy);
+ kProgressSize, time_size.height());
time_remaining_->SetVisible(true);
} else {
time_remaining_->SetText(L"");
- y_pos = ((file_name_size.cy + url_size.cy) / 2) +
+ y_pos = ((file_name_size.height() + url_size.height()) / 2) +
download_util::kBigProgressIconOffset;
}
- CSize byte_size;
download_progress_->SetText(progress);
- download_progress_->GetPreferredSize(&byte_size);
+ gfx::Size byte_size = download_progress_->GetPreferredSize();
download_progress_->SetBounds(dx, y_pos,
- kProgressSize, byte_size.cy);
+ kProgressSize, byte_size.height());
download_progress_->SetVisible(true);
dx += kProgressSize + kSpacer;
- y_pos = ((file_name_size.cy + url_size.cy) / 2) +
+ y_pos = ((file_name_size.height() + url_size.height()) / 2) +
download_util::kBigProgressIconOffset;
// Pause (or Resume) / Cancel buttons.
@@ -561,17 +545,15 @@ void DownloadItemTabView::LayoutInProgress() {
else
pause_->SetText(l10n_util::GetString(IDS_DOWNLOAD_LINK_PAUSE));
- CSize pause_size;
pause_->SetVisible(true);
pause_->SetEnabled(true);
- pause_->GetPreferredSize(&pause_size);
- pause_->SetBounds(dx, y_pos, pause_size.cx, pause_size.cy);
+ gfx::Size pause_size = pause_->GetPreferredSize();
+ pause_->SetBounds(dx, y_pos, pause_size.width(), pause_size.height());
- dx += pause_size.cx + kHorizontalLinkPadding;
+ dx += pause_size.width() + kHorizontalLinkPadding;
- CSize cancel_size;
- cancel_->GetPreferredSize(&cancel_size);
- cancel_->SetBounds(dx, y_pos, cancel_size.cx, cancel_size.cy);
+ gfx::Size cancel_size = cancel_->GetPreferredSize();
+ cancel_->SetBounds(dx, y_pos, cancel_size.width(), cancel_size.height());
cancel_->SetVisible(true);
cancel_->SetEnabled(true);
}
@@ -595,41 +577,38 @@ void DownloadItemTabView::LayoutPromptDangerousDownload() {
kInfoPadding;
// Warning message and URL.
- CSize warning_size;
std::wstring file_name;
ElideString(model_->original_name(), kFileNameMaxLength, &file_name);
dangerous_download_warning_->SetText(
l10n_util::GetStringF(IDS_PROMPT_DANGEROUS_DOWNLOAD, file_name));
- dangerous_download_warning_->GetPreferredSize(&warning_size);
+ gfx::Size warning_size = dangerous_download_warning_->GetPreferredSize();
dangerous_download_warning_->SetBounds(dx, 0,
- kFilenameSize, warning_size.cy);
+ kFilenameSize, warning_size.height());
dangerous_download_warning_->SetVisible(true);
GURL url(model_->url());
download_url_->SetURL(url);
- CSize url_size;
- download_url_->GetPreferredSize(&url_size);
- download_url_->SetBounds(dx, height() - url_size.cy,
+ gfx::Size url_size = download_url_->GetPreferredSize();
+ download_url_->SetBounds(dx, height() - url_size.height(),
std::min(kFilenameSize - kSpacer,
static_cast<int>(width() - dx)),
- url_size.cy);
+ url_size.height());
download_url_->SetVisible(true);
dx += kFilenameSize + kSpacer;
// Save/Discard buttons.
- CSize button_size;
- save_button_->GetPreferredSize(&button_size);
- save_button_->SetBounds(dx, (height() - button_size.cy) / 2,
- button_size.cx, button_size.cy);
+ gfx::Size button_size = save_button_->GetPreferredSize();
+ save_button_->SetBounds(dx, (height() - button_size.height()) / 2,
+ button_size.width(), button_size.height());
save_button_->SetVisible(true);
save_button_->SetEnabled(true);
- dx += button_size.cx + kHorizontalButtonPadding;
+ dx += button_size.width() + kHorizontalButtonPadding;
- discard_button_->GetPreferredSize(&button_size);
- discard_button_->SetBounds(dx, (height() - button_size.cy) / 2,
- button_size.cx, button_size.cy);
+ button_size = discard_button_->GetPreferredSize();
+ discard_button_->SetBounds(dx, (height() - button_size.height()) / 2,
+ button_size.width(), button_size.height());
discard_button_->SetVisible(true);
discard_button_->SetEnabled(true);
}
diff --git a/chrome/browser/views/download_tab_view.h b/chrome/browser/views/download_tab_view.h
index f78ee4a..8c59089 100644
--- a/chrome/browser/views/download_tab_view.h
+++ b/chrome/browser/views/download_tab_view.h
@@ -35,7 +35,7 @@ class DownloadItemTabView : public ChromeViews::View,
virtual void Layout();
virtual void Paint(ChromeCanvas* canvas);
void PaintBackground(ChromeCanvas* canvas);
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual bool OnMousePressed(const ChromeViews::MouseEvent& event);
virtual bool OnMouseDragged(const ChromeViews::MouseEvent& event);
diff --git a/chrome/browser/views/first_run_bubble.cc b/chrome/browser/views/first_run_bubble.cc
index 5b6fac0..4dc3812b 100644
--- a/chrome/browser/views/first_run_bubble.cc
+++ b/chrome/browser/views/first_run_bubble.cc
@@ -63,15 +63,14 @@ class FirstRunBubbleView : public ChromeViews::View,
label1_->SetHorizontalAlignment(ChromeViews::Label::ALIGN_LEFT);
AddChildView(label1_);
- CSize ps;
- GetPreferredSize(&ps);
+ gfx::Size ps = GetPreferredSize();
label2_ =
new ChromeViews::Label(l10n_util::GetString(IDS_FR_BUBBLE_SUBTEXT));
label2_->SetMultiLine(true);
label2_->SetFont(font);
label2_->SetHorizontalAlignment(ChromeViews::Label::ALIGN_LEFT);
- label2_->SizeToFit(ps.cx - kBubblePadding * 2);
+ label2_->SizeToFit(ps.width() - kBubblePadding * 2);
AddChildView(label2_);
std::wstring question_str
@@ -81,7 +80,7 @@ class FirstRunBubbleView : public ChromeViews::View,
label3_->SetMultiLine(true);
label3_->SetFont(font);
label3_->SetHorizontalAlignment(ChromeViews::Label::ALIGN_LEFT);
- label3_->SizeToFit(ps.cx - kBubblePadding * 2);
+ label3_->SizeToFit(ps.width() - kBubblePadding * 2);
AddChildView(label3_);
std::wstring keep_str = l10n_util::GetStringF(IDS_FR_BUBBLE_OK,
@@ -115,45 +114,44 @@ class FirstRunBubbleView : public ChromeViews::View,
// Overridden from ChromeViews::View.
virtual void Layout() {
- CSize canvas;
- GetPreferredSize(&canvas);
+ gfx::Size canvas = GetPreferredSize();
- CSize pref_size;
// The multiline business that follows is dirty hacks to get around
// bug 1325257.
label1_->SetMultiLine(false);
- label1_->GetPreferredSize(&pref_size);
+ gfx::Size pref_size = label1_->GetPreferredSize();
label1_->SetMultiLine(true);
- label1_->SizeToFit(canvas.cx - kBubblePadding * 2);
+ label1_->SizeToFit(canvas.width() - kBubblePadding * 2);
label1_->SetBounds(kBubblePadding, kBubblePadding,
- canvas.cx - kBubblePadding * 2,
- pref_size.cy);
+ canvas.width() - kBubblePadding * 2,
+ pref_size.height());
- int next_v_space = label1_->y() + pref_size.cy +
+ int next_v_space = label1_->y() + pref_size.height() +
kRelatedControlSmallVerticalSpacing;
- label2_->GetPreferredSize(&pref_size);
+ pref_size = label2_->GetPreferredSize();
label2_->SetBounds(kBubblePadding, next_v_space,
- canvas.cx - kBubblePadding * 2,
- pref_size.cy);
+ canvas.width() - kBubblePadding * 2,
+ pref_size.height());
next_v_space = label2_->y() + label2_->height() +
kPanelSubVerticalSpacing;
- label3_->GetPreferredSize(&pref_size);
+ pref_size = label3_->GetPreferredSize();
label3_->SetBounds(kBubblePadding, next_v_space,
- canvas.cx - kBubblePadding * 2,
- pref_size.cy);
+ canvas.width() - kBubblePadding * 2,
+ pref_size.height());
- change_button_->GetPreferredSize(&pref_size);
- change_button_->SetBounds(canvas.cx - pref_size.cx - kBubblePadding,
- canvas.cy - pref_size.cy - kButtonVEdgeMargin,
- pref_size.cx, pref_size.cy);
+ pref_size = change_button_->GetPreferredSize();
+ change_button_->SetBounds(
+ canvas.width() - pref_size.width() - kBubblePadding,
+ canvas.height() - pref_size.height() - kButtonVEdgeMargin,
+ pref_size.width(), pref_size.height());
- keep_button_->GetPreferredSize(&pref_size);
- keep_button_->SetBounds(change_button_->x() - pref_size.cx -
+ pref_size = keep_button_->GetPreferredSize();
+ keep_button_->SetBounds(change_button_->x() - pref_size.width() -
kRelatedButtonHSpacing, change_button_->y(),
- pref_size.cx, pref_size.cy);
+ pref_size.width(), pref_size.height());
}
virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child) {
@@ -162,11 +160,10 @@ class FirstRunBubbleView : public ChromeViews::View,
}
// Overridden from ChromeViews::View.
- virtual void GetPreferredSize(CSize *out) {
- DCHECK(out);
- *out = ChromeViews::Window::GetLocalizedContentsSize(
+ virtual gfx::Size GetPreferredSize() {
+ return gfx::Size(ChromeViews::Window::GetLocalizedContentsSize(
IDS_FIRSTRUNBUBBLE_DIALOG_WIDTH_CHARS,
- IDS_FIRSTRUNBUBBLE_DIALOG_HEIGHT_LINES).ToSIZE();
+ IDS_FIRSTRUNBUBBLE_DIALOG_HEIGHT_LINES));
}
private:
diff --git a/chrome/browser/views/first_run_customize_view.cc b/chrome/browser/views/first_run_customize_view.cc
index 9c0b0ab..4a89b5b 100644
--- a/chrome/browser/views/first_run_customize_view.cc
+++ b/chrome/browser/views/first_run_customize_view.cc
@@ -83,11 +83,10 @@ void FirstRunCustomizeView::SetupControls() {
quick_shortcut_cbox_->SetIsSelected(true);
}
-void FirstRunCustomizeView::GetPreferredSize(CSize *out) {
- DCHECK(out);
- *out = ChromeViews::Window::GetLocalizedContentsSize(
+gfx::Size FirstRunCustomizeView::GetPreferredSize() {
+ return gfx::Size(ChromeViews::Window::GetLocalizedContentsSize(
IDS_FIRSTRUNCUSTOMIZE_DIALOG_WIDTH_CHARS,
- IDS_FIRSTRUNCUSTOMIZE_DIALOG_HEIGHT_LINES).ToSIZE();
+ IDS_FIRSTRUNCUSTOMIZE_DIALOG_HEIGHT_LINES));
}
void FirstRunCustomizeView::Layout() {
@@ -96,63 +95,62 @@ void FirstRunCustomizeView::Layout() {
const int kVertSpacing = 8;
const int kComboExtraPad = 8;
- CSize canvas;
- GetPreferredSize(&canvas);
+ gfx::Size canvas = GetPreferredSize();
// Welcome label goes in to to the left. It does not go across the
// entire window because the background gets busy on the right.
- CSize pref_size;
- main_label_->GetPreferredSize(&pref_size);
+ gfx::Size pref_size = main_label_->GetPreferredSize();
main_label_->SetBounds(kPanelHorizMargin, kPanelVertMargin,
- canvas.cx - pref_size.cx, pref_size.cy);
+ canvas.width() - pref_size.width(),
+ pref_size.height());
AdjustDialogWidth(main_label_);
int next_v_space = background_image()->y() +
background_image()->height() + kPanelVertMargin;
- import_cbox_->GetPreferredSize(&pref_size);
+ pref_size = import_cbox_->GetPreferredSize();
import_cbox_->SetBounds(kPanelHorizMargin, next_v_space,
- pref_size.cx, pref_size.cy);
+ pref_size.width(), pref_size.height());
import_cbox_->SetIsSelected(true);
int x_offset = import_cbox_->x() +
import_cbox_->width();
- import_from_combo_->GetPreferredSize(&pref_size);
+ pref_size = import_from_combo_->GetPreferredSize();
import_from_combo_->SetBounds(x_offset,
next_v_space +
(import_cbox_->height() -
- pref_size.cy) / 2,
- pref_size.cx + kComboExtraPad,
- pref_size.cy);
+ pref_size.height()) / 2,
+ pref_size.width() + kComboExtraPad,
+ pref_size.height());
AdjustDialogWidth(import_from_combo_);
next_v_space = import_cbox_->y() + import_cbox_->height() +
kUnrelatedControlVerticalSpacing;
- shortcuts_label_->GetPreferredSize(&pref_size);
+ pref_size = shortcuts_label_->GetPreferredSize();
shortcuts_label_->SetBounds(kPanelHorizMargin, next_v_space,
- pref_size.cx, pref_size.cy);
+ pref_size.width(), pref_size.height());
AdjustDialogWidth(shortcuts_label_);
next_v_space += shortcuts_label_->height() +
kRelatedControlVerticalSpacing;
- desktop_shortcut_cbox_->GetPreferredSize(&pref_size);
+ pref_size = desktop_shortcut_cbox_->GetPreferredSize();
desktop_shortcut_cbox_->SetBounds(kPanelHorizMargin, next_v_space,
- pref_size.cx, pref_size.cy);
+ pref_size.width(), pref_size.height());
AdjustDialogWidth(desktop_shortcut_cbox_);
next_v_space += desktop_shortcut_cbox_->height() +
kRelatedControlVerticalSpacing;
- quick_shortcut_cbox_->GetPreferredSize(&pref_size);
+ pref_size = quick_shortcut_cbox_->GetPreferredSize();
quick_shortcut_cbox_->SetBounds(kPanelHorizMargin, next_v_space,
- pref_size.cx, pref_size.cy);
+ pref_size.width(), pref_size.height());
AdjustDialogWidth(quick_shortcut_cbox_);
}
diff --git a/chrome/browser/views/first_run_customize_view.h b/chrome/browser/views/first_run_customize_view.h
index 2edcc42..8d17187 100644
--- a/chrome/browser/views/first_run_customize_view.h
+++ b/chrome/browser/views/first_run_customize_view.h
@@ -42,7 +42,7 @@ class FirstRunCustomizeView : public FirstRunViewBase,
virtual ~FirstRunCustomizeView();
// Overridden from ChromeViews::View.
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
virtual void Layout();
// Overridden from ChromeViews::DialogDelegate.
diff --git a/chrome/browser/views/first_run_view.cc b/chrome/browser/views/first_run_view.cc
index e310e0a..72ed29a 100644
--- a/chrome/browser/views/first_run_view.cc
+++ b/chrome/browser/views/first_run_view.cc
@@ -94,11 +94,10 @@ void FirstRunView::SetupControls() {
AddChildView(customize_link_);
}
-void FirstRunView::GetPreferredSize(CSize *out) {
- DCHECK(out);
- *out = ChromeViews::Window::GetLocalizedContentsSize(
+gfx::Size FirstRunView::GetPreferredSize() {
+ return gfx::Size(ChromeViews::Window::GetLocalizedContentsSize(
IDS_FIRSTRUN_DIALOG_WIDTH_CHARS,
- IDS_FIRSTRUN_DIALOG_HEIGHT_LINES).ToSIZE();
+ IDS_FIRSTRUN_DIALOG_HEIGHT_LINES));
}
void FirstRunView::Layout() {
@@ -107,21 +106,20 @@ void FirstRunView::Layout() {
const int kVertSpacing = 8;
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- CSize pref_size;
- welcome_label_->GetPreferredSize(&pref_size);
+ gfx::Size pref_size = welcome_label_->GetPreferredSize();
// Wrap the label text before we overlap the product icon.
int label_width = background_image()->width() -
rb.GetBitmapNamed(IDR_WIZARD_ICON)->width() - kPanelHorizMargin;
welcome_label_->SetBounds(kPanelHorizMargin, kPanelVertMargin,
- label_width, pref_size.cy);
+ label_width, pref_size.height());
AdjustDialogWidth(welcome_label_);
int next_v_space = background_image()->y() +
background_image()->height() + kPanelVertMargin;
- actions_label_->GetPreferredSize(&pref_size);
+ pref_size = actions_label_->GetPreferredSize();
actions_label_->SetBounds(kPanelHorizMargin, next_v_space,
- pref_size.cx, pref_size.cy);
+ pref_size.width(), pref_size.height());
AdjustDialogWidth(actions_label_);
next_v_space = actions_label_->y() +
@@ -145,9 +143,9 @@ void FirstRunView::Layout() {
actions_shorcuts_->height() +
kUnrelatedControlVerticalSpacing;
- customize_link_->GetPreferredSize(&pref_size);
+ pref_size = customize_link_->GetPreferredSize();
customize_link_->SetBounds(kPanelHorizMargin, next_v_space,
- pref_size.cx, pref_size.cy);
+ pref_size.width(), pref_size.height());
}
void FirstRunView::OpenCustomizeDialog() {
diff --git a/chrome/browser/views/first_run_view.h b/chrome/browser/views/first_run_view.h
index 87b0152..45e576a 100644
--- a/chrome/browser/views/first_run_view.h
+++ b/chrome/browser/views/first_run_view.h
@@ -29,7 +29,7 @@ class FirstRunView : public FirstRunViewBase,
virtual ~FirstRunView();
// Overridden from ChromeViews::View:
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
virtual void Layout();
// Overridden from ChromeViews::DialogDelegate:
diff --git a/chrome/browser/views/first_run_view_base.cc b/chrome/browser/views/first_run_view_base.cc
index 51feba4..3f5e869 100644
--- a/chrome/browser/views/first_run_view_base.cc
+++ b/chrome/browser/views/first_run_view_base.cc
@@ -121,27 +121,27 @@ void FirstRunViewBase::SetMinimumDialogWidth(int width) {
void FirstRunViewBase::Layout() {
const int kVertSpacing = 8;
- CSize canvas;
- GetPreferredSize(&canvas);
+ gfx::Size canvas = GetPreferredSize();
- CSize pref_size;
- background_image_->GetPreferredSize(&pref_size);
- background_image_->SetBounds(0, 0, canvas.cx, pref_size.cy);
+ gfx::Size pref_size = background_image_->GetPreferredSize();
+ background_image_->SetBounds(0, 0, canvas.width(), pref_size.height());
int next_v_space = background_image_->y() +
background_image_->height() - 2;
- separator_1_->GetPreferredSize(&pref_size);
- separator_1_->SetBounds(0 , next_v_space, canvas.cx + 1, pref_size.cy);
+ pref_size = separator_1_->GetPreferredSize();
+ separator_1_->SetBounds(0, next_v_space, canvas.width() + 1,
+ pref_size.height());
- next_v_space = canvas.cy - kPanelSubVerticalSpacing - 2 * kVertSpacing;
- separator_2_->GetPreferredSize(&pref_size);
+ next_v_space = canvas.height() - kPanelSubVerticalSpacing - 2 * kVertSpacing;
+ pref_size = separator_2_->GetPreferredSize();
separator_2_->SetBounds(kPanelHorizMargin , next_v_space,
- canvas.cx - 2 * kPanelHorizMargin, pref_size.cy);
+ canvas.width() - 2 * kPanelHorizMargin,
+ pref_size.height());
next_v_space = separator_2_->y() + separator_2_->height() + kVertSpacing;
- int width = canvas.cx - 2 * kPanelHorizMargin;
+ int width = canvas.width() - 2 * kPanelHorizMargin;
int height = default_browser_->GetHeightForWidth(width);
default_browser_->SetBounds(kPanelHorizMargin, next_v_space, width, height);
AdjustDialogWidth(default_browser_);
diff --git a/chrome/browser/views/frame/aero_glass_non_client_view.cc b/chrome/browser/views/frame/aero_glass_non_client_view.cc
index 09d8703..74de8bb 100644
--- a/chrome/browser/views/frame/aero_glass_non_client_view.cc
+++ b/chrome/browser/views/frame/aero_glass_non_client_view.cc
@@ -242,11 +242,12 @@ void AeroGlassNonClientView::Layout() {
LayoutClientView();
}
-void AeroGlassNonClientView::GetPreferredSize(CSize* out) {
- DCHECK(out);
- frame_->client_view()->GetPreferredSize(out);
- out->cx += 2 * kWindowHorizontalClientEdgeWidth;
- out->cy += CalculateNonClientTopHeight() + kWindowBottomClientEdgeHeight;
+gfx::Size AeroGlassNonClientView::GetPreferredSize() {
+ gfx::Size prefsize = frame_->client_view()->GetPreferredSize();
+ prefsize.Enlarge(2 * kWindowHorizontalClientEdgeWidth,
+ CalculateNonClientTopHeight() +
+ kWindowBottomClientEdgeHeight);
+ return prefsize;
}
void AeroGlassNonClientView::DidChangeBounds(const CRect& previous,
diff --git a/chrome/browser/views/frame/aero_glass_non_client_view.h b/chrome/browser/views/frame/aero_glass_non_client_view.h
index 530b3c1..2412a63 100644
--- a/chrome/browser/views/frame/aero_glass_non_client_view.h
+++ b/chrome/browser/views/frame/aero_glass_non_client_view.h
@@ -33,7 +33,7 @@ class AeroGlassNonClientView : public ChromeViews::NonClientView {
// Overridden from ChromeViews::View:
virtual void Paint(ChromeCanvas* canvas);
virtual void Layout();
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual void ViewHierarchyChanged(bool is_add,
ChromeViews::View* parent,
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 5bff85a..71b82c4 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -196,10 +196,8 @@ bool BrowserView::IsBookmarkBarVisible() const {
if (bookmark_bar_view->IsNewTabPage() || bookmark_bar_view->IsAnimating())
return true;
- CSize sz;
- bookmark_bar_view->GetPreferredSize(&sz);
// 1 is the minimum in GetPreferredSize for the bookmark bar.
- return sz.cy > 1;
+ return bookmark_bar_view->GetPreferredSize().height() > 1;
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/views/frame/opaque_non_client_view.cc b/chrome/browser/views/frame/opaque_non_client_view.cc
index 789da0f..1bbbbfd 100644
--- a/chrome/browser/views/frame/opaque_non_client_view.cc
+++ b/chrome/browser/views/frame/opaque_non_client_view.cc
@@ -626,11 +626,12 @@ void OpaqueNonClientView::Layout() {
LayoutClientView();
}
-void OpaqueNonClientView::GetPreferredSize(CSize* out) {
- DCHECK(out);
- frame_->client_view()->GetPreferredSize(out);
- out->cx += 2 * kWindowHorizontalBorderSize;
- out->cy += CalculateNonClientTopHeight() + kWindowVerticalBorderBottomSize;
+gfx::Size OpaqueNonClientView::GetPreferredSize() {
+ gfx::Size prefsize = frame_->client_view()->GetPreferredSize();
+ prefsize.Enlarge(2 * kWindowHorizontalBorderSize,
+ CalculateNonClientTopHeight() +
+ kWindowVerticalBorderBottomSize);
+ return prefsize;
}
ChromeViews::View* OpaqueNonClientView::GetViewForPoint(
@@ -875,73 +876,78 @@ void OpaqueNonClientView::PaintClientEdge(ChromeCanvas* canvas) {
}
void OpaqueNonClientView::LayoutWindowControls() {
- CSize ps;
+ gfx::Size ps;
if (frame_->IsMaximized() || frame_->IsMinimized()) {
maximize_button_->SetVisible(false);
restore_button_->SetVisible(true);
}
if (frame_->IsMaximized()) {
- close_button_->GetPreferredSize(&ps);
+ ps = close_button_->GetPreferredSize();
close_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
ChromeViews::Button::ALIGN_TOP);
close_button_->SetBounds(
- width() - ps.cx - kWindowControlsRightZoomedOffset,
- 0, ps.cx + kWindowControlsRightZoomedOffset,
- ps.cy + kWindowControlsTopZoomedOffset);
+ width() - ps.width() - kWindowControlsRightZoomedOffset,
+ 0, ps.width() + kWindowControlsRightZoomedOffset,
+ ps.height() + kWindowControlsTopZoomedOffset);
- restore_button_->GetPreferredSize(&ps);
+ ps = restore_button_->GetPreferredSize();
restore_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
ChromeViews::Button::ALIGN_TOP);
- restore_button_->SetBounds(close_button_->x() - ps.cx, 0, ps.cx,
- ps.cy + kWindowControlsTopZoomedOffset);
+ restore_button_->SetBounds(close_button_->x() - ps.width(), 0, ps.width(),
+ ps.height() + kWindowControlsTopZoomedOffset);
- minimize_button_->GetPreferredSize(&ps);
+ ps = minimize_button_->GetPreferredSize();
minimize_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
ChromeViews::Button::ALIGN_TOP);
- minimize_button_->SetBounds(restore_button_->x() - ps.cx, 0, ps.cx,
- ps.cy + kWindowControlsTopZoomedOffset);
+ minimize_button_->SetBounds(restore_button_->x() - ps.width(), 0,
+ ps.width(),
+ ps.height() + kWindowControlsTopZoomedOffset);
} else if (frame_->IsMinimized()) {
- close_button_->GetPreferredSize(&ps);
+ ps = close_button_->GetPreferredSize();
close_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
ChromeViews::Button::ALIGN_BOTTOM);
close_button_->SetBounds(
- width() - ps.cx - kWindowControlsRightZoomedOffset,
- 0, ps.cx + kWindowControlsRightZoomedOffset,
- ps.cy + kWindowControlsTopZoomedOffset);
+ width() - ps.width() - kWindowControlsRightZoomedOffset,
+ 0, ps.width() + kWindowControlsRightZoomedOffset,
+ ps.height() + kWindowControlsTopZoomedOffset);
- restore_button_->GetPreferredSize(&ps);
+ ps = restore_button_->GetPreferredSize();
restore_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
ChromeViews::Button::ALIGN_BOTTOM);
- restore_button_->SetBounds(close_button_->x() - ps.cx, 0, ps.cx,
- ps.cy + kWindowControlsTopZoomedOffset);
+ restore_button_->SetBounds(close_button_->x() - ps.width(), 0, ps.width(),
+ ps.height() + kWindowControlsTopZoomedOffset);
- minimize_button_->GetPreferredSize(&ps);
+ ps = minimize_button_->GetPreferredSize();
minimize_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
ChromeViews::Button::ALIGN_BOTTOM);
- minimize_button_->SetBounds(restore_button_->x() - ps.cx, 0, ps.cx,
- ps.cy + kWindowControlsTopZoomedOffset);
+ minimize_button_->SetBounds(restore_button_->x() - ps.width(), 0,
+ ps.width(),
+ ps.height() + kWindowControlsTopZoomedOffset);
} else {
- close_button_->GetPreferredSize(&ps);
+ ps = close_button_->GetPreferredSize();
close_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
ChromeViews::Button::ALIGN_TOP);
- close_button_->SetBounds(width() - kWindowControlsRightOffset - ps.cx,
- kWindowControlsTopOffset, ps.cx, ps.cy);
+ close_button_->SetBounds(width() - kWindowControlsRightOffset - ps.width(),
+ kWindowControlsTopOffset, ps.width(),
+ ps.height());
restore_button_->SetVisible(false);
maximize_button_->SetVisible(true);
- maximize_button_->GetPreferredSize(&ps);
+ ps = maximize_button_->GetPreferredSize();
maximize_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
ChromeViews::Button::ALIGN_TOP);
- maximize_button_->SetBounds(close_button_->x() - ps.cx,
- kWindowControlsTopOffset, ps.cx, ps.cy);
+ maximize_button_->SetBounds(close_button_->x() - ps.width(),
+ kWindowControlsTopOffset, ps.width(),
+ ps.height());
- minimize_button_->GetPreferredSize(&ps);
+ ps = minimize_button_->GetPreferredSize();
minimize_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
ChromeViews::Button::ALIGN_TOP);
- minimize_button_->SetBounds(maximize_button_->x() - ps.cx,
- kWindowControlsTopOffset, ps.cx, ps.cy);
+ minimize_button_->SetBounds(maximize_button_->x() - ps.width(),
+ kWindowControlsTopOffset, ps.width(),
+ ps.height());
}
}
diff --git a/chrome/browser/views/frame/opaque_non_client_view.h b/chrome/browser/views/frame/opaque_non_client_view.h
index 7766ce7..5b9bc54 100644
--- a/chrome/browser/views/frame/opaque_non_client_view.h
+++ b/chrome/browser/views/frame/opaque_non_client_view.h
@@ -56,7 +56,7 @@ class OpaqueNonClientView : public ChromeViews::NonClientView,
// Overridden from ChromeViews::View:
virtual void Paint(ChromeCanvas* canvas);
virtual void Layout();
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
virtual ChromeViews::View* GetViewForPoint(const gfx::Point& point,
bool can_create_floating);
virtual void DidChangeBounds(const CRect& previous, const CRect& current);
diff --git a/chrome/browser/views/html_dialog_view.cc b/chrome/browser/views/html_dialog_view.cc
index 1d985d2..ac2380f 100644
--- a/chrome/browser/views/html_dialog_view.cc
+++ b/chrome/browser/views/html_dialog_view.cc
@@ -28,8 +28,10 @@ HtmlDialogView::~HtmlDialogView() {
////////////////////////////////////////////////////////////////////////////////
// HtmlDialogView, ChromeViews::View implementation:
-void HtmlDialogView::GetPreferredSize(CSize *out) {
- delegate_->GetDialogSize(out);
+gfx::Size HtmlDialogView::GetPreferredSize() {
+ CSize out;
+ delegate_->GetDialogSize(&out);
+ return gfx::Size(out.cx, out.cy);
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/views/html_dialog_view.h b/chrome/browser/views/html_dialog_view.h
index 82a42f6..b9dd1d1 100644
--- a/chrome/browser/views/html_dialog_view.h
+++ b/chrome/browser/views/html_dialog_view.h
@@ -38,7 +38,7 @@ class HtmlDialogView
void InitDialog();
// Overridden from ChromeViews::View:
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
// Overridden from ChromeViews::WindowDelegate:
virtual bool CanResize() const;
diff --git a/chrome/browser/views/hung_renderer_view.cc b/chrome/browser/views/hung_renderer_view.cc
index 8138cc6..edba957 100644
--- a/chrome/browser/views/hung_renderer_view.cc
+++ b/chrome/browser/views/hung_renderer_view.cc
@@ -343,8 +343,8 @@ void HungRendererWarningView::Init() {
hung_pages_table_ = new ChromeViews::GroupTableView(
hung_pages_table_model_.get(), columns, ChromeViews::ICON_AND_TEXT, true,
false, true);
- hung_pages_table_->SetPreferredSize(
- CSize(kTableViewWidth, kTableViewHeight));
+ hung_pages_table_->set_preferred_size(
+ gfx::Size(kTableViewWidth, kTableViewHeight));
CreateKillButtonView();
diff --git a/chrome/browser/views/importer_lock_view.cc b/chrome/browser/views/importer_lock_view.cc
index e3aec26..edb7e6e 100644
--- a/chrome/browser/views/importer_lock_view.cc
+++ b/chrome/browser/views/importer_lock_view.cc
@@ -34,11 +34,10 @@ ImporterLockView::ImporterLockView(ImporterHost* host)
ImporterLockView::~ImporterLockView() {
}
-void ImporterLockView::GetPreferredSize(CSize *out) {
- DCHECK(out);
- *out = ChromeViews::Window::GetLocalizedContentsSize(
+gfx::Size ImporterLockView::GetPreferredSize() {
+ return gfx::Size(ChromeViews::Window::GetLocalizedContentsSize(
IDS_IMPORTLOCK_DIALOG_WIDTH_CHARS,
- IDS_IMPORTLOCK_DIALOG_HEIGHT_LINES).ToSIZE();
+ IDS_IMPORTLOCK_DIALOG_HEIGHT_LINES));
}
void ImporterLockView::Layout() {
diff --git a/chrome/browser/views/importer_lock_view.h b/chrome/browser/views/importer_lock_view.h
index 4613ef5..9070184 100644
--- a/chrome/browser/views/importer_lock_view.h
+++ b/chrome/browser/views/importer_lock_view.h
@@ -26,7 +26,7 @@ class ImporterLockView : public ChromeViews::View,
virtual ~ImporterLockView();
// Overridden from ChromeViews::View.
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
virtual void Layout();
// Overridden from ChromeViews::DialogDelegate:
diff --git a/chrome/browser/views/importer_view.cc b/chrome/browser/views/importer_view.cc
index b8ee784..5349b90 100644
--- a/chrome/browser/views/importer_view.cc
+++ b/chrome/browser/views/importer_view.cc
@@ -88,11 +88,10 @@ void ImporterView::SetupControl() {
layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
}
-void ImporterView::GetPreferredSize(CSize *out) {
- DCHECK(out);
- *out = ChromeViews::Window::GetLocalizedContentsSize(
+gfx::Size ImporterView::GetPreferredSize() {
+ return gfx::Size(ChromeViews::Window::GetLocalizedContentsSize(
IDS_IMPORT_DIALOG_WIDTH_CHARS,
- IDS_IMPORT_DIALOG_HEIGHT_LINES).ToSIZE();
+ IDS_IMPORT_DIALOG_HEIGHT_LINES));
}
void ImporterView::Layout() {
diff --git a/chrome/browser/views/importer_view.h b/chrome/browser/views/importer_view.h
index 18219f9..6906fee 100644
--- a/chrome/browser/views/importer_view.h
+++ b/chrome/browser/views/importer_view.h
@@ -34,7 +34,7 @@ class ImporterView : public ChromeViews::View,
virtual ~ImporterView();
// Overridden from ChromeViews::View.
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
virtual void Layout();
// Overridden from ChromeViews::DialogDelegate:
diff --git a/chrome/browser/views/importing_progress_view.cc b/chrome/browser/views/importing_progress_view.cc
index 77f842f..d580cfa 100644
--- a/chrome/browser/views/importing_progress_view.cc
+++ b/chrome/browser/views/importing_progress_view.cc
@@ -151,11 +151,10 @@ void ImportingProgressView::ImportEnded() {
////////////////////////////////////////////////////////////////////////////////
// ImportingProgressView, ChromeViews::View overrides:
-void ImportingProgressView::GetPreferredSize(CSize* out) {
- DCHECK(out);
- *out = ChromeViews::Window::GetLocalizedContentsSize(
+gfx::Size ImportingProgressView::GetPreferredSize() {
+ return gfx::Size(ChromeViews::Window::GetLocalizedContentsSize(
IDS_IMPORTPROGRESS_DIALOG_WIDTH_CHARS,
- IDS_IMPORTPROGRESS_DIALOG_HEIGHT_LINES).ToSIZE();
+ IDS_IMPORTPROGRESS_DIALOG_HEIGHT_LINES));
}
void ImportingProgressView::ViewHierarchyChanged(bool is_add,
@@ -214,8 +213,7 @@ void ImportingProgressView::InitControlLayout() {
GridLayout* layout = CreatePanelGridLayout(this);
SetLayoutManager(layout);
- CSize ps;
- state_history_->GetPreferredSize(&ps);
+ gfx::Size ps = state_history_->GetPreferredSize();
const int single_column_view_set_id = 0;
ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id);
@@ -225,7 +223,7 @@ void ImportingProgressView::InitControlLayout() {
column_set = layout->AddColumnSet(double_column_view_set_id);
column_set->AddPaddingColumn(0, kUnrelatedControlLargeHorizontalSpacing);
column_set->AddColumn(GridLayout::CENTER, GridLayout::CENTER, 0,
- GridLayout::FIXED, ps.cx, 0);
+ GridLayout::FIXED, ps.width(), 0);
column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
GridLayout::USE_PREF, 0, 0);
diff --git a/chrome/browser/views/importing_progress_view.h b/chrome/browser/views/importing_progress_view.h
index a06e9a0..9637c05 100644
--- a/chrome/browser/views/importing_progress_view.h
+++ b/chrome/browser/views/importing_progress_view.h
@@ -42,7 +42,7 @@ class ImportingProgressView : public ChromeViews::View,
virtual ChromeViews::View* GetContentsView();
// Overridden from ChromeViews::View:
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
virtual void ViewHierarchyChanged(bool is_add,
ChromeViews::View* parent,
ChromeViews::View* child);
diff --git a/chrome/browser/views/info_bar_item_view.cc b/chrome/browser/views/info_bar_item_view.cc
index 985b1c6..1f1d2ab 100644
--- a/chrome/browser/views/info_bar_item_view.cc
+++ b/chrome/browser/views/info_bar_item_view.cc
@@ -20,9 +20,8 @@ class HorizontalSpacer : public ChromeViews::View {
public:
explicit HorizontalSpacer(int width) : width_(width) {}
- void GetPreferredSize(CSize* out) {
- out->cx = width_;
- out->cy = 0;
+ gfx::Size GetPreferredSize() {
+ return gfx::Size(width_, 0);
}
private:
@@ -50,9 +49,10 @@ int InfoBarItemView::CenterPosition(int size, int target_size) {
return (target_size - size) / 2;
}
-void InfoBarItemView::GetPreferredSize(CSize* out) {
- out->cx = GetParent()->width();
- out->cy = static_cast<int>(kInfoBarHeight * animation_->GetCurrentValue());
+gfx::Size InfoBarItemView::GetPreferredSize() {
+ return gfx::Size(
+ GetParent()->width(),
+ static_cast<int>(kInfoBarHeight * animation_->GetCurrentValue()));
}
// The following is an overall note on the underlying implementation. You don't
@@ -99,14 +99,13 @@ void InfoBarItemView::Layout() {
for (int i = child_count - 1; i >= insert_index_ ; i--) {
View* v = GetChildViewAt(i);
if (v->IsVisible()) {
- CSize view_size;
- v->GetPreferredSize(&view_size);
- next_x = next_x - view_size.cx;
+ gfx::Size view_size = v->GetPreferredSize();
+ next_x = next_x - view_size.width();
v->SetBounds(next_x,
- CenterPosition(view_size.cy,
+ CenterPosition(view_size.height(),
static_cast<int>(kInfoBarHeight)) - height_diff,
- view_size.cx,
- view_size.cy);
+ view_size.width(),
+ view_size.height());
}
}
int left_most_x = next_x;
@@ -118,18 +117,17 @@ void InfoBarItemView::Layout() {
for (int i = 0; i < insert_index_ ; i++) {
View* v = GetChildViewAt(i);
if (v->IsVisible()) {
- CSize view_size;
- v->GetPreferredSize(&view_size);
+ gfx::Size view_size = v->GetPreferredSize();
int remaining_space = std::max(0, left_most_x - next_x);
- if (view_size.cx > remaining_space) {
- view_size.cx = remaining_space;
+ if (view_size.width() > remaining_space) {
+ view_size.set_width(remaining_space);
}
v->SetBounds(next_x,
- CenterPosition(view_size.cy,
+ CenterPosition(view_size.height(),
static_cast<int>(kInfoBarHeight)) - height_diff,
- view_size.cx,
- view_size.cy);
- next_x = next_x + view_size.cx;
+ view_size.width(),
+ view_size.height());
+ next_x = next_x + view_size.width();
}
}
}
diff --git a/chrome/browser/views/info_bar_item_view.h b/chrome/browser/views/info_bar_item_view.h
index baae48a..c5b99ab 100644
--- a/chrome/browser/views/info_bar_item_view.h
+++ b/chrome/browser/views/info_bar_item_view.h
@@ -43,7 +43,7 @@ class InfoBarItemView : public ChromeViews::View,
// The preferred height is equal to the maximum height of all views
// in the info bar. Preferred width is equal to the parents width.
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
// Lays out all child views of the info bar from trailing to leading.
virtual void Layout();
diff --git a/chrome/browser/views/info_bar_view.cc b/chrome/browser/views/info_bar_view.cc
index 17d4a2a..a5955a2 100644
--- a/chrome/browser/views/info_bar_view.cc
+++ b/chrome/browser/views/info_bar_view.cc
@@ -55,20 +55,19 @@ void InfoBarView::AppendInfoBarItem(ChromeViews::View* view, bool auto_expire) {
// Preferred size is equal to the max of the childrens horizontal sizes
// and the sum of their vertical sizes.
-void InfoBarView::GetPreferredSize(CSize *out) {
- out->cx = 0;
- out->cy = 0;
+gfx::Size InfoBarView::GetPreferredSize() {
+ gfx::Size prefsize;
// We count backwards so the most recently added view is on the top.
for (int i = GetChildViewCount() - 1; i >= 0; i--) {
View* v = GetChildViewAt(i);
if (v->IsVisible()) {
- CSize view_size;
- v->GetPreferredSize(&view_size);
- out->cx = std::max(static_cast<int>(out->cx), v->width());
- out->cy += static_cast<int>(view_size.cy) + kSeparatorHeight;
+ prefsize.set_width(std::max(prefsize.width(), v->width()));
+ prefsize.Enlarge(0, v->GetPreferredSize().height() + kSeparatorHeight);
}
}
+
+ return prefsize;
}
void InfoBarView::Layout() {
@@ -81,14 +80,10 @@ void InfoBarView::Layout() {
if (!v->IsVisible())
continue;
- CSize view_size;
- v->GetPreferredSize(&view_size);
- int view_width = std::max(static_cast<int>(view_size.cx), width());
- y = y - view_size.cy - kSeparatorHeight;
- v->SetBounds(x,
- y,
- view_width,
- view_size.cy);
+ gfx::Size view_size = v->GetPreferredSize();
+ int view_width = std::max(view_size.width(), width());
+ y = y - view_size.height() - kSeparatorHeight;
+ v->SetBounds(x, y, view_width, view_size.height());
}
}
diff --git a/chrome/browser/views/info_bar_view.h b/chrome/browser/views/info_bar_view.h
index 0ff9b94..52a91c5 100644
--- a/chrome/browser/views/info_bar_view.h
+++ b/chrome/browser/views/info_bar_view.h
@@ -30,7 +30,7 @@ class InfoBarView : public ChromeViews::View,
// add an infobar that should not expire.
void AppendInfoBarItem(ChromeViews::View* view, bool auto_expire);
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
virtual void Layout();
diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc
index 0b6f3d6..938ac49 100644
--- a/chrome/browser/views/info_bubble.cc
+++ b/chrome/browser/views/info_bubble.cc
@@ -236,14 +236,15 @@ gfx::Rect InfoBubble::ContentView::CalculateWindowBounds(
return CalculateWindowBounds(position_relative_to);
}
-void InfoBubble::ContentView::GetPreferredSize(CSize* pref) {
+gfx::Size InfoBubble::ContentView::GetPreferredSize() {
DCHECK(GetChildViewCount() == 1);
View* content = GetChildViewAt(0);
- content->GetPreferredSize(pref);
- pref->cx += kBorderSize + kBorderSize + kInfoBubbleViewLeftMargin +
- kInfoBubbleViewRightMargin;
- pref->cy += kBorderSize + kBorderSize + kArrowSize +
- kInfoBubbleViewTopMargin + kInfoBubbleViewBottomMargin;
+ gfx::Size pref = content->GetPreferredSize();
+ pref.Enlarge(kBorderSize + kBorderSize + kInfoBubbleViewLeftMargin +
+ kInfoBubbleViewRightMargin,
+ kBorderSize + kBorderSize + kArrowSize +
+ kInfoBubbleViewTopMargin + kInfoBubbleViewBottomMargin);
+ return pref;
}
void InfoBubble::ContentView::Layout() {
@@ -405,19 +406,18 @@ void InfoBubble::ContentView::Paint(ChromeCanvas* canvas) {
gfx::Rect InfoBubble::ContentView::CalculateWindowBounds(
const gfx::Rect& position_relative_to) {
- CSize pref;
- GetPreferredSize(&pref);
+ gfx::Size pref = GetPreferredSize();
int x = position_relative_to.x() + position_relative_to.width() / 2;
int y;
if (IsLeft())
x -= kArrowXOffset;
else
- x = x + kArrowXOffset - pref.cx;
+ x = x + kArrowXOffset - pref.width();
if (IsTop()) {
y = position_relative_to.bottom() + kArrowToContentPadding;
} else {
- y = position_relative_to.y() - kArrowToContentPadding - pref.cy;
+ y = position_relative_to.y() - kArrowToContentPadding - pref.height();
}
- return gfx::Rect(x, y, pref.cx, pref.cy);
+ return gfx::Rect(x, y, pref.width(), pref.height());
}
diff --git a/chrome/browser/views/info_bubble.h b/chrome/browser/views/info_bubble.h
index 78ebae2..e237660 100644
--- a/chrome/browser/views/info_bubble.h
+++ b/chrome/browser/views/info_bubble.h
@@ -107,7 +107,7 @@ class InfoBubble : public ChromeViews::HWNDViewContainer,
// Returns the preferred size, which is the sum of the preferred size of
// the content and the border/arrow.
- virtual void GetPreferredSize(CSize* pref);
+ virtual gfx::Size GetPreferredSize();
// Positions the content relative to the border.
virtual void Layout();
diff --git a/chrome/browser/views/keyword_editor_view.cc b/chrome/browser/views/keyword_editor_view.cc
index 9ef5527..fb1fd8e 100644
--- a/chrome/browser/views/keyword_editor_view.cc
+++ b/chrome/browser/views/keyword_editor_view.cc
@@ -426,11 +426,10 @@ void KeywordEditorView::DidChangeBounds(const CRect& previous,
Layout();
}
-void KeywordEditorView::GetPreferredSize(CSize* out) {
- DCHECK(out);
- *out = ChromeViews::Window::GetLocalizedContentsSize(
+gfx::Size KeywordEditorView::GetPreferredSize() {
+ return gfx::Size(ChromeViews::Window::GetLocalizedContentsSize(
IDS_SEARCHENGINES_DIALOG_WIDTH_CHARS,
- IDS_SEARCHENGINES_DIALOG_HEIGHT_LINES).ToSIZE();
+ IDS_SEARCHENGINES_DIALOG_HEIGHT_LINES));
}
bool KeywordEditorView::CanResize() const {
diff --git a/chrome/browser/views/keyword_editor_view.h b/chrome/browser/views/keyword_editor_view.h
index aaebd93..41773ad 100644
--- a/chrome/browser/views/keyword_editor_view.h
+++ b/chrome/browser/views/keyword_editor_view.h
@@ -147,7 +147,7 @@ class KeywordEditorView : public ChromeViews::View,
// Overriden to invoke Layout.
virtual void DidChangeBounds(const CRect& previous, const CRect& current);
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
// DialogDelegate methods:
virtual bool CanResize() const;
diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc
index a60494f..8e3a2c5 100644
--- a/chrome/browser/views/location_bar_view.cc
+++ b/chrome/browser/views/location_bar_view.cc
@@ -204,14 +204,13 @@ void LocationBarView::SetProfile(Profile* profile) {
}
}
-void LocationBarView::GetPreferredSize(CSize *out) {
- CSize size;
- security_image_view_.GetPreferredSize(&size);
- out->cx = 0;
-
- out->cy = std::max(
- (popup_window_mode_ ? kPopupBackgroundCenter : kBackground)->height(),
- static_cast<int>(size.cy));
+gfx::Size LocationBarView::GetPreferredSize() {
+ return gfx::Size(
+ 0,
+ std::max(
+ (popup_window_mode_ ? kPopupBackgroundCenter
+ : kBackground)->height(),
+ security_image_view_.GetPreferredSize().width()));
}
void LocationBarView::DidChangeBounds(const CRect& previous,
@@ -375,15 +374,15 @@ void LocationBarView::DoLayout(const bool force_layout) {
location_entry_->GetClientRect(&edit_bounds);
int entry_width = width() - kEntryPadding - kEntryPadding;
- CSize security_image_size;
+ gfx::Size security_image_size;
if (security_image_view_.IsVisible()) {
- security_image_view_.GetPreferredSize(&security_image_size);
- entry_width -= security_image_size.cx;
+ security_image_size = security_image_view_.GetPreferredSize();
+ entry_width -= security_image_size.width();
}
- CSize info_label_size;
+ gfx::Size info_label_size;
if (info_label_.IsVisible()) {
- info_label_.GetPreferredSize(&info_label_size);
- entry_width -= (info_label_size.cx + kInnerPadding);
+ info_label_size = info_label_.GetPreferredSize();
+ entry_width -= (info_label_size.width() + kInnerPadding);
}
const int max_edit_width = entry_width - formatting_rect.left -
@@ -404,18 +403,18 @@ void LocationBarView::DoLayout(const bool force_layout) {
int location_y = ((height() - bh) / 2) + kTextVertMargin;
int location_height = bh - (2 * kTextVertMargin);
if (info_label_.IsVisible()) {
- info_label_.SetBounds(width() - kEntryPadding - info_label_size.cx,
+ info_label_.SetBounds(width() - kEntryPadding - info_label_size.width(),
location_y,
- info_label_size.cx, location_height);
+ info_label_size.width(), location_height);
}
if (security_image_view_.IsVisible()) {
- const int info_label_width = info_label_size.cx ?
- info_label_size.cx + kInnerPadding : 0;
+ const int info_label_width = info_label_size.width() ?
+ info_label_size.width() + kInnerPadding : 0;
security_image_view_.SetBounds(width() - kEntryPadding -
info_label_width -
- security_image_size.cx,
+ security_image_size.width(),
location_y,
- security_image_size.cx, location_height);
+ security_image_size.width(), location_height);
}
gfx::Rect location_bounds(kEntryPadding, location_y, entry_width,
location_height);
@@ -455,11 +454,10 @@ bool LocationBarView::UsePref(int pref_width, int text_width, int max_width) {
}
bool LocationBarView::NeedsResize(View* view, int text_width, int max_width) {
- CSize size;
- view->GetPreferredSize(&size);
- if (!UsePref(size.cx, text_width, max_width))
- view->GetMinimumSize(&size);
- return (view->width() != size.cx);
+ gfx::Size size = view->GetPreferredSize();
+ if (!UsePref(size.width(), text_width, max_width))
+ size = view->GetMinimumSize();
+ return (view->width() != size.width());
}
bool LocationBarView::AdjustHints(int text_width, int max_width) {
@@ -472,9 +470,8 @@ bool LocationBarView::AdjustHints(int text_width, int max_width) {
if (show_search_hint) {
// Only show type to search if all the text fits.
- CSize view_pref;
- type_to_search_view_.GetPreferredSize(&view_pref);
- show_search_hint = UsePref(view_pref.cx, text_width, max_width);
+ gfx::Size view_pref = type_to_search_view_.GetPreferredSize();
+ show_search_hint = UsePref(view_pref.width(), text_width, max_width);
}
// NOTE: This isn't just one big || statement as ToggleVisibility MUST be
@@ -505,20 +502,20 @@ void LocationBarView::LayoutView(bool leading, ChromeViews::View* view,
int text_width, int max_width,
gfx::Rect* bounds) {
DCHECK(view && bounds);
- CSize view_size(0, 0);
- view->GetPreferredSize(&view_size);
- if (!UsePref(view_size.cx, text_width, max_width))
- view->GetMinimumSize(&view_size);
- if (view_size.cx + kInnerPadding < bounds->width()) {
+ gfx::Size view_size = view->GetPreferredSize();
+ if (!UsePref(view_size.width(), text_width, max_width))
+ view_size = view->GetMinimumSize();
+ if (view_size.width() + kInnerPadding < bounds->width()) {
view->SetVisible(true);
if (leading) {
- view->SetBounds(bounds->x(), bounds->y(), view_size.cx, bounds->height());
- bounds->Offset(view_size.cx + kInnerPadding, 0);
+ view->SetBounds(bounds->x(), bounds->y(), view_size.width(),
+ bounds->height());
+ bounds->Offset(view_size.width() + kInnerPadding, 0);
} else {
- view->SetBounds(bounds->right() - view_size.cx, bounds->y(),
- view_size.cx, bounds->height());
+ view->SetBounds(bounds->right() - view_size.width(), bounds->y(),
+ view_size.width(), bounds->height());
}
- bounds->set_width(bounds->width() - view_size.cx - kInnerPadding);
+ bounds->set_width(bounds->width() - view_size.width() - kInnerPadding);
} else {
view->SetVisible(false);
}
@@ -641,12 +638,12 @@ void LocationBarView::SelectedKeywordView::Paint(ChromeCanvas* canvas) {
canvas->TranslateInt(0, -kBackgroundYOffset);
}
-void LocationBarView::SelectedKeywordView::GetPreferredSize(CSize* size) {
- full_label_.GetPreferredSize(size);
+gfx::Size LocationBarView::SelectedKeywordView::GetPreferredSize() {
+ return full_label_.GetPreferredSize();
}
-void LocationBarView::SelectedKeywordView::GetMinimumSize(CSize* size) {
- partial_label_.GetMinimumSize(size);
+gfx::Size LocationBarView::SelectedKeywordView::GetMinimumSize() {
+ return partial_label_.GetMinimumSize();
}
void LocationBarView::SelectedKeywordView::DidChangeBounds(
@@ -656,9 +653,8 @@ void LocationBarView::SelectedKeywordView::DidChangeBounds(
}
void LocationBarView::SelectedKeywordView::Layout() {
- CSize pref;
- GetPreferredSize(&pref);
- bool at_pref = (width() == pref.cx);
+ gfx::Size pref = GetPreferredSize();
+ bool at_pref = (width() == pref.width());
if (at_pref)
full_label_.SetBounds(0, 0, width(), height());
else
@@ -772,21 +768,21 @@ void LocationBarView::KeywordHintView::Paint(ChromeCanvas* canvas) {
tab_button_bounds.y());
}
-void LocationBarView::KeywordHintView::GetPreferredSize(CSize *out) {
+gfx::Size LocationBarView::KeywordHintView::GetPreferredSize() {
// TODO(sky): currently height doesn't matter, once baseline support is
// added this should check baselines.
- leading_label_.GetPreferredSize(out);
- int width = out->cx;
+ gfx::Size prefsize = leading_label_.GetPreferredSize();
+ int width = prefsize.width();
width += kTabButtonBitmap->width();
- trailing_label_.GetPreferredSize(out);
- width += out->cx;
- out->cx = width;
+ prefsize = trailing_label_.GetPreferredSize();
+ width += prefsize.width();
+ return gfx::Size(width, prefsize.height());
}
-void LocationBarView::KeywordHintView::GetMinimumSize(CSize* out) {
+gfx::Size LocationBarView::KeywordHintView::GetMinimumSize() {
// TODO(sky): currently height doesn't matter, once baseline support is
// added this should check baselines.
- out->cx = kTabButtonBitmap->width();
+ return gfx::Size(kTabButtonBitmap->width(), 0);
}
void LocationBarView::KeywordHintView::Layout() {
@@ -796,15 +792,15 @@ void LocationBarView::KeywordHintView::Layout() {
leading_label_.SetVisible(show_labels);
trailing_label_.SetVisible(show_labels);
int x = 0;
- CSize pref;
+ gfx::Size pref;
if (show_labels) {
- leading_label_.GetPreferredSize(&pref);
- leading_label_.SetBounds(x, 0, pref.cx, height());
+ pref = leading_label_.GetPreferredSize();
+ leading_label_.SetBounds(x, 0, pref.width(), height());
- x += pref.cx + kTabButtonBitmap->width();
- trailing_label_.GetPreferredSize(&pref);
- trailing_label_.SetBounds(x, 0, pref.cx, height());
+ x += pref.width() + kTabButtonBitmap->width();
+ pref = trailing_label_.GetPreferredSize();
+ trailing_label_.SetBounds(x, 0, pref.width(), height());
}
}
diff --git a/chrome/browser/views/location_bar_view.h b/chrome/browser/views/location_bar_view.h
index f02c24d..cec73af 100644
--- a/chrome/browser/views/location_bar_view.h
+++ b/chrome/browser/views/location_bar_view.h
@@ -67,7 +67,7 @@ class LocationBarView : public ChromeViews::View,
Profile* profile() { return profile_; }
// Sizing functions
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
// Layout and Painting functions
virtual void DidChangeBounds(const CRect& previous, const CRect& current);
@@ -153,8 +153,8 @@ class LocationBarView : public ChromeViews::View,
virtual void Paint(ChromeCanvas* canvas);
- virtual void GetPreferredSize(CSize* out);
- virtual void GetMinimumSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
+ virtual gfx::Size GetMinimumSize();
virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual void Layout();
@@ -208,9 +208,9 @@ class LocationBarView : public ChromeViews::View,
std::wstring keyword() const { return keyword_; }
virtual void Paint(ChromeCanvas* canvas);
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
// The minimum size is just big enough to show the tab.
- virtual void GetMinimumSize(CSize* out);
+ virtual gfx::Size GetMinimumSize();
virtual void Layout();
void DidChangeBounds(const CRect& previous, const CRect& current);
diff --git a/chrome/browser/views/old_frames/simple_vista_frame.cc b/chrome/browser/views/old_frames/simple_vista_frame.cc
index 884d748..82b246c 100644
--- a/chrome/browser/views/old_frames/simple_vista_frame.cc
+++ b/chrome/browser/views/old_frames/simple_vista_frame.cc
@@ -203,12 +203,11 @@ void SimpleVistaFrame::Layout() {
if (browser_->ShouldDisplayURLField()) {
TabContentsContainerView* container = GetTabContentsContainer();
- CSize s;
- location_bar_->GetPreferredSize(&s);
+ gfx::Size s = location_bar_->GetPreferredSize();
location_bar_->SetBounds(container->x() - kLocationBarOutdent,
container->y() - kLocationBarOutdent,
container->width() + kLocationBarOutdent * 2,
- s.cy);
+ s.height());
container->SetBounds(container->x(),
location_bar_->y() + location_bar_->height() -
kLocationBarSpacing, container->width(),
diff --git a/chrome/browser/views/old_frames/simple_xp_frame.cc b/chrome/browser/views/old_frames/simple_xp_frame.cc
index 79046e6..8436b63 100644
--- a/chrome/browser/views/old_frames/simple_xp_frame.cc
+++ b/chrome/browser/views/old_frames/simple_xp_frame.cc
@@ -79,15 +79,16 @@ void TitleBarMenuButton::SetContents(ChromeViews::View* contents) {
contents_ = contents;
}
-void TitleBarMenuButton::GetPreferredSize(CSize *out) {
+gfx::Size TitleBarMenuButton::GetPreferredSize() {
+ gfx::Size prefsize;
if (contents_)
- contents_->GetPreferredSize(out);
- else
- out->cx = out->cy = 0;
+ prefsize = contents_->GetPreferredSize();
- out->cx += drop_arrow_->width() + kHorizMargin + (2 * kHorizBorderSize);
- out->cy = std::max(drop_arrow_->height(), static_cast<int>(out->cy));
- out->cy += (2 * kVertBorderSize);
+ prefsize.set_height(std::max(drop_arrow_->height(), prefsize.height()));
+ prefsize.Enlarge(
+ drop_arrow_->width() + kHorizMargin + (2 * kHorizBorderSize),
+ 2 * kVertBorderSize);
+ return prefsize;
}
void TitleBarMenuButton::Paint(ChromeCanvas* canvas) {
@@ -97,17 +98,16 @@ void TitleBarMenuButton::Paint(ChromeCanvas* canvas) {
}
if (contents_) {
- CSize s;
- contents_->GetPreferredSize(&s);
+ gfx::Size s = contents_->GetPreferredSize();
// Note: we use a floating view in this case because we never want the
// contents to process any event.
PaintFloatingView(canvas,
contents_,
kVertBorderSize,
- (height() - s.cy) / 2,
+ (height() - s.height()) / 2,
width() - kHorizMargin - drop_arrow_->width() -
(2 * kHorizBorderSize),
- s.cy);
+ s.height());
}
// We can not use the mirroring infrastructure in ChromeViews in order to
@@ -205,10 +205,9 @@ void SimpleXPFrameTitleBar::RunMenu(ChromeViews::View* source,
}
void SimpleXPFrameTitleBar::Layout() {
- CSize s;
- menu_button_->GetPreferredSize(&s);
- menu_button_->SetBounds(kFavIconMargin, (height() - s.cy) / 2,
- s.cx, s.cy);
+ gfx::Size s = menu_button_->GetPreferredSize();
+ menu_button_->SetBounds(kFavIconMargin, (height() - s.height()) / 2,
+ s.width(), s.height());
menu_button_->Layout();
label_->SetBounds(menu_button_->x() + menu_button_->width() +
kFavIconPadding, kLabelVerticalOffset,
@@ -322,12 +321,11 @@ void SimpleXPFrame::Layout() {
if (browser_->ShouldDisplayURLField()) {
TabContentsContainerView* container = GetTabContentsContainer();
- CSize s;
- location_bar_->GetPreferredSize(&s);
+ gfx::Size s = location_bar_->GetPreferredSize();
location_bar_->SetBounds(container->x() - kLocationBarOffset,
container->y(),
container->width() + kLocationBarOffset * 2,
- s.cy);
+ s.height());
container->SetBounds(container->x(),
location_bar_->y() + location_bar_->height() +
kLocationBarSpacing, container->width(),
diff --git a/chrome/browser/views/old_frames/simple_xp_frame.h b/chrome/browser/views/old_frames/simple_xp_frame.h
index 24a8a25..2b5b368 100644
--- a/chrome/browser/views/old_frames/simple_xp_frame.h
+++ b/chrome/browser/views/old_frames/simple_xp_frame.h
@@ -108,7 +108,7 @@ class TitleBarMenuButton : public ChromeViews::MenuButton {
void SetContents(ChromeViews::View* contents);
// overridden from View
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
virtual void Paint(ChromeCanvas* canvas);
virtual bool OnMousePressed(const ChromeViews::MouseEvent& e);
diff --git a/chrome/browser/views/old_frames/vista_frame.cc b/chrome/browser/views/old_frames/vista_frame.cc
index 6b0d081..fb934ad 100644
--- a/chrome/browser/views/old_frames/vista_frame.cc
+++ b/chrome/browser/views/old_frames/vista_frame.cc
@@ -181,24 +181,23 @@ void VistaFrame::Layout() {
int tabstrip_x = g_bitmaps[CT_LEFT_SIDE]->width();
if (is_off_the_record_) {
off_the_record_image_->SetVisible(true);
- CSize otr_image_size;
- off_the_record_image_->GetPreferredSize(&otr_image_size);
- tabstrip_x += otr_image_size.cx + (2 * kOTRImageHorizMargin);
+ gfx::Size otr_image_size = off_the_record_image_->GetPreferredSize();
+ tabstrip_x += otr_image_size.width() + (2 * kOTRImageHorizMargin);
gfx::Rect off_the_record_bounds;
if (IsZoomed()) {
off_the_record_bounds.SetRect(g_bitmaps[CT_LEFT_SIDE]->width(),
kResizeBorder,
- otr_image_size.cx,
+ otr_image_size.width(),
tabstrip_->GetPreferredHeight() -
kToolbarOverlapVertOffset + 1);
} else {
off_the_record_bounds.SetRect(g_bitmaps[CT_LEFT_SIDE]->width(),
kResizeBorder + kTitlebarHeight +
tabstrip_->GetPreferredHeight() -
- otr_image_size.cy -
+ otr_image_size.height() -
kToolbarOverlapVertOffset + 1,
- otr_image_size.cx,
- otr_image_size.cy);
+ otr_image_size.width(),
+ otr_image_size.height());
}
if (frame_view_->UILayoutIsRightToLeft())
@@ -233,22 +232,22 @@ void VistaFrame::Layout() {
// Hide the distributor logo if we're zoomed.
distributor_logo_->SetVisible(false);
} else {
- CSize distributor_logo_size;
- distributor_logo_->GetPreferredSize(&distributor_logo_size);
+ gfx::Size distributor_logo_size =
+ distributor_logo_->GetPreferredSize();
int logo_x;
// Because of Bug 1128173, our Window controls aren't actually flipped
// on Vista, yet all our math and layout presumes that they are.
if (frame_view_->UILayoutIsRightToLeft())
- logo_x = width - distributor_logo_size.cx;
+ logo_x = width - distributor_logo_size.width();
else
- logo_x = width - min_offset - distributor_logo_size.cx;
+ logo_x = width - min_offset - distributor_logo_size.width();
distributor_logo_->SetVisible(true);
distributor_logo_->SetBounds(logo_x,
kDistributorLogoVerticalOffset,
- distributor_logo_size.cx,
- distributor_logo_size.cy);
+ distributor_logo_size.width(),
+ distributor_logo_size.height());
}
}
@@ -309,25 +308,25 @@ void VistaFrame::Layout() {
browser_h = height;
}
- CSize preferred_size;
+ gfx::Size preferred_size;
if (shelf_view_) {
- shelf_view_->GetPreferredSize(&preferred_size);
+ preferred_size = shelf_view_->GetPreferredSize();
shelf_view_->SetBounds(browser_x,
height - g_bitmaps[CT_BOTTOM_CENTER]->height() -
- preferred_size.cy,
+ preferred_size.height(),
browser_w,
- preferred_size.cy);
- browser_h -= preferred_size.cy;
+ preferred_size.height());
+ browser_h -= preferred_size.height();
}
- CSize bookmark_bar_size;
- CSize info_bar_size;
+ gfx::Size bookmark_bar_size;
+ gfx::Size info_bar_size;
if (bookmark_bar_view_.get())
- bookmark_bar_view_->GetPreferredSize(&bookmark_bar_size);
+ bookmark_bar_size = bookmark_bar_view_->GetPreferredSize();
if (info_bar_view_)
- info_bar_view_->GetPreferredSize(&info_bar_size);
+ info_bar_size = info_bar_view_->GetPreferredSize();
// If we're showing a bookmarks bar in the new tab page style and we
// have an infobar showing, we need to flip them.
@@ -338,17 +337,17 @@ void VistaFrame::Layout() {
info_bar_view_->SetBounds(browser_x,
browser_y,
browser_w,
- info_bar_size.cy);
- browser_h -= info_bar_size.cy;
+ info_bar_size.height());
+ browser_h -= info_bar_size.height();
- browser_y += info_bar_size.cy - kSeparationLineHeight;
+ browser_y += info_bar_size.height() - kSeparationLineHeight;
bookmark_bar_view_->SetBounds(browser_x,
browser_y,
browser_w,
- bookmark_bar_size.cy);
- browser_h -= bookmark_bar_size.cy - kSeparationLineHeight;
- browser_y += bookmark_bar_size.cy;
+ bookmark_bar_size.height());
+ browser_h -= bookmark_bar_size.height() - kSeparationLineHeight;
+ browser_y += bookmark_bar_size.height();
} else {
if (bookmark_bar_view_.get()) {
// We want our bookmarks bar to be responsible for drawing its own
@@ -358,18 +357,18 @@ void VistaFrame::Layout() {
bookmark_bar_view_->SetBounds(browser_x,
browser_y,
browser_w,
- bookmark_bar_size.cy);
- browser_h -= bookmark_bar_size.cy - kSeparationLineHeight;
- browser_y += bookmark_bar_size.cy;
+ bookmark_bar_size.height());
+ browser_h -= bookmark_bar_size.height() - kSeparationLineHeight;
+ browser_y += bookmark_bar_size.height();
}
if (info_bar_view_) {
info_bar_view_->SetBounds(browser_x,
browser_y,
browser_w,
- info_bar_size.cy);
- browser_h -= info_bar_size.cy;
- browser_y += info_bar_size.cy;
+ info_bar_size.height());
+ browser_h -= info_bar_size.height();
+ browser_y += info_bar_size.height();
}
}
@@ -657,10 +656,8 @@ bool VistaFrame::IsBookmarkBarVisible() const {
if (bookmark_bar_view_->IsNewTabPage() || bookmark_bar_view_->IsAnimating())
return true;
- CSize sz;
- bookmark_bar_view_->GetPreferredSize(&sz);
// 1 is the minimum in GetPreferredSize for the bookmark bar.
- return sz.cy > 1;
+ return bookmark_bar_view_->GetPreferredSize().height() > 1;
}
////////////////////////////////////////////////////////////////////////////////
@@ -1446,9 +1443,7 @@ bool VistaFrame::UpdateChildViewAndLayout(ChromeViews::View* new_view,
if (*view == new_view) {
// The views haven't changed, if the views pref changed schedule a layout.
if (new_view) {
- CSize pref_size;
- new_view->GetPreferredSize(&pref_size);
- if (pref_size.cy != new_view->height())
+ if (new_view->GetPreferredSize().height() != new_view->height())
return true;
}
return false;
@@ -1467,9 +1462,7 @@ bool VistaFrame::UpdateChildViewAndLayout(ChromeViews::View* new_view,
int new_height = 0;
if (new_view) {
- CSize preferred_size;
- new_view->GetPreferredSize(&preferred_size);
- new_height = preferred_size.cy;
+ new_height = new_view->GetPreferredSize().height();
root_view_.AddChildView(new_view);
}
diff --git a/chrome/browser/views/old_frames/xp_frame.cc b/chrome/browser/views/old_frames/xp_frame.cc
index e4a80e7..2512f63 100644
--- a/chrome/browser/views/old_frames/xp_frame.cc
+++ b/chrome/browser/views/old_frames/xp_frame.cc
@@ -584,69 +584,69 @@ void XPFrame::Layout() {
root_view_.SetBounds(0, 0, width, height);
frame_view_->SetBounds(0, 0, width, height);
- CSize preferred_size;
+ gfx::Size preferred_size;
if (IsZoomed()) {
- close_button_->GetPreferredSize(&preferred_size);
+ preferred_size = close_button_->GetPreferredSize();
close_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
ChromeViews::Button::ALIGN_BOTTOM);
- close_button_->SetBounds(width - preferred_size.cx -
+ close_button_->SetBounds(width - preferred_size.width() -
kWindowControlsRightZoomedOffset,
0,
- preferred_size.cx +
+ preferred_size.width() +
kWindowControlsRightZoomedOffset,
- preferred_size.cy +
+ preferred_size.height() +
kWindowControlsTopZoomedOffset);
max_button_->SetVisible(false);
restore_button_->SetVisible(true);
- restore_button_->GetPreferredSize(&preferred_size);
+ preferred_size = restore_button_->GetPreferredSize();
restore_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
ChromeViews::Button::ALIGN_BOTTOM);
- restore_button_->SetBounds(close_button_->x() - preferred_size.cx,
+ restore_button_->SetBounds(close_button_->x() - preferred_size.width(),
0,
- preferred_size.cx,
- preferred_size.cy +
+ preferred_size.width(),
+ preferred_size.height() +
kWindowControlsTopZoomedOffset);
- min_button_->GetPreferredSize(&preferred_size);
+ preferred_size = min_button_->GetPreferredSize();
min_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
ChromeViews::Button::ALIGN_BOTTOM);
- min_button_->SetBounds(restore_button_->x() - preferred_size.cx,
+ min_button_->SetBounds(restore_button_->x() - preferred_size.width(),
0,
- preferred_size.cx,
- preferred_size.cy +
+ preferred_size.width(),
+ preferred_size.height() +
kWindowControlsTopZoomedOffset);
} else {
- close_button_->GetPreferredSize(&preferred_size);
+ preferred_size = close_button_->GetPreferredSize();
close_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
ChromeViews::Button::ALIGN_TOP);
close_button_->SetBounds(width - kWindowControlsRightOffset -
- preferred_size.cx,
+ preferred_size.width(),
kWindowControlsTopOffset,
- preferred_size.cx,
- preferred_size.cy);
+ preferred_size.width(),
+ preferred_size.height());
restore_button_->SetVisible(false);
max_button_->SetVisible(true);
- max_button_->GetPreferredSize(&preferred_size);
+ preferred_size = max_button_->GetPreferredSize();
max_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
ChromeViews::Button::ALIGN_TOP);
- max_button_->SetBounds(close_button_->x() - preferred_size.cx,
+ max_button_->SetBounds(close_button_->x() - preferred_size.width(),
kWindowControlsTopOffset,
- preferred_size.cx,
- preferred_size.cy);
+ preferred_size.width(),
+ preferred_size.height());
- min_button_->GetPreferredSize(&preferred_size);
+ preferred_size = min_button_->GetPreferredSize();
min_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
ChromeViews::Button::ALIGN_TOP);
- min_button_->SetBounds(max_button_->x() - preferred_size.cx,
+ min_button_->SetBounds(max_button_->x() - preferred_size.width(),
kWindowControlsTopOffset,
- preferred_size.cx,
- preferred_size.cy);
+ preferred_size.width(),
+ preferred_size.height());
}
int right_limit = min_button_->x();
@@ -674,23 +674,22 @@ void XPFrame::Layout() {
int tab_strip_x = left_margin;
if (is_off_the_record_) {
- CSize otr_image_size;
- off_the_record_image_->GetPreferredSize(&otr_image_size);
- tab_strip_x += otr_image_size.cx + (2 * kOTRImageHorizMargin);
+ gfx::Size otr_image_size = off_the_record_image_->GetPreferredSize();
+ tab_strip_x += otr_image_size.width() + (2 * kOTRImageHorizMargin);
if (IsZoomed()) {
off_the_record_image_->SetBounds(left_margin + kOTRImageHorizMargin,
top_margin + 1,
- otr_image_size.cx,
+ otr_image_size.width(),
tabstrip_->GetPreferredHeight() -
kToolbarOverlapVertOffset - 1);
} else {
off_the_record_image_->SetBounds(left_margin + kOTRImageHorizMargin,
top_margin - 1 +
tabstrip_->GetPreferredHeight() -
- otr_image_size.cy -
+ otr_image_size.height() -
kOTRImageVertMargin,
- otr_image_size.cx,
- otr_image_size.cy);
+ otr_image_size.width(),
+ otr_image_size.height());
}
}
@@ -698,15 +697,15 @@ void XPFrame::Layout() {
if (IsZoomed()) {
distributor_logo_->SetVisible(false);
} else {
- CSize distributor_logo_size;
- distributor_logo_->GetPreferredSize(&distributor_logo_size);
+ gfx::Size distributor_logo_size =
+ distributor_logo_->GetPreferredSize();
distributor_logo_->SetVisible(true);
distributor_logo_->SetBounds(min_button_->x() -
- distributor_logo_size.cx -
+ distributor_logo_size.width() -
kDistributorLogoHorizontalOffset,
kDistributorLogoVerticalOffset,
- distributor_logo_size.cx,
- distributor_logo_size.cy);
+ distributor_logo_size.width(),
+ distributor_logo_size.height());
}
}
@@ -753,26 +752,26 @@ void XPFrame::Layout() {
int browser_h = height - last_y - bottom_margin;
if (shelf_view_) {
- shelf_view_->GetPreferredSize(&preferred_size);
+ preferred_size = shelf_view_->GetPreferredSize();
shelf_view_->SetBounds(left_margin,
- height - bottom_margin - preferred_size.cy,
+ height - bottom_margin - preferred_size.height(),
width - left_margin - right_margin,
- preferred_size.cy);
- browser_h -= preferred_size.cy;
+ preferred_size.height());
+ browser_h -= preferred_size.height();
}
int bookmark_bar_height = 0;
- CSize bookmark_bar_size;
- CSize info_bar_size;
+ gfx::Size bookmark_bar_size;
+ gfx::Size info_bar_size;
if (bookmark_bar_view_.get()) {
- bookmark_bar_view_->GetPreferredSize(&bookmark_bar_size);
- bookmark_bar_height = bookmark_bar_size.cy;
+ bookmark_bar_size = bookmark_bar_view_->GetPreferredSize();
+ bookmark_bar_height = bookmark_bar_size.height();
}
if (info_bar_view_)
- info_bar_view_->GetPreferredSize(&info_bar_size);
+ info_bar_size = info_bar_view_->GetPreferredSize();
// If we're showing a bookmarks bar in the new tab page style and we
// have an infobar showing, we need to flip them.
@@ -783,9 +782,9 @@ void XPFrame::Layout() {
info_bar_view_->SetBounds(left_margin,
last_y,
client_rect.Width() - left_margin - right_margin,
- info_bar_size.cy);
- browser_h -= info_bar_size.cy;
- last_y += info_bar_size.cy;
+ info_bar_size.height());
+ browser_h -= info_bar_size.height();
+ last_y += info_bar_size.height();
last_y -= kSeparationLineHeight;
@@ -793,9 +792,9 @@ void XPFrame::Layout() {
last_y,
client_rect.Width() - left_margin -
right_margin,
- bookmark_bar_size.cy);
- browser_h -= (bookmark_bar_size.cy - kSeparationLineHeight);
- last_y += bookmark_bar_size.cy;
+ bookmark_bar_size.height());
+ browser_h -= (bookmark_bar_size.height() - kSeparationLineHeight);
+ last_y += bookmark_bar_size.height();
} else {
if (bookmark_bar_view_.get()) {
// We want our bookmarks bar to be responsible for drawing its own
@@ -806,9 +805,9 @@ void XPFrame::Layout() {
last_y,
client_rect.Width() - left_margin -
right_margin,
- bookmark_bar_size.cy);
- browser_h -= (bookmark_bar_size.cy - kSeparationLineHeight);
- last_y += bookmark_bar_size.cy;
+ bookmark_bar_size.height());
+ browser_h -= (bookmark_bar_size.height() - kSeparationLineHeight);
+ last_y += bookmark_bar_size.height();
}
if (info_bar_view_) {
@@ -816,9 +815,9 @@ void XPFrame::Layout() {
last_y,
client_rect.Width() -
left_margin - right_margin,
- info_bar_size.cy);
- browser_h -= info_bar_size.cy;
- last_y += info_bar_size.cy;
+ info_bar_size.height());
+ browser_h -= info_bar_size.height();
+ last_y += info_bar_size.height();
}
}
@@ -1894,10 +1893,8 @@ bool XPFrame::IsBookmarkBarVisible() const {
if (bookmark_bar_view_->IsNewTabPage() || bookmark_bar_view_->IsAnimating())
return true;
- CSize sz;
- bookmark_bar_view_->GetPreferredSize(&sz);
// 1 is the minimum in GetPreferredSize for the bookmark bar.
- return sz.cy > 1;
+ return bookmark_bar_view_->GetPreferredSize().height() > 1;
}
void XPFrame::MoveToFront(bool should_activate) {
@@ -2304,9 +2301,7 @@ bool XPFrame::UpdateChildViewAndLayout(ChromeViews::View* new_view,
if (*view == new_view) {
// The views haven't changed, if the views pref changed schedule a layout.
if (new_view) {
- CSize pref_size;
- new_view->GetPreferredSize(&pref_size);
- if (pref_size.cy != new_view->height())
+ if (new_view->GetPreferredSize().height() != new_view->height())
return true;
}
return false;
@@ -2325,9 +2320,7 @@ bool XPFrame::UpdateChildViewAndLayout(ChromeViews::View* new_view,
int new_height = 0;
if (new_view) {
- CSize preferred_size;
- new_view->GetPreferredSize(&preferred_size);
- new_height = preferred_size.cy;
+ new_height = new_view->GetPreferredSize().height();
root_view_.AddChildView(new_view);
}
bool changed = false;
diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc
index c063e33..0c04dd8 100644
--- a/chrome/browser/views/options/advanced_contents_view.cc
+++ b/chrome/browser/views/options/advanced_contents_view.cc
@@ -1106,9 +1106,7 @@ void AdvancedContentsView::Layout() {
const int height = GetHeightForWidth(width);
SetBounds(0, 0, width, height);
} else {
- CSize pref;
- GetPreferredSize(&pref);
- SetBounds(0, 0, pref.cx, pref.cy);
+ SetBounds(gfx::Point(), GetPreferredSize());
}
View::Layout();
}
diff --git a/chrome/browser/views/options/content_page_view.cc b/chrome/browser/views/options/content_page_view.cc
index bb70905..510976a 100644
--- a/chrome/browser/views/options/content_page_view.cc
+++ b/chrome/browser/views/options/content_page_view.cc
@@ -56,7 +56,7 @@ class FileDisplayArea : public ChromeViews::View {
// ChromeViews::View overrides:
virtual void Paint(ChromeCanvas* canvas);
virtual void Layout();
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
protected:
// ChromeViews::View overrides:
@@ -111,19 +111,17 @@ void FileDisplayArea::Paint(ChromeCanvas* canvas) {
void FileDisplayArea::Layout() {
icon_bounds_.SetRect(kFileIconHorizontalSpacing, kFileIconVerticalSpacing,
kFileIconSize, kFileIconSize);
- CSize ps;
- text_field_->GetPreferredSize(&ps);
+ gfx::Size ps = text_field_->GetPreferredSize();
text_field_->SetBounds(icon_bounds_.right() + kFileIconTextFieldSpacing,
- (height() - ps.cy) / 2,
+ (height() - ps.height()) / 2,
width() - icon_bounds_.right() -
kFileIconHorizontalSpacing -
- kFileIconTextFieldSpacing, ps.cy);
+ kFileIconTextFieldSpacing, ps.height());
}
-void FileDisplayArea::GetPreferredSize(CSize* out) {
- DCHECK(out);
- out->cx = kFileIconSize + 2 * kFileIconVerticalSpacing;
- out->cy = kFileIconSize + 2 * kFileIconHorizontalSpacing;
+gfx::Size FileDisplayArea::GetPreferredSize() {
+ return gfx::Size(kFileIconSize + 2 * kFileIconVerticalSpacing,
+ kFileIconSize + 2 * kFileIconHorizontalSpacing);
}
void FileDisplayArea::ViewHierarchyChanged(bool is_add,
diff --git a/chrome/browser/views/options/cookies_view.cc b/chrome/browser/views/options/cookies_view.cc
index 3ef2c47..cf0d5ee 100644
--- a/chrome/browser/views/options/cookies_view.cc
+++ b/chrome/browser/views/options/cookies_view.cc
@@ -641,28 +641,28 @@ ChromeViews::View* CookiesView::GetContentsView() {
void CookiesView::Layout() {
// Lay out the Remove/Remove All buttons in the parent view.
- CSize ps;
- remove_button_->GetPreferredSize(&ps);
+ gfx::Size ps = remove_button_->GetPreferredSize();
CRect parent_bounds;
GetParent()->GetLocalBounds(&parent_bounds, false);
- int y_buttons = parent_bounds.bottom - ps.cy - kButtonVEdgeMargin;
+ int y_buttons = parent_bounds.bottom - ps.height() - kButtonVEdgeMargin;
- remove_button_->SetBounds(kPanelHorizMargin, y_buttons, ps.cx, ps.cy);
+ remove_button_->SetBounds(kPanelHorizMargin, y_buttons, ps.width(),
+ ps.height());
- remove_all_button_->GetPreferredSize(&ps);
+ ps = remove_all_button_->GetPreferredSize();
int remove_all_x = remove_button_->x() + remove_button_->width() +
kRelatedControlHorizontalSpacing;
- remove_all_button_->SetBounds(remove_all_x, y_buttons, ps.cx, ps.cy);
+ remove_all_button_->SetBounds(remove_all_x, y_buttons, ps.width(),
+ ps.height());
// Lay out this View
View::Layout();
}
-void CookiesView::GetPreferredSize(CSize* out) {
- DCHECK(out);
- *out = ChromeViews::Window::GetLocalizedContentsSize(
+gfx::Size CookiesView::GetPreferredSize() {
+ return gfx::Size(ChromeViews::Window::GetLocalizedContentsSize(
IDS_COOKIES_DIALOG_WIDTH_CHARS,
- IDS_COOKIES_DIALOG_HEIGHT_LINES).ToSIZE();
+ IDS_COOKIES_DIALOG_HEIGHT_LINES));
}
void CookiesView::ViewHierarchyChanged(bool is_add,
diff --git a/chrome/browser/views/options/cookies_view.h b/chrome/browser/views/options/cookies_view.h
index a1e4315..4121c25 100644
--- a/chrome/browser/views/options/cookies_view.h
+++ b/chrome/browser/views/options/cookies_view.h
@@ -60,7 +60,7 @@ class CookiesView : public ChromeViews::View,
// ChromeViews::View overrides:
virtual void Layout();
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
protected:
// ChromeViews::View overrides:
diff --git a/chrome/browser/views/options/fonts_languages_window_view.cc b/chrome/browser/views/options/fonts_languages_window_view.cc
index 54c6952..a93fe2c 100644
--- a/chrome/browser/views/options/fonts_languages_window_view.cc
+++ b/chrome/browser/views/options/fonts_languages_window_view.cc
@@ -67,11 +67,10 @@ void FontsLanguagesWindowView::Layout() {
height() - (2 * kDialogPadding));
}
-void FontsLanguagesWindowView::GetPreferredSize(CSize* out) {
- DCHECK(out);
- *out = ChromeViews::Window::GetLocalizedContentsSize(
+gfx::Size FontsLanguagesWindowView::GetPreferredSize() {
+ return gfx::Size(ChromeViews::Window::GetLocalizedContentsSize(
IDS_FONTSLANG_DIALOG_WIDTH_CHARS,
- IDS_FONTSLANG_DIALOG_HEIGHT_LINES).ToSIZE();
+ IDS_FONTSLANG_DIALOG_HEIGHT_LINES));
}
void FontsLanguagesWindowView::ViewHierarchyChanged(
diff --git a/chrome/browser/views/options/fonts_languages_window_view.h b/chrome/browser/views/options/fonts_languages_window_view.h
index ff46478..e30f7f0 100644
--- a/chrome/browser/views/options/fonts_languages_window_view.h
+++ b/chrome/browser/views/options/fonts_languages_window_view.h
@@ -35,7 +35,7 @@ class FontsLanguagesWindowView : public ChromeViews::View,
// ChromeViews::View overrides:
virtual void Layout();
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
protected:
// ChromeViews::View overrides:
diff --git a/chrome/browser/views/options/fonts_page_view.cc b/chrome/browser/views/options/fonts_page_view.cc
index db44561..0dd8bab 100644
--- a/chrome/browser/views/options/fonts_page_view.cc
+++ b/chrome/browser/views/options/fonts_page_view.cc
@@ -97,7 +97,7 @@ class FontDisplayView : public ChromeViews::View {
// ChromeViews::View overrides:
virtual void Paint(ChromeCanvas* canvas);
virtual void Layout();
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
private:
ChromeViews::Label* font_text_label_;
@@ -169,13 +169,12 @@ void FontDisplayView::Layout() {
font_text_label_->SetBounds(0, 0, width(), height());
}
-void FontDisplayView::GetPreferredSize(CSize* out) {
- DCHECK(out);
+gfx::Size FontDisplayView::GetPreferredSize() {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
ChromeFont font = rb.GetFont(ResourceBundle::BaseFont);
- out->cx = font.ave_char_width() * kFontDisplayMaxWidthChars;
- out->cy = font.height() * kFontDisplayMaxHeightChars
- + 2 * kFontDisplayLabelPadding;
+ return gfx::Size(font.ave_char_width() * kFontDisplayMaxWidthChars,
+ font.height() * kFontDisplayMaxHeightChars
+ + 2 * kFontDisplayLabelPadding);
}
void EmbellishTitle(ChromeViews::Label* title_label) {
diff --git a/chrome/browser/views/options/languages_page_view.cc b/chrome/browser/views/options/languages_page_view.cc
index 27a00e5..465a2fa 100644
--- a/chrome/browser/views/options/languages_page_view.cc
+++ b/chrome/browser/views/options/languages_page_view.cc
@@ -229,7 +229,7 @@ class AddLanguageWindowView : public ChromeViews::View,
// ChromeViews::View overrides.
virtual void Layout();
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
protected:
virtual void ViewHierarchyChanged(bool is_add, ChromeViews::View* parent,
@@ -290,18 +290,17 @@ void AddLanguageWindowView::ItemChanged(ChromeViews::ComboBox* combo_box,
}
void AddLanguageWindowView::Layout() {
- CSize sz;
- accept_language_combobox_->GetPreferredSize(&sz);
+ gfx::Size sz = accept_language_combobox_->GetPreferredSize();
accept_language_combobox_->SetBounds(kDialogPadding, kDialogPadding,
- width() - 2*kDialogPadding, sz.cy);
+ width() - 2*kDialogPadding,
+ sz.height());
}
-void AddLanguageWindowView::GetPreferredSize(CSize* out) {
- DCHECK(out);
+gfx::Size AddLanguageWindowView::GetPreferredSize() {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
ChromeFont font = rb.GetFont(ResourceBundle::BaseFont);
- out->cx = font.ave_char_width() * kDefaultWindowWidthChars;
- out->cy = font.height() * kDefaultWindowHeightLines;
+ return gfx::Size(font.ave_char_width() * kDefaultWindowWidthChars,
+ font.height() * kDefaultWindowHeightLines);
}
void AddLanguageWindowView::ViewHierarchyChanged(
diff --git a/chrome/browser/views/options/options_window_view.cc b/chrome/browser/views/options/options_window_view.cc
index cb8bb50..57138f0 100644
--- a/chrome/browser/views/options/options_window_view.cc
+++ b/chrome/browser/views/options/options_window_view.cc
@@ -53,7 +53,7 @@ class OptionsWindowView : public ChromeViews::View,
// ChromeViews::View overrides:
virtual void Layout();
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
protected:
// ChromeViews::View overrides:
@@ -163,11 +163,10 @@ void OptionsWindowView::Layout() {
height() - (2 * kDialogPadding));
}
-void OptionsWindowView::GetPreferredSize(CSize* out) {
- DCHECK(out);
- *out = ChromeViews::Window::GetLocalizedContentsSize(
+gfx::Size OptionsWindowView::GetPreferredSize() {
+ return gfx::Size(ChromeViews::Window::GetLocalizedContentsSize(
IDS_OPTIONS_DIALOG_WIDTH_CHARS,
- IDS_OPTIONS_DIALOG_HEIGHT_LINES).ToSIZE();
+ IDS_OPTIONS_DIALOG_HEIGHT_LINES));
}
void OptionsWindowView::ViewHierarchyChanged(bool is_add,
diff --git a/chrome/browser/views/page_info_window.cc b/chrome/browser/views/page_info_window.cc
index adbdd73..79e697a 100644
--- a/chrome/browser/views/page_info_window.cc
+++ b/chrome/browser/views/page_info_window.cc
@@ -170,24 +170,22 @@ int SecurityTabView::Section::GetHeightForWidth(int width) {
// (multi-line). We need to know the width of the description label to know
// its height.
int height = 0;
- CSize size;
- title_label_->GetPreferredSize(&size);
- height += size.cy + kVGapTitleToImage;
+ gfx::Size size = title_label_->GetPreferredSize();
+ height += size.height() + kVGapTitleToImage;
- CSize image_size;
- status_image_->GetPreferredSize(&image_size);
+ gfx::Size image_size = status_image_->GetPreferredSize();
int text_height = 0;
if (!head_line_label_->GetText().empty()) {
- head_line_label_->GetPreferredSize(&size);
- text_height = size.cy + kVGapHeadLineToDescription;
+ size = head_line_label_->GetPreferredSize();
+ text_height = size.height() + kVGapHeadLineToDescription;
}
- int description_width = width - image_size.cx - kHGapImageToDescription -
- kHGapToBorder;
+ int description_width =
+ width - image_size.width() - kHGapImageToDescription - kHGapToBorder;
text_height += description_label_->GetHeightForWidth(description_width);
- height += std::max(static_cast<int>(image_size.cy), text_height);
+ height += std::max(image_size.height(), text_height);
return height;
}
@@ -196,24 +194,24 @@ void SecurityTabView::Section::Layout() {
// First, layout the title and separator.
int x = 0;
int y = 0;
- CSize size;
- title_label_->GetPreferredSize(&size);
- title_label_->SetBounds(x, y, size.cx, size.cy);
- x += size.cx + kHGapTitleToSeparator;
+ gfx::Size size = title_label_->GetPreferredSize();
+ title_label_->SetBounds(x, y, size.width(), size.height());
+ x += size.width() + kHGapTitleToSeparator;
separator_->SetBounds(x + kHExtraSeparatorPadding, y,
- width() - x - 2 * kHExtraSeparatorPadding, size.cy);
+ width() - x - 2 * kHExtraSeparatorPadding,
+ size.height());
// Then the image, head-line and description.
x = kHGapToBorder;
y += title_label_->height() + kVGapTitleToImage;
- status_image_->GetPreferredSize(&size);
- status_image_->SetBounds(x, y, size.cx, size.cy);
- x += size.cx + kHGapImageToDescription;
+ size = status_image_->GetPreferredSize();
+ status_image_->SetBounds(x, y, size.width(), size.height());
+ x += size.width() + kHGapImageToDescription;
int w = width() - x;
if (!head_line_label_->GetText().empty()) {
- head_line_label_->GetPreferredSize(&size);
- head_line_label_->SetBounds(x, y, w > 0 ? w : 0, size.cy);
- y += size.cy + kVGapHeadLineToDescription;
+ size = head_line_label_->GetPreferredSize();
+ head_line_label_->SetBounds(x, y, w > 0 ? w : 0, size.height());
+ y += size.height() + kVGapHeadLineToDescription;
} else {
head_line_label_->SetBounds(x, y, 0, 0);
}
@@ -450,14 +448,13 @@ class PageInfoContentView : public ChromeViews::View {
virtual void Layout() {
if (cert_viewer_button_) {
- CSize ps;
- cert_viewer_button_->GetPreferredSize(&ps);
+ gfx::Size ps = cert_viewer_button_->GetPreferredSize();
CRect parent_bounds;
GetParent()->GetLocalBounds(&parent_bounds, false);
- int y_buttons = parent_bounds.bottom - ps.cy - kButtonVEdgeMargin;
- cert_viewer_button_->SetBounds(kPanelHorizMargin, y_buttons, ps.cx,
- ps.cy);
+ int y_buttons = parent_bounds.bottom - ps.height() - kButtonVEdgeMargin;
+ cert_viewer_button_->SetBounds(kPanelHorizMargin, y_buttons, ps.width(),
+ ps.height());
}
View::Layout();
}
diff --git a/chrome/browser/views/password_manager_view.cc b/chrome/browser/views/password_manager_view.cc
index 926ce17..e39d67b 100644
--- a/chrome/browser/views/password_manager_view.cc
+++ b/chrome/browser/views/password_manager_view.cc
@@ -36,21 +36,20 @@ MultiLabelButtons::MultiLabelButtons(const std::wstring& label,
pref_size_(-1, -1) {
}
-void MultiLabelButtons::GetPreferredSize(CSize *out) {
- if (pref_size_.cx == -1 && pref_size_.cy == -1) {
+gfx::Size MultiLabelButtons::GetPreferredSize() {
+ if (pref_size_.width() == -1 && pref_size_.height() == -1) {
// Let's compute our preferred size.
std::wstring current_label = GetLabel();
SetLabel(label_);
- NativeButton::GetPreferredSize(&pref_size_);
+ pref_size_ = NativeButton::GetPreferredSize();
SetLabel(alt_label_);
- CSize alt_pref_size;
- NativeButton::GetPreferredSize(&alt_pref_size);
+ gfx::Size alt_pref_size = NativeButton::GetPreferredSize();
// Revert to the original label.
SetLabel(current_label);
- pref_size_.cx = std::max(pref_size_.cx, alt_pref_size.cx);
- pref_size_.cy = std::max(pref_size_.cy, alt_pref_size.cy);
+ pref_size_.SetSize(std::max(pref_size_.width(), alt_pref_size.width()),
+ std::max(pref_size_.height(), alt_pref_size.height()));
}
- *out = pref_size_;
+ return gfx::Size(pref_size_.width(), pref_size_.height());
}
////////////////////////////////////////////////////////////////////
@@ -296,16 +295,14 @@ void PasswordManagerView::Layout() {
// the close button.
CRect parent_bounds;
GetParent()->GetLocalBounds(&parent_bounds, false);
- CSize prefsize;
- remove_all_button_.GetPreferredSize(&prefsize);
- int button_y = parent_bounds.bottom - prefsize.cy - kButtonVEdgeMargin;
- remove_all_button_.SetBounds(kPanelHorizMargin, button_y, prefsize.cx,
- prefsize.cy);
+ gfx::Size prefsize = remove_all_button_.GetPreferredSize();
+ int button_y = parent_bounds.bottom - prefsize.height() - kButtonVEdgeMargin;
+ remove_all_button_.SetBounds(kPanelHorizMargin, button_y, prefsize.width(),
+ prefsize.height());
}
-void PasswordManagerView::GetPreferredSize(CSize* out) {
- out->cx = kDefaultWindowWidth;
- out->cy = kDefaultWindowHeight;
+gfx::Size PasswordManagerView::GetPreferredSize() {
+ return gfx::Size(kDefaultWindowWidth, kDefaultWindowHeight);
}
void PasswordManagerView::ViewHierarchyChanged(bool is_add,
diff --git a/chrome/browser/views/password_manager_view.h b/chrome/browser/views/password_manager_view.h
index bbcba7d..f611b18 100644
--- a/chrome/browser/views/password_manager_view.h
+++ b/chrome/browser/views/password_manager_view.h
@@ -89,12 +89,12 @@ class MultiLabelButtons : public ChromeViews::NativeButton {
public:
MultiLabelButtons(const std::wstring& label, const std::wstring& alt_label);
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
private:
std::wstring label_;
std::wstring alt_label_;
- CSize pref_size_;
+ gfx::Size pref_size_;
DISALLOW_EVIL_CONSTRUCTORS(MultiLabelButtons);
};
@@ -112,7 +112,7 @@ class PasswordManagerView : public ChromeViews::View,
// View methods.
virtual void Layout();
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
virtual void ViewHierarchyChanged(bool is_add, ChromeViews::View* parent,
ChromeViews::View* child);
diff --git a/chrome/browser/views/shelf_item_dialog.cc b/chrome/browser/views/shelf_item_dialog.cc
index 9293619..f1bbeaa 100644
--- a/chrome/browser/views/shelf_item_dialog.cc
+++ b/chrome/browser/views/shelf_item_dialog.cc
@@ -446,11 +446,10 @@ void ShelfItemDialog::PerformModelChange() {
delegate_->AddBookmark(this, title, url);
}
-void ShelfItemDialog::GetPreferredSize(CSize *out) {
- DCHECK(out);
- *out = ChromeViews::Window::GetLocalizedContentsSize(
+gfx::Size ShelfItemDialog::GetPreferredSize() {
+ return gfx::Size(ChromeViews::Window::GetLocalizedContentsSize(
IDS_SHELFITEM_DIALOG_WIDTH_CHARS,
- IDS_SHELFITEM_DIALOG_HEIGHT_LINES).ToSIZE();
+ IDS_SHELFITEM_DIALOG_HEIGHT_LINES));
}
bool ShelfItemDialog::AcceleratorPressed(
diff --git a/chrome/browser/views/shelf_item_dialog.h b/chrome/browser/views/shelf_item_dialog.h
index b2622a9..744e6f6 100644
--- a/chrome/browser/views/shelf_item_dialog.h
+++ b/chrome/browser/views/shelf_item_dialog.h
@@ -74,7 +74,7 @@ class ShelfItemDialog : public ChromeViews::View,
// Overridden from View.
virtual void DidChangeBounds(const CRect& previous, const CRect& current);
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
virtual bool AcceleratorPressed(const ChromeViews::Accelerator& accelerator);
// TableViewObserver.
diff --git a/chrome/browser/views/star_toggle.cc b/chrome/browser/views/star_toggle.cc
index 43ebed3e..d51b440 100644
--- a/chrome/browser/views/star_toggle.cc
+++ b/chrome/browser/views/star_toggle.cc
@@ -40,9 +40,8 @@ void StarToggle::Paint(ChromeCanvas* canvas) {
(height() - state_off_->height()) / 2);
}
-void StarToggle::GetPreferredSize(CSize* out) {
- out->cx = state_off_->width();
- out->cy = state_off_->height();
+gfx::Size StarToggle::GetPreferredSize() {
+ return gfx::Size(state_off_->width(), state_off_->height());
}
bool StarToggle::OnMouseDragged(const ChromeViews::MouseEvent& e) {
diff --git a/chrome/browser/views/star_toggle.h b/chrome/browser/views/star_toggle.h
index 6a353e1..e5e71e8 100644
--- a/chrome/browser/views/star_toggle.h
+++ b/chrome/browser/views/star_toggle.h
@@ -41,7 +41,7 @@ class StarToggle : public ChromeViews::View {
// Overriden from view.
void Paint(ChromeCanvas* canvas);
- void GetPreferredSize(CSize* out);
+ gfx::Size GetPreferredSize();
virtual bool OnMousePressed(const ChromeViews::MouseEvent& e);
virtual bool OnMouseDragged(const ChromeViews::MouseEvent& event);
virtual void OnMouseReleased(const ChromeViews::MouseEvent& e, bool canceled);
diff --git a/chrome/browser/views/tab_icon_view.cc b/chrome/browser/views/tab_icon_view.cc
index fb2caae..245a38d 100644
--- a/chrome/browser/views/tab_icon_view.cc
+++ b/chrome/browser/views/tab_icon_view.cc
@@ -127,7 +127,7 @@ void TabIconView::Paint(ChromeCanvas* canvas) {
}
}
-void TabIconView::GetPreferredSize(CSize* out) {
- out->cx = out->cy = kFavIconSize;
+gfx::Size TabIconView::GetPreferredSize() {
+ return gfx::Size(kFavIconSize, kFavIconSize);
}
diff --git a/chrome/browser/views/tab_icon_view.h b/chrome/browser/views/tab_icon_view.h
index 47ee9de..304c224 100644
--- a/chrome/browser/views/tab_icon_view.h
+++ b/chrome/browser/views/tab_icon_view.h
@@ -39,7 +39,7 @@ class TabIconView : public ChromeViews::View {
// Overriden from View
virtual void Paint(ChromeCanvas* canvas);
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
private:
void PaintThrobber(ChromeCanvas* canvas);
diff --git a/chrome/browser/views/tabs/dragged_tab_view.cc b/chrome/browser/views/tabs/dragged_tab_view.cc
index 6e3fead..5b43500 100644
--- a/chrome/browser/views/tabs/dragged_tab_view.cc
+++ b/chrome/browser/views/tabs/dragged_tab_view.cc
@@ -63,9 +63,8 @@ void DraggedTabView::MoveTo(const gfx::Point& screen_point) {
// On RTL locales, a dragged tab (when it is not attached to a tab strip)
// is rendered using a right-to-left orientation so we should calculate the
// window position differently.
- CSize ps;
- GetPreferredSize(&ps);
- x = screen_point.x() - ScaleValue(ps.cx) + mouse_tab_offset_.x() +
+ gfx::Size ps = GetPreferredSize();
+ x = screen_point.x() - ScaleValue(ps.width()) + mouse_tab_offset_.x() +
ScaleValue(
renderer_->MirroredXCoordinateInsideView(mouse_tab_offset_.x()));
} else {
@@ -150,30 +149,26 @@ void DraggedTabView::Paint(ChromeCanvas* canvas) {
}
void DraggedTabView::Layout() {
- CSize ps;
- GetPreferredSize(&ps);
if (attached_) {
- renderer_->SetBounds(CRect(0, 0, ps.cx, ps.cy));
+ renderer_->SetBounds(gfx::Point(), GetPreferredSize());
} else {
int left = 0;
if (UILayoutIsRightToLeft())
- left = ps.cx - attached_tab_size_.width();
+ left = GetPreferredSize().width() - attached_tab_size_.width();
renderer_->SetBounds(CRect(left, 0, left + attached_tab_size_.width(),
attached_tab_size_.height()));
}
}
-void DraggedTabView::GetPreferredSize(CSize* out) {
- DCHECK(out);
- if (attached_) {
- *out = attached_tab_size_.ToSIZE();
- } else {
- int width = std::max(attached_tab_size_.width(), contents_size_.width()) +
- kTwiceDragFrameBorderSize;
- int height = attached_tab_size_.height() + kDragFrameBorderSize +
- contents_size_.height();
- *out = CSize(width, height);
- }
+gfx::Size DraggedTabView::GetPreferredSize() {
+ if (attached_)
+ return attached_tab_size_;
+
+ int width = std::max(attached_tab_size_.width(), contents_size_.width()) +
+ kTwiceDragFrameBorderSize;
+ int height = attached_tab_size_.height() + kDragFrameBorderSize +
+ contents_size_.height();
+ return gfx::Size(width, height);
}
////////////////////////////////////////////////////////////////////////////////
@@ -184,21 +179,20 @@ void DraggedTabView::PaintAttachedTab(ChromeCanvas* canvas) {
}
void DraggedTabView::PaintDetachedView(ChromeCanvas* canvas) {
- CSize ps;
- GetPreferredSize(&ps);
- ChromeCanvas scale_canvas(ps.cx, ps.cy, false);
+ gfx::Size ps = GetPreferredSize();
+ ChromeCanvas scale_canvas(ps.width(), ps.height(), false);
SkBitmap& bitmap_device = const_cast<SkBitmap&>(
scale_canvas.getTopPlatformDevice().accessBitmap(true));
bitmap_device.eraseARGB(0, 0, 0, 0);
scale_canvas.FillRectInt(kDraggedTabBorderColor, 0,
attached_tab_size_.height() - kDragFrameBorderSize,
- ps.cx, ps.cy - attached_tab_size_.height());
+ ps.width(), ps.height() - attached_tab_size_.height());
int image_x = kDragFrameBorderSize;
int image_y = attached_tab_size_.height();
- int image_w = ps.cx - kTwiceDragFrameBorderSize;
+ int image_w = ps.width() - kTwiceDragFrameBorderSize;
int image_h =
- ps.cy - kTwiceDragFrameBorderSize - attached_tab_size_.height();
+ ps.height() - kTwiceDragFrameBorderSize - attached_tab_size_.height();
scale_canvas.FillRectInt(SK_ColorBLACK, image_x, image_y, image_w, image_h);
photobooth_->PaintScreenshotIntoCanvas(
&scale_canvas,
@@ -206,7 +200,7 @@ void DraggedTabView::PaintDetachedView(ChromeCanvas* canvas) {
renderer_->ProcessPaint(&scale_canvas);
SkIRect subset;
- subset.set(0, 0, ps.cx, ps.cy);
+ subset.set(0, 0, ps.width(), ps.height());
SkBitmap mipmap = scale_canvas.ExtractBitmap();
mipmap.buildMipMap(true);
@@ -226,16 +220,16 @@ void DraggedTabView::PaintDetachedView(ChromeCanvas* canvas) {
SkRect rc;
rc.fLeft = 0;
rc.fTop = 0;
- rc.fRight = SkIntToScalar(ps.cx);
- rc.fBottom = SkIntToScalar(ps.cy);
+ rc.fRight = SkIntToScalar(ps.width());
+ rc.fBottom = SkIntToScalar(ps.height());
canvas->drawRect(rc, paint);
}
void DraggedTabView::ResizeContainer() {
- CSize ps;
- GetPreferredSize(&ps);
- SetWindowPos(container_->GetHWND(), HWND_TOPMOST, 0, 0, ScaleValue(ps.cx),
- ScaleValue(ps.cy), SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
+ gfx::Size ps = GetPreferredSize();
+ SetWindowPos(container_->GetHWND(), HWND_TOPMOST, 0, 0,
+ ScaleValue(ps.width()), ScaleValue(ps.height()),
+ SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
}
int DraggedTabView::ScaleValue(int value) {
diff --git a/chrome/browser/views/tabs/dragged_tab_view.h b/chrome/browser/views/tabs/dragged_tab_view.h
index e59582c..14ba7ec 100644
--- a/chrome/browser/views/tabs/dragged_tab_view.h
+++ b/chrome/browser/views/tabs/dragged_tab_view.h
@@ -61,7 +61,7 @@ class DraggedTabView : public ChromeViews::View,
// Overridden from ChromeViews::View:
virtual void Paint(ChromeCanvas* canvas);
virtual void Layout();
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
// Paint the view, when it's attached to a TabStrip.
void PaintAttachedTab(ChromeCanvas* canvas);
diff --git a/chrome/browser/views/tabs/tab_renderer.cc b/chrome/browser/views/tabs/tab_renderer.cc
index 44cd363..876c57e 100644
--- a/chrome/browser/views/tabs/tab_renderer.cc
+++ b/chrome/browser/views/tabs/tab_renderer.cc
@@ -330,7 +330,7 @@ void TabRenderer::StopPulse() {
}
// static
-gfx::Size TabRenderer::GetMinimumSize() {
+gfx::Size TabRenderer::GetMinimumUnselectedSize() {
InitResources();
gfx::Size minimum_size;
@@ -343,14 +343,14 @@ gfx::Size TabRenderer::GetMinimumSize() {
// static
gfx::Size TabRenderer::GetMinimumSelectedSize() {
- gfx::Size minimum_size = GetMinimumSize();
+ gfx::Size minimum_size = GetMinimumUnselectedSize();
minimum_size.set_width(kLeftPadding + kFaviconSize + kRightPadding);
return minimum_size;
}
// static
gfx::Size TabRenderer::GetStandardSize() {
- gfx::Size standard_size = GetMinimumSize();
+ gfx::Size standard_size = GetMinimumUnselectedSize();
standard_size.set_width(
standard_size.width() + kFavIconTitleSpacing + kStandardTitleWidth);
return standard_size;
@@ -369,7 +369,7 @@ std::wstring TabRenderer::GetTitle() const {
void TabRenderer::Paint(ChromeCanvas* canvas) {
// Don't paint if we're narrower than we can render correctly. (This should
// only happen during animations).
- if (width() < GetMinimumSize().width())
+ if (width() < GetMinimumUnselectedSize().width())
return;
// See if the model changes whether the icons should be painted.
@@ -492,7 +492,7 @@ void TabRenderer::Layout() {
// If the user has big fonts, the title will appear rendered too far down on
// the y-axis if we use the regular top padding, so we need to adjust it so
// that the text appears centered.
- gfx::Size minimum_size = GetMinimumSize();
+ gfx::Size minimum_size = GetMinimumUnselectedSize();
int text_height = title_top + title_font_height + kBottomPadding;
if (text_height > minimum_size.height())
title_top -= (text_height - minimum_size.height()) / 2;
@@ -635,9 +635,8 @@ void TabRenderer::PaintLoadingAnimation(ChromeCanvas* canvas) {
}
int TabRenderer::IconCapacity() const {
- if (height() < GetMinimumSize().height()) {
+ if (height() < GetMinimumUnselectedSize().height())
return 0;
- }
return (width() - kLeftPadding - kRightPadding) / kFaviconSize;
}
diff --git a/chrome/browser/views/tabs/tab_renderer.h b/chrome/browser/views/tabs/tab_renderer.h
index cb92574..1c0a9f5 100644
--- a/chrome/browser/views/tabs/tab_renderer.h
+++ b/chrome/browser/views/tabs/tab_renderer.h
@@ -54,7 +54,7 @@ class TabRenderer : public ChromeViews::View,
void StopPulse();
// Returns the minimum possible size of a single unselected Tab.
- static gfx::Size GetMinimumSize();
+ static gfx::Size GetMinimumUnselectedSize();
// Returns the minimum possible size of a selected Tab. Selected tabs must
// always show a close button and have a larger minimum size than unselected
// tabs.
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index 835ffa6..7158bf0 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -197,7 +197,7 @@ class TabStrip::TabAnimation : public AnimationDelegate {
if (start_tab_count < end_tab_count &&
start_unselected_width_ < standard_tab_width) {
double minimum_tab_width =
- static_cast<double>(TabRenderer::GetMinimumSize().width());
+ static_cast<double>(TabRenderer::GetMinimumUnselectedSize().width());
start_unselected_width_ -= minimum_tab_width / start_tab_count;
}
tabstrip_->GenerateIdealBounds();
@@ -247,7 +247,7 @@ class InsertTabAnimation : public TabStrip::TabAnimation {
double target_width =
is_selected ? end_unselected_width_ : end_selected_width_;
double start_width = is_selected ? Tab::GetMinimumSelectedSize().width() :
- Tab::GetMinimumSize().width();
+ Tab::GetMinimumUnselectedSize().width();
double delta = target_width - start_width;
if (delta > 0)
return start_width + (delta * animation_.GetCurrentValue());
@@ -294,7 +294,8 @@ class RemoveTabAnimation : public TabStrip::TabAnimation {
// of the animation.
// Removed animated Tabs are never selected.
double start_width = start_unselected_width_;
- double target_width = Tab::GetMinimumSize().width() + kTabHOffset;
+ double target_width =
+ Tab::GetMinimumUnselectedSize().width() + kTabHOffset;
double delta = start_width - target_width;
return start_width - (delta * animation_.GetCurrentValue());
}
@@ -508,9 +509,7 @@ TabStrip::~TabStrip() {
}
int TabStrip::GetPreferredHeight() {
- CSize preferred_size;
- GetPreferredSize(&preferred_size);
- return preferred_size.cy;
+ return GetPreferredSize().height();
}
bool TabStrip::HasAvailableDragActions() const {
@@ -676,10 +675,8 @@ void TabStrip::Layout() {
SchedulePaint();
}
-void TabStrip::GetPreferredSize(CSize* preferred_size) {
- DCHECK(preferred_size);
- preferred_size->cx = 0;
- preferred_size->cy = Tab::GetMinimumSize().height();
+gfx::Size TabStrip::GetPreferredSize() {
+ return gfx::Size(0, Tab::GetMinimumUnselectedSize().height());
}
void TabStrip::OnDragEntered(const DropTargetEvent& event) {
@@ -1157,7 +1154,7 @@ void TabStrip::GetCurrentTabWidths(double* unselected_width,
void TabStrip::GetDesiredTabWidths(int tab_count,
double* unselected_width,
double* selected_width) const {
- const double min_unselected_width = Tab::GetMinimumSize().width();
+ const double min_unselected_width = Tab::GetMinimumUnselectedSize().width();
const double min_selected_width = Tab::GetMinimumSelectedSize().width();
if (tab_count == 0) {
// Return immediately to avoid divide-by-zero below.
diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h
index 4d53fa1..f30f59b 100644
--- a/chrome/browser/views/tabs/tab_strip.h
+++ b/chrome/browser/views/tabs/tab_strip.h
@@ -101,7 +101,7 @@ class TabStrip : public ChromeViews::View,
virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual ChromeViews::View* GetViewByID(int id) const;
virtual void Layout();
- virtual void GetPreferredSize(CSize* preferred_size);
+ virtual gfx::Size GetPreferredSize();
// NOTE: the drag and drop methods are invoked from FrameView. This is done to
// allow for a drop region that extends outside the bounds of the TabStrip.
virtual void OnDragEntered(const ChromeViews::DropTargetEvent& event);
diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc
index b381125..63dd222 100644
--- a/chrome/browser/views/toolbar_view.cc
+++ b/chrome/browser/views/toolbar_view.cc
@@ -262,7 +262,7 @@ void BrowserToolbarView::CreateRightSideControls(Profile* profile) {
}
void BrowserToolbarView::Layout() {
- CSize sz;
+ gfx::Size sz;
// If we have not been initialized yet just do nothing.
if (back_ == NULL)
@@ -275,49 +275,49 @@ void BrowserToolbarView::Layout() {
// The width of all of the controls to the right of the location bar.
int right_side_width = 0;
if (IsDisplayModeNormal()) {
- back_->GetPreferredSize(&sz);
- back_->SetBounds(kControlIndent, kControlVertOffset, sz.cx, sz.cy);
+ sz = back_->GetPreferredSize();
+ back_->SetBounds(kControlIndent, kControlVertOffset, sz.width(),
+ sz.height());
- forward_->GetPreferredSize(&sz);
+ sz = forward_->GetPreferredSize();
forward_->SetBounds(back_->x() + back_->width(), kControlVertOffset,
- sz.cx, sz.cy);
+ sz.width(), sz.height());
- reload_->GetPreferredSize(&sz);
+ sz = reload_->GetPreferredSize();
reload_->SetBounds(forward_->x() + forward_->width() +
kControlHorizOffset,
- kControlVertOffset, sz.cx, sz.cy);
+ kControlVertOffset, sz.width(), sz.height());
int offset = 0;
if (show_home_button_.GetValue()) {
- home_->GetPreferredSize(&sz);
+ sz = home_->GetPreferredSize();
offset = kControlHorizOffset;
home_->SetVisible(true);
} else {
- sz = CSize(0, 0);
+ sz = gfx::Size();
home_->SetVisible(false);
}
home_->SetBounds(reload_->x() + reload_->width() + offset,
- kControlVertOffset, sz.cx, sz.cy);
+ kControlVertOffset, sz.width(), sz.height());
- star_->GetPreferredSize(&sz);
+ sz = star_->GetPreferredSize();
star_->SetBounds(home_->x() + home_->width() + kControlHorizOffset,
- kControlVertOffset, sz.cx, sz.cy);
+ kControlVertOffset, sz.width(), sz.height());
- page_menu_->GetPreferredSize(&sz);
- right_side_width = sz.cx + kMenuButtonOffset;
+ sz = page_menu_->GetPreferredSize();
+ right_side_width = sz.width() + kMenuButtonOffset;
- app_menu_->GetPreferredSize(&sz);
- right_side_width += sz.cx + kPaddingRight;
+ sz = app_menu_->GetPreferredSize();
+ right_side_width += sz.width() + kPaddingRight;
- go_->GetPreferredSize(&sz);
- location_bar_height = sz.cy;
- right_side_width += sz.cx;
+ sz = go_->GetPreferredSize();
+ location_bar_height = sz.height();
+ right_side_width += sz.width();
left_side_width = star_->x() + star_->width();
} else {
- CSize temp;
- location_bar_->GetPreferredSize(&temp);
- location_bar_height = temp.cy;
+ gfx::Size temp = location_bar_->GetPreferredSize();
+ location_bar_height = temp.height();
left_side_width = kToolbarHorizontalMargin;
right_side_width = kToolbarHorizontalMargin;
location_bar_y = kControlVertOffsetLocationOnly;
@@ -329,15 +329,16 @@ void BrowserToolbarView::Layout() {
if (IsDisplayModeNormal()) {
go_->SetBounds(location_bar_->x() + location_bar_->width(),
- kControlVertOffset, sz.cx, sz.cy);
+ kControlVertOffset, sz.width(), sz.height());
// Make sure the Page menu never overlaps the location bar.
int page_x = go_->x() + go_->width() + kMenuButtonOffset;
- page_menu_->GetPreferredSize(&sz);
- page_menu_->SetBounds(page_x, kControlVertOffset, sz.cx, go_->height());
- app_menu_->GetPreferredSize(&sz);
+ sz = page_menu_->GetPreferredSize();
+ page_menu_->SetBounds(page_x, kControlVertOffset, sz.width(),
+ go_->height());
+ sz = app_menu_->GetPreferredSize();
app_menu_->SetBounds(page_menu_->x() + page_menu_->width(),
- page_menu_->y(), sz.cx, go_->height());
+ page_menu_->y(), sz.width(), go_->height());
}
}
@@ -469,22 +470,18 @@ bool BrowserToolbarView::OnKeyReleased(const ChromeViews::KeyEvent& e) {
return acc_focused_view_->OnKeyReleased(e);
}
-void BrowserToolbarView::GetPreferredSize(CSize* out) {
- DCHECK(out);
- out->cx = 0;
-
+gfx::Size BrowserToolbarView::GetPreferredSize() {
if (IsDisplayModeNormal()) {
static SkBitmap normal_background;
if (normal_background.isNull()) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
normal_background = *rb.GetBitmapNamed(IDR_CONTENT_TOP_CENTER);
}
- out->cy = normal_background.height();
- } else {
- CSize ps;
- location_bar_->GetPreferredSize(&ps);
- out->cy = ps.cy + 2 * kControlVertOffsetLocationOnly;
+ return gfx::Size(0, normal_background.height());
}
+
+ int locbar_height = location_bar_->GetPreferredSize().height();
+ return gfx::Size(0, locbar_height + 2 * kControlVertOffsetLocationOnly);
}
void BrowserToolbarView::RunPageMenu(const CPoint& pt, HWND hwnd) {
diff --git a/chrome/browser/views/toolbar_view.h b/chrome/browser/views/toolbar_view.h
index c009dc8..aa4040f 100644
--- a/chrome/browser/views/toolbar_view.h
+++ b/chrome/browser/views/toolbar_view.h
@@ -52,7 +52,7 @@ class BrowserToolbarView : public ChromeViews::View,
virtual void WillLoseFocus();
virtual bool OnKeyPressed(const ChromeViews::KeyEvent& e);
virtual bool OnKeyReleased(const ChromeViews::KeyEvent& e);
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
// Overridden from EncodingMenuControllerDelegate:
virtual bool IsItemChecked(int id) const;
diff --git a/chrome/test/interactive_ui/view_event_test_base.cc b/chrome/test/interactive_ui/view_event_test_base.cc
index 8cf9e61..9f36318 100644
--- a/chrome/test/interactive_ui/view_event_test_base.cc
+++ b/chrome/test/interactive_ui/view_event_test_base.cc
@@ -17,11 +17,10 @@ class TestView : public ChromeViews::View {
TestView() {}
void set_preferred_size(const gfx::Size& size) { preferred_size_ = size; }
- void GetPreferredSize(CSize* out) {
+ gfx::Size GetPreferredSize() {
if (!preferred_size_.IsEmpty())
- *out = preferred_size_.ToSIZE();
- else
- View::GetPreferredSize(out);
+ return preferred_size_;
+ return View::GetPreferredSize();
}
private:
diff --git a/chrome/views/bitmap_scroll_bar.cc b/chrome/views/bitmap_scroll_bar.cc
index 334701b..699d986 100644
--- a/chrome/views/bitmap_scroll_bar.cc
+++ b/chrome/views/bitmap_scroll_bar.cc
@@ -14,6 +14,9 @@
#include "generated_resources.h"
+#undef min
+#undef max
+
namespace ChromeViews {
namespace {
@@ -85,11 +88,10 @@ class BitmapScrollBarThumb : public View {
void SetSize(int size) {
// Make sure the thumb is never sized smaller than its minimum possible
// display size.
- CSize prefsize;
- GetPreferredSize(&prefsize);
+ gfx::Size prefsize = GetPreferredSize();
size = std::max(size,
static_cast<int>(scroll_bar_->IsHorizontal() ?
- prefsize.cx : prefsize.cy));
+ prefsize.width() : prefsize.height()));
gfx::Rect thumb_bounds = bounds();
if (scroll_bar_->IsHorizontal()) {
thumb_bounds.set_width(size);
@@ -127,11 +129,11 @@ class BitmapScrollBarThumb : public View {
}
// View overrides:
- virtual void GetPreferredSize(CSize* preferred_size) {
- DCHECK(preferred_size);
- preferred_size->cx = background_bitmap()->width();
- preferred_size->cy = start_cap_bitmap()->height() +
- end_cap_bitmap()->height() + grippy_bitmap()->height();
+ virtual gfx::Size GetPreferredSize() {
+ return gfx::Size(background_bitmap()->width(),
+ start_cap_bitmap()->height() +
+ end_cap_bitmap()->height() +
+ grippy_bitmap()->height());
}
protected:
@@ -280,20 +282,19 @@ BitmapScrollBar::BitmapScrollBar(bool horizontal, bool show_scroll_buttons)
}
gfx::Rect BitmapScrollBar::GetTrackBounds() const {
- CSize prefsize;
- prev_button_->GetPreferredSize(&prefsize);
+ gfx::Size prefsize = prev_button_->GetPreferredSize();
if (IsHorizontal()) {
if (!show_scroll_buttons_)
- prefsize.cx = 0;
- int new_width = std::max(0,
- static_cast<int>(width() - (prefsize.cx * 2)));
- gfx::Rect track_bounds(prefsize.cx, 0, new_width, prefsize.cy);
+ prefsize.set_width(0);
+ int new_width =
+ std::max(0, static_cast<int>(width() - (prefsize.width() * 2)));
+ gfx::Rect track_bounds(prefsize.width(), 0, new_width, prefsize.height());
return track_bounds;
}
if (!show_scroll_buttons_)
- prefsize.cy = 0;
- gfx::Rect track_bounds(0, prefsize.cy, prefsize.cx,
- std::max(0l, height() - (prefsize.cy * 2)));
+ prefsize.set_height(0);
+ gfx::Rect track_bounds(0, prefsize.height(), prefsize.width(),
+ std::max(0, height() - (prefsize.height() * 2)));
return track_bounds;
}
@@ -381,15 +382,11 @@ void BitmapScrollBar::TrackClicked() {
///////////////////////////////////////////////////////////////////////////////
// BitmapScrollBar, View implementation:
-void BitmapScrollBar::GetPreferredSize(CSize* preferred_size) {
- DCHECK(preferred_size);
-
+gfx::Size BitmapScrollBar::GetPreferredSize() {
// In this case, we're returning the desired width of the scrollbar and its
// minimum allowable height.
- CSize button_prefsize;
- prev_button_->GetPreferredSize(&button_prefsize);
- preferred_size->cx = button_prefsize.cx;
- preferred_size->cy = button_prefsize.cy * 2;
+ gfx::Size button_prefsize = prev_button_->GetPreferredSize();
+ return gfx::Size(button_prefsize.width(), button_prefsize.height() * 2);
}
void BitmapScrollBar::Paint(ChromeCanvas* canvas) {
@@ -403,16 +400,15 @@ void BitmapScrollBar::Paint(ChromeCanvas* canvas) {
void BitmapScrollBar::Layout() {
// Size and place the two scroll buttons.
if (show_scroll_buttons_) {
- CSize prefsize;
- prev_button_->GetPreferredSize(&prefsize);
- prev_button_->SetBounds(0, 0, prefsize.cx, prefsize.cy);
- next_button_->GetPreferredSize(&prefsize);
+ gfx::Size prefsize = prev_button_->GetPreferredSize();
+ prev_button_->SetBounds(gfx::Point(), prefsize);
+ prefsize = next_button_->GetPreferredSize();
if (IsHorizontal()) {
- next_button_->SetBounds(width() - prefsize.cx, 0, prefsize.cx,
- prefsize.cy);
+ next_button_->SetBounds(width() - prefsize.width(), 0, prefsize.width(),
+ prefsize.height());
} else {
- next_button_->SetBounds(0, height() - prefsize.cy, prefsize.cx,
- prefsize.cy);
+ next_button_->SetBounds(0, height() - prefsize.height(), prefsize.width(),
+ prefsize.height());
}
} else {
prev_button_->SetBounds(0, 0, 0, 0);
@@ -420,8 +416,7 @@ void BitmapScrollBar::Layout() {
}
// Size and place the thumb
- CSize thumb_prefsize;
- thumb_->GetPreferredSize(&thumb_prefsize);
+ gfx::Size thumb_prefsize = thumb_->GetPreferredSize();
gfx::Rect track_bounds = GetTrackBounds();
// Preserve the height/width of the thumb (depending on orientation) as set
@@ -429,17 +424,17 @@ void BitmapScrollBar::Layout() {
// appropriate value for the bitmaps provided.
if (IsHorizontal()) {
thumb_->SetBounds(thumb_->x(), thumb_->y(), thumb_->width(),
- thumb_prefsize.cy);
+ thumb_prefsize.height());
} else {
- thumb_->SetBounds(thumb_->x(), thumb_->y(), thumb_prefsize.cx,
+ thumb_->SetBounds(thumb_->x(), thumb_->y(), thumb_prefsize.width(),
thumb_->height());
}
// Hide the thumb if the track isn't tall enough to display even a tiny
// thumb. The user can only use the mousewheel, scroll buttons or keyboard
// in this scenario.
- if ((IsHorizontal() && (track_bounds.width() < thumb_prefsize.cx)) ||
- (!IsHorizontal() && (track_bounds.height() < thumb_prefsize.cy))) {
+ if ((IsHorizontal() && (track_bounds.width() < thumb_prefsize.width()) ||
+ (!IsHorizontal() && (track_bounds.height() < thumb_prefsize.height())))) {
thumb_->SetVisible(false);
} else if (!thumb_->IsVisible()) {
thumb_->SetVisible(true);
@@ -672,9 +667,8 @@ void BitmapScrollBar::Update(int viewport_size, int content_size,
}
int BitmapScrollBar::GetLayoutSize() const {
- CSize prefsize;
- prev_button_->GetPreferredSize(&prefsize);
- return IsHorizontal() ? prefsize.cy : prefsize.cx;
+ gfx::Size prefsize = prev_button_->GetPreferredSize();
+ return IsHorizontal() ? prefsize.height() : prefsize.width();
}
int BitmapScrollBar::GetPosition() const {
diff --git a/chrome/views/bitmap_scroll_bar.h b/chrome/views/bitmap_scroll_bar.h
index 6d630c0..03f2a9a 100644
--- a/chrome/views/bitmap_scroll_bar.h
+++ b/chrome/views/bitmap_scroll_bar.h
@@ -87,7 +87,7 @@ class BitmapScrollBar : public ScrollBar,
void ScrollByContentsOffset(int contents_offset);
// View overrides:
- virtual void GetPreferredSize(CSize* preferred_size);
+ virtual gfx::Size GetPreferredSize();
virtual void Paint(ChromeCanvas* canvas);
virtual void Layout();
virtual void DidChangeBounds(const CRect& previous, const CRect& current);
diff --git a/chrome/views/button.cc b/chrome/views/button.cc
index 5489841..0cc98ae 100644
--- a/chrome/views/button.cc
+++ b/chrome/views/button.cc
@@ -57,14 +57,10 @@ void Button::SetImageAlignment(HorizontalAlignment h_align,
SchedulePaint();
}
-void Button::GetPreferredSize(CSize *result) {
- if (!images_[BS_NORMAL].isNull()) {
- result->cx = images_[BS_NORMAL].width();
- result->cy = images_[BS_NORMAL].height();
- } else {
- result->cx = kDefaultWidth;
- result->cy = kDefaultHeight;
- }
+gfx::Size Button::GetPreferredSize() {
+ if (!images_[BS_NORMAL].isNull())
+ return gfx::Size(images_[BS_NORMAL].width(), images_[BS_NORMAL].height());
+ return gfx::Size(kDefaultWidth, kDefaultHeight);
}
// Set the tooltip text for this button.
diff --git a/chrome/views/button.h b/chrome/views/button.h
index ed404e9..77e4930 100644
--- a/chrome/views/button.h
+++ b/chrome/views/button.h
@@ -43,7 +43,7 @@ class Button : public BaseButton {
//
// Computes the minimum size given the current theme and graphics
- void GetPreferredSize(CSize *result);
+ gfx::Size GetPreferredSize();
// Returns the MSAA default action of the current view. The string returned
// describes the default action that will occur when executing
diff --git a/chrome/views/checkbox.cc b/chrome/views/checkbox.cc
index 0b59e9c..ebfa179 100644
--- a/chrome/views/checkbox.cc
+++ b/chrome/views/checkbox.cc
@@ -71,14 +71,13 @@ void CheckBox::Layout() {
}
void CheckBox::ComputeTextRect(gfx::Rect* out) {
- CSize s;
- label_->GetPreferredSize(&s);
+ gfx::Size s = label_->GetPreferredSize();
out->set_x(GetTextIndent());
out->set_y(kFocusPaddingVertical);
int new_width = std::min(width() - (kCheckBoxWidth + kCheckBoxToLabel),
- static_cast<int>(s.cx));
+ s.width());
out->set_width(std::max(0, new_width));
- out->set_height(s.cy);
+ out->set_height(s.height());
}
void CheckBox::Paint(ChromeCanvas* canvas) {
@@ -119,11 +118,12 @@ void CheckBox::ConfigureNativeButton(HWND hwnd) {
label_->SetText(GetLabel());
}
-void CheckBox::GetPreferredSize(CSize *out) {
- label_->GetPreferredSize(out);
- out->cy = std::max(static_cast<int>(out->cy + kFocusPaddingVertical * 2),
- kCheckBoxHeight);
- out->cx += GetTextIndent() * 2;
+gfx::Size CheckBox::GetPreferredSize() {
+ gfx::Size prefsize = label_->GetPreferredSize();
+ prefsize.set_height(std::max(prefsize.height() + kFocusPaddingVertical * 2,
+ kCheckBoxHeight));
+ prefsize.Enlarge(GetTextIndent() * 2, 0);
+ return prefsize;
}
LRESULT CheckBox::OnCommand(UINT code, int id, HWND source) {
diff --git a/chrome/views/checkbox.h b/chrome/views/checkbox.h
index 7fb49b7..ce4f492 100644
--- a/chrome/views/checkbox.h
+++ b/chrome/views/checkbox.h
@@ -46,7 +46,7 @@ class CheckBox : public NativeButton {
virtual std::string GetClassName() const;
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
virtual void Layout();
virtual bool OnMousePressed(const MouseEvent& event);
diff --git a/chrome/views/chrome_menu.cc b/chrome/views/chrome_menu.cc
index a343efa..0b0d4ff 100644
--- a/chrome/views/chrome_menu.cc
+++ b/chrome/views/chrome_menu.cc
@@ -25,6 +25,9 @@
#include "chrome/views/root_view.h"
#include "generated_resources.h"
+#undef min
+#undef max
+
// Margins between the top of the item and the label.
static const int kItemTopMargin = 3;
@@ -95,7 +98,7 @@ static bool render_gutter = false;
// Max width of a menu. There does not appear to be an OS value for this, yet
// both IE and FF restrict the max width of a menu.
-static const LONG kMaxMenuWidth = 400;
+static const int kMaxMenuWidth = 400;
// Period of the scroll timer (in milliseconds).
static const int kScrollTimerMS = 30;
@@ -167,11 +170,9 @@ void UpdateMenuPartSizes() {
ReleaseDC(NULL, dc);
- CSize pref;
MenuItemView menu_item(NULL);
menu_item.SetTitle(L"blah"); // Text doesn't matter here.
- menu_item.GetPreferredSize(&pref);
- pref_menu_height = pref.cy;
+ pref_menu_height = menu_item.GetPreferredSize().height();
}
namespace {
@@ -279,9 +280,8 @@ class MenuScrollButton : public View {
pref_height_(pref_menu_height) {
}
- virtual void GetPreferredSize(CSize* out) {
- out->cx = kScrollArrowHeight * 2 - 1;
- out->cy = pref_height_;
+ virtual gfx::Size GetPreferredSize() {
+ return gfx::Size(kScrollArrowHeight * 2 - 1, pref_height_);
}
virtual bool CanDrop(const OSExchangeData& data) {
@@ -367,10 +367,9 @@ class MenuScrollView : public View {
View* child = GetContents();
// Convert y to view's coordinates.
y -= child->y();
- CSize pref;
- child->GetPreferredSize(&pref);
+ gfx::Size pref = child->GetPreferredSize();
// Constrain y to make sure we don't show past the bottom of the view.
- y = std::max(0, std::min(static_cast<int>(pref.cy) - this->height(), y));
+ y = std::max(0, std::min(pref.height() - this->height(), y));
child->SetY(-y);
}
@@ -428,34 +427,32 @@ class MenuScrollViewContainer : public View {
return;
}
- CSize pref;
- scroll_up_button_->GetPreferredSize(&pref);
- scroll_up_button_->SetBounds(x, y, width, pref.cy);
- content_height -= pref.cy;
+ gfx::Size pref = scroll_up_button_->GetPreferredSize();
+ scroll_up_button_->SetBounds(x, y, width, pref.height());
+ content_height -= pref.height();
- const int scroll_view_y = y + pref.cy;
+ const int scroll_view_y = y + pref.height();
- scroll_down_button_->GetPreferredSize(&pref);
- scroll_down_button_->SetBounds(x, height() - pref.cy - insets.top(),
- width, pref.cy);
- content_height -= pref.cy;
+ pref = scroll_down_button_->GetPreferredSize();
+ scroll_down_button_->SetBounds(x, height() - pref.height() - insets.top(),
+ width, pref.height());
+ content_height -= pref.height();
scroll_view_->SetBounds(x, scroll_view_y, width, content_height);
scroll_view_->Layout();
}
virtual void DidChangeBounds(const CRect& previous, const CRect& current) {
- CSize content_pref;
- scroll_view_->GetContents()->GetPreferredSize(&content_pref);
- scroll_up_button_->SetVisible(content_pref.cy > height());
- scroll_down_button_->SetVisible(content_pref.cy > height());
+ gfx::Size content_pref = scroll_view_->GetContents()->GetPreferredSize();
+ scroll_up_button_->SetVisible(content_pref.height() > height());
+ scroll_down_button_->SetVisible(content_pref.height() > height());
}
- virtual void GetPreferredSize(CSize* out) {
- scroll_view_->GetContents()->GetPreferredSize(out);
+ virtual gfx::Size GetPreferredSize() {
+ gfx::Size prefsize = scroll_view_->GetContents()->GetPreferredSize();
gfx::Insets insets = GetInsets();
- out->cx += insets.width();
- out->cy += insets.height();
+ prefsize.Enlarge(insets.width(), insets.height());
+ return prefsize;
}
private:
@@ -500,9 +497,9 @@ class MenuSeparator : public View {
canvas->endPlatformPaint();
}
- void GetPreferredSize(CSize* out) {
- out->cx = 10; // Just in case we're the only item in a menu.
- out->cy = separator_height;
+ gfx::Size GetPreferredSize() {
+ return gfx::Size(10, // Just in case we're the only item in a menu.
+ separator_height);
}
private:
@@ -802,9 +799,7 @@ void SubmenuView::Layout() {
View* parent = GetParent();
if (!parent)
return;
- CSize pref;
- GetPreferredSize(&pref);
- SetBounds(x(), y(), parent->width(), pref.cy);
+ SetBounds(x(), y(), parent->width(), GetPreferredSize().height());
gfx::Insets insets = GetInsets();
int x = insets.left();
@@ -812,30 +807,26 @@ void SubmenuView::Layout() {
int menu_item_width = width() - insets.width();
for (int i = 0; i < GetChildViewCount(); ++i) {
View* child = GetChildViewAt(i);
- CSize child_pref_size;
- child->GetPreferredSize(&child_pref_size);
- child->SetBounds(x, y, menu_item_width, child_pref_size.cy);
- y += child_pref_size.cy;
+ gfx::Size child_pref_size = child->GetPreferredSize();
+ child->SetBounds(x, y, menu_item_width, child_pref_size.height());
+ y += child_pref_size.height();
}
}
-void SubmenuView::GetPreferredSize(CSize* out) {
- if (GetChildViewCount() == 0) {
- out->SetSize(0, 0);
- return;
- }
+gfx::Size SubmenuView::GetPreferredSize() {
+ if (GetChildViewCount() == 0)
+ return gfx::Size();
int max_width = 0;
int height = 0;
for (int i = 0; i < GetChildViewCount(); ++i) {
View* child = GetChildViewAt(i);
- CSize child_pref_size;
- child->GetPreferredSize(&child_pref_size);
- max_width = std::max(max_width, static_cast<int>(child_pref_size.cx));
- height += child_pref_size.cy;
+ gfx::Size child_pref_size = child->GetPreferredSize();
+ max_width = std::max(max_width, child_pref_size.width());
+ height += child_pref_size.height();
}
gfx::Insets insets = GetInsets();
- out->SetSize(max_width + insets.width(), height + insets.height());
+ return gfx::Size(max_width + insets.width(), height + insets.height());
}
void SubmenuView::DidChangeBounds(const CRect& previous, const CRect& current) {
@@ -1165,9 +1156,10 @@ void MenuItemView::Paint(ChromeCanvas* canvas) {
Paint(canvas, false);
}
-void MenuItemView::GetPreferredSize(CSize* out) {
- out->cx = font_.GetStringWidth(title_) + label_start + item_right_margin;
- out->cy = font_.height() + kItemBottomMargin + kItemTopMargin;
+gfx::Size MenuItemView::GetPreferredSize() {
+ return gfx::Size(
+ font_.GetStringWidth(title_) + label_start + item_right_margin,
+ font_.height() + kItemBottomMargin + kItemTopMargin);
}
MenuController* MenuItemView::GetMenuController() {
@@ -2415,15 +2407,13 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item,
SubmenuView* submenu = item->GetSubmenu();
DCHECK(submenu);
- CSize pref;
- submenu->GetScrollViewContainer()->GetPreferredSize(&pref);
+ gfx::Size pref = submenu->GetScrollViewContainer()->GetPreferredSize();
// Don't let the menu go to wide. This is some where between what IE and FF
// do.
- pref.cx = std::min(pref.cx, kMaxMenuWidth);
+ pref.set_width(std::min(pref.width(), kMaxMenuWidth));
if (!state_.monitor_bounds.IsEmpty())
- pref.cx = std::min(pref.cx,
- static_cast<LONG>(state_.monitor_bounds.width()));
+ pref.set_width(std::min(pref.width(), state_.monitor_bounds.width()));
// Assume we can honor prefer_leading.
*is_leading = prefer_leading;
@@ -2435,21 +2425,21 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item,
x = state_.initial_bounds.x();
y = state_.initial_bounds.bottom();
if (state_.anchor == MenuItemView::TOPRIGHT)
- x = x + state_.initial_bounds.width() - pref.cx;
+ x = x + state_.initial_bounds.width() - pref.width();
if (!state_.monitor_bounds.IsEmpty() &&
- y + pref.cy > state_.monitor_bounds.bottom()) {
+ y + pref.height() > state_.monitor_bounds.bottom()) {
// The menu doesn't fit on screen. If the first location is above the
// half way point, show from the mouse location to bottom of screen.
// Otherwise show from the top of the screen to the location of the mouse.
// While odd, this behavior matches IE.
if (y < (state_.monitor_bounds.y() +
state_.monitor_bounds.height() / 2)) {
- pref.cy = std::min(pref.cy,
- static_cast<LONG>(state_.monitor_bounds.bottom() - y));
+ pref.set_height(std::min(pref.height(),
+ state_.monitor_bounds.bottom() - y));
} else {
- pref.cy = std::min(pref.cy, static_cast<LONG>(
+ pref.set_height(std::min(pref.height(),
state_.initial_bounds.y() - state_.monitor_bounds.y()));
- y = state_.initial_bounds.y() - pref.cy;
+ y = state_.initial_bounds.y() - pref.height();
}
}
} else {
@@ -2468,15 +2458,15 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item,
if (create_on_the_right) {
x = item_loc.x() + item->width() - kSubmenuHorizontalInset;
if (state_.monitor_bounds.width() != 0 &&
- x + pref.cx > state_.monitor_bounds.right()) {
+ x + pref.width() > state_.monitor_bounds.right()) {
if (layout_is_rtl)
*is_leading = true;
else
*is_leading = false;
- x = item_loc.x() - pref.cx + kSubmenuHorizontalInset;
+ x = item_loc.x() - pref.width() + kSubmenuHorizontalInset;
}
} else {
- x = item_loc.x() - pref.cx + kSubmenuHorizontalInset;
+ x = item_loc.x() - pref.width() + kSubmenuHorizontalInset;
if (state_.monitor_bounds.width() != 0 && x < state_.monitor_bounds.x()) {
if (layout_is_rtl)
*is_leading = false;
@@ -2487,22 +2477,21 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item,
}
y = item_loc.y() - kSubmenuBorderSize;
if (state_.monitor_bounds.width() != 0) {
- pref.cy = std::min(pref.cy,
- static_cast<LONG>(state_.monitor_bounds.height()));
- if (y + pref.cy > state_.monitor_bounds.bottom())
- y = state_.monitor_bounds.bottom() - pref.cy;
+ pref.set_height(std::min(pref.height(), state_.monitor_bounds.height()));
+ if (y + pref.height() > state_.monitor_bounds.bottom())
+ y = state_.monitor_bounds.bottom() - pref.height();
if (y < state_.monitor_bounds.y())
y = state_.monitor_bounds.y();
}
}
if (state_.monitor_bounds.width() != 0) {
- if (x + pref.cx > state_.monitor_bounds.right())
- x = state_.monitor_bounds.right() - pref.cx;
+ if (x + pref.width() > state_.monitor_bounds.right())
+ x = state_.monitor_bounds.right() - pref.width();
if (x < state_.monitor_bounds.x())
x = state_.monitor_bounds.x();
}
- return gfx::Rect(x, y, pref.cx, pref.cy);
+ return gfx::Rect(x, y, pref.width(), pref.height());
}
// static
diff --git a/chrome/views/chrome_menu.h b/chrome/views/chrome_menu.h
index 3e07e21..1c49188 100644
--- a/chrome/views/chrome_menu.h
+++ b/chrome/views/chrome_menu.h
@@ -358,7 +358,7 @@ class MenuItemView : public View {
virtual void Paint(ChromeCanvas* canvas);
// Returns the preferred size of this item.
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
// Returns the object responsible for controlling showing the menu.
MenuController* GetMenuController();
@@ -500,7 +500,7 @@ class SubmenuView : public View {
// Positions and sizes the child views. This tiles the views vertically,
// giving each child the available width.
virtual void Layout();
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
// View method. Overriden to schedule a paint. We do this so that when
// scrolling occurs, everything is repainted correctly.
diff --git a/chrome/views/client_view.cc b/chrome/views/client_view.cc
index ba994cd..5072acd 100644
--- a/chrome/views/client_view.cc
+++ b/chrome/views/client_view.cc
@@ -22,12 +22,12 @@ int ClientView::NonClientHitTest(const gfx::Point& point) {
///////////////////////////////////////////////////////////////////////////////
// ClientView, View overrides:
-void ClientView::GetPreferredSize(CSize* out) {
- DCHECK(out);
+gfx::Size ClientView::GetPreferredSize() {
// |contents_view_| is allowed to be NULL up until the point where this view
// is attached to a ViewContainer.
if (contents_view_)
- contents_view_->GetPreferredSize(out);
+ return contents_view_->GetPreferredSize();
+ return gfx::Size();
}
void ClientView::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
diff --git a/chrome/views/client_view.h b/chrome/views/client_view.h
index ad086f5..2d4ca51 100644
--- a/chrome/views/client_view.h
+++ b/chrome/views/client_view.h
@@ -50,7 +50,7 @@ class ClientView : public View {
virtual int NonClientHitTest(const gfx::Point& point);
// Overridden from View:
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
protected:
// Overridden from View:
diff --git a/chrome/views/combo_box.cc b/chrome/views/combo_box.cc
index f1010a5..2336ff3 100644
--- a/chrome/views/combo_box.cc
+++ b/chrome/views/combo_box.cc
@@ -30,10 +30,10 @@ void ComboBox::SetListener(Listener* listener) {
listener_ = listener;
}
-void ComboBox::GetPreferredSize(CSize* out) {
+gfx::Size ComboBox::GetPreferredSize() {
HWND hwnd = GetNativeControlHWND();
if (!hwnd)
- return;
+ return gfx::Size();
COMBOBOXINFO cbi;
memset(reinterpret_cast<unsigned char*>(&cbi), 0, sizeof(cbi));
@@ -54,12 +54,14 @@ void ComboBox::GetPreferredSize(CSize* out) {
int item_to_button_distance = std::max(kItemOffset - border.width(), 0);
// The cx computation can be read as measuring from left to right.
- out->cx = std::max(kItemOffset + content_width_ + kComboboxExtraPaddingX +
- item_to_button_distance + rect_button.width() +
- border.width(), kMinComboboxWidth);
+ int pref_width = std::max(kItemOffset + content_width_ +
+ kComboboxExtraPaddingX +
+ item_to_button_distance + rect_button.width() +
+ border.width(), kMinComboboxWidth);
// The two arguments to ::max below should be typically be equal.
- out->cy = std::max(rect_item.height() + 2 * kItemOffset,
- rect_button.height() + 2 * border.height());
+ int pref_height = std::max(rect_item.height() + 2 * kItemOffset,
+ rect_button.height() + 2 * border.height());
+ return gfx::Size(pref_width, pref_height);
}
HWND ComboBox::CreateNativeControl(HWND parent_container) {
diff --git a/chrome/views/combo_box.h b/chrome/views/combo_box.h
index 41d57cc..e4dbccb 100644
--- a/chrome/views/combo_box.h
+++ b/chrome/views/combo_box.h
@@ -41,7 +41,7 @@ class ComboBox : public NativeControl {
void SetListener(Listener* listener);
// Overriden from View.
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
// Overriden from NativeControl
virtual HWND CreateNativeControl(HWND parent_container);
diff --git a/chrome/views/custom_frame_window.cc b/chrome/views/custom_frame_window.cc
index ebd705f..046210a 100644
--- a/chrome/views/custom_frame_window.cc
+++ b/chrome/views/custom_frame_window.cc
@@ -244,7 +244,7 @@ class DefaultNonClientView : public NonClientView,
// View overrides:
virtual void Paint(ChromeCanvas* canvas);
virtual void Layout();
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
// BaseButton::ButtonListener implementation:
@@ -515,11 +515,11 @@ void DefaultNonClientView::Layout() {
SchedulePaint();
}
-void DefaultNonClientView::GetPreferredSize(CSize* out) {
- DCHECK(out);
- container_->client_view()->GetPreferredSize(out);
- out->cx += 2 * kWindowHorizontalBorderSize;
- out->cy += CalculateContentsTop() + kWindowVerticalBorderSize;
+gfx::Size DefaultNonClientView::GetPreferredSize() {
+ gfx::Size prefsize = container_->client_view()->GetPreferredSize();
+ prefsize.Enlarge(2 * kWindowHorizontalBorderSize,
+ CalculateContentsTop() + kWindowVerticalBorderSize);
+ return prefsize;
}
void DefaultNonClientView::ViewHierarchyChanged(bool is_add,
@@ -659,59 +659,65 @@ void DefaultNonClientView::PaintClientEdge(ChromeCanvas* canvas) {
}
void DefaultNonClientView::LayoutWindowControls() {
- CSize ps;
+ gfx::Size ps;
if (container_->IsMaximized() || container_->IsMinimized()) {
maximize_button_->SetVisible(false);
restore_button_->SetVisible(true);
}
if (container_->IsMaximized()) {
- close_button_->GetPreferredSize(&ps);
+ ps = close_button_->GetPreferredSize();
close_button_->SetImageAlignment(Button::ALIGN_LEFT, Button::ALIGN_BOTTOM);
close_button_->SetBounds(
- width() - ps.cx - kWindowControlsRightZoomedOffset,
- 0, ps.cx + kWindowControlsRightZoomedOffset,
- ps.cy + kWindowControlsTopZoomedOffset);
+ width() - ps.width() - kWindowControlsRightZoomedOffset,
+ 0, ps.width() + kWindowControlsRightZoomedOffset,
+ ps.height() + kWindowControlsTopZoomedOffset);
if (should_show_minmax_buttons_) {
- restore_button_->GetPreferredSize(&ps);
+ ps = restore_button_->GetPreferredSize();
restore_button_->SetImageAlignment(Button::ALIGN_LEFT,
Button::ALIGN_BOTTOM);
- restore_button_->SetBounds(close_button_->x() - ps.cx, 0, ps.cx,
- ps.cy + kWindowControlsTopZoomedOffset);
+ restore_button_->SetBounds(close_button_->x() - ps.width(), 0,
+ ps.width(),
+ ps.height() + kWindowControlsTopZoomedOffset);
- minimize_button_->GetPreferredSize(&ps);
+ ps = minimize_button_->GetPreferredSize();
minimize_button_->SetImageAlignment(Button::ALIGN_LEFT,
Button::ALIGN_BOTTOM);
- minimize_button_->SetBounds(restore_button_->x() - ps.cx, 0, ps.cx,
- ps.cy + kWindowControlsTopZoomedOffset);
+ minimize_button_->SetBounds(restore_button_->x() - ps.width(), 0,
+ ps.width(),
+ ps.height() + kWindowControlsTopZoomedOffset);
}
} else if (container_->IsMinimized()) {
- close_button_->GetPreferredSize(&ps);
+ ps = close_button_->GetPreferredSize();
close_button_->SetImageAlignment(Button::ALIGN_LEFT, Button::ALIGN_BOTTOM);
close_button_->SetBounds(
- width() - ps.cx - kWindowControlsRightZoomedOffset,
- 0, ps.cx + kWindowControlsRightZoomedOffset,
- ps.cy + kWindowControlsTopZoomedOffset);
+ width() - ps.width() - kWindowControlsRightZoomedOffset,
+ 0, ps.width() + kWindowControlsRightZoomedOffset,
+ ps.height() + kWindowControlsTopZoomedOffset);
if (should_show_minmax_buttons_) {
- restore_button_->GetPreferredSize(&ps);
+ ps = restore_button_->GetPreferredSize();
restore_button_->SetImageAlignment(Button::ALIGN_LEFT,
Button::ALIGN_BOTTOM);
- restore_button_->SetBounds(close_button_->x() - ps.cx, 0, ps.cx,
- ps.cy + kWindowControlsTopZoomedOffset);
+ restore_button_->SetBounds(close_button_->x() - ps.width(), 0,
+ ps.width(),
+ ps.height() + kWindowControlsTopZoomedOffset);
- minimize_button_->GetPreferredSize(&ps);
+ ps = minimize_button_->GetPreferredSize();
minimize_button_->SetImageAlignment(Button::ALIGN_LEFT,
Button::ALIGN_BOTTOM);
- minimize_button_->SetBounds(restore_button_->x() - ps.cx, 0, ps.cx,
- ps.cy + kWindowControlsTopZoomedOffset);
+ minimize_button_->SetBounds(restore_button_->x() - ps.width(), 0,
+ ps.width(),
+ ps.height() +
+ kWindowControlsTopZoomedOffset);
}
} else {
- close_button_->GetPreferredSize(&ps);
+ ps = close_button_->GetPreferredSize();
close_button_->SetImageAlignment(Button::ALIGN_LEFT, Button::ALIGN_TOP);
- close_button_->SetBounds(width() - kWindowControlsRightOffset - ps.cx,
- kWindowControlsTopOffset, ps.cx, ps.cy);
+ close_button_->SetBounds(width() - kWindowControlsRightOffset - ps.width(),
+ kWindowControlsTopOffset, ps.width(),
+ ps.height());
if (should_show_minmax_buttons_) {
close_button_->SetImage(
@@ -727,17 +733,19 @@ void DefaultNonClientView::LayoutWindowControls() {
restore_button_->SetVisible(false);
maximize_button_->SetVisible(true);
- maximize_button_->GetPreferredSize(&ps);
+ ps = maximize_button_->GetPreferredSize();
maximize_button_->SetImageAlignment(Button::ALIGN_LEFT,
Button::ALIGN_TOP);
- maximize_button_->SetBounds(close_button_->x() - ps.cx,
- kWindowControlsTopOffset, ps.cx, ps.cy);
+ maximize_button_->SetBounds(close_button_->x() - ps.width(),
+ kWindowControlsTopOffset, ps.width(),
+ ps.height());
- minimize_button_->GetPreferredSize(&ps);
+ ps = minimize_button_->GetPreferredSize();
minimize_button_->SetImageAlignment(Button::ALIGN_LEFT,
Button::ALIGN_TOP);
- minimize_button_->SetBounds(maximize_button_->x() - ps.cx,
- kWindowControlsTopOffset, ps.cx, ps.cy);
+ minimize_button_->SetBounds(maximize_button_->x() - ps.width(),
+ kWindowControlsTopOffset, ps.width(),
+ ps.height());
}
}
if (!should_show_minmax_buttons_) {
@@ -764,10 +772,10 @@ void DefaultNonClientView::LayoutTitleBar() {
// Size the window icon, if visible.
if (d->ShouldShowWindowIcon()) {
system_menu_button_->SetVisible(true);
- CSize ps;
- system_menu_button_->GetPreferredSize(&ps);
+ gfx::Size ps = system_menu_button_->GetPreferredSize();
system_menu_button_->SetBounds(
- kWindowIconLeftOffset, kWindowIconTopOffset + top_offset, ps.cx, ps.cy);
+ kWindowIconLeftOffset, kWindowIconTopOffset + top_offset, ps.width(),
+ ps.height());
} else {
// Put the menu in the right place at least even if it is hidden so we
// can size the title based on its position.
@@ -856,8 +864,8 @@ class NonClientViewLayout : public ChromeViews::LayoutManager {
host->width() - (2 * horizontal_border_width),
host->height() - (2 * vertical_border_height));
}
- virtual void GetPreferredSize(ChromeViews::View* host, CSize* out) {
- child_->GetPreferredSize(out);
+ virtual gfx::Size GetPreferredSize(ChromeViews::View* host) {
+ return child_->GetPreferredSize();
}
private:
@@ -952,11 +960,11 @@ void CustomFrameWindow::DisableInactiveRendering(bool disable) {
}
void CustomFrameWindow::SizeWindowToDefault() {
- CSize pref(0, 0);
- client_view()->GetPreferredSize(&pref);
- DCHECK(pref.cx > 0 && pref.cy > 0);
+ gfx::Size pref = client_view()->GetPreferredSize();
+ DCHECK(pref.width() > 0 && pref.height() > 0);
gfx::Size window_size =
- non_client_view_->CalculateWindowSizeForClientSize(pref.cx, pref.cy);
+ non_client_view_->CalculateWindowSizeForClientSize(pref.width(),
+ pref.height());
win_util::CenterAndSizeWindow(owning_window(), GetHWND(),
window_size.ToSIZE(), false);
}
diff --git a/chrome/views/decision.cc b/chrome/views/decision.cc
index a6d4f38..e6c57b4 100644
--- a/chrome/views/decision.cc
+++ b/chrome/views/decision.cc
@@ -80,50 +80,47 @@ void Decision::Layout() {
int width = lb.Width();
CPoint position(lb.TopLeft());
- CSize size;
- title_label_->GetPreferredSize(&size);
- title_label_->SetBounds(position.x, position.y, width, size.cy);
- position.y += size.cy + kSpacingInfoBottom;
+ gfx::Size size = title_label_->GetPreferredSize();
+ title_label_->SetBounds(position.x, position.y, width, size.height());
+ position.y += size.height() + kSpacingInfoBottom;
- size.cy = details_label_->GetHeightForWidth(width);
- details_label_->SetBounds(position.x, position.y, width, size.cy);
- position.y += size.cy + kSpacingInfoBottom;
+ size.set_height(details_label_->GetHeightForWidth(width));
+ details_label_->SetBounds(position.x, position.y, width, size.height());
+ position.y += size.height() + kSpacingInfoBottom;
for (std::vector<Option*>::const_iterator iter = options_.begin();
iter != options_.end(); ++iter) {
Option* option = *iter;
- option->GetPreferredSize(&size);
- option->SetBounds(position.x, position.y, width, size.cy);
+ size = option->GetPreferredSize();
+ option->SetBounds(position.x, position.y, width, size.height());
option->Layout();
- position.y += size.cy + kSpacingInfoBottom;
+ position.y += size.height() + kSpacingInfoBottom;
}
}
-void Decision::GetPreferredSize(CSize *out) {
+gfx::Size Decision::GetPreferredSize() {
int width = 0;
int height = 0;
// We need to find the largest width from the title and the options, as the
// details label is multi-line and we need to known its width in order to
// compute its height.
- CSize size;
- title_label_->GetPreferredSize(&size);
- width = size.cx;
- height = size.cy + kSpacingInfoBottom;
+ gfx::Size size = title_label_->GetPreferredSize();
+ width = size.width();
+ height = size.height() + kSpacingInfoBottom;
for (std::vector<Option*>::const_iterator iter = options_.begin();
iter != options_.end(); ++iter) {
- (*iter)->GetPreferredSize(&size);
- if (size.cx > width)
- width = size.cx;
- height += size.cy + kSpacingInfoBottom;
+ size = (*iter)->GetPreferredSize();
+ if (size.width() > width)
+ width = size.width();
+ height += size.height() + kSpacingInfoBottom;
}
// Now we can compute the details label height.
height += details_label_->GetHeightForWidth(width) + kSpacingInfoBottom;
- out->cx = width + 2 * kPaddingEdge;
- out->cy = height + 2 * kPaddingEdge;
+ return gfx::Size(width + 2 * kPaddingEdge, height + 2 * kPaddingEdge);
}
Option::Option(int command_id,
diff --git a/chrome/views/decision.h b/chrome/views/decision.h
index 65924ae..007d0f3 100644
--- a/chrome/views/decision.h
+++ b/chrome/views/decision.h
@@ -42,7 +42,7 @@ class Decision : public View {
// Overridden from View for custom layout.
virtual void Layout();
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
protected:
// Override to call Layout().
diff --git a/chrome/views/dialog_client_view.cc b/chrome/views/dialog_client_view.cc
index be30759..2435644 100644
--- a/chrome/views/dialog_client_view.cc
+++ b/chrome/views/dialog_client_view.cc
@@ -238,9 +238,8 @@ void DialogClientView::DidChangeBounds(const CRect& prev, const CRect& next) {
Layout();
}
-void DialogClientView::GetPreferredSize(CSize* out) {
- DCHECK(out);
- contents_view()->GetPreferredSize(out);
+gfx::Size DialogClientView::GetPreferredSize() {
+ gfx::Size prefsize = contents_view()->GetPreferredSize();
int button_height = 0;
if (has_dialog_buttons()) {
if (cancel_button_)
@@ -250,7 +249,8 @@ void DialogClientView::GetPreferredSize(CSize* out) {
// Account for padding above and below the button.
button_height += kDialogButtonContentSpacing + kButtonVEdgeMargin;
}
- out->cy += button_height;
+ prefsize.Enlarge(0, button_height);
+ return prefsize;
}
bool DialogClientView::AcceleratorPressed(const Accelerator& accelerator) {
@@ -320,24 +320,22 @@ int DialogClientView::GetButtonsHeight() const {
void DialogClientView::LayoutDialogButtons() {
CRect extra_bounds;
if (cancel_button_) {
- CSize ps;
- cancel_button_->GetPreferredSize(&ps);
+ gfx::Size ps = cancel_button_->GetPreferredSize();
CRect lb;
GetLocalBounds(&lb, false);
int button_width = GetButtonWidth(DialogDelegate::DIALOGBUTTON_CANCEL);
CRect bounds;
bounds.left = lb.right - button_width - kButtonHEdgeMargin;
- bounds.top = lb.bottom - ps.cy - kButtonVEdgeMargin;
+ bounds.top = lb.bottom - ps.height() - kButtonVEdgeMargin;
bounds.right = bounds.left + button_width;
- bounds.bottom = bounds.top + ps.cy;
+ bounds.bottom = bounds.top + ps.height();
cancel_button_->SetBounds(bounds);
// The extra view bounds are dependent on this button.
extra_bounds.right = bounds.left;
extra_bounds.top = bounds.top;
}
if (ok_button_) {
- CSize ps;
- ok_button_->GetPreferredSize(&ps);
+ gfx::Size ps = ok_button_->GetPreferredSize();
CRect lb;
GetLocalBounds(&lb, false);
int button_width = GetButtonWidth(DialogDelegate::DIALOGBUTTON_OK);
@@ -346,21 +344,20 @@ void DialogClientView::LayoutDialogButtons() {
ok_button_right = cancel_button_->x() - kRelatedButtonHSpacing;
CRect bounds;
bounds.left = ok_button_right - button_width;
- bounds.top = lb.bottom - ps.cy - kButtonVEdgeMargin;
+ bounds.top = lb.bottom - ps.height() - kButtonVEdgeMargin;
bounds.right = ok_button_right;
- bounds.bottom = bounds.top + ps.cy;
+ bounds.bottom = bounds.top + ps.height();
ok_button_->SetBounds(bounds);
// The extra view bounds are dependent on this button.
extra_bounds.right = bounds.left;
extra_bounds.top = bounds.top;
}
if (extra_view_) {
- CSize ps;
- extra_view_->GetPreferredSize(&ps);
+ gfx::Size ps = extra_view_->GetPreferredSize();
CRect lb;
GetLocalBounds(&lb, false);
extra_bounds.left = lb.left + kButtonHEdgeMargin;
- extra_bounds.bottom = extra_bounds.top + ps.cy;
+ extra_bounds.bottom = extra_bounds.top + ps.height();
extra_view_->SetBounds(extra_bounds);
}
}
diff --git a/chrome/views/dialog_client_view.h b/chrome/views/dialog_client_view.h
index 087ba32..b398823 100644
--- a/chrome/views/dialog_client_view.h
+++ b/chrome/views/dialog_client_view.h
@@ -59,7 +59,7 @@ class DialogClientView : public ClientView,
virtual void Layout();
virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
virtual void DidChangeBounds(const CRect& prev, const CRect& next);
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
virtual bool AcceleratorPressed(const Accelerator& accelerator);
// NativeButton::Listener implementation:
diff --git a/chrome/views/grid_layout.cc b/chrome/views/grid_layout.cc
index e0c7257..806d7fc 100644
--- a/chrome/views/grid_layout.cc
+++ b/chrome/views/grid_layout.cc
@@ -571,21 +571,20 @@ void ColumnSet::ResetColumnXCoordinates() {
}
void ColumnSet::CalculateSize() {
- CSize pref;
+ gfx::Size pref;
// Reset the preferred and remaining sizes.
for (std::vector<ViewState*>::iterator i = view_states_.begin();
i != view_states_.end(); ++i) {
ViewState* view_state = *i;
- pref.cx = pref.cy = 0;
if (!view_state->pref_width_fixed || !view_state->pref_height_fixed) {
- view_state->view->GetPreferredSize(&pref);
+ pref = view_state->view->GetPreferredSize();
if (!view_state->pref_width_fixed)
- view_state->pref_width = pref.cx;
+ view_state->pref_width = pref.width();
if (!view_state->pref_height_fixed)
- view_state->pref_height = pref.cy;
+ view_state->pref_height = pref.height();
}
- view_state->remaining_width = pref.cx;
- view_state->remaining_height = pref.cy;
+ view_state->remaining_width = pref.width();
+ view_state->remaining_height = pref.height();
}
// Let layout element reset the sizes for us.
@@ -789,9 +788,11 @@ void GridLayout::Layout(View* host) {
}
}
-void GridLayout::GetPreferredSize(View* host, CSize* out) {
+gfx::Size GridLayout::GetPreferredSize(View* host) {
DCHECK(host_ == host);
- SizeRowsAndColumns(false, 0, 0, out);
+ CSize out;
+ SizeRowsAndColumns(false, 0, 0, &out);
+ return gfx::Size(out.cx, out.cy);
}
int GridLayout::GetPreferredHeightForWidth(View* host, int width) {
diff --git a/chrome/views/grid_layout.h b/chrome/views/grid_layout.h
index 8274483..68df24c 100644
--- a/chrome/views/grid_layout.h
+++ b/chrome/views/grid_layout.h
@@ -165,7 +165,7 @@ class GridLayout : public LayoutManager {
virtual void Layout(View* host);
// Returns the preferred size for the GridLayout.
- virtual void GetPreferredSize(View* host, CSize* out);
+ virtual gfx::Size GetPreferredSize(View* host);
virtual int GetPreferredHeightForWidth(View* host, int width);
diff --git a/chrome/views/grid_layout_unittest.cc b/chrome/views/grid_layout_unittest.cc
index 4abfced..827e16f 100644
--- a/chrome/views/grid_layout_unittest.cc
+++ b/chrome/views/grid_layout_unittest.cc
@@ -21,16 +21,16 @@ static void ExpectViewBoundsEquals(int x, int y, int w, int h,
class SettableSizeView : public View {
public:
- explicit SettableSizeView(const CSize& pref) {
+ explicit SettableSizeView(const gfx::Size& pref) {
pref_ = pref;
}
- virtual void GetPreferredSize(CSize *out) {
- *out = pref_;
+ virtual gfx::Size GetPreferredSize() {
+ return pref_;
}
private:
- CSize pref_;
+ gfx::Size pref_;
};
class GridLayoutTest : public testing::Test {
@@ -50,10 +50,10 @@ class GridLayoutTest : public testing::Test {
}
void GetPreferredSize() {
- layout->GetPreferredSize(&host, &pref);
+ pref = layout->GetPreferredSize(&host);
}
- CSize pref;
+ gfx::Size pref;
CRect bounds;
View host;
GridLayout* layout;
@@ -63,7 +63,7 @@ class GridLayoutAlignmentTest : public testing::Test {
public:
GridLayoutAlignmentTest() :
host(),
- v1(CSize(10, 20)),
+ v1(gfx::Size(10, 20)),
layout(new GridLayout(&host)) {}
virtual void SetUp() {
@@ -84,9 +84,8 @@ class GridLayoutAlignmentTest : public testing::Test {
c1->AddColumn(alignment, alignment, 1, GridLayout::USE_PREF, 0, 0);
layout->StartRow(1, 0);
layout->AddView(&v1);
- CSize pref;
- layout->GetPreferredSize(&host, &pref);
- EXPECT_TRUE(CSize(10, 20) == pref);
+ gfx::Size pref = layout->GetPreferredSize(&host);
+ EXPECT_TRUE(gfx::Size(10, 20) == pref);
host.SetBounds(0, 0, 100, 100);
layout->Layout(&host);
*bounds = v1.bounds().ToRECT();
@@ -123,8 +122,8 @@ TEST_F(GridLayoutAlignmentTest, Trailing) {
}
TEST_F(GridLayoutTest, TwoColumns) {
- SettableSizeView v1(CSize(10, 20));
- SettableSizeView v2(CSize(20, 20));
+ SettableSizeView v1(gfx::Size(10, 20));
+ SettableSizeView v2(gfx::Size(20, 20));
ColumnSet* c1 = layout->AddColumnSet(0);
c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
0, GridLayout::USE_PREF, 0, 0);
@@ -135,9 +134,9 @@ TEST_F(GridLayoutTest, TwoColumns) {
layout->AddView(&v2);
GetPreferredSize();
- EXPECT_TRUE(CSize(30, 20) == pref);
+ EXPECT_TRUE(gfx::Size(30, 20) == pref);
- host.SetBounds(0, 0, pref.cx, pref.cy);
+ host.SetBounds(0, 0, pref.width(), pref.height());
layout->Layout(&host);
ExpectViewBoundsEquals(0, 0, 10, 20, &v1);
ExpectViewBoundsEquals(10, 0, 20, 20, &v2);
@@ -146,8 +145,8 @@ TEST_F(GridLayoutTest, TwoColumns) {
}
TEST_F(GridLayoutTest, ColSpan1) {
- SettableSizeView v1(CSize(100, 20));
- SettableSizeView v2(CSize(10, 40));
+ SettableSizeView v1(gfx::Size(100, 20));
+ SettableSizeView v2(gfx::Size(10, 40));
ColumnSet* c1 = layout->AddColumnSet(0);
c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
0, GridLayout::USE_PREF, 0, 0);
@@ -159,9 +158,9 @@ TEST_F(GridLayoutTest, ColSpan1) {
layout->AddView(&v2);
GetPreferredSize();
- EXPECT_TRUE(CSize(100, 60) == pref);
+ EXPECT_TRUE(gfx::Size(100, 60) == pref);
- host.SetBounds(0, 0, pref.cx, pref.cy);
+ host.SetBounds(0, 0, pref.width(), pref.height());
layout->Layout(&host);
ExpectViewBoundsEquals(0, 0, 100, 20, &v1);
ExpectViewBoundsEquals(0, 20, 10, 40, &v2);
@@ -170,8 +169,8 @@ TEST_F(GridLayoutTest, ColSpan1) {
}
TEST_F(GridLayoutTest, ColSpan2) {
- SettableSizeView v1(CSize(100, 20));
- SettableSizeView v2(CSize(10, 20));
+ SettableSizeView v1(gfx::Size(100, 20));
+ SettableSizeView v2(gfx::Size(10, 20));
ColumnSet* c1 = layout->AddColumnSet(0);
c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
1, GridLayout::USE_PREF, 0, 0);
@@ -184,9 +183,9 @@ TEST_F(GridLayoutTest, ColSpan2) {
layout->AddView(&v2);
GetPreferredSize();
- EXPECT_TRUE(CSize(100, 40) == pref);
+ EXPECT_TRUE(gfx::Size(100, 40) == pref);
- host.SetBounds(0, 0, pref.cx, pref.cy);
+ host.SetBounds(0, 0, pref.width(), pref.height());
layout->Layout(&host);
ExpectViewBoundsEquals(0, 0, 100, 20, &v1);
ExpectViewBoundsEquals(90, 20, 10, 20, &v2);
@@ -195,9 +194,9 @@ TEST_F(GridLayoutTest, ColSpan2) {
}
TEST_F(GridLayoutTest, ColSpan3) {
- SettableSizeView v1(CSize(100, 20));
- SettableSizeView v2(CSize(10, 20));
- SettableSizeView v3(CSize(10, 20));
+ SettableSizeView v1(gfx::Size(100, 20));
+ SettableSizeView v2(gfx::Size(10, 20));
+ SettableSizeView v3(gfx::Size(10, 20));
ColumnSet* c1 = layout->AddColumnSet(0);
c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
0, GridLayout::USE_PREF, 0, 0);
@@ -210,9 +209,9 @@ TEST_F(GridLayoutTest, ColSpan3) {
layout->AddView(&v3);
GetPreferredSize();
- EXPECT_TRUE(CSize(100, 40) == pref);
+ EXPECT_TRUE(gfx::Size(100, 40) == pref);
- host.SetBounds(0, 0, pref.cx, pref.cy);
+ host.SetBounds(0, 0, pref.width(), pref.height());
layout->Layout(&host);
ExpectViewBoundsEquals(0, 0, 100, 20, &v1);
ExpectViewBoundsEquals(0, 20, 10, 20, &v2);
@@ -230,9 +229,9 @@ TEST_F(GridLayoutTest, ColSpan4) {
set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
GridLayout::USE_PREF, 0, 0);
- SettableSizeView v1(CSize(10, 10));
- SettableSizeView v2(CSize(10, 10));
- SettableSizeView v3(CSize(25, 20));
+ SettableSizeView v1(gfx::Size(10, 10));
+ SettableSizeView v2(gfx::Size(10, 10));
+ SettableSizeView v3(gfx::Size(25, 20));
layout->StartRow(0, 0);
layout->AddView(&v1);
layout->AddView(&v2);
@@ -240,9 +239,9 @@ TEST_F(GridLayoutTest, ColSpan4) {
layout->AddView(&v3, 2, 1);
GetPreferredSize();
- EXPECT_TRUE(CSize(25, 30) == pref);
+ EXPECT_TRUE(gfx::Size(25, 30) == pref);
- host.SetBounds(0, 0, pref.cx, pref.cy);
+ host.SetBounds(0, 0, pref.width(), pref.height());
layout->Layout(&host);
ExpectViewBoundsEquals(0, 0, 10, 10, &v1);
ExpectViewBoundsEquals(12, 0, 10, 10, &v2);
@@ -252,8 +251,8 @@ TEST_F(GridLayoutTest, ColSpan4) {
}
TEST_F(GridLayoutTest, SameSizeColumns) {
- SettableSizeView v1(CSize(50, 20));
- SettableSizeView v2(CSize(10, 10));
+ SettableSizeView v1(gfx::Size(50, 20));
+ SettableSizeView v2(gfx::Size(10, 10));
ColumnSet* c1 = layout->AddColumnSet(0);
c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
0, GridLayout::USE_PREF, 0, 0);
@@ -264,11 +263,10 @@ TEST_F(GridLayoutTest, SameSizeColumns) {
layout->AddView(&v1);
layout->AddView(&v2);
- CSize pref;
- layout->GetPreferredSize(&host, &pref);
- EXPECT_TRUE(CSize(100, 20) == pref);
+ gfx::Size pref = layout->GetPreferredSize(&host);
+ EXPECT_TRUE(gfx::Size(100, 20) == pref);
- host.SetBounds(0, 0, pref.cx, pref.cy);
+ host.SetBounds(0, 0, pref.width(), pref.height());
layout->Layout(&host);
ExpectViewBoundsEquals(0, 0, 50, 20, &v1);
ExpectViewBoundsEquals(50, 0, 10, 10, &v2);
@@ -277,8 +275,8 @@ TEST_F(GridLayoutTest, SameSizeColumns) {
}
TEST_F(GridLayoutTest, HorizontalResizeTest1) {
- SettableSizeView v1(CSize(50, 20));
- SettableSizeView v2(CSize(10, 10));
+ SettableSizeView v1(gfx::Size(50, 20));
+ SettableSizeView v2(gfx::Size(10, 10));
ColumnSet* c1 = layout->AddColumnSet(0);
c1->AddColumn(GridLayout::FILL, GridLayout::LEADING,
1, GridLayout::USE_PREF, 0, 0);
@@ -297,8 +295,8 @@ TEST_F(GridLayoutTest, HorizontalResizeTest1) {
}
TEST_F(GridLayoutTest, HorizontalResizeTest2) {
- SettableSizeView v1(CSize(50, 20));
- SettableSizeView v2(CSize(10, 10));
+ SettableSizeView v1(gfx::Size(50, 20));
+ SettableSizeView v2(gfx::Size(10, 10));
ColumnSet* c1 = layout->AddColumnSet(0);
c1->AddColumn(GridLayout::FILL, GridLayout::LEADING,
1, GridLayout::USE_PREF, 0, 0);
@@ -317,8 +315,8 @@ TEST_F(GridLayoutTest, HorizontalResizeTest2) {
}
TEST_F(GridLayoutTest, TestVerticalResize1) {
- SettableSizeView v1(CSize(50, 20));
- SettableSizeView v2(CSize(10, 10));
+ SettableSizeView v1(gfx::Size(50, 20));
+ SettableSizeView v2(gfx::Size(10, 10));
ColumnSet* c1 = layout->AddColumnSet(0);
c1->AddColumn(GridLayout::FILL, GridLayout::FILL,
1, GridLayout::USE_PREF, 0, 0);
@@ -328,7 +326,7 @@ TEST_F(GridLayoutTest, TestVerticalResize1) {
layout->AddView(&v2);
GetPreferredSize();
- EXPECT_TRUE(CSize(50, 30) == pref);
+ EXPECT_TRUE(gfx::Size(50, 30) == pref);
host.SetBounds(0, 0, 50, 100);
layout->Layout(&host);
@@ -339,7 +337,7 @@ TEST_F(GridLayoutTest, TestVerticalResize1) {
}
TEST_F(GridLayoutTest, Insets) {
- SettableSizeView v1(CSize(10, 20));
+ SettableSizeView v1(gfx::Size(10, 20));
ColumnSet* c1 = layout->AddColumnSet(0);
layout->SetInsets(1, 2, 3, 4);
c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
@@ -348,9 +346,9 @@ TEST_F(GridLayoutTest, Insets) {
layout->AddView(&v1);
GetPreferredSize();
- EXPECT_TRUE(CSize(16, 24) == pref);
+ EXPECT_TRUE(gfx::Size(16, 24) == pref);
- host.SetBounds(0, 0, pref.cx, pref.cy);
+ host.SetBounds(0, 0, pref.width(), pref.height());
layout->Layout(&host);
ExpectViewBoundsEquals(2, 1, 10, 20, &v1);
@@ -380,7 +378,7 @@ TEST_F(GridLayoutTest, FixedSize) {
for (int row = 0; row < row_count; ++row) {
layout->StartRow(0, 0);
for (int col = 0; col < column_count; ++col) {
- layout->AddView(new SettableSizeView(CSize(pref_width, pref_height)));
+ layout->AddView(new SettableSizeView(gfx::Size(pref_width, pref_height)));
}
}
@@ -396,8 +394,8 @@ TEST_F(GridLayoutTest, FixedSize) {
}
GetPreferredSize();
- EXPECT_TRUE(CSize(column_count * title_width + 4,
- row_count * pref_height + 4) == pref);
+ EXPECT_TRUE(gfx::Size(column_count * title_width + 4,
+ row_count * pref_height + 4) == pref);
}
TEST_F(GridLayoutTest, RowSpanWithPaddingRow) {
@@ -411,7 +409,7 @@ TEST_F(GridLayoutTest, RowSpanWithPaddingRow) {
10);
layout->StartRow(0, 0);
- layout->AddView(new SettableSizeView(CSize(10, 10)), 1, 2);
+ layout->AddView(new SettableSizeView(gfx::Size(10, 10)), 1, 2);
layout->AddPaddingRow(0, 10);
}
@@ -432,16 +430,16 @@ TEST_F(GridLayoutTest, RowSpan) {
0);
layout->StartRow(0, 0);
- layout->AddView(new SettableSizeView(CSize(20, 10)));
- layout->AddView(new SettableSizeView(CSize(20, 40)), 1, 2);
+ layout->AddView(new SettableSizeView(gfx::Size(20, 10)));
+ layout->AddView(new SettableSizeView(gfx::Size(20, 40)), 1, 2);
layout->StartRow(1, 0);
- ChromeViews::View* s3 = new SettableSizeView(CSize(20, 10));
+ ChromeViews::View* s3 = new SettableSizeView(gfx::Size(20, 10));
layout->AddView(s3);
GetPreferredSize();
- EXPECT_TRUE(CSize(40, 40) == pref);
+ EXPECT_TRUE(gfx::Size(40, 40) == pref);
- host.SetBounds(0, 0, pref.cx, pref.cy);
+ host.SetBounds(0, 0, pref.width(), pref.height());
layout->Layout(&host);
ExpectViewBoundsEquals(0, 10, 20, 10, s3);
}
@@ -455,19 +453,19 @@ TEST_F(GridLayoutTest, RowSpan2) {
0,GridLayout::USE_PREF, 0, 0);
layout->StartRow(0, 0);
- layout->AddView(new SettableSizeView(CSize(20, 20)));
- ChromeViews::View* s3 = new SettableSizeView(CSize(64, 64));
+ layout->AddView(new SettableSizeView(gfx::Size(20, 20)));
+ ChromeViews::View* s3 = new SettableSizeView(gfx::Size(64, 64));
layout->AddView(s3, 1, 3);
layout->AddPaddingRow(0, 10);
layout->StartRow(0, 0);
- layout->AddView(new SettableSizeView(CSize(10, 20)));
+ layout->AddView(new SettableSizeView(gfx::Size(10, 20)));
GetPreferredSize();
- EXPECT_TRUE(CSize(84, 64) == pref);
+ EXPECT_TRUE(gfx::Size(84, 64) == pref);
- host.SetBounds(0, 0, pref.cx, pref.cy);
+ host.SetBounds(0, 0, pref.width(), pref.height());
layout->Layout(&host);
ExpectViewBoundsEquals(20, 0, 64, 64, s3);
}
@@ -481,14 +479,14 @@ TEST_F(GridLayoutTest, FixedViewWidth) {
0,GridLayout::USE_PREF, 0, 0);
layout->StartRow(0, 0);
- View* view = new SettableSizeView(CSize(30, 40));
+ View* view = new SettableSizeView(gfx::Size(30, 40));
layout->AddView(view, 1, 1, GridLayout::LEADING, GridLayout::LEADING, 10, 0);
GetPreferredSize();
- EXPECT_EQ(10, pref.cx);
- EXPECT_EQ(40, pref.cy);
+ EXPECT_EQ(10, pref.width());
+ EXPECT_EQ(40, pref.height());
- host.SetBounds(0, 0, pref.cx, pref.cy);
+ host.SetBounds(0, 0, pref.width(), pref.height());
layout->Layout(&host);
ExpectViewBoundsEquals(0, 0, 10, 40, view);
}
@@ -502,14 +500,14 @@ TEST_F(GridLayoutTest, FixedViewHeight) {
0,GridLayout::USE_PREF, 0, 0);
layout->StartRow(0, 0);
- View* view = new SettableSizeView(CSize(30, 40));
+ View* view = new SettableSizeView(gfx::Size(30, 40));
layout->AddView(view, 1, 1, GridLayout::LEADING, GridLayout::LEADING, 0, 10);
GetPreferredSize();
- EXPECT_EQ(30, pref.cx);
- EXPECT_EQ(10, pref.cy);
+ EXPECT_EQ(30, pref.width());
+ EXPECT_EQ(10, pref.height());
- host.SetBounds(0, 0, pref.cx, pref.cy);
+ host.SetBounds(0, 0, pref.width(), pref.height());
layout->Layout(&host);
ExpectViewBoundsEquals(0, 0, 30, 10, view);
}
diff --git a/chrome/views/hwnd_view.cc b/chrome/views/hwnd_view.cc
index c163704..3550278 100644
--- a/chrome/views/hwnd_view.cc
+++ b/chrome/views/hwnd_view.cc
@@ -17,7 +17,6 @@ static const char kViewClassName[] = "chrome/views/HWNDView";
HWNDView::HWNDView() :
hwnd_(0),
- preferred_size_(0, 0),
installed_clip_(false),
fast_resize_(false),
focus_view_(NULL) {
@@ -145,13 +144,8 @@ void HWNDView::VisibilityChanged(View* starting_from, bool is_visible) {
::ShowWindow(hwnd_, SW_HIDE);
}
-void HWNDView::GetPreferredSize(CSize *out) {
- out->cx = preferred_size_.cx;
- out->cy = preferred_size_.cy;
-}
-
-void HWNDView::SetPreferredSize(const CSize& size) {
- preferred_size_ = size;
+gfx::Size HWNDView::GetPreferredSize() {
+ return preferred_size_;
}
void HWNDView::ViewHierarchyChanged(bool is_add, View *parent, View *child) {
diff --git a/chrome/views/hwnd_view.h b/chrome/views/hwnd_view.h
index f39dd6d..2af1aa5 100644
--- a/chrome/views/hwnd_view.h
+++ b/chrome/views/hwnd_view.h
@@ -26,9 +26,9 @@ class HWNDView : public View {
HWNDView();
virtual ~HWNDView();
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
- void SetPreferredSize(const CSize& size);
+ void set_preferred_size(const gfx::Size& size) { preferred_size_ = size; }
// Attach a window handle to this View, making the window it represents
// subject to sizing according to this View's parent container's Layout
@@ -74,7 +74,7 @@ class HWNDView : public View {
HWND hwnd_;
// The preferred size of this View
- CSize preferred_size_;
+ gfx::Size preferred_size_;
// Have we installed a region on the HWND used to clip to only the visible
// portion of the HWND?
diff --git a/chrome/views/hwnd_view_container.cc b/chrome/views/hwnd_view_container.cc
index d4f4ae2..1529085 100644
--- a/chrome/views/hwnd_view_container.cc
+++ b/chrome/views/hwnd_view_container.cc
@@ -59,9 +59,9 @@ void FillLayout::Layout(View* host) {
frame_view->SetBounds(CRect(CPoint(0, 0), bounds.Size()));
}
-void FillLayout::GetPreferredSize(View* host, CSize* out) {
+gfx::Size FillLayout::GetPreferredSize(View* host) {
DCHECK(host->GetChildViewCount() == 1);
- host->GetChildViewAt(0)->GetPreferredSize(out);
+ return host->GetChildViewAt(0)->GetPreferredSize();
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/views/hwnd_view_container.h b/chrome/views/hwnd_view_container.h
index 60171b6..2df9622 100644
--- a/chrome/views/hwnd_view_container.h
+++ b/chrome/views/hwnd_view_container.h
@@ -60,7 +60,7 @@ class FillLayout : public LayoutManager {
// Overridden from LayoutManager:
virtual void Layout(View* host);
- virtual void GetPreferredSize(View* host, CSize* out);
+ virtual gfx::Size GetPreferredSize(View* host);
private:
DISALLOW_EVIL_CONSTRUCTORS(FillLayout);
diff --git a/chrome/views/image_view.cc b/chrome/views/image_view.cc
index 00c771d..640541c 100644
--- a/chrome/views/image_view.cc
+++ b/chrome/views/image_view.cc
@@ -35,12 +35,12 @@ const SkBitmap& ImageView::GetImage() {
return image_;
}
-void ImageView::SetImageSize(const CSize& image_size) {
+void ImageView::SetImageSize(const gfx::Size& image_size) {
image_size_set_ = true;
image_size_ = image_size;
}
-bool ImageView::GetImageSize(CSize* image_size) {
+bool ImageView::GetImageSize(gfx::Size* image_size) {
DCHECK(image_size);
if (image_size_set_)
*image_size = image_size_;
@@ -51,14 +51,13 @@ void ImageView::ResetImageSize() {
image_size_set_ = false;
}
-void ImageView::GetPreferredSize(CSize* out) {
- DCHECK(out);
+gfx::Size ImageView::GetPreferredSize() {
if (image_size_set_) {
- GetImageSize(out);
- } else {
- out->cx = image_.width();
- out->cy = image_.height();
+ gfx::Size image_size;
+ GetImageSize(&image_size);
+ return image_size;
}
+ return gfx::Size(image_.width(), image_.height());
}
void ImageView::ComputeImageOrigin(int image_width, int image_height,
@@ -114,12 +113,13 @@ void ImageView::Paint(ChromeCanvas* canvas) {
int x, y;
if (image_size_set_ &&
- (image_size_.cx != image_width || image_size_.cy != image_height)) {
+ (image_size_.width() != image_width ||
+ image_size_.width() != image_height)) {
// Resize case
image_.buildMipMap(false);
- ComputeImageOrigin(image_size_.cx, image_size_.cy, &x, &y);
+ ComputeImageOrigin(image_size_.width(), image_size_.height(), &x, &y);
canvas->DrawBitmapInt(image_, 0, 0, image_width, image_height,
- x, y, image_size_.cx, image_size_.cy,
+ x, y, image_size_.width(), image_size_.height(),
true);
} else {
ComputeImageOrigin(image_width, image_height, &x, &y);
diff --git a/chrome/views/image_view.h b/chrome/views/image_view.h
index 1f25550..ce18b81 100644
--- a/chrome/views/image_view.h
+++ b/chrome/views/image_view.h
@@ -48,12 +48,12 @@ class ImageView : public View {
const SkBitmap& GetImage();
// Set the desired image size for the receiving ImageView.
- void SetImageSize(const CSize& image_size);
+ void SetImageSize(const gfx::Size& image_size);
// Return the preferred size for the receiving view. Returns false if the
// preferred size is not defined, which means that the view uses the image
// size.
- bool GetImageSize(CSize* image_size);
+ bool GetImageSize(gfx::Size* image_size);
// Reset the image size to the current image dimensions.
void ResetImageSize();
@@ -72,7 +72,7 @@ class ImageView : public View {
// Return whether the image should be centered inside the view.
// Overriden from View
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
virtual void Paint(ChromeCanvas* canvas);
// Overriden from View.
@@ -87,7 +87,7 @@ class ImageView : public View {
bool image_size_set_;
// The actual image size.
- CSize image_size_;
+ gfx::Size image_size_;
// The underlying bitmap.
SkBitmap image_;
diff --git a/chrome/views/label.cc b/chrome/views/label.cc
index 91f4d94..f6ce601 100644
--- a/chrome/views/label.cc
+++ b/chrome/views/label.cc
@@ -50,21 +50,21 @@ void Label::Init(const std::wstring& text, const ChromeFont& font) {
Label::~Label() {
}
-void Label::GetPreferredSize(CSize* out) {
- DCHECK(out);
+gfx::Size Label::GetPreferredSize() {
+ gfx::Size prefsize;
if (is_multi_line_) {
ChromeCanvas cc(0, 0, true);
int w = width(), h = 0;
cc.SizeStringInt(text_, font_, &w, &h, ComputeMultiLineFlags());
- out->cx = w;
- out->cy = h;
+ prefsize.SetSize(w, h);
} else {
- GetTextSize(out);
+ prefsize = GetTextSize();
}
gfx::Insets insets = GetInsets();
- out->cx += insets.left() + insets.right();
- out->cy += insets.top() + insets.bottom();
+ prefsize.Enlarge(insets.left() + insets.right(),
+ insets.top() + insets.bottom());
+ return prefsize;
}
int Label::ComputeMultiLineFlags() {
@@ -179,18 +179,15 @@ const GURL Label::GetURL() const {
return GURL(text_);
}
-void Label::GetTextSize(CSize* out) {
+gfx::Size Label::GetTextSize() {
if (!text_size_valid_) {
- text_size_.cx = font_.GetStringWidth(text_);
- text_size_.cy = font_.height();
+ text_size_.SetSize(font_.GetStringWidth(text_), font_.height());
text_size_valid_ = true;
}
- if (text_size_valid_) {
- *out = text_size_;
- } else {
- out->cx = out->cy = 0;
- }
+ if (text_size_valid_)
+ return text_size_;
+ return gfx::Size();
}
int Label::GetHeightForWidth(int w) {
@@ -314,15 +311,14 @@ void Label::SetContainsMouse(bool contains_mouse) {
}
gfx::Rect Label::GetTextBounds() {
- CSize text_size;
- GetTextSize(&text_size);
+ gfx::Size text_size = GetTextSize();
gfx::Insets insets = GetInsets();
int avail_width = width() - insets.left() - insets.right();
// Respect the size set by the owner view
- text_size.cx = std::min(avail_width, static_cast<int>(text_size.cx));
+ text_size.set_width(std::min(avail_width, text_size.width()));
int text_y = insets.top() +
- (height() - text_size.cy - insets.top() - insets.bottom()) / 2;
+ (height() - text_size.height() - insets.top() - insets.bottom()) / 2;
int text_x;
switch (horiz_alignment_) {
case ALIGN_LEFT:
@@ -331,13 +327,13 @@ gfx::Rect Label::GetTextBounds() {
case ALIGN_CENTER:
// We put any extra margin pixel on the left rather than the right, since
// GetTextExtentPoint32() can report a value one too large on the right.
- text_x = insets.left() + (avail_width + 1 - text_size.cx) / 2;
+ text_x = insets.left() + (avail_width + 1 - text_size.width()) / 2;
break;
case ALIGN_RIGHT:
- text_x = width() - insets.right() - text_size.cx;
+ text_x = width() - insets.right() - text_size.width();
break;
}
- return gfx::Rect(text_x, text_y, text_size.cx, text_size.cy);
+ return gfx::Rect(text_x, text_y, text_size.width(), text_size.height());
}
void Label::SizeToFit(int max_width) {
diff --git a/chrome/views/label.h b/chrome/views/label.h
index 240ac55..034abee 100644
--- a/chrome/views/label.h
+++ b/chrome/views/label.h
@@ -39,11 +39,11 @@ class Label : public View {
virtual ~Label();
// Overridden to compute the size required to display this label
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
// Return the height necessary to display this label with the provided width.
// This method is used to layout multi-line labels. It is equivalent to
- // GetPreferredSize().cy if the receiver is not multi-line
+ // GetPreferredSize().height() if the receiver is not multi-line
virtual int GetHeightForWidth(int w);
// Returns chrome/views/Label.
@@ -154,13 +154,13 @@ class Label : public View {
gfx::Rect GetTextBounds();
int ComputeMultiLineFlags();
- void GetTextSize(CSize* out);
+ gfx::Size GetTextSize();
void Init(const std::wstring& text, const ChromeFont& font);
std::wstring text_;
GURL url_;
ChromeFont font_;
SkColor color_;
- CSize text_size_;
+ gfx::Size text_size_;
bool text_size_valid_;
bool is_multi_line_;
bool url_set_;
diff --git a/chrome/views/layout_manager.cc b/chrome/views/layout_manager.cc
index b22faef..52991a9 100644
--- a/chrome/views/layout_manager.cc
+++ b/chrome/views/layout_manager.cc
@@ -9,9 +9,7 @@
namespace ChromeViews {
int LayoutManager::GetPreferredHeightForWidth(View* host, int width) {
- CSize pref;
- GetPreferredSize(host, &pref);
- return pref.cy;
+ return GetPreferredSize(host).height();
}
} // namespace
diff --git a/chrome/views/layout_manager.h b/chrome/views/layout_manager.h
index d153110..bf55cad 100644
--- a/chrome/views/layout_manager.h
+++ b/chrome/views/layout_manager.h
@@ -9,6 +9,10 @@
#include <atlapp.h>
#include <atlmisc.h>
+namespace gfx {
+class Size;
+}
+
namespace ChromeViews {
class View;
@@ -40,7 +44,7 @@ class LayoutManager {
// Return the preferred size which is the size required to give each
// children their respective preferred size.
- virtual void GetPreferredSize(View* host, CSize* out) = 0;
+ virtual gfx::Size GetPreferredSize(View* host) = 0;
// Returns the preferred height for the specified width. The default
// implementation returns the value from GetPreferredSize.
diff --git a/chrome/views/menu_button.cc b/chrome/views/menu_button.cc
index b8fd1b6..a7eeb46 100644
--- a/chrome/views/menu_button.cc
+++ b/chrome/views/menu_button.cc
@@ -65,12 +65,14 @@ MenuButton::~MenuButton() {
//
////////////////////////////////////////////////////////////////////////////////
-void MenuButton::GetPreferredSize(CSize* result) {
- TextButton::GetPreferredSize(result);
+gfx::Size MenuButton::GetPreferredSize() {
+ gfx::Size prefsize = TextButton::GetPreferredSize();
if (show_menu_marker_) {
- result->cx += kMenuMarker->width() + kMenuMarkerPaddingLeft +
- kMenuMarkerPaddingRight;
+ prefsize.Enlarge(kMenuMarker->width() + kMenuMarkerPaddingLeft +
+ kMenuMarkerPaddingRight,
+ 0);
}
+ return prefsize;
}
void MenuButton::Paint(ChromeCanvas* canvas, bool for_drag) {
diff --git a/chrome/views/menu_button.h b/chrome/views/menu_button.h
index 080d4e1..961360b 100644
--- a/chrome/views/menu_button.h
+++ b/chrome/views/menu_button.h
@@ -38,7 +38,7 @@ class MenuButton : public TextButton {
virtual bool Activate();
// Overridden to take into account the potential use of a drop marker.
- void GetPreferredSize(CSize* result);
+ virtual gfx::Size GetPreferredSize();
virtual void Paint(ChromeCanvas* canvas, bool for_drag);
// These methods are overriden to implement a simple push button
diff --git a/chrome/views/message_box_view.cc b/chrome/views/message_box_view.cc
index fbc6d32..bf2ac5f 100644
--- a/chrome/views/message_box_view.cc
+++ b/chrome/views/message_box_view.cc
@@ -119,9 +119,9 @@ void MessageBoxView::ResetLayoutManager() {
GridLayout* layout = CreatePanelGridLayout(this);
SetLayoutManager(layout);
- CSize icon_size;
+ gfx::Size icon_size;
if (icon_)
- icon_->GetPreferredSize(&icon_size);
+ icon_size = icon_->GetPreferredSize();
// Add the column set for the message displayed at the top of the dialog box.
// And an icon, if one has been set.
@@ -129,7 +129,8 @@ void MessageBoxView::ResetLayoutManager() {
ColumnSet* column_set = layout->AddColumnSet(message_column_view_set_id);
if (icon_) {
column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::FIXED, icon_size.cx, icon_size.cy);
+ GridLayout::FIXED, icon_size.width(),
+ icon_size.height());
column_set->AddPaddingColumn(0, kUnrelatedControlHorizontalSpacing);
}
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
@@ -141,7 +142,7 @@ void MessageBoxView::ResetLayoutManager() {
column_set = layout->AddColumnSet(textfield_column_view_set_id);
if (icon_) {
column_set->AddPaddingColumn(0,
- icon_size.cx + kUnrelatedControlHorizontalSpacing);
+ icon_size.width() + kUnrelatedControlHorizontalSpacing);
}
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
GridLayout::USE_PREF, 0, 0);
@@ -153,7 +154,7 @@ void MessageBoxView::ResetLayoutManager() {
column_set = layout->AddColumnSet(checkbox_column_view_set_id);
if (icon_) {
column_set->AddPaddingColumn(0,
- icon_size.cx + kUnrelatedControlHorizontalSpacing);
+ icon_size.width() + kUnrelatedControlHorizontalSpacing);
}
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
GridLayout::USE_PREF, 0, 0);
diff --git a/chrome/views/native_button.cc b/chrome/views/native_button.cc
index 55323c6..ee2288f 100644
--- a/chrome/views/native_button.cc
+++ b/chrome/views/native_button.cc
@@ -33,7 +33,7 @@ void NativeButton::SetPadding(CSize size) {
padding_ = size;
}
-void NativeButton::GetPreferredSize(CSize *out) {
+gfx::Size NativeButton::GetPreferredSize() {
HWND hwnd = GetNativeControlHWND();
if (hwnd) {
SIZE sz = {0, 0};
@@ -54,8 +54,9 @@ void NativeButton::GetPreferredSize(CSize *out) {
sz.cy = std::max(static_cast<int>(sz.cy),
font_.vertical_dlus_to_pixels(min_dlu_size_.height()));
}
- *out = sz;
+ return gfx::Size(sz.cx, sz.cy);
}
+ return gfx::Size();
}
void NativeButton::SetLabel(const std::wstring& l) {
diff --git a/chrome/views/native_button.h b/chrome/views/native_button.h
index 935349f..df1fd8e 100644
--- a/chrome/views/native_button.h
+++ b/chrome/views/native_button.h
@@ -30,7 +30,7 @@ class NativeButton : public NativeControl {
NativeButton(const std::wstring& label, bool is_default);
virtual ~NativeButton();
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
void SetLabel(const std::wstring& l);
const std::wstring GetLabel() const;
diff --git a/chrome/views/native_scroll_bar.cc b/chrome/views/native_scroll_bar.cc
index 0f36834..6058646 100644
--- a/chrome/views/native_scroll_bar.cc
+++ b/chrome/views/native_scroll_bar.cc
@@ -250,15 +250,10 @@ void NativeScrollBar::DidChangeBounds(const CRect& previous,
Layout();
}
-void NativeScrollBar::GetPreferredSize(CSize *out) {
- DCHECK(out);
- if (IsHorizontal()) {
- out->cx = 0;
- out->cy = GetLayoutSize();
- } else {
- out->cx = GetLayoutSize();
- out->cy = 0;
- }
+gfx::Size NativeScrollBar::GetPreferredSize() {
+ if (IsHorizontal())
+ return gfx::Size(0, GetLayoutSize());
+ return gfx::Size(GetLayoutSize(), 0);
}
void NativeScrollBar::Update(int viewport_size, int content_size, int current_pos) {
diff --git a/chrome/views/native_scroll_bar.h b/chrome/views/native_scroll_bar.h
index 60f7381..ad514b4 100644
--- a/chrome/views/native_scroll_bar.h
+++ b/chrome/views/native_scroll_bar.h
@@ -30,7 +30,7 @@ class NativeScrollBar : public ScrollBar {
// Overridden for layout purpose
virtual void Layout();
- virtual void GetPreferredSize(CSize* sz);
+ virtual gfx::Size GetPreferredSize();
virtual void DidChangeBounds(const CRect& previous, const CRect& current);
// Overridden for keyboard UI purpose
diff --git a/chrome/views/radio_button.cc b/chrome/views/radio_button.cc
index 1e860e7..56e80f1 100644
--- a/chrome/views/radio_button.cc
+++ b/chrome/views/radio_button.cc
@@ -60,11 +60,13 @@ std::string RadioButton::GetClassName() const {
return kViewClassName;
}
-void RadioButton::GetPreferredSize(CSize *out) {
- label_->GetPreferredSize(out);
- out->cy = std::max(static_cast<int>(out->cy + kFocusPaddingVertical * 2),
- kRadioHeight) ;
- out->cx += kRadioToLabel + kRadioWidth + kFocusPaddingHorizontal * 2;
+gfx::Size RadioButton::GetPreferredSize() {
+ gfx::Size prefsize = label_->GetPreferredSize();
+ prefsize.set_height(std::max(prefsize.height() + kFocusPaddingVertical * 2,
+ kRadioHeight));
+ prefsize.Enlarge(kRadioToLabel + kRadioWidth + kFocusPaddingHorizontal * 2,
+ 0);
+ return prefsize;
}
void RadioButton::Layout() {
diff --git a/chrome/views/radio_button.h b/chrome/views/radio_button.h
index d81cceb..0a5e5fa 100644
--- a/chrome/views/radio_button.h
+++ b/chrome/views/radio_button.h
@@ -29,7 +29,7 @@ class RadioButton : public CheckBox {
RadioButton(const std::wstring& label, int group_id);
virtual ~RadioButton();
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
virtual void Layout();
virtual std::string GetClassName() const;
diff --git a/chrome/views/separator.cc b/chrome/views/separator.cc
index 0c9c6fa..c808826 100644
--- a/chrome/views/separator.cc
+++ b/chrome/views/separator.cc
@@ -31,10 +31,8 @@ LRESULT Separator::OnNotify(int w_param, LPNMHDR l_param) {
return 0;
}
-void Separator::GetPreferredSize(CSize* out) {
- DCHECK(out);
- out->cx = width();
- out->cy = fixed_height_;
+gfx::Size Separator::GetPreferredSize() {
+ return gfx::Size(width(), fixed_height_);
}
}
diff --git a/chrome/views/separator.h b/chrome/views/separator.h
index c949b04..9a4c2bc 100644
--- a/chrome/views/separator.h
+++ b/chrome/views/separator.h
@@ -22,7 +22,7 @@ class Separator : public NativeControl {
virtual LRESULT OnNotify(int w_param, LPNMHDR l_param);
// View overrides:
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
private:
diff --git a/chrome/views/table_view.cc b/chrome/views/table_view.cc
index c3100f8..21ada1f 100644
--- a/chrome/views/table_view.cc
+++ b/chrome/views/table_view.cc
@@ -1096,13 +1096,8 @@ void TableView::ResetColumnSizes() {
}
}
-void TableView::SetPreferredSize(const CSize& preferred_size) {
- preferred_size_ = preferred_size;
-}
-
-void TableView::GetPreferredSize(CSize* out) {
- DCHECK(out);
- *out = preferred_size_;
+gfx::Size TableView::GetPreferredSize() {
+ return preferred_size_;
}
void TableView::UpdateListViewCache0(int start, int length, bool add) {
diff --git a/chrome/views/table_view.h b/chrome/views/table_view.h
index 6f2df47..7f8422b 100644
--- a/chrome/views/table_view.h
+++ b/chrome/views/table_view.h
@@ -405,8 +405,8 @@ class TableView : public NativeControl,
// Sometimes we may want to size the TableView to a specific width and
// height.
- void SetPreferredSize(const CSize& preferred_size);
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
+ void set_preferred_size(const gfx::Size& size) { preferred_size_ = size; }
// Is the table sorted?
bool is_sorted() const { return !sort_descriptors_.empty(); }
@@ -627,7 +627,7 @@ class TableView : public NativeControl,
HFONT custom_cell_font_;
// The preferred size of the table view.
- CSize preferred_size_;
+ gfx::Size preferred_size_;
// The offset from the top of the client area to the start of the content.
int content_offset_;
diff --git a/chrome/views/text_button.cc b/chrome/views/text_button.cc
index 617860d..c1631ff 100644
--- a/chrome/views/text_button.cc
+++ b/chrome/views/text_button.cc
@@ -143,8 +143,7 @@ void TextButtonBorder::GetInsets(gfx::Insets* insets) const {
////////////////////////////////////////////////////////////////////////////////
TextButton::TextButton(const std::wstring& text)
- : max_text_size_(CSize(0, 0)),
- font_(ResourceBundle::GetSharedInstance().GetFont(
+ : font_(ResourceBundle::GetSharedInstance().GetFont(
ResourceBundle::BaseFont)),
color_(kEnabledColor),
BaseButton(),
@@ -158,24 +157,25 @@ TextButton::TextButton(const std::wstring& text)
TextButton::~TextButton() {
}
-void TextButton::GetPreferredSize(CSize *result) {
+gfx::Size TextButton::GetPreferredSize() {
gfx::Insets insets = GetInsets();
// Use the max size to set the button boundaries.
- result->cx = max_text_size_.cx + icon_.width() + insets.width();
- result->cy = std::max(static_cast<int>(max_text_size_.cy), icon_.height()) +
- insets.height();
+ gfx::Size prefsize(max_text_size_.width() + icon_.width() + insets.width(),
+ std::max(max_text_size_.height(), icon_.height()) +
+ insets.height());
if (icon_.width() > 0 && !text_.empty())
- result->cx += kIconTextPadding;
+ prefsize.Enlarge(kIconTextPadding, 0);
if (max_width_ > 0)
- result->cx = std::min(max_width_, static_cast<int>(result->cx));
+ prefsize.set_width(std::min(max_width_, prefsize.width()));
+
+ return prefsize;
}
-void TextButton::GetMinimumSize(CSize *result) {
- result->cx = max_text_size_.cx;
- result->cy = max_text_size_.cy;
+gfx::Size TextButton::GetMinimumSize() {
+ return max_text_size_;
}
bool TextButton::OnMousePressed(const ChromeViews::MouseEvent& e) {
@@ -185,10 +185,10 @@ bool TextButton::OnMousePressed(const ChromeViews::MouseEvent& e) {
void TextButton::SetText(const std::wstring& text) {
text_ = text;
// Update our new current and max text size
- text_size_.cx = font_.GetStringWidth(text_);
- text_size_.cy = font_.height();
- max_text_size_.cx = std::max(max_text_size_.cx, text_size_.cx);
- max_text_size_.cy = std::max(max_text_size_.cy, text_size_.cy);
+ text_size_.SetSize(font_.GetStringWidth(text_), font_.height());
+ max_text_size_.SetSize(std::max(max_text_size_.width(), text_size_.width()),
+ std::max(max_text_size_.height(),
+ text_size_.height()));
}
void TextButton::SetIcon(const SkBitmap& icon) {
@@ -227,7 +227,7 @@ void TextButton::Paint(ChromeCanvas* canvas, bool for_drag) {
int available_width = width() - insets.width();
int available_height = height() - insets.height();
// Use the actual text (not max) size to properly center the text.
- int content_width = text_size_.cx;
+ int content_width = text_size_.width();
if (icon_.width() > 0) {
content_width += icon_.width();
if (!text_.empty())
@@ -246,9 +246,9 @@ void TextButton::Paint(ChromeCanvas* canvas, bool for_drag) {
int text_x = icon_x;
if (icon_.width() > 0)
text_x += icon_.width() + kIconTextPadding;
- const int text_width = std::min(static_cast<int>(text_size_.cx),
+ const int text_width = std::min(text_size_.width(),
width() - insets.right() - text_x);
- int text_y = (available_height - text_size_.cy) / 2 + insets.top();
+ int text_y = (available_height - text_size_.height()) / 2 + insets.top();
if (text_width > 0) {
// Because the text button can (at times) draw multiple elements on the
@@ -259,7 +259,7 @@ void TextButton::Paint(ChromeCanvas* canvas, bool for_drag) {
// horizontally.
//
// Due to the above, we must perform the flipping manually for RTL UIs.
- gfx::Rect text_bounds(text_x, text_y, text_width, text_size_.cy);
+ gfx::Rect text_bounds(text_x, text_y, text_width, text_size_.height());
text_bounds.set_x(MirroredLeftPointForRect(text_bounds));
// Draw bevel highlight
diff --git a/chrome/views/text_button.h b/chrome/views/text_button.h
index dcfcca1..2b4a01f 100644
--- a/chrome/views/text_button.h
+++ b/chrome/views/text_button.h
@@ -75,8 +75,8 @@ public:
ALIGN_RIGHT
};
- void GetPreferredSize(CSize* result);
- void GetMinimumSize(CSize* result);
+ virtual gfx::Size GetPreferredSize();
+ virtual gfx::Size GetMinimumSize();
virtual bool OnMousePressed(const ChromeViews::MouseEvent& e);
// Call SetText once per string in your set of possible values at
@@ -113,11 +113,11 @@ public:
private:
std::wstring text_;
- CSize text_size_;
+ gfx::Size text_size_;
// Track the size of the largest text string seen so far, so that
// changing text_ will not resize the button boundary.
- CSize max_text_size_;
+ gfx::Size max_text_size_;
TextAlignment alignment_;
diff --git a/chrome/views/text_field.cc b/chrome/views/text_field.cc
index 8d61868..6968b2b 100644
--- a/chrome/views/text_field.cc
+++ b/chrome/views/text_field.cc
@@ -850,11 +850,12 @@ void TextField::DidChangeBounds(const CRect& previous, const CRect& current) {
Layout();
}
-void TextField::GetPreferredSize(CSize *out) {
+gfx::Size TextField::GetPreferredSize() {
gfx::Insets insets;
CalculateInsets(&insets);
- out->cx = default_width_in_chars_ * font_.ave_char_width() + insets.width();
- out->cy = num_lines_ * font_.height() + insets.height();
+ return gfx::Size(default_width_in_chars_ * font_.ave_char_width() +
+ insets.width(),
+ num_lines_ * font_.height() + insets.height());
}
std::wstring TextField::GetText() const {
diff --git a/chrome/views/text_field.h b/chrome/views/text_field.h
index 8696f1d..9d7539c 100644
--- a/chrome/views/text_field.h
+++ b/chrome/views/text_field.h
@@ -72,7 +72,7 @@ class TextField : public View {
// Overridden for layout purposes
virtual void Layout();
- virtual void GetPreferredSize(CSize* sz);
+ virtual gfx::Size GetPreferredSize();
virtual void DidChangeBounds(const CRect& previous, const CRect& current);
// Controller accessors
diff --git a/chrome/views/throbber.cc b/chrome/views/throbber.cc
index 754ea6c..f848fba 100644
--- a/chrome/views/throbber.cc
+++ b/chrome/views/throbber.cc
@@ -62,10 +62,8 @@ void Throbber::Run() {
SchedulePaint();
}
-void Throbber::GetPreferredSize(CSize *out) {
- DCHECK(out);
-
- out->SetSize(frames_->height(), frames_->height());
+gfx::Size Throbber::GetPreferredSize() {
+ return gfx::Size(frames_->height(), frames_->height());
}
void Throbber::Paint(ChromeCanvas* canvas) {
diff --git a/chrome/views/throbber.h b/chrome/views/throbber.h
index 3c42fde..93d771c 100644
--- a/chrome/views/throbber.h
+++ b/chrome/views/throbber.h
@@ -29,7 +29,7 @@ class Throbber : public ChromeViews::View {
virtual void Stop();
// overridden from View
- virtual void GetPreferredSize(CSize *out);
+ virtual gfx::Size GetPreferredSize();
virtual void Paint(ChromeCanvas* canvas);
protected:
diff --git a/chrome/views/view.cc b/chrome/views/view.cc
index f73ca92..cbb1b25 100644
--- a/chrome/views/view.cc
+++ b/chrome/views/view.cc
@@ -169,6 +169,10 @@ void View::SetBounds(int x, int y, int width, int height) {
SetBounds(tmp);
}
+void View::SetBounds(const gfx::Point& origin, const gfx::Size& size) {
+ SetBounds(origin.x(), origin.y(), size.width(), size.height());
+}
+
void View::GetLocalBounds(CRect* out, bool include_border) const {
if (include_border || border_ == NULL) {
out->left = 0;
@@ -195,32 +199,27 @@ void View::GetPosition(CPoint* p) const {
p->y = y();
}
-void View::GetPreferredSize(CSize* out) {
- if (layout_manager_.get()) {
- layout_manager_->GetPreferredSize(this, out);
- } else {
- out->cx = out->cy = 0;
- }
+gfx::Size View::GetPreferredSize() {
+ if (layout_manager_.get())
+ return layout_manager_->GetPreferredSize(this);
+ return gfx::Size();
}
void View::SizeToPreferredSize() {
- CSize size;
- GetPreferredSize(&size);
- if ((size.cx != width()) || (size.cy != height()))
- SetBounds(x(), y(), size.cx, size.cy);
+ gfx::Size prefsize = GetPreferredSize();
+ if ((prefsize.width() != width()) || (prefsize.height() != height()))
+ SetBounds(x(), y(), prefsize.width(), prefsize.height());
}
-void View::GetMinimumSize(CSize* out) {
- GetPreferredSize(out);
+gfx::Size View::GetMinimumSize() {
+ return GetPreferredSize();
}
int View::GetHeightForWidth(int w) {
if (layout_manager_.get())
return layout_manager_->GetPreferredHeightForWidth(this, w);
- CSize size;
- GetPreferredSize(&size);
- return size.cy;
+ return GetPreferredSize().height();
}
void View::DidChangeBounds(const CRect& previous, const CRect& current) {
diff --git a/chrome/views/view.h b/chrome/views/view.h
index d56d94f..18314b0 100644
--- a/chrome/views/view.h
+++ b/chrome/views/view.h
@@ -158,6 +158,7 @@ class View : public AcceleratorTarget {
// 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 SetX(int x) { SetBounds(x, y(), width(), height()); }
void SetY(int y) { SetBounds(x(), y, width(), height()); }
@@ -212,14 +213,14 @@ class View : public AcceleratorTarget {
void GetPosition(CPoint* out) const;
// Get the size the View would like to be, if enough space were available.
- virtual void GetPreferredSize(CSize* out);
+ virtual gfx::Size GetPreferredSize();
// Convenience method that sizes this view to its preferred size.
void SizeToPreferredSize();
// Gets the minimum size of the view. View's implementation invokes
// GetPreferredSize.
- virtual void GetMinimumSize(CSize* out);
+ virtual gfx::Size GetMinimumSize();
// Return the height necessary to display this view with the provided width.
// View's implementation returns the value from getPreferredSize.cy.
diff --git a/chrome/views/window.cc b/chrome/views/window.cc
index 87c8f57..78df878 100644
--- a/chrome/views/window.cc
+++ b/chrome/views/window.cc
@@ -325,16 +325,17 @@ void Window::SetClientView(ClientView* client_view) {
}
void Window::SizeWindowToDefault() {
- CSize pref(0, 0);
+ gfx::Size pref;
if (non_client_view_) {
- non_client_view_->GetPreferredSize(&pref);
+ pref = non_client_view_->GetPreferredSize();
} else {
- client_view_->GetPreferredSize(&pref);
+ pref = client_view_->GetPreferredSize();
}
- DCHECK(pref.cx > 0 && pref.cy > 0);
+ DCHECK(pref.width() > 0 && pref.height() > 0);
// CenterAndSizeWindow adjusts the window size to accommodate the non-client
// area.
- win_util::CenterAndSizeWindow(owning_window(), GetHWND(), pref, true);
+ win_util::CenterAndSizeWindow(owning_window(), GetHWND(), pref.ToSIZE(),
+ true);
}
void Window::RunSystemMenu(const CPoint& point) {