Title: [136948] trunk
Revision
136948
Author
[email protected]
Date
2012-12-07 05:22:52 -0800 (Fri, 07 Dec 2012)

Log Message

Web Inspector: the "Sources" column is always empty in CSS selector profiles
https://bugs.webkit.org/show_bug.cgi?id=104225

Reviewed by Pavel Feldman.

Source/WebCore:

r112923 and preceding changesets modified the CSSOM wrapper creation for StyleRules in a way
that would not specify the parent CSSStyleSheet for the CSSStyleRules created. Instead,
styleResolver->ensureFullCSSOMWrapperForInspector(rule) is now used to make sure the CSSStyleRule
has a valid parent CSSStyleSheet.

Test: inspector/profiler/selector-profiler-url.html

* css/StyleResolver.cpp:
(WebCore::StyleResolver::collectMatchingRulesForList):
(WebCore::StyleResolver::applyProperties):
* inspector/InspectorInstrumentation.cpp:
(WebCore):
(WebCore::InspectorInstrumentation::willMatchRuleImpl):
(WebCore::InspectorInstrumentation::willProcessRuleImpl):
* inspector/InspectorInstrumentation.h:
(WebCore):
(InspectorInstrumentation):
(WebCore::InspectorInstrumentation::willMatchRule):
(WebCore::InspectorInstrumentation::willProcessRule):

LayoutTests:

* inspector/profiler/selector-profiler-url-expected.txt: Added.
* inspector/profiler/selector-profiler-url.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (136947 => 136948)


--- trunk/LayoutTests/ChangeLog	2012-12-07 13:03:24 UTC (rev 136947)
+++ trunk/LayoutTests/ChangeLog	2012-12-07 13:22:52 UTC (rev 136948)
@@ -1,3 +1,13 @@
+2012-12-07  Alexander Pavlov  <[email protected]>
+
+        Web Inspector: the "Sources" column is always empty in CSS selector profiles
+        https://bugs.webkit.org/show_bug.cgi?id=104225
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/profiler/selector-profiler-url-expected.txt: Added.
+        * inspector/profiler/selector-profiler-url.html: Added.
+
 2012-12-07  Ilya Tikhonovsky  <[email protected]>
 
         Web Inspector: enable inspector tests on chromium-mac.

Added: trunk/LayoutTests/inspector/profiler/selector-profiler-url-expected.txt (0 => 136948)


--- trunk/LayoutTests/inspector/profiler/selector-profiler-url-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/profiler/selector-profiler-url-expected.txt	2012-12-07 13:22:52 UTC (rev 136948)
@@ -0,0 +1,5 @@
+Tests that CSS selector profile entries contain valid stylesheet URLs. Bug 104225.
+
+Value
+#input:focus stylesheet URL: inspector/profiler/selector-profiler-url.html
+

Added: trunk/LayoutTests/inspector/profiler/selector-profiler-url.html (0 => 136948)


--- trunk/LayoutTests/inspector/profiler/selector-profiler-url.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/profiler/selector-profiler-url.html	2012-12-07 13:22:52 UTC (rev 136948)
@@ -0,0 +1,63 @@
+<html>
+<head>
+<style>
+#input:focus {
+  color: green;
+}
+</style>
+<script src=""
+<script>
+
+function focus()
+{
+    document.getElementById("input").focus();
+    document.width;
+}
+
+function test()
+{
+    CSSAgent.startSelectorProfiler();
+    InspectorTest.evaluateInPage("focus()", step1);
+
+    function step1()
+    {
+        CSSAgent.stopSelectorProfiler(step2);
+    }
+
+    function step2(error, profile)
+    {
+        if (error) {
+            InspectorTest.addResult(error);
+            InspectorTest.completeTest();
+            return;
+        }
+
+        const selector = "#input:focus";
+        for (var i = 0; i < profile.data.length; ++i) {
+            var entry = profile.data[i];
+            if (entry.selector === selector) {
+                var segments = entry.url.split("/");
+                var url = ""
+                if (segments.length > 3) {
+                    segments.splice(0, segments.length - 3);
+                    url = ""
+                }
+                InspectorTest.addResult(selector + " stylesheet URL: " + url);
+                break;
+            }
+        }
+        InspectorTest.completeTest();
+    }
+}
+
+</script>
+</head>
+
+<body _onload_="runTest()">
+<p>
+Tests that CSS selector profile entries contain valid stylesheet URLs. <a href="" 104225</a>.
+</p>
+
+<input type="text" id="input">Value</input>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (136947 => 136948)


--- trunk/Source/WebCore/ChangeLog	2012-12-07 13:03:24 UTC (rev 136947)
+++ trunk/Source/WebCore/ChangeLog	2012-12-07 13:22:52 UTC (rev 136948)
@@ -1,3 +1,30 @@
+2012-12-07  Alexander Pavlov  <[email protected]>
+
+        Web Inspector: the "Sources" column is always empty in CSS selector profiles
+        https://bugs.webkit.org/show_bug.cgi?id=104225
+
+        Reviewed by Pavel Feldman.
+
+        r112923 and preceding changesets modified the CSSOM wrapper creation for StyleRules in a way
+        that would not specify the parent CSSStyleSheet for the CSSStyleRules created. Instead,
+        styleResolver->ensureFullCSSOMWrapperForInspector(rule) is now used to make sure the CSSStyleRule
+        has a valid parent CSSStyleSheet.
+
+        Test: inspector/profiler/selector-profiler-url.html
+
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::collectMatchingRulesForList):
+        (WebCore::StyleResolver::applyProperties):
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore):
+        (WebCore::InspectorInstrumentation::willMatchRuleImpl):
+        (WebCore::InspectorInstrumentation::willProcessRuleImpl):
+        * inspector/InspectorInstrumentation.h:
+        (WebCore):
+        (InspectorInstrumentation):
+        (WebCore::InspectorInstrumentation::willMatchRule):
+        (WebCore::InspectorInstrumentation::willProcessRule):
+
 2012-12-05  Antonio Gomes  <[email protected]>
 
         Rework bug 97927 to not depend on RenderLayer::allowsScrolling

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (136947 => 136948)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2012-12-07 13:03:24 UTC (rev 136947)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2012-12-07 13:22:52 UTC (rev 136948)
@@ -847,7 +847,7 @@
             continue;
 
         StyleRule* rule = ruleData.rule();
-        InspectorInstrumentationCookie cookie = InspectorInstrumentation::willMatchRule(document(), rule);
+        InspectorInstrumentationCookie cookie = InspectorInstrumentation::willMatchRule(document(), rule, this);
         if (checkSelector(ruleData, options.scope)) {
             // If the rule has no properties to apply, then ignore it in the non-debug mode.
             const StylePropertySet* properties = rule->properties();
@@ -2274,7 +2274,7 @@
 void StyleResolver::applyProperties(const StylePropertySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, bool filterRegionProperties)
 {
     ASSERT(!filterRegionProperties || m_regionForStyling);
-    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willProcessRule(document(), rule);
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willProcessRule(document(), rule, this);
 
     unsigned propertyCount = properties->propertyCount();
     for (unsigned i = 0; i < propertyCount; ++i) {

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (136947 => 136948)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2012-12-07 13:03:24 UTC (rev 136947)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2012-12-07 13:22:52 UTC (rev 136948)
@@ -64,6 +64,7 @@
 #include "ScriptArguments.h"
 #include "ScriptCallStack.h"
 #include "ScriptProfile.h"
+#include "StyleResolver.h"
 #include "StyleRule.h"
 #include "WorkerContext.h"
 #include "WorkerRuntimeAgent.h"
@@ -569,12 +570,12 @@
         resourceAgent->didScheduleStyleRecalculation(document);
 }
 
-InspectorInstrumentationCookie InspectorInstrumentation::willMatchRuleImpl(InstrumentingAgents* instrumentingAgents, const StyleRule* rule)
+InspectorInstrumentationCookie InspectorInstrumentation::willMatchRuleImpl(InstrumentingAgents* instrumentingAgents, StyleRule* rule, StyleResolver* styleResolver)
 {
     InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent();
     if (cssAgent) {
-        RefPtr<CSSRule> cssRule = rule->createCSSOMWrapper();
-        cssAgent->willMatchRule(static_cast<CSSStyleRule*>(cssRule.get()));
+        CSSStyleRule* cssRule = styleResolver->ensureFullCSSOMWrapperForInspector(rule);
+        cssAgent->willMatchRule(cssRule);
         return InspectorInstrumentationCookie(instrumentingAgents, 1);
     }
 
@@ -588,12 +589,12 @@
         cssAgent->didMatchRule(matched);
 }
 
-InspectorInstrumentationCookie InspectorInstrumentation::willProcessRuleImpl(InstrumentingAgents* instrumentingAgents, const StyleRule* rule)
+InspectorInstrumentationCookie InspectorInstrumentation::willProcessRuleImpl(InstrumentingAgents* instrumentingAgents, StyleRule* rule, StyleResolver* styleResolver)
 {
     InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent();
     if (cssAgent) {
-        RefPtr<CSSRule> cssRule = rule->createCSSOMWrapper();
-        cssAgent->willProcessRule(static_cast<CSSStyleRule*>(cssRule.get()));
+        CSSStyleRule* cssRule = styleResolver->ensureFullCSSOMWrapperForInspector(rule);
+        cssAgent->willProcessRule(cssRule);
         return InspectorInstrumentationCookie(instrumentingAgents, 1);
     }
 

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (136947 => 136948)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2012-12-07 13:03:24 UTC (rev 136947)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2012-12-07 13:22:52 UTC (rev 136948)
@@ -71,6 +71,7 @@
 class SecurityOrigin;
 class ShadowRoot;
 class StorageArea;
+class StyleResolver;
 class StyleRule;
 class ThreadableLoaderClient;
 class WorkerContext;
@@ -150,9 +151,9 @@
     static InspectorInstrumentationCookie willRecalculateStyle(Document*);
     static void didRecalculateStyle(const InspectorInstrumentationCookie&);
     static void didScheduleStyleRecalculation(Document*);
-    static InspectorInstrumentationCookie willMatchRule(Document*, const StyleRule*);
+    static InspectorInstrumentationCookie willMatchRule(Document*, StyleRule*, StyleResolver*);
     static void didMatchRule(const InspectorInstrumentationCookie&, bool matched);
-    static InspectorInstrumentationCookie willProcessRule(Document*, const StyleRule*);
+    static InspectorInstrumentationCookie willProcessRule(Document*, StyleRule*, StyleResolver*);
     static void didProcessRule(const InspectorInstrumentationCookie&);
 
     static void applyUserAgentOverride(Frame*, String*);
@@ -343,9 +344,9 @@
     static InspectorInstrumentationCookie willRecalculateStyleImpl(InstrumentingAgents*, Frame*);
     static void didRecalculateStyleImpl(const InspectorInstrumentationCookie&);
     static void didScheduleStyleRecalculationImpl(InstrumentingAgents*, Document*);
-    static InspectorInstrumentationCookie willMatchRuleImpl(InstrumentingAgents*, const StyleRule*);
+    static InspectorInstrumentationCookie willMatchRuleImpl(InstrumentingAgents*, StyleRule*, StyleResolver*);
     static void didMatchRuleImpl(const InspectorInstrumentationCookie&, bool matched);
-    static InspectorInstrumentationCookie willProcessRuleImpl(InstrumentingAgents*, const StyleRule*);
+    static InspectorInstrumentationCookie willProcessRuleImpl(InstrumentingAgents*, StyleRule*, StyleResolver*);
     static void didProcessRuleImpl(const InspectorInstrumentationCookie&);
 
     static void applyUserAgentOverrideImpl(InstrumentingAgents*, String*);
@@ -990,12 +991,12 @@
 #endif
 }
 
-inline InspectorInstrumentationCookie InspectorInstrumentation::willMatchRule(Document* document, const StyleRule* rule)
+inline InspectorInstrumentationCookie InspectorInstrumentation::willMatchRule(Document* document, StyleRule* rule, StyleResolver* styleResolver)
 {
 #if ENABLE(INSPECTOR)
     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
-        return willMatchRuleImpl(instrumentingAgents, rule);
+        return willMatchRuleImpl(instrumentingAgents, rule, styleResolver);
 #endif
     return InspectorInstrumentationCookie();
 }
@@ -1009,14 +1010,14 @@
 #endif
 }
 
-inline InspectorInstrumentationCookie InspectorInstrumentation::willProcessRule(Document* document, const StyleRule* rule)
+inline InspectorInstrumentationCookie InspectorInstrumentation::willProcessRule(Document* document, StyleRule* rule, StyleResolver* styleResolver)
 {
 #if ENABLE(INSPECTOR)
     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
     if (!rule)
         return InspectorInstrumentationCookie();
     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
-        return willProcessRuleImpl(instrumentingAgents, rule);
+        return willProcessRuleImpl(instrumentingAgents, rule, styleResolver);
 #endif
     return InspectorInstrumentationCookie();
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to