New issue
Advanced search Search tips

Issue 906218 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Feature



Sign in to add a comment

Unify logic for mapping logical to physical scroll direction

Project Member Reported by majidvp@google.com, Nov 16

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

 
Status: Assigned (was: Untriaged)
Here is the mini table that shows the correct mapping AFAICT:

+-------------------------+---------------+-------------+---------------+
| writing-mode            | horizontal-tb | vertical-rl | vertical-lr   |
+-------------------------+---------------+-------------+---------------+
| direction               | ltr    | rtl  | ltr  | rtl  | ltr   | rtl   |
+-------------------------+--------+------+------+------+-------+-------+
| block scroll direction  | down   | down | left | left | right | right |
+-------------------------+--------+------+------+------+-------+-------+
| inline scroll direction | right  | left | down | up   | down  | up    |
+-------------------------+--------+------+------+------+-------+-------+


This is based on https://drafts.csswg.org/css-writing-modes-3/#logical-to-physical

For now assigning to bokan@ in case he has other ideas.
Cc: -smcgruer@chromium.org bokan@chromium.org
Owner: smcgruer@chromium.org
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