diff options
author | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-22 23:02:13 +0000 |
---|---|---|
committer | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-22 23:02:13 +0000 |
commit | 528ad8be61f87ef874a3da9be49c2d73575b7e33 (patch) | |
tree | c76d8f07a53ecc1242f1f2bfa53a669e221fa0b9 /chrome | |
parent | ca105a270964207f4c61636f5676842ee6ee652c (diff) | |
download | chromium_src-528ad8be61f87ef874a3da9be49c2d73575b7e33.zip chromium_src-528ad8be61f87ef874a3da9be49c2d73575b7e33.tar.gz chromium_src-528ad8be61f87ef874a3da9be49c2d73575b7e33.tar.bz2 |
Fix ExtensionView to properly set the size of the RenderWidgetHostView. Without this, GetClientRect would return a size of 0,0 for the view, which would prevent the tooltip machinery from working properly.
Review URL: http://codereview.chromium.org/87058
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14264 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rwxr-xr-x | chrome/browser/extensions/extension_view.cc | 40 | ||||
-rw-r--r-- | chrome/common/temp_scaffolding_stubs.h | 2 |
2 files changed, 27 insertions, 15 deletions
diff --git a/chrome/browser/extensions/extension_view.cc b/chrome/browser/extensions/extension_view.cc index 960765a..8caf259 100755 --- a/chrome/browser/extensions/extension_view.cc +++ b/chrome/browser/extensions/extension_view.cc @@ -50,22 +50,32 @@ void ExtensionView::DidStopLoading(RenderViewHost* render_view_host, void ExtensionView::DidContentsPreferredWidthChange(const int pref_width) { if (pref_width > 0) { - // SchedulePaint first because new_width may be smaller and we want - // the Parent to paint the vacated space. - SchedulePaint(); - set_preferred_size(gfx::Size(pref_width, 100)); - SizeToPreferredSize(); - - // TODO(rafaelw): This assumes that the extension view is a child of an - // ExtensionToolstrip, which is a child of the BookmarkBarView. There should - // be a way to do this where the ExtensionView doesn't have to know it's - // containment hierarchy. - if (GetParent() != NULL && GetParent()->GetParent() != NULL) { - GetParent()->GetParent()->Layout(); + gfx::Size pref_size = GetPreferredSize(); + // This seems to get called a fair amount, so early out if preferred width + // is unchanged. + if (pref_size.width() != pref_width) { + // SchedulePaint first because new_width may be smaller and we want + // the Parent to paint the vacated space. + SchedulePaint(); + set_preferred_size(gfx::Size(pref_width, 100)); + SizeToPreferredSize(); + + // TODO(rafaelw): This assumes that the extension view is a child of an + // ExtensionToolstrip, which is a child of the BookmarkBarView. There + // should be a way to do this where the ExtensionView doesn't have to know + // its containment hierarchy. + if (GetParent() != NULL && GetParent()->GetParent() != NULL) { + GetParent()->GetParent()->Layout(); + } + + // Also SchedulePaint after because new_width may be larger, and we need + // to draw the new part of the view. + SchedulePaint(); + + // Need to tell the RenderWidgetHostView about the new size since it's + // not part of the view hierarchy. + render_view_host()->view()->SetSize(size()); } - - SchedulePaint(); - render_view_host()->WasResized(); } } diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h index cac23ea..5578bb1 100644 --- a/chrome/common/temp_scaffolding_stubs.h +++ b/chrome/common/temp_scaffolding_stubs.h @@ -514,6 +514,8 @@ class HWNDHtmlView { void Layout() { NOTIMPLEMENTED(); } void SchedulePaint() { NOTIMPLEMENTED(); } SiteInstance* site_instance() { NOTIMPLEMENTED(); return NULL; } + gfx::Size GetPreferredSize() { NOTIMPLEMENTED(); return gfx::Size(); } + gfx::Size size() { NOTIMPLEMENTED(); return gfx::Size(); } }; #endif // CHROME_COMMON_TEMP_SCAFFOLDING_STUBS_H_ |