[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

mrobinson at webkit.org mrobinson at webkit.org
Sun Feb 20 23:21:19 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit e645fcf5eba603101687787c0ee347f6fe53d17d
Author: mrobinson at webkit.org <mrobinson at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jan 20 02:49:54 2011 +0000

    2011-01-13  Martin Robinson  <mrobinson at igalia.com>
    
            Reviewed by Daniel Bates.
    
            [GTK] Move progress bar painting out of gtk2drawing.c
            https://bugs.webkit.org/show_bug.cgi?id=52385
    
            Move progress bar painting to RenderThemeGtk2 and share some animation
            logic between the GTK+ 2.x and GTK+ 3.x port.
    
            No new tests. This should not change functionality.
    
            * platform/gtk/RenderThemeGtk.cpp:
            (WebCore::RenderThemeGtk::animationRepeatIntervalForProgressBar): Moved from RenderThemeGtk3.
            (WebCore::RenderThemeGtk::animationDurationForProgressBar): Ditto.
            (WebCore::RenderThemeGtk::calculateProgressRect): Calculate the proper rectangle for the
            progress indicator given the rect for the maximum size of the indicator.
            * platform/gtk/RenderThemeGtk.h: Added calculateProgressRect declaration and
            a new widget member for GTK+ 2.x
            * platform/gtk/RenderThemeGtk2.cpp:
            (WebCore::RenderThemeGtk::platformInit): Added initialization for the new widget member.
            (WebCore::RenderThemeGtk::paintProgressBar): Paint the progress bar manually instead of
            calling the old Mozilla code.
            (WebCore::RenderThemeGtk::gtkProgressBar): Added.
            * platform/gtk/RenderThemeGtk3.cpp:
            (WebCore::RenderThemeGtk::paintProgressBar): Call calculateProgressRect now to get
            the area of the progress indicator.
            * platform/gtk/gtk2drawing.c: Remove unused code.
            (moz_gtk_get_widget_border):
            (moz_gtk_widget_paint):
            * platform/gtk/gtkdrawing.h: Ditto.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76192 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 31fdacf..2c53fe3 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,35 @@
+2011-01-13  Martin Robinson  <mrobinson at igalia.com>
+
+        Reviewed by Daniel Bates.
+
+        [GTK] Move progress bar painting out of gtk2drawing.c
+        https://bugs.webkit.org/show_bug.cgi?id=52385
+
+        Move progress bar painting to RenderThemeGtk2 and share some animation
+        logic between the GTK+ 2.x and GTK+ 3.x port.
+
+        No new tests. This should not change functionality.
+
+        * platform/gtk/RenderThemeGtk.cpp:
+        (WebCore::RenderThemeGtk::animationRepeatIntervalForProgressBar): Moved from RenderThemeGtk3.
+        (WebCore::RenderThemeGtk::animationDurationForProgressBar): Ditto.
+        (WebCore::RenderThemeGtk::calculateProgressRect): Calculate the proper rectangle for the
+        progress indicator given the rect for the maximum size of the indicator.
+        * platform/gtk/RenderThemeGtk.h: Added calculateProgressRect declaration and
+        a new widget member for GTK+ 2.x
+        * platform/gtk/RenderThemeGtk2.cpp:
+        (WebCore::RenderThemeGtk::platformInit): Added initialization for the new widget member.
+        (WebCore::RenderThemeGtk::paintProgressBar): Paint the progress bar manually instead of
+        calling the old Mozilla code.
+        (WebCore::RenderThemeGtk::gtkProgressBar): Added.
+        * platform/gtk/RenderThemeGtk3.cpp:
+        (WebCore::RenderThemeGtk::paintProgressBar): Call calculateProgressRect now to get
+        the area of the progress indicator.
+        * platform/gtk/gtk2drawing.c: Remove unused code.
+        (moz_gtk_get_widget_border):
+        (moz_gtk_widget_paint):
+        * platform/gtk/gtkdrawing.h: Ditto.
+
 2011-01-19  Dmitry Titov  <dimich at chromium.org>
 
         [Chromium] Not reviewed, reverts the following changes:
diff --git a/Source/WebCore/platform/gtk/RenderThemeGtk.cpp b/Source/WebCore/platform/gtk/RenderThemeGtk.cpp
index 97c966d..dce7763 100644
--- a/Source/WebCore/platform/gtk/RenderThemeGtk.cpp
+++ b/Source/WebCore/platform/gtk/RenderThemeGtk.cpp
@@ -41,6 +41,10 @@
 #include <gdk/gdk.h>
 #include <gtk/gtk.h>
 
+#if ENABLE(PROGRESS_TAG)
+#include "RenderProgress.h"
+#endif
+
 namespace WebCore {
 
 using namespace HTMLNames;
@@ -543,6 +547,50 @@ void RenderThemeGtk::adjustProgressBarStyle(CSSStyleSelector*, RenderStyle* styl
 {
     style->setBoxShadow(0);
 }
+
+// These values have been copied from RenderThemeChromiumSkia.cpp
+static const int progressActivityBlocks = 5;
+static const int progressAnimationFrames = 10;
+static const double progressAnimationInterval = 0.125;
+double RenderThemeGtk::animationRepeatIntervalForProgressBar(RenderProgress*) const
+{
+    return progressAnimationInterval;
+}
+
+double RenderThemeGtk::animationDurationForProgressBar(RenderProgress*) const
+{
+    return progressAnimationInterval * progressAnimationFrames * 2; // "2" for back and forth;
+}
+
+IntRect RenderThemeGtk::calculateProgressRect(RenderObject* renderObject, const IntRect& fullBarRect)
+{
+    IntRect progressRect(fullBarRect);
+    RenderProgress* renderProgress = toRenderProgress(renderObject);
+    if (renderProgress->isDeterminate()) {
+        int progressWidth = progressRect.width() * renderProgress->position();
+        if (renderObject->style()->direction() == RTL)
+            progressRect.setX(progressRect.x() + progressRect.width() - progressWidth);
+        progressRect.setWidth(progressWidth);
+        return progressRect;
+    }
+
+    double animationProgress = renderProgress->animationProgress();
+
+    // Never let the progress rect shrink smaller than 2 pixels.
+    int newWidth = max(2, progressRect.width() / progressActivityBlocks);
+    int movableWidth = progressRect.width() - newWidth;
+    progressRect.setWidth(newWidth);
+
+    // We want the first 0.5 units of the animation progress to represent the
+    // forward motion and the second 0.5 units to represent the backward motion,
+    // thus we multiply by two here to get the full sweep of the progress bar with
+    // each direction.
+    if (animationProgress < 0.5)
+        progressRect.setX(progressRect.x() + (animationProgress * 2 * movableWidth));
+    else
+        progressRect.setX(progressRect.x() + ((1.0 - animationProgress) * 2 * movableWidth));
+    return progressRect;
+}
 #endif
 
 }
diff --git a/Source/WebCore/platform/gtk/RenderThemeGtk.h b/Source/WebCore/platform/gtk/RenderThemeGtk.h
index 65d9366..bce89d9 100644
--- a/Source/WebCore/platform/gtk/RenderThemeGtk.h
+++ b/Source/WebCore/platform/gtk/RenderThemeGtk.h
@@ -171,11 +171,16 @@ protected:
 
 private:
     void platformInit();
+    static void setTextInputBorders(RenderStyle*);
+    GRefPtr<GdkPixbuf> getStockIcon(GType, const char* iconName, gint direction, gint state, gint iconSize);
+
 #if ENABLE(VIDEO)
     bool paintMediaButton(RenderObject*, GraphicsContext*, const IntRect&, const char* iconName);
 #endif
-    static void setTextInputBorders(RenderStyle*);
-    GRefPtr<GdkPixbuf> getStockIcon(GType, const char* iconName, gint direction, gint state, gint iconSize);
+
+#if ENABLE(PROGRESS_TAG)
+    static IntRect calculateProgressRect(RenderObject*, const IntRect&);
+#endif
 
     mutable Color m_panelColor;
     mutable Color m_sliderColor;
@@ -197,6 +202,7 @@ private:
     GtkWidget* gtkContainer() const;
     GtkWidget* gtkRadioButton() const;
     GtkWidget* gtkCheckButton() const;
+    GtkWidget* gtkProgressBar() const;
 
     mutable GtkWidget* m_gtkWindow;
     mutable GtkWidget* m_gtkContainer;
@@ -207,6 +213,7 @@ private:
     mutable GtkWidget* m_gtkHScale;
     mutable GtkWidget* m_gtkRadioButton;
     mutable GtkWidget* m_gtkCheckButton;
+    mutable GtkWidget* m_gtkProgressBar;
 
     bool m_themePartsHaveRGBAColormap;
     friend class WidgetRenderingContext;
diff --git a/Source/WebCore/platform/gtk/RenderThemeGtk2.cpp b/Source/WebCore/platform/gtk/RenderThemeGtk2.cpp
index 97b4f78..093e735 100644
--- a/Source/WebCore/platform/gtk/RenderThemeGtk2.cpp
+++ b/Source/WebCore/platform/gtk/RenderThemeGtk2.cpp
@@ -45,10 +45,6 @@
 #include <gdk/gdk.h>
 #include <gtk/gtk.h>
 
-#if ENABLE(PROGRESS_TAG)
-#include "RenderProgress.h"
-#endif
-
 namespace WebCore {
 
 // This is not a static method, because we want to avoid having GTK+ headers in RenderThemeGtk.h.
@@ -67,6 +63,7 @@ void RenderThemeGtk::platformInit()
     m_gtkHScale = 0;
     m_gtkRadioButton = 0;
     m_gtkCheckButton = 0;
+    m_gtkProgressBar = 0;
 
     memset(&m_themeParts, 0, sizeof(GtkThemeParts));
     GdkColormap* colormap = gdk_screen_get_rgba_colormap(gdk_screen_get_default());
@@ -477,45 +474,25 @@ void RenderThemeGtk::adjustSliderThumbSize(RenderObject* o) const
 }
 
 #if ENABLE(PROGRESS_TAG)
-double RenderThemeGtk::animationRepeatIntervalForProgressBar(RenderProgress*) const
-{
-    // FIXME: It doesn't look like there is a good way yet to support animated
-    // progress bars with the Mozilla theme drawing code.
-    return 0;
-}
-
-double RenderThemeGtk::animationDurationForProgressBar(RenderProgress*) const
-{
-    // FIXME: It doesn't look like there is a good way yet to support animated
-    // progress bars with the Mozilla theme drawing code.
-    return 0;
-}
-
 bool RenderThemeGtk::paintProgressBar(RenderObject* renderObject, const PaintInfo& paintInfo, const IntRect& rect)
 {
-    if (!renderObject->isProgress())
-        return true;
+    GtkWidget* widget = gtkProgressBar();
+    gtk_widget_set_direction(widget, gtkTextDirection(renderObject->style()->direction()));
 
-    GtkWidget* progressBarWidget = moz_gtk_get_progress_widget();
-    if (!progressBarWidget)
-        return true;
+    WidgetRenderingContext widgetContext(paintInfo.context, rect);
+    IntRect fullProgressBarRect(IntPoint(), rect.size());
+    widgetContext.gtkPaintBox(fullProgressBarRect, widget, GTK_STATE_NORMAL, GTK_SHADOW_IN, "trough");
 
-    if (paintRenderObject(MOZ_GTK_PROGRESSBAR, renderObject, paintInfo.context, rect))
-        return true;
+    GtkStyle* style = gtk_widget_get_style(widget);
+    IntRect progressRect(fullProgressBarRect);
+    progressRect.inflateX(-style->xthickness);
+    progressRect.inflateY(-style->ythickness);
+    progressRect = RenderThemeGtk::calculateProgressRect(renderObject, progressRect);
 
-    IntRect chunkRect(rect);
-    RenderProgress* renderProgress = toRenderProgress(renderObject);
+    if (!progressRect.isEmpty())
+        widgetContext.gtkPaintBox(progressRect, widget, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, "bar");
 
-    GtkStyle* style = gtk_widget_get_style(progressBarWidget);
-    chunkRect.setHeight(chunkRect.height() - (2 * style->ythickness));
-    chunkRect.setY(chunkRect.y() + style->ythickness);
-    chunkRect.setWidth((chunkRect.width() - (2 * style->xthickness)) * renderProgress->position());
-    if (renderObject->style()->direction() == RTL)
-        chunkRect.setX(rect.x() + rect.width() - chunkRect.width() - style->xthickness);
-    else
-        chunkRect.setX(chunkRect.x() + style->xthickness);
-
-    return paintRenderObject(MOZ_GTK_PROGRESS_CHUNK, renderObject, paintInfo.context, chunkRect);
+    return false;
 }
 #endif
 
@@ -686,6 +663,16 @@ GtkWidget* RenderThemeGtk::gtkCheckButton() const
     return m_gtkCheckButton;
 }
 
+GtkWidget* RenderThemeGtk::gtkProgressBar() const
+{
+    if (m_gtkProgressBar)
+        return m_gtkProgressBar;
+    m_gtkProgressBar = gtk_progress_bar_new();
+    setupWidgetAndAddToContainer(m_gtkProgressBar, gtkContainer());
+    return m_gtkProgressBar;
+}
+
+
 GtkWidget* RenderThemeGtk::gtkScrollbar()
 {
     return moz_gtk_get_scrollbar_widget();
diff --git a/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp b/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp
index 212e29d..1a9f445 100644
--- a/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp
+++ b/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp
@@ -41,10 +41,6 @@
 #include <gdk/gdk.h>
 #include <gtk/gtk.h>
 
-#if ENABLE(PROGRESS_TAG)
-#include "RenderProgress.h"
-#endif
-
 namespace WebCore {
 
 // This is the default value defined by GTK+, where it was defined as MIN_ARROW_SIZE in gtkarrow.c.
@@ -690,20 +686,6 @@ void RenderThemeGtk::adjustSliderThumbSize(RenderObject* renderObject) const
 }
 
 #if ENABLE(PROGRESS_TAG)
-// These values have been copied from RenderThemeChromiumSkia.cpp
-static const int progressActivityBlocks = 5;
-static const int progressAnimationFrames = 10;
-static const double progressAnimationInterval = 0.125;
-double RenderThemeGtk::animationRepeatIntervalForProgressBar(RenderProgress*) const
-{
-    return progressAnimationInterval;
-}
-
-double RenderThemeGtk::animationDurationForProgressBar(RenderProgress*) const
-{
-    return progressAnimationInterval * progressAnimationFrames * 2; // "2" for back and forth;
-}
-
 bool RenderThemeGtk::paintProgressBar(RenderObject* renderObject, const PaintInfo& paintInfo, const IntRect& rect)
 {
     if (!renderObject->isProgress())
@@ -722,34 +704,18 @@ bool RenderThemeGtk::paintProgressBar(RenderObject* renderObject, const PaintInf
     gtk_style_context_save(context);
     gtk_style_context_add_class(context, GTK_STYLE_CLASS_PROGRESSBAR);
 
-    RenderProgress* renderProgress = toRenderProgress(renderObject);
 
     GtkBorder padding;
     gtk_style_context_get_padding(context, static_cast<GtkStateFlags>(0), &padding);
     IntRect progressRect(rect.x() + padding.left, rect.y() + padding.top,
                          rect.width() - (padding.left + padding.right),
                          rect.height() - (padding.top + padding.bottom));
-
-    if (renderProgress->isDeterminate()) {
-        progressRect.setWidth(progressRect.width() * renderProgress->position());
-        if (renderObject->style()->direction() == RTL)
-            progressRect.setX(rect.x() + rect.width() - progressRect.width() - padding.right);
-    } else {
-        double animationProgress = renderProgress->animationProgress();
-
-        progressRect.setWidth(max(2, progressRect.width() / progressActivityBlocks));
-        int movableWidth = rect.width() - progressRect.width();
-        if (animationProgress < 0.5)
-            progressRect.setX(progressRect.x() + (animationProgress * 2 * movableWidth));
-        else
-            progressRect.setX(progressRect.x() + ((1.0 - animationProgress) * 2 * movableWidth));
-    }
+    progressRect = RenderThemeGtk::calculateProgressRect(renderObject, progressRect);
 
     if (!progressRect.isEmpty())
         gtk_render_activity(context, paintInfo.context->platformContext(), progressRect.x(), progressRect.y(), progressRect.width(), progressRect.height());
 
     gtk_style_context_restore(context);
-
     return false;
 }
 #endif
diff --git a/Source/WebCore/platform/gtk/gtk2drawing.c b/Source/WebCore/platform/gtk/gtk2drawing.c
index 0c11aeb..ab79ce3 100644
--- a/Source/WebCore/platform/gtk/gtk2drawing.c
+++ b/Source/WebCore/platform/gtk/gtk2drawing.c
@@ -268,16 +268,6 @@ ensure_combo_box_widgets()
 }
 
 static gint
-ensure_progress_widget()
-{
-    if (!gParts->progresWidget) {
-        gParts->progresWidget = gtk_progress_bar_new();
-        setup_widget_prototype(gParts->progresWidget);
-    }
-    return MOZ_GTK_SUCCESS;
-}
-
-static gint
 ensure_scrolled_window_widget()
 {
     if (!gParts->scrolledWindowWidget) {
@@ -848,44 +838,6 @@ moz_gtk_combo_box_paint(GdkDrawable* drawable, GdkRectangle* rect,
     return MOZ_GTK_SUCCESS;
 }
 
-static gint
-moz_gtk_progressbar_paint(GdkDrawable* drawable, GdkRectangle* rect,
-                          GdkRectangle* cliprect, GtkTextDirection direction)
-{
-    GtkStyle* style;
-
-    ensure_progress_widget();
-    gtk_widget_set_direction(gParts->progresWidget, direction);
-
-    style = gtk_widget_get_style(gParts->progresWidget);
-
-    TSOffsetStyleGCs(style, rect->x, rect->y);
-    gtk_paint_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN,
-                  cliprect, gParts->progresWidget, "trough", rect->x, rect->y,
-                  rect->width, rect->height);
-
-    return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_progress_chunk_paint(GdkDrawable* drawable, GdkRectangle* rect,
-                             GdkRectangle* cliprect, GtkTextDirection direction)
-{
-    GtkStyle* style;
-
-    ensure_progress_widget();
-    gtk_widget_set_direction(gParts->progresWidget, direction);
-
-    style = gtk_widget_get_style(gParts->progresWidget);
-
-    TSOffsetStyleGCs(style, rect->x, rect->y);
-    gtk_paint_box(style, drawable, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
-                  cliprect, gParts->progresWidget, "bar", rect->x, rect->y,
-                  rect->width, rect->height);
-
-    return MOZ_GTK_SUCCESS;
-}
-
 gint
 moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
                           gint* right, gint* bottom, GtkTextDirection direction,
@@ -971,17 +923,12 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
 
             return MOZ_GTK_SUCCESS;
         }
-    case MOZ_GTK_PROGRESSBAR:
-        ensure_progress_widget();
-        w = gParts->progresWidget;
-        break;
     /* These widgets have no borders, since they are not containers. */
     case MOZ_GTK_SCROLLBAR_BUTTON:
     case MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL:
     case MOZ_GTK_SCROLLBAR_TRACK_VERTICAL:
     case MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL:
     case MOZ_GTK_SCROLLBAR_THUMB_VERTICAL:
-    case MOZ_GTK_PROGRESS_CHUNK:
         *left = *top = *right = *bottom = 0;
         return MOZ_GTK_SUCCESS;
     default:
@@ -1057,13 +1004,6 @@ moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable,
         return moz_gtk_combo_box_paint(drawable, rect, cliprect, state,
                                        (gboolean) flags, direction);
         break;
-    case MOZ_GTK_PROGRESSBAR:
-        return moz_gtk_progressbar_paint(drawable, rect, cliprect, direction);
-        break;
-    case MOZ_GTK_PROGRESS_CHUNK:
-        return moz_gtk_progress_chunk_paint(drawable, rect, cliprect,
-                                            direction);
-        break;
     default:
         g_warning("Unknown widget type: %d", widget);
     }
@@ -1102,12 +1042,4 @@ void moz_gtk_destroy_theme_parts_widgets(GtkThemeParts* parts)
     }
 }
 
-GtkWidget* moz_gtk_get_progress_widget()
-{
-    if (!is_initialized)
-        return NULL;
-    ensure_progress_widget();
-    return gParts->progresWidget;
-}
-
 #endif // GTK_API_VERSION_2
diff --git a/Source/WebCore/platform/gtk/gtkdrawing.h b/Source/WebCore/platform/gtk/gtkdrawing.h
index 238a293..d4c59e4 100644
--- a/Source/WebCore/platform/gtk/gtkdrawing.h
+++ b/Source/WebCore/platform/gtk/gtkdrawing.h
@@ -99,7 +99,6 @@ typedef struct _GtkThemeParts {
     GtkWidget* comboBoxEntryTextareaWidget;
     GtkWidget* comboBoxEntryButtonWidget;
     GtkWidget* comboBoxEntryArrowWidget;
-    GtkWidget* progresWidget;
     GtkWidget* scrolledWindowWidget;
 } GtkThemeParts;
 
@@ -136,10 +135,6 @@ typedef enum {
   MOZ_GTK_SCROLLED_WINDOW,
   /* Paints a GtkOptionMenu. */
   MOZ_GTK_DROPDOWN,
-  /* Paints a GtkProgressBar. */
-  MOZ_GTK_PROGRESSBAR,
-  /* Paints a progress chunk of a GtkProgressBar. */
-  MOZ_GTK_PROGRESS_CHUNK
 } GtkThemeWidgetType;
 
 /*** General library functions ***/
@@ -242,12 +237,6 @@ moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics* metrics);
  */
 GtkWidget* moz_gtk_get_scrollbar_widget(void);
 
-/**
- * Retrieve an actual GTK progress bar widget for style analysis. It will not
- * be modified.
- */
-GtkWidget* moz_gtk_get_progress_widget(void);
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list