[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:10 UTC 2011


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

    2011-01-07  Carlos Garcia Campos  <cgarcia at igalia.com>
    
            Reviewed by Martin Robinson.
    
            [GTK] Port scrollbar painting to GtkStyleContext
            https://bugs.webkit.org/show_bug.cgi?id=52051
    
            * wtf/gobject/GTypedefs.h: Add GtkStyleContext forward
            declaration.
    2011-01-07  Carlos Garcia Campos  <cgarcia at igalia.com>
    
            Reviewed by Martin Robinson.
    
            [GTK] Port scrollbar painting to GtkStyleContext
            https://bugs.webkit.org/show_bug.cgi?id=52051
    
            Use GtkStyleContext API to paint scrollbars when building with
            GTK+ 3.x.
    
            No new tests. This should not change functionality.
    
            * platform/gtk/RenderThemeGtk.h:
            * platform/gtk/RenderThemeGtk3.cpp:
            (WebCore::RenderThemeGtk::gtkScrollbarStyle):
            * platform/gtk/ScrollbarThemeGtk.cpp:
            * platform/gtk/ScrollbarThemeGtk.h:
            * platform/gtk/ScrollbarThemeGtk2.cpp:
            (WebCore::gtkStyleSetCallback):
            (WebCore::ScrollbarThemeGtk::ScrollbarThemeGtk):
            * platform/gtk/ScrollbarThemeGtk3.cpp:
            (WebCore::gtkStyleChangedCallback):
            (WebCore::ScrollbarThemeGtk::ScrollbarThemeGtk):
            (WebCore::ScrollbarThemeGtk::updateThemeProperties):
            (WebCore::ScrollbarThemeGtk::paintTrackBackground):
            (WebCore::ScrollbarThemeGtk::paintScrollbarBackground):
            (WebCore::ScrollbarThemeGtk::paintThumb):
            (WebCore::ScrollbarThemeGtk::paintButton):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75259 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index dd233d7..2f66994 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,13 @@
+2011-01-07  Carlos Garcia Campos  <cgarcia at igalia.com>
+
+        Reviewed by Martin Robinson.
+
+        [GTK] Port scrollbar painting to GtkStyleContext
+        https://bugs.webkit.org/show_bug.cgi?id=52051
+
+        * wtf/gobject/GTypedefs.h: Add GtkStyleContext forward
+        declaration.
+
 2011-01-07  Daniel Bates  <dbates at rim.com>
 
         Reviewed by Martin Robinson.
diff --git a/Source/JavaScriptCore/wtf/gobject/GTypedefs.h b/Source/JavaScriptCore/wtf/gobject/GTypedefs.h
index 0b9a9ea..f9f8f2f 100644
--- a/Source/JavaScriptCore/wtf/gobject/GTypedefs.h
+++ b/Source/JavaScriptCore/wtf/gobject/GTypedefs.h
@@ -89,6 +89,7 @@ typedef struct _GdkDrawable GdkWindow;
 typedef struct _GdkWindow GdkWindow;
 typedef struct _cairo_rectangle_int cairo_rectangle_int_t;
 typedef cairo_rectangle_int_t GdkRectangle;
+typedef struct _GtkStyleContext GtkStyleContext;
 #endif
 
 #endif
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 4e999b4..35121ac 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,32 @@
+2011-01-07  Carlos Garcia Campos  <cgarcia at igalia.com>
+
+        Reviewed by Martin Robinson.
+
+        [GTK] Port scrollbar painting to GtkStyleContext
+        https://bugs.webkit.org/show_bug.cgi?id=52051
+
+        Use GtkStyleContext API to paint scrollbars when building with
+        GTK+ 3.x.
+
+        No new tests. This should not change functionality.
+
+        * platform/gtk/RenderThemeGtk.h:
+        * platform/gtk/RenderThemeGtk3.cpp:
+        (WebCore::RenderThemeGtk::gtkScrollbarStyle):
+        * platform/gtk/ScrollbarThemeGtk.cpp:
+        * platform/gtk/ScrollbarThemeGtk.h:
+        * platform/gtk/ScrollbarThemeGtk2.cpp:
+        (WebCore::gtkStyleSetCallback):
+        (WebCore::ScrollbarThemeGtk::ScrollbarThemeGtk):
+        * platform/gtk/ScrollbarThemeGtk3.cpp:
+        (WebCore::gtkStyleChangedCallback):
+        (WebCore::ScrollbarThemeGtk::ScrollbarThemeGtk):
+        (WebCore::ScrollbarThemeGtk::updateThemeProperties):
+        (WebCore::ScrollbarThemeGtk::paintTrackBackground):
+        (WebCore::ScrollbarThemeGtk::paintScrollbarBackground):
+        (WebCore::ScrollbarThemeGtk::paintThumb):
+        (WebCore::ScrollbarThemeGtk::paintButton):
+
 2011-01-07  Dan Bernstein  <mitz at apple.com>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/platform/gtk/RenderThemeGtk.h b/WebCore/platform/gtk/RenderThemeGtk.h
index 17b31b5..ef1df05 100644
--- a/WebCore/platform/gtk/RenderThemeGtk.h
+++ b/WebCore/platform/gtk/RenderThemeGtk.h
@@ -88,7 +88,11 @@ public:
 
     void getIndicatorMetrics(ControlPart, int& indicatorSize, int& indicatorSpacing) const;
 
+#ifdef GTK_API_VERSION_2
     GtkWidget* gtkScrollbar();
+#else
+    GtkStyleContext* gtkScrollbarStyle();
+#endif
 
 protected:
     virtual bool paintCheckbox(RenderObject* o, const PaintInfo& i, const IntRect& r);
diff --git a/WebCore/platform/gtk/RenderThemeGtk3.cpp b/WebCore/platform/gtk/RenderThemeGtk3.cpp
index 729bda7..663404d 100644
--- a/WebCore/platform/gtk/RenderThemeGtk3.cpp
+++ b/WebCore/platform/gtk/RenderThemeGtk3.cpp
@@ -633,9 +633,9 @@ GtkWidget* RenderThemeGtk::gtkHScale() const
     return m_gtkHScale;
 }
 
-GtkWidget* RenderThemeGtk::gtkScrollbar()
+GtkStyleContext* RenderThemeGtk::gtkScrollbarStyle()
 {
-    return moz_gtk_get_scrollbar_widget();
+    return getStyleContext(GTK_TYPE_SCROLLBAR);
 }
 
 } // namespace WebCore
diff --git a/WebCore/platform/gtk/ScrollbarThemeGtk.cpp b/WebCore/platform/gtk/ScrollbarThemeGtk.cpp
index 0835c7f..cb9b0f8 100644
--- a/WebCore/platform/gtk/ScrollbarThemeGtk.cpp
+++ b/WebCore/platform/gtk/ScrollbarThemeGtk.cpp
@@ -34,7 +34,6 @@
 namespace WebCore {
 
 static HashSet<Scrollbar*>* gScrollbars;
-static void gtkStyleSetCallback(GtkWidget*, GtkStyle*, ScrollbarThemeGtk*);
 
 ScrollbarTheme* ScrollbarTheme::nativeTheme()
 {
@@ -42,13 +41,6 @@ ScrollbarTheme* ScrollbarTheme::nativeTheme()
     return &theme;
 }
 
-ScrollbarThemeGtk::ScrollbarThemeGtk()
-{
-    updateThemeProperties();
-    g_signal_connect(static_cast<RenderThemeGtk*>(RenderTheme::defaultTheme().get())->gtkScrollbar(),
-         "style-set", G_CALLBACK(gtkStyleSetCallback), this);
-}
-
 ScrollbarThemeGtk::~ScrollbarThemeGtk()
 {
 }
@@ -94,11 +86,6 @@ void ScrollbarThemeGtk::updateScrollbarsFrameThickness()
     }
 }
 
-static void gtkStyleSetCallback(GtkWidget* widget, GtkStyle* previous, ScrollbarThemeGtk* scrollbarTheme)
-{
-    scrollbarTheme->updateThemeProperties();
-}
-
 bool ScrollbarThemeGtk::hasThumb(Scrollbar* scrollbar)
 {
     // This method is just called as a paint-time optimization to see if
diff --git a/WebCore/platform/gtk/ScrollbarThemeGtk.h b/WebCore/platform/gtk/ScrollbarThemeGtk.h
index e3642cb..207ec1f 100644
--- a/WebCore/platform/gtk/ScrollbarThemeGtk.h
+++ b/WebCore/platform/gtk/ScrollbarThemeGtk.h
@@ -63,14 +63,17 @@ public:
     void unregisterScrollbar(Scrollbar*);
 
 protected:
+#ifndef GTK_API_VERSION_2
+    GtkStyleContext* m_context;
+#endif
     int m_thumbFatness;
     int m_troughBorderWidth;
     int m_stepperSize;
     int m_stepperSpacing;
     int m_minThumbLength;
-    bool m_troughUnderSteppers;
-    bool m_hasForwardButtonStartPart;
-    bool m_hasBackButtonEndPart;
+    gboolean m_troughUnderSteppers;
+    gboolean m_hasForwardButtonStartPart;
+    gboolean m_hasBackButtonEndPart;
 };
 
 }
diff --git a/WebCore/platform/gtk/ScrollbarThemeGtk2.cpp b/WebCore/platform/gtk/ScrollbarThemeGtk2.cpp
index b782dd6..79295c1 100644
--- a/WebCore/platform/gtk/ScrollbarThemeGtk2.cpp
+++ b/WebCore/platform/gtk/ScrollbarThemeGtk2.cpp
@@ -38,6 +38,18 @@
 
 namespace WebCore {
 
+static void gtkStyleSetCallback(GtkWidget* widget, GtkStyle* previous, ScrollbarThemeGtk* scrollbarTheme)
+{
+    scrollbarTheme->updateThemeProperties();
+}
+
+ScrollbarThemeGtk::ScrollbarThemeGtk()
+{
+    updateThemeProperties();
+    g_signal_connect(static_cast<RenderThemeGtk*>(RenderTheme::defaultTheme().get())->gtkScrollbar(),
+         "style-set", G_CALLBACK(gtkStyleSetCallback), this);
+}
+
 void ScrollbarThemeGtk::updateThemeProperties()
 {
     MozGtkScrollbarMetrics metrics;
diff --git a/WebCore/platform/gtk/ScrollbarThemeGtk3.cpp b/WebCore/platform/gtk/ScrollbarThemeGtk3.cpp
index 30d021e..d000063 100644
--- a/WebCore/platform/gtk/ScrollbarThemeGtk3.cpp
+++ b/WebCore/platform/gtk/ScrollbarThemeGtk3.cpp
@@ -32,109 +32,165 @@
 #include "RenderThemeGtk.h"
 #include "ScrollView.h"
 #include "Scrollbar.h"
-#include "WidgetRenderingContext.h"
-#include "gtkdrawing.h"
 #include <gtk/gtk.h>
 
 namespace WebCore {
 
-void ScrollbarThemeGtk::updateThemeProperties()
+static void gtkStyleChangedCallback(GtkWidget*, ScrollbarThemeGtk* scrollbarTheme)
+{
+    scrollbarTheme->updateThemeProperties();
+}
+
+ScrollbarThemeGtk::ScrollbarThemeGtk()
+    : m_context(static_cast<RenderThemeGtk*>(RenderTheme::defaultTheme().get())->gtkScrollbarStyle())
 {
-    MozGtkScrollbarMetrics metrics;
-    moz_gtk_get_scrollbar_metrics(&metrics);
-
-    m_thumbFatness = metrics.slider_width;
-    m_troughBorderWidth = metrics.trough_border;
-    m_stepperSize = metrics.stepper_size;
-    m_stepperSpacing = metrics.stepper_spacing;
-    m_minThumbLength = metrics.min_slider_size;
-    m_troughUnderSteppers = metrics.trough_under_steppers;
-    m_hasForwardButtonStartPart = metrics.has_secondary_forward_stepper;
-    m_hasBackButtonEndPart = metrics.has_secondary_backward_stepper;
+    updateThemeProperties();
+    g_signal_connect(m_context, "changed", G_CALLBACK(gtkStyleChangedCallback), this);
+}
 
+void ScrollbarThemeGtk::updateThemeProperties()
+{
+    gtk_style_context_get_style(m_context,
+                                "min-slider-length", &m_minThumbLength,
+                                "slider-width", &m_thumbFatness,
+                                "trough-border", &m_troughBorderWidth,
+                                "stepper-size", &m_stepperSize,
+                                "stepper-spacing", &m_stepperSpacing,
+                                "trough-under-steppers", &m_troughUnderSteppers,
+                                "has-secondary-backward-stepper", &m_hasBackButtonEndPart,
+                                "has-secondary-forward-stepper", &m_hasForwardButtonStartPart,
+                                NULL);
     updateScrollbarsFrameThickness();
 }
 
 void ScrollbarThemeGtk::paintTrackBackground(GraphicsContext* context, Scrollbar* scrollbar, const IntRect& rect)
 {
-    GtkWidgetState state;
-    state.focused = FALSE;
-    state.isDefault = FALSE;
-    state.canDefault = FALSE;
-    state.disabled = FALSE;
-    state.active = FALSE;
-    state.inHover = FALSE;
-
     // Paint the track background. If the trough-under-steppers property is true, this
     // should be the full size of the scrollbar, but if is false, it should only be the
     // track rect.
-    IntRect fullScrollbarRect = rect;
+    IntRect fullScrollbarRect(rect);
     if (m_troughUnderSteppers)
         fullScrollbarRect = IntRect(scrollbar->x(), scrollbar->y(), scrollbar->width(), scrollbar->height());
 
-    GtkThemeWidgetType type = scrollbar->orientation() == VerticalScrollbar ? MOZ_GTK_SCROLLBAR_TRACK_VERTICAL : MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL;
-    WidgetRenderingContext widgetContext(context, fullScrollbarRect);
-    widgetContext.paintMozillaWidget(type, &state, 0);
+    gtk_style_context_save(m_context);
+
+    gtk_style_context_add_class(m_context, GTK_STYLE_CLASS_SCROLLBAR);
+    gtk_style_context_add_class(m_context, GTK_STYLE_CLASS_TROUGH);
+
+    gtk_render_background(m_context, context->platformContext(),
+                          fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
+    gtk_render_frame(m_context, context->platformContext(),
+                     fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
+
+    gtk_style_context_restore(m_context);
 }
 
 void ScrollbarThemeGtk::paintScrollbarBackground(GraphicsContext* context, Scrollbar* scrollbar)
 {
-    // This is unused by the moz_gtk_scrollecd_window_paint.
-    GtkWidgetState state;
-    IntRect fullScrollbarRect = IntRect(scrollbar->x(), scrollbar->y(), scrollbar->width(), scrollbar->height());
-    WidgetRenderingContext widgetContext(context, fullScrollbarRect);
-    widgetContext.paintMozillaWidget(MOZ_GTK_SCROLLED_WINDOW, &state, 0);
+    gtk_style_context_save(m_context);
+
+    gtk_style_context_add_class(m_context, GTK_STYLE_CLASS_SCROLLBAR);
+    gtk_style_context_add_class(m_context, "scrolled-window");
+    gtk_render_frame(m_context, context->platformContext(), scrollbar->x(), scrollbar->y(), scrollbar->width(), scrollbar->height());
+
+    gtk_style_context_restore(m_context);
 }
 
 void ScrollbarThemeGtk::paintThumb(GraphicsContext* context, Scrollbar* scrollbar, const IntRect& rect)
 {
-    GtkWidgetState state;
-    state.focused = FALSE;
-    state.isDefault = FALSE;
-    state.canDefault = FALSE;
-    state.disabled = FALSE;
-    state.active = scrollbar->pressedPart() == ThumbPart;
-    state.inHover = scrollbar->hoveredPart() == ThumbPart;
-    state.maxpos = scrollbar->maximum();
-    state.curpos = scrollbar->currentPos();
-
-    GtkThemeWidgetType type = scrollbar->orientation() == VerticalScrollbar ? MOZ_GTK_SCROLLBAR_THUMB_VERTICAL : MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL;
-    WidgetRenderingContext widgetContext(context, rect);
-    widgetContext.paintMozillaWidget(type, &state, 0);
+    gtk_style_context_save(m_context);
+
+    gtk_style_context_add_class(m_context, GTK_STYLE_CLASS_SCROLLBAR);
+    gtk_style_context_add_class(m_context, GTK_STYLE_CLASS_SLIDER);
+
+    guint flags = 0;
+    if (scrollbar->pressedPart() == ThumbPart)
+        flags |= GTK_STATE_FLAG_ACTIVE;
+    if (scrollbar->hoveredPart() == ThumbPart)
+        flags |= GTK_STATE_FLAG_PRELIGHT;
+    gtk_style_context_set_state(m_context, static_cast<GtkStateFlags>(flags));
+
+    gtk_render_slider(m_context, context->platformContext(), rect.x(), rect.y(), rect.width(), rect.height(),
+                      scrollbar->orientation() == VerticalScrollbar ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL);
+
+    gtk_style_context_restore(m_context);
 }
 
 void ScrollbarThemeGtk::paintButton(GraphicsContext* context, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart part)
 {
-    int flags = 0;
-    if (scrollbar->orientation() == VerticalScrollbar)
-        flags |= MOZ_GTK_STEPPER_VERTICAL;
+    gtk_style_context_save(m_context);
 
-    if (part == ForwardButtonEndPart)
-        flags |= (MOZ_GTK_STEPPER_DOWN | MOZ_GTK_STEPPER_BOTTOM);
-    if (part == ForwardButtonStartPart)
-        flags |= MOZ_GTK_STEPPER_DOWN;
-
-    GtkWidgetState state;
-    state.focused = TRUE;
-    state.isDefault = TRUE;
-    state.canDefault = TRUE;
-    state.depressed = FALSE;
+    gtk_style_context_add_class(m_context, GTK_STYLE_CLASS_SCROLLBAR);
 
+    guint flags = 0;
     if ((BackButtonStartPart == part && scrollbar->currentPos())
         || (BackButtonEndPart == part && scrollbar->currentPos())
         || (ForwardButtonEndPart == part && scrollbar->currentPos() != scrollbar->maximum())
         || (ForwardButtonStartPart == part && scrollbar->currentPos() != scrollbar->maximum())) {
-        state.disabled = FALSE;
-        state.active = part == scrollbar->pressedPart();
-        state.inHover = part == scrollbar->hoveredPart();
+        if (part == scrollbar->pressedPart())
+            flags |= GTK_STATE_FLAG_ACTIVE;
+        if (part == scrollbar->hoveredPart())
+            flags |= GTK_STATE_FLAG_PRELIGHT;
+    } else
+        flags |= GTK_STATE_FLAG_INSENSITIVE;
+    gtk_style_context_set_state(m_context, static_cast<GtkStateFlags>(flags));
+
+    guint sides = gtk_style_context_get_junction_sides(m_context);
+    if (scrollbar->orientation() == VerticalScrollbar)
+        sides &= ~(GTK_JUNCTION_TOP | GTK_JUNCTION_BOTTOM);
+    else
+        sides &= ~(GTK_JUNCTION_LEFT | GTK_JUNCTION_RIGHT);
+
+    switch (part) {
+    case BackButtonStartPart:
+        sides |= (scrollbar->orientation() == VerticalScrollbar) ? GTK_JUNCTION_BOTTOM : GTK_JUNCTION_RIGHT;
+        break;
+    case BackButtonEndPart:
+    case ForwardButtonEndPart:
+        sides |= (scrollbar->orientation() == VerticalScrollbar) ?
+                GTK_JUNCTION_TOP | GTK_JUNCTION_BOTTOM : GTK_JUNCTION_RIGHT | GTK_JUNCTION_LEFT;
+        break;
+    case ForwardButtonStartPart:
+        sides |= (scrollbar->orientation() == VerticalScrollbar) ? GTK_JUNCTION_TOP : GTK_JUNCTION_LEFT;
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+    }
+    gtk_style_context_set_junction_sides(m_context, static_cast<GtkJunctionSides>(sides));
+    gtk_style_context_add_class(m_context, GTK_STYLE_CLASS_BUTTON);
+
+    gtk_render_background(m_context, context->platformContext(), rect.x(), rect.y(), rect.width(), rect.height());
+    gtk_render_frame(m_context, context->platformContext(), rect.x(), rect.y(), rect.width(), rect.height());
+
+    gfloat arrowScaling;
+    gtk_style_context_get_style(m_context, "arrow-scaling", &arrowScaling, NULL);
+
+    IntSize arrowSize = rect.size();
+    arrowSize.scale(arrowScaling);
+    IntPoint arrowPoint(rect.x() + (rect.width() - arrowSize.width()) / 2,
+                        rect.y() + (rect.height() - arrowSize.height()) / 2);
+
+    if (flags & GTK_STATE_FLAG_ACTIVE) {
+        gint arrowDisplacementX, arrowDisplacementY;
+        gtk_style_context_get_style(m_context,
+                                    "arrow-displacement-x", &arrowDisplacementX,
+                                    "arrow-displacement-y", &arrowDisplacementY,
+                                    NULL);
+        arrowPoint.move(arrowDisplacementX, arrowDisplacementY);
+    }
+
+    gdouble angle, size;
+    if (scrollbar->orientation() == VerticalScrollbar) {
+        size = arrowSize.width();
+        angle = (part == ForwardButtonEndPart || part == ForwardButtonStartPart) ? G_PI : 0;
     } else {
-        state.disabled = TRUE;
-        state.active = FALSE;
-        state.inHover = FALSE;
+        size = arrowSize.height();
+        angle = (part == ForwardButtonEndPart || part == ForwardButtonStartPart) ? G_PI / 2 : 3 * (G_PI / 2);
     }
 
-    WidgetRenderingContext widgetContext(context, rect);
-    widgetContext.paintMozillaWidget(MOZ_GTK_SCROLLBAR_BUTTON, &state, flags);
+    gtk_render_arrow(m_context, context->platformContext(), angle, arrowPoint.x(), arrowPoint.y(), size);
+
+    gtk_style_context_restore(m_context);
 }
 
 } // namespace WebCore

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list