RESOLVED FIXED Bug 233403
Clarify behavior of ScrollAnimator::scroll()
https://bugs.webkit.org/show_bug.cgi?id=233403
Summary Clarify behavior of ScrollAnimator::scroll()
Simon Fraser (smfr)
Reported 2021-11-20 16:44:38 PST
Clarify behavior of ScrollAnimator::scroll()
Attachments
Patch (35.66 KB, patch)
2021-11-20 16:44 PST, Simon Fraser (smfr)
no flags
Patch (38.77 KB, patch)
2021-11-20 21:53 PST, Simon Fraser (smfr)
sam: review+
Simon Fraser (smfr)
Comment 1 2021-11-20 16:44:55 PST
Simon Fraser (smfr)
Comment 2 2021-11-20 21:53:24 PST
Sam Weinig
Comment 3 2021-11-21 10:33:34 PST
Comment on attachment 444915 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=444915&action=review > Source/WebCore/platform/ScrollTypes.h:174 > +inline ScrollEventAxis axisFromDirection(ScrollDirection direction) You could make this constexpr. > Source/WebCore/platform/ScrollTypes.h:194 > +inline void setValueForAxis(FloatSize& size, ScrollEventAxis axis, float value) I think this reference parameter makes this more confusing than necessary, and probably isn't a performance win over just returning a new FloatSize. An alternative that might make sense would be making a subclass or wrapper class of FloatSize called something like ScrollDelta that has this function. > Source/WebCore/platform/ScrollTypes.h:211 > +inline void setValueForAxis(FloatPoint& point, ScrollEventAxis axis, float value) Same here as setValueForAxis.
Chris Lord
Comment 4 2021-11-22 02:46:29 PST
Comment on attachment 444915 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=444915&action=review Drive-by from a non-reviewer that has some stake in this part of the code - looks good to me, just some small bits and bobs I think might be worth addressing. > Source/WebCore/dom/Element.cpp:-1124 > ScrollDirection direction = ScrollDown; > - if (units < 0) { > + if (units < 0) > direction = ScrollUp; > - units = -units; > - } Maybe it's a style thing, but could this not just be condensed to a one-line `ScrollDirection direction = (units < 0) ? ScrollUp : ScrollDown;` now? I think it'd read nicer, though would understand opposition to a ternary. > Source/WebCore/dom/Element.h:178 > + // These are only used by WebKitLegacy DOM API. Great to have this comment here, I wonder if it'd be nice to add even more separation somehow, either via an interface (LegacyScrolling or something) or via the use of a friend class and making these private. > Source/WebCore/page/FrameView.cpp:3839 > + if (granularity != ScrollGranularity::Page || axis == ScrollEventAxis::Horizontal) If this function does nothing when not vertical, paged scrolling, would it make more sense to name this function something different and adjust the call-site instead? I suppose that's a bigger change, but it feels weird to me to have a whole function that takes two parameters whether to decide to do anything at all. > Source/WebCore/platform/ScrollAnimator.cpp:74 > + behavior.remove(ScrollBehavior::RespectScrollSnap); If this function is no longer re-entrant, should this flag still be removed? It might actually be useful later on to determine whether the scroll position may have been adjusted(?) > Source/WebCore/platform/ScrollTypes.h:182 > + return ScrollEventAxis::Vertical; I guess it would be nice to have an ASSERT_NOT_REACHED() before this. > Source/WebCore/platform/ScrollTypes.h:191 > + return 0; Same here re assert. > Source/WebCore/platform/ScrollableArea.h:229 > + return nullptr; Again, I think it would be nice to assert here.
Simon Fraser (smfr)
Comment 5 2021-11-22 12:03:25 PST
Sorry Chris, I committed before I saw your comments. I'll address your comments in a followup.
Simon Fraser (smfr)
Comment 6 2021-11-22 13:30:33 PST
Radar WebKit Bug Importer
Comment 7 2021-11-22 13:31:25 PST
Note You need to log in before you can comment on or make changes to this bug.