Title: [89822] trunk
Revision
89822
Author
[email protected]
Date
2011-06-27 08:33:56 -0700 (Mon, 27 Jun 2011)

Log Message

2011-06-27  Alexander Pavlov  <[email protected]>

        Reviewed by Pavel Feldman.

        Web Inspector: Change the inspector model API and backend to allow CSS pseudoclass inspection
        https://bugs.webkit.org/show_bug.cgi?id=63446

        WebCore:
        * inspector/Inspector.json:
        * inspector/InspectorCSSAgent.cpp:
        (WebCore::computePseudoClassMask):
        (WebCore::InspectorCSSAgent::getStylesForNode):
        * inspector/InspectorCSSAgent.h:
        * inspector/front-end/AuditRules.js:
        (WebInspector.AuditRules.ImageDimensionsRule.prototype.doRun.getStyles):
        * inspector/front-end/CSSStyleModel.js:
        (WebInspector.CSSStyleModel.prototype.getStylesAsync):
        * inspector/front-end/StylesSidebarPane.js:
        (WebInspector.StylesSidebarPane.prototype.update):

        LayoutTests:
        * inspector/styles/get-set-stylesheet-text.html:
        * inspector/styles/styles-new-API.html:
        * inspector/styles/styles-source-offsets.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (89821 => 89822)


--- trunk/LayoutTests/ChangeLog	2011-06-27 15:12:29 UTC (rev 89821)
+++ trunk/LayoutTests/ChangeLog	2011-06-27 15:33:56 UTC (rev 89822)
@@ -1,3 +1,14 @@
+2011-06-27  Alexander Pavlov  <[email protected]>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: Change the inspector model API and backend to allow CSS pseudoclass inspection
+        https://bugs.webkit.org/show_bug.cgi?id=63446
+
+        * inspector/styles/get-set-stylesheet-text.html:
+        * inspector/styles/styles-new-API.html:
+        * inspector/styles/styles-source-offsets.html:
+
 2011-06-27  Pavel Feldman  <[email protected]>
 
         Not reviewed: updating chromium expectations.

Modified: trunk/LayoutTests/inspector/styles/get-set-stylesheet-text.html (89821 => 89822)


--- trunk/LayoutTests/inspector/styles/get-set-stylesheet-text.html	2011-06-27 15:12:29 UTC (rev 89821)
+++ trunk/LayoutTests/inspector/styles/get-set-stylesheet-text.html	2011-06-27 15:33:56 UTC (rev 89822)
@@ -70,7 +70,7 @@
 
         function nodeCallback(node)
         {
-            CSSAgent.getStylesForNode(node.id, callback);
+            CSSAgent.getStylesForNode(node.id, undefined, callback);
         }
 
         InspectorTest.selectNodeWithId("inspected", nodeCallback);

Modified: trunk/LayoutTests/inspector/styles/styles-new-API.html (89821 => 89822)


--- trunk/LayoutTests/inspector/styles/styles-new-API.html	2011-06-27 15:12:29 UTC (rev 89821)
+++ trunk/LayoutTests/inspector/styles/styles-new-API.html	2011-06-27 15:33:56 UTC (rev 89822)
@@ -54,7 +54,7 @@
         function nodeCallback(node)
         {
             bodyId = node.id;
-            CSSAgent.getStylesForNode(bodyId, callback);
+            CSSAgent.getStylesForNode(bodyId, undefined, callback);
         }
         InspectorTest.selectNodeWithId("mainBody", nodeCallback);
     }
@@ -79,7 +79,7 @@
 
         function nodeCallback(node)
         {
-            CSSAgent.getStylesForNode(node.id, callback);
+            CSSAgent.getStylesForNode(node.id, undefined, callback);
         }
         InspectorTest.nodeWithId("thetable", nodeCallback);
     }
@@ -174,7 +174,7 @@
                 InspectorTest.addResult("error: " + error);
                 return;
             }
-            CSSAgent.getStylesForNode(bodyId, didGetStyles);
+            CSSAgent.getStylesForNode(bodyId, undefined, didGetStyles);
         }
 
         function ruleAdded(error, rule)
@@ -242,7 +242,7 @@
 
         function nodeCallback(node)
         {
-            CSSAgent.getStylesForNode(node.id, stylesCallback);
+            CSSAgent.getStylesForNode(node.id, undefined, stylesCallback);
         }
         InspectorTest.nodeWithId("toggle", nodeCallback);
     }

Modified: trunk/LayoutTests/inspector/styles/styles-source-offsets.html (89821 => 89822)


--- trunk/LayoutTests/inspector/styles/styles-source-offsets.html	2011-06-27 15:12:29 UTC (rev 89821)
+++ trunk/LayoutTests/inspector/styles/styles-source-offsets.html	2011-06-27 15:33:56 UTC (rev 89822)
@@ -37,7 +37,7 @@
 
     function step1(node)
     {
-        CSSAgent.getStylesForNode(node.id, step2);
+        CSSAgent.getStylesForNode(node.id, undefined, step2);
     }
 
     function step2(error, styles)

Modified: trunk/Source/WebCore/ChangeLog (89821 => 89822)


--- trunk/Source/WebCore/ChangeLog	2011-06-27 15:12:29 UTC (rev 89821)
+++ trunk/Source/WebCore/ChangeLog	2011-06-27 15:33:56 UTC (rev 89822)
@@ -1,3 +1,22 @@
+2011-06-27  Alexander Pavlov  <[email protected]>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: Change the inspector model API and backend to allow CSS pseudoclass inspection
+        https://bugs.webkit.org/show_bug.cgi?id=63446
+
+        * inspector/Inspector.json:
+        * inspector/InspectorCSSAgent.cpp:
+        (WebCore::computePseudoClassMask):
+        (WebCore::InspectorCSSAgent::getStylesForNode):
+        * inspector/InspectorCSSAgent.h:
+        * inspector/front-end/AuditRules.js:
+        (WebInspector.AuditRules.ImageDimensionsRule.prototype.doRun.getStyles):
+        * inspector/front-end/CSSStyleModel.js:
+        (WebInspector.CSSStyleModel.prototype.getStylesAsync):
+        * inspector/front-end/StylesSidebarPane.js:
+        (WebInspector.StylesSidebarPane.prototype.update):
+
 2011-06-27  Pavel Feldman  <[email protected]>
 
         Reviewed by Yury Semikhatsky.

Modified: trunk/Source/WebCore/inspector/Inspector.json (89821 => 89822)


--- trunk/Source/WebCore/inspector/Inspector.json	2011-06-27 15:12:29 UTC (rev 89821)
+++ trunk/Source/WebCore/inspector/Inspector.json	2011-06-27 15:33:56 UTC (rev 89822)
@@ -1223,7 +1223,8 @@
             {
                 "name": "getStylesForNode",
                 "parameters": [
-                    { "name": "nodeId", "type": "integer" }
+                    { "name": "nodeId", "type": "integer" },
+                    { "name": "forcedPseudoClasses", "type": "array", "items": { "type": "string", "enum": ["active", "focus", "hover", "visited"] }, "optional": true, "description": "Element pseudo classes to force when computing applicable style rules." }
                 ],
                 "returns": [
                     { "name": "styles", "$ref": "CSSNodeStyles", "description": "All styles for the specified DOM node." }

Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp (89821 => 89822)


--- trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp	2011-06-27 15:12:29 UTC (rev 89821)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp	2011-06-27 15:33:56 UTC (rev 89822)
@@ -130,6 +130,35 @@
 
 namespace WebCore {
 
+static unsigned computePseudoClassMask(InspectorArray* pseudoClassArray)
+{
+    DEFINE_STATIC_LOCAL(String, active, ("active"));
+    DEFINE_STATIC_LOCAL(String, hover, ("hover"));
+    DEFINE_STATIC_LOCAL(String, focus, ("focus"));
+    DEFINE_STATIC_LOCAL(String, visited, ("visited"));
+    if (!pseudoClassArray || !pseudoClassArray->length())
+        return CSSStyleSelector::DoNotForcePseudoClassMask;
+
+    unsigned result = CSSStyleSelector::ForceNone;
+    for (size_t i = 0; i < pseudoClassArray->length(); ++i) {
+        RefPtr<InspectorValue> pseudoClassValue = pseudoClassArray->get(i);
+        String pseudoClass;
+        bool success = pseudoClassValue->asString(&pseudoClass);
+        if (!success)
+            continue;
+        if (pseudoClass == active)
+            result |= CSSStyleSelector::ForceActive;
+        else if (pseudoClass == hover)
+            result |= CSSStyleSelector::ForceHover;
+        else if (pseudoClass == focus)
+            result |= CSSStyleSelector::ForceFocus;
+        else if (pseudoClass == visited)
+            result |= CSSStyleSelector::ForceVisited;
+    }
+
+    return result;
+}
+
 // static
 CSSStyleSheet* InspectorCSSAgent::parentStyleSheet(StyleBase* styleBase)
 {
@@ -182,7 +211,7 @@
     m_documentToInspectorStyleSheet.clear();
 }
 
-void InspectorCSSAgent::getStylesForNode(ErrorString* errorString, int nodeId, RefPtr<InspectorObject>* result)
+void InspectorCSSAgent::getStylesForNode(ErrorString* errorString, int nodeId, const PassRefPtr<InspectorArray>* forcedPseudoClasses, PassRefPtr<InspectorObject>* result)
 {
     Element* element = elementForId(errorString, nodeId);
     if (!element)
@@ -198,15 +227,16 @@
     RefPtr<InspectorStyle> computedInspectorStyle = InspectorStyle::create(InspectorCSSId(), computedStyleInfo, 0);
     resultObject->setObject("computedStyle", computedInspectorStyle->buildObjectForStyle());
 
+    unsigned forcePseudoClassMask = computePseudoClassMask(forcedPseudoClasses->get());
     CSSStyleSelector* selector = element->ownerDocument()->styleSelector();
-    RefPtr<CSSRuleList> matchedRules = selector->styleRulesForElement(element, CSSStyleSelector::AllCSSRules);
+    RefPtr<CSSRuleList> matchedRules = selector->styleRulesForElement(element, CSSStyleSelector::AllCSSRules, forcePseudoClassMask);
     resultObject->setArray("matchedCSSRules", buildArrayForRuleList(matchedRules.get()));
 
     resultObject->setArray("styleAttributes", buildArrayForAttributeStyles(element));
 
     RefPtr<InspectorArray> pseudoElements = InspectorArray::create();
     for (PseudoId pseudoId = FIRST_PUBLIC_PSEUDOID; pseudoId < AFTER_LAST_INTERNAL_PSEUDOID; pseudoId = static_cast<PseudoId>(pseudoId + 1)) {
-        RefPtr<CSSRuleList> matchedRules = selector->pseudoStyleRulesForElement(element, pseudoId, CSSStyleSelector::AllCSSRules);
+        RefPtr<CSSRuleList> matchedRules = selector->pseudoStyleRulesForElement(element, pseudoId, CSSStyleSelector::AllCSSRules, forcePseudoClassMask);
         if (matchedRules && matchedRules->length()) {
             RefPtr<InspectorObject> pseudoStyles = InspectorObject::create();
             pseudoStyles->setNumber("pseudoId", static_cast<int>(pseudoId));

Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.h (89821 => 89822)


--- trunk/Source/WebCore/inspector/InspectorCSSAgent.h	2011-06-27 15:12:29 UTC (rev 89821)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.h	2011-06-27 15:33:56 UTC (rev 89822)
@@ -61,7 +61,7 @@
     ~InspectorCSSAgent();
 
     void reset();
-    void getStylesForNode(ErrorString*, int nodeId, RefPtr<InspectorObject>* result);
+    void getStylesForNode(ErrorString*, int nodeId, const PassRefPtr<InspectorArray>* forcedPseudoClasses, PassRefPtr<InspectorObject>* result);
     void getInlineStyleForNode(ErrorString*, int nodeId, RefPtr<InspectorObject>* style);
     void getComputedStyleForNode(ErrorString*, int nodeId, RefPtr<InspectorObject>* style);
     void getAllStyleSheets(ErrorString*, RefPtr<InspectorArray>* styleSheetInfos);

Modified: trunk/Source/WebCore/inspector/front-end/AuditRules.js (89821 => 89822)


--- trunk/Source/WebCore/inspector/front-end/AuditRules.js	2011-06-27 15:12:29 UTC (rev 89821)
+++ trunk/Source/WebCore/inspector/front-end/AuditRules.js	2011-06-27 15:33:56 UTC (rev 89822)
@@ -712,7 +712,7 @@
         function getStyles(nodeIds)
         {
             for (var i = 0; nodeIds && i < nodeIds.length; ++i)
-                WebInspector.cssModel.getStylesAsync(nodeIds[i], imageStylesReady.bind(this, nodeIds[i], i === nodeIds.length - 1));
+                WebInspector.cssModel.getStylesAsync(nodeIds[i], undefined, imageStylesReady.bind(this, nodeIds[i], i === nodeIds.length - 1));
         }
 
         function onDocumentAvailable(root)

Modified: trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js (89821 => 89822)


--- trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js	2011-06-27 15:12:29 UTC (rev 89821)
+++ trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js	2011-06-27 15:33:56 UTC (rev 89822)
@@ -46,7 +46,7 @@
 }
 
 WebInspector.CSSStyleModel.prototype = {
-    getStylesAsync: function(nodeId, userCallback)
+    getStylesAsync: function(nodeId, forcedPseudoClasses, userCallback)
     {
         function callback(userCallback, error, payload)
         {
@@ -91,7 +91,7 @@
                 userCallback(result);
         }
 
-        CSSAgent.getStylesForNode(nodeId, callback.bind(null, userCallback));
+        CSSAgent.getStylesForNode(nodeId, forcedPseudoClasses || [], callback.bind(null, userCallback));
     },
 
     getComputedStyleAsync: function(nodeId, userCallback)

Modified: trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js (89821 => 89822)


--- trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js	2011-06-27 15:12:29 UTC (rev 89821)
+++ trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js	2011-06-27 15:33:56 UTC (rev 89822)
@@ -244,7 +244,7 @@
         if (refresh)
             WebInspector.cssModel.getComputedStyleAsync(node.id, computedStyleCallback.bind(this));
         else
-            WebInspector.cssModel.getStylesAsync(node.id, stylesCallback.bind(this));
+            WebInspector.cssModel.getStylesAsync(node.id, undefined, stylesCallback.bind(this));
     },
 
     _refreshUpdate: function(node, computedStyle, editedSection)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to