summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-10 17:36:38 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-10 17:36:38 +0000
commit66194b10c48282e9e074cec1010adda45814b6f4 (patch)
tree1ac2487f614074a14cba2e4085b11a84ca0bda57
parentdbb61a7972dd01541f11747688db709968af3075 (diff)
downloadchromium_src-66194b10c48282e9e074cec1010adda45814b6f4.zip
chromium_src-66194b10c48282e9e074cec1010adda45814b6f4.tar.gz
chromium_src-66194b10c48282e9e074cec1010adda45814b6f4.tar.bz2
Check for NULL backing store before painting.
Backing store for a RenderWidgetHostViewViews can be NULL. So make sure the backing store was allocated correctly before painting to it. BUG=66375 TEST=TabRestoreUITest.RestoreWindowAndTab and TabRestoreUITest.RestoreWindow passes with touchui=1 Review URL: http://codereview.chromium.org/6050009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70904 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/renderer_host/backing_store_manager.cc7
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_views.cc13
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_views.h7
3 files changed, 17 insertions, 10 deletions
diff --git a/chrome/browser/renderer_host/backing_store_manager.cc b/chrome/browser/renderer_host/backing_store_manager.cc
index 755a772..d9a273a 100644
--- a/chrome/browser/renderer_host/backing_store_manager.cc
+++ b/chrome/browser/renderer_host/backing_store_manager.cc
@@ -148,7 +148,8 @@ BackingStore* CreateBackingStore(RenderWidgetHost* host,
cache = small_cache;
}
BackingStore* backing_store = host->AllocBackingStore(backing_store_size);
- cache->Put(host, backing_store);
+ if (backing_store)
+ cache->Put(host, backing_store);
return backing_store;
}
@@ -203,14 +204,14 @@ void BackingStoreManager::PrepareBackingStore(
// don't have a previous snapshot.
if (bitmap_rect.size() != backing_store_size ||
bitmap_rect.x() != 0 || bitmap_rect.y() != 0 ||
- ComputeTotalArea(copy_rects) != backing_store_size.GetArea()) {
+ ComputeTotalArea(copy_rects) != backing_store_size.GetArea() ||
+ !(backing_store = CreateBackingStore(host, backing_store_size))) {
DCHECK(needs_full_paint != NULL);
*needs_full_paint = true;
// Makes no sense to paint the transport dib if we are going
// to request a full paint.
return;
}
- backing_store = CreateBackingStore(host, backing_store_size);
}
backing_store->PaintToBackingStore(host->process(), bitmap,
diff --git a/chrome/browser/renderer_host/render_widget_host_view_views.cc b/chrome/browser/renderer_host/render_widget_host_view_views.cc
index a8049cf..3e70816 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_views.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_views.cc
@@ -324,12 +324,15 @@ bool RenderWidgetHostViewViews::IsPopup() {
BackingStore* RenderWidgetHostViewViews::AllocBackingStore(
const gfx::Size& size) {
+ gfx::NativeView nview = GetInnerNativeView();
+ if (!nview)
+ return NULL;
return new BackingStoreX(host_, size,
- x11_util::GetVisualFromGtkWidget(native_view()),
- gtk_widget_get_visual(native_view())->depth);
+ x11_util::GetVisualFromGtkWidget(nview),
+ gtk_widget_get_visual(nview)->depth);
}
-gfx::NativeView RenderWidgetHostViewViews::native_view() const {
+gfx::NativeView RenderWidgetHostViewViews::GetInnerNativeView() const {
// TODO(sad): Ideally this function should be equivalent to GetNativeView, and
// WidgetGtk-specific function call should not be necessary.
views::WidgetGtk* widget = static_cast<views::WidgetGtk*>(GetWidget());
@@ -365,7 +368,7 @@ void RenderWidgetHostViewViews::Paint(gfx::Canvas* canvas) {
return;
}
- GdkWindow* window = native_view()->window;
+ GdkWindow* window = GetInnerNativeView()->window;
DCHECK(!about_to_validate_and_paint_);
// TODO(anicolao): get the damage somehow
@@ -593,7 +596,7 @@ void RenderWidgetHostViewViews::WillLoseFocus() {
void RenderWidgetHostViewViews::ShowCurrentCursor() {
// The widget may not have a window. If that's the case, abort mission. This
// is the same issue as that explained above in Paint().
- if (!native_view() || !native_view()->window)
+ if (!GetInnerNativeView() || !GetInnerNativeView()->window)
return;
native_cursor_ = current_cursor_.GetNativeCursor();
diff --git a/chrome/browser/renderer_host/render_widget_host_view_views.h b/chrome/browser/renderer_host/render_widget_host_view_views.h
index 8a582a7..2aa9cf7 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_views.h
+++ b/chrome/browser/renderer_host/render_widget_host_view_views.h
@@ -43,6 +43,7 @@ class RenderWidgetHostViewViews : public RenderWidgetHostView,
virtual void DidBecomeSelected();
virtual void WasHidden();
virtual void SetSize(const gfx::Size& size);
+ virtual gfx::NativeView GetNativeView();
virtual void MovePluginWindows(
const std::vector<webkit::npapi::WebPluginGeometry>& moves);
virtual void Focus();
@@ -75,8 +76,10 @@ class RenderWidgetHostViewViews : public RenderWidgetHostView,
virtual bool ContainsNativeView(gfx::NativeView native_view) const;
virtual void AcceleratedCompositingActivated(bool activated);
- gfx::NativeView native_view() const;
- virtual gfx::NativeView GetNativeView();
+ // On some systems, there can be two native views, where an outer native view
+ // contains the inner native view (e.g. when using GTK+). This returns the
+ // inner view. This can return NULL when it's not attached to a view.
+ gfx::NativeView GetInnerNativeView() const;
virtual void Paint(gfx::Canvas* canvas);