⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 245787 in webkit


Ignore:
Timestamp:
May 26, 2019, 6:12:00 PM (7 years ago)
Author:
Simon Fraser
Message:

Move VelocityData to WebCore
​https://bugs.webkit.org/show_bug.cgi?id=198261

Reviewed by Antti Koivisto.

Move VelocityData and HistoricalVelocityData to WebCore for future use in overflow scroll.
Source/WebCore:

VisibleContentRectUpdateInfo can now store a VelocityData (its timestamp is used as
the timetamp for the entire update).

No behavior change.

  • Headers.cmake:
  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • page/FrameView.cpp:

(WebCore::FrameView::setScrollVelocity):

  • page/FrameView.h:
  • platform/graphics/TiledBacking.h:

(WebCore::VelocityData::VelocityData): Deleted.
(WebCore::VelocityData::velocityOrScaleIsChanging const): Deleted.

  • platform/graphics/ca/TileController.cpp:

(WebCore::TileController::adjustTileCoverageRect const):

  • platform/graphics/ca/TileController.h:

Source/WebKit:

VisibleContentRectUpdateInfo can now store a VelocityData (its timestamp is used as
the timetamp for the entire update).

  • Shared/VisibleContentRectUpdateInfo.cpp:

(WebKit::VisibleContentRectUpdateInfo::encode const):
(WebKit::VisibleContentRectUpdateInfo::decode):
(WebKit::operator<<):

  • Shared/VisibleContentRectUpdateInfo.h:

(WebKit::VisibleContentRectUpdateInfo::VisibleContentRectUpdateInfo):
(WebKit::VisibleContentRectUpdateInfo::scrollVelocity const):
(WebKit::VisibleContentRectUpdateInfo::enclosedInScrollableAncestorView const):
(WebKit::VisibleContentRectUpdateInfo::timestamp const):
(WebKit::operator==):
(WebKit::VisibleContentRectUpdateInfo::horizontalVelocity const): Deleted.
(WebKit::VisibleContentRectUpdateInfo::verticalVelocity const): Deleted.
(WebKit::VisibleContentRectUpdateInfo::scaleChangeRate const): Deleted.

  • Shared/WebCoreArgumentCoders.cpp:

(IPC::ArgumentCoder<VelocityData>::encode):
(IPC::ArgumentCoder<VelocityData>::decode):

  • Shared/WebCoreArgumentCoders.h:
  • UIProcess/ios/WKContentView.mm:

(-[WKContentView didUpdateVisibleRect:unobscuredRect:contentInsets:unobscuredRectInScrollViewCoordinates:obscuredInsets:unobscuredSafeAreaInsets:inputViewBounds:scale:minimumScale:inStableState:isChangingObscuredInsetsInteractively:enclosedInScrollableAncestorView:]):
(WebKit::HistoricalVelocityData::VelocityData::VelocityData): Deleted.
(WebKit::HistoricalVelocityData::HistoricalVelocityData): Deleted.
(WebKit::HistoricalVelocityData::velocityForNewData): Deleted.
(WebKit::HistoricalVelocityData::clear): Deleted.
(WebKit::HistoricalVelocityData::append): Deleted.

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::dynamicViewportSizeUpdate):
(WebKit::WebPage::viewportConfigurationChanged):
(WebKit::adjustVelocityDataForBoundedScale):
(WebKit::WebPage::updateVisibleContentRects):

Location:
trunk/Source
Files:
2 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r245786 r245787  
     12019-05-26  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Move VelocityData to WebCore
     4        https://bugs.webkit.org/show_bug.cgi?id=198261
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Move VelocityData and HistoricalVelocityData to WebCore for future use in overflow scroll.
     9       
     10        VisibleContentRectUpdateInfo can now store a VelocityData (its timestamp is used as
     11        the timetamp for the entire update).
     12
     13        No behavior change.
     14
     15        * Headers.cmake:
     16        * Sources.txt:
     17        * WebCore.xcodeproj/project.pbxproj:
     18        * page/FrameView.cpp:
     19        (WebCore::FrameView::setScrollVelocity):
     20        * page/FrameView.h:
     21        * platform/graphics/TiledBacking.h:
     22        (WebCore::VelocityData::VelocityData): Deleted.
     23        (WebCore::VelocityData::velocityOrScaleIsChanging const): Deleted.
     24        * platform/graphics/ca/TileController.cpp:
     25        (WebCore::TileController::adjustTileCoverageRect const):
     26        * platform/graphics/ca/TileController.h:
     27
    1282019-05-26  Simon Fraser  <simon.fraser@apple.com>
    229
  • trunk/Source/WebCore/Headers.cmake

    r245784 r245787  
    10911091    platform/graphics/TiledBacking.h
    10921092    platform/graphics/TrackPrivateBase.h
     1093    platform/graphics/VelocityData.h
    10931094    platform/graphics/VideoTrackPrivate.h
    10941095    platform/graphics/WidthCache.h
  • trunk/Source/WebCore/Sources.txt

    r245776 r245787  
    17801780platform/graphics/SurrogatePairAwareTextIterator.cpp
    17811781platform/graphics/TextRun.cpp
     1782platform/graphics/VelocityData.cpp
    17821783platform/graphics/WOFFFileFormat.cpp
    17831784platform/graphics/WidthIterator.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r245784 r245787  
    293293                0F15ED5C1B7EC7C500EDDFEB /* WillChangeData.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F15ED5A1B7EC7C500EDDFEB /* WillChangeData.h */; settings = {ATTRIBUTES = (Private, ); }; };
    294294                0F1774801378B772009DA76A /* ScrollAnimatorIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F17747E1378B771009DA76A /* ScrollAnimatorIOS.h */; };
     295                0F1A0C38229A481800D37ADB /* VelocityData.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F1A0C36229A481800D37ADB /* VelocityData.h */; settings = {ATTRIBUTES = (Private, ); }; };
    295296                0F37F0852202BF9800A89C0B /* ScrollingTreeScrollingNodeDelegateMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F37F0842202ACB700A89C0B /* ScrollingTreeScrollingNodeDelegateMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
    296297                0F3DD45012F5EA1B000D9190 /* ShadowBlur.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F3DD44E12F5EA1B000D9190 /* ShadowBlur.h */; };
    … …  
    56305631                0F17747E1378B771009DA76A /* ScrollAnimatorIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollAnimatorIOS.h; sourceTree = "<group>"; };
    56315632                0F17747F1378B772009DA76A /* ScrollAnimatorIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollAnimatorIOS.mm; sourceTree = "<group>"; };
     5633                0F1A0C36229A481800D37ADB /* VelocityData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VelocityData.h; sourceTree = "<group>"; };
    56325634                0F26A7A72054C2270090A141 /* TemplateContentDocumentFragment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TemplateContentDocumentFragment.cpp; sourceTree = "<group>"; };
    56335635                0F26A7A92054C3CF0090A141 /* HTMLBDIElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLBDIElement.cpp; sourceTree = "<group>"; };
    … …  
    57015703                0F580FA21496939100FB5BD8 /* WebTiledBackingLayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebTiledBackingLayer.mm; sourceTree = "<group>"; };
    57025704                0F580FAE149800D400FB5BD8 /* AnimationUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationUtilities.h; sourceTree = "<group>"; };
     5705                0F5A57CA229B18AE0025EDA9 /* VelocityData.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = VelocityData.cpp; sourceTree = "<group>"; };
    57035706                0F5B7A5210F65D7A00376302 /* RenderEmbeddedObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderEmbeddedObject.cpp; sourceTree = "<group>"; };
    57045707                0F5B7A5310F65D7A00376302 /* RenderEmbeddedObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderEmbeddedObject.h; sourceTree = "<group>"; };
    … …  
    2453424537                                BE913D7F181EF8E500DCB09E /* TrackPrivateBase.h */,
    2453524538                                E4AFCFA40DAF29A300F5F55C /* UnitBezier.h */,
     24539                                0F5A57CA229B18AE0025EDA9 /* VelocityData.cpp */,
     24540                                0F1A0C36229A481800D37ADB /* VelocityData.h */,
    2453624541                                075BA84720618AA500FCB4AD /* VideoFullscreenLayerManager.h */,
    2453724542                                BEF29EEA1715DD0900C4B4C9 /* VideoTrackPrivate.h */,
    … …  
    3193331938                                15C7708D100D3C6B005BA267 /* ValidityState.h in Headers */,
    3193431939                                FD3160AF12B026F700C1A359 /* VectorMath.h in Headers */,
     31940                                0F1A0C38229A481800D37ADB /* VelocityData.h in Headers */,
    3193531941                                BCA257151293C010007A263D /* VerticalPositionCache.h in Headers */,
    3193631942                                52B0D4C01C57FD660077CE53 /* VideoFullscreenChangeObserver.h in Headers */,
  • trunk/Source/WebCore/page/FrameView.cpp

    r245543 r245787  
    100100#include "TextResourceDecoder.h"
    101101#include "TiledBacking.h"
     102#include "VelocityData.h"
    102103#include "VisualViewport.h"
    103104#include "WheelEventTestTrigger.h"
    … …  
    50525053}
    50535054
    5054 void FrameView::setScrollVelocity(double horizontalVelocity, double verticalVelocity, double scaleChangeRate, MonotonicTime timestamp)
     5055void FrameView::setScrollVelocity(const VelocityData& velocityData)
    50555056{
    50565057    if (TiledBacking* tiledBacking = this->tiledBacking())
    5057         tiledBacking->setVelocity(VelocityData(horizontalVelocity, verticalVelocity, scaleChangeRate, timestamp));
     5058        tiledBacking->setVelocity(velocityData);
    50585059}
    50595060#endif // PLATFORM(IOS_FAMILY)
  • trunk/Source/WebCore/page/FrameView.h

    r245320 r245787  
    138138    WEBCORE_EXPORT void setCustomSizeForResizeEvent(IntSize);
    139139
    140     WEBCORE_EXPORT void setScrollVelocity(double horizontalVelocity, double verticalVelocity, double scaleChangeRate, MonotonicTime timestamp);
     140    WEBCORE_EXPORT void setScrollVelocity(const VelocityData&);
    141141#else
    142142    bool useCustomFixedPositionLayoutRect() const { return false; }
  • trunk/Source/WebCore/platform/graphics/TiledBacking.h

    r239427 r245787  
    4242class IntSize;
    4343class PlatformCALayer;
     44struct VelocityData;
    4445
    4546enum ScrollingModeIndication {
    … …  
    4849    SynchronousScrollingBecauseOfEventHandlersIndication,
    4950    AsyncScrollingIndication
    50 };
    51 
    52 struct VelocityData  {
    53     double horizontalVelocity;
    54     double verticalVelocity;
    55     double scaleChangeRate;
    56     MonotonicTime lastUpdateTime;
    57    
    58     VelocityData(double horizontal = 0, double vertical = 0, double scaleChange = 0, MonotonicTime updateTime = MonotonicTime())
    59         : horizontalVelocity(horizontal)
    60         , verticalVelocity(vertical)
    61         , scaleChangeRate(scaleChange)
    62         , lastUpdateTime(updateTime)
    63     {
    64     }
    65    
    66     bool velocityOrScaleIsChanging() const
    67     {
    68         return horizontalVelocity || verticalVelocity || scaleChangeRate;
    69     }
    7051};
    7152
  • trunk/Source/WebCore/platform/graphics/ca/TileController.cpp

    r239535 r245787  
    3535#include "TileCoverageMap.h"
    3636#include "TileGrid.h"
     37#include "VelocityData.h"
    3738#include <utility>
    3839#include <wtf/MainThread.h>
    … …  
    429430        if (m_velocity.scaleChangeRate > 0) {
    430431            coverageRect = visibleRect;
     432            LOG_WITH_STREAM(Tiling, stream << "TileController " << this << " computeTileCoverageRect - zooming, coverage is visible rect " << coverageRect);
    431433            return;
    432434        }
    … …  
    449451        futureRect.setY(0);
    450452
     453    LOG_WITH_STREAM(Tiling, stream << "TileController " << this << " computeTileCoverageRect - coverage " << coverageRect << " expanded to " << unionRect(coverageRect, futureRect) << " velocity " << m_velocity);
     454
    451455    coverageRect.unite(futureRect);
    452     return;
    453456#else
    454457    UNUSED_PARAM(contentsScale);
  • trunk/Source/WebCore/platform/graphics/ca/TileController.h

    r241113 r245787  
    3333#include "TiledBacking.h"
    3434#include "Timer.h"
     35#include "VelocityData.h"
    3536#include <wtf/Deque.h>
    3637#include <wtf/Noncopyable.h>
  • trunk/Source/WebKit/ChangeLog

    r245784 r245787  
     12019-05-26  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Move VelocityData to WebCore
     4        https://bugs.webkit.org/show_bug.cgi?id=198261
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Move VelocityData and HistoricalVelocityData to WebCore for future use in overflow scroll.
     9
     10        VisibleContentRectUpdateInfo can now store a VelocityData (its timestamp is used as
     11        the timetamp for the entire update).
     12
     13        * Shared/VisibleContentRectUpdateInfo.cpp:
     14        (WebKit::VisibleContentRectUpdateInfo::encode const):
     15        (WebKit::VisibleContentRectUpdateInfo::decode):
     16        (WebKit::operator<<):
     17        * Shared/VisibleContentRectUpdateInfo.h:
     18        (WebKit::VisibleContentRectUpdateInfo::VisibleContentRectUpdateInfo):
     19        (WebKit::VisibleContentRectUpdateInfo::scrollVelocity const):
     20        (WebKit::VisibleContentRectUpdateInfo::enclosedInScrollableAncestorView const):
     21        (WebKit::VisibleContentRectUpdateInfo::timestamp const):
     22        (WebKit::operator==):
     23        (WebKit::VisibleContentRectUpdateInfo::horizontalVelocity const): Deleted.
     24        (WebKit::VisibleContentRectUpdateInfo::verticalVelocity const): Deleted.
     25        (WebKit::VisibleContentRectUpdateInfo::scaleChangeRate const): Deleted.
     26        * Shared/WebCoreArgumentCoders.cpp:
     27        (IPC::ArgumentCoder<VelocityData>::encode):
     28        (IPC::ArgumentCoder<VelocityData>::decode):
     29        * Shared/WebCoreArgumentCoders.h:
     30        * UIProcess/ios/WKContentView.mm:
     31        (-[WKContentView didUpdateVisibleRect:unobscuredRect:contentInsets:unobscuredRectInScrollViewCoordinates:obscuredInsets:unobscuredSafeAreaInsets:inputViewBounds:scale:minimumScale:inStableState:isChangingObscuredInsetsInteractively:enclosedInScrollableAncestorView:]):
     32        (WebKit::HistoricalVelocityData::VelocityData::VelocityData): Deleted.
     33        (WebKit::HistoricalVelocityData::HistoricalVelocityData): Deleted.
     34        (WebKit::HistoricalVelocityData::velocityForNewData): Deleted.
     35        (WebKit::HistoricalVelocityData::clear): Deleted.
     36        (WebKit::HistoricalVelocityData::append): Deleted.
     37        * WebProcess/WebPage/ios/WebPageIOS.mm:
     38        (WebKit::WebPage::dynamicViewportSizeUpdate):
     39        (WebKit::WebPage::viewportConfigurationChanged):
     40        (WebKit::adjustVelocityDataForBoundedScale):
     41        (WebKit::WebPage::updateVisibleContentRects):
     42
    1432019-05-26  John Wilander  <wilander@apple.com>
    244
  • trunk/Source/WebKit/Shared/VisibleContentRectUpdateInfo.cpp

    r240139 r245787  
    4444    encoder << m_obscuredInsets;
    4545    encoder << m_unobscuredSafeAreaInsets;
     46    encoder << m_scrollVelocity;
    4647    encoder << m_lastLayerTreeTransactionID;
    4748    encoder << m_scale;
    48     encoder << m_timestamp;
    49     encoder << m_horizontalVelocity;
    50     encoder << m_verticalVelocity;
    51     encoder << m_scaleChangeRate;
    5249    encoder << m_inStableState;
    5350    encoder << m_isFirstUpdateForNewViewSize;
    … …  
    7572    if (!decoder.decode(result.m_unobscuredSafeAreaInsets))
    7673        return false;
     74    if (!decoder.decode(result.m_scrollVelocity))
     75        return false;
    7776    if (!decoder.decode(result.m_lastLayerTreeTransactionID))
    7877        return false;
    7978    if (!decoder.decode(result.m_scale))
    80         return false;
    81     if (!decoder.decode(result.m_timestamp))
    82         return false;
    83     if (!decoder.decode(result.m_horizontalVelocity))
    84         return false;
    85     if (!decoder.decode(result.m_verticalVelocity))
    86         return false;
    87     if (!decoder.decode(result.m_scaleChangeRate))
    8879        return false;
    8980    if (!decoder.decode(result.m_inStableState))
    … …  
    133124        ts.dumpProperty("enclosedInScrollableAncestorView", info.enclosedInScrollableAncestorView());
    134125
    135     ts.dumpProperty("timestamp", info.timestamp().secondsSinceEpoch().value());
    136126    ts.dumpProperty("allowShrinkToFit", info.allowShrinkToFit());
    137     if (info.horizontalVelocity())
    138         ts.dumpProperty("horizontalVelocity", info.horizontalVelocity());
    139     if (info.verticalVelocity())
    140         ts.dumpProperty("verticalVelocity", info.verticalVelocity());
    141     if (info.scaleChangeRate())
    142         ts.dumpProperty("scaleChangeRate", info.scaleChangeRate());
     127    ts.dumpProperty("scrollVelocity", info.scrollVelocity());
    143128
    144129    return ts;
  • trunk/Source/WebKit/Shared/VisibleContentRectUpdateInfo.h

    r240139 r245787  
    2828#include <WebCore/FloatRect.h>
    2929#include <WebCore/LengthBox.h>
     30#include <WebCore/VelocityData.h>
    3031#include <wtf/MonotonicTime.h>
    3132#include <wtf/text/WTFString.h>
    … …  
    4647    VisibleContentRectUpdateInfo() = default;
    4748
    48     VisibleContentRectUpdateInfo(const WebCore::FloatRect& exposedContentRect, const WebCore::FloatRect& unobscuredContentRect, const WebCore::FloatBoxExtent& contentInsets, const WebCore::FloatRect& unobscuredRectInScrollViewCoordinates, const WebCore::FloatRect& unobscuredContentRectRespectingInputViewBounds, const WebCore::FloatRect& customFixedPositionRect, const WebCore::FloatBoxExtent& obscuredInsets, const WebCore::FloatBoxExtent& unobscuredSafeAreaInsets, double scale, bool inStableState, bool isFirstUpdateForNewViewSize, bool isChangingObscuredInsetsInteractively, bool allowShrinkToFit, bool enclosedInScrollableAncestorView, MonotonicTime timestamp, double horizontalVelocity, double verticalVelocity, double scaleChangeRate, uint64_t lastLayerTreeTransactionId)
     49    VisibleContentRectUpdateInfo(const WebCore::FloatRect& exposedContentRect, const WebCore::FloatRect& unobscuredContentRect, const WebCore::FloatBoxExtent& contentInsets, const WebCore::FloatRect& unobscuredRectInScrollViewCoordinates, const WebCore::FloatRect& unobscuredContentRectRespectingInputViewBounds, const WebCore::FloatRect& customFixedPositionRect, const WebCore::FloatBoxExtent& obscuredInsets, const WebCore::FloatBoxExtent& unobscuredSafeAreaInsets, double scale, bool inStableState, bool isFirstUpdateForNewViewSize, bool isChangingObscuredInsetsInteractively, bool allowShrinkToFit, bool enclosedInScrollableAncestorView, const WebCore::VelocityData& scrollVelocity, uint64_t lastLayerTreeTransactionId)
    4950        : m_exposedContentRect(exposedContentRect)
    5051        , m_unobscuredContentRect(unobscuredContentRect)
    … …  
    5556        , m_obscuredInsets(obscuredInsets)
    5657        , m_unobscuredSafeAreaInsets(unobscuredSafeAreaInsets)
     58        , m_scrollVelocity(scrollVelocity)
    5759        , m_lastLayerTreeTransactionID(lastLayerTreeTransactionId)
    5860        , m_scale(scale)
    59         , m_timestamp(timestamp)
    60         , m_horizontalVelocity(horizontalVelocity)
    61         , m_verticalVelocity(verticalVelocity)
    62         , m_scaleChangeRate(scaleChangeRate)
    6361        , m_inStableState(inStableState)
    6462        , m_isFirstUpdateForNewViewSize(isFirstUpdateForNewViewSize)
    … …  
    7573    const WebCore::FloatRect& unobscuredContentRectRespectingInputViewBounds() const { return m_unobscuredContentRectRespectingInputViewBounds; }
    7674    const WebCore::FloatRect& customFixedPositionRect() const { return m_customFixedPositionRect; }
     75    const WebCore::VelocityData& scrollVelocity() const { return m_scrollVelocity; }
    7776    const WebCore::FloatBoxExtent& obscuredInsets() const { return m_obscuredInsets; }
    7877    const WebCore::FloatBoxExtent& unobscuredSafeAreaInsets() const { return m_unobscuredSafeAreaInsets; }
    … …  
    8483    bool allowShrinkToFit() const { return m_allowShrinkToFit; }
    8584    bool enclosedInScrollableAncestorView() const { return m_enclosedInScrollableAncestorView; }
     85    uint64_t lastLayerTreeTransactionID() const { return m_lastLayerTreeTransactionID; }
    8686
    87     MonotonicTime timestamp() const { return m_timestamp; }
    88     double horizontalVelocity() const { return m_horizontalVelocity; }
    89     double verticalVelocity() const { return m_verticalVelocity; }
    90     double scaleChangeRate() const { return m_scaleChangeRate; }
    91 
    92     uint64_t lastLayerTreeTransactionID() const { return m_lastLayerTreeTransactionID; }
     87    MonotonicTime timestamp() const { return m_scrollVelocity.lastUpdateTime; }
    9388
    9489    void encode(IPC::Encoder&) const;
    … …  
    106101    WebCore::FloatBoxExtent m_obscuredInsets;
    107102    WebCore::FloatBoxExtent m_unobscuredSafeAreaInsets;
     103    WebCore::VelocityData m_scrollVelocity;
    108104    uint64_t m_lastLayerTreeTransactionID { 0 };
    109105    double m_scale { -1 };
    110     MonotonicTime m_timestamp;
    111     double m_horizontalVelocity { 0 };
    112     double m_verticalVelocity { 0 };
    113     double m_scaleChangeRate { 0 };
    114106    bool m_inStableState { false };
    115107    bool m_isFirstUpdateForNewViewSize { false };
    … …  
    130122        && a.obscuredInsets() == b.obscuredInsets()
    131123        && a.unobscuredSafeAreaInsets() == b.unobscuredSafeAreaInsets()
    132         && a.horizontalVelocity() == b.horizontalVelocity()
    133         && a.verticalVelocity() == b.verticalVelocity()
    134         && a.scaleChangeRate() == b.scaleChangeRate()
     124        && a.scrollVelocity().equalIgnoringTimestamp(b.scrollVelocity())
    135125        && a.inStableState() == b.inStableState()
    136126        && a.isFirstUpdateForNewViewSize() == b.isFirstUpdateForNewViewSize()
  • trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp

    r243416 r245787  
    8282#include <WebCore/TransformationMatrix.h>
    8383#include <WebCore/UserStyleSheet.h>
     84#include <WebCore/VelocityData.h>
    8485#include <WebCore/ViewportArguments.h>
    8586#include <WebCore/WindowFeatures.h>
    … …  
    924925}
    925926
     927void ArgumentCoder<VelocityData>::encode(Encoder& encoder, const VelocityData& velocityData)
     928{
     929    encoder << velocityData.horizontalVelocity << velocityData.verticalVelocity << velocityData.scaleChangeRate << velocityData.lastUpdateTime;
     930}
     931
     932bool ArgumentCoder<VelocityData>::decode(Decoder& decoder, VelocityData& velocityData)
     933{
     934    float horizontalVelocity;
     935    if (!decoder.decode(horizontalVelocity))
     936        return false;
     937
     938    float verticalVelocity;
     939    if (!decoder.decode(verticalVelocity))
     940        return false;
     941
     942    float scaleChangeRate;
     943    if (!decoder.decode(scaleChangeRate))
     944        return false;
     945
     946    MonotonicTime lastUpdateTime;
     947    if (!decoder.decode(lastUpdateTime))
     948        return false;
     949
     950    velocityData.horizontalVelocity = horizontalVelocity;
     951    velocityData.verticalVelocity = verticalVelocity;
     952    velocityData.scaleChangeRate = scaleChangeRate;
     953    velocityData.lastUpdateTime = lastUpdateTime;
     954
     955    return true;
     956}
    926957
    927958void ArgumentCoder<MimeClassInfo>::encode(Encoder& encoder, const MimeClassInfo& mimeClassInfo)
  • trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h

    r244475 r245787  
    126126struct TouchActionData;
    127127#endif
     128struct VelocityData;
    128129struct ViewportAttributes;
    129130struct WindowFeatures;
    … …  
    333334    static void encode(Encoder&, const WebCore::ViewportAttributes&);
    334335    static bool decode(Decoder&, WebCore::ViewportAttributes&);
     336};
     337
     338template<> struct ArgumentCoder<WebCore::VelocityData> {
     339    static void encode(Encoder&, const WebCore::VelocityData&);
     340    static bool decode(Decoder&, WebCore::VelocityData&);
    335341};
    336342
  • trunk/Source/WebKit/UIProcess/ios/WKContentView.mm

    r245272 r245787  
    6161#import <WebCore/PlatformScreen.h>
    6262#import <WebCore/Quirks.h>
     63#import <WebCore/VelocityData.h>
    6364#import <pal/spi/cocoa/QuartzCoreSPI.h>
    6465#import <wtf/RetainPtr.h>
    6566#import <wtf/text/TextStream.h>
    6667
    67 
    68 namespace WebKit {
    69 using namespace WebCore;
    70 using namespace WebKit;
    71 
    72 class HistoricalVelocityData {
    73 public:
    74     struct VelocityData {
    75         VelocityData()
    76             : horizontalVelocity(0)
    77             , verticalVelocity(0)
    78             , scaleChangeRate(0)
    79         {
    80         }
    81 
    82         VelocityData(double horizontalVelocity, double verticalVelocity, double scaleChangeRate)
    83             : horizontalVelocity(horizontalVelocity)
    84             , verticalVelocity(verticalVelocity)
    85             , scaleChangeRate(scaleChangeRate)
    86         {
    87         }
    88 
    89         double horizontalVelocity;
    90         double verticalVelocity;
    91         double scaleChangeRate;
    92     };
    93 
    94     HistoricalVelocityData()
    95         : m_historySize(0)
    96         , m_latestDataIndex(0)
    97     {
    98     }
    99 
    100     VelocityData velocityForNewData(CGPoint newPosition, double scale, MonotonicTime timestamp)
    101     {
    102         // Due to all the source of rect update, the input is very noisy. To smooth the output, we accumulate all changes
    103         // within 1 frame as a single update. No speed computation is ever done on data within the same frame.
    104         const Seconds filteringThreshold(1.0 / 60);
    105 
    106         VelocityData velocityData;
    107         if (m_historySize > 0) {
    108             unsigned oldestDataIndex;
    109             unsigned distanceToLastHistoricalData = m_historySize - 1;
    110             if (distanceToLastHistoricalData <= m_latestDataIndex)
    111                 oldestDataIndex = m_latestDataIndex - distanceToLastHistoricalData;
    112             else
    113                 oldestDataIndex = m_historySize - (distanceToLastHistoricalData - m_latestDataIndex);
    114 
    115             Seconds timeDelta = timestamp - m_history[oldestDataIndex].timestamp;
    116             if (timeDelta > filteringThreshold) {
    117                 Data& oldestData = m_history[oldestDataIndex];
    118                 velocityData = VelocityData((newPosition.x - oldestData.position.x) / timeDelta.seconds(), (newPosition.y - oldestData.position.y) / timeDelta.seconds(), (scale - oldestData.scale) / timeDelta.seconds());
    119             }
    120         }
    121 
    122         Seconds timeSinceLastAppend = timestamp - m_lastAppendTimestamp;
    123         if (timeSinceLastAppend > filteringThreshold)
    124             append(newPosition, scale, timestamp);
    125         else
    126             m_history[m_latestDataIndex] = { timestamp, newPosition, scale };
    127         return velocityData;
    128     }
    129 
    130     void clear() { m_historySize = 0; }
    131 
    132 private:
    133     void append(CGPoint newPosition, double scale, MonotonicTime timestamp)
    134     {
    135         m_latestDataIndex = (m_latestDataIndex + 1) % maxHistoryDepth;
    136         m_history[m_latestDataIndex] = { timestamp, newPosition, scale };
    137 
    138         unsigned size = m_historySize + 1;
    139         if (size <= maxHistoryDepth)
    140             m_historySize = size;
    141 
    142         m_lastAppendTimestamp = timestamp;
    143     }
    144 
    145 
    146     static const unsigned maxHistoryDepth = 3;
    147 
    148     unsigned m_historySize;
    149     unsigned m_latestDataIndex;
    150     MonotonicTime m_lastAppendTimestamp;
    151 
    152     struct Data {
    153         MonotonicTime timestamp;
    154         CGPoint position;
    155         double scale;
    156     } m_history[maxHistoryDepth];
    157 };
    158 } // namespace WebKit
    15968
    16069@interface WKInspectorIndicationView : UIView
    … …  
    224133#endif
    225134
    226     WebKit::HistoricalVelocityData _historicalKinematicData;
     135    WebCore::HistoricalVelocityData _historicalKinematicData;
    227136
    228137    RetainPtr<NSUndoManager> _undoManager;
    … …  
    464373
    465374    MonotonicTime timestamp = MonotonicTime::now();
    466     WebKit::HistoricalVelocityData::VelocityData velocityData;
     375    WebCore::VelocityData velocityData;
    467376    if (!isStableState)
    468377        velocityData = _historicalKinematicData.velocityForNewData(visibleContentRect.origin, zoomScale, timestamp);
    469     else
     378    else {
    470379        _historicalKinematicData.clear();
     380        velocityData = { 0, 0, 0, timestamp };
     381    }
    471382
    472383    WebKit::RemoteScrollingCoordinatorProxy* scrollingCoordinator = _page->scrollingCoordinatorProxy();
    … …  
    490401        _webView._allowsViewportShrinkToFit,
    491402        enclosedInScrollableAncestorView,
    492         timestamp,
    493         velocityData.horizontalVelocity,
    494         velocityData.verticalVelocity,
    495         velocityData.scaleChangeRate,
     403        velocityData,
    496404        downcast<WebKit::RemoteLayerTreeDrawingAreaProxy>(*drawingArea).lastCommittedLayerTreeTransactionID());
    497405
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r245778 r245787  
    31613161    }
    31623162
    3163     frameView.setScrollVelocity(0, 0, 0, MonotonicTime::now());
     3163    frameView.setScrollVelocity({ 0, 0, 0, MonotonicTime::now() });
    31643164
    31653165    IntPoint roundedUnobscuredContentRectPosition = roundedIntPoint(newUnobscuredContentRect.location());
    … …  
    33343334        IntSize minimumLayoutSizeInDocumentCoordinates = roundedIntSize(minimumLayoutSizeInScrollViewCoordinates);
    33353335        frameView.setUnobscuredContentSize(minimumLayoutSizeInDocumentCoordinates);
    3336         frameView.setScrollVelocity(0, 0, 0, MonotonicTime::now());
     3336        frameView.setScrollVelocity({ 0, 0, 0, MonotonicTime::now() });
    33373337
    33383338        // FIXME: We could send down the obscured margins to find a better exposed rect and unobscured rect.
    … …  
    34053405}
    34063406
    3407 static inline void adjustVelocityDataForBoundedScale(double& horizontalVelocity, double& verticalVelocity, double& scaleChangeRate, double exposedRectScale, double minimumScale, double maximumScale)
    3408 {
    3409     if (scaleChangeRate) {
    3410         horizontalVelocity = 0;
    3411         verticalVelocity = 0;
     3407static inline void adjustVelocityDataForBoundedScale(VelocityData& velocityData, double exposedRectScale, double minimumScale, double maximumScale)
     3408{
     3409    if (velocityData.scaleChangeRate) {
     3410        velocityData.horizontalVelocity = 0;
     3411        velocityData.verticalVelocity = 0;
    34123412    }
    34133413
    34143414    if (exposedRectScale >= maximumScale || exposedRectScale <= minimumScale)
    3415         scaleChangeRate = 0;
     3415        velocityData.scaleChangeRate = 0;
    34163416}
    34173417
    … …  
    35213521    m_page->setEnclosedInScrollableAncestorView(visibleContentRectUpdateInfo.enclosedInScrollableAncestorView());
    35223522
    3523     double horizontalVelocity = visibleContentRectUpdateInfo.horizontalVelocity();
    3524     double verticalVelocity = visibleContentRectUpdateInfo.verticalVelocity();
    3525     double scaleChangeRate = visibleContentRectUpdateInfo.scaleChangeRate();
    3526     adjustVelocityDataForBoundedScale(horizontalVelocity, verticalVelocity, scaleChangeRate, visibleContentRectUpdateInfo.scale(), m_viewportConfiguration.minimumScale(), m_viewportConfiguration.maximumScale());
    3527 
    3528     frameView.setScrollVelocity(horizontalVelocity, verticalVelocity, scaleChangeRate, visibleContentRectUpdateInfo.timestamp());
     3523    VelocityData scrollVelocity = visibleContentRectUpdateInfo.scrollVelocity();
     3524    adjustVelocityDataForBoundedScale(scrollVelocity, visibleContentRectUpdateInfo.scale(), m_viewportConfiguration.minimumScale(), m_viewportConfiguration.maximumScale());
     3525    frameView.setScrollVelocity(scrollVelocity);
    35293526
    35303527    if (m_isInStableState) {
Note: See TracChangeset for help on using the changeset viewer.