RESOLVED FIXED72930
window.getMatchedCSSRules() not supporting pseudo element
https://bugs.webkit.org/show_bug.cgi?id=72930
Summary window.getMatchedCSSRules() not supporting pseudo element
Naveen Bobbili
Reported 2011-11-21 23:50:46 PST
What steps will reproduce the problem? 1. Create CSS rules that apply to an element (including pseudo-element selectors) 2. Call window.getMatchedCSSRules(domElement, pseudoElementString), with pseudoElementString corresponding to those used in step 1. What is the expected result? The method should return a rule list containing the rules with pseudo element/class selectors. What happens instead? It only returns a rule list with the non-pseudo element/class selectors. Please provide any additional information below. Attach a screenshot if possible. I've provided a html page which is a demo of the bug. Additionally, it would be very convenient to be able to call this method and have it return all rules applying to the passed element for all pseudo elements/classes in one call. Further, it would also be convenient to optionally return the rule list in order of selector specificity, or provide the specificity value as a part of the CSSRule object.
Attachments
Test case to reproduce the issue. (1.94 KB, text/html)
2011-11-22 20:41 PST, Naveen Bobbili
no flags
Proposed Patch (4.81 KB, patch)
2011-11-23 04:22 PST, Naveen Bobbili
no flags
Updated Patch (4.81 KB, patch)
2011-11-23 04:32 PST, Naveen Bobbili
no flags
Updated Patch (4.79 KB, patch)
2011-11-27 23:08 PST, Naveen Bobbili
no flags
Updated Patch (4.80 KB, patch)
2011-11-27 23:50 PST, Naveen Bobbili
no flags
Updated Patch (4.80 KB, patch)
2011-11-28 21:05 PST, Naveen Bobbili
no flags
Updated Patch (4.62 KB, patch)
2011-11-29 21:08 PST, Naveen Bobbili
no flags
Naveen Bobbili
Comment 1 2011-11-22 20:41:20 PST
Created attachment 116310 [details] Test case to reproduce the issue.
Naveen Bobbili
Comment 2 2011-11-22 20:43:37 PST
Naveen Bobbili
Comment 3 2011-11-23 04:22:26 PST
Created attachment 116344 [details] Proposed Patch Modified DOMWindow::getMatchedCSSRules() for getting the CSS Rules of pseudo elements.
WebKit Review Bot
Comment 4 2011-11-23 04:24:35 PST
Attachment 116344 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/fast..." exit_code: 1 LayoutTests/ChangeLog:5: Line contains tab character. [whitespace/tab] [5] Total errors found: 1 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Naveen Bobbili
Comment 5 2011-11-23 04:32:04 PST
Created attachment 116345 [details] Updated Patch Fixed Style.
Naveen Bobbili
Comment 6 2011-11-27 23:08:51 PST
Created attachment 116701 [details] Updated Patch As per review comments.
Ryosuke Niwa
Comment 7 2011-11-27 23:29:26 PST
Comment on attachment 116701 [details] Updated Patch View in context: https://bugs.webkit.org/attachment.cgi?id=116701&action=review > Source/WebCore/ChangeLog:9 > + Reviewed by NOBODY (OOPS!). This line should appear before the description ("Added functionality to retrieve CSS rules of psuedo elements using getMatchedCSSRules.") followed by a blank line. See other entries. > Source/WebCore/page/DOMWindow.cpp:1355 > +PassRefPtr<CSSRuleList> DOMWindow::getMatchedCSSRules(Element* element, const String& pseudoElt, bool authorOnly) const Please don't use abbreviations like Elt. Spell out Element.
Naveen Bobbili
Comment 8 2011-11-27 23:50:02 PST
Created attachment 116705 [details] Updated Patch As per review comments.
Simon Fraser (smfr)
Comment 9 2011-11-28 11:48:07 PST
Comment on attachment 116705 [details] Updated Patch View in context: https://bugs.webkit.org/attachment.cgi?id=116705&action=review > Source/WebCore/page/DOMWindow.cpp:1370 > + return m_frame->document()->styleSelector()->pseudoStyleRulesForElement(element, pseudoId, rulesToInclude); Is there any benefit to the old code path when pseudoElement is empty? > LayoutTests/fast/dom/Window/getMatchedCSSRules-with-pseudo-elements.html:22 > +var cssText = "border-top-width: 1pxborder-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-style: initial; border-color: initial; border-image: initial;" Is there a missing semicolon at "1pxborder"?
Naveen Bobbili
Comment 10 2011-11-28 20:58:09 PST
(In reply to comment #9) > (From update of attachment 116705 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=116705&action=review > > > Source/WebCore/page/DOMWindow.cpp:1370 > > + return m_frame->document()->styleSelector()->pseudoStyleRulesForElement(element, pseudoId, rulesToInclude); > > Is there any benefit to the old code path when pseudoElement is empty? > No there is no change. The empty pseudoElement still returns the same value. > > LayoutTests/fast/dom/Window/getMatchedCSSRules-with-pseudo-elements.html:22 > > +var cssText = "border-top-width: 1pxborder-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-style: initial; border-color: initial; border-image: initial;" > > Is there a missing semicolon at "1pxborder"? Yes there is. I will fix it and upload the patch.
Naveen Bobbili
Comment 11 2011-11-28 21:05:35 PST
Created attachment 116881 [details] Updated Patch Fixed Review comments.
Simon Fraser (smfr)
Comment 12 2011-11-29 12:43:30 PST
Comment on attachment 116881 [details] Updated Patch View in context: https://bugs.webkit.org/attachment.cgi?id=116881&action=review > LayoutTests/fast/dom/Window/getMatchedCSSRules-with-pseudo-elements.html:19 > +var styled = document.getElementById('div1'); 'styled' doesn't reflect what this variable represents. > LayoutTests/fast/dom/Window/getMatchedCSSRules-with-pseudo-elements.html:22 > +var cssText = "border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-style: initial; border-color: initial; border-image: initial;" This doesn't appear to be used.
Naveen Bobbili
Comment 13 2011-11-29 21:08:28 PST
Created attachment 117114 [details] Updated Patch Fixed Review comments.
Darin Adler
Comment 14 2011-11-30 12:33:43 PST
Comment on attachment 117114 [details] Updated Patch Would be better if the test case had more coverage.
WebKit Review Bot
Comment 15 2011-11-30 18:54:04 PST
Comment on attachment 117114 [details] Updated Patch Clearing flags on attachment: 117114 Committed r101587: <http://trac.webkit.org/changeset/101587>
WebKit Review Bot
Comment 16 2011-11-30 18:54:09 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.