Unify logic for mapping logical to physical scroll direction |
||
Issue description
We currently have an implementation in [1]
inline ScrollDirectionPhysical ToPhysicalDirection(ScrollDirection direction,
bool is_vertical,
bool is_flipped);
smcgruer@ was needed this functionality for ScrollTimeline so I suggested using it. However as he rightly pointed out:
"I am wary of those functions. As far as I can tell: they're called in only one place[0], have no tests, and they don't seem to do the right thing as currently called because they ignore directionality. It is called with writing-mode == horizontal-tb for is_vertical, and writing-mode == vertical-rl for is_flipped, which also means that both bools cannot be true - yet the code in the function has cases where it handles that."
And I agree. The fact that the only call site gets this wrong is a sign that this function interface is not that great. I think it should not requires the caller to pass in is_vertical and is_flipped, much safer to pass in style and let the function compute this.
smcgruer@ has implemented the same functionality with a different approach in [2]. We should unify these.
[1] https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/scroll/scroll_types.h?type=cs&sq=package:chromium&g=0&l=87
[2] https://chromium-review.googlesource.com/c/chromium/src/+/1310567/4/third_party/blink/renderer/modules/animationworklet/worklet_animation.cc#188
,
Nov 16
For now assigning to bokan@ in case he has other ideas.
,
Nov 16
This sgtm. Those functions are super-old and, came from existing shaky code and have survived multiple rounds of refactorings so I'm not terribly surprised they're not totally correct. Unify-away! |
||
►
Sign in to add a comment |
||
Comment 1 by majidvp@google.com
, Nov 16