From 7c48fa51a1329a47bbe5ed919cf1ff03410e6ca1 Mon Sep 17 00:00:00 2001
From: Di Zhang
Date: Tue, 17 Dec 2024 15:38:38 -0800
Subject: [PATCH 1/7] Add definition for composed live range
---
dom.bs | 69 ++++++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 50 insertions(+), 19 deletions(-)
diff --git a/dom.bs b/dom.bs
index 8645c1ff..78ad3d66 100644
--- a/dom.bs
+++ b/dom.bs
@@ -22,6 +22,8 @@ urlPrefix: https://www.w3.org/TR/xml-names/#NT-
text: QName; url: QName
url: https://w3c.github.io/DOM-Parsing/#dom-range-createcontextualfragment
type: method; text: createContextualFragment(); for: Range
+url: https://w3c.github.io/selection-api/#dom-selection-getrangeat
+ type: method; text: getRangeAt(); for: Range
type: interface
url: https://w3c.github.io/touch-events/#idl-def-touchevent
text: TouchEvent
@@ -3034,6 +3036,14 @@ optional suppress observers flag, run these steps:
For each live range whose end node is an inclusive descendant
of node, set its end to (parent, index).
+
For each composed live range whose start node is a
+ shadow-including inclusive descendant of node, set its start to
+ (parent, index).
+
+
For each composed live range whose end node is an
+ shadow-including inclusive descendant of node, set its end to
+ (parent, index).
+
For each live range whose start node is parent and
start offset is greater than index, decrease its
start offset by 1.
@@ -5775,7 +5785,8 @@ are:
The createRange()
method steps are to return a new
-live range with (this, 0) as its start an end.
+{{Range}} live range with (this, 0) as its start and end.
The {{Range/Range()}} constructor can be used instead.
@@ -7910,11 +7921,11 @@ range.setEnd(secondText, 4)
node tree above cannot be represented by a range. Ranges are only useful for
nodes.
-
{{Range}} objects, unlike {{StaticRange}} objects, are affected by mutations to the
-node tree. Therefore they are also known as live ranges. Such mutations will not
-invalidate them and will try to ensure that it still represents the same piece of content.
-Necessarily, a live range might itself be modified as part of the mutation to the
-node tree when, e.g., part of the content it represents is mutated.
+
{{Range}} objects, unlike {{StaticRange}} objects, are affected by mutations to the node
+tree. Therefore they are live ranges. Such mutations will not invalidate them and will
+try to ensure that it still represents the same piece of content. Necessarily, a live range
+might itself be modified as part of the mutation to the node tree when, e.g., part of the
+content it represents is mutated.
See the insert and remove algorithms, the
{{Node/normalize()}} method, and the replace data and split
@@ -8141,12 +8152,22 @@ interface Range : AbstractRange {
};
-
Objects implementing the {{Range}} interface are known as
-live ranges.
+
A live range is a range that is affected by
+mutations to the node tree.
+
+Objects implementing the {{Range}} interface are live ranges.
Algorithms that modify a tree (in particular the insert,
remove, replace data, and split algorithms) modify
-live ranges associated with that tree.
+live ranges associated with that tree.
+
+A composed live range is a live range
+that has one associated {{Range}} object - cached live
+range.
+
+The cached live range is used to maintain backward compatibility with the
+{{getRangeAt}} API.
The root of a live range is the
root of its start node.
@@ -8216,7 +8237,7 @@ but not its end node, or vice versa.
range = new Range()
- - Returns a new live range.
+
- Returns a new {{Range}} live range.
The new Range()
constructor steps are
@@ -8281,6 +8302,10 @@ steps:
Set range's
start to bp.
+
+ If range is the associated cached live range of a composed live
+ range composed live range, set composed live range’s start to bp.
If these steps were invoked as "set the end"
@@ -8296,6 +8321,10 @@ steps:
Set range's
end to bp.
+
+ If range is the associated cached live range of a composed live range
+ composed live range, set composed live range’s end to
+ bp.
@@ -8576,8 +8605,8 @@ method steps are:
(new node, new offset).
-To a live range
-range, run these steps:
+
To a {{Range}} live
+range range, run these steps:
Let fragment be a new {{DocumentFragment}} node whose
@@ -8753,7 +8782,7 @@ method steps are:
- Append clone
to fragment.
-
- Let subrange be a new live range
+
- Let subrange be a new {{Range}} live range
whose start is
(original start node, original start offset) and
whose end is
@@ -8807,7 +8836,7 @@ method steps are:
- Append clone
to fragment.
-
- Let subrange be a new live range
+
- Let subrange be a new {{Range}} live range
whose start is
(last partially contained child, 0) and whose
end is
@@ -8832,7 +8861,7 @@ result of extracting this.
To
clone the contents
-of a live range range, run these steps:
+of a {{Range}} live range range, run these steps:
Let fragment be a new {{DocumentFragment}} node whose
@@ -8960,7 +8989,7 @@ of a live range range, run these steps:
- Append clone
to fragment.
-
- Let subrange be a new live range
+
- Let subrange be a new {{Range}} live range
whose start is
(original start node, original start offset) and
whose end is
@@ -9018,7 +9047,7 @@ of a live range range, run these steps:
- Append clone
to fragment.
-
- Let subrange be a new live range
+
- Let subrange be a new {{Range}} live range
whose start is
(last partially contained child, 0) and whose
end is
@@ -9038,7 +9067,7 @@ of a live range range, run these steps:
result of cloning the contents of this.
To insert a node
-node into a live range range, run these steps:
+node into a {{Range}} live range range, run these steps:
- If range's start node is a {{ProcessingInstruction}} or {{Comment}}
@@ -9188,7 +9217,8 @@ check first thing, which matches everyone but Firefox.
The cloneRange()
method steps are to return a new
-live range with the same start and end as this.
+{{Range}} live range with the same start and end as
+this.
The detach()
method steps are to do nothing.
Its functionality (disabling a {{Range}} object) was removed, but the method itself
@@ -10441,6 +10471,7 @@ David Håsäther,
David Hyatt,
Deepak Sherveghar,
Dethe Elza,
+Di Zhang,
Dimitri Glazkov,
Domenic Denicola,
Dominic Cooney,
From 487cac0e1782bedf0feae57e2bd9384bc89e1df5 Mon Sep 17 00:00:00 2001
From: Di Zhang
Date: Tue, 21 Jan 2025 14:26:06 -0800
Subject: [PATCH 2/7] Review, format changes
---
dom.bs | 58 +++++++++++++++++++++++++++-------------------------------
1 file changed, 27 insertions(+), 31 deletions(-)
diff --git a/dom.bs b/dom.bs
index 78ad3d66..c7265f4c 100644
--- a/dom.bs
+++ b/dom.bs
@@ -3040,7 +3040,7 @@ optional suppress observers flag, run these steps:
shadow-including inclusive descendant of node, set its start to
(parent, index).
- For each composed live range whose end node is an
+
For each composed live range whose end node is a
shadow-including inclusive descendant of node, set its end to
(parent, index).
@@ -5785,8 +5785,7 @@ are:
The createRange()
method steps are to return a new
-{{Range}} live range with (this, 0) as its start and end.
+{{Range}} object with (this, 0) as its start and end.
The {{Range/Range()}} constructor can be used instead.
@@ -7921,11 +7920,11 @@ range.setEnd(secondText, 4)
node tree above cannot be represented by a range. Ranges are only useful for
nodes.
-
{{Range}} objects, unlike {{StaticRange}} objects, are affected by mutations to the node
-tree. Therefore they are live ranges. Such mutations will not invalidate them and will
-try to ensure that it still represents the same piece of content. Necessarily, a live range
-might itself be modified as part of the mutation to the node tree when, e.g., part of the
-content it represents is mutated.
+
{{Range}} objects, unlike {{StaticRange}} objects, are affected by mutations to the
+node tree. Therefore they are live ranges. Such mutations will not invalidate them and
+will try to ensure that it still represents the same piece of content. Necessarily, a
+live range might itself be modified as part of the mutation to the node tree when,
+e.g., part of the content it represents is mutated.
See the insert and remove algorithms, the
{{Node/normalize()}} method, and the replace data and split
@@ -8162,12 +8161,11 @@ mutations to the node tree.
live ranges associated with that tree.
A composed live range is a live range
-that has one associated {{Range}} object - cached live
-range.
+that has one associated {{Range}} object —
+cached live range.
-The cached live range is used to maintain backward compatibility with the
-{{getRangeAt}} API.
+The cached live range is used to maintain backward
+compatibility with the {{getRangeAt}} API.
The root of a live range is the
root of its start node.
@@ -8237,7 +8235,7 @@ but not its end node, or vice versa.
range = new Range()
- - Returns a new {{Range}} live range.
+
- Returns a new {{Range}} object.
The new Range()
constructor steps are
@@ -8303,9 +8301,9 @@ steps:
Set range's
start to bp.
- If range is the associated cached live range of a composed live
- range composed live range, set composed live range’s start to bp.
+ If range is the cached live range of a
+ composed live range, set composed live range’s
+ start to bp.
If these steps were invoked as "set the end"
@@ -8322,9 +8320,9 @@ steps:
Set range's
end to bp.
- If range is the associated cached live range of a composed live range
- composed live range, set composed live range’s end to
- bp.
+ If range is the cached live range of a
+ composed live range, set composed live range’s
+ end to bp.
@@ -8605,8 +8603,8 @@ method steps are:
(new node, new offset).
-To a {{Range}} live
-range range, run these steps:
+
To a {{Range}} object
+range, run these steps:
Let fragment be a new {{DocumentFragment}} node whose
@@ -8782,8 +8780,7 @@ range range, run these steps:
- Append clone
to fragment.
-
- Let subrange be a new {{Range}} live range
- whose start is
+
- Let subrange be a new {{Range}} object whose start is
(original start node, original start offset) and
whose end is
(first partially contained child, first partially contained child's
@@ -8836,8 +8833,7 @@ range range, run these steps:
- Append clone
to fragment.
-
- Let subrange be a new {{Range}} live range
- whose start is
+
- Let subrange be a new {{Range}} object whose start is
(last partially contained child, 0) and whose
end is
(original end node, original end offset).
@@ -8861,7 +8857,7 @@ result of extracting this.
To
clone the contents
-of a {{Range}} live range range, run these steps:
+of a {{Range}} object range, run these steps:
Let fragment be a new {{DocumentFragment}} node whose
@@ -8989,7 +8985,7 @@ of a {{Range}} live range range, run these steps:
- Append clone
to fragment.
-
- Let subrange be a new {{Range}} live range
+
- Let subrange be a new {{Range}} object
whose start is
(original start node, original start offset) and
whose end is
@@ -9047,7 +9043,7 @@ of a {{Range}} live range range, run these steps:
- Append clone
to fragment.
-
- Let subrange be a new {{Range}} live range
+
- Let subrange be a new {{Range}} object
whose start is
(last partially contained child, 0) and whose
end is
@@ -9067,7 +9063,7 @@ of a {{Range}} live range range, run these steps:
result of cloning the contents of this.
To insert a node
-node into a {{Range}} live range range, run these steps:
+node into a {{Range}} object range, run these steps:
- If range's start node is a {{ProcessingInstruction}} or {{Comment}}
@@ -9217,7 +9213,7 @@ check first thing, which matches everyone but Firefox.
The cloneRange()
method steps are to return a new
-{{Range}} live range with the same start and end as
+{{Range}} object with the same start and end as
this.
The detach()
method steps are to do nothing.
From 461aed7b23b235b957edde2f7b6a277099c6e64d Mon Sep 17 00:00:00 2001
From: Di Zhang
Date: Thu, 23 Jan 2025 13:03:26 -0800
Subject: [PATCH 3/7] Fix collapse logic for set the start or end
---
dom.bs | 44 ++++++++++++++++++++++++++++++--------------
1 file changed, 30 insertions(+), 14 deletions(-)
diff --git a/dom.bs b/dom.bs
index c7265f4c..c28a0b51 100644
--- a/dom.bs
+++ b/dom.bs
@@ -8292,17 +8292,25 @@ steps:
- If range's
root is not equal to
node's root,
- or if bp is
- after the
- range's end, set
- range's end
+ set range's end
to bp.
+
- Otherwise, if bp is
+ after the
+ range's end,
+ set range's end
+ to bp. If range is the
+ cached live range of a
+ composed live range composed live range,
+ set composed live range’s
+ end to bp.
+
- Set range's
start to bp.
-
-
- If range is the cached live range of a
- composed live range, set composed live range’s
+ If range is the
+ cached live range of a
+ composed live range composed live range,
+ set composed live range’s
start to bp.
- If these steps were invoked as "set the end"
@@ -8311,17 +8319,25 @@ steps:
- If range's
root is not equal to
node's root,
- or if bp is
- before the
- range's start, set
- range's start
+ set range's start
to bp.
+
- Otherwise, if bp is
+ before the
+ range's start,
+ set range's start
+ to bp. If range is the
+ cached live range of a
+ composed live range composed live range,
+ set composed live range’s
+ start to bp.
+
- Set range's
end to bp.
-
-
- If range is the cached live range of a
- composed live range, set composed live range’s
+ If range is the
+ cached live range of a
+ composed live range composed live range,
+ set composed live range’s
end to bp.
From 413348dc0808a0cf7c0f28bbbf611d6dd2a6bf93 Mon Sep 17 00:00:00 2001
From: Di Zhang
Date: Fri, 24 Jan 2025 13:57:10 -0800
Subject: [PATCH 4/7] Fix for= typo
---
dom.bs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dom.bs b/dom.bs
index c28a0b51..e16bf655 100644
--- a/dom.bs
+++ b/dom.bs
@@ -8303,7 +8303,7 @@ steps:
cached live range of a
composed live range composed live range,
set composed live range’s
- end to bp.
+ end to bp.
Set range's
start to bp.
@@ -8311,7 +8311,7 @@ steps:
cached live range of a
composed live range composed live range,
set composed live range’s
- start to bp.
+ start to bp.
If these steps were invoked as "set the end"
@@ -8330,7 +8330,7 @@ steps:
cached live range of a
composed live range composed live range,
set composed live range’s
- start to bp.
+ start to bp.
Set range's
end to bp.
From c7f38b12bdcab4eb8f41d992b13674c0ffbafb6f Mon Sep 17 00:00:00 2001
From: Dominic Farolino
Date: Tue, 28 Jan 2025 10:34:31 -0500
Subject: [PATCH 5/7] Linking nit
---
dom.bs | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/dom.bs b/dom.bs
index e16bf655..c7b1c321 100644
--- a/dom.bs
+++ b/dom.bs
@@ -22,8 +22,6 @@ urlPrefix: https://www.w3.org/TR/xml-names/#NT-
text: QName; url: QName
url: https://w3c.github.io/DOM-Parsing/#dom-range-createcontextualfragment
type: method; text: createContextualFragment(); for: Range
-url: https://w3c.github.io/selection-api/#dom-selection-getrangeat
- type: method; text: getRangeAt(); for: Range
type: interface
url: https://w3c.github.io/touch-events/#idl-def-touchevent
text: TouchEvent
@@ -8165,7 +8163,7 @@ that has one associated {{Range}} object —
cached live range.
The cached live range is used to maintain backward
-compatibility with the {{getRangeAt}} API.
+compatibility with the {{Selection/getRangeAt()}} API.
The root of a live range is the
root of its start node.
From 1f74a51b1816b1d68181a08f128ece38beda2e7b Mon Sep 17 00:00:00 2001
From: Dominic Farolino
Date: Tue, 28 Jan 2025 10:40:09 -0500
Subject: [PATCH 6/7] Remove em dash to fix spacing in rendered spec
---
dom.bs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dom.bs b/dom.bs
index c7b1c321..7b83b0ff 100644
--- a/dom.bs
+++ b/dom.bs
@@ -8159,7 +8159,7 @@ mutations to the node tree.
live ranges associated with that tree.
A composed live range is a live range
-that has one associated {{Range}} object —
+that has an associated {{Range}} object, a
cached live range.
The cached live range is used to maintain backward
From f5b6935dd76af4618cec5b7f5762e5d738051819 Mon Sep 17 00:00:00 2001
From: Di Zhang
Date: Tue, 28 Jan 2025 15:52:21 -0800
Subject: [PATCH 7/7] Review changes: rename composed live range, improve
format of set the start/end algorithm
---
dom.bs | 74 ++++++++++++++++++++++++++++++++--------------------------
1 file changed, 41 insertions(+), 33 deletions(-)
diff --git a/dom.bs b/dom.bs
index 7b83b0ff..783c57f1 100644
--- a/dom.bs
+++ b/dom.bs
@@ -3034,11 +3034,11 @@ optional suppress observers flag, run these steps:
For each live range whose end node is an inclusive descendant
of node, set its end to (parent, index).
-
For each composed live range whose start node is a
+
For each composed selection range whose start node is a
shadow-including inclusive descendant of node, set its start to
(parent, index).
-
For each composed live range whose end node is a
+
For each composed selection range whose end node is a
shadow-including inclusive descendant of node, set its end to
(parent, index).
@@ -7919,10 +7919,10 @@ range.setEnd(secondText, 4)
nodes.
{{Range}} objects, unlike {{StaticRange}} objects, are affected by mutations to the
-node tree. Therefore they are live ranges. Such mutations will not invalidate them and
-will try to ensure that it still represents the same piece of content. Necessarily, a
-live range might itself be modified as part of the mutation to the node tree when,
-e.g., part of the content it represents is mutated.
+node tree. Therefore they are also known as live ranges. Such mutations will not
+invalidate them and will try to ensure that it still represents the same piece of content.
+Necessarily, a live range might itself be modified as part of the mutation to the
+node tree when, e.g., part of the content it represents is mutated.
See the insert and remove algorithms, the
{{Node/normalize()}} method, and the replace data and split
@@ -8158,12 +8158,12 @@ mutations to the node tree.
remove, replace data, and split algorithms) modify
live ranges associated with that tree.
-A composed live range is a live range
-that has an associated {{Range}} object, a
-cached live range.
+A composed selection range is a
+live range that has an associated {{Range}} object, a
+legacy selection range.
-The cached live range is used to maintain backward
-compatibility with the {{Selection/getRangeAt()}} API.
+The legacy selection range is used to maintain
+backward compatibility with the {{Selection/getRangeAt()}} API.
The root of a live range is the
root of its start node.
@@ -8282,6 +8282,12 @@ steps:
boundary point
(node, offset).
+
If range is the legacy selection range of a
+ composed selection range, set selection range to that
+ composed selection range.
+
+ Otherwise, set selection range to null.
+
- If these steps were invoked as "set the start"
@@ -8295,20 +8301,21 @@ steps:
- Otherwise, if bp is
after the
- range's end,
- set range's end
- to bp. If range is the
- cached live range of a
- composed live range composed live range,
- set composed live range’s
- end to bp.
+ range's end, then:
+
+ - Set range's end
+ to bp.
+
+
- If selection range is not null,
+ set selection range’s
+ end to bp.
+
- Set range's
start to bp.
- If range is the
- cached live range of a
- composed live range composed live range,
- set composed live range’s
+
+
- If selection range is not null,
+ set selection range’s
start to bp.
- If these steps were invoked as "set the end"
@@ -8322,20 +8329,21 @@ steps:
- Otherwise, if bp is
before the
- range's start,
- set range's start
- to bp. If range is the
- cached live range of a
- composed live range composed live range,
- set composed live range’s
- start to bp.
+ range's start, then:
+
+ - Set range's start
+ to bp.
+
+
- If selection range is not null,
+ set selection range’s
+ start to bp.
+
- Set range's
end to bp.
- If range is the
- cached live range of a
- composed live range composed live range,
- set composed live range’s
+
+
- If selection range is not null,
+ set selection range’s
end to bp.