Title: [141610] trunk/Source/WebCore
Revision
141610
Author
bda...@apple.com
Date
2013-02-01 10:59:08 -0800 (Fri, 01 Feb 2013)

Log Message

ScrollAnimatorMac should adopt contentAreaScrolledInDirection
https://bugs.webkit.org/show_bug.cgi?id=108647
-and corresponding-
<rdar://problem/12434779>

Reviewed by Anders Carlsson.

This patch makes notifyContentAreaScrolled() and notifyPositionChanged() take a 
FloatSize parameter that represents the scroll delta so that it can be passed 
along to contentAreaScrolledInDirection:. 

Pass along the scroll delta.
* platform/ScrollAnimator.cpp:
(WebCore::ScrollAnimator::scroll):
(WebCore::ScrollAnimator::scrollToOffsetWithoutAnimation):

The delta is not needed in this base-class implementation. It will only be needed 
in the ScrollAnimatorMac override.
(WebCore::ScrollAnimator::notifyPositionChanged):
* platform/ScrollAnimator.h:
(WebCore::ScrollAnimator::notifyContentAreaScrolled):

Pass along the delta.
* platform/ScrollAnimatorNone.cpp:
(WebCore::ScrollAnimatorNone::scrollToOffsetWithoutAnimation):
(WebCore::ScrollAnimatorNone::animationTimerFired):
* platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::scrollPositionChanged):

Add contentAreaScrolledInDirection: to the NSScrollerImpDetails.
* platform/mac/NSScrollerImpDetails.h:

New member variable m_contentAreaScrolledTimerScrollDelta stores the current 
scroll delta while we are waiting for m_sendContentAreaScrolledTimer to fire.
* platform/mac/ScrollAnimatorMac.h:

We need this so that we can call just contentAreaScrolled if 
contentAreaScrolledInDirection: is not available.
* platform/mac/ScrollAnimatorMac.mm:
(supportsContentAreaScrolledInDirection):

Pass along the delta.
(WebCore::ScrollAnimatorMac::immediateScrollTo):
(WebCore::ScrollAnimatorMac::notifyPositionChanged):
(WebCore::ScrollAnimatorMac::mayBeginScrollGesture):
(WebCore::ScrollAnimatorMac::notifyContentAreaScrolled):
(WebCore::ScrollAnimatorMac::immediateScrollBy):
(WebCore::ScrollAnimatorMac::sendContentAreaScrolledSoon):

If contentAreaScrolledInDirection: is available, call it with the delta, and then 
reset our delta. Otherwise, still call contentAreaScrolled.
(WebCore::ScrollAnimatorMac::sendContentAreaScrolledTimerFired):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (141609 => 141610)


--- trunk/Source/WebCore/ChangeLog	2013-02-01 18:56:23 UTC (rev 141609)
+++ trunk/Source/WebCore/ChangeLog	2013-02-01 18:59:08 UTC (rev 141610)
@@ -1,3 +1,58 @@
+2013-02-01  Beth Dakin  <bda...@apple.com>
+
+        ScrollAnimatorMac should adopt contentAreaScrolledInDirection
+        https://bugs.webkit.org/show_bug.cgi?id=108647
+        -and corresponding-
+        <rdar://problem/12434779>
+
+        Reviewed by Anders Carlsson.
+
+        This patch makes notifyContentAreaScrolled() and notifyPositionChanged() take a 
+        FloatSize parameter that represents the scroll delta so that it can be passed 
+        along to contentAreaScrolledInDirection:. 
+
+        Pass along the scroll delta.
+        * platform/ScrollAnimator.cpp:
+        (WebCore::ScrollAnimator::scroll):
+        (WebCore::ScrollAnimator::scrollToOffsetWithoutAnimation):
+
+        The delta is not needed in this base-class implementation. It will only be needed 
+        in the ScrollAnimatorMac override.
+        (WebCore::ScrollAnimator::notifyPositionChanged):
+        * platform/ScrollAnimator.h:
+        (WebCore::ScrollAnimator::notifyContentAreaScrolled):
+
+        Pass along the delta.
+        * platform/ScrollAnimatorNone.cpp:
+        (WebCore::ScrollAnimatorNone::scrollToOffsetWithoutAnimation):
+        (WebCore::ScrollAnimatorNone::animationTimerFired):
+        * platform/ScrollableArea.cpp:
+        (WebCore::ScrollableArea::scrollPositionChanged):
+
+        Add contentAreaScrolledInDirection: to the NSScrollerImpDetails.
+        * platform/mac/NSScrollerImpDetails.h:
+
+        New member variable m_contentAreaScrolledTimerScrollDelta stores the current 
+        scroll delta while we are waiting for m_sendContentAreaScrolledTimer to fire.
+        * platform/mac/ScrollAnimatorMac.h:
+
+        We need this so that we can call just contentAreaScrolled if 
+        contentAreaScrolledInDirection: is not available.
+        * platform/mac/ScrollAnimatorMac.mm:
+        (supportsContentAreaScrolledInDirection):
+
+        Pass along the delta.
+        (WebCore::ScrollAnimatorMac::immediateScrollTo):
+        (WebCore::ScrollAnimatorMac::notifyPositionChanged):
+        (WebCore::ScrollAnimatorMac::mayBeginScrollGesture):
+        (WebCore::ScrollAnimatorMac::notifyContentAreaScrolled):
+        (WebCore::ScrollAnimatorMac::immediateScrollBy):
+        (WebCore::ScrollAnimatorMac::sendContentAreaScrolledSoon):
+
+        If contentAreaScrolledInDirection: is available, call it with the delta, and then 
+        reset our delta. Otherwise, still call contentAreaScrolled.
+        (WebCore::ScrollAnimatorMac::sendContentAreaScrolledTimerFired):
+
 2013-02-01  Pavel Feldman  <pfeld...@chromium.org>
 
         Web Inspector: [file selector dialog] for mixed case queries, score uppercase letters only when assessing camelcase.

Modified: trunk/Source/WebCore/platform/ScrollAnimator.cpp (141609 => 141610)


--- trunk/Source/WebCore/platform/ScrollAnimator.cpp	2013-02-01 18:56:23 UTC (rev 141609)
+++ trunk/Source/WebCore/platform/ScrollAnimator.cpp	2013-02-01 18:59:08 UTC (rev 141610)
@@ -63,20 +63,22 @@
 {
     float* currentPos = (orientation == HorizontalScrollbar) ? &m_currentPosX : &m_currentPosY;
     float newPos = std::max(std::min(*currentPos + (step * multiplier), static_cast<float>(m_scrollableArea->scrollSize(orientation))), 0.0f);
+    float delta = *currentPos - newPos;
     if (*currentPos == newPos)
         return false;
     *currentPos = newPos;
 
-    notifyPositionChanged();
+    notifyPositionChanged(orientation == HorizontalScrollbar ? FloatSize(delta, 0) : FloatSize(0, delta));
 
     return true;
 }
 
 void ScrollAnimator::scrollToOffsetWithoutAnimation(const FloatPoint& offset)
 {
+    FloatSize delta = FloatSize(offset.x() - m_currentPosX, offset.y() - m_currentPosY);
     m_currentPosX = offset.x();
     m_currentPosY = offset.y();
-    notifyPositionChanged();
+    notifyPositionChanged(delta);
 }
 
 bool ScrollAnimator::handleWheelEvent(const PlatformWheelEvent& e)
@@ -139,8 +141,9 @@
     return FloatPoint(m_currentPosX, m_currentPosY);
 }
 
-void ScrollAnimator::notifyPositionChanged()
+void ScrollAnimator::notifyPositionChanged(const FloatSize& delta)
 {
+    UNUSED_PARAM(delta);
     m_scrollableArea->setScrollOffsetFromAnimation(IntPoint(m_currentPosX, m_currentPosY));
 }
 

Modified: trunk/Source/WebCore/platform/ScrollAnimator.h (141609 => 141610)


--- trunk/Source/WebCore/platform/ScrollAnimator.h	2013-02-01 18:56:23 UTC (rev 141609)
+++ trunk/Source/WebCore/platform/ScrollAnimator.h	2013-02-01 18:59:08 UTC (rev 141610)
@@ -35,6 +35,7 @@
 #include "ScrollTypes.h"
 #include <wtf/FastAllocBase.h>
 #include <wtf/Forward.h>
+#include <wtf/UnusedParam.h>
 
 namespace WebCore {
 
@@ -94,14 +95,14 @@
 
     virtual bool shouldScrollbarParticipateInHitTesting(Scrollbar*) { return true; }
 
-    virtual void notifyContentAreaScrolled() { }
+    virtual void notifyContentAreaScrolled(const FloatSize& delta) { UNUSED_PARAM(delta); }
 
     virtual bool isRubberBandInProgress() const { return false; }
 
 protected:
     explicit ScrollAnimator(ScrollableArea*);
 
-    virtual void notifyPositionChanged();
+    virtual void notifyPositionChanged(const FloatSize& delta);
 
     ScrollableArea* m_scrollableArea;
     float m_currentPosX; // We avoid using a FloatPoint in order to reduce

Modified: trunk/Source/WebCore/platform/ScrollAnimatorNone.cpp (141609 => 141610)


--- trunk/Source/WebCore/platform/ScrollAnimatorNone.cpp	2013-02-01 18:56:23 UTC (rev 141609)
+++ trunk/Source/WebCore/platform/ScrollAnimatorNone.cpp	2013-02-01 18:59:08 UTC (rev 141610)
@@ -475,6 +475,8 @@
 {
     stopAnimationTimerIfNeeded();
 
+    FloatSize delta = FloatSize(offset.x() - *m_horizontalData.m_currentPosition, offset.y() - *m_verticalData.m_currentPosition);
+
     m_horizontalData.reset();
     *m_horizontalData.m_currentPosition = offset.x();
     m_horizontalData.m_desiredPosition = offset.x();
@@ -483,7 +485,7 @@
     *m_verticalData.m_currentPosition = offset.y();
     m_verticalData.m_desiredPosition = offset.y();
 
-    notifyPositionChanged();
+    notifyPositionChanged(delta);
 }
 
 #if !USE(REQUEST_ANIMATION_FRAME_TIMER)
@@ -555,7 +557,7 @@
 #if PLATFORM(CHROMIUM)
     TRACE_EVENT0("webkit", "ScrollAnimatorNone::notifyPositionChanged");
 #endif
-    notifyPositionChanged();
+    notifyPositionChanged(FloatSize());
 
     if (!continueAnimation)
         animationDidFinish();

Modified: trunk/Source/WebCore/platform/ScrollableArea.cpp (141609 => 141610)


--- trunk/Source/WebCore/platform/ScrollableArea.cpp	2013-02-01 18:56:23 UTC (rev 141609)
+++ trunk/Source/WebCore/platform/ScrollableArea.cpp	2013-02-01 18:59:08 UTC (rev 141610)
@@ -177,7 +177,7 @@
     }
 
     if (scrollPosition() != oldPosition)
-        scrollAnimator()->notifyContentAreaScrolled();
+        scrollAnimator()->notifyContentAreaScrolled(scrollPosition() - oldPosition);
 }
 
 bool ScrollableArea::handleWheelEvent(const PlatformWheelEvent& wheelEvent)

Modified: trunk/Source/WebCore/platform/mac/NSScrollerImpDetails.h (141609 => 141610)


--- trunk/Source/WebCore/platform/mac/NSScrollerImpDetails.h	2013-02-01 18:56:23 UTC (rev 141609)
+++ trunk/Source/WebCore/platform/mac/NSScrollerImpDetails.h	2013-02-01 18:59:08 UTC (rev 141610)
@@ -94,6 +94,7 @@
 - (NSScrollerStyle)scrollerStyle;
 - (void)setScrollerStyle:(NSScrollerStyle)scrollerStyle;
 - (void)contentAreaScrolled;
+- (void)contentAreaScrolledInDirection:(NSPoint)direction;
 - (void)contentAreaWillDraw;
 - (void)mouseEnteredContentArea;
 - (void)mouseExitedContentArea;

Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h (141609 => 141610)


--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h	2013-02-01 18:56:23 UTC (rev 141609)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h	2013-02-01 18:59:08 UTC (rev 141610)
@@ -65,7 +65,7 @@
     void startScrollbarPaintTimer();
     void stopScrollbarPaintTimer();
 
-    void sendContentAreaScrolledSoon();
+    void sendContentAreaScrolledSoon(const FloatSize& scrollDelta);
 
     void setVisibleScrollerThumbRect(const IntRect&);
 
@@ -83,6 +83,7 @@
 
     void sendContentAreaScrolledTimerFired(Timer<ScrollAnimatorMac>*);
     Timer<ScrollAnimatorMac> m_sendContentAreaScrolledTimer;
+    FloatSize m_contentAreaScrolledTimerScrollDelta;
 
     virtual bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier);
     virtual void scrollToOffsetWithoutAnimation(const FloatPoint&);
@@ -96,7 +97,7 @@
     virtual void cancelAnimations();
     virtual void setIsActive();
     
-    virtual void notifyPositionChanged();
+    virtual void notifyPositionChanged(const FloatSize& delta);
     virtual void contentAreaWillPaint() const;
     virtual void mouseEnteredContentArea() const;
     virtual void mouseExitedContentArea() const;
@@ -121,7 +122,7 @@
 
     virtual bool shouldScrollbarParticipateInHitTesting(Scrollbar*);
 
-    virtual void notifyContentAreaScrolled() OVERRIDE;
+    virtual void notifyContentAreaScrolled(const FloatSize& delta) OVERRIDE;
 
     FloatPoint adjustScrollPositionIfNecessary(const FloatPoint&) const;
 

Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm (141609 => 141610)


--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2013-02-01 18:56:23 UTC (rev 141609)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2013-02-01 18:59:08 UTC (rev 141610)
@@ -59,6 +59,12 @@
     return globalSupportsExpansionTransitionProgress;
 }
 
+static bool supportsContentAreaScrolledInDirection()
+{
+    static bool globalSupportsContentAreaScrolledInDirection = [NSClassFromString(@"NSScrollerImpPair") instancesRespondToSelector:@selector(contentAreaScrolledInDirection:)];
+    return globalSupportsContentAreaScrolledInDirection;
+}
+
 static ScrollbarThemeMac* macScrollbarTheme()
 {
     ScrollbarTheme* scrollbarTheme = ScrollbarTheme::theme();
@@ -714,9 +720,11 @@
     if (!positionChanged && !scrollableArea()->scrollOriginChanged())
         return;
 
+    FloatSize delta = FloatSize(adjustedPosition.x() - m_currentPosX, adjustedPosition.y() - m_currentPosY);
+
     m_currentPosX = adjustedPosition.x();
     m_currentPosY = adjustedPosition.y();
-    notifyPositionChanged();
+    notifyPositionChanged(delta);
 }
 
 bool ScrollAnimatorMac::isRubberBandInProgress() const
@@ -734,10 +742,10 @@
     immediateScrollTo(newPosition);
 }
 
-void ScrollAnimatorMac::notifyPositionChanged()
+void ScrollAnimatorMac::notifyPositionChanged(const FloatSize& delta)
 {
-    notifyContentAreaScrolled();
-    ScrollAnimator::notifyPositionChanged();
+    notifyContentAreaScrolled(delta);
+    ScrollAnimator::notifyPositionChanged(delta);
 }
 
 void ScrollAnimatorMac::contentAreaWillPaint() const
@@ -969,7 +977,7 @@
     return [painter knobAlpha] > 0;
 }
 
-void ScrollAnimatorMac::notifyContentAreaScrolled()
+void ScrollAnimatorMac::notifyContentAreaScrolled(const FloatSize& delta)
 {
     if (!isScrollbarOverlayAPIAvailable())
         return;
@@ -978,7 +986,7 @@
     // isn't really scrolling in that case. We should only pass the message on to the
     // ScrollbarPainterController when we're really scrolling on an active page.
     if (scrollableArea()->scrollbarsCanBeActive())
-        sendContentAreaScrolledSoon();
+        sendContentAreaScrolledSoon(delta);
 }
 
 void ScrollAnimatorMac::cancelAnimations()
@@ -1146,9 +1154,11 @@
     if (newPos.x() == m_currentPosX && newPos.y() == m_currentPosY)
         return;
 
+    FloatSize adjustedDelta = FloatSize(newPos.x() - m_currentPosX, newPos.y() - m_currentPosY);
+
     m_currentPosX = newPos.x();
     m_currentPosY = newPos.y();
-    notifyPositionChanged();
+    notifyPositionChanged(adjustedDelta);
 }
 
 void ScrollAnimatorMac::startSnapRubberbandTimer()
@@ -1264,15 +1274,21 @@
     }
 }
 
-void ScrollAnimatorMac::sendContentAreaScrolledSoon()
+void ScrollAnimatorMac::sendContentAreaScrolledSoon(const FloatSize& delta)
 {
+    m_contentAreaScrolledTimerScrollDelta = delta;
+
     if (!m_sendContentAreaScrolledTimer.isActive())
         m_sendContentAreaScrolledTimer.startOneShot(0);
 }
 
 void ScrollAnimatorMac::sendContentAreaScrolledTimerFired(Timer<ScrollAnimatorMac>*)
 {
-    [m_scrollbarPainterController.get() contentAreaScrolled];
+    if (supportsContentAreaScrolledInDirection()) {
+        [m_scrollbarPainterController.get() contentAreaScrolledInDirection:NSMakePoint(m_contentAreaScrolledTimerScrollDelta.width(), m_contentAreaScrolledTimerScrollDelta.height())];
+        m_contentAreaScrolledTimerScrollDelta = FloatSize();
+    } else
+        [m_scrollbarPainterController.get() contentAreaScrolled];
 }
 
 void ScrollAnimatorMac::setVisibleScrollerThumbRect(const IntRect& scrollerThumb)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to