summaryrefslogtreecommitdiffstats
path: root/www/webkit-gtk3/files/patch-gtkregion-removal
blob: ed9d94f3210ad95880c3451fce939bd2c3606e51 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
From 1deabc22a79236001955f6f6082cac2249776ac2 Mon Sep 17 00:00:00 2001
From: Xan Lopez <xlopez@igalia.com>
Date: Thu, 1 Jul 2010 16:18:26 +0200
Subject: [PATCH] WebCore:

2010-07-01  Xan Lopez  <xlopez@igalia.com>

        Reviewed by NOBODY (OOPS!).

        [GTK] Stop using GdkRegion in 3.x mode
        https://bugs.webkit.org/show_bug.cgi?id=41463

        Make us compile without using GdkRegion, since it's gone from GTK+
        3.x.

        * platform/graphics/IntRect.h:
        * platform/graphics/cairo/GraphicsContextCairo.cpp:
        (WebCore::GraphicsContext::drawFocusRing):
        * platform/graphics/gtk/FontGtk.cpp:
        (WebCore::cairo_region_shrink):
        (WebCore::Font::drawComplexText):
        * platform/gtk/GtkPluginWidget.cpp:
        (WebCore::GtkPluginWidget::paint):
        * platform/gtk/RenderThemeGtk.h:
        * platform/gtk/ScrollbarGtk.cpp:
        (ScrollbarGtk::paint):

WebKit/gtk:

2010-07-01  Xan Lopez  <xlopez@igalia.com>

        Reviewed by NOBODY (OOPS!).

        [GTK] Stop using GdkRegion in 3.x mode
        https://bugs.webkit.org/show_bug.cgi?id=41463

        Make us compile without using GdkRegion, since it's gone from GTK+
        3.x.

        * WebCoreSupport/ChromeClientGtk.cpp:
        (WebKit::ChromeClient::scroll):
        * webkit/webkitwebview.cpp:
        (webkit_web_view_expose_event):
---
 WebCore/ChangeLog                                  |   22 ++++++++++++
 WebCore/platform/graphics/IntRect.h                |    5 +++
 .../graphics/cairo/GraphicsContextCairo.cpp        |   14 +++++++
 WebCore/platform/graphics/gtk/FontGtk.cpp          |   37 +++++++++++++++++++-
 WebCore/platform/gtk/GtkPluginWidget.cpp           |    8 ++++
 WebCore/platform/gtk/RenderThemeGtk.h              |    5 +++
 WebCore/platform/gtk/ScrollbarGtk.cpp              |    8 ++++
 WebKit/gtk/ChangeLog                               |   15 ++++++++
 WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp      |   16 ++++++++
 WebKit/gtk/webkit/webkitwebview.cpp                |   10 ++++-
 10 files changed, 137 insertions(+), 3 deletions(-)

diff --git a/WebCore/platform/graphics/IntRect.h b/WebCore/platform/graphics/IntRect.h
index ad90dd9..c5990ef 100644
--- WebCore/platform/graphics/IntRect.h
+++ WebCore/platform/graphics/IntRect.h
@@ -48,7 +48,12 @@ QT_BEGIN_NAMESPACE
 class QRect;
 QT_END_NAMESPACE
 #elif PLATFORM(GTK)
+#ifdef GTK_API_VERSION_2
 typedef struct _GdkRectangle GdkRectangle;
+#else
+typedef struct _cairo_rectangle_int cairo_rectangle_int_t;
+typedef cairo_rectangle_int_t GdkRectangle;
+#endif
 #elif PLATFORM(HAIKU)
 class BRect;
 #endif
diff --git a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
index dc32317..5521a6f 100644
--- WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
+++ WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
@@ -643,13 +643,27 @@ void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int
     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
 
     setColor(cr, color);
     cairo_set_line_width(cr, 2.0f);
diff --git a/WebCore/platform/graphics/gtk/FontGtk.cpp b/WebCore/platform/graphics/gtk/FontGtk.cpp
index fae84cb..e451b76 100644
--- WebCore/platform/graphics/gtk/FontGtk.cpp
+++ WebCore/platform/graphics/gtk/FontGtk.cpp
@@ -181,6 +181,29 @@ bool Font::canReturnFallbackFontsForComplexText()
     return false;
 }
 
+#ifndef GTK_API_VERSION_2
+static void cairo_region_shrink(cairo_region_t* region, int dx, int dy)
+{
+    int nRects = cairo_region_num_rectangles(region);
+    /* clear region */
+    cairo_region_subtract(region, region);
+
+    for (int i = 0; i < nRects; i++) {
+        cairo_rectangle_int_t rect;
+        cairo_region_get_rectangle(region, i, &rect);
+
+        if (rect.width <= 2 * dx || rect.height <= 2 * dy)
+            continue;
+
+        rect.x += dx;
+        rect.y += dy;
+        rect.width -= 2 * dx;
+        rect.height -= 2 * dy;
+        cairo_region_union_rectangle(region, &rect);
+    }
+}
+#endif
+
 void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
 {
     cairo_t* cr = context->platformContext();
@@ -196,14 +219,22 @@ void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const F
     // Our layouts are single line
     PangoLayoutLine* layoutLine = pango_layout_get_line_readonly(layout, 0);
 
-    GdkRegion* partialRegion = NULL;
+#ifdef GTK_API_VERSION_2
+    GdkRegion* partialRegion = 0;
+#else
+    cairo_region_t* partialRegion = 0;
+#endif
     if (to - from != run.length()) {
         // Clip the region of the run to be rendered
         char* start = g_utf8_offset_to_pointer(utf8, from);
         char* end = g_utf8_offset_to_pointer(start, to - from);
         int ranges[] = {start - utf8, end - utf8};
         partialRegion = gdk_pango_layout_line_get_clip_region(layoutLine, 0, 0, ranges, 1);
+#ifdef GTK_API_VERSION_2
         gdk_region_shrink(partialRegion, 0, -pixelSize());
+#else
+        cairo_region_shrink(partialRegion, 0, -pixelSize());
+#endif
     }
 
     Color fillColor = context->fillColor();
@@ -265,7 +296,11 @@ void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const F
     cairo_new_path(cr);
 
     if (partialRegion)
+#ifdef GTK_API_VERSION_2
         gdk_region_destroy(partialRegion);
+#else
+        cairo_region_destroy(partialRegion);
+#endif
 
     g_free(utf8);
     g_object_unref(layout);
diff --git a/WebCore/platform/gtk/GtkPluginWidget.cpp b/WebCore/platform/gtk/GtkPluginWidget.cpp
index 94382f1..331f60f 100644
--- WebCore/platform/gtk/GtkPluginWidget.cpp
+++ WebCore/platform/gtk/GtkPluginWidget.cpp
@@ -87,7 +87,11 @@ void GtkPluginWidget::paint(GraphicsContext* context, const IntRect& rect)
     event->expose.area.x = loc.x();
     event->expose.area.y = loc.y();
 
+#ifdef GTK_API_VERSION_2
     event->expose.region = gdk_region_rectangle(&event->expose.area);
+#else
+    event->expose.region = cairo_region_create_rectangle(&event->expose.area);
+#endif
 
     /*
      * This will be unref'ed by gdk_event_free.
@@ -97,7 +101,11 @@ void GtkPluginWidget::paint(GraphicsContext* context, const IntRect& rect)
     /*
      * If we are going to paint do the translation and GtkAllocation manipulation.
      */
+#ifdef GTK_API_VERSION_2
     if (!gdk_region_empty(event->expose.region))
+#else
+    if (!cairo_region_is_empty(event->expose.region))
+#endif
         gtk_widget_send_expose(widget, event);
 
     gdk_event_free(event);
diff --git a/WebCore/platform/gtk/RenderThemeGtk.h b/WebCore/platform/gtk/RenderThemeGtk.h
index 3f02f0e..71338d4 100644
--- WebCore/platform/gtk/RenderThemeGtk.h
+++ WebCore/platform/gtk/RenderThemeGtk.h
@@ -34,7 +34,12 @@
 typedef struct _GtkWidget GtkWidget;
 typedef struct _GtkStyle GtkStyle;
 typedef struct _GtkContainer GtkContainer;
+#ifdef GTK_API_VERSION_2
 typedef struct _GdkRectangle GdkRectangle;
+#else
+typedef struct _cairo_rectangle_int cairo_rectangle_int_t;
+typedef cairo_rectangle_int_t GdkRectangle;
+#endif
 typedef struct _GdkDrawable GdkDrawable;
 typedef struct _GtkBorder GtkBorder;
 typedef struct _GtkThemeParts GtkThemeParts;
diff --git a/WebCore/platform/gtk/ScrollbarGtk.cpp b/WebCore/platform/gtk/ScrollbarGtk.cpp
index 5dc4dd6..8081fb8 100644
--- WebCore/platform/gtk/ScrollbarGtk.cpp
+++ WebCore/platform/gtk/ScrollbarGtk.cpp
@@ -238,7 +238,11 @@ void ScrollbarGtk::paint(GraphicsContext* context, const IntRect& rect)
     event->expose.area.x = loc.x();
     event->expose.area.y = loc.y();
 
+#ifdef GTK_API_VERSION_2
     event->expose.region = gdk_region_rectangle(&event->expose.area);
+#else
+    event->expose.region = cairo_region_create_rectangle(&event->expose.area);
+#endif
 
     /*
      * This will be unref'ed by gdk_event_free.
@@ -248,7 +252,11 @@ void ScrollbarGtk::paint(GraphicsContext* context, const IntRect& rect)
     /*
      * If we are going to paint do the translation and GtkAllocation manipulation.
      */
+#ifdef GTK_API_VERSION_2
     if (!gdk_region_empty(event->expose.region))
+#else
+    if (!cairo_region_is_empty(event->expose.region))
+#endif
         gtk_widget_send_expose(widget, event);
 
     gdk_event_free(event);
diff --git a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
index fe5d9eb..bb469c5 100644
--- WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
+++ WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
@@ -372,6 +372,7 @@ void ChromeClient::scroll(const IntSize& delta, const IntRect& rectToScroll, con
     sourceRect.x -= delta.width();
     sourceRect.y -= delta.height();
 
+#ifdef GTK_API_VERSION_2
     GdkRegion* invalidRegion = gdk_region_rectangle(&area);
 
     if (gdk_rectangle_intersect(&area, &sourceRect, &moveRect)) {
@@ -384,6 +385,21 @@ void ChromeClient::scroll(const IntSize& delta, const IntRect& rectToScroll, con
 
     gdk_window_invalidate_region(window, invalidRegion, FALSE);
     gdk_region_destroy(invalidRegion);
+#else
+    cairo_region_t* invalidRegion = cairo_region_create_rectangle(&area);
+
+    if (gdk_rectangle_intersect(&area, &sourceRect, &moveRect)) {
+        cairo_region_t* moveRegion = cairo_region_create_rectangle(&moveRect);
+        gdk_window_move_region(window, moveRegion, delta.width(), delta.height());
+        cairo_region_translate(moveRegion, delta.width(), delta.height());
+        cairo_region_subtract(invalidRegion, moveRegion);
+        cairo_region_destroy(moveRegion);
+    }
+
+    gdk_window_invalidate_region(window, invalidRegion, FALSE);
+    cairo_region_destroy(invalidRegion);
+#endif
+
 }
 
 // FIXME: this does not take into account the WM decorations
diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp
index ff4aa8a..62997c5 100644
--- WebKit/gtk/webkit/webkitwebview.cpp
+++ WebKit/gtk/webkit/webkitwebview.cpp
@@ -517,10 +517,16 @@ static gboolean webkit_web_view_expose_event(GtkWidget* widget, GdkEventExpose*
         cairo_destroy(cr);
         ctx.setGdkExposeEvent(event);
 
-        GOwnPtr<GdkRectangle> rects;
         int rectCount;
+#ifdef GTK_API_VERSION_2
+        GOwnPtr<GdkRectangle> rects;
         gdk_region_get_rectangles(event->region, &rects.outPtr(), &rectCount);
-
+#else
+        rectCount = cairo_region_num_rectangles(event->region);
+        GOwnPtr<GdkRectangle> rects(g_new(GdkRectangle, rectCount));
+        for (int i = 0; i < rectCount; i++)
+            cairo_region_get_rectangle(event->region, i, rects.get()+i);
+#endif
         // Avoid recursing into the render tree excessively
         bool coalesce = shouldCoalesce(event->area, rects.get(), rectCount);
 
-- 
1.6.6.1