[SCM] WebKit Debian packaging branch, debian/experimental, updated. debian/1.3.8-1-1049-g2e11a8e

carlosgc at webkit.org carlosgc at webkit.org
Fri Jan 21 15:08:04 UTC 2011


The following commit has been merged in the debian/experimental branch:
commit 58529d5cdee197b561d3ac34a89cec455cec22cf
Author: carlosgc at webkit.org <carlosgc at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jan 7 18:58:33 2011 +0000

    2011-01-07  Carlos Garcia Campos  <cgarcia at igalia.com>
    
            Reviewed by Martin Robinson.
    
            [GTK] Port buttons painting to GtkStyleContext
            https://bugs.webkit.org/show_bug.cgi?id=51812
    
            Use GtkStyleContext API to paint buttons when building with GTK+
            3.x.
    
            No new tests. This should not change functionality.
    
            * platform/gtk/RenderThemeGtk3.cpp:
            (WebCore::adjustRectForFocus):
            (WebCore::RenderThemeGtk::adjustRepaintRect):
            (WebCore::RenderThemeGtk::paintButton):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75255 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 7b09a98..6e27f21 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,20 @@
+2011-01-07  Carlos Garcia Campos  <cgarcia at igalia.com>
+
+        Reviewed by Martin Robinson.
+
+        [GTK] Port buttons painting to GtkStyleContext
+        https://bugs.webkit.org/show_bug.cgi?id=51812
+
+        Use GtkStyleContext API to paint buttons when building with GTK+
+        3.x.
+
+        No new tests. This should not change functionality.
+
+        * platform/gtk/RenderThemeGtk3.cpp:
+        (WebCore::adjustRectForFocus):
+        (WebCore::RenderThemeGtk::adjustRepaintRect):
+        (WebCore::RenderThemeGtk::paintButton):
+
 2011-01-07  Zhenyao Mo  <zmo at google.com>
 
         Unreviewed, build fix.
diff --git a/WebCore/platform/gtk/RenderThemeGtk3.cpp b/WebCore/platform/gtk/RenderThemeGtk3.cpp
index cf548a8..729bda7 100644
--- a/WebCore/platform/gtk/RenderThemeGtk3.cpp
+++ b/WebCore/platform/gtk/RenderThemeGtk3.cpp
@@ -101,22 +101,39 @@ void RenderThemeGtk::initMediaColors()
     m_sliderThumbColor = style->bg[GTK_STATE_SELECTED];
 }
 
+static void adjustRectForFocus(GtkStyleContext* context, IntRect& rect)
+{
+    gint focusWidth, focusPad;
+    gtk_style_context_get_style(context,
+                                "focus-line-width", &focusWidth,
+                                "focus-padding", &focusPad, NULL);
+    rect.inflate(focusWidth + focusPad);
+}
+
 void RenderThemeGtk::adjustRepaintRect(const RenderObject* renderObject, IntRect& rect)
 {
+    GtkStyleContext* context = 0;
     ControlPart part = renderObject->style()->appearance();
     switch (part) {
     case SliderVerticalPart:
-    case SliderHorizontalPart: {
-        GtkStyleContext* context = getStyleContext(part == SliderThumbHorizontalPart ?  GTK_TYPE_HSCALE : GTK_TYPE_VSCALE);
-        gint focusWidth, focusPad;
-        gtk_style_context_get_style(context,
-                                    "focus-line-width", &focusWidth,
-                                    "focus-padding", &focusPad, NULL);
-        rect.inflate(focusWidth + focusPad);
-    }
-    default:
+    case SliderHorizontalPart:
+        context = getStyleContext(part == SliderThumbHorizontalPart ?  GTK_TYPE_HSCALE : GTK_TYPE_VSCALE);
         break;
+    case ButtonPart:
+        context = getStyleContext(GTK_TYPE_BUTTON);
+
+        gboolean interiorFocus;
+        gtk_style_context_get_style(context, "interior-focus", &interiorFocus, NULL);
+        if (interiorFocus)
+            return;
+
+        break;
+    default:
+        return;
     }
+
+    ASSERT(context);
+    adjustRectForFocus(context, rect);
 }
 
 GtkStateType RenderThemeGtk::getGtkStateType(RenderObject* object)
@@ -198,48 +215,80 @@ bool RenderThemeGtk::paintRadio(RenderObject* object, const PaintInfo& info, con
     return paintRenderObject(MOZ_GTK_RADIOBUTTON, object, info.context, rect, isChecked(object));
 }
 
-bool RenderThemeGtk::paintButton(RenderObject* object, const PaintInfo& info, const IntRect& rect)
+bool RenderThemeGtk::paintButton(RenderObject* renderObject, const PaintInfo& paintInfo, const IntRect& rect)
 {
-    if (info.context->paintingDisabled())
-        return false;
+    GtkStyleContext* context = getStyleContext(GTK_TYPE_BUTTON);
+    gtk_style_context_save(context);
+
+    gtk_style_context_set_direction(context, static_cast<GtkTextDirection>(gtkTextDirection(renderObject->style()->direction())));
+    gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON);
+
+    IntRect buttonRect(rect);
+
+    if (isDefault(renderObject)) {
+        GtkBorder* borderPtr = 0;
+        GtkBorder border = { 1, 1, 1, 1 };
+
+        gtk_style_context_get_style(context, "default-border", &borderPtr, NULL);
+        if (borderPtr) {
+            border = *borderPtr;
+            gtk_border_free(borderPtr);
+        }
+
+        buttonRect.move(border.left, border.top);
+        buttonRect.setWidth(buttonRect.width() - (border.left + border.right));
+        buttonRect.setHeight(buttonRect.height() - (border.top + border.bottom));
+
+        gtk_style_context_add_class(context, GTK_STYLE_CLASS_DEFAULT);
+    }
+
+    guint flags = 0;
+    if (!isEnabled(renderObject) || isReadOnlyControl(renderObject))
+        flags |= GTK_STATE_FLAG_INSENSITIVE;
+    else if (isHovered(renderObject))
+        flags |= GTK_STATE_FLAG_PRELIGHT;
+    if (isPressed(renderObject))
+        flags |= GTK_STATE_FLAG_ACTIVE;
+    gtk_style_context_set_state(context, static_cast<GtkStateFlags>(flags));
+
+    gtk_render_background(context, paintInfo.context->platformContext(), buttonRect.x(), buttonRect.y(), buttonRect.width(), buttonRect.height());
+    gtk_render_frame(context, paintInfo.context->platformContext(), buttonRect.x(), buttonRect.y(), buttonRect.width(), buttonRect.height());
+
+    if (isFocused(renderObject)) {
+        gint focusWidth, focusPad;
+        gboolean displaceFocus, interiorFocus;
+        gtk_style_context_get_style(context,
+                                    "focus-line-width", &focusWidth,
+                                    "focus-padding", &focusPad,
+                                    "interior-focus", &interiorFocus,
+                                    "displace-focus", &displaceFocus,
+                                    NULL);
 
-    GtkWidget* widget = gtkButton();
-    IntRect buttonRect(IntPoint(), rect.size());
-    IntRect focusRect(buttonRect);
-
-    GtkStateType state = getGtkStateType(object);
-    gtk_widget_set_state(widget, state);
-    gtk_widget_set_direction(widget, gtkTextDirection(object->style()->direction()));
-
-    if (isFocused(object)) {
-        if (isEnabled(object))
-            g_object_set(widget, "has-focus", TRUE, NULL);
-
-        gboolean interiorFocus = 0, focusWidth = 0, focusPadding = 0;
-        gtk_widget_style_get(widget,
-                             "interior-focus", &interiorFocus,
-                             "focus-line-width", &focusWidth,
-                             "focus-padding", &focusPadding, NULL);
-        // If we are using exterior focus, we shrink the button rect down before
-        // drawing. If we are using interior focus we shrink the focus rect. This
-        // approach originates from the Mozilla theme drawing code (gtk2drawing.c).
         if (interiorFocus) {
-            GtkStyle* style = gtk_widget_get_style(widget);
-            focusRect.inflateX(-style->xthickness - focusPadding);
-            focusRect.inflateY(-style->ythickness - focusPadding);
-        } else {
-            buttonRect.inflateX(-focusWidth - focusPadding);
-            buttonRect.inflateY(-focusPadding - focusPadding);
+            GtkBorder borderWidth;
+            gtk_style_context_get_border(context, static_cast<GtkStateFlags>(flags), &borderWidth);
+
+            buttonRect = IntRect(buttonRect.x() + borderWidth.left + focusPad, buttonRect.y() + borderWidth.top + focusPad,
+                                 buttonRect.width() - (2 * focusPad + borderWidth.left + borderWidth.right),
+                                 buttonRect.height() - (2 * focusPad + borderWidth.top + borderWidth.bottom));
+        } else
+            buttonRect.inflate(focusWidth + focusPad);
+
+        if (displaceFocus && isPressed(renderObject)) {
+            gint childDisplacementX;
+            gint childDisplacementY;
+            gtk_style_context_get_style(context,
+                                        "child-displacement-x", &childDisplacementX,
+                                        "child-displacement-y", &childDisplacementY,
+                                        NULL);
+            buttonRect.move(childDisplacementX, childDisplacementY);
         }
+
+        gtk_render_focus(context, paintInfo.context->platformContext(), buttonRect.x(), buttonRect.y(), buttonRect.width(), buttonRect.height());
     }
 
-    WidgetRenderingContext widgetContext(info.context, rect);
-    GtkShadowType shadowType = state == GTK_STATE_ACTIVE ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
-    widgetContext.gtkPaintBox(buttonRect, widget, state, shadowType, "button");
-    if (isFocused(object))
-        widgetContext.gtkPaintFocus(focusRect, widget, state, "button");
+    gtk_style_context_restore(context);
 
-    g_object_set(widget, "has-focus", FALSE, NULL);
     return false;
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list