[cairo] GraphicsContext should not depend on GTK+
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 28 Sep 2014 08:06:08 +0000 (08:06 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 28 Sep 2014 08:06:08 +0000 (08:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137175

Reviewed by Martin Robinson.

Remove the unused methods depending on GDK and simplify
GraphicsContext::drawFocusRing() using only cairo API.

* PlatformGTK.cmake: Move GraphicsContextCairo.cpp to the webcore sources.
* platform/graphics/GraphicsContext.h:
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::drawFocusRing): Iterate the rectangles
instead of creating a region for the rectangles and call gdk_cairo_region().
(WebCore::GraphicsContext::setGdkExposeEvent): Deleted.
(WebCore::GraphicsContext::gdkExposeEvent): Deleted.
(WebCore::GraphicsContext::gdkWindow): Deleted.
* platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h:
(WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@174041 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/PlatformGTK.cmake
Source/WebCore/platform/graphics/GraphicsContext.h
Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
Source/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h

index 01ec2ea..f5a7eb4 100644 (file)
@@ -1,3 +1,24 @@
+2014-09-28  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [cairo] GraphicsContext should not depend on GTK+
+        https://bugs.webkit.org/show_bug.cgi?id=137175
+
+        Reviewed by Martin Robinson.
+
+        Remove the unused methods depending on GDK and simplify
+        GraphicsContext::drawFocusRing() using only cairo API.
+
+        * PlatformGTK.cmake: Move GraphicsContextCairo.cpp to the webcore sources.
+        * platform/graphics/GraphicsContext.h:
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        (WebCore::GraphicsContext::drawFocusRing): Iterate the rectangles
+        instead of creating a region for the rectangles and call gdk_cairo_region().
+        (WebCore::GraphicsContext::setGdkExposeEvent): Deleted.
+        (WebCore::GraphicsContext::gdkExposeEvent): Deleted.
+        (WebCore::GraphicsContext::gdkWindow): Deleted.
+        * platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h:
+        (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
+
 2014-09-27  Chris Dumez  <cdumez@apple.com>
 
         HTMLPlugInElement::isUserObservable() is causing layout
index 1bb1d65..120f970 100644 (file)
@@ -54,6 +54,7 @@ list(APPEND WebCore_SOURCES
     platform/graphics/cairo/FontCairoHarfbuzzNG.cpp
     platform/graphics/cairo/GradientCairo.cpp
     platform/graphics/cairo/GraphicsContext3DCairo.cpp
+    platform/graphics/cairo/GraphicsContextCairo.cpp
     platform/graphics/cairo/ImageBufferCairo.cpp
     platform/graphics/cairo/ImageCairo.cpp
     platform/graphics/cairo/IntRectCairo.cpp
@@ -191,8 +192,6 @@ list(APPEND WebCorePlatformGTK_SOURCES
 
     platform/graphics/GLContext.cpp
 
-    platform/graphics/cairo/GraphicsContextCairo.cpp
-
     platform/graphics/egl/GLContextEGL.cpp
 
     platform/graphics/freetype/FontPlatformDataFreeType.cpp
index c6f861d..7f2a033 100644 (file)
@@ -535,12 +535,6 @@ namespace WebCore {
         GraphicsContext(cairo_t*);
 #endif
 
-#if PLATFORM(GTK)
-        void setGdkExposeEvent(GdkEventExpose*);
-        GdkWindow* gdkWindow() const;
-        GdkEventExpose* gdkExposeEvent() const;
-#endif
-
         static void adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, float strokeWidth, StrokeStyle);
 
     private:
index 71ebdb3..53ef813 100644 (file)
@@ -58,9 +58,7 @@
 #include <stdio.h>
 #include <wtf/MathExtras.h>
 
-#if PLATFORM(GTK)
-#include <gdk/gdk.h>
-#elif PLATFORM(WIN)
+#if PLATFORM(WIN)
 #include <cairo-win32.h>
 #endif
 
@@ -557,36 +555,16 @@ void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int
     if (paintingDisabled())
         return;
 
-    unsigned rectCount = rects.size();
-
     cairo_t* cr = platformContext()->cr();
     cairo_save(cr);
     cairo_push_group(cr);
     cairo_new_path(cr);
 
 #if PLATFORM(GTK)
-#ifdef GTK_API_VERSION_2
-    GdkRegion* reg = gdk_region_new();
-#else
-    cairo_region_t* reg = cairo_region_create();
-#endif
-
-    for (unsigned i = 0; i < rectCount; i++) {
-#ifdef GTK_API_VERSION_2
-        GdkRectangle rect = rects[i];
-        gdk_region_union_with_rect(reg, &rect);
-#else
-        cairo_rectangle_int_t rect = rects[i];
-        cairo_region_union_rectangle(reg, &rect);
-#endif
-    }
-    gdk_cairo_region(cr, reg);
-#ifdef GTK_API_VERSION_2
-    gdk_region_destroy(reg);
-#else
-    cairo_region_destroy(reg);
-#endif
+    for (const auto& rect : rects)
+        cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
 #else
+    unsigned rectCount = rects.size();
     int radius = (width - 1) / 2;
     Path path;
     for (unsigned i = 0; i < rectCount; ++i) {
@@ -1086,26 +1064,6 @@ void GraphicsContext::fillRectWithRoundedHole(const FloatRect& rect, const Float
     cairo_restore(cr);
 }
 
-#if PLATFORM(GTK)
-void GraphicsContext::setGdkExposeEvent(GdkEventExpose* expose)
-{
-    m_data->expose = expose;
-}
-
-GdkEventExpose* GraphicsContext::gdkExposeEvent() const
-{
-    return m_data->expose;
-}
-
-GdkWindow* GraphicsContext::gdkWindow() const
-{
-    if (!m_data->expose)
-        return 0;
-
-    return m_data->expose->window;
-}
-#endif
-
 void GraphicsContext::setPlatformShouldAntialias(bool enable)
 {
     if (paintingDisabled())
index 6bfde83..9edc9f2 100644 (file)
 #include <math.h>
 #include <stdio.h>
 
-#if PLATFORM(GTK)
-#include <pango/pango.h>
-typedef struct _GdkExposeEvent GdkExposeEvent;
-#elif PLATFORM(WIN)
+#if PLATFORM(WIN)
 #include <cairo-win32.h>
 #endif
 
@@ -49,9 +46,6 @@ class GraphicsContextPlatformPrivate {
 public:
     GraphicsContextPlatformPrivate(PlatformContextCairo* newPlatformContext)
         : platformContext(newPlatformContext)
-#if PLATFORM(GTK)
-        , expose(0)
-#endif
 #if PLATFORM(WIN) || (PLATFORM(GTK) && OS(WINDOWS))
         // NOTE:  These may note be needed: review and remove once Cairo implementation is complete
         , m_hdc(0)
@@ -95,9 +89,6 @@ public:
     PlatformContextCairo* platformContext;
     Vector<float> layers;
 
-#if PLATFORM(GTK)
-    GdkEventExpose* expose;
-#endif
 #if PLATFORM(WIN) || (PLATFORM(GTK) && OS(WINDOWS))
     HDC m_hdc;
     bool m_shouldIncludeChildWindows;