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

weinig at apple.com weinig at apple.com
Sun Feb 20 23:57:30 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 10187a9768da1c82b1c70ccce8d4dcf274c77d32
Author: weinig at apple.com <weinig at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jan 27 05:12:24 2011 +0000

    Move ScrollView scroll wheel code to ScrollAnimator.
    
    Reviewed by Adam Roben.
    
    * platform/ScrollAnimator.cpp:
    (WebCore::ScrollAnimator::handleWheelEvent):
    * platform/ScrollAnimator.h:
    Moved implementation of handleWheelEvent from ScrollView::wheelEvent.
    
    * platform/ScrollView.cpp:
    (WebCore::ScrollView::wheelEvent):
    Call down to the ScrollableArea.
    
    * platform/ScrollableArea.cpp:
    (WebCore::ScrollableArea::handleWheelEvent):
    Call down to the ScrollAnimator.
    
    * platform/ScrollableArea.h:
    (WebCore::ScrollableArea::scrollPosition):
    (WebCore::ScrollableArea::minimumScrollPosition):
    (WebCore::ScrollableArea::maximumScrollPosition):
    (WebCore::ScrollableArea::visibleContentRect):
    (WebCore::ScrollableArea::visibleHeight):
    (WebCore::ScrollableArea::visibleWidth):
    Add functions needed to implement wheel event in the animator.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76757 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 3af0be6..8561f1d 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,31 @@
+2011-01-26  Sam Weinig  <sam at webkit.org>
+
+        Reviewed by Adam Roben.
+
+        Move ScrollView scroll wheel code to ScrollAnimator.
+
+        * platform/ScrollAnimator.cpp:
+        (WebCore::ScrollAnimator::handleWheelEvent):
+        * platform/ScrollAnimator.h:
+        Moved implementation of handleWheelEvent from ScrollView::wheelEvent.
+
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::wheelEvent):
+        Call down to the ScrollableArea.
+
+        * platform/ScrollableArea.cpp:
+        (WebCore::ScrollableArea::handleWheelEvent):
+        Call down to the ScrollAnimator.
+
+        * platform/ScrollableArea.h:
+        (WebCore::ScrollableArea::scrollPosition):
+        (WebCore::ScrollableArea::minimumScrollPosition):
+        (WebCore::ScrollableArea::maximumScrollPosition):
+        (WebCore::ScrollableArea::visibleContentRect):
+        (WebCore::ScrollableArea::visibleHeight):
+        (WebCore::ScrollableArea::visibleWidth):
+        Add functions needed to implement wheel event in the animator.
+
 2011-01-26  David Kilzer  <ddkilzer at apple.com>
 
         <http://webkit.org/b/53192> Add experimental support for HTTP pipelining in CFNetwork
diff --git a/Source/WebCore/platform/ScrollAnimator.cpp b/Source/WebCore/platform/ScrollAnimator.cpp
index 428a79d..faad79e 100644
--- a/Source/WebCore/platform/ScrollAnimator.cpp
+++ b/Source/WebCore/platform/ScrollAnimator.cpp
@@ -32,10 +32,13 @@
 #include "ScrollAnimator.h"
 
 #include "FloatPoint.h"
+#include "PlatformWheelEvent.h"
 #include "ScrollableArea.h"
 #include <algorithm>
 #include <wtf/PassOwnPtr.h>
 
+using namespace std;
+
 namespace WebCore {
 
 #if !ENABLE(SMOOTH_SCROLLING)
@@ -78,6 +81,38 @@ void ScrollAnimator::scrollToOffsetWithoutAnimation(const FloatPoint& offset)
     }
 }
 
+void ScrollAnimator::handleWheelEvent(PlatformWheelEvent& e)
+{
+    Scrollbar* horizontalScrollbar = m_scrollableArea->horizontalScrollbar();
+    Scrollbar* verticalScrollbar = m_scrollableArea->verticalScrollbar();
+
+    // Accept the event if we have a scrollbar in that direction and can still
+    // scroll any further.
+    float deltaX = horizontalScrollbar ? e.deltaX() : 0;
+    float deltaY = verticalScrollbar ? e.deltaY() : 0;
+
+    IntSize maxForwardScrollDelta = m_scrollableArea->maximumScrollPosition() - m_scrollableArea->scrollPosition();
+    IntSize maxBackwardScrollDelta = m_scrollableArea->scrollPosition() - m_scrollableArea->minimumScrollPosition();
+    if ((deltaX < 0 && maxForwardScrollDelta.width() > 0)
+        || (deltaX > 0 && maxBackwardScrollDelta.width() > 0)
+        || (deltaY < 0 && maxForwardScrollDelta.height() > 0)
+        || (deltaY > 0 && maxBackwardScrollDelta.height() > 0)) {
+        e.accept();
+        if (e.granularity() == ScrollByPageWheelEvent) {
+            ASSERT(!e.deltaX());
+            bool negative = deltaY < 0;
+            deltaY = max(max(static_cast<float>(m_scrollableArea->visibleHeight()) * Scrollbar::minFractionToStepWhenPaging(), static_cast<float>(m_scrollableArea->visibleHeight() - Scrollbar::maxOverlapBetweenPages())), 1.0f);
+            if (negative)
+                deltaY = -deltaY;
+        }
+
+        if (deltaY)
+            scroll(VerticalScrollbar, ScrollByPixel, verticalScrollbar->pixelStep(), -deltaY);
+        if (deltaX)
+            scroll(HorizontalScrollbar, ScrollByPixel, horizontalScrollbar->pixelStep(), -deltaX);
+    }
+}
+
 FloatPoint ScrollAnimator::currentPosition() const
 {
     return FloatPoint(m_currentPosX, m_currentPosY);
diff --git a/Source/WebCore/platform/ScrollAnimator.h b/Source/WebCore/platform/ScrollAnimator.h
index 155c6e5..a51abcb 100644
--- a/Source/WebCore/platform/ScrollAnimator.h
+++ b/Source/WebCore/platform/ScrollAnimator.h
@@ -37,6 +37,7 @@
 namespace WebCore {
 
 class FloatPoint;
+class PlatformWheelEvent;
 class ScrollableArea;
 
 class ScrollAnimator {
@@ -53,6 +54,8 @@ public:
 
     virtual void scrollToOffsetWithoutAnimation(const FloatPoint&);
 
+    virtual void handleWheelEvent(PlatformWheelEvent&);
+
     FloatPoint currentPosition() const;
 
 protected:
diff --git a/Source/WebCore/platform/ScrollView.cpp b/Source/WebCore/platform/ScrollView.cpp
index cc2a09e..814e65b 100644
--- a/Source/WebCore/platform/ScrollView.cpp
+++ b/Source/WebCore/platform/ScrollView.cpp
@@ -731,31 +731,7 @@ void ScrollView::wheelEvent(PlatformWheelEvent& e)
         return;
     }
 
-    // Accept the event if we have a scrollbar in that direction and can still
-    // scroll any further.
-    float deltaX = m_horizontalScrollbar ? e.deltaX() : 0;
-    float deltaY = m_verticalScrollbar ? e.deltaY() : 0;
-    
-    IntSize maxForwardScrollDelta = maximumScrollPosition() - scrollPosition();
-    IntSize maxBackwardScrollDelta = scrollPosition() - minimumScrollPosition();
-    if ((deltaX < 0 && maxForwardScrollDelta.width() > 0)
-        || (deltaX > 0 && maxBackwardScrollDelta.width() >0)
-        || (deltaY < 0 && maxForwardScrollDelta.height() > 0)
-        || (deltaY > 0 && maxBackwardScrollDelta.height() > 0)) {
-        e.accept();
-        if (e.granularity() == ScrollByPageWheelEvent) {
-            ASSERT(!e.deltaX());
-            bool negative = deltaY < 0;
-            deltaY = max(max(static_cast<float>(visibleHeight()) * Scrollbar::minFractionToStepWhenPaging(), static_cast<float>(visibleHeight() - Scrollbar::maxOverlapBetweenPages())), 1.0f);
-            if (negative)
-                deltaY = -deltaY;
-        }
-
-        if (deltaY)
-            ScrollableArea::scroll(ScrollUp, ScrollByPixel, deltaY);
-        if (deltaX)
-            ScrollableArea::scroll(ScrollLeft, ScrollByPixel, deltaX);
-    }
+    ScrollableArea::handleWheelEvent(e);
 }
 
 void ScrollView::setFrameRect(const IntRect& newRect)
diff --git a/Source/WebCore/platform/ScrollableArea.cpp b/Source/WebCore/platform/ScrollableArea.cpp
index 176cb7e..f379f54 100644
--- a/Source/WebCore/platform/ScrollableArea.cpp
+++ b/Source/WebCore/platform/ScrollableArea.cpp
@@ -108,6 +108,11 @@ void ScrollableArea::scrollToYOffsetWithoutAnimation(float y)
     scrollToOffsetWithoutAnimation(FloatPoint(m_scrollAnimator->currentPosition().x(), y));
 }
 
+void ScrollableArea::handleWheelEvent(PlatformWheelEvent& wheelEvent)
+{
+    m_scrollAnimator->handleWheelEvent(wheelEvent);
+}
+
 void ScrollableArea::setScrollOffsetFromAnimation(const IntPoint& offset)
 {
     // Tell the derived class to scroll its contents.
diff --git a/Source/WebCore/platform/ScrollableArea.h b/Source/WebCore/platform/ScrollableArea.h
index 148ecdb..a05fcf5 100644
--- a/Source/WebCore/platform/ScrollableArea.h
+++ b/Source/WebCore/platform/ScrollableArea.h
@@ -47,6 +47,8 @@ public:
     void scrollToXOffsetWithoutAnimation(float x);
     void scrollToYOffsetWithoutAnimation(float x);
 
+    void handleWheelEvent(PlatformWheelEvent&);
+
     virtual int scrollSize(ScrollbarOrientation) const = 0;
     virtual int scrollPosition(Scrollbar*) const = 0;
     virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) = 0;
@@ -82,6 +84,14 @@ public:
     virtual Scrollbar* horizontalScrollbar() const { return 0; }
     virtual Scrollbar* verticalScrollbar() const { return 0; }
 
+    virtual IntPoint scrollPosition() const { ASSERT_NOT_REACHED(); return IntPoint(); }
+    virtual IntPoint minimumScrollPosition() const { ASSERT_NOT_REACHED(); return IntPoint(); }
+    virtual IntPoint maximumScrollPosition() const { ASSERT_NOT_REACHED(); return IntPoint(); }
+
+    virtual IntRect visibleContentRect(bool = false) const { ASSERT_NOT_REACHED(); return IntRect(); }
+    virtual int visibleHeight() const { ASSERT_NOT_REACHED(); return 0; }
+    virtual int visibleWidth() const { ASSERT_NOT_REACHED(); return 0; }
+
 private:
     // NOTE: Only called from the ScrollAnimator.
     friend class ScrollAnimator;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list