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.
How often is this feature used by web sites?
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).
Seems to come up on stack overflow a bit:
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.
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.
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:
It is a part of remote debugging protocol. We will make it public / documented some time soon, but it is already available.
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.
(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
Chrome Intent to Remove: getMatchedCSSRules()
Created attachment 326725 [details]
The content of attachment 326725 [details] has been deleted for the following reason:
Irrelevant attachment, likely spam or phishing.
Chrome and Firefox have both removed this. We should try to as well.
Created attachment 421100 [details]
(In reply to Sam Weinig from comment #15)
> Created attachment 421100 [details]
Removing this is going to be harder than I would have hoped. A few problems:
- Safari seems to be using it, we need to find out why and get them off of it.
- It seems we made getMatchedCSSRules public API in WebKitLegacy. While it is deprecated, it's not obsolete, so we likely need to keep it working there at least. I am curious if we can make an implementation that is less invaisive just for the Webkit Legacy case, but I am not super optimistic about it.
Created attachment 421101 [details]