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

mrobinson at webkit.org mrobinson at webkit.org
Wed Dec 22 13:05:01 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit c6c1079a864ae1012ae23822a3f326f06b6de819
Author: mrobinson at webkit.org <mrobinson at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Sep 6 21:04:07 2010 +0000

    2010-09-06  Martin Robinson  <mrobinson at igalia.com>
    
            Reviewed by Gustavo Noronha Silva.
    
            [GTK] ScrollbarThemeGtk should be enabled for interior frame scrollbars
            https://bugs.webkit.org/show_bug.cgi?id=45046
    
            Make interior frame scrollbars "fully-fake," which means they do not rely
            at all on GTK+ for painting or behavior, but instead are typical WebCore
            scrollbars drawn according to the GTK+ theme. Move ScrollbarGtk to
            MainFrameScrollbarGtk and remove all logic in that file dealing with interior
            frame scrollbars.
    
            No new tests, as this is already covered by pixel tests for scrollbars,
            which were added in r66605.
    
            * GNUmakefile.am: Update sources list.
            * platform/ScrollView.h: Change the adjustment members to be smart pointers.
            * platform/Scrollbar.cpp: Enable THUMB_POSITION_AFFECTS_BUTTONS for GTK+ as well.
            * platform/gtk/MainFrameScrollbarGtk.cpp: Added.
            (MainFrameScrollbarGtk::create): Create a MainFrameScrollbarGtk instead of ScrollbarGtk.
            (MainFrameScrollbarGtk::MainFrameScrollbarGtk):
            (MainFrameScrollbarGtk::~MainFrameScrollbarGtk):
            (MainFrameScrollbarGtk::attachAdjustment):
            (MainFrameScrollbarGtk::detachAdjustment):
            (MainFrameScrollbarGtk::updateThumbPosition):
            (MainFrameScrollbarGtk::updateThumbProportion):
            (MainFrameScrollbarGtk::gtkValueChanged):
            (MainFrameScrollbarGtk::paint):
            * platform/gtk/MainFrameScrollbarGtk.h: Added.
            * platform/gtk/ScrollViewGtk.cpp:
            (WebCore::ScrollView::platformInit): Remove unnecessary initialization
            because of smart pointer change.
            (WebCore::ScrollView::createScrollbar): Instead of creating ScrollbarGtk for
            interior frame scrollbars, create a normal WebCore scrollbar.
            (WebCore::ScrollView::setGtkAdjustments): Added an extra assert which ensures
            that this method is never called with a non-null adjustment on an interior frame
            scrollbar.
            (WebCore::ScrollView::platformAddChild): Remove logic for interior frame scrollbars.
            (WebCore::ScrollView::platformRemoveChild): Remove logic for interior frame scrollbars.
            (WebCore::ScrollView::visibleContentRect): Use a more accurate guard for detecting
            transitionary states when accessing parent widgets. Explcitly guard against interior
            frame ScrollView's trying to determine size based on parent widgets.
            (WebCore::ScrollView::setScrollbarModes): This method was out of sync with the one
            it copy-and-pasted from. Update it and change the logic to do the right thing for
            interior frame scrollbars.
            * platform/gtk/ScrollbarGtk.cpp: Removed.
            * platform/gtk/ScrollbarGtk.h: Removed.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66848 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 1f34067..09c3268 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,52 @@
+2010-09-06  Martin Robinson  <mrobinson at igalia.com>
+
+        Reviewed by Gustavo Noronha Silva.
+
+        [GTK] ScrollbarThemeGtk should be enabled for interior frame scrollbars
+        https://bugs.webkit.org/show_bug.cgi?id=45046
+
+        Make interior frame scrollbars "fully-fake," which means they do not rely
+        at all on GTK+ for painting or behavior, but instead are typical WebCore
+        scrollbars drawn according to the GTK+ theme. Move ScrollbarGtk to
+        MainFrameScrollbarGtk and remove all logic in that file dealing with interior
+        frame scrollbars.
+
+        No new tests, as this is already covered by pixel tests for scrollbars,
+        which were added in r66605.
+
+        * GNUmakefile.am: Update sources list.
+        * platform/ScrollView.h: Change the adjustment members to be smart pointers.
+        * platform/Scrollbar.cpp: Enable THUMB_POSITION_AFFECTS_BUTTONS for GTK+ as well.
+        * platform/gtk/MainFrameScrollbarGtk.cpp: Added.
+        (MainFrameScrollbarGtk::create): Create a MainFrameScrollbarGtk instead of ScrollbarGtk.
+        (MainFrameScrollbarGtk::MainFrameScrollbarGtk):
+        (MainFrameScrollbarGtk::~MainFrameScrollbarGtk):
+        (MainFrameScrollbarGtk::attachAdjustment):
+        (MainFrameScrollbarGtk::detachAdjustment):
+        (MainFrameScrollbarGtk::updateThumbPosition):
+        (MainFrameScrollbarGtk::updateThumbProportion):
+        (MainFrameScrollbarGtk::gtkValueChanged):
+        (MainFrameScrollbarGtk::paint):
+        * platform/gtk/MainFrameScrollbarGtk.h: Added.
+        * platform/gtk/ScrollViewGtk.cpp:
+        (WebCore::ScrollView::platformInit): Remove unnecessary initialization
+        because of smart pointer change.
+        (WebCore::ScrollView::createScrollbar): Instead of creating ScrollbarGtk for
+        interior frame scrollbars, create a normal WebCore scrollbar.
+        (WebCore::ScrollView::setGtkAdjustments): Added an extra assert which ensures
+        that this method is never called with a non-null adjustment on an interior frame
+        scrollbar.
+        (WebCore::ScrollView::platformAddChild): Remove logic for interior frame scrollbars.
+        (WebCore::ScrollView::platformRemoveChild): Remove logic for interior frame scrollbars.
+        (WebCore::ScrollView::visibleContentRect): Use a more accurate guard for detecting
+        transitionary states when accessing parent widgets. Explcitly guard against interior
+        frame ScrollView's trying to determine size based on parent widgets.
+        (WebCore::ScrollView::setScrollbarModes): This method was out of sync with the one
+        it copy-and-pasted from. Update it and change the logic to do the right thing for
+        interior frame scrollbars.
+        * platform/gtk/ScrollbarGtk.cpp: Removed.
+        * platform/gtk/ScrollbarGtk.h: Removed.
+
 2010-09-06  Justin Schuh  <jschuh at chromium.org>
 
         Reviewed by Nikolas Zimmermann.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index d361810..98d3ce1 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -2503,6 +2503,8 @@ webcoregtk_sources += \
 	WebCore/platform/gtk/Language.cpp \
 	WebCore/platform/gtk/LocalizedStringsGtk.cpp \
 	WebCore/platform/gtk/LoggingGtk.cpp \
+	WebCore/platform/gtk/MainFrameScrollbarGtk.cpp \
+	WebCore/platform/gtk/MainFrameScrollbarGtk.h \
 	WebCore/platform/gtk/MIMETypeRegistryGtk.cpp \
 	WebCore/platform/gtk/MouseEventGtk.cpp \
 	WebCore/platform/gtk/PasteboardGtk.cpp \
@@ -2513,8 +2515,6 @@ webcoregtk_sources += \
 	WebCore/platform/gtk/PopupMenuGtk.h \
 	WebCore/platform/gtk/RenderThemeGtk.cpp \
 	WebCore/platform/gtk/RenderThemeGtk.h \
-	WebCore/platform/gtk/ScrollbarGtk.cpp \
-	WebCore/platform/gtk/ScrollbarGtk.h \
 	WebCore/platform/gtk/ScrollbarThemeGtk.cpp \
 	WebCore/platform/gtk/ScrollbarThemeGtk.h \
 	WebCore/platform/gtk/ScrollViewGtk.cpp \
diff --git a/WebCore/platform/ScrollView.h b/WebCore/platform/ScrollView.h
index adcfaf9..940ead0 100644
--- a/WebCore/platform/ScrollView.h
+++ b/WebCore/platform/ScrollView.h
@@ -40,6 +40,7 @@
 #endif
 
 #if PLATFORM(GTK)
+#include "GRefPtrGtk.h"
 typedef struct _GtkAdjustment GtkAdjustment;
 #endif
 
@@ -333,9 +334,11 @@ private:
 #if PLATFORM(GTK)
 public:
     void setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, bool resetValues = true);
-    GtkAdjustment* m_horizontalAdjustment;
-    GtkAdjustment* m_verticalAdjustment;
     void setScrollOffset(const IntSize& offset) { m_scrollOffset = offset; }
+
+private:
+    PlatformRefPtr<GtkAdjustment> m_horizontalAdjustment;
+    PlatformRefPtr<GtkAdjustment> m_verticalAdjustment;
 #endif
 
 #if PLATFORM(WX)
diff --git a/WebCore/platform/Scrollbar.cpp b/WebCore/platform/Scrollbar.cpp
index ff8f66f..99b32fd 100644
--- a/WebCore/platform/Scrollbar.cpp
+++ b/WebCore/platform/Scrollbar.cpp
@@ -40,7 +40,7 @@
 
 using namespace std;
 
-#if PLATFORM(CHROMIUM) && OS(LINUX)
+#if PLATFORM(CHROMIUM) && OS(LINUX) || PLATFORM(GTK)
 // The position of the scrollbar thumb affects the appearance of the steppers, so
 // when the thumb moves, we have to invalidate them for painting.
 #define THUMB_POSITION_AFFECTS_BUTTONS
@@ -48,7 +48,7 @@ using namespace std;
 
 namespace WebCore {
 
-#if !PLATFORM(GTK) && !PLATFORM(EFL)
+#if !PLATFORM(EFL)
 PassRefPtr<Scrollbar> Scrollbar::createNativeScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize size)
 {
     return adoptRef(new Scrollbar(client, orientation, size));
diff --git a/WebCore/platform/gtk/MainFrameScrollbarGtk.cpp b/WebCore/platform/gtk/MainFrameScrollbarGtk.cpp
new file mode 100644
index 0000000..6e739ff
--- /dev/null
+++ b/WebCore/platform/gtk/MainFrameScrollbarGtk.cpp
@@ -0,0 +1,118 @@
+/*
+ *  Copyright (C) 2007, 2009 Holger Hans Peter Freyther zecke at selfish.org
+ *  Copyright (C) 2010 Gustavo Noronha Silva <gns at gnome.org>
+ *  Copyright (C) 2010 Collabora Ltd.
+ *  Copyright (C) 2010 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "MainFrameScrollbarGtk.h"
+
+#include "GraphicsContext.h"
+#include "GtkVersioning.h"
+#include "IntRect.h"
+#include <gtk/gtk.h>
+
+using namespace WebCore;
+
+PassRefPtr<MainFrameScrollbarGtk> MainFrameScrollbarGtk::create(ScrollbarClient* client, ScrollbarOrientation orientation, GtkAdjustment* adj)
+{
+    return adoptRef(new MainFrameScrollbarGtk(client, orientation, adj));
+}
+
+// Main frame scrollbars are slaves to a GtkAdjustment. If a main frame
+// scrollbar has an m_adjustment, it belongs to the container (a GtkWidget such
+// as GtkScrolledWindow). The adjustment may also be null, in which case there
+// is no containing view or the parent ScrollView is in some sort of transition
+// state. These scrollbars are never painted, as the container takes care of
+// that. They exist only to shuttle data from the GtkWidget container into
+// WebCore and vice-versa.
+MainFrameScrollbarGtk::MainFrameScrollbarGtk(ScrollbarClient* client, ScrollbarOrientation orientation, GtkAdjustment* adjustment)
+    : Scrollbar(client, orientation, RegularScrollbar)
+    , m_adjustment(0)
+{
+    attachAdjustment(adjustment);
+
+    // We have nothing to show as we are solely operating on the GtkAdjustment.
+    resize(0, 0);
+}
+
+MainFrameScrollbarGtk::~MainFrameScrollbarGtk()
+{
+    if (m_adjustment)
+        detachAdjustment();
+}
+
+void MainFrameScrollbarGtk::attachAdjustment(GtkAdjustment* adjustment)
+{
+    if (m_adjustment)
+        detachAdjustment();
+
+    m_adjustment = adjustment;
+    if (!m_adjustment)
+        return;
+
+    g_signal_connect(m_adjustment.get(), "value-changed", G_CALLBACK(MainFrameScrollbarGtk::gtkValueChanged), this);
+    updateThumbProportion();
+    updateThumbPosition();
+}
+
+void MainFrameScrollbarGtk::detachAdjustment()
+{
+    if (!m_adjustment)
+        return;
+
+    g_signal_handlers_disconnect_by_func(G_OBJECT(m_adjustment.get()), (gpointer)MainFrameScrollbarGtk::gtkValueChanged, this);
+
+    // For the case where we only operate on the GtkAdjustment it is best to
+    // reset the values so that the surrounding scrollbar gets updated, or
+    // e.g. for a GtkScrolledWindow the scrollbar gets hidden.
+    gtk_adjustment_configure(m_adjustment.get(), 0, 0, 0, 0, 0, 0);
+
+    m_adjustment = 0;
+}
+
+void MainFrameScrollbarGtk::updateThumbPosition()
+{
+    if (!m_adjustment || gtk_adjustment_get_value(m_adjustment.get()) == m_currentPos)
+        return;
+    gtk_adjustment_set_value(m_adjustment.get(), m_currentPos);
+}
+
+void MainFrameScrollbarGtk::updateThumbProportion()
+{
+    if (!m_adjustment)
+        return;
+    gtk_adjustment_configure(m_adjustment.get(),
+                             gtk_adjustment_get_value(m_adjustment.get()),
+                             gtk_adjustment_get_lower(m_adjustment.get()),
+                             m_totalSize,
+                             m_lineStep,
+                             m_pageStep,
+                             m_visibleSize);
+}
+
+void MainFrameScrollbarGtk::gtkValueChanged(GtkAdjustment*, MainFrameScrollbarGtk* that)
+{
+    that->setValue(static_cast<int>(gtk_adjustment_get_value(that->m_adjustment.get())));
+}
+
+void MainFrameScrollbarGtk::paint(GraphicsContext* context, const IntRect& rect)
+{
+    // Main frame scrollbars are not painted by WebCore.
+    return;
+}
diff --git a/WebCore/platform/gtk/MainFrameScrollbarGtk.h b/WebCore/platform/gtk/MainFrameScrollbarGtk.h
new file mode 100644
index 0000000..8271ef5
--- /dev/null
+++ b/WebCore/platform/gtk/MainFrameScrollbarGtk.h
@@ -0,0 +1,52 @@
+/*
+ *  Copyright (C) 2010 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+
+#ifndef MainFrameScrollbarGtk_h
+#define MainFrameScrollbarGtk_h
+
+#include "GRefPtrGtk.h"
+#include "Scrollbar.h"
+#include <wtf/PassRefPtr.h>
+
+typedef struct _GtkAdjustment GtkAdjustment;
+
+namespace WebCore {
+
+class MainFrameScrollbarGtk : public Scrollbar {
+public:
+    ~MainFrameScrollbarGtk();
+    virtual void paint(GraphicsContext*, const IntRect&);
+    void detachAdjustment();
+    void attachAdjustment(GtkAdjustment*);
+    static PassRefPtr<MainFrameScrollbarGtk> create(ScrollbarClient*, ScrollbarOrientation, GtkAdjustment*);
+
+protected:
+    virtual void updateThumbPosition();
+    virtual void updateThumbProportion();
+
+private:
+    MainFrameScrollbarGtk(ScrollbarClient*, ScrollbarOrientation, GtkAdjustment*);
+    static void gtkValueChanged(GtkAdjustment*, MainFrameScrollbarGtk*);
+
+    PlatformRefPtr<GtkAdjustment> m_adjustment;
+};
+
+}
+
+#endif // ScrollbarGtk_h
diff --git a/WebCore/platform/gtk/ScrollViewGtk.cpp b/WebCore/platform/gtk/ScrollViewGtk.cpp
index 565123c..eb313e0 100644
--- a/WebCore/platform/gtk/ScrollViewGtk.cpp
+++ b/WebCore/platform/gtk/ScrollViewGtk.cpp
@@ -39,10 +39,10 @@
 #include "GtkVersioning.h"
 #include "HostWindow.h"
 #include "IntRect.h"
+#include "MainFrameScrollbarGtk.h"
 #include "Page.h"
 #include "PlatformMouseEvent.h"
 #include "PlatformWheelEvent.h"
-#include "ScrollbarGtk.h"
 #include "ScrollbarTheme.h"
 
 #include <gtk/gtk.h>
@@ -53,8 +53,6 @@ namespace WebCore {
 
 void ScrollView::platformInit()
 {
-    m_horizontalAdjustment = 0;
-    m_verticalAdjustment = 0;
 }
 
 void ScrollView::platformDestroy()
@@ -65,9 +63,8 @@ void ScrollView::platformDestroy()
 
 PassRefPtr<Scrollbar> ScrollView::createScrollbar(ScrollbarOrientation orientation)
 {
-    // If this is an interior frame scrollbar, we want to create a scrollbar without
-    // passing a GtkAdjustment. This will cause the Scrollbar to create a native GTK+
-    // scrollbar.
+    // If this is an interior frame scrollbar, we want to create a totally fake
+    // scrollbar with no GtkAdjustment backing it.
     if (parent())
         return Scrollbar::createNativeScrollbar(this, orientation, RegularScrollbar);
 
@@ -75,10 +72,10 @@ PassRefPtr<Scrollbar> ScrollView::createScrollbar(ScrollbarOrientation orientati
     // and defers to our GtkAdjustment for all of its state. Note that the GtkAdjustment
     // may be null here.
     if (orientation == HorizontalScrollbar)
-        return ScrollbarGtk::createScrollbar(this, orientation, m_horizontalAdjustment);
+        return MainFrameScrollbarGtk::create(this, orientation, m_horizontalAdjustment.get());
 
     // VerticalScrollbar
-    return ScrollbarGtk::createScrollbar(this, orientation, m_verticalAdjustment);
+    return MainFrameScrollbarGtk::create(this, orientation, m_verticalAdjustment.get());
 }
 
 /*
@@ -89,15 +86,21 @@ void ScrollView::setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, boo
 {
     ASSERT(!hadj == !vadj);
 
+    // If this is a non-main frame ScrollView, we do not want to set the
+    // m_horizontalAdjustments & m_verticalAdjustments members. At the same
+    // time we want to to allow FrameLoaderClientGtk.cpp to call 
+    // ScrollView::setGtkAdjustments(0, 0) unconditionally.
+    ASSERT(!parent() || !hadj);
+
     m_horizontalAdjustment = hadj;
     m_verticalAdjustment = vadj;
 
     if (!m_horizontalAdjustment) {
-        ScrollbarGtk* hScrollbar = reinterpret_cast<ScrollbarGtk*>(horizontalScrollbar());
+        MainFrameScrollbarGtk* hScrollbar = reinterpret_cast<MainFrameScrollbarGtk*>(horizontalScrollbar());
         if (hScrollbar)
             hScrollbar->detachAdjustment();
 
-        ScrollbarGtk* vScrollbar = reinterpret_cast<ScrollbarGtk*>(verticalScrollbar());
+        MainFrameScrollbarGtk* vScrollbar = reinterpret_cast<MainFrameScrollbarGtk*>(verticalScrollbar());
         if (vScrollbar)
             vScrollbar->detachAdjustment();
 
@@ -109,11 +112,11 @@ void ScrollView::setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, boo
     setHasVerticalScrollbar(true);
     setHasHorizontalScrollbar(true);
 
-    ScrollbarGtk* hScrollbar = reinterpret_cast<ScrollbarGtk*>(horizontalScrollbar());
-    hScrollbar->attachAdjustment(m_horizontalAdjustment);
+    MainFrameScrollbarGtk* hScrollbar = reinterpret_cast<MainFrameScrollbarGtk*>(horizontalScrollbar());
+    hScrollbar->attachAdjustment(m_horizontalAdjustment.get());
 
-    ScrollbarGtk* vScrollbar = reinterpret_cast<ScrollbarGtk*>(verticalScrollbar());
-    vScrollbar->attachAdjustment(m_verticalAdjustment);
+    MainFrameScrollbarGtk* vScrollbar = reinterpret_cast<MainFrameScrollbarGtk*>(verticalScrollbar());
+    vScrollbar->attachAdjustment(m_verticalAdjustment.get());
 
     // We used to reset everything to 0 here, but when page cache
     // is enabled we reuse FrameViews that are cached. Since their
@@ -124,7 +127,7 @@ void ScrollView::setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, boo
     // able to report correct values.
 
     int horizontalPageStep = max(max<int>(frameRect().width() * Scrollbar::minFractionToStepWhenPaging(), frameRect().width() - Scrollbar::maxOverlapBetweenPages()), 1);
-    gtk_adjustment_configure(m_horizontalAdjustment,
+    gtk_adjustment_configure(m_horizontalAdjustment.get(),
                              resetValues ? 0 : scrollOffset().width(), 0,
                              resetValues ? 0 : contentsSize().width(),
                              resetValues ? 0 : Scrollbar::pixelsPerLineStep(),
@@ -132,7 +135,7 @@ void ScrollView::setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, boo
                              resetValues ? 0 : frameRect().width());
 
     int verticalPageStep = max(max<int>(frameRect().height() * Scrollbar::minFractionToStepWhenPaging(), frameRect().height() - Scrollbar::maxOverlapBetweenPages()), 1);
-    gtk_adjustment_configure(m_verticalAdjustment,
+    gtk_adjustment_configure(m_verticalAdjustment.get(),
                              resetValues ? 0 : scrollOffset().height(), 0,
                              resetValues ? 0 : contentsSize().height(),
                              resetValues ? 0 : Scrollbar::pixelsPerLineStep(),
@@ -142,72 +145,73 @@ void ScrollView::setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, boo
 
 void ScrollView::platformAddChild(Widget* child)
 {
-    if (!GTK_IS_SOCKET(child->platformWidget()))
-        gtk_container_add(GTK_CONTAINER(hostWindow()->platformPageClient()), child->platformWidget());
 }
 
 void ScrollView::platformRemoveChild(Widget* child)
 {
-    GtkWidget* parent;
-
-    // HostWindow can be NULL here. If that's the case
-    // let's grab the child's parent instead.
-    if (hostWindow())
-        parent = GTK_WIDGET(hostWindow()->platformPageClient());
-    else
-        parent = GTK_WIDGET(gtk_widget_get_parent(child->platformWidget()));
-
-    if (GTK_IS_CONTAINER(parent) && parent == gtk_widget_get_parent(child->platformWidget()))
-        gtk_container_remove(GTK_CONTAINER(parent), child->platformWidget());
 }
 
 IntRect ScrollView::visibleContentRect(bool includeScrollbars) const
 {
-    if (!m_horizontalAdjustment)
+    // If we are an interior frame scrollbar or are in some sort of transition
+    // state, just calculate our size based on what the GTK+ theme says the
+    // scrollbar width should be.
+    if (parent() || !hostWindow() || !hostWindow()->platformPageClient()) {
         return IntRect(IntPoint(m_scrollOffset.width(), m_scrollOffset.height()),
                        IntSize(max(0, width() - (verticalScrollbar() && !includeScrollbars ? verticalScrollbar()->width() : 0)),
                                max(0, height() - (horizontalScrollbar() && !includeScrollbars ? horizontalScrollbar()->height() : 0))));
+    }
 
-    // Main frame.
+    // We don't have a parent, so we are the main frame and thus have
+    // a parent widget which we can use to measure the visible region.
     GtkWidget* measuredWidget = hostWindow()->platformPageClient();
-    GtkWidget* parent = gtk_widget_get_parent(measuredWidget);
+    GtkWidget* parentWidget = gtk_widget_get_parent(measuredWidget);
 
     // We may not be in a widget that displays scrollbars, but we may
     // have other kinds of decoration that make us smaller.
-    if (parent && includeScrollbars)
-        measuredWidget = parent;
+    if (parentWidget && includeScrollbars)
+        measuredWidget = parentWidget;
 
     GtkAllocation allocation;
-#if GTK_CHECK_VERSION(2, 18, 0)
     gtk_widget_get_allocation(measuredWidget, &allocation);
-#else
-    allocation = measuredWidget->allocation;
-#endif
     return IntRect(IntPoint(m_scrollOffset.width(), m_scrollOffset.height()),
                    IntSize(allocation.width, allocation.height));
 }
 
-void ScrollView::setScrollbarModes(ScrollbarMode horizontalMode, ScrollbarMode verticalMode, bool, bool)
+void ScrollView::setScrollbarModes(ScrollbarMode horizontalMode, ScrollbarMode verticalMode, bool horizontalLock, bool verticalLock)
 {
-    if (horizontalMode == m_horizontalScrollbarMode && verticalMode == m_verticalScrollbarMode)
-        return;
+    // FIXME: Restructure the ScrollView abstraction so that we do not have to
+    // copy this verbatim from ScrollView.cpp. Until then, we should make sure this
+    // is kept in sync.
+    bool needsUpdate = false;
+
+    if (horizontalMode != horizontalScrollbarMode() && !m_horizontalScrollbarLock) {
+        m_horizontalScrollbarMode = horizontalMode;
+        needsUpdate = true;
+    }
+
+    if (verticalMode != verticalScrollbarMode() && !m_verticalScrollbarLock) {
+        m_verticalScrollbarMode = verticalMode;
+        needsUpdate = true;
+    }
 
-    m_horizontalScrollbarMode = horizontalMode;
-    m_verticalScrollbarMode = verticalMode;
+    if (horizontalLock)
+        setHorizontalScrollbarLock();
 
-    // We don't really care about reporting policy changes on frames
-    // that have no adjustments attached to them.
-    if (!m_horizontalAdjustment) {
+    if (verticalLock)
+        setVerticalScrollbarLock();
+
+    if (needsUpdate)
         updateScrollbars(scrollOffset());
-        return;
-    }
 
-    if (!isFrameView())
+    // We don't need to report policy changes on ScrollView's unless this
+    // one has an adjustment attached and it is a main frame.
+    if (!m_horizontalAdjustment || parent() || !isFrameView())
         return;
 
     // For frames that do have adjustments attached, we want to report
     // policy changes, so that they may be applied to the widget to
-    // which the WebView has been added, for instance.
+    // which the WebView's container (e.g. GtkScrolledWindow).
     if (hostWindow())
         hostWindow()->scrollbarsModeDidChange();
 }
diff --git a/WebCore/platform/gtk/ScrollbarGtk.cpp b/WebCore/platform/gtk/ScrollbarGtk.cpp
deleted file mode 100644
index 8a1c4fa..0000000
--- a/WebCore/platform/gtk/ScrollbarGtk.cpp
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- *  Copyright (C) 2007, 2009 Holger Hans Peter Freyther zecke at selfish.org
- *  Copyright (C) 2010 Gustavo Noronha Silva <gns at gnome.org>
- *  Copyright (C) 2010 Collabora Ltd.
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "config.h"
-#include "ScrollbarGtk.h"
-
-#include "FrameView.h"
-#include "GraphicsContext.h"
-#include "GtkVersioning.h"
-#include "IntRect.h"
-#include "ScrollbarTheme.h"
-
-#include <gtk/gtk.h>
-
-using namespace WebCore;
-
-PassRefPtr<Scrollbar> Scrollbar::createNativeScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize size)
-{
-    return adoptRef(new ScrollbarGtk(client, orientation, size));
-}
-
-PassRefPtr<ScrollbarGtk> ScrollbarGtk::createScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, GtkAdjustment* adj)
-{
-    return adoptRef(new ScrollbarGtk(client, orientation, adj));
-}
-
-static gboolean gtkScrollEventCallback(GtkWidget* widget, GdkEventScroll* event, ScrollbarGtk*)
-{
-    /* Scroll only if our parent rejects the scroll event. The rationale for
-     * this is that we want the main frame to scroll when we move the mouse
-     * wheel over a child scrollbar in most cases. */
-    return gtk_widget_event(gtk_widget_get_parent(widget), reinterpret_cast<GdkEvent*>(event));
-}
-
-ScrollbarGtk::ScrollbarGtk(ScrollbarClient* client, ScrollbarOrientation orientation,
-                           ScrollbarControlSize controlSize)
-    : Scrollbar(client, orientation, controlSize)
-    , m_adjustment(GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)))
-{
-    GtkWidget* scrollBar = orientation == HorizontalScrollbar ?
-                           gtk_hscrollbar_new(m_adjustment):
-                           gtk_vscrollbar_new(m_adjustment);
-    gtk_widget_show(scrollBar);
-    g_object_ref(m_adjustment);
-    g_signal_connect(m_adjustment, "value-changed", G_CALLBACK(ScrollbarGtk::gtkValueChanged), this);
-    g_signal_connect(scrollBar, "scroll-event", G_CALLBACK(gtkScrollEventCallback), this);
-
-    setPlatformWidget(scrollBar);
-
-    /*
-     * assign a sane default width and height to the Scrollbar, otherwise
-     * we will end up with a 0 width scrollbar.
-     */
-    resize(ScrollbarTheme::nativeTheme()->scrollbarThickness(),
-           ScrollbarTheme::nativeTheme()->scrollbarThickness());
-}
-
-// Create a ScrollbarGtk on top of an existing GtkAdjustment but do not create a
-// GtkScrollbar on top of this adjustment. The goal is to have a WebCore::Scrollbar
-// that will manipulate the GtkAdjustment properties, will react to the changed
-// value but will not consume any space on the screen and will not be painted
-// at all. It is achieved by not calling setPlatformWidget.
-ScrollbarGtk::ScrollbarGtk(ScrollbarClient* client, ScrollbarOrientation orientation, GtkAdjustment* adjustment)
-    : Scrollbar(client, orientation, RegularScrollbar)
-    , m_adjustment(adjustment)
-{
-    if (m_adjustment) {
-        g_object_ref(m_adjustment);
-        g_signal_connect(m_adjustment, "value-changed", G_CALLBACK(ScrollbarGtk::gtkValueChanged), this);
-    }
-
-    // We have nothing to show as we are solely operating on the GtkAdjustment
-    resize(0, 0);
-}
-
-ScrollbarGtk::~ScrollbarGtk()
-{
-    if (m_adjustment)
-        detachAdjustment();
-}
-
-void ScrollbarGtk::attachAdjustment(GtkAdjustment* adjustment)
-{
-    if (platformWidget())
-        return;
-
-    if (m_adjustment)
-        detachAdjustment();
-
-    m_adjustment = adjustment;
-
-    if (m_adjustment) {
-        g_object_ref(m_adjustment);
-        g_signal_connect(m_adjustment, "value-changed", G_CALLBACK(ScrollbarGtk::gtkValueChanged), this);
-    }
-
-    updateThumbProportion();
-    updateThumbPosition();
-}
-
-void ScrollbarGtk::detachAdjustment()
-{
-    if (!m_adjustment)
-        return;
-
-    g_signal_handlers_disconnect_by_func(G_OBJECT(m_adjustment), (gpointer)ScrollbarGtk::gtkValueChanged, this);
-
-    // For the case where we only operate on the GtkAdjustment it is best to
-    // reset the values so that the surrounding scrollbar gets updated, or
-    // e.g. for a GtkScrolledWindow the scrollbar gets hidden.
-    gtk_adjustment_configure(m_adjustment, 0, 0, 0, 0, 0, 0);
-
-    g_object_unref(m_adjustment);
-    m_adjustment = 0;
-}
-
-IntPoint ScrollbarGtk::getLocationInParentWindow(const IntRect& rect)
-{
-    IntPoint loc;
-
-    if (parent()->isScrollViewScrollbar(this))
-        loc = parent()->convertToContainingWindow(rect.location());
-    else
-        loc = parent()->contentsToWindow(rect.location());
-
-    return loc;
-}
-
-void ScrollbarGtk::frameRectsChanged()
-{
-    if (!parent() || !platformWidget())
-        return;
-
-    IntPoint loc = getLocationInParentWindow(frameRect());
-
-    // Don't allow the allocation size to be negative
-    IntSize sz = frameRect().size();
-    sz.clampNegativeToZero();
-
-    GtkAllocation allocation = { loc.x(), loc.y(), sz.width(), sz.height() };
-    gtk_widget_size_allocate(platformWidget(), &allocation);
-}
-
-void ScrollbarGtk::updateThumbPosition()
-{
-    if (!m_adjustment)
-        return;
-
-    if (gtk_adjustment_get_value(m_adjustment) != m_currentPos)
-        gtk_adjustment_set_value(m_adjustment, m_currentPos);
-}
-
-void ScrollbarGtk::updateThumbProportion()
-{
-    if (!m_adjustment)
-        return;
-
-    gtk_adjustment_configure(m_adjustment,
-                             gtk_adjustment_get_value(m_adjustment),
-                             gtk_adjustment_get_lower(m_adjustment),
-                             m_totalSize,
-                             m_lineStep,
-                             m_pageStep,
-                             m_visibleSize);
-}
-
-void ScrollbarGtk::setFrameRect(const IntRect& rect)
-{
-    Widget::setFrameRect(rect);
-    frameRectsChanged();
-}
-
-void ScrollbarGtk::gtkValueChanged(GtkAdjustment*, ScrollbarGtk* that)
-{
-    that->setValue(static_cast<int>(gtk_adjustment_get_value(that->m_adjustment)));
-}
-
-void ScrollbarGtk::setEnabled(bool shouldEnable)
-{
-    if (enabled() == shouldEnable)
-        return;
-        
-    Scrollbar::setEnabled(shouldEnable);
-    if (platformWidget()) 
-        gtk_widget_set_sensitive(platformWidget(), shouldEnable);
-}
-
-/*
- * Strategy to painting a Widget:
- *  1.) do not paint if there is no GtkWidget set
- *  2.) We assume that the widget has no window and that frameRectsChanged positioned
- *      the widget correctly. ATM we do not honor the GraphicsContext translation.
- */
-void ScrollbarGtk::paint(GraphicsContext* context, const IntRect& rect)
-{
-    if (!platformWidget())
-        return;
-
-    if (!context->gdkExposeEvent())
-        return;
-
-    GtkWidget* widget = platformWidget();
-    ASSERT(!gtk_widget_get_has_window(widget));
-
-    GdkEvent* event = gdk_event_new(GDK_EXPOSE);
-    event->expose = *context->gdkExposeEvent();
-    event->expose.area = static_cast<GdkRectangle>(rect);
-
-    IntPoint loc = getLocationInParentWindow(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.
-     */
-    g_object_ref(event->expose.window);
-
-    /*
-     * 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/ScrollbarGtk.h b/WebCore/platform/gtk/ScrollbarGtk.h
deleted file mode 100644
index 1a078c9..0000000
--- a/WebCore/platform/gtk/ScrollbarGtk.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollbarGtk_h
-#define ScrollbarGtk_h
-
-#include "Scrollbar.h"
-#include <wtf/PassRefPtr.h>
-
-namespace WebCore {
-
-class ScrollbarGtk : public Scrollbar {
-public:
-    friend class Scrollbar;
-    friend class ScrollView;
-    ~ScrollbarGtk();
-
-    virtual void setFrameRect(const IntRect&);
-    virtual void paint(GraphicsContext*, const IntRect&);
-    
-    virtual bool handleMouseMoveEvent(const PlatformMouseEvent&) { return false; }
-    virtual bool handleMouseOutEvent(const PlatformMouseEvent&) { return false; }
-    virtual bool handleMousePressEvent(const PlatformMouseEvent&) { return false; }
-    virtual bool handleMouseReleaseEvent(const PlatformMouseEvent&) { return false; }
-
-    virtual void setEnabled(bool);
-
-    virtual void frameRectsChanged();
-
-protected:
-    static PassRefPtr<ScrollbarGtk> createScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, GtkAdjustment*);
-
-    ScrollbarGtk(ScrollbarClient*, ScrollbarOrientation, ScrollbarControlSize);
-    ScrollbarGtk(ScrollbarClient*, ScrollbarOrientation, GtkAdjustment*);
-
-    virtual void updateThumbPosition();
-    virtual void updateThumbProportion();
-
-    void detachAdjustment();
-    void attachAdjustment(GtkAdjustment*);
-private:
-    static void gtkValueChanged(GtkAdjustment*, ScrollbarGtk*);
-    IntPoint getLocationInParentWindow(const IntRect&);
-    GtkAdjustment* m_adjustment;
-};
-
-}
-
-#endif // ScrollbarGtk_h

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list