There is no way to get text out of a page: there is no text selection, and nothing can write to the clipboard. On a handheld, that means an address seen on one page has to be retyped into the address bar letter by letter using the OSK.
Wanted: select a range with the pad, copy it, and paste it through the OSK.
Design
- Selection lives in the page and is driven by injected JS (
evaluate_javascript), the same mechanism already used by reader mode and hint mode. The virtual cursor provides the anchor: use caretPositionFromPoint at the cursor position, then extend the DOM Selection as the cursor moves.
- Use a two-step interaction, like hint mode: one press sets the anchor, the D-pad extends the selection, and a second press copies it and clears the selection. L1/R1 move by word or line — stepping through a paragraph character by character is unusable with a pad.
- Copy
window.getSelection().toString() through the result callback and place it on SDL's clipboard. This also makes paste work anywhere in the app.
- Add an OSK key that inserts the clipboard, allowing the address bar and page fields to accept pasted text. This is useful on its own even before selection exists, so it may be worth splitting out if the issue gets too long.
- Highlighting comes from the browser's native selection painting; nothing needs to be drawn separately.
Notes
- Servo exposes no selection or clipboard API to the embedder, so both sides need to be implemented by us.
- Pages using
user-select: none will refuse selection; the injected script can temporarily override it for the selection pass.
There is no way to get text out of a page: there is no text selection, and nothing can write to the clipboard. On a handheld, that means an address seen on one page has to be retyped into the address bar letter by letter using the OSK.
Wanted: select a range with the pad, copy it, and paste it through the OSK.
Design
evaluate_javascript), the same mechanism already used by reader mode and hint mode. The virtual cursor provides the anchor: usecaretPositionFromPointat the cursor position, then extend the DOMSelectionas the cursor moves.window.getSelection().toString()through the result callback and place it on SDL's clipboard. This also makes paste work anywhere in the app.Notes
user-select: nonewill refuse selection; the injected script can temporarily override it for the selection pass.