Bug 110750

Summary: Web Inspector: CSS.styleSheetChanged before @import rules are loaded
Product: WebKit Reporter: Timothy Hatcher <timothy>
Component: Web InspectorAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: apavlov, graouts, hyatt, inspector-bugzilla-changes, keishi, koivisto, loislo, pfeldman, pmuellr, simon.fraser, vsevik, web-inspector-bugs, webkit-bug-importer, yurys
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Test Case
none
Protocol Dump none

Timothy Hatcher
Reported 2013-02-25 05:22:58 PST
Created attachment 190039 [details] Test Case When editing a stylesheet text, the styleSheetChanged event fires before imported stylesheets are loaded. Normally this would be fine; however, calling CSS.getMatchedStylesForNode in response to the styleSheetChanged event results in a blank response. Calling after the Network.loadingFinished event for the imported stylesheet results in the expected matched rules. First saw this on daringfireball.net editing fireball_screen.css, which @imports fireball_fontsize.php and fireball_unicode.css. Here is an attached test case that imports fireball_fontsize.php. If you edit background-color in the attached test, the color applies right away but you can't get the parsed rules until after the imports load. I would expect rules to return no matter what the loading status is, since the background-color edit applies instantly. Also attached is a protocol dump showing the order of operations (with some irrelevant layer tree messages removed and some blank lines added for clarity).
Attachments
Test Case (113 bytes, text/html)
2013-02-25 05:22 PST, Timothy Hatcher
no flags
Protocol Dump (5.17 KB, text/plain)
2013-02-25 05:23 PST, Timothy Hatcher
no flags
Timothy Hatcher
Comment 1 2013-02-25 05:23:20 PST
Created attachment 190040 [details] Protocol Dump
Timothy Hatcher
Comment 2 2013-02-25 05:35:53 PST
Either the rules need to be available immediately, or we need a separate event that fires when they are (which would normally fire right after styleSheetChanged when there are no @import rules.)
Timothy Hatcher
Comment 3 2013-02-25 06:41:41 PST
The fact that user agent rules and rules from other stylesheets are not included is odd too.
Alexander Pavlov (apavlov)
Comment 4 2013-02-26 07:16:48 PST
According to Antti, StyleResolver::styleRulesForElement() should return the set of rules currently matching the element, without waiting for the @imports to load.
Alexander Pavlov (apavlov)
Comment 5 2013-02-27 07:31:28 PST
The root cause: PassRefPtr<CSSRuleList> StyleResolver::pseudoStyleRulesForElement(Element* e, PseudoId pseudoId, unsigned rulesToInclude) { if (!e || !e->document()->haveStylesheetsLoaded()) return 0; ... Antti, any ideas? Is it safe to just remove the second part of this check?
Timothy Hatcher
Comment 6 2013-04-18 07:41:35 PDT
Antti, Hyatt, Simon, thoughts?
Radar WebKit Bug Importer
Comment 7 2014-12-01 14:03:47 PST
Note You need to log in before you can comment on or make changes to this bug.