[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

mrobinson at webkit.org mrobinson at webkit.org
Wed Dec 22 18:40:59 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit cfbd912d910afe448e7df5e61c7acffb84c19f5c
Author: mrobinson at webkit.org <mrobinson at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Dec 15 19:19:05 2010 +0000

    2010-10-18  Martin Robinson  <mrobinson at igalia.com>
    
            Reviewed by Gustavo Noronha Silva.
    
            [GTK] Move input type=range rendering to RenderThemeGtk
            https://bugs.webkit.org/show_bug.cgi?id=47836
    
            Begin moving widget rendering out of the old Mozilla theme drawing code,
            which should remove many lines of code when completed. WidgetRenderingContext
            now hides the GTK+ 2 vs. 3 API differences, so that RenderThemeGtk can stay
            version agnostic.
    
            No new tests as this patch does not change functionality.
    
            * platform/gtk/RenderThemeGtk.cpp:
            (WebCore::RenderThemeGtk::RenderThemeGtk): gtkContainer() now returns a
            GtkWidget, so update the cast here.
            (WebCore::RenderThemeGtk::getGtkStateType): Added this helper which
            converts a RenderObject state into a GtkStateType.
            (WebCore::RenderThemeGtk::paintRenderObject): Removed work-arounds for
            scale painting, as it's not handled by this method any longer.
            (WebCore::RenderThemeGtk::paintSliderTrack): Updated to use
            WidgetRenderingContext.
            (WebCore::RenderThemeGtk::paintSliderThumb): Ditto.
            (WebCore::RenderThemeGtk::adjustSliderThumbSize): Get the size
            properties directly from the widget now instead of asking the Mozilla code.
            (WebCore::RenderThemeGtk::setupWidgetAndAddToContainer): Added this
            helper which reduces the amount of code quite a bit.
            (WebCore::RenderThemeGtk::gtkContainer): Updated to use helper.
            (WebCore::RenderThemeGtk::gtkButton): Ditto.
            (WebCore::RenderThemeGtk::gtkEntry): Ditto.
            (WebCore::RenderThemeGtk::gtkTreeView): Ditto.
            (WebCore::RenderThemeGtk::gtkVScale): Added.
            (WebCore::RenderThemeGtk::gtkHScale): Added.
            (WebCore::RenderThemeGtk::platformColorsDidChange): Removed
            GTK_CONTAINER cast.
            * platform/gtk/RenderThemeGtk.h: Updated to add new GtkHScale and
             GtkVScale members.
            * platform/gtk/WidgetRenderingContext.h: Aded new methods to proxy
            gtk_paint_box, gtk_paint_focus and gtk_paint_slider.
            * platform/gtk/WidgetRenderingContextGtk2.cpp:
            (WebCore::WidgetRenderingContext::gtkPaintBox): Added.
            (WebCore::WidgetRenderingContext::gtkPaintFocus): Ditto.
            (WebCore::WidgetRenderingContext::gtkPaintSlider): Ditto.
            * platform/gtk/WidgetRenderingContextGtk3.cpp:
            (WebCore::WidgetRenderingContext::gtkPaintBox): Ditto.
            (WebCore::WidgetRenderingContext::gtkPaintFocus): Ditto.
            (WebCore::WidgetRenderingContext::gtkPaintSlider): Ditto.
            * platform/gtk/gtk2drawing.c: Removed defunct code!
            (moz_gtk_get_widget_border):
            (moz_gtk_widget_paint):
            * platform/gtk/gtk3drawing.c: Ditto.
            (moz_gtk_get_widget_border):
            (moz_gtk_widget_paint):
            * platform/gtk/gtkdrawing.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74129 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index def6d33..b905057 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,59 @@
+2010-10-18  Martin Robinson  <mrobinson at igalia.com>
+
+        Reviewed by Gustavo Noronha Silva.
+
+        [GTK] Move input type=range rendering to RenderThemeGtk
+        https://bugs.webkit.org/show_bug.cgi?id=47836
+
+        Begin moving widget rendering out of the old Mozilla theme drawing code,
+        which should remove many lines of code when completed. WidgetRenderingContext
+        now hides the GTK+ 2 vs. 3 API differences, so that RenderThemeGtk can stay
+        version agnostic.
+
+        No new tests as this patch does not change functionality.
+
+        * platform/gtk/RenderThemeGtk.cpp:
+        (WebCore::RenderThemeGtk::RenderThemeGtk): gtkContainer() now returns a
+        GtkWidget, so update the cast here.
+        (WebCore::RenderThemeGtk::getGtkStateType): Added this helper which
+        converts a RenderObject state into a GtkStateType.
+        (WebCore::RenderThemeGtk::paintRenderObject): Removed work-arounds for
+        scale painting, as it's not handled by this method any longer.
+        (WebCore::RenderThemeGtk::paintSliderTrack): Updated to use
+        WidgetRenderingContext.
+        (WebCore::RenderThemeGtk::paintSliderThumb): Ditto.
+        (WebCore::RenderThemeGtk::adjustSliderThumbSize): Get the size
+        properties directly from the widget now instead of asking the Mozilla code.
+        (WebCore::RenderThemeGtk::setupWidgetAndAddToContainer): Added this
+        helper which reduces the amount of code quite a bit.
+        (WebCore::RenderThemeGtk::gtkContainer): Updated to use helper.
+        (WebCore::RenderThemeGtk::gtkButton): Ditto.
+        (WebCore::RenderThemeGtk::gtkEntry): Ditto.
+        (WebCore::RenderThemeGtk::gtkTreeView): Ditto.
+        (WebCore::RenderThemeGtk::gtkVScale): Added.
+        (WebCore::RenderThemeGtk::gtkHScale): Added.
+        (WebCore::RenderThemeGtk::platformColorsDidChange): Removed
+        GTK_CONTAINER cast.
+        * platform/gtk/RenderThemeGtk.h: Updated to add new GtkHScale and
+         GtkVScale members.
+        * platform/gtk/WidgetRenderingContext.h: Aded new methods to proxy
+        gtk_paint_box, gtk_paint_focus and gtk_paint_slider.
+        * platform/gtk/WidgetRenderingContextGtk2.cpp:
+        (WebCore::WidgetRenderingContext::gtkPaintBox): Added.
+        (WebCore::WidgetRenderingContext::gtkPaintFocus): Ditto.
+        (WebCore::WidgetRenderingContext::gtkPaintSlider): Ditto.
+        * platform/gtk/WidgetRenderingContextGtk3.cpp:
+        (WebCore::WidgetRenderingContext::gtkPaintBox): Ditto.
+        (WebCore::WidgetRenderingContext::gtkPaintFocus): Ditto.
+        (WebCore::WidgetRenderingContext::gtkPaintSlider): Ditto.
+        * platform/gtk/gtk2drawing.c: Removed defunct code!
+        (moz_gtk_get_widget_border):
+        (moz_gtk_widget_paint):
+        * platform/gtk/gtk3drawing.c: Ditto.
+        (moz_gtk_get_widget_border):
+        (moz_gtk_widget_paint):
+        * platform/gtk/gtkdrawing.h:
+
 2010-12-15  Sheriff Bot  <webkit.review.bot at gmail.com>
 
         Unreviewed, rolling out r74117.
diff --git a/WebCore/platform/gtk/RenderThemeGtk.cpp b/WebCore/platform/gtk/RenderThemeGtk.cpp
index 4db857d..43a23f2 100644
--- a/WebCore/platform/gtk/RenderThemeGtk.cpp
+++ b/WebCore/platform/gtk/RenderThemeGtk.cpp
@@ -217,6 +217,17 @@ static bool supportsFocus(ControlPart appearance)
     }
 }
 
+GtkStateType RenderThemeGtk::getGtkStateType(RenderObject* object)
+{
+    if (!isEnabled(object) || isReadOnlyControl(object))
+        return GTK_STATE_INSENSITIVE;
+    if (isPressed(object))
+        return GTK_STATE_ACTIVE;
+    if (isHovered(object))
+        return GTK_STATE_PRELIGHT;
+    return GTK_STATE_NORMAL;
+}
+
 bool RenderThemeGtk::supportsFocusRing(const RenderStyle* style) const
 {
     return supportsFocus(style->appearance());
@@ -288,14 +299,6 @@ bool RenderThemeGtk::paintRenderObject(GtkThemeWidgetType type, RenderObject* re
     widgetState.isDefault = false;
     widgetState.canDefault = false;
 
-    // FIXME: The depressed value should probably apply for other theme parts too.
-    // It must be used for range thumbs, because otherwise when the thumb is pressed,
-    // the rendering is incorrect.
-    if (type == MOZ_GTK_SCALE_THUMB_HORIZONTAL || type == MOZ_GTK_SCALE_THUMB_VERTICAL)
-        widgetState.depressed = isPressed(renderObject);
-    else
-        widgetState.depressed = false;
-
     WidgetRenderingContext widgetContext(context, rect);
     return !widgetContext.paintMozillaWidget(type, &widgetState, flags, gtkTextDirection(renderObject->style()->direction()));
 }
@@ -531,14 +534,30 @@ bool RenderThemeGtk::paintSearchField(RenderObject* o, const PaintInfo& i, const
 
 bool RenderThemeGtk::paintSliderTrack(RenderObject* object, const PaintInfo& info, const IntRect& rect)
 {
+    if (info.context->paintingDisabled())
+        return false;
+
     ControlPart part = object->style()->appearance();
     ASSERT(part == SliderHorizontalPart || part == SliderVerticalPart);
 
-    GtkThemeWidgetType gtkPart = MOZ_GTK_SCALE_HORIZONTAL;
-    if (part == SliderVerticalPart)
-        gtkPart = MOZ_GTK_SCALE_VERTICAL;
+    // We shrink the trough rect slightly to make room for the focus indicator.
+    IntRect troughRect(IntPoint(), rect.size()); // This is relative to rect.
+    GtkWidget* widget = 0;
+    if (part == SliderVerticalPart) {
+        widget = gtkVScale();
+        troughRect.inflateY(-gtk_widget_get_style(widget)->ythickness);
+    } else {
+        widget = gtkHScale();
+        troughRect.inflateX(-gtk_widget_get_style(widget)->xthickness);
+    }
+    gtk_widget_set_direction(widget, gtkTextDirection(object->style()->direction()));
+
+    WidgetRenderingContext widgetContext(info.context, rect);
+    widgetContext.gtkPaintBox(troughRect, widget, GTK_STATE_ACTIVE, GTK_SHADOW_OUT, "trough");
+    if (isFocused(object))
+        widgetContext.gtkPaintFocus(IntRect(IntPoint(), rect.size()), widget, getGtkStateType(object), "trough");
 
-    return paintRenderObject(gtkPart, object, info.context, rect);
+    return false;
 }
 
 void RenderThemeGtk::adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
@@ -548,14 +567,34 @@ void RenderThemeGtk::adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle* styl
 
 bool RenderThemeGtk::paintSliderThumb(RenderObject* object, const PaintInfo& info, const IntRect& rect)
 {
+    if (info.context->paintingDisabled())
+        return false;
+
     ControlPart part = object->style()->appearance();
     ASSERT(part == SliderThumbHorizontalPart || part == SliderThumbVerticalPart);
 
-    GtkThemeWidgetType gtkPart = MOZ_GTK_SCALE_THUMB_HORIZONTAL;
-    if (part == SliderThumbVerticalPart)
-        gtkPart = MOZ_GTK_SCALE_THUMB_VERTICAL;
-
-    return paintRenderObject(gtkPart, object, info.context, rect);
+    GtkWidget* widget = 0;
+    const char* detail = 0;
+    GtkOrientation orientation;
+    if (part == SliderThumbVerticalPart) {
+        widget = gtkVScale();
+        detail = "vscale";
+        orientation = GTK_ORIENTATION_VERTICAL;
+    } else {
+        widget = gtkHScale();
+        detail = "hscale";
+        orientation = GTK_ORIENTATION_HORIZONTAL;
+    }
+    gtk_widget_set_direction(widget, gtkTextDirection(object->style()->direction()));
+
+    // Only some themes have slider thumbs respond to clicks and some don't. This information is
+    // gathered via the 'activate-slider' property, but it's deprecated in GTK+ 2.22 and removed in
+    // GTK+ 3.x. The drawback of not honoring it is that slider thumbs change color when you click
+    // on them. 
+    IntRect thumbRect(IntPoint(), rect.size());
+    WidgetRenderingContext widgetContext(info.context, rect);
+    widgetContext.gtkPaintSlider(thumbRect, widget, getGtkStateType(object), GTK_SHADOW_OUT, detail, orientation);
+    return false;
 }
 
 void RenderThemeGtk::adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
@@ -570,14 +609,27 @@ void RenderThemeGtk::adjustSliderThumbSize(RenderObject* o) const
     if (part == MediaSliderThumbPart) {
         o->style()->setWidth(Length(m_mediaSliderThumbWidth, Fixed));
         o->style()->setHeight(Length(m_mediaSliderThumbHeight, Fixed));
-    } else
+        return;
+    }
+    if (part == MediaVolumeSliderThumbPart)
+        return;
 #endif
-    if (part == SliderThumbHorizontalPart || part == SliderThumbVerticalPart) {
-        gint width, height;
-        moz_gtk_get_scalethumb_metrics(part == SliderThumbHorizontalPart ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, &width, &height);
-        o->style()->setWidth(Length(width, Fixed));
-        o->style()->setHeight(Length(height, Fixed));
+
+    GtkWidget* widget = part == SliderThumbHorizontalPart ? gtkHScale() : gtkVScale();
+    int length = 0, width = 0;
+    gtk_widget_style_get(widget,
+                         "slider_length", &length,
+                         "slider_width", &width,
+                         NULL);
+
+    if (part == SliderThumbHorizontalPart) {
+        o->style()->setWidth(Length(length, Fixed));
+        o->style()->setHeight(Length(width, Fixed));
+        return;
     }
+    ASSERT(part == SliderThumbVerticalPart);
+    o->style()->setWidth(Length(width, Fixed));
+    o->style()->setHeight(Length(length, Fixed));
 }
 
 Color RenderThemeGtk::platformActiveSelectionBackgroundColor() const
@@ -703,17 +755,30 @@ static void gtkStyleSetCallback(GtkWidget* widget, GtkStyle* previous, RenderThe
     renderTheme->platformColorsDidChange();
 }
 
-GtkContainer* RenderThemeGtk::gtkContainer() const
+void RenderThemeGtk::setupWidgetAndAddToContainer(GtkWidget* widget, GtkWidget* window) const
+{
+    gtk_container_add(GTK_CONTAINER(window), widget);
+    gtk_widget_realize(widget);
+    g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", GINT_TO_POINTER(TRUE));
+
+    // FIXME: Perhaps this should only be called for the containing window or parent container.
+    g_signal_connect(widget, "style-set", G_CALLBACK(gtkStyleSetCallback), const_cast<RenderThemeGtk*>(this));
+}
+
+GtkWidget* RenderThemeGtk::gtkContainer() const
 {
     if (m_gtkContainer)
         return m_gtkContainer;
 
     m_gtkWindow = gtk_window_new(GTK_WINDOW_POPUP);
-    m_gtkContainer = GTK_CONTAINER(gtk_fixed_new());
-    g_signal_connect(m_gtkWindow, "style-set", G_CALLBACK(gtkStyleSetCallback), const_cast<RenderThemeGtk*>(this));
-    gtk_container_add(GTK_CONTAINER(m_gtkWindow), GTK_WIDGET(m_gtkContainer));
+#if GTK_API_VERSION_2
+    gtk_widget_set_colormap(m_gtkWindow, m_themeParts.colormap);
+#endif
     gtk_widget_realize(m_gtkWindow);
+    gtk_widget_set_name(m_gtkWindow, "MozillaGtkWidget");
 
+    m_gtkContainer = gtk_fixed_new();
+    setupWidgetAndAddToContainer(m_gtkContainer, m_gtkWindow);
     return m_gtkContainer;
 }
 
@@ -721,12 +786,8 @@ GtkWidget* RenderThemeGtk::gtkButton() const
 {
     if (m_gtkButton)
         return m_gtkButton;
-
     m_gtkButton = gtk_button_new();
-    g_signal_connect(m_gtkButton, "style-set", G_CALLBACK(gtkStyleSetCallback), const_cast<RenderThemeGtk*>(this));
-    gtk_container_add(gtkContainer(), m_gtkButton);
-    gtk_widget_realize(m_gtkButton);
-
+    setupWidgetAndAddToContainer(m_gtkButton, gtkContainer());
     return m_gtkButton;
 }
 
@@ -734,12 +795,8 @@ GtkWidget* RenderThemeGtk::gtkEntry() const
 {
     if (m_gtkEntry)
         return m_gtkEntry;
-
     m_gtkEntry = gtk_entry_new();
-    g_signal_connect(m_gtkEntry, "style-set", G_CALLBACK(gtkStyleSetCallback), const_cast<RenderThemeGtk*>(this));
-    gtk_container_add(gtkContainer(), m_gtkEntry);
-    gtk_widget_realize(m_gtkEntry);
-
+    setupWidgetAndAddToContainer(m_gtkEntry, gtkContainer());
     return m_gtkEntry;
 }
 
@@ -747,15 +804,29 @@ GtkWidget* RenderThemeGtk::gtkTreeView() const
 {
     if (m_gtkTreeView)
         return m_gtkTreeView;
-
     m_gtkTreeView = gtk_tree_view_new();
-    g_signal_connect(m_gtkTreeView, "style-set", G_CALLBACK(gtkStyleSetCallback), const_cast<RenderThemeGtk*>(this));
-    gtk_container_add(gtkContainer(), m_gtkTreeView);
-    gtk_widget_realize(m_gtkTreeView);
-
+    setupWidgetAndAddToContainer(m_gtkTreeView, gtkContainer());
     return m_gtkTreeView;
 }
 
+GtkWidget* RenderThemeGtk::gtkVScale() const
+{
+    if (m_gtkVScale)
+        return m_gtkVScale;
+    m_gtkVScale = gtk_vscale_new(0);
+    setupWidgetAndAddToContainer(m_gtkVScale, gtkContainer());
+    return m_gtkVScale;
+}
+
+GtkWidget* RenderThemeGtk::gtkHScale() const
+{
+    if (m_gtkHScale)
+        return m_gtkHScale;
+    m_gtkHScale = gtk_hscale_new(0);
+    setupWidgetAndAddToContainer(m_gtkHScale, gtkContainer());
+    return m_gtkHScale;
+}
+
 GtkWidget* RenderThemeGtk::gtkScrollbar()
 {
     return moz_gtk_get_scrollbar_widget();
diff --git a/WebCore/platform/gtk/RenderThemeGtk.h b/WebCore/platform/gtk/RenderThemeGtk.h
index cf40fc8..d377c45 100644
--- a/WebCore/platform/gtk/RenderThemeGtk.h
+++ b/WebCore/platform/gtk/RenderThemeGtk.h
@@ -157,19 +157,15 @@ protected:
 #endif
 
 private:
-    /*
-     * hold the state
-     */
     GtkWidget* gtkButton() const;
     GtkWidget* gtkEntry() const;
     GtkWidget* gtkTreeView() const;
+    GtkWidget* gtkVScale() const;
+    GtkWidget* gtkHScale() const;
+    GtkWidget* gtkContainer() const;
 
-    /*
-     * unmapped GdkWindow having a container. This is holding all
-     * our fake widgets
-     */
-    GtkContainer* gtkContainer() const;
-
+    void setupWidgetAndAddToContainer(GtkWidget*, GtkWidget*) const;
+    GtkStateType getGtkStateType(RenderObject* object);
     bool paintRenderObject(GtkThemeWidgetType, RenderObject*, GraphicsContext*, const IntRect& rect, int flags = 0);
 #if ENABLE(VIDEO)
     bool paintMediaButton(RenderObject*, GraphicsContext*, const IntRect&, const char* iconName);
@@ -177,10 +173,12 @@ private:
     GtkStateType gtkIconState(RenderObject*);
 
     mutable GtkWidget* m_gtkWindow;
-    mutable GtkContainer* m_gtkContainer;
+    mutable GtkWidget* m_gtkContainer;
     mutable GtkWidget* m_gtkButton;
     mutable GtkWidget* m_gtkEntry;
     mutable GtkWidget* m_gtkTreeView;
+    mutable GtkWidget* m_gtkVScale;
+    mutable GtkWidget* m_gtkHScale;
 
     mutable Color m_panelColor;
     mutable Color m_sliderColor;
diff --git a/WebCore/platform/gtk/WidgetRenderingContext.h b/WebCore/platform/gtk/WidgetRenderingContext.h
index 3bb8065..7334656 100644
--- a/WebCore/platform/gtk/WidgetRenderingContext.h
+++ b/WebCore/platform/gtk/WidgetRenderingContext.h
@@ -34,7 +34,11 @@ class WidgetRenderingContext {
 public:
     WidgetRenderingContext(GraphicsContext*, const IntRect&);
     ~WidgetRenderingContext();
+
     bool paintMozillaWidget(GtkThemeWidgetType, GtkWidgetState*, int flags, GtkTextDirection = GTK_TEXT_DIR_NONE);
+    void gtkPaintBox(const IntRect&, GtkWidget*, GtkStateType, GtkShadowType, const gchar*);
+    void gtkPaintFocus(const IntRect&, GtkWidget*, GtkStateType, const gchar*);
+    void gtkPaintSlider(const IntRect&, GtkWidget*, GtkStateType, GtkShadowType, const gchar*, GtkOrientation);
 
 private:
     GraphicsContext* m_graphicsContext;
diff --git a/WebCore/platform/gtk/WidgetRenderingContextGtk2.cpp b/WebCore/platform/gtk/WidgetRenderingContextGtk2.cpp
index fd0b9ca..e85c570 100644
--- a/WebCore/platform/gtk/WidgetRenderingContextGtk2.cpp
+++ b/WebCore/platform/gtk/WidgetRenderingContextGtk2.cpp
@@ -165,6 +165,27 @@ bool WidgetRenderingContext::paintMozillaWidget(GtkThemeWidgetType type, GtkWidg
     return !m_hadError;
 }
 
+void WidgetRenderingContext::gtkPaintBox(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, GtkShadowType shadowType, const gchar* detail)
+{
+    GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() };
+    gtk_paint_box(gtk_widget_get_style(widget), m_target, stateType, shadowType, &m_paintRect,
+                  widget, detail, paintRect.x, paintRect.y, paintRect.width, paintRect.height);
+}
+
+void WidgetRenderingContext::gtkPaintFocus(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, const gchar* detail)
+{
+    GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() };
+    gtk_paint_focus(gtk_widget_get_style(widget), m_target, stateType, &m_paintRect, widget,
+                    detail, paintRect.x, paintRect.y, paintRect.width, paintRect.height);
+}
+
+void WidgetRenderingContext::gtkPaintSlider(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, GtkShadowType shadowType, const gchar* detail, GtkOrientation orientation)
+{
+    GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() };
+    gtk_paint_slider(gtk_widget_get_style(widget), m_target, stateType, shadowType, &m_paintRect, widget,
+                     detail, paintRect.x, paintRect.y, paintRect.width, paintRect.height, orientation);
+}
+
 }
 
 #endif // GTK_API_VERSION_2
diff --git a/WebCore/platform/gtk/WidgetRenderingContextGtk3.cpp b/WebCore/platform/gtk/WidgetRenderingContextGtk3.cpp
index e5f1823..9010263 100644
--- a/WebCore/platform/gtk/WidgetRenderingContextGtk3.cpp
+++ b/WebCore/platform/gtk/WidgetRenderingContextGtk3.cpp
@@ -47,6 +47,25 @@ bool WidgetRenderingContext::paintMozillaWidget(GtkThemeWidgetType type, GtkWidg
     return !m_hadError;
 }
 
+void WidgetRenderingContext::gtkPaintBox(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, GtkShadowType shadowType, const gchar* detail)
+{
+    GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() };
+    gtk_paint_box(gtk_widget_get_style(widget), m_target, stateType, shadowType, widget,
+                  detail, paintRect.x, paintRect.y, paintRect.width, paintRect.height);
+}
+
+void WidgetRenderingContext::gtkPaintFocus(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, const gchar* detail)
+{
+    GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() };
+    gtk_paint_focus(gtk_widget_get_style(widget), m_target, stateType, widget,
+                    detail, paintRect.x, paintRect.y, paintRect.width, paintRect.height);
+}
+
+void WidgetRenderingContext::gtkPaintSlider(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, GtkShadowType shadowType, const gchar* detail, GtkOrientation orientation)
+{
+    GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() };
+    gtk_paint_slider(gtk_widget_get_style(widget), m_target, stateType, shadowType, widget,
+                     detail, paintRect.x, paintRect.y, paintRect.width, paintRect.height, orientation);
 }
 
 #endif // !GTK_API_VERSION_2
diff --git a/WebCore/platform/gtk/gtk2drawing.c b/WebCore/platform/gtk/gtk2drawing.c
index 2f2edb6..3ebd332 100644
--- a/WebCore/platform/gtk/gtk2drawing.c
+++ b/WebCore/platform/gtk/gtk2drawing.c
@@ -185,20 +185,6 @@ ensure_scrollbar_widget()
 }
 
 static gint
-ensure_scale_widget()
-{
-  if (!gParts->hScaleWidget) {
-    gParts->hScaleWidget = gtk_hscale_new(NULL);
-    setup_widget_prototype(gParts->hScaleWidget);
-  }
-  if (!gParts->vScaleWidget) {
-    gParts->vScaleWidget = gtk_vscale_new(NULL);
-    setup_widget_prototype(gParts->vScaleWidget);
-  }
-  return MOZ_GTK_SUCCESS;
-}
-
-static gint
 ensure_entry_widget()
 {
     if (!gParts->entryWidget) {
@@ -921,83 +907,6 @@ moz_gtk_scrollbar_thumb_paint(GtkThemeWidgetType widget,
 }
 
 static gint
-moz_gtk_scale_paint(GdkDrawable* drawable, GdkRectangle* rect,
-                    GdkRectangle* cliprect, GtkWidgetState* state,
-                    GtkOrientation flags, GtkTextDirection direction)
-{
-  gint x = 0, y = 0;
-  GtkStateType state_type = ConvertGtkState(state);
-  GtkStyle* style;
-  GtkWidget* widget;
-
-  ensure_scale_widget();
-  widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gParts->hScaleWidget : gParts->vScaleWidget);
-  gtk_widget_set_direction(widget, direction);
-
-  style = gtk_widget_get_style(widget);
-
-  if (flags == GTK_ORIENTATION_HORIZONTAL) {
-    x = XTHICKNESS(style);
-    y++;
-  }
-  else {
-    x++;
-    y = YTHICKNESS(style);
-  }
-
-  TSOffsetStyleGCs(style, rect->x, rect->y);
-  gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_NORMAL,
-                                     cliprect, rect->x, rect->y,
-                                     rect->width, rect->height);
-
-  gtk_paint_box(style, drawable, GTK_STATE_ACTIVE, GTK_SHADOW_IN, cliprect,
-                widget, "trough", rect->x + x, rect->y + y,
-                rect->width - 2*x, rect->height - 2*y);
-
-  if (state->focused)
-    gtk_paint_focus(style, drawable, state_type, cliprect, widget, "trough",
-                    rect->x, rect->y, rect->width, rect->height);
-
-  return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_scale_thumb_paint(GdkDrawable* drawable, GdkRectangle* rect,
-                          GdkRectangle* cliprect, GtkWidgetState* state,
-                          GtkOrientation flags, GtkTextDirection direction)
-{
-  GtkStateType state_type = ConvertGtkState(state);
-  GtkStyle* style;
-  GtkWidget* widget;
-  gint thumb_width, thumb_height, x, y;
-
-  ensure_scale_widget();
-  widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gParts->hScaleWidget : gParts->vScaleWidget);
-  gtk_widget_set_direction(widget, direction);
-
-  style = gtk_widget_get_style(widget);
-
-  /* determine the thumb size, and position the thumb in the center in the opposite axis */
-  if (flags == GTK_ORIENTATION_HORIZONTAL) {
-    moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_HORIZONTAL, &thumb_width, &thumb_height);
-    x = rect->x;
-    y = rect->y + (rect->height - thumb_height) / 2;
-  }
-  else {
-    moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_VERTICAL, &thumb_height, &thumb_width);
-    x = rect->x + (rect->width - thumb_width) / 2;
-    y = rect->y;
-  }
-
-  TSOffsetStyleGCs(style, rect->x, rect->y);
-  gtk_paint_slider(style, drawable, state_type, GTK_SHADOW_OUT, cliprect,
-                   widget, (flags == GTK_ORIENTATION_HORIZONTAL) ? "hscale" : "vscale",
-                   x, y, thumb_width, thumb_height, flags);
-
-  return MOZ_GTK_SUCCESS;
-}
-
-static gint
 moz_gtk_entry_paint(GdkDrawable* drawable, GdkRectangle* rect,
                     GdkRectangle* cliprect, GtkWidgetState* state,
                     GtkWidget* widget, GtkTextDirection direction)
@@ -1310,14 +1219,6 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
         ensure_progress_widget();
         w = gParts->progresWidget;
         break;
-    case MOZ_GTK_SCALE_HORIZONTAL:
-        ensure_scale_widget();
-        w = gParts->hScaleWidget;
-        break;
-    case MOZ_GTK_SCALE_VERTICAL:
-        ensure_scale_widget();
-        w = gParts->vScaleWidget;
-        break;
     /* These widgets have no borders, since they are not containers. */
     case MOZ_GTK_CHECKBUTTON:
     case MOZ_GTK_RADIOBUTTON:
@@ -1326,8 +1227,6 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
     case MOZ_GTK_SCROLLBAR_TRACK_VERTICAL:
     case MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL:
     case MOZ_GTK_SCROLLBAR_THUMB_VERTICAL:
-    case MOZ_GTK_SCALE_THUMB_HORIZONTAL:
-    case MOZ_GTK_SCALE_THUMB_VERTICAL:
     case MOZ_GTK_PROGRESS_CHUNK:
         *left = *top = *right = *bottom = 0;
         return MOZ_GTK_SUCCESS;
@@ -1344,22 +1243,6 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
 }
 
 gint
-moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint* thumb_height)
-{
-  GtkWidget* widget;
-
-  ensure_scale_widget();
-  widget = ((orient == GTK_ORIENTATION_HORIZONTAL) ? gParts->hScaleWidget : gParts->vScaleWidget);
-
-  gtk_widget_style_get (widget,
-                        "slider_length", thumb_length,
-                        "slider_width", thumb_height,
-                        NULL);
-
-  return MOZ_GTK_SUCCESS;
-}
-
-gint
 moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics *metrics)
 {
     ensure_scrollbar_widget();
@@ -1424,16 +1307,6 @@ moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable,
     case MOZ_GTK_SCROLLED_WINDOW:
         return moz_gtk_scrolled_window_paint(drawable, rect, cliprect, state);
         break;
-    case MOZ_GTK_SCALE_HORIZONTAL:
-    case MOZ_GTK_SCALE_VERTICAL:
-        return moz_gtk_scale_paint(drawable, rect, cliprect, state,
-                                   (GtkOrientation) flags, direction);
-        break;
-    case MOZ_GTK_SCALE_THUMB_HORIZONTAL:
-    case MOZ_GTK_SCALE_THUMB_VERTICAL:
-        return moz_gtk_scale_thumb_paint(drawable, rect, cliprect, state,
-                                         (GtkOrientation) flags, direction);
-        break;
     case MOZ_GTK_ENTRY:
         ensure_entry_widget();
         return moz_gtk_entry_paint(drawable, rect, cliprect, state,
diff --git a/WebCore/platform/gtk/gtk3drawing.c b/WebCore/platform/gtk/gtk3drawing.c
index 880eb6d..d3bdd56 100644
--- a/WebCore/platform/gtk/gtk3drawing.c
+++ b/WebCore/platform/gtk/gtk3drawing.c
@@ -178,20 +178,6 @@ ensure_scrollbar_widget()
 }
 
 static gint
-ensure_scale_widget()
-{
-  if (!gParts->hScaleWidget) {
-    gParts->hScaleWidget = gtk_hscale_new(NULL);
-    setup_widget_prototype(gParts->hScaleWidget);
-  }
-  if (!gParts->vScaleWidget) {
-    gParts->vScaleWidget = gtk_vscale_new(NULL);
-    setup_widget_prototype(gParts->vScaleWidget);
-  }
-  return MOZ_GTK_SUCCESS;
-}
-
-static gint
 ensure_entry_widget()
 {
     if (!gParts->entryWidget) {
@@ -848,82 +834,6 @@ moz_gtk_scrollbar_thumb_paint(GtkThemeWidgetType widget,
 }
 
 static gint
-moz_gtk_scale_paint(cairo_t* cr, GdkRectangle* rect,
-                    GtkWidgetState* state, GtkOrientation flags,
-                    GtkTextDirection direction)
-{
-  gint x = 0, y = 0;
-  GtkStateType state_type = ConvertGtkState(state);
-  GtkStyle* style;
-  GtkWidget* widget;
-
-  ensure_scale_widget();
-  widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gParts->hScaleWidget : gParts->vScaleWidget);
-  gtk_widget_set_direction(widget, direction);
-
-  style = gtk_widget_get_style(widget);
-
-  if (flags == GTK_ORIENTATION_HORIZONTAL) {
-    x = XTHICKNESS(style);
-    y++;
-  }
-  else {
-    x++;
-    y = YTHICKNESS(style);
-  }
-
-  gtk_style_apply_default_background(style, cr, gtk_widget_get_window (widget),
-                                     GTK_STATE_NORMAL,
-                                     rect->x, rect->y,
-                                     rect->width, rect->height);
-
-  gtk_paint_box(style, cr, GTK_STATE_ACTIVE, GTK_SHADOW_IN,
-                widget, "trough", rect->x + x, rect->y + y,
-                rect->width - 2*x, rect->height - 2*y);
-
-  if (state->focused)
-    gtk_paint_focus(style, cr, state_type, widget, "trough",
-                    rect->x, rect->y, rect->width, rect->height);
-
-  return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_scale_thumb_paint(cairo_t* cr, GdkRectangle* rect,
-                          GtkWidgetState* state, GtkOrientation flags,
-                          GtkTextDirection direction)
-{
-  GtkStateType state_type = ConvertGtkState(state);
-  GtkStyle* style;
-  GtkWidget* widget;
-  gint thumb_width, thumb_height, x, y;
-
-  ensure_scale_widget();
-  widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gParts->hScaleWidget : gParts->vScaleWidget);
-  gtk_widget_set_direction(widget, direction);
-
-  style = gtk_widget_get_style(widget);
-
-  /* determine the thumb size, and position the thumb in the center in the opposite axis */
-  if (flags == GTK_ORIENTATION_HORIZONTAL) {
-    moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_HORIZONTAL, &thumb_width, &thumb_height);
-    x = rect->x;
-    y = rect->y + (rect->height - thumb_height) / 2;
-  }
-  else {
-    moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_VERTICAL, &thumb_height, &thumb_width);
-    x = rect->x + (rect->width - thumb_width) / 2;
-    y = rect->y;
-  }
-
-  gtk_paint_slider(style, cr, state_type, GTK_SHADOW_OUT,
-                   widget, (flags == GTK_ORIENTATION_HORIZONTAL) ? "hscale" : "vscale",
-                   x, y, thumb_width, thumb_height, flags);
-
-  return MOZ_GTK_SUCCESS;
-}
-
-static gint
 moz_gtk_entry_paint(cairo_t* cr, GdkRectangle* rect,
                     GtkWidgetState* state, GtkWidget* widget,
                     GtkTextDirection direction)
@@ -1227,14 +1137,6 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
         ensure_progress_widget();
         w = gParts->progresWidget;
         break;
-    case MOZ_GTK_SCALE_HORIZONTAL:
-        ensure_scale_widget();
-        w = gParts->hScaleWidget;
-        break;
-    case MOZ_GTK_SCALE_VERTICAL:
-        ensure_scale_widget();
-        w = gParts->vScaleWidget;
-        break;
     /* These widgets have no borders, since they are not containers. */
     case MOZ_GTK_CHECKBUTTON:
     case MOZ_GTK_RADIOBUTTON:
@@ -1243,8 +1145,6 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
     case MOZ_GTK_SCROLLBAR_TRACK_VERTICAL:
     case MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL:
     case MOZ_GTK_SCROLLBAR_THUMB_VERTICAL:
-    case MOZ_GTK_SCALE_THUMB_HORIZONTAL:
-    case MOZ_GTK_SCALE_THUMB_VERTICAL:
     case MOZ_GTK_PROGRESS_CHUNK:
         *left = *top = *right = *bottom = 0;
         return MOZ_GTK_SUCCESS;
@@ -1261,22 +1161,6 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
 }
 
 gint
-moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint* thumb_height)
-{
-  GtkWidget* widget;
-
-  ensure_scale_widget();
-  widget = ((orient == GTK_ORIENTATION_HORIZONTAL) ? gParts->hScaleWidget : gParts->vScaleWidget);
-
-  gtk_widget_style_get (widget,
-                        "slider_length", thumb_length,
-                        "slider_width", thumb_height,
-                        NULL);
-
-  return MOZ_GTK_SUCCESS;
-}
-
-gint
 moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics *metrics)
 {
     ensure_scrollbar_widget();
@@ -1340,16 +1224,6 @@ moz_gtk_widget_paint(GtkThemeWidgetType widget, cairo_t* cr,
     case MOZ_GTK_SCROLLED_WINDOW:
         return moz_gtk_scrolled_window_paint(cr, rect, state);
         break;
-    case MOZ_GTK_SCALE_HORIZONTAL:
-    case MOZ_GTK_SCALE_VERTICAL:
-        return moz_gtk_scale_paint(cr, rect, state,
-                                   (GtkOrientation) flags, direction);
-        break;
-    case MOZ_GTK_SCALE_THUMB_HORIZONTAL:
-    case MOZ_GTK_SCALE_THUMB_VERTICAL:
-        return moz_gtk_scale_thumb_paint(cr, rect, state,
-                                         (GtkOrientation) flags, direction);
-        break;
     case MOZ_GTK_ENTRY:
         ensure_entry_widget();
         return moz_gtk_entry_paint(cr, rect, state,
diff --git a/WebCore/platform/gtk/gtkdrawing.h b/WebCore/platform/gtk/gtkdrawing.h
index a981543..9d13a07 100644
--- a/WebCore/platform/gtk/gtkdrawing.h
+++ b/WebCore/platform/gtk/gtkdrawing.h
@@ -93,8 +93,6 @@ typedef struct _GtkThemeParts {
     GtkWidget* radiobuttonWidget;
     GtkWidget* horizScrollbarWidget;
     GtkWidget* vertScrollbarWidget;
-    GtkWidget* hScaleWidget;
-    GtkWidget* vScaleWidget;
     GtkWidget* entryWidget;
     GtkWidget* comboBoxWidget;
     GtkWidget* comboBoxButtonWidget;
@@ -147,12 +145,6 @@ typedef enum {
   MOZ_GTK_SCROLLBAR_THUMB_VERTICAL,
   /* Paints the background of a scrolled window */
   MOZ_GTK_SCROLLED_WINDOW,
-  /* Paints a GtkScale. */
-  MOZ_GTK_SCALE_HORIZONTAL,
-  MOZ_GTK_SCALE_VERTICAL,
-  /* Paints a GtkScale thumb. */
-  MOZ_GTK_SCALE_THUMB_HORIZONTAL,
-  MOZ_GTK_SCALE_THUMB_VERTICAL,
   MOZ_GTK_ENTRY,
   /* Paints a GtkOptionMenu. */
   MOZ_GTK_DROPDOWN,
@@ -277,17 +269,6 @@ moz_gtk_widget_get_focus(GtkWidget* widget, gboolean* interior_focus,
                          gint* focus_width, gint* focus_pad);
 
 /**
- * Get the desired size of a GtkScale thumb
- * orient:           [IN] the scale orientation
- * thumb_length:     [OUT] the length of the thumb
- * thumb_height:     [OUT] the height of the thumb
- *
- * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint
-moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint* thumb_height);
-
-/**
  * Get the desired metrics for a GtkScrollbar
  * metrics:          [IN]  struct which will contain the metrics
  *

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list