Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Unified Diff: chrome/browser/extensions/extension_view.cc

Issue 99042: Fix several painting glitches for toolstrips. (Closed)
Patch Set: Review responses Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_view.cc
diff --git a/chrome/browser/extensions/extension_view.cc b/chrome/browser/extensions/extension_view.cc
index b55c3aad0a43eca3f84887ab5947b5f06acbee63..a26194ca25eec873a315cfe0ae231cd7dac118be 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) {

Powered by Google App Engine
This is Rietveld 408576698