diff options
author | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-09 16:52:00 +0000 |
---|---|---|
committer | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-09 16:52:00 +0000 |
commit | 8eb52a9ae0407aa717113d48b540b1abdb0616e8 (patch) | |
tree | 358644668ef2e16d94c86d04b56bb7c1e8673c4e | |
parent | 470ed45abe7452e9f72122e0273cc0506114860a (diff) | |
download | chromium_src-8eb52a9ae0407aa717113d48b540b1abdb0616e8.zip chromium_src-8eb52a9ae0407aa717113d48b540b1abdb0616e8.tar.gz chromium_src-8eb52a9ae0407aa717113d48b540b1abdb0616e8.tar.bz2 |
This will help minimize the area we paint various views, including BrowserView in cros. Before the default when a child's preferred view size changed was to propagate it up and
paint everything from the rootview down. This will limit the area to the parts that actually changed size.
I expect we may find things that aren't being painted because they were assuming the behavior of Layout(). We should fix this as necessary.
Also, a subsequent change will minimize our calls to SchedulePaint(). We frequently do it when we don't need to.
BUG=None
TEST=ViewTest.SetBoundsPaint
Review URL: http://codereview.chromium.org/6531032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77481 0039d316-1c4b-4281-b951-d872f2087c98
33 files changed, 273 insertions, 236 deletions
diff --git a/chrome/browser/chromeos/frame/browser_view.cc b/chrome/browser/chromeos/frame/browser_view.cc index 8a0b678..f41ccfc 100644 --- a/chrome/browser/chromeos/frame/browser_view.cc +++ b/chrome/browser/chromeos/frame/browser_view.cc @@ -276,7 +276,6 @@ views::LayoutManager* BrowserView::CreateLayoutManager() const { void BrowserView::ChildPreferredSizeChanged(View* child) { Layout(); - SchedulePaint(); } bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const { diff --git a/chrome/browser/chromeos/input_method/candidate_window.cc b/chrome/browser/chromeos/input_method/candidate_window.cc index f142a9f..aacee58 100644 --- a/chrome/browser/chromeos/input_method/candidate_window.cc +++ b/chrome/browser/chromeos/input_method/candidate_window.cc @@ -421,10 +421,10 @@ class CandidateWindowView : public views::View { protected: // Override View::VisibilityChanged() - virtual void VisibilityChanged(View* starting_from, bool is_visible); + virtual void VisibilityChanged(View* starting_from, bool is_visible) OVERRIDE; // Override View::OnBoundsChanged() - virtual void OnBoundsChanged(); + virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; private: // Initializes the candidate views if needed. @@ -1248,10 +1248,10 @@ void CandidateWindowView::VisibilityChanged(View* starting_from, } } -void CandidateWindowView::OnBoundsChanged() { +void CandidateWindowView::OnBoundsChanged(const gfx::Rect& previous_bounds) { // If the bounds(size) of candidate window is changed, // we should move the frame to the right position. - View::OnBoundsChanged(); + View::OnBoundsChanged(previous_bounds); MoveParentFrame(); } diff --git a/chrome/browser/ui/views/extensions/extension_view.cc b/chrome/browser/ui/views/extensions/extension_view.cc index ffff940..891b4bc 100644 --- a/chrome/browser/ui/views/extensions/extension_view.cc +++ b/chrome/browser/ui/views/extensions/extension_view.cc @@ -74,14 +74,6 @@ void ExtensionView::SetVisible(bool is_visible) { } } -void ExtensionView::OnBoundsChanged() { - View::OnBoundsChanged(); - // Propagate the new size to RenderWidgetHostView. - // We can't send size zero because RenderWidget DCHECKs that. - if (render_view_host()->view() && !bounds().IsEmpty()) - render_view_host()->view()->SetSize(size()); -} - void ExtensionView::CreateWidgetHostView() { DCHECK(!initialized_); initialized_ = true; @@ -180,6 +172,13 @@ bool ExtensionView::SkipDefaultKeyEventProcessing(const views::KeyEvent& e) { return (e.key_code() == ui::VKEY_TAB); } +void ExtensionView::OnBoundsChanged(const gfx::Rect& previous_bounds) { + // Propagate the new size to RenderWidgetHostView. + // We can't send size zero because RenderWidget DCHECKs that. + if (render_view_host()->view() && !bounds().IsEmpty()) + render_view_host()->view()->SetSize(size()); +} + void ExtensionView::HandleMouseMove() { if (container_) container_->OnExtensionMouseMove(this); diff --git a/chrome/browser/ui/views/extensions/extension_view.h b/chrome/browser/ui/views/extensions/extension_view.h index baee1550..b7d82e2 100644 --- a/chrome/browser/ui/views/extensions/extension_view.h +++ b/chrome/browser/ui/views/extensions/extension_view.h @@ -57,15 +57,15 @@ class ExtensionView : public views::NativeViewHost { void SetContainer(Container* container) { container_ = container; } // Overridden from views::NativeViewHost: - virtual void SetVisible(bool is_visible); - virtual void OnBoundsChanged(); - virtual void ViewHierarchyChanged(bool is_add, - views::View *parent, views::View *child); + virtual void SetVisible(bool is_visible) OVERRIDE; + virtual void ViewHierarchyChanged( + bool is_add, views::View *parent, views::View *child) OVERRIDE; protected: // Overridden from views::View. - virtual void PreferredSizeChanged(); - virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e); + virtual void PreferredSizeChanged() OVERRIDE; + virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e) OVERRIDE; + virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; private: friend class ExtensionHost; diff --git a/chrome/browser/ui/views/infobars/infobar_view.cc b/chrome/browser/ui/views/infobars/infobar_view.cc index b6d930d..74db095 100644 --- a/chrome/browser/ui/views/infobars/infobar_view.cc +++ b/chrome/browser/ui/views/infobars/infobar_view.cc @@ -351,8 +351,7 @@ gfx::Size InfoBarView::GetPreferredSize() { return gfx::Size(0, AnimatedTabHeight() + AnimatedBarHeight()); } -void InfoBarView::OnBoundsChanged() { - views::View::OnBoundsChanged(); +void InfoBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { int tab_height = AnimatedTabHeight(); int bar_height = AnimatedBarHeight(); int divider_y = tab_height - 1; diff --git a/chrome/browser/ui/views/infobars/infobar_view.h b/chrome/browser/ui/views/infobars/infobar_view.h index 519763b..5729242 100644 --- a/chrome/browser/ui/views/infobars/infobar_view.h +++ b/chrome/browser/ui/views/infobars/infobar_view.h @@ -102,14 +102,16 @@ class InfoBarView : public InfoBar, bool needs_elevation); // views::View: - virtual void Layout(); - virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); + virtual void Layout() OVERRIDE; + virtual void ViewHierarchyChanged( + bool is_add, View* parent, View* child) OVERRIDE; // views::ButtonListener: - virtual void ButtonPressed(views::Button* sender, const views::Event& event); + virtual void ButtonPressed( + views::Button* sender, const views::Event& event) OVERRIDE; // ui::AnimationDelegate: - virtual void AnimationProgressed(const ui::Animation* animation); + virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; // Returns the minimum width the content (that is, everything between the icon // and the close button) can be shrunk to. This is used to prevent the close @@ -144,16 +146,17 @@ class InfoBarView : public InfoBar, static const int kTabWidth; // views::View: - virtual AccessibilityTypes::Role GetAccessibleRole(); - virtual gfx::Size GetPreferredSize(); - virtual void OnBoundsChanged(); - virtual void PaintChildren(gfx::Canvas* canvas); + virtual AccessibilityTypes::Role GetAccessibleRole() OVERRIDE; + virtual gfx::Size GetPreferredSize() OVERRIDE; + virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; + virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; // views::FocusChangeListener: - virtual void FocusWillChange(View* focused_before, View* focused_now); + virtual void FocusWillChange( + View* focused_before, View* focused_now) OVERRIDE; // ui::AnimationDelegate: - virtual void AnimationEnded(const ui::Animation* animation); + virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; // Returns a centered y-position of a control of height specified in // |prefsize| within the standard InfoBar height. Stable during an animation. diff --git a/chrome/browser/ui/views/notifications/balloon_view.cc b/chrome/browser/ui/views/notifications/balloon_view.cc index 8d741c0..3fdb610 100644 --- a/chrome/browser/ui/views/notifications/balloon_view.cc +++ b/chrome/browser/ui/views/notifications/balloon_view.cc @@ -165,10 +165,6 @@ void BalloonViewImpl::DelayedClose(bool by_user) { balloon_->OnClose(by_user); } -void BalloonViewImpl::OnBoundsChanged() { - SizeContentsWindow(); -} - gfx::Size BalloonViewImpl::GetPreferredSize() { return gfx::Size(1000, 1000); } @@ -493,6 +489,10 @@ void BalloonViewImpl::OnPaint(gfx::Canvas* canvas) { OnPaintBorder(canvas); } +void BalloonViewImpl::OnBoundsChanged(const gfx::Rect& previous_bounds) { + SizeContentsWindow(); +} + void BalloonViewImpl::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { diff --git a/chrome/browser/ui/views/notifications/balloon_view.h b/chrome/browser/ui/views/notifications/balloon_view.h index 17c5e36..a956d6a 100644 --- a/chrome/browser/ui/views/notifications/balloon_view.h +++ b/chrome/browser/ui/views/notifications/balloon_view.h @@ -57,36 +57,37 @@ class BalloonViewImpl : public BalloonView, ~BalloonViewImpl(); // BalloonView interface. - virtual void Show(Balloon* balloon); - virtual void Update(); - virtual void RepositionToBalloon(); - virtual void Close(bool by_user); - virtual gfx::Size GetSize() const; - virtual BalloonHost* GetHost() const; + virtual void Show(Balloon* balloon) OVERRIDE; + virtual void Update() OVERRIDE; + virtual void RepositionToBalloon() OVERRIDE; + virtual void Close(bool by_user) OVERRIDE; + virtual gfx::Size GetSize() const OVERRIDE; + virtual BalloonHost* GetHost() const OVERRIDE; private: // views::View interface. - virtual void OnPaint(gfx::Canvas* canvas); - virtual void OnBoundsChanged(); - virtual gfx::Size GetPreferredSize(); + virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; + virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; + virtual gfx::Size GetPreferredSize() OVERRIDE; // views::ViewMenuDelegate interface. - virtual void RunMenu(views::View* source, const gfx::Point& pt); + virtual void RunMenu(views::View* source, const gfx::Point& pt) OVERRIDE; // views::WidgetDelegate interface. - virtual void DisplayChanged(); - virtual void WorkAreaChanged(); + virtual void DisplayChanged() OVERRIDE; + virtual void WorkAreaChanged() OVERRIDE; // views::ButtonListener interface. - virtual void ButtonPressed(views::Button* sender, const views::Event&); + virtual void ButtonPressed( + views::Button* sender, const views::Event&) OVERRIDE; // NotificationObserver interface. virtual void Observe(NotificationType type, const NotificationSource& source, - const NotificationDetails& details); + const NotificationDetails& details) OVERRIDE; // ui::AnimationDelegate interface. - virtual void AnimationProgressed(const ui::Animation* animation); + virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; // Launches the options menu at screen coordinates |pt|. void RunOptionsMenu(const gfx::Point& pt); diff --git a/chrome/browser/ui/views/options/advanced_contents_view.cc b/chrome/browser/ui/views/options/advanced_contents_view.cc index d84edda..96ced98 100644 --- a/chrome/browser/ui/views/options/advanced_contents_view.cc +++ b/chrome/browser/ui/views/options/advanced_contents_view.cc @@ -1519,7 +1519,6 @@ class AdvancedContentsView : public OptionsPageView { virtual int GetLineScrollIncrement(views::ScrollView* scroll_view, bool is_horizontal, bool is_positive); virtual void Layout(); - virtual void OnBoundsChanged(); protected: // OptionsPageView implementation: @@ -1572,11 +1571,6 @@ void AdvancedContentsView::Layout() { View::Layout(); } -void AdvancedContentsView::OnBoundsChanged() { - // Override to do nothing. Calling Layout() interferes with our scrolling. -} - - //////////////////////////////////////////////////////////////////////////////// // AdvancedContentsView, OptionsPageView implementation: diff --git a/chrome/browser/ui/views/options/advanced_contents_view.h b/chrome/browser/ui/views/options/advanced_contents_view.h index eda31a0..2e1b40e 100644 --- a/chrome/browser/ui/views/options/advanced_contents_view.h +++ b/chrome/browser/ui/views/options/advanced_contents_view.h @@ -24,7 +24,7 @@ class AdvancedScrollViewContainer : public views::View { virtual ~AdvancedScrollViewContainer(); // views::View overrides: - virtual void Layout(); + virtual void Layout() OVERRIDE; private: // The contents of the advanced scroll view. diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.cc index d0cabba..2b2bdb9 100644 --- a/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.cc +++ b/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.cc @@ -239,8 +239,13 @@ void TabContentsViewGtk::SetPageTitle(const std::wstring& title) { gdk_window_set_title(content_view->window, WideToUTF8(title).c_str()); } -void TabContentsViewGtk::OnTabCrashed(base::TerminationStatus /* status */, +void TabContentsViewGtk::OnTabCrashed(base::TerminationStatus status, int /* error_code */) { + SadTabView::Kind kind = + status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ? + SadTabView::KILLED : SadTabView::CRASHED; + sad_tab_ = new SadTabView(tab_contents(), kind); + SetContentsView(sad_tab_); } void TabContentsViewGtk::SizeContents(const gfx::Size& size) { @@ -402,16 +407,8 @@ void TabContentsViewGtk::OnSizeAllocate(GtkWidget* widget, gboolean TabContentsViewGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) { if (tab_contents()->render_view_host() && - !tab_contents()->render_view_host()->IsRenderViewLive()) { - base::TerminationStatus status = - tab_contents()->render_view_host()->render_view_termination_status(); - SadTabView::Kind kind = - status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ? - SadTabView::KILLED : SadTabView::CRASHED; - sad_tab_ = new SadTabView(tab_contents(), kind); - SetContentsView(sad_tab_); - gfx::Rect bounds = GetWindowScreenBounds(); - sad_tab_->SetBoundsRect(gfx::Rect(0, 0, bounds.width(), bounds.height())); + !tab_contents()->render_view_host()->IsRenderViewLive() && + sad_tab_) { gfx::CanvasSkiaPaint canvas(event); sad_tab_->Paint(&canvas); } @@ -449,6 +446,8 @@ void TabContentsViewGtk::WasSized(const gfx::Size& size) { RenderWidgetHostView* rwhv = tab_contents()->GetRenderWidgetHostView(); if (rwhv && rwhv->GetViewBounds().size() != size) rwhv->SetSize(size); + if (sad_tab_ && sad_tab_->size() != size) + sad_tab_->SetSize(size); if (needs_resize) SetFloatingPosition(size); diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc b/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc index 0de03cd..224517f 100644 --- a/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc +++ b/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc @@ -225,7 +225,7 @@ void TabContentsViewViews::GetViewBounds(gfx::Rect* out) const { out->SetRect(x(), y(), width(), height()); } -void TabContentsViewViews::OnBoundsChanged() { +void TabContentsViewViews::OnBoundsChanged(const gfx::Rect& previous_bounds) { if (IsVisibleInRootView()) WasSized(size()); } diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_view_views.h b/chrome/browser/ui/views/tab_contents/tab_contents_view_views.h index 687bcad..327c9a9 100644 --- a/chrome/browser/ui/views/tab_contents/tab_contents_view_views.h +++ b/chrome/browser/ui/views/tab_contents/tab_contents_view_views.h @@ -44,26 +44,26 @@ class TabContentsViewViews : public TabContentsView, public views::View { void RemoveConstrainedWindow(ConstrainedWindowGtk* constrained_window); // TabContentsView implementation - virtual void CreateView(const gfx::Size& initial_size); + virtual void CreateView(const gfx::Size& initial_size) OVERRIDE; virtual RenderWidgetHostView* CreateViewForWidget( - RenderWidgetHost* render_widget_host); - virtual gfx::NativeView GetNativeView() const; - virtual gfx::NativeView GetContentNativeView() const; - virtual gfx::NativeWindow GetTopLevelNativeWindow() const; - virtual void GetContainerBounds(gfx::Rect* out) const; - virtual void SetPageTitle(const std::wstring& title); + RenderWidgetHost* render_widget_host) OVERRIDE; + virtual gfx::NativeView GetNativeView() const OVERRIDE; + virtual gfx::NativeView GetContentNativeView() const OVERRIDE; + virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; + virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE; + virtual void SetPageTitle(const std::wstring& title) OVERRIDE; virtual void OnTabCrashed(base::TerminationStatus status, - int error_code); - virtual void SizeContents(const gfx::Size& size); - virtual void Focus(); - virtual void SetInitialFocus(); - virtual void StoreFocus(); - virtual void RestoreFocus(); - virtual void GetViewBounds(gfx::Rect* out) const; + int error_code) OVERRIDE; + virtual void SizeContents(const gfx::Size& size) OVERRIDE; + virtual void Focus() OVERRIDE; + virtual void SetInitialFocus() OVERRIDE; + virtual void StoreFocus() OVERRIDE; + virtual void RestoreFocus() OVERRIDE; + virtual void GetViewBounds(gfx::Rect* out) const OVERRIDE; // views::View implementation - virtual void OnBoundsChanged(); - virtual void OnPaint(gfx::Canvas* canvas); + virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; + virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; // Backend implementation of RenderViewHostDelegate::View. virtual void ShowContextMenu(const ContextMenuParams& params); @@ -72,15 +72,15 @@ class TabContentsViewViews : public TabContentsView, public views::View { double item_font_size, int selected_item, const std::vector<WebMenuItem>& items, - bool right_aligned); + bool right_aligned) OVERRIDE; virtual void StartDragging(const WebDropData& drop_data, WebKit::WebDragOperationsMask ops_allowed, const SkBitmap& image, - const gfx::Point& image_offset); - virtual void UpdateDragCursor(WebKit::WebDragOperation operation); - virtual void GotFocus(); - virtual void TakeFocus(bool reverse); - virtual void VisibilityChanged(views::View *, bool is_visible); + const gfx::Point& image_offset) OVERRIDE; + virtual void UpdateDragCursor(WebKit::WebDragOperation operation) OVERRIDE; + virtual void GotFocus() OVERRIDE; + virtual void TakeFocus(bool reverse) OVERRIDE; + virtual void VisibilityChanged(views::View *, bool is_visible) OVERRIDE; private: // Signal handlers ----------------------------------------------------------- diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_view_win.cc b/chrome/browser/ui/views/tab_contents/tab_contents_view_win.cc index 4307447..0aa71e6 100644 --- a/chrome/browser/ui/views/tab_contents/tab_contents_view_win.cc +++ b/chrome/browser/ui/views/tab_contents/tab_contents_view_win.cc @@ -182,13 +182,18 @@ void TabContentsViewWin::SetPageTitle(const std::wstring& title) { } } -void TabContentsViewWin::OnTabCrashed(base::TerminationStatus /* status */, +void TabContentsViewWin::OnTabCrashed(base::TerminationStatus status, int /* error_code */) { - // Force an invalidation to render sad tab. We will notice we crashed when we - // paint. + // Force an invalidation to render sad tab. // Note that it's possible to get this message after the window was destroyed. - if (::IsWindow(GetNativeView())) + if (::IsWindow(GetNativeView())) { + SadTabView::Kind kind = + status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ? + SadTabView::KILLED : SadTabView::CRASHED; + sad_tab_ = new SadTabView(tab_contents(), kind); + SetContentsView(sad_tab_); InvalidateRect(GetNativeView(), NULL, FALSE); + } } void TabContentsViewWin::SizeContents(const gfx::Size& size) { @@ -436,18 +441,7 @@ LRESULT TabContentsViewWin::OnMouseRange(UINT msg, void TabContentsViewWin::OnPaint(HDC junk_dc) { if (tab_contents()->render_view_host() && !tab_contents()->render_view_host()->IsRenderViewLive()) { - base::TerminationStatus status = - tab_contents()->render_view_host()->render_view_termination_status(); - SadTabView::Kind kind = - status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ? - SadTabView::KILLED : SadTabView::CRASHED; - sad_tab_ = new SadTabView(tab_contents(), kind); - SetContentsView(sad_tab_); - CRect cr; - GetClientRect(&cr); - sad_tab_->SetBoundsRect(gfx::Rect(cr)); - gfx::CanvasSkiaPaint canvas(GetNativeView(), true); - sad_tab_->Paint(&canvas); + WidgetWin::OnPaint(junk_dc); return; } @@ -568,6 +562,9 @@ void TabContentsViewWin::WasSized(const gfx::Size& size) { RenderWidgetHostView* rwhv = tab_contents()->GetRenderWidgetHostView(); if (rwhv) rwhv->SetSize(size); + // TODO(beng) This really shouldn't be necessary but currently is. + if (sad_tab_ && sad_tab_->size() != size) + sad_tab_->SetSize(size); // We have to layout root view here because we handle OnWindowPosChanged // without calling DefWindowProc (it sends OnSize and OnMove) so we don't diff --git a/views/controls/label.cc b/views/controls/label.cc index 5bc1a2a..a428bcd 100644 --- a/views/controls/label.cc +++ b/views/controls/label.cc @@ -73,10 +73,6 @@ int Label::GetHeightForWidth(int w) { return h + GetInsets().height(); } -void Label::OnBoundsChanged() { - text_size_valid_ &= !is_multi_line_; -} - std::string Label::GetClassName() const { return kViewClassName; } @@ -316,6 +312,10 @@ gfx::Size Label::GetTextSize() const { return text_size_; } +void Label::OnBoundsChanged(const gfx::Rect& previous_bounds) { + text_size_valid_ &= !is_multi_line_; +} + // static gfx::Font Label::GetDefaultFont() { return ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont); diff --git a/views/controls/label.h b/views/controls/label.h index 017b33c7..a3bef8f 100644 --- a/views/controls/label.h +++ b/views/controls/label.h @@ -55,28 +55,25 @@ class Label : public View { virtual ~Label(); // Overridden to compute the size required to display this label. - virtual gfx::Size GetPreferredSize(); + virtual gfx::Size GetPreferredSize() OVERRIDE; // Overriden to return the baseline of the label. - virtual int GetBaseline(); + virtual int GetBaseline() OVERRIDE; // Return the height necessary to display this label with the provided width. // This method is used to layout multi-line labels. It is equivalent to // GetPreferredSize().height() if the receiver is not multi-line. virtual int GetHeightForWidth(int w); - // Overriden to dirty our text bounds if we're multi-line. - virtual void OnBoundsChanged(); - // Returns views/Label. - virtual std::string GetClassName() const; + virtual std::string GetClassName() const OVERRIDE; // Overridden to paint - virtual void OnPaint(gfx::Canvas* canvas); + virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; // If the mouse is over the label, and a mouse over background has been // specified, its used. Otherwise super's implementation is invoked. - virtual void OnPaintBackground(gfx::Canvas* canvas); + virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; // Set the font. void SetFont(const gfx::Font& font); @@ -166,7 +163,7 @@ class Label : public View { const Background* GetMouseOverBackground() const; // Sets the enabled state. Setting the enabled state resets the color. - virtual void SetEnabled(bool enabled); + virtual void SetEnabled(bool enabled) OVERRIDE; // Overridden from View: virtual gfx::Insets GetInsets() const; @@ -180,8 +177,8 @@ class Label : public View { void SizeToFit(int max_width); // Accessibility accessors, overridden from View. - virtual AccessibilityTypes::Role GetAccessibleRole(); - virtual AccessibilityTypes::State GetAccessibleState(); + virtual AccessibilityTypes::Role GetAccessibleRole() OVERRIDE; + virtual AccessibilityTypes::State GetAccessibleState() OVERRIDE; // Gets/sets the flag to determine whether the label should be collapsed when // it's hidden (not visible). If this flag is true, the label will return a @@ -208,6 +205,10 @@ class Label : public View { void invalidate_text_size() { text_size_valid_ = false; } virtual gfx::Size GetTextSize() const; + + // Overriden to dirty our text bounds if we're multi-line. + virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; + private: // These tests call CalculateDrawStringParams in order to verify the // calculations done for drawing text. diff --git a/views/controls/menu/menu_scroll_view_container.cc b/views/controls/menu/menu_scroll_view_container.cc index 6089838..28ce10a 100644 --- a/views/controls/menu/menu_scroll_view_container.cc +++ b/views/controls/menu/menu_scroll_view_container.cc @@ -252,13 +252,6 @@ void MenuScrollViewContainer::Layout() { scroll_view_->Layout(); } -void MenuScrollViewContainer::OnBoundsChanged() { - gfx::Size content_pref = scroll_view_->GetContents()->GetPreferredSize(); - scroll_up_button_->SetVisible(content_pref.height() > height()); - scroll_down_button_->SetVisible(content_pref.height() > height()); - Layout(); -} - gfx::Size MenuScrollViewContainer::GetPreferredSize() { gfx::Size prefsize = scroll_view_->GetContents()->GetPreferredSize(); gfx::Insets insets = GetInsets(); @@ -276,4 +269,12 @@ AccessibilityTypes::State MenuScrollViewContainer::GetAccessibleState() { return AccessibilityTypes::STATE_FOCUSED; } +void MenuScrollViewContainer::OnBoundsChanged( + const gfx::Rect& previous_bounds) { + gfx::Size content_pref = scroll_view_->GetContents()->GetPreferredSize(); + scroll_up_button_->SetVisible(content_pref.height() > height()); + scroll_down_button_->SetVisible(content_pref.height() > height()); + Layout(); +} + } // namespace views diff --git a/views/controls/menu/menu_scroll_view_container.h b/views/controls/menu/menu_scroll_view_container.h index 5472091..d6ca679 100644 --- a/views/controls/menu/menu_scroll_view_container.h +++ b/views/controls/menu/menu_scroll_view_container.h @@ -24,12 +24,15 @@ class MenuScrollViewContainer : public View { View* scroll_up_button() const { return scroll_up_button_; } // View overrides. - virtual void OnPaintBackground(gfx::Canvas* canvas); - virtual void Layout(); - virtual void OnBoundsChanged(); - virtual gfx::Size GetPreferredSize(); - virtual AccessibilityTypes::Role GetAccessibleRole(); - virtual AccessibilityTypes::State GetAccessibleState(); + virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; + virtual void Layout() OVERRIDE; + virtual gfx::Size GetPreferredSize() OVERRIDE; + virtual AccessibilityTypes::Role GetAccessibleRole() OVERRIDE; + virtual AccessibilityTypes::State GetAccessibleState() OVERRIDE; + + protected: + // View override. + virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; private: class MenuScrollView; diff --git a/views/controls/menu/submenu_view.cc b/views/controls/menu/submenu_view.cc index f3ecaea..9e2214a 100644 --- a/views/controls/menu/submenu_view.cc +++ b/views/controls/menu/submenu_view.cc @@ -121,10 +121,6 @@ gfx::Size SubmenuView::GetPreferredSize() { height + insets.height()); } -void SubmenuView::OnBoundsChanged() { - SchedulePaint(); -} - AccessibilityTypes::Role SubmenuView::GetAccessibleRole() { return AccessibilityTypes::ROLE_MENUPOPUP; } @@ -327,6 +323,10 @@ std::string SubmenuView::GetClassName() const { return kViewClassName; } +void SubmenuView::OnBoundsChanged(const gfx::Rect& previous_bounds) { + SchedulePaint(); +} + void SubmenuView::PaintDropIndicator(gfx::Canvas* canvas, MenuItemView* item, MenuDelegate::DropPosition position) { diff --git a/views/controls/menu/submenu_view.h b/views/controls/menu/submenu_view.h index 792189f..61e42b5 100644 --- a/views/controls/menu/submenu_view.h +++ b/views/controls/menu/submenu_view.h @@ -50,32 +50,28 @@ class SubmenuView : public View { // Positions and sizes the child views. This tiles the views vertically, // giving each child the available width. - virtual void Layout(); - virtual gfx::Size GetPreferredSize(); - - // View method. Overridden to schedule a paint. We do this so that when - // scrolling occurs, everything is repainted correctly. - virtual void OnBoundsChanged(); + virtual void Layout() OVERRIDE; + virtual gfx::Size GetPreferredSize() OVERRIDE; // Override from View. - virtual AccessibilityTypes::Role GetAccessibleRole(); + virtual AccessibilityTypes::Role GetAccessibleRole() OVERRIDE; // Painting. - virtual void PaintChildren(gfx::Canvas* canvas); + virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; // Drag and drop methods. These are forwarded to the MenuController. virtual bool GetDropFormats( int* formats, - std::set<OSExchangeData::CustomFormat>* custom_formats); - virtual bool AreDropTypesRequired(); + std::set<OSExchangeData::CustomFormat>* custom_formats) OVERRIDE; + virtual bool AreDropTypesRequired() OVERRIDE; virtual bool CanDrop(const OSExchangeData& data); - virtual void OnDragEntered(const DropTargetEvent& event); - virtual int OnDragUpdated(const DropTargetEvent& event); - virtual void OnDragExited(); - virtual int OnPerformDrop(const DropTargetEvent& event); + virtual void OnDragEntered(const DropTargetEvent& event) OVERRIDE; + virtual int OnDragUpdated(const DropTargetEvent& event) OVERRIDE; + virtual void OnDragExited() OVERRIDE; + virtual int OnPerformDrop(const DropTargetEvent& event) OVERRIDE; // Scrolls on menu item boundaries. - virtual bool OnMouseWheel(const MouseWheelEvent& e); + virtual bool OnMouseWheel(const MouseWheelEvent& e) OVERRIDE; // Returns true if the menu is showing. bool IsShowing(); @@ -141,7 +137,13 @@ class SubmenuView : public View { static const int kSubmenuBorderSize; protected: - virtual std::string GetClassName() const; + // View override. + virtual std::string GetClassName() const OVERRIDE; + + // View method. Overridden to schedule a paint. We do this so that when + // scrolling occurs, everything is repainted correctly. + virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; + private: // Paints the drop indicator. This is only invoked if item is non-NULL and diff --git a/views/controls/single_split_view.cc b/views/controls/single_split_view.cc index 2b076d6..7522667 100644 --- a/views/controls/single_split_view.cc +++ b/views/controls/single_split_view.cc @@ -38,13 +38,6 @@ SingleSplitView::SingleSplitView(View* leading, #endif } -void SingleSplitView::OnBoundsChanged() { - divider_offset_ = CalculateDividerOffset(divider_offset_, previous_bounds_, - bounds()); - View::OnBoundsChanged(); - previous_bounds_ = bounds(); -} - void SingleSplitView::Layout() { gfx::Rect leading_bounds; gfx::Rect trailing_bounds; @@ -194,6 +187,11 @@ void SingleSplitView::OnMouseReleased(const MouseEvent& event, bool canceled) { } } +void SingleSplitView::OnBoundsChanged(const gfx::Rect& previous_bounds) { + divider_offset_ = CalculateDividerOffset(divider_offset_, previous_bounds, + bounds()); +} + bool SingleSplitView::IsPointInDivider(const gfx::Point& p) { if (child_count() < 2) return false; diff --git a/views/controls/single_split_view.h b/views/controls/single_split_view.h index dc69c67..5b7f477 100644 --- a/views/controls/single_split_view.h +++ b/views/controls/single_split_view.h @@ -39,18 +39,17 @@ class SingleSplitView : public views::View { Orientation orientation, Observer* observer); - virtual void OnBoundsChanged(); - virtual void Layout(); + virtual void Layout() OVERRIDE; - virtual AccessibilityTypes::Role GetAccessibleRole(); + virtual AccessibilityTypes::Role GetAccessibleRole() OVERRIDE; // SingleSplitView's preferred size is the sum of the preferred widths // and the max of the heights. - virtual gfx::Size GetPreferredSize(); + virtual gfx::Size GetPreferredSize() OVERRIDE; // Overriden to return a resize cursor when over the divider. virtual gfx::NativeCursor GetCursorForPoint(ui::EventType event_type, - const gfx::Point& p); + const gfx::Point& p) OVERRIDE; Orientation orientation() const { return is_horizontal_ ? HORIZONTAL_SPLIT : VERTICAL_SPLIT; @@ -76,9 +75,11 @@ class SingleSplitView : public views::View { gfx::Rect* trailing_bounds) const; protected: - virtual bool OnMousePressed(const MouseEvent& event); - virtual bool OnMouseDragged(const MouseEvent& event); - virtual void OnMouseReleased(const MouseEvent& event, bool canceled); + // View overrides. + virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; + virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; + virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE; + virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; private: // This test calls OnMouse* functions. @@ -123,10 +124,6 @@ class SingleSplitView : public views::View { // Position of the divider. int divider_offset_; - // The bounds of the SingleSplitView as a result of the last resize. Used to - // determine the divider position when a subsequent resize occurs. - gfx::Rect previous_bounds_; - bool resize_leading_on_bounds_change_; // Observer to notify about user initiated handle movements. Not own by us. diff --git a/views/controls/table/table_view.cc b/views/controls/table/table_view.cc index f226cd0..59f5d62 100644 --- a/views/controls/table/table_view.cc +++ b/views/controls/table/table_view.cc @@ -128,17 +128,6 @@ void TableView::SetSortDescriptors(const SortDescriptors& sort_descriptors) { SendMessage(list_view_, WM_SETREDRAW, static_cast<WPARAM>(TRUE), 0); } -void TableView::OnBoundsChanged() { - if (!list_view_) - return; - SendMessage(list_view_, WM_SETREDRAW, static_cast<WPARAM>(FALSE), 0); - Layout(); - if ((autosize_columns_ || !column_sizes_valid_) && width() > 0) - ResetColumnSizes(); - UpdateContentOffset(); - SendMessage(list_view_, WM_SETREDRAW, static_cast<WPARAM>(TRUE), 0); -} - int TableView::RowCount() const { if (!list_view_) return 0; @@ -1511,6 +1500,17 @@ bool TableView::OnKeyDown(ui::KeyboardCode virtual_keycode) { return false; // Let the key event be processed as ususal. } +void TableView::OnBoundsChanged(const gfx::Rect& previous_bounds) { + if (!list_view_) + return; + SendMessage(list_view_, WM_SETREDRAW, static_cast<WPARAM>(FALSE), 0); + Layout(); + if ((autosize_columns_ || !column_sizes_valid_) && width() > 0) + ResetColumnSizes(); + UpdateContentOffset(); + SendMessage(list_view_, WM_SETREDRAW, static_cast<WPARAM>(TRUE), 0); +} + int TableView::PreviousSelectedViewIndex(int view_index) { DCHECK_GE(view_index, 0); if (!list_view_ || view_index <= 0) diff --git a/views/controls/table/table_view.h b/views/controls/table/table_view.h index 620845d..a0181c9 100644 --- a/views/controls/table/table_view.h +++ b/views/controls/table/table_view.h @@ -162,8 +162,6 @@ class TableView : public NativeControl, // Current sort. const SortDescriptors& sort_descriptors() const { return sort_descriptors_; } - virtual void OnBoundsChanged(); - // Returns the number of rows in the TableView. int RowCount() const; @@ -246,7 +244,7 @@ class TableView : public NativeControl, protected: // Overriden to return the position of the first selected row. - virtual gfx::Point GetKeyboardContextMenuLocation(); + virtual gfx::Point GetKeyboardContextMenuLocation() OVERRIDE; // Subclasses that want to customize the colors of a particular row/column, // must invoke this passing in true. The default value is false, such that @@ -264,7 +262,10 @@ class TableView : public NativeControl, virtual void OnMiddleClick(); // Overridden from NativeControl. Notifies the observer. - virtual bool OnKeyDown(ui::KeyboardCode virtual_keycode); + virtual bool OnKeyDown(ui::KeyboardCode virtual_keycode) OVERRIDE; + + // View override. + virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; // Invoked to customize the colors or font at a particular cell. If you // change the colors or font, return true. This is only invoked if diff --git a/views/controls/textfield/native_textfield_views.cc b/views/controls/textfield/native_textfield_views.cc index 4950ebe..775308a 100644 --- a/views/controls/textfield/native_textfield_views.cc +++ b/views/controls/textfield/native_textfield_views.cc @@ -122,10 +122,6 @@ void NativeTextfieldViews::OnPaint(gfx::Canvas* canvas) { OnPaintBorder(canvas); } -void NativeTextfieldViews::OnBoundsChanged() { - UpdateCursorBoundsAndTextOffset(); -} - void NativeTextfieldViews::OnFocus() { NOTREACHED(); } @@ -406,6 +402,10 @@ void NativeTextfieldViews::SetEnableTextfieldViews(bool enabled) { textfield_view_enabled = enabled; } +void NativeTextfieldViews::OnBoundsChanged(const gfx::Rect& previous_bounds) { + UpdateCursorBoundsAndTextOffset(); +} + /////////////////////////////////////////////////////////////////////////////// // NativeTextfieldViews private: diff --git a/views/controls/textfield/native_textfield_views.h b/views/controls/textfield/native_textfield_views.h index 488551d..5a21596 100644 --- a/views/controls/textfield/native_textfield_views.h +++ b/views/controls/textfield/native_textfield_views.h @@ -54,7 +54,6 @@ class NativeTextfieldViews : public views::View, virtual bool OnKeyPressed(const views::KeyEvent& e) OVERRIDE; virtual bool OnKeyReleased(const views::KeyEvent& e) OVERRIDE; virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; - virtual void OnBoundsChanged() OVERRIDE; virtual void OnFocus() OVERRIDE; virtual void OnBlur() OVERRIDE; virtual gfx::NativeCursor GetCursorForPoint(ui::EventType event_type, @@ -119,6 +118,9 @@ class NativeTextfieldViews : public views::View, NONE, }; + protected: + // View override. + virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; private: friend class NativeTextfieldViewsTest; diff --git a/views/view.cc b/views/view.cc index ac5911d..aede253 100644 --- a/views/view.cc +++ b/views/view.cc @@ -214,17 +214,14 @@ void View::SetBoundsRect(const gfx::Rect& bounds) { if (needs_layout_) { needs_layout_ = false; Layout(); + SchedulePaint(); } return; } gfx::Rect prev = bounds_; bounds_ = bounds; - bool size_changed = prev.size() != bounds_.size(); - bool position_changed = prev.origin() != bounds_.origin(); - - if (size_changed || position_changed) - BoundsChanged(); + BoundsChanged(prev); } void View::SetSize(const gfx::Size& size) { @@ -243,11 +240,6 @@ void View::SetY(int y) { SetBounds(x(), y, width(), height()); } -void View::OnBoundsChanged() { - needs_layout_ = false; - Layout(); -} - gfx::Rect View::GetContentsBounds() const { gfx::Rect contents_bounds(GetLocalBounds()); if (border_.get()) { @@ -468,10 +460,8 @@ void View::Layout() { needs_layout_ = false; // If we have a layout manager, let it handle the layout for us. - if (layout_manager_.get()) { + if (layout_manager_.get()) layout_manager_->Layout(this); - SchedulePaint(); - } // Make sure to propagate the Layout() call to any children that haven't // received it yet through the layout manager and need to be laid out. This @@ -1085,6 +1075,9 @@ int View::GetLineScrollIncrement(ScrollView* scroll_view, // Size and disposition -------------------------------------------------------- +void View::OnBoundsChanged(const gfx::Rect& previous_bounds) { +} + void View::PreferredSizeChanged() { InvalidateLayout(); if (parent_) @@ -1361,8 +1354,22 @@ void View::VisibilityChangedImpl(View* starting_from, bool is_visible) { VisibilityChanged(starting_from, is_visible); } -void View::BoundsChanged() { - OnBoundsChanged(); +void View::BoundsChanged(const gfx::Rect& previous_bounds) { + if (parent_) { + parent_->SchedulePaintInRect(previous_bounds); + parent_->SchedulePaintInRect(bounds_); + } else { + // Previous bounds has no meaning to an orphan. This should only happen + // when the View is a RootView. + SchedulePaintInRect(gfx::Rect(0, 0, bounds_.width(), bounds_.height())); + } + + OnBoundsChanged(previous_bounds); + + if (previous_bounds.size() != size()) { + needs_layout_ = false; + Layout(); + } // Notify interested Views that visible bounds within the root view may have // changed. diff --git a/views/view.h b/views/view.h index d32bf02..f0939a3 100644 --- a/views/view.h +++ b/views/view.h @@ -249,9 +249,6 @@ class View : public AcceleratorTarget { void SetX(int x); void SetY(int y); - // Override to be notified when the bounds of the view have changed. - virtual void OnBoundsChanged(); - // No transformation is applied on the size or the locations. const gfx::Rect& bounds() const { return bounds_; } int x() const { return bounds_.x(); } @@ -956,6 +953,9 @@ class View : public AcceleratorTarget { protected: // Size and disposition ------------------------------------------------------ + // Override to be notified when the bounds of the view have changed. + virtual void OnBoundsChanged(const gfx::Rect& previous_bounds); + // Called when the preferred size of a child view changed. This gives the // parent an opportunity to do a fresh layout if that makes sense. virtual void ChildPreferredSizeChanged(View* child) {} @@ -1200,7 +1200,7 @@ class View : public AcceleratorTarget { // Responsible for propagating bounds change notifications to relevant // views. - void BoundsChanged(); + void BoundsChanged(const gfx::Rect& previous_bounds); // Visible bounds notification registration. // When a view is added to a hierarchy, it and all its children are asked if diff --git a/views/view_unittest.cc b/views/view_unittest.cc index 3eaa9e0..76eb1c9 100644 --- a/views/view_unittest.cc +++ b/views/view_unittest.cc @@ -148,16 +148,18 @@ class TestView : public View { accelerator_count_map_.clear(); } - virtual void OnBoundsChanged(); - virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); - virtual bool OnMousePressed(const MouseEvent& event); - virtual bool OnMouseDragged(const MouseEvent& event); - virtual void OnMouseReleased(const MouseEvent& event, bool canceled); + virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; + virtual void ViewHierarchyChanged( + bool is_add, View *parent, View *child) OVERRIDE; + virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; + virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; + virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE; #if defined(TOUCH_UI) virtual TouchStatus OnTouchEvent(const TouchEvent& event); #endif - virtual void Paint(gfx::Canvas* canvas); - virtual bool AcceleratorPressed(const Accelerator& accelerator); + virtual void Paint(gfx::Canvas* canvas) OVERRIDE; + virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; + virtual bool AcceleratorPressed(const Accelerator& accelerator) OVERRIDE; // OnBoundsChanged test bool did_change_bounds_; @@ -173,7 +175,10 @@ class TestView : public View { int last_mouse_event_type_; gfx::Point location_; -#if defined(TOUCH_UI) + // Painting + std::vector<gfx::Rect> scheduled_paint_rects_; + + #if defined(TOUCH_UI) // TouchEvent int last_touch_event_type_; bool last_touch_event_was_handled_; @@ -218,7 +223,7 @@ class MockGestureManager : public GestureManager { // OnBoundsChanged //////////////////////////////////////////////////////////////////////////////// -void TestView::OnBoundsChanged() { +void TestView::OnBoundsChanged(const gfx::Rect& previous_bounds) { did_change_bounds_ = true; new_bounds_ = bounds(); } @@ -561,6 +566,11 @@ void TestView::Paint(gfx::Canvas* canvas) { canvas->AsCanvasSkia()->getClipBounds(&last_clip_); } +void TestView::SchedulePaintInRect(const gfx::Rect& rect) { + scheduled_paint_rects_.push_back(rect); + View::SchedulePaintInRect(rect); +} + void CheckRect(const SkRect& check_rect, const SkRect& target_rect) { EXPECT_EQ(target_rect.fLeft, check_rect.fLeft); EXPECT_EQ(target_rect.fRight, check_rect.fRight); @@ -1778,3 +1788,26 @@ TEST_F(ViewTest, OnVisibleBoundsChanged) { } #endif + +//////////////////////////////////////////////////////////////////////////////// +// BoundsChanged() + +TEST_F(ViewTest, SetBoundsPaint) { + TestView* top_view = new TestView; + TestView* child_view = new TestView; + + top_view->SetBounds(0, 0, 100, 100); + top_view->scheduled_paint_rects_.clear(); + child_view->SetBounds(10, 10, 20, 20); + top_view->AddChildView(child_view); + + top_view->scheduled_paint_rects_.clear(); + child_view->SetBounds(30, 30, 20, 20); + EXPECT_EQ(2U, top_view->scheduled_paint_rects_.size()); + + // There should be 2 rects, spanning from (10, 10) to (50, 50). + gfx::Rect paint_rect = + top_view->scheduled_paint_rects_[0].Union( + top_view->scheduled_paint_rects_[1]); + EXPECT_EQ(gfx::Rect(10, 10, 40, 40), paint_rect); +} diff --git a/views/window/client_view.cc b/views/window/client_view.cc index 5d964de..6ec3f90 100644 --- a/views/window/client_view.cc +++ b/views/window/client_view.cc @@ -63,7 +63,7 @@ void ClientView::ViewHierarchyChanged(bool is_add, View* parent, View* child) { } } -void ClientView::OnBoundsChanged() { +void ClientView::OnBoundsChanged(const gfx::Rect& previous_bounds) { // Overridden to do nothing. The NonClientView manually calls Layout on the // ClientView when it is itself laid out, see comment in // NonClientView::Layout. diff --git a/views/window/client_view.h b/views/window/client_view.h index 405ec4e..b50eafa 100644 --- a/views/window/client_view.h +++ b/views/window/client_view.h @@ -55,14 +55,15 @@ class ClientView : public View { virtual int NonClientHitTest(const gfx::Point& point); // Overridden from View: - virtual gfx::Size GetPreferredSize(); - virtual void Layout(); + virtual gfx::Size GetPreferredSize() OVERRIDE; + virtual void Layout() OVERRIDE; protected: // Overridden from View: - virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); - virtual void OnBoundsChanged(); - virtual AccessibilityTypes::Role GetAccessibleRole(); + virtual void ViewHierarchyChanged( + bool is_add, View* parent, View* child) OVERRIDE; + virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; + virtual AccessibilityTypes::Role GetAccessibleRole() OVERRIDE; // Accessors for private data members. Window* window() const { return window_; } diff --git a/views/window/non_client_view.cc b/views/window/non_client_view.cc index f297c45..ec82685 100644 --- a/views/window/non_client_view.cc +++ b/views/window/non_client_view.cc @@ -196,11 +196,6 @@ bool NonClientFrameView::HitTest(const gfx::Point& l) const { return !GetWindow()->client_view()->bounds().Contains(l); } -void NonClientFrameView::OnBoundsChanged() { - // Overridden to do nothing. The NonClientView manually calls Layout on the - // FrameView when it is itself laid out, see comment in NonClientView::Layout. -} - //////////////////////////////////////////////////////////////////////////////// // NonClientFrameView, protected: @@ -261,4 +256,9 @@ AccessibilityTypes::Role NonClientFrameView::GetAccessibleRole() { return AccessibilityTypes::ROLE_WINDOW; } +void NonClientFrameView::OnBoundsChanged(const gfx::Rect& previous_bounds) { + // Overridden to do nothing. The NonClientView manually calls Layout on the + // FrameView when it is itself laid out, see comment in NonClientView::Layout. +} + } // namespace views diff --git a/views/window/non_client_view.h b/views/window/non_client_view.h index d45c30e..38fc0b1 100644 --- a/views/window/non_client_view.h +++ b/views/window/non_client_view.h @@ -69,11 +69,11 @@ class NonClientFrameView : public View { virtual void ResetWindowControls() = 0; // Overridden from View: - virtual bool HitTest(const gfx::Point& l) const; - virtual AccessibilityTypes::Role GetAccessibleRole(); + virtual bool HitTest(const gfx::Point& l) const OVERRIDE; + virtual AccessibilityTypes::Role GetAccessibleRole() OVERRIDE; protected: - virtual void OnBoundsChanged(); + virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; NonClientFrameView() : paint_as_active_(false) {} |