Title: [245787] trunk/Source
Revision
245787
Author
[email protected]
Date
2019-05-26 18:12:00 -0700 (Sun, 26 May 2019)

Log 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):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (245786 => 245787)


--- trunk/Source/WebCore/ChangeLog	2019-05-27 00:10:44 UTC (rev 245786)
+++ trunk/Source/WebCore/ChangeLog	2019-05-27 01:12:00 UTC (rev 245787)
@@ -1,5 +1,32 @@
 2019-05-26  Simon Fraser  <[email protected]>
 
+        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.
+        
+        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:
+
+2019-05-26  Simon Fraser  <[email protected]>
+
         Add a GraphicsLayer::Type for ScrolledContents
         https://bugs.webkit.org/show_bug.cgi?id=198257
 

Modified: trunk/Source/WebCore/Headers.cmake (245786 => 245787)


--- trunk/Source/WebCore/Headers.cmake	2019-05-27 00:10:44 UTC (rev 245786)
+++ trunk/Source/WebCore/Headers.cmake	2019-05-27 01:12:00 UTC (rev 245787)
@@ -1090,6 +1090,7 @@
     platform/graphics/TextRun.h
     platform/graphics/TiledBacking.h
     platform/graphics/TrackPrivateBase.h
+    platform/graphics/VelocityData.h
     platform/graphics/VideoTrackPrivate.h
     platform/graphics/WidthCache.h
     platform/graphics/WindRule.h

Modified: trunk/Source/WebCore/Sources.txt (245786 => 245787)


--- trunk/Source/WebCore/Sources.txt	2019-05-27 00:10:44 UTC (rev 245786)
+++ trunk/Source/WebCore/Sources.txt	2019-05-27 01:12:00 UTC (rev 245787)
@@ -1779,6 +1779,7 @@
 platform/graphics/StringTruncator.cpp
 platform/graphics/SurrogatePairAwareTextIterator.cpp
 platform/graphics/TextRun.cpp
+platform/graphics/VelocityData.cpp
 platform/graphics/WOFFFileFormat.cpp
 platform/graphics/WidthIterator.cpp
 

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (245786 => 245787)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-05-27 00:10:44 UTC (rev 245786)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-05-27 01:12:00 UTC (rev 245787)
@@ -292,6 +292,7 @@
 		0F15DA8A0F3AAEE70000CE47 /* CSSAnimationControllerPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F15DA890F3AAEE70000CE47 /* CSSAnimationControllerPrivate.h */; };
 		0F15ED5C1B7EC7C500EDDFEB /* WillChangeData.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F15ED5A1B7EC7C500EDDFEB /* WillChangeData.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0F1774801378B772009DA76A /* ScrollAnimatorIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F17747E1378B771009DA76A /* ScrollAnimatorIOS.h */; };
+		0F1A0C38229A481800D37ADB /* VelocityData.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F1A0C36229A481800D37ADB /* VelocityData.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0F37F0852202BF9800A89C0B /* ScrollingTreeScrollingNodeDelegateMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F37F0842202ACB700A89C0B /* ScrollingTreeScrollingNodeDelegateMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0F3DD45012F5EA1B000D9190 /* ShadowBlur.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F3DD44E12F5EA1B000D9190 /* ShadowBlur.h */; };
 		0F3F0E5A157030C3006DA57F /* RenderGeometryMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F3F0E58157030C3006DA57F /* RenderGeometryMap.h */; };
@@ -5629,6 +5630,7 @@
 		0F15ED5A1B7EC7C500EDDFEB /* WillChangeData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WillChangeData.h; sourceTree = "<group>"; };
 		0F17747E1378B771009DA76A /* ScrollAnimatorIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollAnimatorIOS.h; sourceTree = "<group>"; };
 		0F17747F1378B772009DA76A /* ScrollAnimatorIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollAnimatorIOS.mm; sourceTree = "<group>"; };
+		0F1A0C36229A481800D37ADB /* VelocityData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VelocityData.h; sourceTree = "<group>"; };
 		0F26A7A72054C2270090A141 /* TemplateContentDocumentFragment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TemplateContentDocumentFragment.cpp; sourceTree = "<group>"; };
 		0F26A7A92054C3CF0090A141 /* HTMLBDIElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLBDIElement.cpp; sourceTree = "<group>"; };
 		0F26A7AA2054EC5A0090A141 /* HTMLUnknownElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLUnknownElement.cpp; sourceTree = "<group>"; };
@@ -5700,6 +5702,7 @@
 		0F580FA11496939100FB5BD8 /* WebTiledBackingLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebTiledBackingLayer.h; sourceTree = "<group>"; };
 		0F580FA21496939100FB5BD8 /* WebTiledBackingLayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebTiledBackingLayer.mm; sourceTree = "<group>"; };
 		0F580FAE149800D400FB5BD8 /* AnimationUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationUtilities.h; sourceTree = "<group>"; };
+		0F5A57CA229B18AE0025EDA9 /* VelocityData.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = VelocityData.cpp; sourceTree = "<group>"; };
 		0F5B7A5210F65D7A00376302 /* RenderEmbeddedObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderEmbeddedObject.cpp; sourceTree = "<group>"; };
 		0F5B7A5310F65D7A00376302 /* RenderEmbeddedObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderEmbeddedObject.h; sourceTree = "<group>"; };
 		0F5E200518E771FC003EC3E5 /* PlatformCAAnimationCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformCAAnimationCocoa.h; sourceTree = "<group>"; };
@@ -24533,6 +24536,8 @@
 				076E11BE1F683E0D00177395 /* TrackPrivateBase.cpp */,
 				BE913D7F181EF8E500DCB09E /* TrackPrivateBase.h */,
 				E4AFCFA40DAF29A300F5F55C /* UnitBezier.h */,
+				0F5A57CA229B18AE0025EDA9 /* VelocityData.cpp */,
+				0F1A0C36229A481800D37ADB /* VelocityData.h */,
 				075BA84720618AA500FCB4AD /* VideoFullscreenLayerManager.h */,
 				BEF29EEA1715DD0900C4B4C9 /* VideoTrackPrivate.h */,
 				1411DCB0164C39A800D49BC1 /* WidthCache.h */,
@@ -31932,6 +31937,7 @@
 				F513A3EA15FF4841001526DB /* ValidationMessageClient.h in Headers */,
 				15C7708D100D3C6B005BA267 /* ValidityState.h in Headers */,
 				FD3160AF12B026F700C1A359 /* VectorMath.h in Headers */,
+				0F1A0C38229A481800D37ADB /* VelocityData.h in Headers */,
 				BCA257151293C010007A263D /* VerticalPositionCache.h in Headers */,
 				52B0D4C01C57FD660077CE53 /* VideoFullscreenChangeObserver.h in Headers */,
 				3FBC4AF4189881560046EE38 /* VideoFullscreenInterfaceAVKit.h in Headers */,

Modified: trunk/Source/WebCore/page/FrameView.cpp (245786 => 245787)


--- trunk/Source/WebCore/page/FrameView.cpp	2019-05-27 00:10:44 UTC (rev 245786)
+++ trunk/Source/WebCore/page/FrameView.cpp	2019-05-27 01:12:00 UTC (rev 245787)
@@ -99,6 +99,7 @@
 #include "StyleScope.h"
 #include "TextResourceDecoder.h"
 #include "TiledBacking.h"
+#include "VelocityData.h"
 #include "VisualViewport.h"
 #include "WheelEventTestTrigger.h"
 #include <wtf/text/TextStream.h>
@@ -5051,10 +5052,10 @@
     sendResizeEventIfNeeded();
 }
 
-void FrameView::setScrollVelocity(double horizontalVelocity, double verticalVelocity, double scaleChangeRate, MonotonicTime timestamp)
+void FrameView::setScrollVelocity(const VelocityData& velocityData)
 {
     if (TiledBacking* tiledBacking = this->tiledBacking())
-        tiledBacking->setVelocity(VelocityData(horizontalVelocity, verticalVelocity, scaleChangeRate, timestamp));
+        tiledBacking->setVelocity(velocityData);
 }
 #endif // PLATFORM(IOS_FAMILY)
 

Modified: trunk/Source/WebCore/page/FrameView.h (245786 => 245787)


--- trunk/Source/WebCore/page/FrameView.h	2019-05-27 00:10:44 UTC (rev 245786)
+++ trunk/Source/WebCore/page/FrameView.h	2019-05-27 01:12:00 UTC (rev 245787)
@@ -137,7 +137,7 @@
     IntSize customSizeForResizeEvent() const { return m_customSizeForResizeEvent; }
     WEBCORE_EXPORT void setCustomSizeForResizeEvent(IntSize);
 
-    WEBCORE_EXPORT void setScrollVelocity(double horizontalVelocity, double verticalVelocity, double scaleChangeRate, MonotonicTime timestamp);
+    WEBCORE_EXPORT void setScrollVelocity(const VelocityData&);
 #else
     bool useCustomFixedPositionLayoutRect() const { return false; }
 #endif

Modified: trunk/Source/WebCore/platform/graphics/TiledBacking.h (245786 => 245787)


--- trunk/Source/WebCore/platform/graphics/TiledBacking.h	2019-05-27 00:10:44 UTC (rev 245786)
+++ trunk/Source/WebCore/platform/graphics/TiledBacking.h	2019-05-27 01:12:00 UTC (rev 245787)
@@ -41,6 +41,7 @@
 class IntRect;
 class IntSize;
 class PlatformCALayer;
+struct VelocityData;
 
 enum ScrollingModeIndication {
     SynchronousScrollingBecauseOfLackOfScrollingCoordinatorIndication,
@@ -49,26 +50,6 @@
     AsyncScrollingIndication
 };
 
-struct VelocityData  {
-    double horizontalVelocity;
-    double verticalVelocity;
-    double scaleChangeRate;
-    MonotonicTime lastUpdateTime;
-    
-    VelocityData(double horizontal = 0, double vertical = 0, double scaleChange = 0, MonotonicTime updateTime = MonotonicTime())
-        : horizontalVelocity(horizontal)
-        , verticalVelocity(vertical)
-        , scaleChangeRate(scaleChange)
-        , lastUpdateTime(updateTime)
-    {
-    }
-    
-    bool velocityOrScaleIsChanging() const
-    {
-        return horizontalVelocity || verticalVelocity || scaleChangeRate;
-    }
-};
-
 class TiledBacking {
 public:
     virtual ~TiledBacking() = default;

Added: trunk/Source/WebCore/platform/graphics/VelocityData.cpp (0 => 245787)


--- trunk/Source/WebCore/platform/graphics/VelocityData.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/VelocityData.cpp	2019-05-27 01:12:00 UTC (rev 245787)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2019 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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.
+ */
+
+#include "config.h"
+#include "VelocityData.h"
+
+#include <wtf/text/TextStream.h>
+
+namespace WebCore {
+
+TextStream& operator<<(TextStream& ts, const VelocityData& velocityData)
+{
+    ts.dumpProperty("timestamp", velocityData.lastUpdateTime.secondsSinceEpoch().value());
+    if (velocityData.horizontalVelocity)
+        ts.dumpProperty("horizontalVelocity", velocityData.horizontalVelocity);
+    if (velocityData.verticalVelocity)
+        ts.dumpProperty("verticalVelocity", velocityData.verticalVelocity);
+    if (velocityData.scaleChangeRate)
+        ts.dumpProperty("scaleChangeRate", velocityData.scaleChangeRate);
+
+    return ts;
+}
+
+} // namespace WebCore

Added: trunk/Source/WebCore/platform/graphics/VelocityData.h (0 => 245787)


--- trunk/Source/WebCore/platform/graphics/VelocityData.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/VelocityData.h	2019-05-27 01:12:00 UTC (rev 245787)
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2012-2019 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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.
+ */
+
+#pragma once
+
+#include "FloatPoint.h"
+#include <wtf/MonotonicTime.h>
+#include <wtf/Optional.h>
+
+namespace WTF {
+class TextStream;
+}
+
+namespace WebCore {
+
+struct VelocityData  {
+    float horizontalVelocity { 0 };
+    float verticalVelocity { 0 };
+    float scaleChangeRate { 0 };
+    MonotonicTime lastUpdateTime;
+    
+    VelocityData(float horizontal = 0, float vertical = 0, float scaleChange = 0, MonotonicTime updateTime = MonotonicTime())
+        : horizontalVelocity(horizontal)
+        , verticalVelocity(vertical)
+        , scaleChangeRate(scaleChange)
+        , lastUpdateTime(updateTime)
+    {
+    }
+    
+    bool velocityOrScaleIsChanging() const
+    {
+        return horizontalVelocity || verticalVelocity || scaleChangeRate;
+    }
+    
+    bool equalIgnoringTimestamp(const VelocityData& other) const
+    {
+        return horizontalVelocity == other.horizontalVelocity
+            && verticalVelocity == other.verticalVelocity
+            && scaleChangeRate == other.scaleChangeRate;
+    }
+};
+
+WEBCORE_EXPORT TextStream& operator<<(TextStream&, const VelocityData&);
+
+class HistoricalVelocityData {
+public:
+    HistoricalVelocityData() = default;
+
+    VelocityData velocityForNewData(FloatPoint newPosition, double scale, MonotonicTime timestamp)
+    {
+        // Due to all the source of rect update, the input is very noisy. To smooth the output, we accumulate all changes
+        // within 1 frame as a single update. No speed computation is ever done on data within the same frame.
+        const Seconds filteringThreshold(1.0 / 60);
+
+        VelocityData velocityData;
+        if (m_historySize > 0) {
+            unsigned oldestDataIndex;
+            unsigned distanceToLastHistoricalData = m_historySize - 1;
+            if (distanceToLastHistoricalData <= m_latestDataIndex)
+                oldestDataIndex = m_latestDataIndex - distanceToLastHistoricalData;
+            else
+                oldestDataIndex = m_historySize - (distanceToLastHistoricalData - m_latestDataIndex);
+
+            Seconds timeDelta = timestamp - m_positionHistory[oldestDataIndex].timestamp;
+            if (timeDelta > filteringThreshold) {
+                Data& oldestData = m_positionHistory[oldestDataIndex];
+                velocityData = VelocityData((newPosition.x() - oldestData.position.x()) / timeDelta.seconds(), (newPosition.y() - oldestData.position.y()) / timeDelta.seconds(), (scale - oldestData.scale) / timeDelta.seconds(), timestamp);
+            }
+        }
+
+        Seconds timeSinceLastAppend = timestamp - m_lastAppendTimestamp;
+        if (timeSinceLastAppend > filteringThreshold)
+            append(newPosition, scale, timestamp);
+        else
+            m_positionHistory[m_latestDataIndex] = { timestamp, newPosition, scale };
+
+        return velocityData;
+    }
+
+    void clear() { m_historySize = 0; }
+
+private:
+    void append(FloatPoint newPosition, double scale, MonotonicTime timestamp)
+    {
+        m_latestDataIndex = (m_latestDataIndex + 1) % maxHistoryDepth;
+        m_positionHistory[m_latestDataIndex] = { timestamp, newPosition, scale };
+        m_historySize = std::min(m_historySize + 1, maxHistoryDepth);
+        m_lastAppendTimestamp = timestamp;
+    }
+
+    static constexpr unsigned maxHistoryDepth = 3;
+
+    unsigned m_historySize { 0 };
+    unsigned m_latestDataIndex { 0 };
+    MonotonicTime m_lastAppendTimestamp;
+
+    struct Data {
+        MonotonicTime timestamp;
+        FloatPoint position;
+        double scale;
+    } m_positionHistory[maxHistoryDepth];
+};
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/ca/TileController.cpp (245786 => 245787)


--- trunk/Source/WebCore/platform/graphics/ca/TileController.cpp	2019-05-27 00:10:44 UTC (rev 245786)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.cpp	2019-05-27 01:12:00 UTC (rev 245787)
@@ -34,6 +34,7 @@
 #include "Region.h"
 #include "TileCoverageMap.h"
 #include "TileGrid.h"
+#include "VelocityData.h"
 #include <utility>
 #include <wtf/MainThread.h>
 #include <wtf/text/TextStream.h>
@@ -428,6 +429,7 @@
     if (!m_velocity.horizontalVelocity && !m_velocity.verticalVelocity) {
         if (m_velocity.scaleChangeRate > 0) {
             coverageRect = visibleRect;
+            LOG_WITH_STREAM(Tiling, stream << "TileController " << this << " computeTileCoverageRect - zooming, coverage is visible rect " << coverageRect);
             return;
         }
         futureRect.setWidth(futureRect.width() + horizontalMargin);
@@ -448,8 +450,9 @@
     if (futureRect.y() < 0)
         futureRect.setY(0);
 
+    LOG_WITH_STREAM(Tiling, stream << "TileController " << this << " computeTileCoverageRect - coverage " << coverageRect << " expanded to " << unionRect(coverageRect, futureRect) << " velocity " << m_velocity);
+
     coverageRect.unite(futureRect);
-    return;
 #else
     UNUSED_PARAM(contentsScale);
 

Modified: trunk/Source/WebCore/platform/graphics/ca/TileController.h (245786 => 245787)


--- trunk/Source/WebCore/platform/graphics/ca/TileController.h	2019-05-27 00:10:44 UTC (rev 245786)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.h	2019-05-27 01:12:00 UTC (rev 245787)
@@ -32,6 +32,7 @@
 #include "PlatformCALayerClient.h"
 #include "TiledBacking.h"
 #include "Timer.h"
+#include "VelocityData.h"
 #include <wtf/Deque.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/RetainPtr.h>

Modified: trunk/Source/WebKit/ChangeLog (245786 => 245787)


--- trunk/Source/WebKit/ChangeLog	2019-05-27 00:10:44 UTC (rev 245786)
+++ trunk/Source/WebKit/ChangeLog	2019-05-27 01:12:00 UTC (rev 245787)
@@ -1,3 +1,45 @@
+2019-05-26  Simon Fraser  <[email protected]>
+
+        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.
+
+        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):
+
 2019-05-26  John Wilander  <[email protected]>
 
         Resource Load Statistics: Downgrade document.referrer to the referrer's eTLD+1 if the page was navigated to with a prevalent resource referrer containing link decoration

Modified: trunk/Source/WebKit/Shared/VisibleContentRectUpdateInfo.cpp (245786 => 245787)


--- trunk/Source/WebKit/Shared/VisibleContentRectUpdateInfo.cpp	2019-05-27 00:10:44 UTC (rev 245786)
+++ trunk/Source/WebKit/Shared/VisibleContentRectUpdateInfo.cpp	2019-05-27 01:12:00 UTC (rev 245787)
@@ -43,12 +43,9 @@
     encoder << m_customFixedPositionRect;
     encoder << m_obscuredInsets;
     encoder << m_unobscuredSafeAreaInsets;
+    encoder << m_scrollVelocity;
     encoder << m_lastLayerTreeTransactionID;
     encoder << m_scale;
-    encoder << m_timestamp;
-    encoder << m_horizontalVelocity;
-    encoder << m_verticalVelocity;
-    encoder << m_scaleChangeRate;
     encoder << m_inStableState;
     encoder << m_isFirstUpdateForNewViewSize;
     encoder << m_isChangingObscuredInsetsInteractively;
@@ -74,18 +71,12 @@
         return false;
     if (!decoder.decode(result.m_unobscuredSafeAreaInsets))
         return false;
+    if (!decoder.decode(result.m_scrollVelocity))
+        return false;
     if (!decoder.decode(result.m_lastLayerTreeTransactionID))
         return false;
     if (!decoder.decode(result.m_scale))
         return false;
-    if (!decoder.decode(result.m_timestamp))
-        return false;
-    if (!decoder.decode(result.m_horizontalVelocity))
-        return false;
-    if (!decoder.decode(result.m_verticalVelocity))
-        return false;
-    if (!decoder.decode(result.m_scaleChangeRate))
-        return false;
     if (!decoder.decode(result.m_inStableState))
         return false;
     if (!decoder.decode(result.m_isFirstUpdateForNewViewSize))
@@ -132,14 +123,8 @@
     if (info.enclosedInScrollableAncestorView())
         ts.dumpProperty("enclosedInScrollableAncestorView", info.enclosedInScrollableAncestorView());
 
-    ts.dumpProperty("timestamp", info.timestamp().secondsSinceEpoch().value());
     ts.dumpProperty("allowShrinkToFit", info.allowShrinkToFit());
-    if (info.horizontalVelocity())
-        ts.dumpProperty("horizontalVelocity", info.horizontalVelocity());
-    if (info.verticalVelocity())
-        ts.dumpProperty("verticalVelocity", info.verticalVelocity());
-    if (info.scaleChangeRate())
-        ts.dumpProperty("scaleChangeRate", info.scaleChangeRate());
+    ts.dumpProperty("scrollVelocity", info.scrollVelocity());
 
     return ts;
 }

Modified: trunk/Source/WebKit/Shared/VisibleContentRectUpdateInfo.h (245786 => 245787)


--- trunk/Source/WebKit/Shared/VisibleContentRectUpdateInfo.h	2019-05-27 00:10:44 UTC (rev 245786)
+++ trunk/Source/WebKit/Shared/VisibleContentRectUpdateInfo.h	2019-05-27 01:12:00 UTC (rev 245787)
@@ -27,6 +27,7 @@
 
 #include <WebCore/FloatRect.h>
 #include <WebCore/LengthBox.h>
+#include <WebCore/VelocityData.h>
 #include <wtf/MonotonicTime.h>
 #include <wtf/text/WTFString.h>
 
@@ -45,7 +46,7 @@
 public:
     VisibleContentRectUpdateInfo() = default;
 
-    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)
+    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)
         : m_exposedContentRect(exposedContentRect)
         , m_unobscuredContentRect(unobscuredContentRect)
         , m_contentInsets(contentInsets)
@@ -54,12 +55,9 @@
         , m_customFixedPositionRect(customFixedPositionRect)
         , m_obscuredInsets(obscuredInsets)
         , m_unobscuredSafeAreaInsets(unobscuredSafeAreaInsets)
+        , m_scrollVelocity(scrollVelocity)
         , m_lastLayerTreeTransactionID(lastLayerTreeTransactionId)
         , m_scale(scale)
-        , m_timestamp(timestamp)
-        , m_horizontalVelocity(horizontalVelocity)
-        , m_verticalVelocity(verticalVelocity)
-        , m_scaleChangeRate(scaleChangeRate)
         , m_inStableState(inStableState)
         , m_isFirstUpdateForNewViewSize(isFirstUpdateForNewViewSize)
         , m_isChangingObscuredInsetsInteractively(isChangingObscuredInsetsInteractively)
@@ -74,6 +72,7 @@
     const WebCore::FloatRect& unobscuredRectInScrollViewCoordinates() const { return m_unobscuredRectInScrollViewCoordinates; }
     const WebCore::FloatRect& unobscuredContentRectRespectingInputViewBounds() const { return m_unobscuredContentRectRespectingInputViewBounds; }
     const WebCore::FloatRect& customFixedPositionRect() const { return m_customFixedPositionRect; }
+    const WebCore::VelocityData& scrollVelocity() const { return m_scrollVelocity; }
     const WebCore::FloatBoxExtent& obscuredInsets() const { return m_obscuredInsets; }
     const WebCore::FloatBoxExtent& unobscuredSafeAreaInsets() const { return m_unobscuredSafeAreaInsets; }
 
@@ -83,14 +82,10 @@
     bool isChangingObscuredInsetsInteractively() const { return m_isChangingObscuredInsetsInteractively; }
     bool allowShrinkToFit() const { return m_allowShrinkToFit; }
     bool enclosedInScrollableAncestorView() const { return m_enclosedInScrollableAncestorView; }
+    uint64_t lastLayerTreeTransactionID() const { return m_lastLayerTreeTransactionID; }
 
-    MonotonicTime timestamp() const { return m_timestamp; }
-    double horizontalVelocity() const { return m_horizontalVelocity; }
-    double verticalVelocity() const { return m_verticalVelocity; }
-    double scaleChangeRate() const { return m_scaleChangeRate; }
+    MonotonicTime timestamp() const { return m_scrollVelocity.lastUpdateTime; }
 
-    uint64_t lastLayerTreeTransactionID() const { return m_lastLayerTreeTransactionID; }
-
     void encode(IPC::Encoder&) const;
     static bool decode(IPC::Decoder&, VisibleContentRectUpdateInfo&);
 
@@ -105,12 +100,9 @@
     WebCore::FloatRect m_customFixedPositionRect; // When visual viewports are enabled, this is the layout viewport.
     WebCore::FloatBoxExtent m_obscuredInsets;
     WebCore::FloatBoxExtent m_unobscuredSafeAreaInsets;
+    WebCore::VelocityData m_scrollVelocity;
     uint64_t m_lastLayerTreeTransactionID { 0 };
     double m_scale { -1 };
-    MonotonicTime m_timestamp;
-    double m_horizontalVelocity { 0 };
-    double m_verticalVelocity { 0 };
-    double m_scaleChangeRate { 0 };
     bool m_inStableState { false };
     bool m_isFirstUpdateForNewViewSize { false };
     bool m_isChangingObscuredInsetsInteractively { false };
@@ -129,9 +121,7 @@
         && a.customFixedPositionRect() == b.customFixedPositionRect()
         && a.obscuredInsets() == b.obscuredInsets()
         && a.unobscuredSafeAreaInsets() == b.unobscuredSafeAreaInsets()
-        && a.horizontalVelocity() == b.horizontalVelocity()
-        && a.verticalVelocity() == b.verticalVelocity()
-        && a.scaleChangeRate() == b.scaleChangeRate()
+        && a.scrollVelocity().equalIgnoringTimestamp(b.scrollVelocity())
         && a.inStableState() == b.inStableState()
         && a.isFirstUpdateForNewViewSize() == b.isFirstUpdateForNewViewSize()
         && a.allowShrinkToFit() == b.allowShrinkToFit()

Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (245786 => 245787)


--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2019-05-27 00:10:44 UTC (rev 245786)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2019-05-27 01:12:00 UTC (rev 245787)
@@ -81,6 +81,7 @@
 #include <WebCore/TimingFunction.h>
 #include <WebCore/TransformationMatrix.h>
 #include <WebCore/UserStyleSheet.h>
+#include <WebCore/VelocityData.h>
 #include <WebCore/ViewportArguments.h>
 #include <WebCore/WindowFeatures.h>
 #include <pal/SessionID.h>
@@ -923,7 +924,37 @@
     return SimpleArgumentCoder<ViewportAttributes>::decode(decoder, viewportAttributes);
 }
 
+void ArgumentCoder<VelocityData>::encode(Encoder& encoder, const VelocityData& velocityData)
+{
+    encoder << velocityData.horizontalVelocity << velocityData.verticalVelocity << velocityData.scaleChangeRate << velocityData.lastUpdateTime;
+}
 
+bool ArgumentCoder<VelocityData>::decode(Decoder& decoder, VelocityData& velocityData)
+{
+    float horizontalVelocity;
+    if (!decoder.decode(horizontalVelocity))
+        return false;
+
+    float verticalVelocity;
+    if (!decoder.decode(verticalVelocity))
+        return false;
+
+    float scaleChangeRate;
+    if (!decoder.decode(scaleChangeRate))
+        return false;
+
+    MonotonicTime lastUpdateTime;
+    if (!decoder.decode(lastUpdateTime))
+        return false;
+
+    velocityData.horizontalVelocity = horizontalVelocity;
+    velocityData.verticalVelocity = verticalVelocity;
+    velocityData.scaleChangeRate = scaleChangeRate;
+    velocityData.lastUpdateTime = lastUpdateTime;
+
+    return true;
+}
+
 void ArgumentCoder<MimeClassInfo>::encode(Encoder& encoder, const MimeClassInfo& mimeClassInfo)
 {
     encoder << mimeClassInfo.type << mimeClassInfo.desc << mimeClassInfo.extensions;

Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h (245786 => 245787)


--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h	2019-05-27 00:10:44 UTC (rev 245786)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h	2019-05-27 01:12:00 UTC (rev 245787)
@@ -125,6 +125,7 @@
 #if ENABLE(POINTER_EVENTS)
 struct TouchActionData;
 #endif
+struct VelocityData;
 struct ViewportAttributes;
 struct WindowFeatures;
     
@@ -334,6 +335,11 @@
     static bool decode(Decoder&, WebCore::ViewportAttributes&);
 };
 
+template<> struct ArgumentCoder<WebCore::VelocityData> {
+    static void encode(Encoder&, const WebCore::VelocityData&);
+    static bool decode(Decoder&, WebCore::VelocityData&);
+};
+
 template<> struct ArgumentCoder<WebCore::MimeClassInfo> {
     static void encode(Encoder&, const WebCore::MimeClassInfo&);
     static Optional<WebCore::MimeClassInfo> decode(Decoder&);

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentView.mm (245786 => 245787)


--- trunk/Source/WebKit/UIProcess/ios/WKContentView.mm	2019-05-27 00:10:44 UTC (rev 245786)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentView.mm	2019-05-27 01:12:00 UTC (rev 245787)
@@ -60,103 +60,12 @@
 #import <WebCore/NotImplemented.h>
 #import <WebCore/PlatformScreen.h>
 #import <WebCore/Quirks.h>
+#import <WebCore/VelocityData.h>
 #import <pal/spi/cocoa/QuartzCoreSPI.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/text/TextStream.h>
 
 
-namespace WebKit {
-using namespace WebCore;
-using namespace WebKit;
-
-class HistoricalVelocityData {
-public:
-    struct VelocityData {
-        VelocityData()
-            : horizontalVelocity(0)
-            , verticalVelocity(0)
-            , scaleChangeRate(0)
-        {
-        }
-
-        VelocityData(double horizontalVelocity, double verticalVelocity, double scaleChangeRate)
-            : horizontalVelocity(horizontalVelocity)
-            , verticalVelocity(verticalVelocity)
-            , scaleChangeRate(scaleChangeRate)
-        {
-        }
-
-        double horizontalVelocity;
-        double verticalVelocity;
-        double scaleChangeRate;
-    };
-
-    HistoricalVelocityData()
-        : m_historySize(0)
-        , m_latestDataIndex(0)
-    {
-    }
-
-    VelocityData velocityForNewData(CGPoint newPosition, double scale, MonotonicTime timestamp)
-    {
-        // Due to all the source of rect update, the input is very noisy. To smooth the output, we accumulate all changes
-        // within 1 frame as a single update. No speed computation is ever done on data within the same frame.
-        const Seconds filteringThreshold(1.0 / 60);
-
-        VelocityData velocityData;
-        if (m_historySize > 0) {
-            unsigned oldestDataIndex;
-            unsigned distanceToLastHistoricalData = m_historySize - 1;
-            if (distanceToLastHistoricalData <= m_latestDataIndex)
-                oldestDataIndex = m_latestDataIndex - distanceToLastHistoricalData;
-            else
-                oldestDataIndex = m_historySize - (distanceToLastHistoricalData - m_latestDataIndex);
-
-            Seconds timeDelta = timestamp - m_history[oldestDataIndex].timestamp;
-            if (timeDelta > filteringThreshold) {
-                Data& oldestData = m_history[oldestDataIndex];
-                velocityData = VelocityData((newPosition.x - oldestData.position.x) / timeDelta.seconds(), (newPosition.y - oldestData.position.y) / timeDelta.seconds(), (scale - oldestData.scale) / timeDelta.seconds());
-            }
-        }
-
-        Seconds timeSinceLastAppend = timestamp - m_lastAppendTimestamp;
-        if (timeSinceLastAppend > filteringThreshold)
-            append(newPosition, scale, timestamp);
-        else
-            m_history[m_latestDataIndex] = { timestamp, newPosition, scale };
-        return velocityData;
-    }
-
-    void clear() { m_historySize = 0; }
-
-private:
-    void append(CGPoint newPosition, double scale, MonotonicTime timestamp)
-    {
-        m_latestDataIndex = (m_latestDataIndex + 1) % maxHistoryDepth;
-        m_history[m_latestDataIndex] = { timestamp, newPosition, scale };
-
-        unsigned size = m_historySize + 1;
-        if (size <= maxHistoryDepth)
-            m_historySize = size;
-
-        m_lastAppendTimestamp = timestamp;
-    }
-
-
-    static const unsigned maxHistoryDepth = 3;
-
-    unsigned m_historySize;
-    unsigned m_latestDataIndex;
-    MonotonicTime m_lastAppendTimestamp;
-
-    struct Data {
-        MonotonicTime timestamp;
-        CGPoint position;
-        double scale;
-    } m_history[maxHistoryDepth];
-};
-} // namespace WebKit
-
 @interface WKInspectorIndicationView : UIView
 @end
 
@@ -223,7 +132,7 @@
     RetainPtr<_UILayerHostView> _visibilityPropagationView;
 #endif
 
-    WebKit::HistoricalVelocityData _historicalKinematicData;
+    WebCore::HistoricalVelocityData _historicalKinematicData;
 
     RetainPtr<NSUndoManager> _undoManager;
     RetainPtr<WKQuirkyNSUndoManager> _quirkyUndoManager;
@@ -463,11 +372,13 @@
         return;
 
     MonotonicTime timestamp = MonotonicTime::now();
-    WebKit::HistoricalVelocityData::VelocityData velocityData;
+    WebCore::VelocityData velocityData;
     if (!isStableState)
         velocityData = _historicalKinematicData.velocityForNewData(visibleContentRect.origin, zoomScale, timestamp);
-    else
+    else {
         _historicalKinematicData.clear();
+        velocityData = { 0, 0, 0, timestamp };
+    }
 
     WebKit::RemoteScrollingCoordinatorProxy* scrollingCoordinator = _page->scrollingCoordinatorProxy();
 
@@ -489,10 +400,7 @@
         isChangingObscuredInsetsInteractively,
         _webView._allowsViewportShrinkToFit,
         enclosedInScrollableAncestorView,
-        timestamp,
-        velocityData.horizontalVelocity,
-        velocityData.verticalVelocity,
-        velocityData.scaleChangeRate,
+        velocityData,
         downcast<WebKit::RemoteLayerTreeDrawingAreaProxy>(*drawingArea).lastCommittedLayerTreeTransactionID());
 
     LOG_WITH_STREAM(VisibleRects, stream << "-[WKContentView didUpdateVisibleRect]" << visibleContentRectUpdateInfo.dump());

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (245786 => 245787)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-05-27 00:10:44 UTC (rev 245786)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-05-27 01:12:00 UTC (rev 245787)
@@ -3160,7 +3160,7 @@
         newExposedContentRect.moveBy(adjustmentDelta);
     }
 
-    frameView.setScrollVelocity(0, 0, 0, MonotonicTime::now());
+    frameView.setScrollVelocity({ 0, 0, 0, MonotonicTime::now() });
 
     IntPoint roundedUnobscuredContentRectPosition = roundedIntPoint(newUnobscuredContentRect.location());
     frameView.setUnobscuredContentSize(newUnobscuredContentRect.size());
@@ -3333,7 +3333,7 @@
         minimumLayoutSizeInScrollViewCoordinates.scale(1 / scale);
         IntSize minimumLayoutSizeInDocumentCoordinates = roundedIntSize(minimumLayoutSizeInScrollViewCoordinates);
         frameView.setUnobscuredContentSize(minimumLayoutSizeInDocumentCoordinates);
-        frameView.setScrollVelocity(0, 0, 0, MonotonicTime::now());
+        frameView.setScrollVelocity({ 0, 0, 0, MonotonicTime::now() });
 
         // FIXME: We could send down the obscured margins to find a better exposed rect and unobscured rect.
         // It is not a big deal at the moment because the tile coverage will always extend past the obscured bottom inset.
@@ -3404,15 +3404,15 @@
         m_page->applicationDidBecomeActive();
 }
 
-static inline void adjustVelocityDataForBoundedScale(double& horizontalVelocity, double& verticalVelocity, double& scaleChangeRate, double exposedRectScale, double minimumScale, double maximumScale)
+static inline void adjustVelocityDataForBoundedScale(VelocityData& velocityData, double exposedRectScale, double minimumScale, double maximumScale)
 {
-    if (scaleChangeRate) {
-        horizontalVelocity = 0;
-        verticalVelocity = 0;
+    if (velocityData.scaleChangeRate) {
+        velocityData.horizontalVelocity = 0;
+        velocityData.verticalVelocity = 0;
     }
 
     if (exposedRectScale >= maximumScale || exposedRectScale <= minimumScale)
-        scaleChangeRate = 0;
+        velocityData.scaleChangeRate = 0;
 }
 
 Optional<float> WebPage::scaleFromUIProcess(const VisibleContentRectUpdateInfo& visibleContentRectUpdateInfo) const
@@ -3520,13 +3520,10 @@
     m_page->setUnobscuredSafeAreaInsets(visibleContentRectUpdateInfo.unobscuredSafeAreaInsets());
     m_page->setEnclosedInScrollableAncestorView(visibleContentRectUpdateInfo.enclosedInScrollableAncestorView());
 
-    double horizontalVelocity = visibleContentRectUpdateInfo.horizontalVelocity();
-    double verticalVelocity = visibleContentRectUpdateInfo.verticalVelocity();
-    double scaleChangeRate = visibleContentRectUpdateInfo.scaleChangeRate();
-    adjustVelocityDataForBoundedScale(horizontalVelocity, verticalVelocity, scaleChangeRate, visibleContentRectUpdateInfo.scale(), m_viewportConfiguration.minimumScale(), m_viewportConfiguration.maximumScale());
+    VelocityData scrollVelocity = visibleContentRectUpdateInfo.scrollVelocity();
+    adjustVelocityDataForBoundedScale(scrollVelocity, visibleContentRectUpdateInfo.scale(), m_viewportConfiguration.minimumScale(), m_viewportConfiguration.maximumScale());
+    frameView.setScrollVelocity(scrollVelocity);
 
-    frameView.setScrollVelocity(horizontalVelocity, verticalVelocity, scaleChangeRate, visibleContentRectUpdateInfo.timestamp());
-
     if (m_isInStableState) {
         if (visibleContentRectUpdateInfo.unobscuredContentRect() != visibleContentRectUpdateInfo.unobscuredContentRectRespectingInputViewBounds())
             frameView.setVisualViewportOverrideRect(LayoutRect(visibleContentRectUpdateInfo.unobscuredContentRectRespectingInputViewBounds()));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to