diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-12 22:58:52 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-12 22:58:52 +0000 |
commit | 2bb12ce481d5fd5cb4ba371efeb4d52601e822ee (patch) | |
tree | d45d7ba2d7d07e9358c7a365a01f0c996049f414 /chrome/browser/ui/views/tab_contents | |
parent | 3f74cc7cc9f89afb269369a5cc4ec8cefb0ba6b3 (diff) | |
download | chromium_src-2bb12ce481d5fd5cb4ba371efeb4d52601e822ee.zip chromium_src-2bb12ce481d5fd5cb4ba371efeb4d52601e822ee.tar.gz chromium_src-2bb12ce481d5fd5cb4ba371efeb4d52601e822ee.tar.bz2 |
Revert 71230 to see if it is related to hang on linux interactive_ui_tests.
Original CL description:
Streamline the layout of the BrowserView's children TabContents views.
Modify SingleSplitView to calculate its children view's bounds, but do not actually resize them
and change BrowserViewLayout accordingly (BrowserViewLayout resizes all views now).
Do all reserved contents rect calculations before resizing TabContents views.
Rationale: to do all BrowserView layout related actions in the context of
BrowserViewLayout::Layout call and to minimize actual contents re-layouts.
BUG=51084
TEST=All tests should pass
Review URL: http://codereview.chromium.org/5606012
TBR=alekseys@chromium.org
Review URL: http://codereview.chromium.org/6121007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71252 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/views/tab_contents')
-rw-r--r-- | chrome/browser/ui/views/tab_contents/tab_contents_container.cc | 40 | ||||
-rw-r--r-- | chrome/browser/ui/views/tab_contents/tab_contents_container.h | 28 |
2 files changed, 42 insertions, 26 deletions
diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_container.cc b/chrome/browser/ui/views/tab_contents/tab_contents_container.cc index 90af997..06c3400 100644 --- a/chrome/browser/ui/views/tab_contents/tab_contents_container.cc +++ b/chrome/browser/ui/views/tab_contents/tab_contents_container.cc @@ -25,7 +25,8 @@ TabContentsContainer::TabContentsContainer() : native_container_(NULL), - tab_contents_(NULL) { + tab_contents_(NULL), + reserved_area_delegate_(NULL) { SetID(VIEW_ID_TAB_CONTAINER); } @@ -45,6 +46,9 @@ void TabContentsContainer::ChangeTabContents(TabContents* contents) { tab_contents_->WasHidden(); RemoveObservers(); } +#if !defined(TOUCH_UI) + TabContents* old_contents = tab_contents_; +#endif tab_contents_ = contents; // When detaching the last tab of the browser ChangeTabContents is invoked // with NULL. Don't attempt to do anything in that case. @@ -59,7 +63,9 @@ void TabContentsContainer::ChangeTabContents(TabContents* contents) { Layout(); } #else - RenderWidgetHostViewChanged(tab_contents_->GetRenderWidgetHostView()); + RenderWidgetHostViewChanged( + old_contents ? old_contents->GetRenderWidgetHostView() : NULL, + tab_contents_->GetRenderWidgetHostView()); native_container_->AttachContents(tab_contents_); #endif AddObservers(); @@ -76,17 +82,6 @@ void TabContentsContainer::SetFastResize(bool fast_resize) { native_container_->SetFastResize(fast_resize); } -void TabContentsContainer::SetReservedContentsRect( - const gfx::Rect& reserved_rect) { - cached_reserved_rect_ = reserved_rect; -#if !defined(TOUCH_UI) - if (tab_contents_ && tab_contents_->GetRenderWidgetHostView()) { - tab_contents_->GetRenderWidgetHostView()->set_reserved_contents_rect( - reserved_rect); - } -#endif -} - //////////////////////////////////////////////////////////////////////////////// // TabContentsContainer, NotificationObserver implementation: @@ -113,6 +108,8 @@ void TabContentsContainer::Layout() { views::View::Layout(); #else if (native_container_) { + if (reserved_area_delegate_) + reserved_area_delegate_->UpdateReservedContentsRect(this); native_container_->GetView()->SetBounds(0, 0, width(), height()); native_container_->GetView()->Layout(); } @@ -161,8 +158,10 @@ void TabContentsContainer::RenderViewHostChanged(RenderViewHost* old_host, #if defined(TOUCH_UI) NOTIMPLEMENTED(); // TODO(anicolao) #else - if (new_host) - RenderWidgetHostViewChanged(new_host->view()); + if (new_host) { + RenderWidgetHostViewChanged( + old_host ? old_host->view() : NULL, new_host->view()); + } native_container_->RenderViewHostChanged(old_host, new_host); #endif } @@ -175,7 +174,12 @@ void TabContentsContainer::TabContentsDestroyed(TabContents* contents) { } void TabContentsContainer::RenderWidgetHostViewChanged( - RenderWidgetHostView* new_view) { - if (new_view) - new_view->set_reserved_contents_rect(cached_reserved_rect_); + RenderWidgetHostView* old_view, RenderWidgetHostView* new_view) { + // Carry over the reserved rect, if possible. + if (old_view && new_view) { + new_view->set_reserved_contents_rect(old_view->reserved_contents_rect()); + } else { + if (reserved_area_delegate_) + reserved_area_delegate_->UpdateReservedContentsRect(this); + } } diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_container.h b/chrome/browser/ui/views/tab_contents/tab_contents_container.h index 1ba30ed..83633e8 100644 --- a/chrome/browser/ui/views/tab_contents/tab_contents_container.h +++ b/chrome/browser/ui/views/tab_contents/tab_contents_container.h @@ -19,6 +19,19 @@ class TabContents; class TabContentsContainer : public views::View, public NotificationObserver { public: + // Interface to request the reserved contents area updates. + class ReservedAreaDelegate { + public: + // Notifies that |source|'s reserved contents area should be updated. + // Reserved contents area is a rect in tab contents view coordinates where + // contents should not be rendered (to display the resize corner, sidebar + // mini tabs or any other UI elements overlaying this container). + virtual void UpdateReservedContentsRect( + const TabContentsContainer* source) = 0; + protected: + virtual ~ReservedAreaDelegate() {} + }; + TabContentsContainer(); virtual ~TabContentsContainer(); @@ -37,9 +50,9 @@ class TabContentsContainer : public views::View, // so performance is better. void SetFastResize(bool fast_resize); - // Updates the current reserved rect in view coordinates where contents - // should not be rendered to draw the resize corner, sidebar mini tabs etc. - void SetReservedContentsRect(const gfx::Rect& reserved_rect); + void set_reserved_area_delegate(ReservedAreaDelegate* delegate) { + reserved_area_delegate_ = delegate; + } // Overridden from NotificationObserver: virtual void Observe(NotificationType type, @@ -71,7 +84,8 @@ class TabContentsContainer : public views::View, void TabContentsDestroyed(TabContents* contents); // Called when the RenderWidgetHostView of the hosted TabContents has changed. - void RenderWidgetHostViewChanged(RenderWidgetHostView* new_view); + void RenderWidgetHostViewChanged(RenderWidgetHostView* old_view, + RenderWidgetHostView* new_view); // An instance of a NativeTabContentsContainer object that holds the native // view handle associated with the attached TabContents. @@ -83,10 +97,8 @@ class TabContentsContainer : public views::View, // Handles registering for our notifications. NotificationRegistrar registrar_; - // The current reserved rect in view coordinates where contents should not be - // rendered to draw the resize corner, sidebar mini tabs etc. - // Cached here to update ever changing renderers. - gfx::Rect cached_reserved_rect_; + // Delegate for enquiring reserved contents area. Not owned by us. + ReservedAreaDelegate* reserved_area_delegate_; DISALLOW_COPY_AND_ASSIGN(TabContentsContainer); }; |