Changeset 195661 in webkit


Ignore:
Timestamp:
Jan 27, 2016 2:32:59 AM (8 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK][EFL] Rename ScrollAnimationNone as ScrollAnimationSmooth
https://bugs.webkit.org/show_bug.cgi?id=153481

Reviewed by Simon Fraser.

ScrollAnimationNone has always been used by EFL and GTK ports to
implement smooth scrolling. I think it should be possible for
other scroll animators to implement smooth scrolling or even
implement other kind of scroll animations. For example, in the
future I would like to have kinetic scrolling implemented for the
GTK+ port to match all other GTK+ application and decide at
runtime between different animations without having to use a
different scroll animator class. So, this patch also moves the
smooth scrolling animation implementation to its own class
ScrollAnimationSmooth that impements an interface ScrollAnimation
that could be used to implement other animations. This will allow
the GTK+ port to add its own scroll animator class and still
support smooth scrolling sharing the code with the
ScrollAnimationSmooth.

  • PlatformEfl.cmake: Add new files to compilation and remove ScrollAnimationNone.
  • PlatformGTK.cmake: Ditto.
  • platform/ScrollAnimation.h: Added.

(WebCore::ScrollAnimation::serviceAnimation):
(WebCore::ScrollAnimation::ScrollAnimation):

  • platform/ScrollAnimationSmooth.cpp: Added.

(WebCore::ScrollAnimationSmooth::ScrollAnimationSmooth):
(WebCore::ScrollAnimationSmooth::scroll):
(WebCore::ScrollAnimationSmooth::stop):
(WebCore::ScrollAnimationSmooth::updateVisibleLengths):
(WebCore::ScrollAnimationSmooth::setCurrentPosition):
(WebCore::ScrollAnimationSmooth::serviceAnimation):
(WebCore::ScrollAnimationSmooth::~ScrollAnimationSmooth):
(WebCore::curveAt):
(WebCore::attackCurve):
(WebCore::releaseCurve):
(WebCore::coastCurve):
(WebCore::curveIntegralAt):
(WebCore::attackArea):
(WebCore::releaseArea):
(WebCore::getAnimationParametersForGranularity):
(WebCore::ScrollAnimationSmooth::updatePerAxisData):
(WebCore::ScrollAnimationSmooth::animateScroll):
(WebCore::ScrollAnimationSmooth::animationTimerFired):
(WebCore::ScrollAnimationSmooth::startNextTimer):
(WebCore::ScrollAnimationSmooth::animationTimerActive):

  • platform/ScrollAnimationSmooth.h: Added.
  • platform/ScrollAnimator.cpp:

(WebCore::ScrollAnimator::scroll):
(WebCore::ScrollAnimator::scrollToOffsetWithoutAnimation):
(WebCore::ScrollAnimator::setCurrentPosition):
(WebCore::ScrollAnimator::updateActiveScrollSnapIndexForOffset):
(WebCore::ScrollAnimator::notifyPositionChanged):
(WebCore::ScrollAnimator::scrollOffsetOnAxis):

  • platform/ScrollAnimator.h:

(WebCore::ScrollAnimator::ScrollAnimator::currentPosition):

  • platform/ScrollAnimatorNone.cpp: Removed.
  • platform/ScrollAnimatorNone.h: Removed.
  • platform/ScrollAnimatorSmooth.cpp: Added.

(WebCore::ScrollAnimator::create):
(WebCore::ScrollAnimatorSmooth::ScrollAnimatorSmooth):
(WebCore::ScrollAnimatorSmooth::~ScrollAnimatorSmooth):
(WebCore::ScrollAnimatorSmooth::scroll):
(WebCore::ScrollAnimatorSmooth::scrollToOffsetWithoutAnimation):
(WebCore::ScrollAnimatorSmooth::cancelAnimations):
(WebCore::ScrollAnimatorSmooth::serviceScrollAnimations):
(WebCore::ScrollAnimatorSmooth::willEndLiveResize):
(WebCore::ScrollAnimatorSmooth::didAddVerticalScrollbar):
(WebCore::ScrollAnimatorSmooth::didAddHorizontalScrollbar):

  • platform/ScrollAnimatorSmooth.h: Added.
  • platform/mac/ScrollAnimatorMac.mm:

(WebCore::ScrollAnimatorMac::immediateScrollToPosition):
(WebCore::ScrollAnimatorMac::immediateScrollBy):

Location:
trunk/Source/WebCore
Files:
5 added
2 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r195660 r195661  
     12016-01-27  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK][EFL] Rename ScrollAnimationNone as ScrollAnimationSmooth
     4        https://bugs.webkit.org/show_bug.cgi?id=153481
     5
     6        Reviewed by Simon Fraser.
     7
     8        ScrollAnimationNone has always been used by EFL and GTK ports to
     9        implement smooth scrolling. I think it should be possible for
     10        other scroll animators to implement smooth scrolling or even
     11        implement other kind of scroll animations. For example, in the
     12        future I would like to have kinetic scrolling implemented for the
     13        GTK+ port to match all other GTK+ application and decide at
     14        runtime between different animations without having to use a
     15        different scroll animator class. So, this patch also moves the
     16        smooth scrolling animation implementation to its own class
     17        ScrollAnimationSmooth that impements an interface ScrollAnimation
     18        that could be used to implement other animations. This will allow
     19        the GTK+ port to add its own scroll animator class and still
     20        support smooth scrolling sharing the code with the
     21        ScrollAnimationSmooth.
     22
     23        * PlatformEfl.cmake: Add new files to compilation and remove ScrollAnimationNone.
     24        * PlatformGTK.cmake: Ditto.
     25        * platform/ScrollAnimation.h: Added.
     26        (WebCore::ScrollAnimation::serviceAnimation):
     27        (WebCore::ScrollAnimation::ScrollAnimation):
     28        * platform/ScrollAnimationSmooth.cpp: Added.
     29        (WebCore::ScrollAnimationSmooth::ScrollAnimationSmooth):
     30        (WebCore::ScrollAnimationSmooth::scroll):
     31        (WebCore::ScrollAnimationSmooth::stop):
     32        (WebCore::ScrollAnimationSmooth::updateVisibleLengths):
     33        (WebCore::ScrollAnimationSmooth::setCurrentPosition):
     34        (WebCore::ScrollAnimationSmooth::serviceAnimation):
     35        (WebCore::ScrollAnimationSmooth::~ScrollAnimationSmooth):
     36        (WebCore::curveAt):
     37        (WebCore::attackCurve):
     38        (WebCore::releaseCurve):
     39        (WebCore::coastCurve):
     40        (WebCore::curveIntegralAt):
     41        (WebCore::attackArea):
     42        (WebCore::releaseArea):
     43        (WebCore::getAnimationParametersForGranularity):
     44        (WebCore::ScrollAnimationSmooth::updatePerAxisData):
     45        (WebCore::ScrollAnimationSmooth::animateScroll):
     46        (WebCore::ScrollAnimationSmooth::animationTimerFired):
     47        (WebCore::ScrollAnimationSmooth::startNextTimer):
     48        (WebCore::ScrollAnimationSmooth::animationTimerActive):
     49        * platform/ScrollAnimationSmooth.h: Added.
     50        * platform/ScrollAnimator.cpp:
     51        (WebCore::ScrollAnimator::scroll):
     52        (WebCore::ScrollAnimator::scrollToOffsetWithoutAnimation):
     53        (WebCore::ScrollAnimator::setCurrentPosition):
     54        (WebCore::ScrollAnimator::updateActiveScrollSnapIndexForOffset):
     55        (WebCore::ScrollAnimator::notifyPositionChanged):
     56        (WebCore::ScrollAnimator::scrollOffsetOnAxis):
     57        * platform/ScrollAnimator.h:
     58        (WebCore::ScrollAnimator::ScrollAnimator::currentPosition):
     59        * platform/ScrollAnimatorNone.cpp: Removed.
     60        * platform/ScrollAnimatorNone.h: Removed.
     61        * platform/ScrollAnimatorSmooth.cpp: Added.
     62        (WebCore::ScrollAnimator::create):
     63        (WebCore::ScrollAnimatorSmooth::ScrollAnimatorSmooth):
     64        (WebCore::ScrollAnimatorSmooth::~ScrollAnimatorSmooth):
     65        (WebCore::ScrollAnimatorSmooth::scroll):
     66        (WebCore::ScrollAnimatorSmooth::scrollToOffsetWithoutAnimation):
     67        (WebCore::ScrollAnimatorSmooth::cancelAnimations):
     68        (WebCore::ScrollAnimatorSmooth::serviceScrollAnimations):
     69        (WebCore::ScrollAnimatorSmooth::willEndLiveResize):
     70        (WebCore::ScrollAnimatorSmooth::didAddVerticalScrollbar):
     71        (WebCore::ScrollAnimatorSmooth::didAddHorizontalScrollbar):
     72        * platform/ScrollAnimatorSmooth.h: Added.
     73        * platform/mac/ScrollAnimatorMac.mm:
     74        (WebCore::ScrollAnimatorMac::immediateScrollToPosition):
     75        (WebCore::ScrollAnimatorMac::immediateScrollBy):
     76
    1772016-01-27  Carlos Garcia Campos  <cgarcia@igalia.com>
    278
  • trunk/Source/WebCore/PlatformEfl.cmake

    r194586 r195661  
    518518if (ENABLE_SMOOTH_SCROLLING)
    519519    list(APPEND WebCore_SOURCES
    520         platform/ScrollAnimatorNone.cpp
     520        platform/ScrollAnimationSmooth.cpp
     521        platform/ScrollAnimatorSmooth.cpp
    521522    )
    522523endif ()
  • trunk/Source/WebCore/PlatformGTK.cmake

    r194586 r195661  
    936936if (ENABLE_SMOOTH_SCROLLING)
    937937    list(APPEND WebCore_SOURCES
    938         platform/ScrollAnimatorNone.cpp
     938        platform/ScrollAnimationSmooth.cpp
     939        platform/ScrollAnimatorSmooth.cpp
    939940    )
    940941endif ()
  • trunk/Source/WebCore/platform/ScrollAnimator.cpp

    r194516 r195661  
    7373        return false;
    7474
    75     setCurrentPositionInternal(newPosition);
     75    m_currentPosition = newPosition;
    7676    notifyPositionChanged(newPosition - currentPosition);
    7777    return true;
     
    8282    FloatPoint newPositon = ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(m_scrollableArea.scrollOrigin()));
    8383    FloatSize delta = newPositon - currentPosition();
    84     setCurrentPositionInternal(newPositon);
     84    m_currentPosition = newPositon;
    8585    notifyPositionChanged(delta);
    8686    updateActiveScrollSnapIndexForOffset();
     
    173173void ScrollAnimator::setCurrentPosition(const FloatPoint& position)
    174174{
    175     setCurrentPositionInternal(position);
     175    m_currentPosition = position;
    176176    updateActiveScrollSnapIndexForOffset();
    177177}
     
    181181#if ENABLE(CSS_SCROLL_SNAP)
    182182    // FIXME: Needs offset/position disambiguation.
    183     m_scrollController.setActiveScrollSnapIndicesForOffset(m_currentPosX, m_currentPosY);
     183    m_scrollController.setActiveScrollSnapIndicesForOffset(m_currentPosition.x(), m_currentPosition.y());
    184184    if (m_scrollController.activeScrollSnapIndexDidChange()) {
    185185        m_scrollableArea.setCurrentHorizontalSnapPointIndex(m_scrollController.activeScrollSnapIndexForAxis(ScrollEventAxis::Horizontal));
     
    204204LayoutUnit ScrollAnimator::scrollOffsetOnAxis(ScrollEventAxis axis) const
    205205{
    206     return axis == ScrollEventAxis::Horizontal ? m_currentPosX : m_currentPosY;
     206    return axis == ScrollEventAxis::Horizontal ? m_currentPosition.x() : m_currentPosition.y();
    207207}
    208208
  • trunk/Source/WebCore/platform/ScrollAnimator.h

    r194516 r195661  
    8686
    8787    void setCurrentPosition(const FloatPoint&);
    88     FloatPoint currentPosition() const { return FloatPoint(m_currentPosX, m_currentPosY); }
     88    const FloatPoint& currentPosition() const { return m_currentPosition; }
    8989
    9090    virtual void cancelAnimations() { }
     
    146146    void updateActiveScrollSnapIndexForOffset();
    147147
    148     void setCurrentPositionInternal(const FloatPoint& p)
    149     {
    150         m_currentPosX = p.x();
    151         m_currentPosY = p.y();
    152     }
    153 
    154148    ScrollableArea& m_scrollableArea;
    155149    RefPtr<WheelEventTestTrigger> m_wheelEventTestTrigger;
     
    157151    ScrollController m_scrollController;
    158152#endif
    159     float m_currentPosX { 0 }; // ScrollAnimatorNone takes addresses of these, so can't use a FloatPoint.
    160     float m_currentPosY { 0 };
     153    FloatPoint m_currentPosition;
    161154};
    162155
  • trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm

    r194516 r195661  
    764764
    765765    FloatSize delta = adjustedPosition - currentPosition;
    766     setCurrentPositionInternal(adjustedPosition);
     766    m_currentPosition = adjustedPosition;
    767767    notifyPositionChanged(delta);
    768768    updateActiveScrollSnapIndexForOffset();
     
    13051305
    13061306    FloatSize adjustedDelta = newPosition - currentPosition;
    1307     setCurrentPositionInternal(newPosition);
     1307    m_currentPosition = newPosition;
    13081308    notifyPositionChanged(adjustedDelta);
    13091309    updateActiveScrollSnapIndexForOffset();
Note: See TracChangeset for help on using the changeset viewer.