Diff
Modified: trunk/Source/WebCore/ChangeLog (271936 => 271937)
--- trunk/Source/WebCore/ChangeLog 2021-01-27 08:36:19 UTC (rev 271936)
+++ trunk/Source/WebCore/ChangeLog 2021-01-27 08:41:41 UTC (rev 271937)
@@ -1,3 +1,33 @@
+2021-01-27 Martin Robinson <[email protected]>
+
+ Use ScrollSnapOffsetsInfo in the scrolling tree
+ https://bugs.webkit.org/show_bug.cgi?id=220915
+
+ Reviewed by Simon Fraser.
+
+ No new tests. This should not change behavior.
+
+ Use ScrollSnapOffsets more often in the scrolling tree to continue to
+ abstract away the details of how snap offsets are implemented.
+
+ * page/scrolling/AsyncScrollingCoordinator.cpp:
+ (WebCore::setStateScrollingNodeSnapOffsetsAsFloat):
+ (WebCore::AsyncScrollingCoordinator::setScrollingNodeScrollableAreaGeometry):
+ (WebCore::AsyncScrollingCoordinator::updateScrollSnapPropertiesWithFrameView):
+ * page/scrolling/ScrollSnapOffsetsInfo.h:
+ (WebCore::ScrollSnapOffsetsInfo::isEqual const):
+ * page/scrolling/ScrollingStateScrollingNode.cpp:
+ (WebCore::ScrollingStateScrollingNode::applicableProperties const):
+ (WebCore::ScrollingStateScrollingNode::setSnapOffsetsInfo):
+ * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm:
+ (WebCore::ScrollingTreeScrollingNodeDelegateMac::updateFromStateNode):
+ (): Deleted.
+ * platform/cocoa/ScrollController.h:
+ * platform/cocoa/ScrollController.mm:
+ (WebCore::ScrollController::updateScrollSnapState):
+ (WebCore::ScrollController::updateScrollSnapPoints):
+ (WebCore::otherScrollEventAxis): Deleted.
+
2021-01-27 Youenn Fablet <[email protected]>
Add support for RTCRtpParameters.rtcp
Modified: trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp (271936 => 271937)
--- trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp 2021-01-27 08:36:19 UTC (rev 271936)
+++ trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp 2021-01-27 08:41:41 UTC (rev 271937)
@@ -92,31 +92,15 @@
#endif
#if ENABLE(CSS_SCROLL_SNAP)
-static inline void setStateScrollingNodeSnapOffsetsAsFloat(ScrollingStateScrollingNode& node, ScrollEventAxis axis, const ScrollSnapOffsetsInfo<LayoutUnit>* offsetInfo, float deviceScaleFactor)
+static inline void setStateScrollingNodeSnapOffsetsAsFloat(ScrollingStateScrollingNode& node, const ScrollSnapOffsetsInfo<LayoutUnit>* offsetInfo, float deviceScaleFactor)
{
- // FIXME: Incorporate current page scale factor in snapping to device pixel. Perhaps we should just convert to float here and let UI process do the pixel snapping?
- Vector<float> snapOffsetsAsFloat;
- if (offsetInfo) {
- const auto& offsets = offsetInfo->offsetsForAxis(axis);
- snapOffsetsAsFloat.reserveInitialCapacity(offsets.size());
- for (auto& offset : offsets)
- snapOffsetsAsFloat.uncheckedAppend(roundToDevicePixel(offset, deviceScaleFactor, false));
+ if (!offsetInfo) {
+ node.setSnapOffsetsInfo(ScrollSnapOffsetsInfo<float>());
+ return;
}
- Vector<ScrollOffsetRange<float>> snapOffsetRangesAsFloat;
- if (offsetInfo) {
- const auto& snapOffsetRanges = offsetInfo->offsetRangesForAxis(axis);
- snapOffsetRangesAsFloat.reserveInitialCapacity(snapOffsetRanges.size());
- for (auto& range : snapOffsetRanges)
- snapOffsetRangesAsFloat.uncheckedAppend({ roundToDevicePixel(range.start, deviceScaleFactor, false), roundToDevicePixel(range.end, deviceScaleFactor, false) });
- }
- if (axis == ScrollEventAxis::Horizontal) {
- node.setHorizontalSnapOffsets(snapOffsetsAsFloat);
- node.setHorizontalSnapOffsetRanges(snapOffsetRangesAsFloat);
- } else {
- node.setVerticalSnapOffsets(snapOffsetsAsFloat);
- node.setVerticalSnapOffsetRanges(snapOffsetRangesAsFloat);
- }
+ // FIXME: Incorporate current page scale factor in snapping to device pixel. Perhaps we should just convert to float here and let UI process do the pixel snapping?
+ node.setSnapOffsetsInfo(offsetInfo->convertUnits<float>(deviceScaleFactor));
}
#endif
@@ -714,8 +698,7 @@
#if ENABLE(CSS_SCROLL_SNAP)
scrollableArea.updateSnapOffsets();
- setStateScrollingNodeSnapOffsetsAsFloat(scrollingNode, ScrollEventAxis::Horizontal, scrollableArea.snapOffsetInfo(), m_page->deviceScaleFactor());
- setStateScrollingNodeSnapOffsetsAsFloat(scrollingNode, ScrollEventAxis::Vertical, scrollableArea.snapOffsetInfo(), m_page->deviceScaleFactor());
+ setStateScrollingNodeSnapOffsetsAsFloat(scrollingNode, scrollableArea.snapOffsetInfo(), m_page->deviceScaleFactor());
scrollingNode.setCurrentHorizontalSnapPointIndex(scrollableArea.currentHorizontalSnapPointIndex());
scrollingNode.setCurrentVerticalSnapPointIndex(scrollableArea.currentVerticalSnapPointIndex());
#endif
@@ -909,8 +892,7 @@
void AsyncScrollingCoordinator::updateScrollSnapPropertiesWithFrameView(const FrameView& frameView)
{
if (auto node = downcast<ScrollingStateFrameScrollingNode>(m_scrollingStateTree->stateNodeForID(frameView.scrollingNodeID()))) {
- setStateScrollingNodeSnapOffsetsAsFloat(*node, ScrollEventAxis::Horizontal, frameView.snapOffsetInfo(), m_page->deviceScaleFactor());
- setStateScrollingNodeSnapOffsetsAsFloat(*node, ScrollEventAxis::Vertical, frameView.snapOffsetInfo(), m_page->deviceScaleFactor());
+ setStateScrollingNodeSnapOffsetsAsFloat(*node, frameView.snapOffsetInfo(), m_page->deviceScaleFactor());
node->setCurrentHorizontalSnapPointIndex(frameView.currentHorizontalSnapPointIndex());
node->setCurrentVerticalSnapPointIndex(frameView.currentVerticalSnapPointIndex());
}
Modified: trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.cpp (271936 => 271937)
--- trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.cpp 2021-01-27 08:36:19 UTC (rev 271936)
+++ trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.cpp 2021-01-27 08:41:41 UTC (rev 271937)
@@ -320,6 +320,57 @@
scrollableArea.clearVerticalSnapOffsets();
}
+static float convertOffsetUnit(LayoutUnit input, float deviceScaleFactor)
+{
+ return roundToDevicePixel(input, deviceScaleFactor, false);
}
+static LayoutUnit convertOffsetUnit(float input, float /* scaleFactor */)
+{
+ return LayoutUnit(input);
+}
+
+template <typename InputType, typename OutputType>
+static ScrollSnapOffsetsInfo<OutputType> convertOffsetInfo(const ScrollSnapOffsetsInfo<InputType>& input, float scaleFactor = 0.0)
+{
+ auto convertOffsets = [scaleFactor](const Vector<InputType>& input)
+ {
+ Vector<OutputType> output;
+ output.reserveInitialCapacity(input.size());
+ for (auto& offset : input)
+ output.uncheckedAppend(convertOffsetUnit(offset, scaleFactor));
+ return output;
+ };
+
+ auto convertOffsetRanges = [scaleFactor](const Vector<ScrollOffsetRange<InputType>>& input)
+ {
+ Vector<ScrollOffsetRange<OutputType>> output;
+ output.reserveInitialCapacity(input.size());
+ for (auto& range : input)
+ output.uncheckedAppend({ convertOffsetUnit(range.start, scaleFactor), convertOffsetUnit(range.end, scaleFactor) });
+ return output;
+ };
+
+ return {
+ convertOffsets(input.horizontalSnapOffsets),
+ convertOffsets(input.verticalSnapOffsets),
+ convertOffsetRanges(input.horizontalSnapOffsetRanges),
+ convertOffsetRanges(input.verticalSnapOffsetRanges)
+ };
+}
+
+template <> template <>
+ScrollSnapOffsetsInfo<LayoutUnit> ScrollSnapOffsetsInfo<float>::convertUnits(float /* unusedScaleFactor */) const
+{
+ return convertOffsetInfo<float, LayoutUnit>(*this);
+}
+
+template <> template <>
+ScrollSnapOffsetsInfo<float> ScrollSnapOffsetsInfo<LayoutUnit>::convertUnits(float deviceScaleFactor) const
+{
+ return convertOffsetInfo<LayoutUnit, float>(*this, deviceScaleFactor);
+}
+
+}
+
#endif // ENABLE(CSS_SCROLL_SNAP)
Modified: trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.h (271936 => 271937)
--- trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.h 2021-01-27 08:36:19 UTC (rev 271936)
+++ trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.h 2021-01-27 08:41:41 UTC (rev 271937)
@@ -59,6 +59,11 @@
Vector<ScrollOffsetRange<T>> horizontalSnapOffsetRanges;
Vector<ScrollOffsetRange<T>> verticalSnapOffsetRanges;
+ bool isEqual(const ScrollSnapOffsetsInfo<T>& other) const
+ {
+ return horizontalSnapOffsets == other.horizontalSnapOffsets && verticalSnapOffsets == other.verticalSnapOffsets && horizontalSnapOffsetRanges == other.horizontalSnapOffsetRanges && verticalSnapOffsetRanges == other.verticalSnapOffsetRanges;
+ }
+
bool isEmpty() const
{
return horizontalSnapOffsets.isEmpty() && verticalSnapOffsets.isEmpty();
@@ -73,8 +78,16 @@
{
return axis == ScrollEventAxis::Vertical ? verticalSnapOffsetRanges : horizontalSnapOffsetRanges;
}
+
+ template<typename OutputType> ScrollSnapOffsetsInfo<OutputType> convertUnits(float deviceScaleFactor = 0.0) const;
};
+template <> template <>
+ScrollSnapOffsetsInfo<LayoutUnit> ScrollSnapOffsetsInfo<float>::convertUnits(float /* unusedScaleFactor */) const;
+
+template <> template <>
+ScrollSnapOffsetsInfo<float> ScrollSnapOffsetsInfo<LayoutUnit>::convertUnits(float deviceScaleFactor) const;
+
const unsigned invalidSnapOffsetIndex = UINT_MAX;
// Update the snap offsets for this scrollable area, given the RenderBox of the scroll container, the RenderStyle
Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h (271936 => 271937)
--- trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h 2021-01-27 08:36:19 UTC (rev 271936)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h 2021-01-27 08:41:41 UTC (rev 271937)
@@ -230,47 +230,44 @@
ScrollableAreaParams = 1LLU << 7,
ReasonsForSynchronousScrolling = 1LLU << 8,
RequestedScrollPosition = 1LLU << 9,
- HorizontalSnapOffsets = 1LLU << 10,
- VerticalSnapOffsets = 1LLU << 11,
- HorizontalSnapOffsetRanges = 1LLU << 12,
- VerticalSnapOffsetRanges = 1LLU << 13,
- CurrentHorizontalSnapOffsetIndex = 1LLU << 14,
- CurrentVerticalSnapOffsetIndex = 1LLU << 15,
- IsMonitoringWheelEvents = 1LLU << 16,
- ScrollContainerLayer = 1LLU << 17,
- ScrolledContentsLayer = 1LLU << 18,
- HorizontalScrollbarLayer = 1LLU << 19,
- VerticalScrollbarLayer = 1LLU << 20,
- PainterForScrollbar = 1LLU << 21,
+ SnapOffsetsInfo = 1LLU << 10,
+ CurrentHorizontalSnapOffsetIndex = 1LLU << 11,
+ CurrentVerticalSnapOffsetIndex = 1LLU << 12,
+ IsMonitoringWheelEvents = 1LLU << 13,
+ ScrollContainerLayer = 1LLU << 14,
+ ScrolledContentsLayer = 1LLU << 15,
+ HorizontalScrollbarLayer = 1LLU << 16,
+ VerticalScrollbarLayer = 1LLU << 17,
+ PainterForScrollbar = 1LLU << 18,
// ScrollingStateFrameScrollingNode
- FrameScaleFactor = 1LLU << 22,
- EventTrackingRegion = 1LLU << 23,
- RootContentsLayer = 1LLU << 24,
- CounterScrollingLayer = 1LLU << 25,
- InsetClipLayer = 1LLU << 26,
- ContentShadowLayer = 1LLU << 27,
- HeaderHeight = 1LLU << 28,
- FooterHeight = 1LLU << 29,
- HeaderLayer = 1LLU << 30,
- FooterLayer = 1LLU << 31,
- BehaviorForFixedElements = 1LLU << 32,
- TopContentInset = 1LLU << 33,
- FixedElementsLayoutRelativeToFrame = 1LLU << 34,
- VisualViewportIsSmallerThanLayoutViewport = 1LLU << 35,
- AsyncFrameOrOverflowScrollingEnabled = 1LLU << 36,
- WheelEventGesturesBecomeNonBlocking = 1LLU << 37,
- ScrollingPerformanceTestingEnabled = 1LLU << 38,
- LayoutViewport = 1LLU << 39,
- MinLayoutViewportOrigin = 1LLU << 40,
- MaxLayoutViewportOrigin = 1LLU << 41,
- OverrideVisualViewportSize = 1LLU << 42,
+ FrameScaleFactor = 1LLU << 19,
+ EventTrackingRegion = 1LLU << 20,
+ RootContentsLayer = 1LLU << 21,
+ CounterScrollingLayer = 1LLU << 22,
+ InsetClipLayer = 1LLU << 23,
+ ContentShadowLayer = 1LLU << 24,
+ HeaderHeight = 1LLU << 25,
+ FooterHeight = 1LLU << 26,
+ HeaderLayer = 1LLU << 27,
+ FooterLayer = 1LLU << 28,
+ BehaviorForFixedElements = 1LLU << 29,
+ TopContentInset = 1LLU << 30,
+ FixedElementsLayoutRelativeToFrame = 1LLU << 31,
+ VisualViewportIsSmallerThanLayoutViewport = 1LLU << 32,
+ AsyncFrameOrOverflowScrollingEnabled = 1LLU << 33,
+ WheelEventGesturesBecomeNonBlocking = 1LLU << 34,
+ ScrollingPerformanceTestingEnabled = 1LLU << 35,
+ LayoutViewport = 1LLU << 36,
+ MinLayoutViewportOrigin = 1LLU << 37,
+ MaxLayoutViewportOrigin = 1LLU << 38,
+ OverrideVisualViewportSize = 1LLU << 39,
// ScrollingStatePositionedNode
- RelatedOverflowScrollingNodes = 1LLU << 43,
- LayoutConstraintData = 1LLU << 44,
+ RelatedOverflowScrollingNodes = 1LLU << 40,
+ LayoutConstraintData = 1LLU << 41,
// ScrollingStateFixedNode, ScrollingStateStickyNode
- ViewportConstraints = 1LLU << 45,
+ ViewportConstraints = 1LLU << 42,
// ScrollingStateOverflowScrollProxyNode
- OverflowScrollingNode = 1LLU << 46,
+ OverflowScrollingNode = 1LLU << 43,
};
bool hasChangedProperties() const { return !m_changedProperties.isEmpty(); }
Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp (271936 => 271937)
--- trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp 2021-01-27 08:36:19 UTC (rev 271936)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp 2021-01-27 08:41:41 UTC (rev 271937)
@@ -94,10 +94,7 @@
Property::ReasonsForSynchronousScrolling,
#endif
#if ENABLE(CSS_SCROLL_SNAP)
- Property::HorizontalSnapOffsets,
- Property::VerticalSnapOffsets,
- Property::HorizontalSnapOffsetRanges,
- Property::VerticalSnapOffsetRanges,
+ Property::SnapOffsetsInfo,
Property::CurrentHorizontalSnapOffsetIndex,
Property::CurrentVerticalSnapOffsetIndex,
Property::IsMonitoringWheelEvents,
@@ -160,42 +157,15 @@
}
#if ENABLE(CSS_SCROLL_SNAP)
-void ScrollingStateScrollingNode::setHorizontalSnapOffsets(const Vector<float>& snapOffsets)
+void ScrollingStateScrollingNode::setSnapOffsetsInfo(const ScrollSnapOffsetsInfo<float>& info)
{
- if (m_snapOffsetsInfo.horizontalSnapOffsets == snapOffsets)
+ if (m_snapOffsetsInfo.isEqual(info))
return;
- m_snapOffsetsInfo.horizontalSnapOffsets = snapOffsets;
- setPropertyChanged(Property::HorizontalSnapOffsets);
+ m_snapOffsetsInfo = info;
+ setPropertyChanged(Property::SnapOffsetsInfo);
}
-void ScrollingStateScrollingNode::setVerticalSnapOffsets(const Vector<float>& snapOffsets)
-{
- if (m_snapOffsetsInfo.verticalSnapOffsets == snapOffsets)
- return;
-
- m_snapOffsetsInfo.verticalSnapOffsets = snapOffsets;
- setPropertyChanged(Property::VerticalSnapOffsets);
-}
-
-void ScrollingStateScrollingNode::setHorizontalSnapOffsetRanges(const Vector<ScrollOffsetRange<float>>& scrollOffsetRanges)
-{
- if (m_snapOffsetsInfo.horizontalSnapOffsetRanges == scrollOffsetRanges)
- return;
-
- m_snapOffsetsInfo.horizontalSnapOffsetRanges = scrollOffsetRanges;
- setPropertyChanged(Property::HorizontalSnapOffsetRanges);
-}
-
-void ScrollingStateScrollingNode::setVerticalSnapOffsetRanges(const Vector<ScrollOffsetRange<float>>& scrollOffsetRanges)
-{
- if (m_snapOffsetsInfo.verticalSnapOffsetRanges == scrollOffsetRanges)
- return;
-
- m_snapOffsetsInfo.verticalSnapOffsetRanges = scrollOffsetRanges;
- setPropertyChanged(Property::VerticalSnapOffsetRanges);
-}
-
void ScrollingStateScrollingNode::setCurrentHorizontalSnapPointIndex(unsigned index)
{
if (m_currentHorizontalSnapPointIndex == index)
Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h (271936 => 271937)
--- trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h 2021-01-27 08:36:19 UTC (rev 271936)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h 2021-01-27 08:41:41 UTC (rev 271937)
@@ -71,18 +71,9 @@
WEBCORE_EXPORT void setScrollOrigin(const IntPoint&);
#if ENABLE(CSS_SCROLL_SNAP)
- const Vector<float>& horizontalSnapOffsets() const { return m_snapOffsetsInfo.horizontalSnapOffsets; }
- WEBCORE_EXPORT void setHorizontalSnapOffsets(const Vector<float>&);
+ const ScrollSnapOffsetsInfo<float>& snapOffsetsInfo() const { return m_snapOffsetsInfo; }
+ WEBCORE_EXPORT void setSnapOffsetsInfo(const ScrollSnapOffsetsInfo<float>& newOffsetsInfo);
- const Vector<float>& verticalSnapOffsets() const { return m_snapOffsetsInfo.verticalSnapOffsets; }
- WEBCORE_EXPORT void setVerticalSnapOffsets(const Vector<float>&);
-
- const Vector<ScrollOffsetRange<float>>& horizontalSnapOffsetRanges() const { return m_snapOffsetsInfo.horizontalSnapOffsetRanges; }
- WEBCORE_EXPORT void setHorizontalSnapOffsetRanges(const Vector<ScrollOffsetRange<float>>&);
-
- const Vector<ScrollOffsetRange<float>>& verticalSnapOffsetRanges() const { return m_snapOffsetsInfo.verticalSnapOffsetRanges; }
- WEBCORE_EXPORT void setVerticalSnapOffsetRanges(const Vector<ScrollOffsetRange<float>>&);
-
unsigned currentHorizontalSnapPointIndex() const { return m_currentHorizontalSnapPointIndex; }
WEBCORE_EXPORT void setCurrentHorizontalSnapPointIndex(unsigned);
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp (271936 => 271937)
--- trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp 2021-01-27 08:36:19 UTC (rev 271936)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp 2021-01-27 08:41:41 UTC (rev 271937)
@@ -75,18 +75,9 @@
m_scrollOrigin = state.scrollOrigin();
#if ENABLE(CSS_SCROLL_SNAP)
- if (state.hasChangedProperty(ScrollingStateNode::Property::HorizontalSnapOffsets))
- m_snapOffsetsInfo.horizontalSnapOffsets = state.horizontalSnapOffsets();
+ if (state.hasChangedProperty(ScrollingStateNode::Property::SnapOffsetsInfo))
+ m_snapOffsetsInfo = state.snapOffsetsInfo();
- if (state.hasChangedProperty(ScrollingStateNode::Property::VerticalSnapOffsets))
- m_snapOffsetsInfo.verticalSnapOffsets = state.verticalSnapOffsets();
-
- if (state.hasChangedProperty(ScrollingStateNode::Property::HorizontalSnapOffsetRanges))
- m_snapOffsetsInfo.horizontalSnapOffsetRanges = state.horizontalSnapOffsetRanges();
-
- if (state.hasChangedProperty(ScrollingStateNode::Property::VerticalSnapOffsetRanges))
- m_snapOffsetsInfo.verticalSnapOffsetRanges = state.verticalSnapOffsetRanges();
-
if (state.hasChangedProperty(ScrollingStateNode::Property::CurrentHorizontalSnapOffsetIndex))
m_currentHorizontalSnapPointIndex = state.currentHorizontalSnapPointIndex();
@@ -335,6 +326,13 @@
#endif
}
+#if ENABLE(CSS_SCROLL_SNAP)
+const ScrollSnapOffsetsInfo<float>& ScrollingTreeScrollingNode::snapOffsetsInfo() const
+{
+ return m_snapOffsetsInfo;
+}
+#endif
+
} // namespace WebCore
#endif // ENABLE(ASYNC_SCROLLING)
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h (271936 => 271937)
--- trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h 2021-01-27 08:36:19 UTC (rev 271936)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h 2021-01-27 08:41:41 UTC (rev 271937)
@@ -95,10 +95,7 @@
bool canHaveScrollbars() const { return m_scrollableAreaParameters.horizontalScrollbarMode != ScrollbarAlwaysOff || m_scrollableAreaParameters.verticalScrollbarMode != ScrollbarAlwaysOff; }
#if ENABLE(CSS_SCROLL_SNAP)
- const Vector<float>& horizontalSnapOffsets() const { return m_snapOffsetsInfo.horizontalSnapOffsets; }
- const Vector<float>& verticalSnapOffsets() const { return m_snapOffsetsInfo.verticalSnapOffsets; }
- const Vector<ScrollOffsetRange<float>>& horizontalSnapOffsetRanges() const { return m_snapOffsetsInfo.horizontalSnapOffsetRanges; }
- const Vector<ScrollOffsetRange<float>>& verticalSnapOffsetRanges() const { return m_snapOffsetsInfo.verticalSnapOffsetRanges; }
+ const ScrollSnapOffsetsInfo<float>& snapOffsetsInfo() const;
unsigned currentHorizontalSnapPointIndex() const { return m_currentHorizontalSnapPointIndex; }
unsigned currentVerticalSnapPointIndex() const { return m_currentVerticalSnapPointIndex; }
void setCurrentHorizontalSnapPointIndex(unsigned index) { m_currentHorizontalSnapPointIndex = index; }
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h (271936 => 271937)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h 2021-01-27 08:36:19 UTC (rev 271936)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h 2021-01-27 08:41:41 UTC (rev 271937)
@@ -55,8 +55,6 @@
void currentScrollPositionChanged();
#if ENABLE(CSS_SCROLL_SNAP)
- void updateScrollSnapPoints(ScrollEventAxis, const Vector<LayoutUnit>&, const Vector<ScrollOffsetRange<LayoutUnit>>&);
- void setActiveScrollSnapIndexForAxis(ScrollEventAxis, unsigned);
bool activeScrollSnapIndexDidChange() const;
unsigned activeScrollSnapIndexForAxis(ScrollEventAxis) const;
bool isScrollSnapInProgress() const;
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm (271936 => 271937)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm 2021-01-27 08:36:19 UTC (rev 271936)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm 2021-01-27 08:41:41 UTC (rev 271937)
@@ -55,28 +55,6 @@
m_scrollController.stopAllTimers();
}
-#if ENABLE(CSS_SCROLL_SNAP)
-static inline Vector<LayoutUnit> convertToLayoutUnits(const Vector<float>& snapOffsetsAsFloat)
-{
- Vector<LayoutUnit> snapOffsets;
- snapOffsets.reserveInitialCapacity(snapOffsetsAsFloat.size());
- for (auto offset : snapOffsetsAsFloat)
- snapOffsets.uncheckedAppend(offset);
-
- return snapOffsets;
-}
-
-static inline Vector<ScrollOffsetRange<LayoutUnit>> convertToLayoutUnits(const Vector<ScrollOffsetRange<float>>& snapOffsetRangesAsFloat)
-{
- Vector<ScrollOffsetRange<LayoutUnit>> snapOffsetRanges;
- snapOffsetRanges.reserveInitialCapacity(snapOffsetRangesAsFloat.size());
- for (auto range : snapOffsetRangesAsFloat)
- snapOffsetRanges.uncheckedAppend({ LayoutUnit(range.start), LayoutUnit(range.end) });
-
- return snapOffsetRanges;
-}
-#endif
-
void ScrollingTreeScrollingNodeDelegateMac::updateFromStateNode(const ScrollingStateScrollingNode& scrollingStateNode)
{
if (scrollingStateNode.hasChangedProperty(ScrollingStateNode::Property::PainterForScrollbar)) {
@@ -86,30 +64,17 @@
}
#if ENABLE(CSS_SCROLL_SNAP)
- if (scrollingStateNode.hasChangedProperty(ScrollingStateNode::Property::HorizontalSnapOffsets) || scrollingStateNode.hasChangedProperty(ScrollingStateNode::Property::HorizontalSnapOffsetRanges))
- updateScrollSnapPoints(ScrollEventAxis::Horizontal, convertToLayoutUnits(scrollingStateNode.horizontalSnapOffsets()), convertToLayoutUnits(scrollingStateNode.horizontalSnapOffsetRanges()));
+ if (scrollingStateNode.hasChangedProperty(ScrollingStateNode::Property::SnapOffsetsInfo))
+ m_scrollController.updateScrollSnapPoints(scrollingStateNode.snapOffsetsInfo().convertUnits<LayoutUnit>());
- if (scrollingStateNode.hasChangedProperty(ScrollingStateNode::Property::VerticalSnapOffsets) || scrollingStateNode.hasChangedProperty(ScrollingStateNode::Property::VerticalSnapOffsetRanges))
- updateScrollSnapPoints(ScrollEventAxis::Vertical, convertToLayoutUnits(scrollingStateNode.verticalSnapOffsets()), convertToLayoutUnits(scrollingStateNode.verticalSnapOffsetRanges()));
+ if (scrollingStateNode.hasChangedProperty(ScrollingStateNode::Property::CurrentHorizontalSnapOffsetIndex))
+ m_scrollController.setActiveScrollSnapIndexForAxis(ScrollEventAxis::Horizontal, scrollingStateNode.currentHorizontalSnapPointIndex());
- if (scrollingStateNode.hasChangedProperty(ScrollingStateNode::Property::CurrentHorizontalSnapOffsetIndex))
- setActiveScrollSnapIndexForAxis(ScrollEventAxis::Horizontal, scrollingStateNode.currentHorizontalSnapPointIndex());
-
if (scrollingStateNode.hasChangedProperty(ScrollingStateNode::Property::CurrentVerticalSnapOffsetIndex))
- setActiveScrollSnapIndexForAxis(ScrollEventAxis::Vertical, scrollingStateNode.currentVerticalSnapPointIndex());
+ m_scrollController.setActiveScrollSnapIndexForAxis(ScrollEventAxis::Vertical, scrollingStateNode.currentVerticalSnapPointIndex());
#endif
}
-void ScrollingTreeScrollingNodeDelegateMac::updateScrollSnapPoints(ScrollEventAxis axis, const Vector<LayoutUnit>& snapOffsets, const Vector<ScrollOffsetRange<LayoutUnit>>& snapRanges)
-{
- m_scrollController.updateScrollSnapPoints(axis, snapOffsets, snapRanges);
-}
-
-void ScrollingTreeScrollingNodeDelegateMac::setActiveScrollSnapIndexForAxis(ScrollEventAxis axis, unsigned index)
-{
- m_scrollController.setActiveScrollSnapIndexForAxis(axis, index);
-}
-
unsigned ScrollingTreeScrollingNodeDelegateMac::activeScrollSnapIndexForAxis(ScrollEventAxis axis) const
{
return m_scrollController.activeScrollSnapIndexForAxis(axis);
Modified: trunk/Source/WebCore/platform/cocoa/ScrollController.h (271936 => 271937)
--- trunk/Source/WebCore/platform/cocoa/ScrollController.h 2021-01-27 08:36:19 UTC (rev 271936)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.h 2021-01-27 08:41:41 UTC (rev 271937)
@@ -158,7 +158,7 @@
void scrollPositionChanged();
#if ENABLE(CSS_SCROLL_SNAP)
- void updateScrollSnapPoints(ScrollEventAxis, const Vector<LayoutUnit>&, const Vector<ScrollOffsetRange<LayoutUnit>>&);
+ void updateScrollSnapPoints(const ScrollSnapOffsetsInfo<LayoutUnit>&);
void setActiveScrollSnapIndexForAxis(ScrollEventAxis, unsigned);
void setActiveScrollSnapIndicesForOffset(ScrollOffset);
bool activeScrollSnapIndexDidChange() const { return m_activeScrollSnapIndexDidChange; }
Modified: trunk/Source/WebCore/platform/cocoa/ScrollController.mm (271936 => 271937)
--- trunk/Source/WebCore/platform/cocoa/ScrollController.mm 2021-01-27 08:36:19 UTC (rev 271936)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.mm 2021-01-27 08:41:41 UTC (rev 271937)
@@ -81,11 +81,6 @@
}
#endif
-static ScrollEventAxis otherScrollEventAxis(ScrollEventAxis axis)
-{
- return axis == ScrollEventAxis::Horizontal ? ScrollEventAxis::Vertical : ScrollEventAxis::Horizontal;
-}
-
ScrollController::ScrollController(ScrollControllerClient& client)
: m_client(client)
{
@@ -831,45 +826,33 @@
void ScrollController::updateScrollSnapState(const ScrollableArea& scrollableArea)
{
const auto* snapOffsetInfo = scrollableArea.snapOffsetInfo();
- if (!snapOffsetInfo || snapOffsetInfo->isEmpty()) {
+ if (!snapOffsetInfo) {
m_scrollSnapState = nullptr;
return;
}
+ updateScrollSnapPoints(*snapOffsetInfo);
+}
+
+void ScrollController::updateScrollSnapPoints(const ScrollSnapOffsetsInfo<LayoutUnit>& snapOffsetInfo)
+{
+ if (snapOffsetInfo.isEmpty()) {
+ m_scrollSnapState = nullptr;
+ return;
+ }
+
bool shouldComputeCurrentSnapIndices = !m_scrollSnapState;
if (!m_scrollSnapState)
m_scrollSnapState = makeUnique<ScrollSnapAnimatorState>();
- m_scrollSnapState->setSnapOffsetInfo(*snapOffsetInfo);
+ m_scrollSnapState->setSnapOffsetInfo(snapOffsetInfo);
if (shouldComputeCurrentSnapIndices)
setActiveScrollSnapIndicesForOffset(roundedIntPoint(m_client.scrollOffset()));
- LOG_WITH_STREAM(ScrollSnap, stream << "ScrollController " << this << " updateScrollSnapState for " << scrollableArea << " new state " << ValueOrNull(m_scrollSnapState.get()));
+ LOG_WITH_STREAM(ScrollSnap, stream << "ScrollController " << this << " updateScrollSnapState new state: " << ValueOrNull(m_scrollSnapState.get()));
}
-void ScrollController::updateScrollSnapPoints(ScrollEventAxis axis, const Vector<LayoutUnit>& snapPoints, const Vector<ScrollOffsetRange<LayoutUnit>>& snapRanges)
-{
- bool shouldComputeCurrentSnapIndices = false;
- if (!m_scrollSnapState) {
- if (snapPoints.isEmpty())
- return;
-
- m_scrollSnapState = makeUnique<ScrollSnapAnimatorState>();
- shouldComputeCurrentSnapIndices = true;
- }
-
- if (snapPoints.isEmpty() && m_scrollSnapState->snapOffsetsForAxis(otherScrollEventAxis(axis)).isEmpty())
- m_scrollSnapState = nullptr;
- else {
- m_scrollSnapState->setSnapOffsetsAndPositionRangesForAxis(axis, snapPoints, snapRanges);
- if (shouldComputeCurrentSnapIndices) {
- setActiveScrollSnapIndicesForOffset(roundedIntPoint(m_client.scrollOffset()));
- LOG_WITH_STREAM(ScrollSnap, stream << "ScrollController::updateScrollSnapPoints - computed initial snap indices: x " << m_scrollSnapState->activeSnapIndexForAxis(ScrollEventAxis::Horizontal) << ", y " << m_scrollSnapState->activeSnapIndexForAxis(ScrollEventAxis::Vertical));
- }
- }
-}
-
unsigned ScrollController::activeScrollSnapIndexForAxis(ScrollEventAxis axis) const
{
if (!usesScrollSnap())
Modified: trunk/Source/WebKit/ChangeLog (271936 => 271937)
--- trunk/Source/WebKit/ChangeLog 2021-01-27 08:36:19 UTC (rev 271936)
+++ trunk/Source/WebKit/ChangeLog 2021-01-27 08:41:41 UTC (rev 271937)
@@ -1,3 +1,28 @@
+2021-01-27 Martin Robinson <[email protected]>
+
+ Use ScrollSnapOffsetsInfo in the scrolling tree
+ https://bugs.webkit.org/show_bug.cgi?id=220915
+
+ Reviewed by Simon Fraser.
+
+ Use ScrollSnapOffsets more often in the scrolling tree to continue to
+ abstract away the details of how snap offsets are implemented.
+
+ * Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp:
+ (ArgumentCoder<ScrollingStateScrollingNode>::encode):
+ (ArgumentCoder<ScrollingStateScrollingNode>::decode):
+ (ArgumentCoder<ScrollSnapOffsetsInfo<float>>::encode):
+ (ArgumentCoder<ScrollSnapOffsetsInfo<float>>::decode):
+ (WebKit::dump):
+ * UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm:
+ (WebKit::RemoteScrollingCoordinatorProxy::shouldSnapForMainFrameScrolling const):
+ (WebKit::RemoteScrollingCoordinatorProxy::closestSnapOffsetForMainFrameScrolling const):
+ (WebKit::RemoteScrollingCoordinatorProxy::hasActiveSnapPoint const):
+ (WebKit::RemoteScrollingCoordinatorProxy::nearestActiveContentInsetAdjustedSnapOffset const):
+ * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm:
+ (-[WKScrollingNodeScrollViewDelegate scrollViewWillEndDragging:withVelocity:targetContentOffset:]):
+ (WebKit::ScrollingTreeScrollingNodeDelegateIOS::commitStateAfterChildren):
+
2021-01-26 Sihui Liu <[email protected]>
Mute audio capture for speech recognition based on shouldInterruptAudioOnPageVisibilityChange when page is invisible
Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp (271936 => 271937)
--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp 2021-01-27 08:36:19 UTC (rev 271936)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp 2021-01-27 08:41:41 UTC (rev 271937)
@@ -98,6 +98,11 @@
static WARN_UNUSED_RETURN bool decode(Decoder&, RequestedScrollData&);
};
+template<> struct ArgumentCoder<ScrollSnapOffsetsInfo<float>> {
+ static void encode(Encoder&, const ScrollSnapOffsetsInfo<float>&);
+ static WARN_UNUSED_RETURN bool decode(Decoder&, ScrollSnapOffsetsInfo<float>&);
+};
+
} // namespace IPC
namespace WTF {
@@ -115,10 +120,7 @@
WebCore::ScrollingStateNode::Property::ScrollableAreaParams,
WebCore::ScrollingStateNode::Property::ReasonsForSynchronousScrolling,
WebCore::ScrollingStateNode::Property::RequestedScrollPosition,
- WebCore::ScrollingStateNode::Property::HorizontalSnapOffsets,
- WebCore::ScrollingStateNode::Property::VerticalSnapOffsets,
- WebCore::ScrollingStateNode::Property::HorizontalSnapOffsetRanges,
- WebCore::ScrollingStateNode::Property::VerticalSnapOffsetRanges,
+ WebCore::ScrollingStateNode::Property::SnapOffsetsInfo,
WebCore::ScrollingStateNode::Property::CurrentHorizontalSnapOffsetIndex,
WebCore::ScrollingStateNode::Property::CurrentVerticalSnapOffsetIndex,
WebCore::ScrollingStateNode::Property::IsMonitoringWheelEvents,
@@ -206,10 +208,7 @@
SCROLLING_NODE_ENCODE(ScrollingStateNode::Property::ScrollPosition, scrollPosition)
SCROLLING_NODE_ENCODE(ScrollingStateNode::Property::ScrollOrigin, scrollOrigin)
#if ENABLE(CSS_SCROLL_SNAP)
- SCROLLING_NODE_ENCODE(ScrollingStateNode::Property::HorizontalSnapOffsets, horizontalSnapOffsets)
- SCROLLING_NODE_ENCODE(ScrollingStateNode::Property::VerticalSnapOffsets, verticalSnapOffsets)
- SCROLLING_NODE_ENCODE(ScrollingStateNode::Property::HorizontalSnapOffsetRanges, horizontalSnapOffsetRanges)
- SCROLLING_NODE_ENCODE(ScrollingStateNode::Property::VerticalSnapOffsetRanges, verticalSnapOffsetRanges)
+ SCROLLING_NODE_ENCODE(ScrollingStateNode::Property::SnapOffsetsInfo, snapOffsetsInfo)
SCROLLING_NODE_ENCODE(ScrollingStateNode::Property::CurrentHorizontalSnapOffsetIndex, currentHorizontalSnapPointIndex)
SCROLLING_NODE_ENCODE(ScrollingStateNode::Property::CurrentVerticalSnapOffsetIndex, currentVerticalSnapPointIndex)
#endif
@@ -306,10 +305,7 @@
SCROLLING_NODE_DECODE(ScrollingStateNode::Property::ScrollPosition, FloatPoint, setScrollPosition);
SCROLLING_NODE_DECODE(ScrollingStateNode::Property::ScrollOrigin, IntPoint, setScrollOrigin);
#if ENABLE(CSS_SCROLL_SNAP)
- SCROLLING_NODE_DECODE(ScrollingStateNode::Property::HorizontalSnapOffsets, Vector<float>, setHorizontalSnapOffsets);
- SCROLLING_NODE_DECODE(ScrollingStateNode::Property::VerticalSnapOffsets, Vector<float>, setVerticalSnapOffsets);
- SCROLLING_NODE_DECODE(ScrollingStateNode::Property::HorizontalSnapOffsetRanges, Vector<ScrollOffsetRange<float>>, setHorizontalSnapOffsetRanges)
- SCROLLING_NODE_DECODE(ScrollingStateNode::Property::VerticalSnapOffsetRanges, Vector<ScrollOffsetRange<float>>, setVerticalSnapOffsetRanges)
+ SCROLLING_NODE_DECODE(ScrollingStateNode::Property::SnapOffsetsInfo, ScrollSnapOffsetsInfo<float>, setSnapOffsetsInfo);
SCROLLING_NODE_DECODE(ScrollingStateNode::Property::CurrentHorizontalSnapOffsetIndex, unsigned, setCurrentHorizontalSnapPointIndex);
SCROLLING_NODE_DECODE(ScrollingStateNode::Property::CurrentVerticalSnapOffsetIndex, unsigned, setCurrentVerticalSnapPointIndex);
#endif
@@ -526,6 +522,27 @@
return true;
}
+void ArgumentCoder<ScrollSnapOffsetsInfo<float>>::encode(Encoder& encoder, const ScrollSnapOffsetsInfo<float>& info)
+{
+ encoder << info.horizontalSnapOffsets;
+ encoder << info.verticalSnapOffsets;
+ encoder << info.horizontalSnapOffsetRanges;
+ encoder << info.verticalSnapOffsetRanges;
+}
+
+bool ArgumentCoder<ScrollSnapOffsetsInfo<float>>::decode(Decoder& decoder, ScrollSnapOffsetsInfo<float>& info)
+{
+ if (!decoder.decode(info.horizontalSnapOffsets))
+ return false;
+ if (!decoder.decode(info.verticalSnapOffsets))
+ return false;
+ if (!decoder.decode(info.horizontalSnapOffsetRanges))
+ return false;
+ if (!decoder.decode(info.verticalSnapOffsetRanges))
+ return false;
+ return true;
+}
+
namespace WebKit {
static void encodeNodeAndDescendants(IPC::Encoder& encoder, const ScrollingStateNode& stateNode, int& encodedNodeCount)
@@ -696,17 +713,12 @@
ts.dumpProperty("scrolled-contents-layer", static_cast<GraphicsLayer::PlatformLayerID>(node.scrolledContentsLayer()));
#if ENABLE(CSS_SCROLL_SNAP)
- if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateNode::Property::HorizontalSnapOffsets))
- ts.dumpProperty("horizontal snap offsets", node.horizontalSnapOffsets());
-
- if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateNode::Property::VerticalSnapOffsets))
- ts.dumpProperty("vertical snap offsets", node.verticalSnapOffsets());
-
- if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateNode::Property::CurrentHorizontalSnapOffsetIndex))
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateNode::Property::SnapOffsetsInfo)) {
+ ts.dumpProperty("horizontal snap offsets", node.snapOffsetsInfo().horizontalSnapOffsets);
+ ts.dumpProperty("vertical snap offsets", node.snapOffsetsInfo().verticalSnapOffsets);
ts.dumpProperty("current horizontal snap point index", node.currentHorizontalSnapPointIndex());
-
- if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateNode::Property::CurrentVerticalSnapOffsetIndex))
ts.dumpProperty("current vertical snap point index", node.currentVerticalSnapPointIndex());
+ }
#endif
}
Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm (271936 => 271937)
--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm 2021-01-27 08:36:19 UTC (rev 271936)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm 2021-01-27 08:41:41 UTC (rev 271937)
@@ -213,7 +213,7 @@
ScrollingTreeNode* root = m_scrollingTree->rootNode();
if (root && root->isFrameScrollingNode()) {
ScrollingTreeFrameScrollingNode* rootScrollingNode = static_cast<ScrollingTreeFrameScrollingNode*>(root);
- const Vector<float>& snapOffsets = axis == ScrollEventAxis::Horizontal ? rootScrollingNode->horizontalSnapOffsets() : rootScrollingNode->verticalSnapOffsets();
+ const Vector<float>& snapOffsets = rootScrollingNode->snapOffsetsInfo().offsetsForAxis(axis);
unsigned currentIndex = axis == ScrollEventAxis::Horizontal ? m_currentHorizontalSnapPointIndex : m_currentVerticalSnapPointIndex;
return snapOffsets.size() && (currentIndex < snapOffsets.size() || currentIndex == invalidSnapOffsetIndex);
}
@@ -225,8 +225,8 @@
ScrollingTreeNode* root = m_scrollingTree->rootNode();
ASSERT(root && root->isFrameScrollingNode());
ScrollingTreeFrameScrollingNode* rootScrollingNode = static_cast<ScrollingTreeFrameScrollingNode*>(root);
- const Vector<float>& snapOffsets = axis == ScrollEventAxis::Horizontal ? rootScrollingNode->horizontalSnapOffsets() : rootScrollingNode->verticalSnapOffsets();
- const Vector<ScrollOffsetRange<float>>& snapOffsetRanges = axis == ScrollEventAxis::Horizontal ? rootScrollingNode->horizontalSnapOffsetRanges() : rootScrollingNode->verticalSnapOffsetRanges();
+ const Vector<float>& snapOffsets = rootScrollingNode->snapOffsetsInfo().offsetsForAxis(axis);
+ const Vector<ScrollOffsetRange<float>>& snapOffsetRanges = rootScrollingNode->snapOffsetsInfo().offsetRangesForAxis(axis);
float scaledScrollDestination = scrollDestination / m_webPageProxy.displayedContentScale();
float rawClosestSnapOffset = closestSnapOffset(snapOffsets, snapOffsetRanges, scaledScrollDestination, velocity, currentIndex);
@@ -243,8 +243,8 @@
return false;
ScrollingTreeFrameScrollingNode& rootScrollingNode = downcast<ScrollingTreeFrameScrollingNode>(*root);
- const Vector<float>& horizontal = rootScrollingNode.horizontalSnapOffsets();
- const Vector<float>& vertical = rootScrollingNode.verticalSnapOffsets();
+ const Vector<float>& horizontal = rootScrollingNode.snapOffsetsInfo().horizontalSnapOffsets;
+ const Vector<float>& vertical = rootScrollingNode.snapOffsetsInfo().verticalSnapOffsets;
if (horizontal.isEmpty() && vertical.isEmpty())
return false;
@@ -264,8 +264,8 @@
ScrollingTreeNode* root = m_scrollingTree->rootNode();
ASSERT(root && is<ScrollingTreeFrameScrollingNode>(root));
ScrollingTreeFrameScrollingNode& rootScrollingNode = downcast<ScrollingTreeFrameScrollingNode>(*root);
- const Vector<float>& horizontal = rootScrollingNode.horizontalSnapOffsets();
- const Vector<float>& vertical = rootScrollingNode.verticalSnapOffsets();
+ const Vector<float>& horizontal = rootScrollingNode.snapOffsetsInfo().horizontalSnapOffsets;
+ const Vector<float>& vertical = rootScrollingNode.snapOffsetsInfo().verticalSnapOffsets;
// The bounds checking with maxScrollOffsets is to ensure that we won't interfere with rubber-banding when scrolling to the edge of the page.
if (!horizontal.isEmpty() && m_currentHorizontalSnapPointIndex < horizontal.size())
Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm (271936 => 271937)
--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm 2021-01-27 08:36:19 UTC (rev 271936)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm 2021-01-27 08:41:41 UTC (rev 271937)
@@ -106,17 +106,19 @@
unsigned originalHorizontalSnapPosition = _scrollingTreeNodeDelegate->scrollingNode().currentHorizontalSnapPointIndex();
unsigned originalVerticalSnapPosition = _scrollingTreeNodeDelegate->scrollingNode().currentVerticalSnapPointIndex();
- if (!_scrollingTreeNodeDelegate->scrollingNode().horizontalSnapOffsets().isEmpty()) {
+ const auto& horizontal = _scrollingTreeNodeDelegate->scrollingNode().snapOffsetsInfo().horizontalSnapOffsets;
+ if (!horizontal.isEmpty()) {
unsigned index;
- float potentialSnapPosition = WebCore::closestSnapOffset(_scrollingTreeNodeDelegate->scrollingNode().horizontalSnapOffsets(), _scrollingTreeNodeDelegate->scrollingNode().horizontalSnapOffsetRanges(), horizontalTarget, velocity.x, index);
+ float potentialSnapPosition = WebCore::closestSnapOffset(horizontal, _scrollingTreeNodeDelegate->scrollingNode().snapOffsetsInfo().horizontalSnapOffsetRanges, horizontalTarget, velocity.x, index);
_scrollingTreeNodeDelegate->scrollingNode().setCurrentHorizontalSnapPointIndex(index);
if (horizontalTarget >= 0 && horizontalTarget <= scrollView.contentSize.width)
targetContentOffset->x = potentialSnapPosition;
}
- if (!_scrollingTreeNodeDelegate->scrollingNode().verticalSnapOffsets().isEmpty()) {
+ const auto& vertical = _scrollingTreeNodeDelegate->scrollingNode().snapOffsetsInfo().verticalSnapOffsets;
+ if (!vertical.isEmpty()) {
unsigned index;
- float potentialSnapPosition = WebCore::closestSnapOffset(_scrollingTreeNodeDelegate->scrollingNode().verticalSnapOffsets(), _scrollingTreeNodeDelegate->scrollingNode().verticalSnapOffsetRanges(), verticalTarget, velocity.y, index);
+ float potentialSnapPosition = WebCore::closestSnapOffset(vertical, _scrollingTreeNodeDelegate->scrollingNode().snapOffsetsInfo().verticalSnapOffsetRanges, verticalTarget, velocity.y, index);
_scrollingTreeNodeDelegate->scrollingNode().setCurrentVerticalSnapPointIndex(index);
if (verticalTarget >= 0 && verticalTarget <= scrollView.contentSize.height)
targetContentOffset->y = potentialSnapPosition;
@@ -280,9 +282,9 @@
#if ENABLE(CSS_SCROLL_SNAP)
// FIXME: If only one axis snaps in 2D scrolling, the other axis will decelerate fast as well. Is this what we want?
- if (scrollingStateNode.hasChangedProperty(ScrollingStateNode::Property::HorizontalSnapOffsets) || scrollingStateNode.hasChangedProperty(ScrollingStateNode::Property::VerticalSnapOffsets)) {
+ if (scrollingStateNode.hasChangedProperty(ScrollingStateNode::Property::SnapOffsetsInfo)) {
BEGIN_BLOCK_OBJC_EXCEPTIONS
- scrollView().decelerationRate = scrollingNode().horizontalSnapOffsets().size() || scrollingNode().verticalSnapOffsets().size() ? UIScrollViewDecelerationRateFast : UIScrollViewDecelerationRateNormal;
+ scrollView().decelerationRate = scrollingNode().snapOffsetsInfo().horizontalSnapOffsets.size() || scrollingNode().snapOffsetsInfo().verticalSnapOffsets.size() ? UIScrollViewDecelerationRateFast : UIScrollViewDecelerationRateNormal;
END_BLOCK_OBJC_EXCEPTIONS
}
#endif