Intent to Deprecate and Remove: CSSCharsetRule

80 views
Skip to first unread message

Philip Jägenstedt

unread,
Nov 26, 2014, 7:56:07 AM11/26/14
to blink-dev, Simon Pieters

Primary eng (and PM) emails

phi...@opera.com


Summary

Remove the CSSCharsetRule interface so that @charset rules are no longer represented in CSSOM. The @charset syntax itself is not affected.


Motivation

In May, I added a UseCounter for CSSCharsetRule.encoding by request from Simon Pieters, following a blink-dev thread one year prior:

https://groups.google.com/a/chromium.org/d/msg/blink-dev/bWgRZOZKmbk/LZWpPb-ZHJUJ


Simon has summarized in the spec bug why he wants to remove it, and has flagged it in the spec:

https://www.w3.org/Bugs/Public/show_bug.cgi?id=27422#c3 

http://dev.w3.org/csswg/cssom/#the-csscharsetrule-interface


In Blink, CSSCharsetRule is in CSSStyleSheet.cssRules, but not in the "IE extension" CSSStyleSheet.rules. The existence of @charset shifts the indices by one, but this is not compensated for in the "IE extensions" addRule and deleteRule! Getting rid of CSSCharsetRule would eliminate the difference, making it easier to standardize these IE extensions if usage doesn't come down:

https://www.chromestatus.com/metrics/feature/timeline/popularity/219

https://www.chromestatus.com/metrics/feature/timeline/popularity/220

https://www.chromestatus.com/metrics/feature/timeline/popularity/221


Compatibility Risk

Content that accesses CSSStyleSheet.cssRules by a constant index instead of iteration could break. Since IE doesn't have CSSCharsetRule at all, this is already not reliable cross-browser.


CSSCharsetRule was added to WebKit in 2006:

It wasn't justified by Web compat AFAICT. The difference between cssRules and rules was introduced at this time.

Alternative implementation suggestion for web developers

Don't access cssRules by a constant index.


Don't look for CSSCharsetRule at cssRules[0], when it is created the encoding has already been sniffed and cannot be changed.


Don't switch to CSSCharsetRule.rules/addRule/removeRule to avoid the change in behavior, those are non-standard and not supported by Gecko.


Usage information from UseCounter

https://www.chromestatus.com/metrics/feature/timeline/popularity/426


That's 0%, it's reached 0.0001% only 4 days so far.


Entry on chromestatus.com, crbug.com, or MDN

https://developer.mozilla.org/es/docs/DOM/CssRule#CSSCharsetRule (no real info)


Requesting approval to remove too?

Yes. Deprecating
CSSCharsetRule.encoding is pointless because it's virtually unused, and warning about any access to CSSCharsetRule will have false positives when people iterate all rules. We can always revert if it doesn't work out.

Chris Harrelson

unread,
Nov 26, 2014, 11:36:03 AM11/26/14
to Philip Jägenstedt, blink-dev, Simon Pieters
Took me a little while to grok the proposal, but:

LGTM

To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.

Philip Jägenstedt

unread,
Nov 26, 2014, 1:39:56 PM11/26/14
to Chris Harrelson, blink-dev, Simon Pieters
https://codereview.chromium.org/756313002/ is what I intent to land, that might make it more concrete.

Philip

Douglas Stockwell

unread,
Nov 26, 2014, 9:25:18 PM11/26/14
to Chris Harrelson, Philip Jägenstedt, blink-dev, Simon Pieters
+1, sounds like this API is entirely useless and effectively unused.

- Doug

Philip Rogers

unread,
Dec 2, 2014, 12:38:54 AM12/2/14
to Douglas Stockwell, Chris Harrelson, Philip Jägenstedt, blink-dev, Simon Pieters
LGTM.

TAMURA, Kent

unread,
Dec 2, 2014, 3:01:25 AM12/2/14
to Philip Rogers, Douglas Stockwell, Chris Harrelson, Philip Jägenstedt, blink-dev, Simon Pieters
LGTM3

--
TAMURA Kent
Software Engineer, Google


Philip Jägenstedt

unread,
Dec 2, 2014, 4:27:44 AM12/2/14
to TAMURA, Kent, Philip Rogers, Douglas Stockwell, Chris Harrelson, blink-dev, Simon Pieters
Thanks all, this removal is now tracked by https://code.google.com/p/chromium/issues/detail?id=438147
Reply all
Reply to author
Forward
0 new messages