diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-27 23:04:48 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-27 23:04:48 +0000 |
commit | 7deaa81460cae8f40cbd3408a611527b2299c354 (patch) | |
tree | df5bd337270d024838b2b83595c970156e741f85 /chrome/browser/extensions | |
parent | 12a7aa885e5067665577bb86b20f004f0e8c57cb (diff) | |
download | chromium_src-7deaa81460cae8f40cbd3408a611527b2299c354.zip chromium_src-7deaa81460cae8f40cbd3408a611527b2299c354.tar.gz chromium_src-7deaa81460cae8f40cbd3408a611527b2299c354.tar.bz2 |
Fix several painting glitches for toolstrips.
* Reset HWND size when HWNDHtmlView changes size. The two should always be in sync.
* Race: We might already have frames when RenderWidget receives a new background, need to set these to transparent too.
* Race: Toolstrip background not always available by the time ExtensionToolstrip is constucted
* Make images line up correctly for toolstrip buttons.
Review URL: http://codereview.chromium.org/99042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14682 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rwxr-xr-x | chrome/browser/extensions/extension_view.cc | 33 | ||||
-rwxr-xr-x | chrome/browser/extensions/extension_view.h | 17 |
2 files changed, 41 insertions, 9 deletions
diff --git a/chrome/browser/extensions/extension_view.cc b/chrome/browser/extensions/extension_view.cc index b55c3aa..a26194c 100755 --- a/chrome/browser/extensions/extension_view.cc +++ b/chrome/browser/extensions/extension_view.cc @@ -34,21 +34,38 @@ ExtensionView::ExtensionView(Extension* extension, Browser* browser) : HWNDHtmlView(url, this, false, instance), extension_(extension), - browser_(browser) { - SetVisible(false); + browser_(browser), + did_stop_loading_(false), + pending_preferred_width_(0) { +} + +void ExtensionView::ShowIfCompletelyLoaded() { + // We wait to show the ExtensionView until it has loaded and our parent has + // given us a background. These can happen in different orders. + if (did_stop_loading_ && !render_view_host()->view()->background().empty()) { + SetVisible(true); + DidContentsPreferredWidthChange(pending_preferred_width_); + } +} + +void ExtensionView::SetBackground(const SkBitmap& background) { + HWNDHtmlView::SetBackground(background); + ShowIfCompletelyLoaded(); } void ExtensionView::DidStopLoading(RenderViewHost* render_view_host, int32 page_id) { render_view_host->WasResized(); - SetVisible(true); + did_stop_loading_ = true; + ShowIfCompletelyLoaded(); } 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(); + // Don't actually do anything with this information until we have been shown. + // Size changes will not be honored by lower layers while we are hidden. + if (!IsVisible()) { + pending_preferred_width_ = pref_width; + } else if (pref_width > 0) { set_preferred_size(gfx::Size(pref_width, height())); SizeToPreferredSize(); @@ -61,12 +78,12 @@ void ExtensionView::DidContentsPreferredWidthChange(const int pref_width) { } SchedulePaint(); - render_view_host()->WasResized(); } } void ExtensionView::CreatingRenderer() { render_view_host()->AllowExtensionBindings(); + SetVisible(false); } void ExtensionView::RenderViewCreated(RenderViewHost* rvh) { diff --git a/chrome/browser/extensions/extension_view.h b/chrome/browser/extensions/extension_view.h index 7c11371..51c84a3 100755 --- a/chrome/browser/extensions/extension_view.h +++ b/chrome/browser/extensions/extension_view.h @@ -7,6 +7,7 @@ #include "chrome/browser/renderer_host/render_view_host_delegate.h" #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" +#include "skia/include/SkBitmap.h" // TODO(port): Port these files. #if defined(OS_WIN) @@ -30,14 +31,19 @@ class ExtensionView : public HWNDHtmlView, public RenderViewHostDelegate, public RenderViewHostDelegate::View { public: + // ExtensionView ExtensionView(Extension* extension, const GURL& url, SiteInstance* instance, Browser* browser); + Extension* extension() { return extension_; } + // HWNDHtmlView virtual void CreatingRenderer(); + virtual void SetBackground(const SkBitmap& background); + // RenderViewHostDelegate // TODO(mpcomplete): GetProfile is unused. virtual Profile* GetProfile() const { return NULL; } @@ -73,8 +79,10 @@ class ExtensionView : public HWNDHtmlView, virtual void TakeFocus(bool reverse); virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); - Extension* extension() { return extension_; } private: + // We wait to show the ExtensionView until several things have loaded. + void ShowIfCompletelyLoaded(); + // The extension that we're hosting in this view. Extension* extension_; @@ -84,6 +92,13 @@ class ExtensionView : public HWNDHtmlView, // Common implementations of some RenderViewHostDelegate::View methods. RenderViewHostDelegateViewHelper delegate_view_helper_; + // Whether the RenderWidget has reported that it has stopped loading. + bool did_stop_loading_; + + // What we should set the preferred width to once the ExtensionView has + // loaded. + int pending_preferred_width_; + DISALLOW_COPY_AND_ASSIGN(ExtensionView); }; |