Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick "LibWeb+LibWebView: Auto-select subtext when editing DOM nodes/attributes" #25295

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

nico
Copy link
Contributor

@nico nico commented Nov 5, 2024

We currently use a naive word segmentation, looking for ASCII spaces to
mark a word boundary. Use LibUnicode's complete implementation instead.

(cherry picked from commit 430c9d3e3fb6ec9e2aa3d962381672b70957c395)
Otherwise, it looks a bit awkward where the cursor position does not
update while the selection is elsewhere.

Note that this requires passing along the raw selection positions from
`set the selection range` to the elements. Otherwise, consider what will
happen if we set the selection start and end to the same value. By going
through the API accessor, we hit the case where the start and end are
the same value, and return the document cursor position. This would mean
the cursor position would not be updated.

The test changes here more closely match what Firefox produces now. It
is not a 100% match; the `select event fired` test case isn't right. The
problem is the event fires for the input element, but we most recently
focused the textarea element. Thus, when we retrieve the selection from
the input element, we return the document's cursor position, which is
actually in the textarea element. The fix will ultimately be to fully
implement the following:

https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-textarea/input-cursor

That is, each input / textarea element should separately track its own
text cursor position.

(cherry picked from commit fd289deb44e0fc26f54a133c637c136bf0716cd5)
The implementation of setBaseAndExtent will create a new range.

(cherry picked from commit 96ad310643ff90af557b9ca71db450ebd4d37ba5)
This allows for coming up with coordinates that work on macOS with a DPR
of 2 more easily.

(cherry picked from commit 59fe7ca8300ca64ad92e47a694ee352e8f99a1f8)
For example, if the shadow root was detached from the document in some
manner, its host will be null.

(cherry picked from commit 8fb2cc2be1d7a63eba7b1ae5c93e3db181ca393f)
This adds the following behavior for the DOM node/attribute editor in
the Inspector:

* If the user double clicks on an attribute name, the name is selected.
* If the user double clicks on an attribute value, the value text (sans
  the surrounding quotes) is selected.
* Otherwise, double clicks select the entire text range.

(cherry picked from commit 7fff00972d667e7c83ed0336dc8e7f8ddbd91298)
@github-actions github-actions bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label Nov 5, 2024
@nico nico marked this pull request as draft November 5, 2024 01:56
@github-actions github-actions bot removed the 👀 pr-needs-review PR needs review from a maintainer or community member label Nov 5, 2024
Copy link

stale bot commented Nov 27, 2024

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions!

@stale stale bot added the stale label Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants