diff options
-rw-r--r-- | chrome/browser/native_ui_contents.cc | 9 | ||||
-rw-r--r-- | chrome/browser/views/blocked_popup_container.cc | 2 | ||||
-rw-r--r-- | chrome/browser/views/download_shelf_view.cc | 2 | ||||
-rw-r--r-- | chrome/browser/views/find_bar_view.cc | 4 | ||||
-rw-r--r-- | chrome/browser/views/first_run_view_base.cc | 2 | ||||
-rw-r--r-- | chrome/browser/views/info_bar_view.cc | 2 | ||||
-rw-r--r-- | chrome/browser/views/location_bar_view.cc | 4 | ||||
-rw-r--r-- | chrome/browser/views/options/advanced_contents_view.cc | 2 | ||||
-rw-r--r-- | chrome/browser/views/options/cookies_view.cc | 2 | ||||
-rw-r--r-- | chrome/browser/views/page_info_window.cc | 2 | ||||
-rw-r--r-- | chrome/views/chrome_menu.cc | 6 | ||||
-rw-r--r-- | chrome/views/focus_manager_unittest.cc | 22 | ||||
-rw-r--r-- | chrome/views/label.cc | 2 | ||||
-rw-r--r-- | chrome/views/label_unittest.cc | 32 | ||||
-rw-r--r-- | chrome/views/native_control.cc | 2 | ||||
-rw-r--r-- | chrome/views/tabbed_pane.cc | 6 | ||||
-rw-r--r-- | chrome/views/text_button.cc | 2 | ||||
-rw-r--r-- | chrome/views/view.cc | 37 | ||||
-rw-r--r-- | chrome/views/view.h | 22 |
19 files changed, 67 insertions, 95 deletions
diff --git a/chrome/browser/native_ui_contents.cc b/chrome/browser/native_ui_contents.cc index 1961e26d..840bb91 100644 --- a/chrome/browser/native_ui_contents.cc +++ b/chrome/browser/native_ui_contents.cc @@ -164,7 +164,7 @@ LRESULT NativeUIContents::OnCreate(LPCREATESTRUCT create_struct) { // Install the focus manager so we get notified of Tab key events. views::FocusManager::InstallFocusSubclass(GetHWND(), NULL); - GetRootView()->SetBackground(new NativeUIBackground); + GetRootView()->set_background(new NativeUIBackground); return 0; } @@ -497,10 +497,11 @@ SearchableUIContainer::SearchableUIContainer( search_field_->SetController(this); scroll_view_ = new views::ScrollView; - scroll_view_->SetBackground(views::Background::CreateSolidBackground(kBackground)); + scroll_view_->set_background( + views::Background::CreateSolidBackground(kBackground)); // Set background class so that native controls can get a color. - SetBackground(new SearchableUIBackground(kBackground)); + set_background(new SearchableUIBackground(kBackground)); throbber_ = new views::SmoothedThrobber(50); @@ -516,7 +517,7 @@ SearchableUIContainer::SearchableUIContainer( // Set a background color for the search button. If SearchableUIContainer // provided a background, then the search button could inherit that instead. - search_button_->SetBackground(new SearchableUIBackground(kBackground)); + search_button_->set_background(new SearchableUIBackground(kBackground)); // For the first row (icon, title/text field, search button and throbber). ColumnSet* column_set = layout->AddColumnSet(0); diff --git a/chrome/browser/views/blocked_popup_container.cc b/chrome/browser/views/blocked_popup_container.cc index b315976..6d9320e 100644 --- a/chrome/browser/views/blocked_popup_container.cc +++ b/chrome/browser/views/blocked_popup_container.cc @@ -136,7 +136,7 @@ BlockedPopupContainerView::BlockedPopupContainerView( close_button_->SetListener(this, 0); AddChildView(close_button_); - SetBackground(views::Background::CreateStandardPanelBackground()); + set_background(views::Background::CreateStandardPanelBackground()); UpdatePopupCountLabel(); } diff --git a/chrome/browser/views/download_shelf_view.cc b/chrome/browser/views/download_shelf_view.cc index a1538a4..4190d78 100644 --- a/chrome/browser/views/download_shelf_view.cc +++ b/chrome/browser/views/download_shelf_view.cc @@ -100,7 +100,7 @@ void DownloadShelfView::Init() { rb.GetBitmapNamed(IDR_CLOSE_BAR_P)); close_button_->SetListener(this, 0); AddChildView(close_button_); - SetBackground(views::Background::CreateSolidBackground(kBackgroundColor)); + set_background(views::Background::CreateSolidBackground(kBackgroundColor)); new_item_animation_.reset(new SlideAnimation(this)); new_item_animation_->SetSlideDuration(kNewItemAnimationDurationMs); diff --git a/chrome/browser/views/find_bar_view.cc b/chrome/browser/views/find_bar_view.cc index 2307895..a065c1b 100644 --- a/chrome/browser/views/find_bar_view.cc +++ b/chrome/browser/views/find_bar_view.cc @@ -175,7 +175,7 @@ void FindBarView::ResetMatchCount() { } void FindBarView::ResetMatchCountBackground() { - match_count_text_->SetBackground( + match_count_text_->set_background( views::Background::CreateSolidBackground(kBackgroundColorMatch)); match_count_text_->SetColor(kTextColorMatchCount); } @@ -201,7 +201,7 @@ void FindBarView::UpdateMatchCount(int number_of_matches, if (find_text_->GetText().empty() || number_of_matches > 0) { ResetMatchCountBackground(); } else { - match_count_text_->SetBackground( + match_count_text_->set_background( views::Background::CreateSolidBackground(kBackgroundColorNoMatch)); match_count_text_->SetColor(kTextColorNoMatch); MessageBeep(MB_OK); diff --git a/chrome/browser/views/first_run_view_base.cc b/chrome/browser/views/first_run_view_base.cc index 4875580..c919939 100644 --- a/chrome/browser/views/first_run_view_base.cc +++ b/chrome/browser/views/first_run_view_base.cc @@ -79,7 +79,7 @@ void FirstRunViewBase::SetupControls() { if (UILayoutIsRightToLeft()) background_image_->SetImage(rb.GetBitmapNamed(IDR_WIZARD_ICON_RTL)); - background_image_->SetBackground(bkg); + background_image_->set_background(bkg); AddChildView(background_image_); // The first separator marks the end of the image. diff --git a/chrome/browser/views/info_bar_view.cc b/chrome/browser/views/info_bar_view.cc index 255e528..116a00b 100644 --- a/chrome/browser/views/info_bar_view.cc +++ b/chrome/browser/views/info_bar_view.cc @@ -131,7 +131,7 @@ void InfoBarView::ViewHierarchyChanged(bool is_add, View *parent, } void InfoBarView::Init() { - SetBackground( + set_background( views::Background::CreateVerticalGradientBackground( kBackgroundColorTop, kBackgroundColorBottom)); } diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc index 32b1d79..c28974f 100644 --- a/chrome/browser/views/location_bar_view.cc +++ b/chrome/browser/views/location_bar_view.cc @@ -610,10 +610,10 @@ LocationBarView::SelectedKeywordView::SelectedKeywordView(Profile* profile) partial_label_.SetParentOwned(false); full_label_.SetVisible(false); partial_label_.SetVisible(false); - full_label_.SetBorder( + full_label_.set_border( views::Border::CreateEmptyBorder(kTopInset, kLeftInset, kBottomInset, kRightInset)); - partial_label_.SetBorder( + partial_label_.set_border( views::Border::CreateEmptyBorder(kTopInset, kLeftInset, kBottomInset, kRightInset)); } diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc index af30d28..d50ce4e 100644 --- a/chrome/browser/views/options/advanced_contents_view.cc +++ b/chrome/browser/views/options/advanced_contents_view.cc @@ -1187,7 +1187,7 @@ AdvancedScrollViewContainer::AdvancedScrollViewContainer(Profile* profile) scroll_view_(new views::ScrollView) { AddChildView(scroll_view_); scroll_view_->SetContents(contents_view_); - SetBackground(new ListBackground()); + set_background(new ListBackground()); } AdvancedScrollViewContainer::~AdvancedScrollViewContainer() { diff --git a/chrome/browser/views/options/cookies_view.cc b/chrome/browser/views/options/cookies_view.cc index c70d5b3..a4cc197 100644 --- a/chrome/browser/views/options/cookies_view.cc +++ b/chrome/browser/views/options/cookies_view.cc @@ -440,7 +440,7 @@ void CookieInfoView::Init() { SkColor border_color = color_utils::GetSysSkColor(COLOR_3DSHADOW); views::Border* border = views::Border::CreateSolidBorder( kCookieInfoViewBorderSize, border_color); - SetBorder(border); + set_border(border); name_label_ = new views::Label( l10n_util::GetString(IDS_COOKIES_COOKIE_NAME_LABEL)); diff --git a/chrome/browser/views/page_info_window.cc b/chrome/browser/views/page_info_window.cc index 591e61b..fdd32fb 100644 --- a/chrome/browser/views/page_info_window.cc +++ b/chrome/browser/views/page_info_window.cc @@ -523,7 +523,7 @@ void PageInfoWindow::Init(Profile* profile, DWORD sys_color = ::GetSysColor(COLOR_3DFACE); SkColor color = SkColorSetRGB(GetRValue(sys_color), GetGValue(sys_color), GetBValue(sys_color)); - contents_->SetBackground(views::Background::CreateSolidBackground(color)); + contents_->set_background(views::Background::CreateSolidBackground(color)); views::GridLayout* layout = new views::GridLayout(contents_); contents_->SetLayoutManager(layout); diff --git a/chrome/views/chrome_menu.cc b/chrome/views/chrome_menu.cc index d1f4eed..62879cd 100644 --- a/chrome/views/chrome_menu.cc +++ b/chrome/views/chrome_menu.cc @@ -422,9 +422,9 @@ class MenuScrollViewContainer : public View { scroll_view_ = new MenuScrollView(content_view); AddChildView(scroll_view_); - SetBorder( - Border::CreateEmptyBorder(kSubmenuBorderSize, kSubmenuBorderSize, - kSubmenuBorderSize, kSubmenuBorderSize)); + set_border(Border::CreateEmptyBorder( + kSubmenuBorderSize, kSubmenuBorderSize, + kSubmenuBorderSize, kSubmenuBorderSize)); } virtual void Paint(ChromeCanvas* canvas) { diff --git a/chrome/views/focus_manager_unittest.cc b/chrome/views/focus_manager_unittest.cc index ed6b29b..861979e 100644 --- a/chrome/views/focus_manager_unittest.cc +++ b/chrome/views/focus_manager_unittest.cc @@ -236,7 +236,7 @@ TestViewWindow::TestViewWindow(FocusManagerTest* test) void TestViewWindow::Init() { gfx::Rect bounds(0, 0, 600, 460); contents_ = new views::View(); - contents_->SetBackground( + contents_->set_background( views::Background::CreateSolidBackground(255, 255, 255)); ContainerWin::Init(NULL, bounds, true); @@ -250,9 +250,9 @@ void TestViewWindow::Init() { cb->SetID(kTopCheckBoxID); views::View* left_container = new views::View(); - left_container->SetBorder( + left_container->set_border( views::Border::CreateSolidBorder(1, SK_ColorBLACK)); - left_container->SetBackground( + left_container->set_background( views::Background::CreateSolidBackground(240, 240, 240)); left_container->SetID(kLeftContainerID); contents_->AddChildView(left_container); @@ -330,9 +330,9 @@ void TestViewWindow::Init() { left_container->AddChildView(cb); views::View* right_container = new views::View(); - right_container->SetBorder( + right_container->set_border( views::Border::CreateSolidBorder(1, SK_ColorBLACK)); - right_container->SetBackground( + right_container->set_background( views::Background::CreateSolidBackground(240, 240, 240)); right_container->SetID(kRightContainerID); contents_->AddChildView(right_container); @@ -362,9 +362,9 @@ void TestViewWindow::Init() { y += radio_button_height + gap_between_radio_buttons; views::View* inner_container = new views::View(); - inner_container->SetBorder( + inner_container->set_border( views::Border::CreateSolidBorder(1, SK_ColorBLACK)); - inner_container->SetBackground( + inner_container->set_background( views::Background::CreateSolidBackground(230, 230, 230)); inner_container->SetID(kInnerContainerID); right_container->AddChildView(inner_container); @@ -377,7 +377,7 @@ void TestViewWindow::Init() { views::View* scroll_content = new views::View(); scroll_content->SetBounds(0, 0, 200, 200); - scroll_content->SetBackground( + scroll_content->set_background( views::Background::CreateSolidBackground(200, 200, 200)); scroll_view->SetContents(scroll_content); @@ -429,7 +429,7 @@ void TestViewWindow::Init() { // Left bottom box with style checkboxes. views::View* contents = new views::View(); - contents->SetBackground( + contents->set_background( views::Background::CreateSolidBackground(SK_ColorWHITE)); cb = new views::CheckBox(L"Bold"); contents->AddChildView(cb); @@ -455,7 +455,7 @@ void TestViewWindow::Init() { // Right bottom box with search. contents = new views::View(); - contents->SetBackground( + contents->set_background( views::Background::CreateSolidBackground(SK_ColorWHITE)); text_field = new views::TextField(); contents->AddChildView(text_field); @@ -483,7 +483,7 @@ void TestViewWindow::Init() { contents = new views::View(); contents->SetFocusable(true); - contents->SetBackground( + contents->set_background( views::Background::CreateSolidBackground(SK_ColorBLUE)); contents->SetID(kThumbnailContainerID); button = new views::NativeButton(L"Star"); diff --git a/chrome/views/label.cc b/chrome/views/label.cc index 27f30d2..d63e2f0 100644 --- a/chrome/views/label.cc +++ b/chrome/views/label.cc @@ -148,7 +148,7 @@ void Label::Paint(ChromeCanvas* canvas) { void Label::PaintBackground(ChromeCanvas* canvas) { const Background* bg = contains_mouse_ ? GetMouseOverBackground() : NULL; if (!bg) - bg = GetBackground(); + bg = background(); if (bg) bg->Paint(canvas, this); } diff --git a/chrome/views/label_unittest.cc b/chrome/views/label_unittest.cc index b02ee9b..aec1b9b 100644 --- a/chrome/views/label_unittest.cc +++ b/chrome/views/label_unittest.cc @@ -155,10 +155,10 @@ TEST(LabelTest, SingleLineSizing) { // Test everything with borders.
gfx::Insets border(10, 20, 30, 40);
- label.SetBorder(Border::CreateEmptyBorder(border.top(),
- border.left(),
- border.bottom(),
- border.right()));
+ label.set_border(Border::CreateEmptyBorder(border.top(),
+ border.left(),
+ border.bottom(),
+ border.right()));
// GetPreferredSize and borders.
label.SetBounds(0, 0, 0, 0);
@@ -208,10 +208,10 @@ TEST(LabelTest, MultiLineSizing) { // Test everything with borders.
gfx::Insets border(10, 20, 30, 40);
- label.SetBorder(Border::CreateEmptyBorder(border.top(),
- border.left(),
- border.bottom(),
- border.right()));
+ label.set_border(Border::CreateEmptyBorder(border.top(),
+ border.left(),
+ border.bottom(),
+ border.right()));
// SizeToFit and borders.
label.SizeToFit(0);
@@ -298,10 +298,10 @@ TEST(LabelTest, DrawSingleLineString) { // Test single line drawing with a border.
gfx::Insets border(39, 34, 8, 96);
- label.SetBorder(Border::CreateEmptyBorder(border.top(),
- border.left(),
- border.bottom(),
- border.right()));
+ label.set_border(Border::CreateEmptyBorder(border.top(),
+ border.left(),
+ border.bottom(),
+ border.right()));
gfx::Size required_size_with_border(label.GetPreferredSize());
EXPECT_EQ(required_size.width() + border.width(),
@@ -402,10 +402,10 @@ TEST(LabelTest, DrawMultiLineString) { // Test multiline drawing with a border.
gfx::Insets border(19, 92, 23, 2);
- label.SetBorder(Border::CreateEmptyBorder(border.top(),
- border.left(),
- border.bottom(),
- border.right()));
+ label.set_border(Border::CreateEmptyBorder(border.top(),
+ border.left(),
+ border.bottom(),
+ border.right()));
label.SizeToFit(0);
label.SetHorizontalAlignment(Label::ALIGN_CENTER);
paint_text.clear();
diff --git a/chrome/views/native_control.cc b/chrome/views/native_control.cc index c2816be..fd81b4f 100644 --- a/chrome/views/native_control.cc +++ b/chrome/views/native_control.cc @@ -134,7 +134,7 @@ class NativeControlContainer : public CWindowImpl<NativeControlContainer, LRESULT OnCtlColor(UINT msg, HDC dc, HWND control) { const View *ancestor = parent_; while (ancestor) { - const Background *background = ancestor->GetBackground(); + const Background *background = ancestor->background(); if (background) { HBRUSH brush = background->GetNativeControlBrush(); if (brush) diff --git a/chrome/views/tabbed_pane.cc b/chrome/views/tabbed_pane.cc index 85baaf4..bab0d72 100644 --- a/chrome/views/tabbed_pane.cc +++ b/chrome/views/tabbed_pane.cc @@ -85,8 +85,8 @@ void TabbedPane::AddTabAtIndex(int index, int result = TabCtrl_InsertItem(tab_control_, index, &tcitem); DCHECK(result != -1); - if (!contents->GetBackground()) { - contents->SetBackground(new TabBackground); + if (!contents->background()) { + contents->set_background(new TabBackground); } if (tab_views_.size() == 1 && select_if_first_tab) { @@ -181,7 +181,7 @@ HWND TabbedPane::CreateNativeControl(HWND parent_container) { DWORD sys_color = ::GetSysColor(COLOR_3DHILIGHT); SkColor color = SkColorSetRGB(GetRValue(sys_color), GetGValue(sys_color), GetBValue(sys_color)); - root_view->SetBackground(Background::CreateSolidBackground(color)); + root_view->set_background(Background::CreateSolidBackground(color)); content_window_->SetFocusTraversableParentView(this); ResizeContents(tab_control_); diff --git a/chrome/views/text_button.cc b/chrome/views/text_button.cc index be9a221..a64c2fd 100644 --- a/chrome/views/text_button.cc +++ b/chrome/views/text_button.cc @@ -150,7 +150,7 @@ TextButton::TextButton(const std::wstring& text) max_width_(0), alignment_(ALIGN_LEFT) { SetText(text); - SetBorder(new TextButtonBorder); + set_border(new TextButtonBorder); SetAnimationDuration(kHoverAnimationDurationMs); } diff --git a/chrome/views/view.cc b/chrome/views/view.cc index 0ab209a..4525724 100644 --- a/chrome/views/view.cc +++ b/chrome/views/view.cc @@ -75,9 +75,7 @@ View::View() enabled_(true), is_visible_(true), focusable_(false), - background_(NULL), accessibility_(NULL), - border_(NULL), is_parent_owned_(true), notify_when_visible_bounds_in_root_changes_(false), registered_for_visible_bounds_notification_(false), @@ -102,10 +100,6 @@ View::~View() { else child_views_[c]->SetParent(NULL); } - if (background_) - delete background_; - if (border_) - delete border_; } ///////////////////////////////////////////////////////////////////////////// @@ -150,7 +144,7 @@ void View::SetBounds(const gfx::Rect& bounds) { } gfx::Rect View::GetLocalBounds(bool include_border) const { - if (include_border || border_ == NULL) + if (include_border || !border_.get()) return gfx::Rect(0, 0, width(), height()); gfx::Insets insets; @@ -344,12 +338,12 @@ void View::Paint(ChromeCanvas* canvas) { } void View::PaintBackground(ChromeCanvas* canvas) { - if (background_) + if (background_.get()) background_->Paint(canvas, this); } void View::PaintBorder(ChromeCanvas* canvas) { - if (border_) + if (border_.get()) border_->Paint(*this, canvas); } @@ -445,31 +439,10 @@ void View::PaintFloatingView(ChromeCanvas* canvas, View* view, view->SetParent(saved_parent); } -void View::SetBackground(Background* b) { - if (background_ != b) - delete background_; - background_ = b; -} - -const Background* View::GetBackground() const { - return background_; -} - -void View::SetBorder(Border* b) { - if (border_ != b) - delete border_; - border_ = b; -} - -const Border* View::GetBorder() const { - return border_; -} - gfx::Insets View::GetInsets() const { - const Border* border = GetBorder(); gfx::Insets insets; - if (border) - border->GetInsets(&insets); + if (border_.get()) + border_->GetInsets(&insets); return insets; } diff --git a/chrome/views/view.h b/chrome/views/view.h index b98951f..d6b16ce 100644 --- a/chrome/views/view.h +++ b/chrome/views/view.h @@ -15,6 +15,8 @@ #include "base/gfx/rect.h" #include "base/scoped_ptr.h" #include "chrome/views/accelerator.h" +#include "chrome/views/background.h" +#include "chrome/views/border.h" namespace gfx { class Insets; @@ -877,17 +879,13 @@ class View : public AcceleratorTarget { int y, bool is_mouse_gesture); - // Set the background. The background is owned by the view after this call. - virtual void SetBackground(Background* b); + // The background object is owned by this object and may be NULL. + void set_background(Background* b) { background_.reset(b); } + const Background* background() const { return background_.get(); } - // Return the background currently in use or NULL. - virtual const Background* GetBackground() const; - - // Set the border. The border is owned by the view after this call. - virtual void SetBorder(Border* b); - - // Return the border currently in use or NULL. - virtual const Border* GetBorder() const; + // The border object is owned by this object and may be NULL. + void set_border(Border* b) { border_.reset(b); } + const Border* border() const { return border_.get(); } // Returns the insets of the current border. If there is no border an empty // insets is returned. @@ -1256,10 +1254,10 @@ class View : public AcceleratorTarget { bool is_visible_; // Background - Background* background_; + scoped_ptr<Background> background_; // Border. - Border* border_; + scoped_ptr<Border> border_; // Whether this view is owned by its parent. bool is_parent_owned_; |