diff options
author | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-15 18:02:30 +0000 |
---|---|---|
committer | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-15 18:02:30 +0000 |
commit | 154f8bcac65142d7ae6733204c15ae52cfa320c6 (patch) | |
tree | d7375c1119946c2914ee79ef2c0e8aa195b1fbe9 /chrome/browser/views | |
parent | 8144d0cea4e142ff7d7a75c84240a4bb8a7fb3a4 (diff) | |
download | chromium_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/browser/views')
81 files changed, 864 insertions, 960 deletions
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; |