Diff
Modified: trunk/Source/WebCore/ChangeLog (286114 => 286115)
--- trunk/Source/WebCore/ChangeLog 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/ChangeLog 2021-11-22 20:01:09 UTC (rev 286115)
@@ -1,3 +1,65 @@
+2021-11-20 Simon Fraser <[email protected]>
+
+ Clarify the behavior of ScrollAnimator::scroll()
+ https://bugs.webkit.org/show_bug.cgi?id=233403
+
+ Reviewed by Sam Weinig.
+
+ ScrollAnimator::scroll() was hard to reason about. It used ScrollbarOrientation but didn't
+ do anything with scrollbars. It took ScrollGranularity, "step" and "multiplier" and it
+ wasn't clear whether step had already accounted for ScrollGranularity, and whether
+ multiplier was anything other than 1 or -1. One of the behaviors was DoDirectionalSnapping
+ but it wasn't clear if the "directional" or "snapping" part of that was important. It also
+ called itself.
+
+ Bring clarity by using 'unsigned stepCount' in all the callers, using ScrollEventAxis
+ instead of ScrollbarOrientation, and having a single "delta" argument. It no longer
+ calls itself, instead just continuing from the snapping branch.
+
+ Add some helpers that ease interactions with FloatPoint/FloatSize and ScrollEventAxis.
+
+ * dom/Element.cpp:
+ (WebCore::Element::scrollByUnits):
+ * dom/Element.h:
+ * page/FrameView.cpp:
+ (WebCore::FrameView::adjustScrollStepForFixedContent):
+ * page/FrameView.h:
+ * platform/ScrollAnimator.cpp:
+ (WebCore::ScrollAnimator::scroll):
+ (WebCore::ScrollAnimator::deltaFromStep):
+ (WebCore::ScrollAnimator::handleWheelEvent):
+ * platform/ScrollAnimator.h:
+ * platform/ScrollSnapAnimatorState.cpp:
+ (WebCore::ScrollSnapAnimatorState::adjustedScrollDestination const):
+ * platform/ScrollTypes.h:
+ (WebCore::axisFromDirection):
+ (WebCore::valueForAxis):
+ (WebCore::setValueForAxis):
+ * platform/ScrollableArea.cpp:
+ (WebCore::ScrollableArea::adjustScrollStepForFixedContent):
+ (WebCore::ScrollableArea::scroll):
+ * platform/ScrollableArea.h:
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::scrollLayer):
+ (WebCore::RenderBox::scroll):
+ (WebCore::RenderBox::logicalScroll):
+ * rendering/RenderBox.h:
+ * rendering/RenderEmbeddedObject.cpp:
+ (WebCore::RenderEmbeddedObject::scroll):
+ (WebCore::RenderEmbeddedObject::logicalScroll):
+ * rendering/RenderEmbeddedObject.h:
+ * rendering/RenderLayerScrollableArea.cpp:
+ (WebCore::RenderLayerScrollableArea::scroll):
+ * rendering/RenderLayerScrollableArea.h:
+ * rendering/RenderListBox.cpp:
+ (WebCore::RenderListBox::scroll):
+ (WebCore::RenderListBox::logicalScroll):
+ * rendering/RenderListBox.h:
+ * rendering/RenderTextControlSingleLine.cpp:
+ (WebCore::RenderTextControlSingleLine::scroll):
+ (WebCore::RenderTextControlSingleLine::logicalScroll):
+ * rendering/RenderTextControlSingleLine.h:
+
2021-11-22 Antti Koivisto <[email protected]>
[LFC][Integration] Remove dirOverride
Modified: trunk/Source/WebCore/dom/Element.cpp (286114 => 286115)
--- trunk/Source/WebCore/dom/Element.cpp 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/dom/Element.cpp 2021-11-22 20:01:09 UTC (rev 286115)
@@ -1119,12 +1119,11 @@
return;
ScrollDirection direction = ScrollDown;
- if (units < 0) {
+ if (units < 0)
direction = ScrollUp;
- units = -units;
- }
- Element* stopElement = this;
- downcast<RenderBox>(*renderer).scroll(direction, granularity, units, &stopElement);
+
+ auto* stopElement = this;
+ downcast<RenderBox>(*renderer).scroll(direction, granularity, std::abs(units), &stopElement);
}
void Element::scrollByLines(int lines)
Modified: trunk/Source/WebCore/dom/Element.h (286114 => 286115)
--- trunk/Source/WebCore/dom/Element.h 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/dom/Element.h 2021-11-22 20:01:09 UTC (rev 286115)
@@ -175,6 +175,7 @@
virtual void scrollTo(const ScrollToOptions&, ScrollClamping = ScrollClamping::Clamped, ScrollSnapPointSelectionMethod = ScrollSnapPointSelectionMethod::Closest);
void scrollTo(double x, double y);
+ // These are only used by WebKitLegacy DOM API.
WEBCORE_EXPORT void scrollByLines(int lines);
WEBCORE_EXPORT void scrollByPages(int pages);
Modified: trunk/Source/WebCore/page/EventHandler.cpp (286114 => 286115)
--- trunk/Source/WebCore/page/EventHandler.cpp 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2021-11-22 20:01:09 UTC (rev 286115)
@@ -4300,11 +4300,7 @@
float EventHandler::scrollDistance(ScrollDirection direction, ScrollGranularity granularity)
{
- auto scrollbar = [&] {
- if (direction == ScrollDirection::ScrollUp || direction == ScrollDirection::ScrollDown)
- return m_frame.view()->verticalScrollbar();
- return m_frame.view()->horizontalScrollbar();
- }();
+ auto scrollbar = m_frame.view()->scrollbarForDirection(direction);
switch (granularity) {
case ScrollGranularity::Line:
Modified: trunk/Source/WebCore/page/FrameView.cpp (286114 => 286115)
--- trunk/Source/WebCore/page/FrameView.cpp 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/page/FrameView.cpp 2021-11-22 20:01:09 UTC (rev 286115)
@@ -3834,9 +3834,9 @@
setCurrentScrollType(previousScrollType);
}
-float FrameView::adjustScrollStepForFixedContent(float step, ScrollbarOrientation orientation, ScrollGranularity granularity)
+float FrameView::adjustScrollStepForFixedContent(float step, ScrollEventAxis axis, ScrollGranularity granularity)
{
- if (granularity != ScrollGranularity::Page || orientation == ScrollbarOrientation::Horizontal)
+ if (granularity != ScrollGranularity::Page || axis == ScrollEventAxis::Horizontal)
return step;
TrackedRendererListHashSet* positionedObjects = nullptr;
Modified: trunk/Source/WebCore/page/FrameView.h (286114 => 286115)
--- trunk/Source/WebCore/page/FrameView.h 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/page/FrameView.h 2021-11-22 20:01:09 UTC (rev 286115)
@@ -661,7 +661,7 @@
bool isScrollSnapInProgress() const final;
void updateScrollingCoordinatorScrollSnapProperties() const;
- float adjustScrollStepForFixedContent(float step, ScrollbarOrientation, ScrollGranularity) final;
+ float adjustScrollStepForFixedContent(float step, ScrollEventAxis, ScrollGranularity) final;
void didChangeScrollOffset();
Modified: trunk/Source/WebCore/platform/KeyboardScrollingAnimator.cpp (286114 => 286115)
--- trunk/Source/WebCore/platform/KeyboardScrollingAnimator.cpp 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/platform/KeyboardScrollingAnimator.cpp 2021-11-22 20:01:09 UTC (rev 286115)
@@ -147,12 +147,7 @@
float KeyboardScrollingAnimator::scrollDistance(ScrollDirection direction, ScrollGranularity granularity) const
{
- auto scrollbar = [&] {
- if (direction == ScrollDirection::ScrollUp || direction == ScrollDirection::ScrollDown)
- return m_scrollAnimator.scrollableArea().verticalScrollbar();
- return m_scrollAnimator.scrollableArea().horizontalScrollbar();
- }();
-
+ auto scrollbar = m_scrollAnimator.scrollableArea().scrollbarForDirection(direction);
if (scrollbar) {
switch (granularity) {
case ScrollGranularity::Line:
Modified: trunk/Source/WebCore/platform/ScrollAnimator.cpp (286114 => 286115)
--- trunk/Source/WebCore/platform/ScrollAnimator.cpp 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/platform/ScrollAnimator.cpp 2021-11-22 20:01:09 UTC (rev 286115)
@@ -63,28 +63,22 @@
m_scrollController.stopAllTimers();
}
-bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier, OptionSet<ScrollBehavior> behavior)
+bool ScrollAnimator::singleAxisScroll(ScrollEventAxis axis, float scrollDelta, OptionSet<ScrollBehavior> behavior)
{
m_scrollableArea.scrollbarsController().setScrollbarAnimationsUnsuspendedByUserInteraction(true);
- auto delta = deltaFromStep(orientation, step, multiplier);
- if (behavior.contains(ScrollBehavior::DoDirectionalSnapping)) {
- behavior.remove(ScrollBehavior::DoDirectionalSnapping);
- if (!m_scrollController.usesScrollSnap())
- return ScrollAnimator::scroll(orientation, granularity, step, multiplier, behavior);
+ auto delta = setValueForAxis(FloatSize { }, axis, scrollDelta);
- auto currentOffset = offsetFromPosition(currentPosition());
- auto newOffset = currentOffset + delta;
- if (orientation == ScrollbarOrientation::Horizontal)
- newOffset.setX(m_scrollController.adjustedScrollDestination(ScrollEventAxis::Horizontal, newOffset, multiplier, currentOffset.x()));
- else
- newOffset.setY(m_scrollController.adjustedScrollDestination(ScrollEventAxis::Vertical, newOffset, multiplier, currentOffset.y()));
-
- auto newDelta = newOffset - currentOffset;
- if (orientation == ScrollbarOrientation::Horizontal)
- return scroll(ScrollbarOrientation::Horizontal, granularity, newDelta.width(), 1.0, behavior);
-
- return scroll(ScrollbarOrientation::Vertical, granularity, newDelta.height(), 1.0, behavior);
+ if (behavior.contains(ScrollBehavior::RespectScrollSnap)) {
+ behavior.remove(ScrollBehavior::RespectScrollSnap);
+ if (m_scrollController.usesScrollSnap()) {
+ auto currentOffset = offsetFromPosition(currentPosition());
+ auto newOffset = currentOffset + delta;
+ auto velocity = copysignf(1.0f, scrollDelta);
+ auto newOffsetOnAxis = m_scrollController.adjustedScrollDestination(axis, newOffset, velocity, valueForAxis(currentOffset, axis));
+ newOffset = setValueForAxis(newOffset, axis, newOffsetOnAxis);
+ delta = newOffset - currentOffset;
+ }
}
if (m_scrollableArea.scrollAnimatorEnabled() && platformAllowsScrollAnimation() && !behavior.contains(ScrollBehavior::NeverAnimate)) {
@@ -141,16 +135,6 @@
return ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(m_scrollableArea.scrollOrigin()));
}
-FloatSize ScrollAnimator::deltaFromStep(ScrollbarOrientation orientation, float step, float multiplier)
-{
- FloatSize delta;
- if (orientation == ScrollbarOrientation::Horizontal)
- delta.setWidth(step * multiplier);
- else
- delta.setHeight(step * multiplier);
- return delta;
-}
-
bool ScrollAnimator::activeScrollSnapIndexDidChange() const
{
return m_scrollController.activeScrollSnapIndexDidChange();
@@ -206,28 +190,24 @@
|| (deltaY > 0 && maxBackwardScrollDelta.height() > 0)) {
handled = true;
- OptionSet<ScrollBehavior> behavior(ScrollBehavior::DoDirectionalSnapping);
+ OptionSet<ScrollBehavior> behavior = { ScrollBehavior::RespectScrollSnap };
if (e.hasPreciseScrollingDeltas())
behavior.add(ScrollBehavior::NeverAnimate);
if (deltaY) {
- if (e.granularity() == ScrollByPageWheelEvent) {
- bool negative = deltaY < 0;
- deltaY = Scrollbar::pageStepDelta(m_scrollableArea.visibleHeight());
- if (negative)
- deltaY = -deltaY;
- }
- scroll(ScrollbarOrientation::Vertical, ScrollGranularity::Pixel, verticalScrollbar->pixelStep(), -deltaY, behavior);
+ if (e.granularity() == ScrollByPageWheelEvent)
+ deltaY = std::copysign(Scrollbar::pageStepDelta(m_scrollableArea.visibleHeight()), deltaY);
+
+ auto scrollDelta = verticalScrollbar->pixelStep() * -deltaY; // Wheel deltas are reversed from scrolling direction.
+ singleAxisScroll(ScrollEventAxis::Vertical, scrollDelta, behavior);
}
if (deltaX) {
- if (e.granularity() == ScrollByPageWheelEvent) {
- bool negative = deltaX < 0;
- deltaX = Scrollbar::pageStepDelta(m_scrollableArea.visibleWidth());
- if (negative)
- deltaX = -deltaX;
- }
- scroll(ScrollbarOrientation::Horizontal, ScrollGranularity::Pixel, horizontalScrollbar->pixelStep(), -deltaX, behavior);
+ if (e.granularity() == ScrollByPageWheelEvent)
+ deltaX = std::copysign(Scrollbar::pageStepDelta(m_scrollableArea.visibleWidth()), deltaX);
+
+ auto scrollDelta = horizontalScrollbar->pixelStep() * -deltaX; // Wheel deltas are reversed from scrolling direction.
+ singleAxisScroll(ScrollEventAxis::Horizontal, scrollDelta, behavior);
}
}
return handled;
Modified: trunk/Source/WebCore/platform/ScrollAnimator.h (286114 => 286115)
--- trunk/Source/WebCore/platform/ScrollAnimator.h 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/platform/ScrollAnimator.h 2021-11-22 20:01:09 UTC (rev 286115)
@@ -66,15 +66,15 @@
KeyboardScrollingAnimator *keyboardScrollingAnimator() const final { return m_keyboardScrollingAnimator.get(); }
enum ScrollBehavior {
- DoDirectionalSnapping = 1 << 0,
- NeverAnimate = 1 << 1,
+ RespectScrollSnap = 1 << 0,
+ NeverAnimate = 1 << 1,
};
// Computes a scroll destination for the given parameters. Returns false if
- // already at the destination. Otherwise, starts scrolling towards the
- // destination and returns true. Scrolling may be immediate or animated.
+ // already at the destination. Otherwise, starts scrolling towards the
+ // destination and returns true. Scrolling may be immediate or animated.
// The base class implementation always scrolls immediately, never animates.
- bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier, OptionSet<ScrollBehavior>);
+ bool singleAxisScroll(ScrollEventAxis, float delta, OptionSet<ScrollBehavior>);
virtual bool scrollToPositionWithoutAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped);
bool scrollToPositionWithAnimation(const FloatPoint&);
@@ -171,8 +171,6 @@
bool scrollAnimationEnabled() const final;
#endif
- static FloatSize deltaFromStep(ScrollbarOrientation, float step, float multiplier);
-
protected:
ScrollableArea& m_scrollableArea;
RefPtr<WheelEventTestMonitor> m_wheelEventTestMonitor;
Modified: trunk/Source/WebCore/platform/ScrollSnapAnimatorState.cpp (286114 => 286115)
--- trunk/Source/WebCore/platform/ScrollSnapAnimatorState.cpp 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/platform/ScrollSnapAnimatorState.cpp 2021-11-22 20:01:09 UTC (rev 286115)
@@ -83,7 +83,7 @@
{
auto snapOffsets = snapOffsetsForAxis(axis);
if (!snapOffsets.size())
- return axis == ScrollEventAxis::Horizontal ? destinationOffset.x() : destinationOffset.y();
+ return valueForAxis(destinationOffset, axis);
std::optional<LayoutUnit> originalOffsetInLayoutUnits;
if (originalOffset)
Modified: trunk/Source/WebCore/platform/ScrollTypes.h (286114 => 286115)
--- trunk/Source/WebCore/platform/ScrollTypes.h 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/platform/ScrollTypes.h 2021-11-22 20:01:09 UTC (rev 286115)
@@ -25,6 +25,8 @@
#pragma once
+#include "FloatPoint.h"
+#include "FloatSize.h"
#include <wtf/EnumTraits.h>
namespace WTF {
@@ -169,6 +171,60 @@
Vertical
};
+inline constexpr ScrollEventAxis axisFromDirection(ScrollDirection direction)
+{
+ switch (direction) {
+ case ScrollUp: return ScrollEventAxis::Vertical;
+ case ScrollDown: return ScrollEventAxis::Vertical;
+ case ScrollLeft: return ScrollEventAxis::Horizontal;
+ case ScrollRight: return ScrollEventAxis::Horizontal;
+ }
+ return ScrollEventAxis::Vertical;
+}
+
+inline float valueForAxis(FloatSize size, ScrollEventAxis axis)
+{
+ switch (axis) {
+ case ScrollEventAxis::Horizontal: return size.width();
+ case ScrollEventAxis::Vertical: return size.height();
+ }
+ return 0;
+}
+
+inline FloatSize setValueForAxis(FloatSize size, ScrollEventAxis axis, float value)
+{
+ switch (axis) {
+ case ScrollEventAxis::Horizontal:
+ size.setWidth(value);
+ return size;
+ case ScrollEventAxis::Vertical:
+ size.setHeight(value);
+ return size;
+ }
+ return size;
+}
+
+inline float valueForAxis(FloatPoint point, ScrollEventAxis axis)
+{
+ switch (axis) {
+ case ScrollEventAxis::Horizontal: return point.x();
+ case ScrollEventAxis::Vertical: return point.y();
+ }
+ return 0;
+}
+
+inline FloatPoint setValueForAxis(FloatPoint point, ScrollEventAxis axis, float value)
+{
+ switch (axis) {
+ case ScrollEventAxis::Horizontal:
+ point.setX(value);
+ return point;
+ case ScrollEventAxis::Vertical: point.setY(value);
+ return point;
+ }
+ return point;
+}
+
enum ScrollbarControlStateMask {
ActiveScrollbarState = 1,
EnabledScrollbarState = 1 << 1,
Modified: trunk/Source/WebCore/platform/ScrollableArea.cpp (286114 => 286115)
--- trunk/Source/WebCore/platform/ScrollableArea.cpp 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/platform/ScrollableArea.cpp 2021-11-22 20:01:09 UTC (rev 286115)
@@ -91,23 +91,14 @@
}
}
-float ScrollableArea::adjustScrollStepForFixedContent(float step, ScrollbarOrientation, ScrollGranularity)
+float ScrollableArea::adjustScrollStepForFixedContent(float step, ScrollEventAxis, ScrollGranularity)
{
return step;
}
-bool ScrollableArea::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier)
+bool ScrollableArea::scroll(ScrollDirection direction, ScrollGranularity granularity, unsigned stepCount)
{
- ScrollbarOrientation orientation;
- Scrollbar* scrollbar;
- if (direction == ScrollUp || direction == ScrollDown) {
- orientation = ScrollbarOrientation::Vertical;
- scrollbar = verticalScrollbar();
- } else {
- orientation = ScrollbarOrientation::Horizontal;
- scrollbar = horizontalScrollbar();
- }
-
+ auto* scrollbar = scrollbarForDirection(direction);
if (!scrollbar)
return false;
@@ -127,11 +118,14 @@
break;
}
+ auto axis = axisFromDirection(direction);
+ step = adjustScrollStepForFixedContent(step, axis, granularity);
+ auto scrollDelta = step * stepCount;
+
if (direction == ScrollUp || direction == ScrollLeft)
- multiplier = -multiplier;
+ scrollDelta = -scrollDelta;
- step = adjustScrollStepForFixedContent(step, orientation, granularity);
- return scrollAnimator().scroll(orientation, granularity, step, multiplier, ScrollAnimator::ScrollBehavior::DoDirectionalSnapping);
+ return scrollAnimator().singleAxisScroll(axis, scrollDelta, ScrollAnimator::ScrollBehavior::RespectScrollSnap);
}
void ScrollableArea::scrollToPositionWithoutAnimation(const FloatPoint& position, ScrollClamping clamping)
Modified: trunk/Source/WebCore/platform/ScrollableArea.h (286114 => 286115)
--- trunk/Source/WebCore/platform/ScrollableArea.h 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/platform/ScrollableArea.h 2021-11-22 20:01:09 UTC (rev 286115)
@@ -68,7 +68,7 @@
virtual bool isListBox() const { return false; }
virtual bool isPDFPlugin() const { return false; }
- WEBCORE_EXPORT bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1);
+ WEBCORE_EXPORT bool scroll(ScrollDirection, ScrollGranularity, unsigned stepCount = 1);
WEBCORE_EXPORT void scrollToPositionWithAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped);
WEBCORE_EXPORT void scrollToPositionWithoutAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped);
@@ -216,6 +216,19 @@
virtual Scrollbar* horizontalScrollbar() const { return nullptr; }
virtual Scrollbar* verticalScrollbar() const { return nullptr; }
+ Scrollbar* scrollbarForDirection(ScrollDirection direction) const
+ {
+ switch (direction) {
+ case ScrollUp:
+ case ScrollDown:
+ return verticalScrollbar();
+ case ScrollLeft:
+ case ScrollRight:
+ return horizontalScrollbar();
+ }
+ return nullptr;
+ }
+
const IntPoint& scrollOrigin() const { return m_scrollOrigin; }
bool scrollOriginChanged() const { return m_scrollOriginChanged; }
@@ -365,7 +378,7 @@
void setScrollOrigin(const IntPoint&);
void resetScrollOriginChanged() { m_scrollOriginChanged = false; }
- WEBCORE_EXPORT virtual float adjustScrollStepForFixedContent(float step, ScrollbarOrientation, ScrollGranularity);
+ WEBCORE_EXPORT virtual float adjustScrollStepForFixedContent(float step, ScrollEventAxis, ScrollGranularity);
virtual void invalidateScrollbarRect(Scrollbar&, const IntRect&) = 0;
virtual void invalidateScrollCornerRect(const IntRect&) = 0;
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (286114 => 286115)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2021-11-22 20:01:09 UTC (rev 286115)
@@ -893,10 +893,10 @@
return 0;
}
-bool RenderBox::scrollLayer(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement)
+bool RenderBox::scrollLayer(ScrollDirection direction, ScrollGranularity granularity, unsigned stepCount, Element** stopElement)
{
auto* scrollableArea = layer() ? layer()->scrollableArea() : nullptr;
- if (scrollableArea && scrollableArea->scroll(direction, granularity, multiplier)) {
+ if (scrollableArea && scrollableArea->scroll(direction, granularity, stepCount)) {
if (stopElement)
*stopElement = element();
@@ -906,9 +906,9 @@
return false;
}
-bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement, RenderBox* startBox, const IntPoint& wheelEventAbsolutePoint)
+bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity, unsigned stepCount, Element** stopElement, RenderBox* startBox, const IntPoint& wheelEventAbsolutePoint)
{
- if (scrollLayer(direction, granularity, multiplier, stopElement))
+ if (scrollLayer(direction, granularity, stepCount, stopElement))
return true;
if (stopElement && *stopElement && *stopElement == element())
@@ -917,12 +917,12 @@
RenderBlock* nextScrollBlock = containingBlock();
if (nextScrollBlock && !nextScrollBlock->isRenderView())
- return nextScrollBlock->scroll(direction, granularity, multiplier, stopElement, startBox, wheelEventAbsolutePoint);
+ return nextScrollBlock->scroll(direction, granularity, stepCount, stopElement, startBox, wheelEventAbsolutePoint);
return false;
}
-bool RenderBox::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement)
+bool RenderBox::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, unsigned stepCount, Element** stopElement)
{
bool scrolled = false;
@@ -930,9 +930,9 @@
#if PLATFORM(COCOA)
// On Mac only we reset the inline direction position when doing a document scroll (e.g., hitting Home/End).
if (granularity == ScrollGranularity::Document)
- scrolled = scrollableArea->scroll(logicalToPhysical(ScrollInlineDirectionBackward, isHorizontalWritingMode(), style().isFlippedBlocksWritingMode()), ScrollGranularity::Document, multiplier);
+ scrolled = scrollableArea->scroll(logicalToPhysical(ScrollInlineDirectionBackward, isHorizontalWritingMode(), style().isFlippedBlocksWritingMode()), ScrollGranularity::Document, stepCount);
#endif
- if (scrollableArea->scroll(logicalToPhysical(direction, isHorizontalWritingMode(), style().isFlippedBlocksWritingMode()), granularity, multiplier))
+ if (scrollableArea->scroll(logicalToPhysical(direction, isHorizontalWritingMode(), style().isFlippedBlocksWritingMode()), granularity, stepCount))
scrolled = true;
if (scrolled) {
@@ -947,7 +947,7 @@
RenderBlock* b = containingBlock();
if (b && !b->isRenderView())
- return b->logicalScroll(direction, granularity, multiplier, stopElement);
+ return b->logicalScroll(direction, granularity, stepCount, stopElement);
return false;
}
Modified: trunk/Source/WebCore/rendering/RenderBox.h (286114 => 286115)
--- trunk/Source/WebCore/rendering/RenderBox.h 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/rendering/RenderBox.h 2021-11-22 20:01:09 UTC (rev 286115)
@@ -492,8 +492,8 @@
int intrinsicScrollbarLogicalWidth() const;
int scrollbarLogicalWidth() const { return style().isHorizontalWritingMode() ? verticalScrollbarWidth() : horizontalScrollbarHeight(); }
int scrollbarLogicalHeight() const { return style().isHorizontalWritingMode() ? horizontalScrollbarHeight() : verticalScrollbarWidth(); }
- virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = nullptr, RenderBox* startBox = nullptr, const IntPoint& wheelEventAbsolutePoint = IntPoint());
- virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = nullptr);
+ virtual bool scroll(ScrollDirection, ScrollGranularity, unsigned stepCount = 1, Element** stopElement = nullptr, RenderBox* startBox = nullptr, const IntPoint& wheelEventAbsolutePoint = IntPoint());
+ virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, unsigned stepCount = 1, Element** stopElement = nullptr);
WEBCORE_EXPORT bool canBeScrolledAndHasScrollableArea() const;
virtual bool canBeProgramaticallyScrolled() const;
virtual void autoscroll(const IntPoint&);
@@ -744,7 +744,7 @@
void updateGridPositionAfterStyleChange(const RenderStyle&, const RenderStyle* oldStyle);
- bool scrollLayer(ScrollDirection, ScrollGranularity, float multiplier, Element** stopElement);
+ bool scrollLayer(ScrollDirection, ScrollGranularity, unsigned stepCount, Element** stopElement);
bool fixedElementLaysOutRelativeToFrame(const FrameView&) const;
Modified: trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp (286114 => 286115)
--- trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp 2021-11-22 20:01:09 UTC (rev 286115)
@@ -383,7 +383,7 @@
return true;
}
-bool RenderEmbeddedObject::scroll(ScrollDirection direction, ScrollGranularity granularity, float, Element**, RenderBox*, const IntPoint&)
+bool RenderEmbeddedObject::scroll(ScrollDirection direction, ScrollGranularity granularity, unsigned, Element**, RenderBox*, const IntPoint&)
{
if (!is<PluginViewBase>(widget()))
return false;
@@ -391,10 +391,10 @@
return downcast<PluginViewBase>(*widget()).scroll(direction, granularity);
}
-bool RenderEmbeddedObject::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement)
+bool RenderEmbeddedObject::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, unsigned stepCount, Element** stopElement)
{
// Plugins don't expose a writing direction, so assuming horizontal LTR.
- return scroll(logicalToPhysical(direction, true, false), granularity, multiplier, stopElement);
+ return scroll(logicalToPhysical(direction, true, false), granularity, stepCount, stopElement);
}
bool RenderEmbeddedObject::isInUnavailablePluginIndicator(const FloatPoint& point) const
Modified: trunk/Source/WebCore/rendering/RenderEmbeddedObject.h (286114 => 286115)
--- trunk/Source/WebCore/rendering/RenderEmbeddedObject.h 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/rendering/RenderEmbeddedObject.h 2021-11-22 20:01:09 UTC (rev 286115)
@@ -79,8 +79,8 @@
bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) final;
- bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = nullptr, RenderBox* startBox = nullptr, const IntPoint& wheelEventAbsolutePoint = IntPoint()) final;
- bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier, Element** stopElement) final;
+ bool scroll(ScrollDirection, ScrollGranularity, unsigned stepCount = 1, Element** stopElement = nullptr, RenderBox* startBox = nullptr, const IntPoint& wheelEventAbsolutePoint = IntPoint()) final;
+ bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, unsigned stepCount, Element** stopElement) final;
void setUnavailablePluginIndicatorIsPressed(bool);
bool isInUnavailablePluginIndicator(const MouseEvent&) const;
Modified: trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp (286114 => 286115)
--- trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp 2021-11-22 20:01:09 UTC (rev 286115)
@@ -1491,9 +1491,9 @@
return false;
}
-bool RenderLayerScrollableArea::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier)
+bool RenderLayerScrollableArea::scroll(ScrollDirection direction, ScrollGranularity granularity, unsigned stepCount)
{
- return ScrollableArea::scroll(direction, granularity, multiplier);
+ return ScrollableArea::scroll(direction, granularity, stepCount);
}
bool RenderLayerScrollableArea::isActive() const
Modified: trunk/Source/WebCore/rendering/RenderLayerScrollableArea.h (286114 => 286115)
--- trunk/Source/WebCore/rendering/RenderLayerScrollableArea.h 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/rendering/RenderLayerScrollableArea.h 2021-11-22 20:01:09 UTC (rev 286115)
@@ -130,7 +130,7 @@
void updateScrollInfoAfterLayout();
void updateScrollbarSteps();
- bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1);
+ bool scroll(ScrollDirection, ScrollGranularity, unsigned stepCount = 1);
public:
// All methods in this section override ScrollableaArea methods (final).
Modified: trunk/Source/WebCore/rendering/RenderListBox.cpp (286114 => 286115)
--- trunk/Source/WebCore/rendering/RenderListBox.cpp 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/rendering/RenderListBox.cpp 2021-11-22 20:01:09 UTC (rev 286115)
@@ -615,14 +615,14 @@
return index >= firstIndex && index < endIndex;
}
-bool RenderListBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Element**, RenderBox*, const IntPoint&)
+bool RenderListBox::scroll(ScrollDirection direction, ScrollGranularity granularity, unsigned stepCount, Element**, RenderBox*, const IntPoint&)
{
- return ScrollableArea::scroll(direction, granularity, multiplier);
+ return ScrollableArea::scroll(direction, granularity, stepCount);
}
-bool RenderListBox::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Element**)
+bool RenderListBox::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, unsigned stepCount, Element**)
{
- return ScrollableArea::scroll(logicalToPhysical(direction, style().isHorizontalWritingMode(), style().isFlippedBlocksWritingMode()), granularity, multiplier);
+ return ScrollableArea::scroll(logicalToPhysical(direction, style().isHorizontalWritingMode(), style().isFlippedBlocksWritingMode()), granularity, stepCount);
}
void RenderListBox::valueChanged(unsigned listIndex)
Modified: trunk/Source/WebCore/rendering/RenderListBox.h (286114 => 286115)
--- trunk/Source/WebCore/rendering/RenderListBox.h 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/rendering/RenderListBox.h 2021-11-22 20:01:09 UTC (rev 286115)
@@ -59,7 +59,7 @@
int size() const;
- bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = nullptr, RenderBox* startBox = nullptr, const IntPoint& wheelEventAbsolutePoint = IntPoint()) override;
+ bool scroll(ScrollDirection, ScrollGranularity, unsigned stepCount = 1, Element** stopElement = nullptr, RenderBox* startBox = nullptr, const IntPoint& wheelEventAbsolutePoint = IntPoint()) override;
bool scrolledToTop() const final;
bool scrolledToBottom() const final;
@@ -82,7 +82,7 @@
bool isPointInOverflowControl(HitTestResult&, const LayoutPoint& locationInContainer, const LayoutPoint& accumulatedOffset) override;
- bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = nullptr) override;
+ bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, unsigned stepCount = 1, Element** stopElement = nullptr) override;
void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const override;
void computePreferredLogicalWidths() override;
Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp (286114 => 286115)
--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp 2021-11-22 20:01:09 UTC (rev 286115)
@@ -396,24 +396,24 @@
innerTextElement()->setScrollTop(newTop);
}
-bool RenderTextControlSingleLine::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement, RenderBox* startBox, const IntPoint& wheelEventAbsolutePoint)
+bool RenderTextControlSingleLine::scroll(ScrollDirection direction, ScrollGranularity granularity, unsigned stepCount, Element** stopElement, RenderBox* startBox, const IntPoint& wheelEventAbsolutePoint)
{
auto* renderer = innerTextElement()->renderer();
if (!renderer)
return false;
auto* scrollableArea = renderer->layer() ? renderer->layer()->scrollableArea() : nullptr;
- if (scrollableArea && scrollableArea->scroll(direction, granularity, multiplier))
+ if (scrollableArea && scrollableArea->scroll(direction, granularity, stepCount))
return true;
- return RenderBlockFlow::scroll(direction, granularity, multiplier, stopElement, startBox, wheelEventAbsolutePoint);
+ return RenderBlockFlow::scroll(direction, granularity, stepCount, stopElement, startBox, wheelEventAbsolutePoint);
}
-bool RenderTextControlSingleLine::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement)
+bool RenderTextControlSingleLine::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, unsigned stepCount, Element** stopElement)
{
auto* layer = innerTextElement()->renderer()->layer();
auto* scrollableArea = layer ? layer->scrollableArea() : nullptr;
- if (scrollableArea && scrollableArea->scroll(logicalToPhysical(direction, style().isHorizontalWritingMode(), style().isFlippedBlocksWritingMode()), granularity, multiplier))
+ if (scrollableArea && scrollableArea->scroll(logicalToPhysical(direction, style().isHorizontalWritingMode(), style().isFlippedBlocksWritingMode()), granularity, stepCount))
return true;
- return RenderBlockFlow::logicalScroll(direction, granularity, multiplier, stopElement);
+ return RenderBlockFlow::logicalScroll(direction, granularity, stepCount, stopElement);
}
HTMLInputElement& RenderTextControlSingleLine::inputElement() const
Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h (286114 => 286115)
--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h 2021-11-22 18:14:59 UTC (rev 286114)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h 2021-11-22 20:01:09 UTC (rev 286115)
@@ -59,8 +59,8 @@
int scrollHeight() const override;
void setScrollLeft(int, const ScrollPositionChangeOptions&) override;
void setScrollTop(int, const ScrollPositionChangeOptions&) override;
- bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = nullptr, RenderBox* startBox = nullptr, const IntPoint& wheelEventAbsolutePoint = IntPoint()) final;
- bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = 0) final;
+ bool scroll(ScrollDirection, ScrollGranularity, unsigned stepCount = 1, Element** stopElement = nullptr, RenderBox* startBox = nullptr, const IntPoint& wheelEventAbsolutePoint = IntPoint()) final;
+ bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, unsigned stepCount = 1, Element** stopElement = nullptr) final;
int textBlockWidth() const;
float getAverageCharWidth() override;