diff --git a/source b/source index a92d86863c1..ed3ee6982a2 100644 --- a/source +++ b/source @@ -49827,10 +49827,13 @@ interface HTMLInputElement : HTMLElement { attribute gives the default value of the input element. When the value content attribute is added, set, or removed, if the control's dirty value flag - is false, the user agent must set the value of the element - to the value of the value content attribute, if there is - one, or the empty string otherwise, and then run the current value sanitization - algorithm, if one is defined.

+ is false, the user agent must:

+
    +
  1. Let oldValue be the element's current value.

  2. +
  3. Set the value of the element to the value of the value content attribute, if there is one, or the empty string otherwise.

  4. +
  5. Run the current value sanitization algorithm, if one is defined.

  6. +
  7. If the element supports form control range and oldValue and the element's new value differ, then run the form control range full replacement steps with the element, the length of oldValue, and the length of the new value.

  8. +
@@ -49866,17 +49869,16 @@ interface HTMLInputElement : HTMLElement {

The reset algorithm for input - elements is to set its user validity, - dirty value flag, and - dirty checkedness flag - back to false, set the value of the element to the value - of the value content attribute, if there is one, or the - empty string otherwise, set the checkedness of the - element to true if the element has a checked content - attribute and false if it does not, empty the list of selected files, and then invoke the value - sanitization algorithm, if the type attribute's - current state defines one.

+ elements is to:

+
    +
  1. Set its user validity, dirty value flag, and dirty checkedness flag back to false.

  2. +
  3. Let oldValue be the element's current value.

  4. +
  5. Set the value of the element to the value of the value content attribute, if there is one, or the empty string otherwise.

  6. +
  7. Set the checkedness of the element to true if the element has a checked content attribute and false if it does not.

  8. +
  9. Empty the list of selected files.

  10. +
  11. Invoke the value sanitization algorithm, if the type attribute's current state defines one.

  12. +
  13. If the element supports form control range and oldValue and the element's new value differ, then run the form control range full replacement steps with the element, the length of oldValue, and the length of the new value.

  14. +

Each input element can be mutable. Except where @@ -50087,6 +50089,11 @@ interface HTMLInputElement : HTMLElement { element's text entry cursor position to the beginning of the text control, and set its selection direction to "none".

+ +
  • If previouslySelectable is true and nowSelectable is false, then for + each FormControlRange object whose control is this + element, set that object's control to null and set both its start offset and end offset to 0.

  • @@ -50153,6 +50160,87 @@ interface HTMLInputElement : HTMLElement { form, and name IDL attributes are part of the element's forms API.

    +

    The following concepts and algorithms integrate the {{FormControlRange}} interface (defined in + the DOM Standard) with HTML form controls.

    + +

    A {{FormControlRange}} object is associated + with an element if its control is that element. An element's form control ranges are the {{FormControlRange}} objects + associated with it.

    + +
    +

    The form control range value mutation algorithm +updates each {{FormControlRange}} associated with a supported +text control when a contiguous substring of its value string +is replaced. It is passed an element el, non‑negative integers start, +oldLength (removed length), and newLength (inserted length). Let delta = +newLengtholdLength. For each {{FormControlRange}} object range in +el's form control ranges:

    +
      +
    1. Let rs be range's start offset; let re + be its end offset.

    2. + +
    3. Let editStart be start; let editEnd be start + + oldLength.

    4. + +
    5. If editEndrs, then (edit strictly before range) set rs = + rs + delta and re = re + delta and jump to step + Clamp.

    6. + +
    7. If editStartre, then (edit strictly after range) jump to step + Clamp.

    8. + +
    9. (Overlapping removal) If oldLength > 0, then:

      +
        +
      1. If rseditStart and rs < editEnd, set + rs = editStart.

      2. + +
      3. If reeditStart and re < editEnd, set + re = editStart.

      4. +
      +
    10. + +
    11. (Replacement insertion remap) If oldLength > 0 and newLength > 0 + and editStartrsreeditEnd, then for each boundary + (rs then re): let offsetWithin be that boundary's original value − + editStart; set boundary = editStart + min(offsetWithin, + newLength).

    12. + +
    13. (Pure insertion) If oldLength = 0 and newLength > 0 and + editStart is within [rs, re] then:

      +
        +
      1. If rs = re (collapsed), set rs = re = rs + + newLength.

      2. + +
      3. Otherwise, if editStart = rs, set re = re + + newLength. (Insertion at start expands.)

      4. + +
      5. Otherwise, if editStart = re, do nothing. (Insertion at end does not + expand.)

      6. +
      +
    14. + +
    15. Clamp: Let valueLen be the length of + el's current value string. Set rs = + min(rs, valueLen) and re = min(re, valueLen). If + rs > re, then set re = rs.

    16. + +
    17. Set range's start offset to rs and its end offset to re.

    18. +
    +

    This algorithm mirrors {{Range}} boundary adjustment rules, operating instead on the +UTF-16 code unit indices of a form control's value string.

    +

    +
    + +

    The form control range full replacement steps + for an element el with previous value length oldLength and new value length + newLength are to run the form control range value + mutation algorithm with el, 0, oldLength, and newLength.

    + +

    User agents must call the algorithm explicitly at each value mutation point; it is not + implicitly invoked by unspecified text modifications.

    + @@ -54799,6 +54887,9 @@ You cannot submit this form when the field is incorrect.
  • Invoke the value sanitization algorithm, if the element's type attribute's current state defines one.

  • +
  • If the element's value is different from + oldValue and the element supports form control range, then run the form control range full replacement steps with the element, the length of oldValue, and the length of the element's current value.

  • +
  • If the element's value (after applying the value sanitization algorithm) is different from oldValue, and the element has a text entry cursor position, @@ -54807,6 +54898,13 @@ You cannot submit this form when the field is incorrect. direction">resetting the selection direction to "none".

  • + +

    Integration with FormControlRange:

    +

    After setting the new value, run + adjust form-control ranges for this control. Treat the + entire old value as deleted and the entire new value as inserted, so that all associated ranges + update according to the rules in that section.

    +
    default @@ -57529,6 +57627,7 @@ interface HTMLTextAreaElement : HTMLElement { 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.

    +

    Additionally, before queuing that task, the user agent must run the form control range value mutation steps with the change characterized by the edit (offset, deleted length, inserted length) for this element.

    @@ -57549,7 +57648,7 @@ interface HTMLTextAreaElement : HTMLElement {

    The children changed steps for textarea elements must, if the element's dirty value flag is false, set the element's raw value to its child text - content.

    + content. If this changes the element's raw value, then run the form control range value mutation steps with a change offset of 0, a deleted length of the length of the previous API value, and an inserted length of the length of the new API value.

    @@ -57557,7 +57656,7 @@ interface HTMLTextAreaElement : HTMLElement { elements is to set the user validity to false, the dirty value flag back to false, and the raw value to its child text - content.

    + content. If this changes the element's API value, then run the form control range value mutation steps with a change offset of 0, a deleted length of the length of the old API value, and an inserted length of the length of the new API value.

    @@ -57814,7 +57913,7 @@ interface HTMLTextAreaElement : HTMLElement {

    The defaultValue attribute's setter must - string replace all with the given value within this element.

    + string replace all with the given value within this element. If the element's dirty value flag is false and this causes the element's raw value (and thus its API value) to change, then run the form control range value mutation steps with a change offset of 0, a deleted length of the length of the old API value, and an inserted length of the length of the new API value.

    @@ -57830,8 +57929,10 @@ interface HTMLTextAreaElement : HTMLElement {
  • Set this element's raw value to the new value.

  • -
  • Set this element's dirty value flag to - true.

  • +
  • Set this element's dirty value flag to + true.

  • + +
  • Run the form control range value mutation steps with this element, a change offset of 0, a deleted length of the length of oldAPIValue, and an inserted length of the length of this element's new API value.

  • If the new API value is different from oldAPIValue, then move the text entry @@ -57841,6 +57942,12 @@ interface HTMLTextAreaElement : HTMLElement {

  • +

    Integration with FormControlRange:

    +

    After setting the new value, run + adjust form-control ranges for this control. Treat the + entire old value as deleted and the entire new value as inserted, so that all associated ranges + update according to the rules in that section.

    +

    The textLength IDL attribute must return the @@ -61689,6 +61796,11 @@ MIT Room 32-G524

    APIs for the text control selections

    +

    + Text-entry controls support FormControlRange. Liveness is maintained by HTML's + form-control range adjustment algorithm, and the algorithms + in this section invoke it whenever they modify a control's value string.

    +

    The input and textarea elements define several attributes and methods @@ -62137,7 +62249,13 @@ MIT Room 32-G524

  • Let new length be the length of the value of the first argument.

  • -
  • Let new end be the sum of start and new length.

  • +
  • Let new end be the sum of start and new length.

  • + +
  • Let deleted count be max(0, end minus start).

  • + +
  • If this element supports form control range, + then run the form control range value mutation algorithm + with this element, start, deleted count, and new length.

  • Run the appropriate set of substeps from the following list:

    @@ -62247,6 +62365,56 @@ control.setSelectionRange(oldStart + prefix.length, oldEnd + prefix.length, oldD +
    Form control range liveness
    + + + + +

    Some DOM APIs expose FormControlRange objects whose boundary points are defined over + the UTF-16 code units of a text control's value string rather than over the node tree. HTML is + responsible for keeping those ranges live when a control's value changes.

    + +
    Adjusting form-control ranges for a value change
    + +

    The algorithm to adjust form-control ranges + for a control is defined earlier as the form control + range value mutation algorithm. This section only summarizes its purpose: to keep + FormControlRange objects live by updating their boundary offsets after each value + mutation.

    + +
    Where adjustments are invoked
    + +

    User agents must invoke the form control range value + mutation algorithm each time a supported text control's value + string is mutated by replacing a contiguous substring (including insertions and deletions). This + includes, but is not limited to:

    +
      +
    • User editing operations (typing, confirmed IME composition, deletion, paste, drag-and-drop + text insertion, spellcheck or autocorrect replacements, undo/redo) that modify the value and dispatch + an input event.

    • + +
    • Calls to setRangeText().

    • + +
    • Scripted assignment to HTMLInputElement.value or + HTMLTextAreaElement.value, including during form reset, + autofill, session/history restoration, and drag-and-drop insertion producing a programmatic value + change.

    • + +
    • Value changes produced by sanitization algorithms that actually alter the stored value (e.g., + newline stripping, whitespace trimming).

    • +
    + +

    Selection changes alone (via setSelectionRange(), + setting selectionStart/selectionEnd, or changing selectionDirection) do not invoke the + algorithm because they do not modify the control's value string.

    + +

    If an input element's type is changed to a state that does not + support the selection APIs (see selection + applicability), then for each FormControlRange whose control is that element, set its + control to null and set both its start offset and end offset to 0.

    +

    Constraints