Bug 79653

Summary: Remove getMatchedCSSRules
Product: WebKit Reporter: Antti Koivisto <koivisto>
Component: CSSAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, ap, cred+bugzilla, darin, emilio, itbeenews, jmayhew, joethomas, koivisto, kriomant, mitz, moz, oliver, pfeldman, sam, shezbaig.wk, syoichi, tkaraszewski
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=89240
Bug Depends on:    
Bug Blocks: 83298    
Attachments:
Description Flags
chrome os
none
Patch
none
Patch ews-feeder: commit-queue-

Antti Koivisto
Reported 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.
Attachments
chrome os (deleted)
2017-11-12 13:33 PST, Azrael
no flags
Patch (19.55 KB, patch)
2021-02-20 12:27 PST, Sam Weinig
no flags
Patch (17.76 KB, patch)
2021-02-20 12:32 PST, Sam Weinig
ews-feeder: commit-queue-
Adam Barth
Comment 1 2012-02-27 11:02:41 PST
How often is this feature used by web sites?
Antti Koivisto
Comment 2 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).
jmayhew
Comment 4 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.
Tyler Karaszewski
Comment 5 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.
Joe Nelson
Comment 6 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
Pavel Feldman
Comment 7 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.
kriomant
Comment 8 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.
Oliver Hunt
Comment 9 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
Antti Koivisto
Comment 10 2014-03-18 09:09:49 PDT
j.j.
Comment 11 2017-08-24 05:41:21 PDT
Azrael
Comment 12 2017-11-12 13:33:12 PST
Created attachment 326725 [details] chrome os
Alexey Proskuryakov
Comment 13 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.
Sam Weinig
Comment 14 2021-02-20 12:13:32 PST
Chrome and Firefox have both removed this. We should try to as well.
Sam Weinig
Comment 15 2021-02-20 12:27:06 PST
Sam Weinig
Comment 16 2021-02-20 12:30:26 PST
(In reply to Sam Weinig from comment #15) > Created attachment 421100 [details] > Patch 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.
Sam Weinig
Comment 17 2021-02-20 12:32:06 PST
Chris Dumez
Comment 18 2022-07-15 16:45:26 PDT
EWS
Comment 19 2022-07-16 14:49:58 PDT
Committed 252542@main (7d88064a3d12): <https://commits.webkit.org/252542@main> Reviewed commits have been landed. Closing PR #2479 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.