Intent to Implement and Ship: StaticRange constructor

110 views
Skip to first unread message

Sanket Joshi (Edge)

unread,
Jan 25, 2021, 3:32:11 PM1/25/21
to blink-dev, mason...@chromium.org, tk...@chromium.org, chri...@chromium.org
Contact emails
ffi...@microsoft.comsa...@microsoft.compc...@microsoft.com

Explainer
None

Specification
Currently, Range is the only constructible range type available to web authors. However, Range objects are "live", meaning that DOM mutations will not invalidate them and they will adjust themselves whenever the content they represent is changed. Updating these live ranges can be expensive. For every tree change, all affected Range objects need to be updated. Even if the application is uninterested in some live ranges, it still has to pay the cost of keeping them up-to-date when a mutation occurs.

StaticRange objects, on the other hand, are not live. They represent a lightweight range type that is not subject to the same maintenance cost as live ranges. By making StaticRange constructible, we will allow web authors to use them for ranges that do not need to be updated on every DOM tree change.

Blink component
Blink>DOM

Search tags
StaticRange

TAG review
None

TAG review status
Not applicable

Risks
None

Interoperability and Compatibility

Gecko: Shipped.

Edge: Public support (will ship whenever it is implemented in Chromium).

WebKit: Shipped.

Web developers: No signals


Is this feature fully tested by web-platform-tests?
Yes

Tracking bug
https://crbug.com/1170482

Link to entry on the Chrome Platform Status

Philip Jägenstedt

unread,
Jan 25, 2021, 3:55:46 PM1/25/21
to Sanket Joshi (Edge), blink-dev, mason...@chromium.org, tk...@chromium.org, chri...@chromium.org
LGTM1

This makes a lot of sense, especially given that the AbstractRange superclass recently shipped as well. It looks like the tests for this are in StaticRange-constructor.html, and all passes in Firefox and Safari. Matching that is clearly sensible.

Happily, it looks like it will be possible to detect support for this, by checking StaticRange.length. It is now 0 in Chromium, but should be 1 after this change, as it is in Firefox and Safari.

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/3a066b57-5a03-481c-8fa9-c6e659f61693n%40chromium.org.

Chris Harrelson

unread,
Jan 25, 2021, 4:00:41 PM1/25/21
to Philip Jägenstedt, Sanket Joshi (Edge), blink-dev, mason...@chromium.org, tk...@chromium.org

Manuel Rego Casasnovas

unread,
Jan 26, 2021, 6:36:03 AM1/26/21
to blin...@chromium.org
LGTM3

On 25/01/2021 22:00, Chris Harrelson wrote:
> LGTM2
>
> On Mon, Jan 25, 2021 at 12:55 PM Philip Jägenstedt <foo...@chromium.org
> <mailto:foo...@chromium.org>> wrote:
>
> LGTM1
>
> This makes a lot of sense, especially given that the AbstractRange
> superclass
> <https://groups.google.com/a/chromium.org/g/blink-dev/c/h9AyVUx7M7M/m/NUrQd9DRBwAJ> recently
> shipped as well. It looks like the tests for this are in
> StaticRange-constructor.html
> <https://wpt.fyi/results/dom/ranges/StaticRange-constructor.html?run_id=5764625926717440&run_id=5693525561704448&run_id=5767954660589568&run_id=5704744083390464>,
> and all passes in Firefox and Safari. Matching that is clearly sensible.
>
> Happily, it looks like it will be possible to detect support for
> this, by checking StaticRange.length. It is now 0 in Chromium, but
> should be 1 after this change, as it is in Firefox and Safari.
>
> On Mon, Jan 25, 2021 at 9:32 PM 'Sanket Joshi (Edge)' via blink-dev
> <blin...@chromium.org <mailto:blin...@chromium.org>> wrote:
>
> *Contact emails*
> ffi...@microsoft.com <mailto:ffi...@microsoft.com>,
> sa...@microsoft.com <mailto:sa...@microsoft.com>,
> pc...@microsoft.com <mailto:pc...@microsoft.com>
>
> *Explainer*
> None
>
> *Specification*
> https://dom.spec.whatwg.org/#interface-staticrange
> <https://dom.spec.whatwg.org/#interface-staticrange>
>
> *Summary*
> Currently, Range is the only constructible range type available
> to web authors. However, Range objects are "live", meaning that
> DOM mutations will not invalidate them and they will adjust
> themselves whenever the content they represent is changed.
> Updating these live ranges can be expensive. For every tree
> change, all affected Range objects need to be updated. Even if
> the application is uninterested in some live ranges, it still
> has to pay the cost of keeping them up-to-date when a mutation
> occurs.
>
> StaticRange objects, on the other hand, are not live. They
> represent a lightweight range type that is not subject to the
> same maintenance cost as live ranges. By
> making StaticRange constructible, we will allow web authors to
> use them for ranges that do not need to be updated on every DOM
> tree change.
>
> *Blink component*
> Blink>DOM
> <https://bugs.chromium.org/p/chromium/issues/list?q=component:Blink%3EDOM>
>
> *Search tags*
> StaticRange <https://chromestatus.com/features#tags:StaticRange>
>
> *TAG review*
> None
>
> *TAG review status*
> Not applicable
>
> *Risks*
> None
>
> *Interoperability and Compatibility*
>
> /Gecko/: Shipped.
>
> /Edge/: Public support (will ship whenever it is implemented in
> Chromium).
>
> /WebKit/: Shipped.
>
> /Web developers/: No signals
>
>
> Is this feature fully tested by web-platform-tests
> <https://chromium.googlesource.com/chromium/src/+/master/docs/testing/web_platform_tests.md>?
> Yes
>
> Tracking bug
> https://crbug.com/992606
> <https://bugs.chromium.org/p/chromium/issues/detail?id=992606>
>
> Launch bug
> https://crbug.com/1170482
> <https://bugs.chromium.org/p/chromium/issues/detail?id=1170482>
>
> Link to entry on the Chrome Platform Status
> https://chromestatus.com/feature/5676695065460736
> <https://chromestatus.com/feature/5676695065460736>
>
> This intent message was generated by Chrome Platform Status
> <https://www.chromestatus.com/>.
>
> --
> You received this message because you are subscribed to the
> Google Groups "blink-dev" group.
> To unsubscribe from this group and stop receiving emails from
> it, send an email to blink-dev+...@chromium.org
> <mailto:blink-dev+...@chromium.org>.
> <https://groups.google.com/a/chromium.org/d/msgid/blink-dev/3a066b57-5a03-481c-8fa9-c6e659f61693n%40chromium.org?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "blink-dev" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to blink-dev+...@chromium.org
> <mailto:blink-dev+...@chromium.org>.
> To view this discussion on the web visit
> https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAARdPYcd42Ru_y_0f671r-N0%2BVu2MDdPTDMR%2BO_Fe3sQg74%2BAQ%40mail.gmail.com
> <https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAARdPYcd42Ru_y_0f671r-N0%2BVu2MDdPTDMR%2BO_Fe3sQg74%2BAQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "blink-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to blink-dev+...@chromium.org
> <mailto:blink-dev+...@chromium.org>.
> To view this discussion on the web visit
> https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAOMQ%2Bw_j73FEJYPa-Rr2zfX87vLMpiuWEdoD_BjXzsTsEG7uuA%40mail.gmail.com
> <https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAOMQ%2Bw_j73FEJYPa-Rr2zfX87vLMpiuWEdoD_BjXzsTsEG7uuA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages