From 45f8fe831f5c6231f941f845071c770e7b9bbe76 Mon Sep 17 00:00:00 2001
From: siusin
If the selection's range is not null and is
[=range/collapsed=], then the caret position must be at that
range's boundary point. When the selection is not
- [=range/collapsed=], this specification does not define the caret position; user
- agents should follow platform conventions in deciding whether the caret
- is at the start of the selection, the end of the
- selection, or somewhere else.
+ [=range/collapsed=], this specification does not define the caret
+ position; user agents should follow platform conventions in deciding
+ whether the caret is at the start of the selection, the end of
+ the selection, or somewhere else.
Each selection has a direction: forwards, @@ -162,9 +162,9 @@
- When the selection's range is mutated by scripts, - e.g. via {{Range/selectNode(node)}}, direction of the selection - must be preserved. + When the selection's range is mutated by scripts, e.g. + via {{Range/selectNode(node)}}, direction of the + selection must be preserved.
Each selections also have an anchor and a @@ -176,13 +176,14 @@
- anchor and focus of selection need not to be - in the [=document tree=]. It could be in a [=shadow tree=] of - the same [=document=]. + anchor and focus of selection need not to be in + the [=document tree=]. It could be in a [=shadow tree=] of the same + [=document=].
- Each document, input element, and textarea element has a boolean - has scheduled selectionchange event, which is initially false. + Each document, input element, and textarea element + has a boolean has scheduled selectionchange event, which is + initially false.
The attribute must return the anchor [=boundary point/node=] - of [=this=], or `null` if the anchor is null or anchor - is not in the [=document tree=]. + of [=this=], or `null` if the anchor is null or + anchor is not in the [=document tree=].
The attribute must return `"None"` if [=this=] is empty or - either focus or anchor is not in the [=document tree=], - `"Caret"` if [=this=]'s range is [=range/collapsed=], and - `"Range"` otherwise. + either focus or anchor is not in the [=document + tree=], `"Caret"` if [=this=]'s range is + [=range/collapsed=], and `"Range"` otherwise.
The attribute must return `"none"` if [=this=] is empty or - this selection is directionless. `"forward"` if this selection's - direction is forwards and `"backward"` if this selection's - direction is backwards. + this selection is directionless. `"forward"` if this + selection's direction is forwards and `"backward"` if this + selection's direction is backwards.
0
, or if [=this=] is
empty or either focus or anchor is not in the
- [=document tree=]. Otherwise, it must return a reference to (not a copy
- of) [=this=]'s range.
+ [=document tree=]. Otherwise, it must return a reference to (not a
+ copy of) [=this=]'s range.
Thus subsequent calls of this method returns the same range @@ -401,29 +402,49 @@
The method must follow these steps:
- We need to more precisely define what it means to extend or move selection by each granularity. + We need to more precisely define what it means to extend or move + selection by each granularity.
The method must invoke {{Range/deleteContents()}} on [=this=]'s - range if [=this=] is not empty and both focus and anchor - are in the [=document tree=]. Otherwise the method must do nothing. + range if [=this=] is not empty and both focus + and anchor are in the [=document tree=]. Otherwise the + method must do nothing.
This is the one method that actually mutates the range instead of @@ -726,20 +763,25 @@
true
, the
method must return true
if and only if [=range/start=]
of its range is [=boundary point/before=] or visually
- equivalent to the last boundary point in the
- node and [=range/end=] of its
- range is [=boundary point/after=] or visually equivalent to
- the first boundary point in the node.
+ equivalent to the last boundary point in the node
+ and [=range/end=] of its range is
+ [=boundary point/after=] or visually equivalent to the first
+ boundary point in the node.
The stringification must return the string, which is the concatenation of - the rendered text if there is a [=range=] associated with [=this=].
-If the selection is within a textarea or input element, - it must return the selected substring in its value.
++ The stringification must return the string, which is the + concatenation of the rendered text if there is a [=range=] + associated with [=this=]. +
++ If the selection is within a textarea or input + element, it must return the selected substring in its value. +
@@ -885,21 +927,27 @@
- When the user agent is to [=replace data=] or [=CharacterData/substring data=] on {{CharacterData}}, - the user agent must update the range associated with selection of the [=Node/node document=] - of the {{CharacterData}} as if it's a live range. + When the user agent is to [=replace data=] or [=CharacterData/substring + data=] on {{CharacterData}}, the user agent must update the + range associated with selection of the [=Node/node + document=] of the {{CharacterData}} as if it's a live range.
- When the user agent is to split a {{Text}} [=node=], the user agent must update the range associated with - selection of the [=Node/node document=] of the {{Text}} as if it's a live range. + When the user agent is to split a {{Text}} [=node=], the user agent + must update the range associated with selection of the + [=Node/node document=] of the {{Text}} as if it's a live range.
- When the user agent is to run steps for normalize()
method, the user agent must update
- the range associated with selection of the [=Node/node document=] of [=this=] as if it's a live range.
+ When the user agent is to run steps for normalize()
+ method, the user agent must update the range associated with
+ selection of the [=Node/node document=] of [=this=] as if it's a
+ live range.
- When the user agent is to [=remove=] or [=insert=] a [=node=], the user agent must update - the range associated with selection of the [=Node/node document=] of the [=node=] as if it's a live range. + When the user agent is to [=remove=] or [=insert=] a [=node=], the user + agent must update the range associated with selection of + the [=Node/node document=] of the [=node=] as if it's a live + range.
The user agent should allow the user to change the selection - associated with the [=navigable/active document=]. If the user makes any - modification to a selection, the user agent must create a new - range with suitable [=range/start=] and [=range/end=] of the + associated with the [=navigable/active document=]. If the user makes + any modification to a selection, the user agent must create a + new range with suitable [=range/start=] and [=range/end=] of the range and associate the selection with this new range (not modify the existing range), and set update selection's direction to forwards if the @@ -934,17 +982,17 @@
selectstart
event
+ selectstart
event
When the user agent is about to associate a new range
newRange to the selection in response to a user
initiated action, the user agent must fire an event named
- selectstart
, which bubbles and is cancelable, at
- the [=boundary point/node=] associated with the boundary point
- of newRange's [=range/start=] prior to changing the
- selection if the selection was previously empty or the
- previously associated range was [=range/collapsed=].
+ selectstart
, which bubbles and is cancelable, at the
+ [=boundary point/node=] associated with the boundary point of
+ newRange's [=range/start=] prior to changing the selection
+ if the selection was previously empty or the previously
+ associated range was [=range/collapsed=].
If the event is canceled, the user agent must not change the @@ -957,26 +1005,32 @@
selectionchange
event
+ selectionchange
event
When the selection is dissociated with its range, associated with a new range, or the associated range's - boundary point is mutated either by the user or the content script, - the user agent must schedule a selectionchange event on document. + boundary point is mutated either by the user or the content + script, the user agent must schedule a selectionchange event + on document.
When an [^input^] or [^textarea^] element provide a text selection - and its selection changes (in either extent or [=direction=]), - the user agent must schedule a selectionchange event on the element. + and its selection changes (in either extent or [=direction=]), the + user agent must schedule a selectionchange event on the + element.
selectionhange
eventTo schedule a selectionchange event on a node target, run these steps:
+selectionhange
event
+ + To schedule a selectionchange event on a node + target, run these steps: +
selectionhange
eventselectionhange
eventTo fire a selectionchange event on a node target, run these steps:
+selectionhange
event
+ + To fire a selectionchange event on a node + target, run these steps: +
selectionchange
,
- which bubbles and not cancelable, at target.
+ selectionchange
, which bubbles and not cancelable, at
+ target.
selectionchange
,
- which does not bubble and not cancelable, at target.
+ selectionchange
, which does not bubble
+ and not cancelable, at target.
selectionhange
eventThis specification defines conformance criteria that apply to a single - product: the user agent that implements the - interfaces that it contains. + product: the user agent that implements the interfaces that it + contains.
- To mitigate potential privacy risks of exposing user's use of assistive technologies, for example, - user agent may elect to emulate mouse and keyboard events typically associated with - selectstart or selectionchange events when the user opts to modify the selection of a document. + To mitigate potential privacy risks of exposing user's use of assistive + technologies, for example, user agent may elect to emulate mouse + and keyboard events typically associated with selectstart or + selectionchange events when the user opts to modify the + selection of a document.