All pastes #784059 Raw Edit

gtk+ drawing fixes

public text v1 · immutable
·published 2007-11-19 14:52 UTC
rendered paste body
Index: WebCore/ChangeLog
===================================================================
--- WebCore/ChangeLog	(revision 27903)
+++ WebCore/ChangeLog	(working copy)
@@ -1,3 +1,22 @@
+2007-11-19  Alp Toker  <alp@atoker.com>
+
+        Reviewed by NOBODY (OOPS!).
+
+        GTK+ drawing fixes.
+
+        Add a check to avoid crashing when the GraphicsContext is not
+        associated with a GdkDrawable. This was noticed when adding printing
+        support but might be triggered in other situations too.
+
+        Do not render themes when painting is disabled. This is an
+        optimisation for cases where GraphicsContext is used to calculate page
+        dimensions etc. without actually rendering.
+
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        (WebCore::GraphicsContext::gdkDrawable):
+        * platform/gtk/RenderThemeGtk.cpp:
+        (WebCore::paintMozWidget):
+
 2007-11-13  Rahul Abrol  <ra5ul@comcast.net>
 
         Reviewed by Tim Hatcher.
Index: WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
===================================================================
--- WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp	(revision 27903)
+++ WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp	(working copy)
@@ -867,6 +867,9 @@ GdkEventExpose* GraphicsContext::gdkExpo
 
 GdkDrawable* GraphicsContext::gdkDrawable() const
 {
+    if (!m_data->expose)
+        return 0;
+
     return GDK_DRAWABLE(m_data->expose->window);
 }
 
Index: WebCore/platform/gtk/RenderThemeGtk.cpp
===================================================================
--- WebCore/platform/gtk/RenderThemeGtk.cpp	(revision 27903)
+++ WebCore/platform/gtk/RenderThemeGtk.cpp	(working copy)
@@ -110,6 +110,14 @@ static void setMozState(RenderTheme* the
 
 static bool paintMozWidget(RenderTheme* theme, GtkThemeWidgetType type, RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
 {
+    // No GdkWindow to render to, so return true to fall back
+    if (!i.context->gdkDrawable())
+        return true;
+
+    // Painting is disabled so just claim to have succeeded
+    if (i.context->paintingDisabled())
+        return false;
+
     GtkWidgetState mozState;
     setMozState(theme, &mozState, o);