[webkit-changes] [WebKit/WebKit] 51184f: Fix resizer behavior with `writing-mode: vertical-...

Aditya Keerthi noreply at github.com
Tue Sep 19 16:00:51 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 51184f8a009b08ee6599c933c435507c2359f495
      https://github.com/WebKit/WebKit/commit/51184f8a009b08ee6599c933c435507c2359f495
  Author: Aditya Keerthi <akeerthi at apple.com>
  Date:   2023-09-19 (Tue, 19 Sep 2023)

  Changed paths:
    A LayoutTests/fast/css/resize-rtl-expected.txt
    A LayoutTests/fast/css/resize-rtl.html
    M LayoutTests/platform/ios/TestExpectations
    M Source/WebCore/page/EventHandler.cpp
    M Source/WebCore/rendering/RenderLayer.h

  Log Message:
  -----------
  Fix resizer behavior with `writing-mode: vertical-rl` or `direction: rtl`
https://bugs.webkit.org/show_bug.cgi?id=248261
rdar://102620110

Reviewed by Simon Fraser.

Resizing behavior is implemented by storing the original offset from the mouse
position to the resizer on mouse down. Then, as the mouse moves, the new offset
from the resizer is compared to the stored offset to determine the overall size
change. This approach ensures that the size of the element does not change when
the mouse position and resizer become detached, which can happen when resizing
the element to its minimum size and continuing to move the mouse away from the resizer.

For elements with right-to-left directionality, the resizer is positioned at
the bottom left. Dragging the resizer along the x-axis adjusts the width of the
element inverse to the movement direction. Unlike left-to-right elements, this
means that it is possible for the mouse position and resizer to become detached
as the width of the element is increasing due to dragging on the resizer.
Specifically, if a resize if started and the mouse is moved is moved to the left
by X pixels, and then down by Y pixels, there will be a constant difference
of X between the original offset (on mouse down) and the new offset. This means
that as the user continues to drag down Y pixels, the offset along the x-axis
continues to increase the width of the element, even though there is no
further movement along the x-axis.

To fix, update the original offset that was stored on mouse down each time a
resize occurs. This ensures that the difference along the x-axis does not
continue accumulating.

* LayoutTests/fast/css/resize-rtl-expected.txt: Added.
* LayoutTests/fast/css/resize-rtl.html: Added.
* LayoutTests/platform/ios/TestExpectations:
* Source/WebCore/page/EventHandler.cpp:
(WebCore::EventHandler::handleMouseMoveEvent):

Update the original offset that was stored on mouse down each time a resize
occurs. Note that following restrictions on the update:

1. The offset is only updated for elements with right-to-left directionality.
   This is neccessary so that the width of left-to-right elements is not
   changed when the mouse position becomes detached from the resizer. Without
   this restriction, beginning a resize and moving the mouse beyond the left of
   the element (forcing its minimum width and detaching from the resizer), and
   then moving the mouse back towards the resizer, would incorrectly increase
   the width of the element.

2. Only the offset in the x-axis is updated. This is because height resizes
   the same for both left-to-right and right-to-left elements, and the
   detachment issue described in (1) should be prevented on the y-axis.
   Detachment on the x-axis is fine, since that is the only way right-to-left
   elements can be resized.

* Source/WebCore/rendering/RenderLayer.h:

Canonical link: https://commits.webkit.org/268157@main




More information about the webkit-changes mailing list