summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/views/tab_contents
diff options
context:
space:
mode:
authoralekseys@chromium.org <alekseys@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-12 20:57:44 +0000
committeralekseys@chromium.org <alekseys@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-12 20:57:44 +0000
commit84f024c021c2a8e009026516483897546faf86fa (patch)
treeaf3d146edbd064dbdfedaad04041231559d7abd0 /chrome/browser/ui/views/tab_contents
parentc8fd6c617808b668f28962dc8c139d878c861e07 (diff)
downloadchromium_src-84f024c021c2a8e009026516483897546faf86fa.zip
chromium_src-84f024c021c2a8e009026516483897546faf86fa.tar.gz
chromium_src-84f024c021c2a8e009026516483897546faf86fa.tar.bz2
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 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71230 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.cc40
-rw-r--r--chrome/browser/ui/views/tab_contents/tab_contents_container.h28
2 files changed, 26 insertions, 42 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 06c3400..90af997 100644
--- a/chrome/browser/ui/views/tab_contents/tab_contents_container.cc
+++ b/chrome/browser/ui/views/tab_contents/tab_contents_container.cc
@@ -25,8 +25,7 @@
TabContentsContainer::TabContentsContainer()
: native_container_(NULL),
- tab_contents_(NULL),
- reserved_area_delegate_(NULL) {
+ tab_contents_(NULL) {
SetID(VIEW_ID_TAB_CONTAINER);
}
@@ -46,9 +45,6 @@ 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.
@@ -63,9 +59,7 @@ void TabContentsContainer::ChangeTabContents(TabContents* contents) {
Layout();
}
#else
- RenderWidgetHostViewChanged(
- old_contents ? old_contents->GetRenderWidgetHostView() : NULL,
- tab_contents_->GetRenderWidgetHostView());
+ RenderWidgetHostViewChanged(tab_contents_->GetRenderWidgetHostView());
native_container_->AttachContents(tab_contents_);
#endif
AddObservers();
@@ -82,6 +76,17 @@ 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:
@@ -108,8 +113,6 @@ 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();
}
@@ -158,10 +161,8 @@ void TabContentsContainer::RenderViewHostChanged(RenderViewHost* old_host,
#if defined(TOUCH_UI)
NOTIMPLEMENTED(); // TODO(anicolao)
#else
- if (new_host) {
- RenderWidgetHostViewChanged(
- old_host ? old_host->view() : NULL, new_host->view());
- }
+ if (new_host)
+ RenderWidgetHostViewChanged(new_host->view());
native_container_->RenderViewHostChanged(old_host, new_host);
#endif
}
@@ -174,12 +175,7 @@ void TabContentsContainer::TabContentsDestroyed(TabContents* contents) {
}
void TabContentsContainer::RenderWidgetHostViewChanged(
- 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);
- }
+ RenderWidgetHostView* new_view) {
+ if (new_view)
+ new_view->set_reserved_contents_rect(cached_reserved_rect_);
}
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 83633e8..1ba30ed 100644
--- a/chrome/browser/ui/views/tab_contents/tab_contents_container.h
+++ b/chrome/browser/ui/views/tab_contents/tab_contents_container.h
@@ -19,19 +19,6 @@ 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();
@@ -50,9 +37,9 @@ class TabContentsContainer : public views::View,
// so performance is better.
void SetFastResize(bool fast_resize);
- void set_reserved_area_delegate(ReservedAreaDelegate* delegate) {
- reserved_area_delegate_ = delegate;
- }
+ // 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);
// Overridden from NotificationObserver:
virtual void Observe(NotificationType type,
@@ -84,8 +71,7 @@ class TabContentsContainer : public views::View,
void TabContentsDestroyed(TabContents* contents);
// Called when the RenderWidgetHostView of the hosted TabContents has changed.
- void RenderWidgetHostViewChanged(RenderWidgetHostView* old_view,
- RenderWidgetHostView* new_view);
+ void RenderWidgetHostViewChanged(RenderWidgetHostView* new_view);
// An instance of a NativeTabContentsContainer object that holds the native
// view handle associated with the attached TabContents.
@@ -97,8 +83,10 @@ class TabContentsContainer : public views::View,
// Handles registering for our notifications.
NotificationRegistrar registrar_;
- // Delegate for enquiring reserved contents area. Not owned by us.
- ReservedAreaDelegate* reserved_area_delegate_;
+ // 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_;
DISALLOW_COPY_AND_ASSIGN(TabContentsContainer);
};