Bug 79653

Summary: Remove getMatchedCSSRules
Product: WebKit Reporter: Antti Koivisto <koivisto>
Component: CSSAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: abarth, ap, cred+bugzilla, emilio, itbeenews, jmayhew, joethomas, kriomant, mitz, moz, oliver, pfeldman, shezbaig.wk, syoichi, tkaraszewski
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 83298    
Attachments:
Description Flags
chrome os none

Description Antti Koivisto 2012-02-27 02:32:31 PST
Based on comments in bug 35015, getMatchedCSSRules was implemented purely to support inspector but is no longer used by it. Supporting the feature is complicating CSSStyleSelector and will be even more problematic with the planned stylesheet refactoring. It should be removed.
Comment 1 Adam Barth 2012-02-27 11:02:41 PST
How often is this feature used by web sites?
Comment 2 Antti Koivisto 2012-02-27 11:29:47 PST
I can't imagine it having any real use cases in the web. It is an introspection API (a poor one, due to security constraints).
Comment 4 jmayhew 2012-05-14 13:51:57 PDT
We are using this API specifically so we can introspect CSS on DOM objects. Currently getMatchedCSSRules it is still unable to get rules for pseudo classes but we are working to have the spec updated to include this functionality. 

We would be able to get the functionality we want if the APIs that the web inspector uses were available to all web apps, but it appears that they are limited to use within the inspector windows. As a result our only option is to use getMatchedCSSRules. 

If this API is dropped we would need an API to take its place. Perhaps, the APIs the inspector uses could be opened up, or some chrome extension permissions could be added that open up use of those APIs to extensions.
Comment 5 Tyler Karaszewski 2012-06-07 11:59:42 PDT
We use this at Evernote in a very similar way to how it's mentioned in comment #4. We have an extension that uses it to do introspection on a page and retrieve that original style rules that apply to each element on that page.
Comment 6 Joe Nelson 2013-02-13 19:30:24 PST
If you remove this function please provide access to whatever API that the inspector uses.

Style introspection is very useful. I use it in my CSS refactoring tool:
https://github.com/begriffs/css-ratiocinator
Comment 7 Pavel Feldman 2013-02-13 22:37:33 PST
It is a part of remote debugging protocol. We will make it public / documented some time soon, but it is already available.
Comment 8 kriomant 2013-09-24 20:31:16 PDT
I use getMatchedCSSRules in my Chrome extension. Extension uses devtool panel, so using remote debugging protocol is not an option - as far as I know opening devtools will prevent extensions from using it.

So it will be good to have some method for extensions to introspect page styles. It would be even better if this method doesn't suffer from same-origin restriction. Currently I have to load and embed all stylesheets to work around it.
Comment 9 Oliver Hunt 2013-09-24 23:03:53 PDT
(In reply to comment #8)
> I use getMatchedCSSRules in my Chrome extension. Extension uses devtool panel, so using remote debugging protocol is not an option - as far as I know opening devtools will prevent extensions from using it.
> 
> So it will be good to have some method for extensions to introspect page styles. It would be even better if this method doesn't suffer from same-origin restriction. Currently I have to load and embed all stylesheets to work around it.

Chrome forked from webkit, so you are better off posting in their bug db
Comment 10 Antti Koivisto 2014-03-18 09:09:49 PDT
<rdar://problem/16354443>
Comment 11 j.j. 2017-08-24 05:41:21 PDT
Chrome Intent to Remove: getMatchedCSSRules()
https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/-_Al0I5Rm9Q
Comment 12 Azrael 2017-11-12 13:33:12 PST
Created attachment 326725 [details]
chrome os
Comment 13 Alexey Proskuryakov 2017-11-17 09:51:21 PST
The content of attachment 326725 [details] has been deleted for the following reason:

Irrelevant attachment, likely spam or phishing.