Skip to content

script: Add DragGesture and DragHandler abstractions - #47329

Merged
mrobinson merged 1 commit into
servo:mainfrom
mrobinson:drag-handler
Aug 18, 2026
Merged

mrobinson merged 1 commit into
servo:mainfrom
mrobinson:drag-handler

Conversation

@mrobinson

Copy link
Copy Markdown
Member

This change adds two abstractions that allow drags to be updated even
when they extend outside the boundaries of the element that starts them.
This allows continuing to select text in an input box even when the
cursor leaves the box. In addition, this will make it more
straight-forward to properly implement document selection which will be
different variant of DragHandler.

Notes:

  • This cannot reuse the pointer capture code because these kind of drag
    gestures do not change the target of input events.
  • Cross document drags are not supported yet.
  • Moving drag updates to before event handling means that
    preventDefault() on the input events won't prevent drag updates,
    which is what we want.

Testing: This change includes new and updated Servo-specific WPT tests.

@mrobinson
mrobinson force-pushed the drag-handler branch 2 times, most recently from 69475f4 to 95c3317 Compare August 18, 2026 13:38
}
}

#[cfg_attr(crown, expect(crown::unrooted_must_root))]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is triggering this lint ok? Should this get a &NoGC parameter?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is necessary because it takes a "must root" type as an argument. It's fine to accept this because it is placed immediately into a traced struct.

This change adds two abstractions that allow drags to be updated even
when they extend outside the boundaries of the element that starts them.
This allows continuing to select text in an input box even when the
cursor leaves the box. In addition, this will make it more
straight-forward to properly implement document selection which will be
different variant of `DragHandler`.

Notes:

- This cannot reuse the pointer capture code because these kind of drag
  gestures do not change the target of input events.
- Cross document drags are not supported yet.
- Moving drag updates to before event handling means that
  `preventDefault()` on the input events won't prevent drag updates,
  which is what we want.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Simon Sapin <simon@igalia.com>
@mrobinson
mrobinson marked this pull request as ready for review August 18, 2026 20:14
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Aug 18, 2026
@mrobinson
mrobinson enabled auto-merge August 18, 2026 20:15
@mrobinson
mrobinson added this pull request to the merge queue Aug 18, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Aug 18, 2026
Merged via the queue into servo:main with commit 544c99b Aug 18, 2026
36 checks passed
@mrobinson
mrobinson deleted the drag-handler branch August 18, 2026 22:27
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Aug 18, 2026
RichardTjokroutomo pushed a commit to RichardTjokroutomo/servo that referenced this pull request Oct 6, 2026
This change adds two abstractions that allow drags to be updated even
when they extend outside the boundaries of the element that starts them.
This allows continuing to select text in an input box even when the
cursor leaves the box. In addition, this will make it more
straight-forward to properly implement document selection which will be
different variant of `DragHandler`.

Notes:

- This cannot reuse the pointer capture code because these kind of drag
  gestures do not change the target of input events.
- Cross document drags are not supported yet.
- Moving drag updates to before event handling means that
  `preventDefault()` on the input events won't prevent drag updates,
  which is what we want.


Testing: This change includes new and updated Servo-specific WPT tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Simon Sapin <simon@igalia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-review There is new code that needs to be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants