Integrate OpaqueRange hooks into text controls (input/textarea)#11741
Integrate OpaqueRange hooks into text controls (input/textarea)#11741stephanieyzhang wants to merge 17 commits intowhatwg:mainfrom
Conversation
Whoops, forgot to define that 🤦. Added it to the "APIs for the text control selections" section. Let me know if you'd prefer it placed elsewhere as I wasn't sure where the best spot for it was. |
The new name makes it explicitly clear that a new range is created each time, as suggested in HTML spec PR discussion: whatwg/html#11741 (comment) Updates the OpaqueRangeCreation mixin and IDL, all implementing classes (TextControlElement, HTMLInputElement), and test files. Low-Coverage-Reason: COVERAGE_UNDERREPORTED Bug: 421421332 Change-Id: Iec9572c470443e85d2a38ecd978bd7c78e8c5a86
The new name makes it explicitly clear that a new range is created each time, as suggested in HTML spec PR discussion: whatwg/html#11741 (comment) Updates the OpaqueRangeCreation mixin and IDL, all implementing classes (TextControlElement, HTMLInputElement), and test files. Low-Coverage-Reason: COVERAGE_UNDERREPORTED Bug: 421421332 Change-Id: Iec9572c470443e85d2a38ecd978bd7c78e8c5a86
The new name makes it explicitly clear that a new range is created each time, as suggested in HTML spec PR discussion: whatwg/html#11741 (comment) Updates the OpaqueRangeCreation mixin and IDL, all implementing classes (TextControlElement, HTMLInputElement), and test files. Low-Coverage-Reason: COVERAGE_UNDERREPORTED Bug: 421421332 Change-Id: Iec9572c470443e85d2a38ecd978bd7c78e8c5a86 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7595653 Reviewed-by: Dan Clark <daniec@microsoft.com> Commit-Queue: Stephanie Zhang <stephanie.zhang@microsoft.com> Reviewed-by: Mason Freed <masonf@chromium.org> Reviewed-by: Ana Sollano Kim <ansollan@microsoft.com> Cr-Commit-Position: refs/heads/main@{#1591036}
The new name makes it explicitly clear that a new range is created each time, as suggested in HTML spec PR discussion: whatwg/html#11741 (comment) Updates the OpaqueRangeCreation mixin and IDL, all implementing classes (TextControlElement, HTMLInputElement), and test files. Low-Coverage-Reason: COVERAGE_UNDERREPORTED Bug: 421421332 Change-Id: Iec9572c470443e85d2a38ecd978bd7c78e8c5a86 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7595653 Reviewed-by: Dan Clark <daniec@microsoft.com> Commit-Queue: Stephanie Zhang <stephanie.zhang@microsoft.com> Reviewed-by: Mason Freed <masonf@chromium.org> Reviewed-by: Ana Sollano Kim <ansollan@microsoft.com> Cr-Commit-Position: refs/heads/main@{#1591036}
The new name makes it explicitly clear that a new range is created each time, as suggested in HTML spec PR discussion: whatwg/html#11741 (comment) Updates the OpaqueRangeCreation mixin and IDL, all implementing classes (TextControlElement, HTMLInputElement), and test files. Low-Coverage-Reason: COVERAGE_UNDERREPORTED Bug: 421421332 Change-Id: Iec9572c470443e85d2a38ecd978bd7c78e8c5a86 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7595653 Reviewed-by: Dan Clark <daniec@microsoft.com> Commit-Queue: Stephanie Zhang <stephanie.zhang@microsoft.com> Reviewed-by: Mason Freed <masonf@chromium.org> Reviewed-by: Ana Sollano Kim <ansollan@microsoft.com> Cr-Commit-Position: refs/heads/main@{#1591036}
…eateValueRange(), a=testonly Automatic update from web-platform-tests Rename OpaqueRange getValueRange() to createValueRange() The new name makes it explicitly clear that a new range is created each time, as suggested in HTML spec PR discussion: whatwg/html#11741 (comment) Updates the OpaqueRangeCreation mixin and IDL, all implementing classes (TextControlElement, HTMLInputElement), and test files. Low-Coverage-Reason: COVERAGE_UNDERREPORTED Bug: 421421332 Change-Id: Iec9572c470443e85d2a38ecd978bd7c78e8c5a86 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7595653 Reviewed-by: Dan Clark <daniec@microsoft.com> Commit-Queue: Stephanie Zhang <stephanie.zhang@microsoft.com> Reviewed-by: Mason Freed <masonf@chromium.org> Reviewed-by: Ana Sollano Kim <ansollan@microsoft.com> Cr-Commit-Position: refs/heads/main@{#1591036} -- wpt-commits: 4c5d702b40927803c1024376687a6ca84e877720 wpt-pr: 58079
| <p>Before queuing that task, if the element <span>supports opaque ranges</span>, then run the | ||
| <span>opaque range replacement steps</span> with the element, the edit's code unit offset, the | ||
| number of code units removed, and the number of code units inserted.</p> |
There was a problem hiding this comment.
"Before queuing that task" doesn't seem right.
I think this requires more substantial editing to ensure the steps are in order, so it goes:
- Any time the user causes change...
- Update opaque ranges
- Queue a task.
It might be worth breaking this out into an algorithm so it's easier to follow, rather than a dense paragraph though.
There was a problem hiding this comment.
This says to run opaque range replacement steps, and then queue a task to fire the input event. Is that correct? Or should the checking of "supports opaque ranges" and running "opaque range replacement steps" happen in the same task as firing the input event?
| interaction before queuing the task; for example, a user agent could wait for the user to have not | ||
| hit a key for 100ms, so as to only fire the event when the user pauses, instead of continuously | ||
| for each keystroke.</p> | ||
| <p>Before queuing that task, if the element <span>supports opaque ranges</span>, then run the |
There was a problem hiding this comment.
Same here, these steps should be in order.
| <p>A <code>textarea</code> element, or an <code>input</code> element whose <code | ||
| data-x="attr-input-type">type</code> attribute is in the <span | ||
| data-x="attr-input-type-text">Text</span>, <span data-x="attr-input-type-search">Search</span>, | ||
| <span data-x="attr-input-type-tel">Telephone</span>, <span | ||
| data-x="attr-input-type-url">URL</span>, or <span | ||
| data-x="attr-input-type-password">Password</span> state, <span>supports opaque ranges</span>.</p> |
There was a problem hiding this comment.
Why not input type="number"? Seems like it could be useful there too. I guess because setRangeText doesn't apply... which is a much bigger change. Worth thinking about perhaps?
| data-x="concept-textarea-raw-value">raw value</span>, and the element <span>supports opaque | ||
| ranges</span>, then run the <span>opaque range full replacement steps</span> with the element, |
There was a problem hiding this comment.
All textareas seem to support opaque ranges so this if seems unnecessary.
| content</span>. If this changes the element's <span data-x="concept-fe-api-value">API | ||
| value</span>, and the element <span>supports opaque ranges</span>, then run the <span>opaque |
There was a problem hiding this comment.
Likewise here; textareas support opaque ranges so this seems unnecessary.
| true.</p></li> | ||
| <li><p>Set this element's <span data-x="concept-fe-dirty">dirty value flag</span> to true.</p></li> | ||
|
|
||
| <li><p>If this changes the element's <span data-x="concept-fe-api-value">API value</span>, |
There was a problem hiding this comment.
And again here; textareas support opaque ranges so this seems unnecessary.
| <p>A <code>textarea</code> element, or an <code>input</code> element whose <code | ||
| data-x="attr-input-type">type</code> attribute is in the <span | ||
| data-x="attr-input-type-text">Text</span>, <span data-x="attr-input-type-search">Search</span>, | ||
| <span data-x="attr-input-type-tel">Telephone</span>, <span | ||
| data-x="attr-input-type-url">URL</span>, or <span | ||
| data-x="attr-input-type-password">Password</span> state, <span>supports opaque ranges</span>.</p> |
There was a problem hiding this comment.
Given this is always true for textarea, this could be a concept of input elements only, and perhaps could be a flag (or algo) on input elements. It seems input elements have this concept twice: They have "supports opaque ranges" and also "createValueRange() does not apply" - AIUI these are the same concept?
Unless I'm mistaken in the belief that textareas always support opaque ranges?
OpaqueRange is a specialized, live AbstractRange subtype whose boundary points reference internal nodes within host-defined elements (e.g.,
<input>/<textarea>today, with a path to custom elements in the future). It enables range-based operations over encapsulated content while avoiding exposure of internal DOM nodes.Explainer: https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/OpaqueRange/explainer.md
WhatWG discussion: OpaqueRange Interface #11478
Corresponding DOM Spec PR: Add OpaqueRange interface dom#1404
Corresponding CSSOM PR: [cssom-view-1] Define OpaqueRange geometry APIs (getClientRects/getBoundingClientRect) w3c/csswg-drafts#12904
At least two implementers are interested (and none opposed):
Tests are written and can be reviewed and commented upon at:
Implementation bugs are filed:
Corresponding HTML AAM & ARIA in HTML issues & PRs:
MDN issue is filed: …
The top of this comment includes a clear commit message to use.
(See WHATWG Working Mode: Changes for more details.)
/form-control-infrastructure.html ( diff )
/form-elements.html ( diff )
/infrastructure.html ( diff )
/input.html ( diff )