Bug 72930 - window.getMatchedCSSRules() not supporting pseudo element
Summary: window.getMatchedCSSRules() not supporting pseudo element
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P1 Blocker
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-21 23:50 PST by Naveen Bobbili
Modified: 2011-11-30 18:54 PST (History)
12 users (show)

See Also:


Attachments
Test case to reproduce the issue. (1.94 KB, text/html)
2011-11-22 20:41 PST, Naveen Bobbili
no flags Details
Proposed Patch (4.81 KB, patch)
2011-11-23 04:22 PST, Naveen Bobbili
no flags Details | Formatted Diff | Diff
Updated Patch (4.81 KB, patch)
2011-11-23 04:32 PST, Naveen Bobbili
no flags Details | Formatted Diff | Diff
Updated Patch (4.79 KB, patch)
2011-11-27 23:08 PST, Naveen Bobbili
no flags Details | Formatted Diff | Diff
Updated Patch (4.80 KB, patch)
2011-11-27 23:50 PST, Naveen Bobbili
no flags Details | Formatted Diff | Diff
Updated Patch (4.80 KB, patch)
2011-11-28 21:05 PST, Naveen Bobbili
no flags Details | Formatted Diff | Diff
Updated Patch (4.62 KB, patch)
2011-11-29 21:08 PST, Naveen Bobbili
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Naveen Bobbili 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.
Comment 1 Naveen Bobbili 2011-11-22 20:41:20 PST
Created attachment 116310 [details]
Test case to reproduce the issue.
Comment 2 Naveen Bobbili 2011-11-22 20:43:37 PST
This is a chromium Bug
http://code.google.com/p/chromium/issues/detail?id=102599
Comment 3 Naveen Bobbili 2011-11-23 04:22:26 PST
Created attachment 116344 [details]
Proposed Patch

Modified DOMWindow::getMatchedCSSRules() for getting the CSS Rules of pseudo elements.
Comment 4 WebKit Review Bot 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.
Comment 5 Naveen Bobbili 2011-11-23 04:32:04 PST
Created attachment 116345 [details]
Updated Patch

Fixed Style.
Comment 6 Naveen Bobbili 2011-11-27 23:08:51 PST
Created attachment 116701 [details]
Updated Patch

As per review comments.
Comment 7 Ryosuke Niwa 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.
Comment 8 Naveen Bobbili 2011-11-27 23:50:02 PST
Created attachment 116705 [details]
Updated Patch

As per review comments.
Comment 9 Simon Fraser (smfr) 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"?
Comment 10 Naveen Bobbili 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.
Comment 11 Naveen Bobbili 2011-11-28 21:05:35 PST
Created attachment 116881 [details]
Updated Patch

Fixed Review comments.
Comment 12 Simon Fraser (smfr) 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.
Comment 13 Naveen Bobbili 2011-11-29 21:08:28 PST
Created attachment 117114 [details]
Updated Patch

Fixed Review comments.
Comment 14 Darin Adler 2011-11-30 12:33:43 PST
Comment on attachment 117114 [details]
Updated Patch

Would be better if the test case had more coverage.
Comment 15 WebKit Review Bot 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>
Comment 16 WebKit Review Bot 2011-11-30 18:54:09 PST
All reviewed patches have been landed.  Closing bug.