Changeset 89822 in webkit


Ignore:
Timestamp:
Jun 27, 2011 8:33:56 AM (13 years ago)
Author:
apavlov@chromium.org
Message:

2011-06-27 Alexander Pavlov <apavlov@chromium.org>

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:
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r89816 r89822  
     12011-06-27  Alexander Pavlov  <apavlov@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: Change the inspector model API and backend to allow CSS pseudoclass inspection
     6        https://bugs.webkit.org/show_bug.cgi?id=63446
     7
     8        * inspector/styles/get-set-stylesheet-text.html:
     9        * inspector/styles/styles-new-API.html:
     10        * inspector/styles/styles-source-offsets.html:
     11
    1122011-06-27  Pavel Feldman  <pfeldman@google.com>
    213
  • trunk/LayoutTests/inspector/styles/get-set-stylesheet-text.html

    r83962 r89822  
    7171        function nodeCallback(node)
    7272        {
    73             CSSAgent.getStylesForNode(node.id, callback);
     73            CSSAgent.getStylesForNode(node.id, undefined, callback);
    7474        }
    7575
  • trunk/LayoutTests/inspector/styles/styles-new-API.html

    r83962 r89822  
    5555        {
    5656            bodyId = node.id;
    57             CSSAgent.getStylesForNode(bodyId, callback);
     57            CSSAgent.getStylesForNode(bodyId, undefined, callback);
    5858        }
    5959        InspectorTest.selectNodeWithId("mainBody", nodeCallback);
     
    8080        function nodeCallback(node)
    8181        {
    82             CSSAgent.getStylesForNode(node.id, callback);
     82            CSSAgent.getStylesForNode(node.id, undefined, callback);
    8383        }
    8484        InspectorTest.nodeWithId("thetable", nodeCallback);
     
    175175                return;
    176176            }
    177             CSSAgent.getStylesForNode(bodyId, didGetStyles);
     177            CSSAgent.getStylesForNode(bodyId, undefined, didGetStyles);
    178178        }
    179179
     
    243243        function nodeCallback(node)
    244244        {
    245             CSSAgent.getStylesForNode(node.id, stylesCallback);
     245            CSSAgent.getStylesForNode(node.id, undefined, stylesCallback);
    246246        }
    247247        InspectorTest.nodeWithId("toggle", nodeCallback);
  • trunk/LayoutTests/inspector/styles/styles-source-offsets.html

    r84148 r89822  
    3838    function step1(node)
    3939    {
    40         CSSAgent.getStylesForNode(node.id, step2);
     40        CSSAgent.getStylesForNode(node.id, undefined, step2);
    4141    }
    4242
  • trunk/Source/WebCore/ChangeLog

    r89815 r89822  
     12011-06-27  Alexander Pavlov  <apavlov@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: Change the inspector model API and backend to allow CSS pseudoclass inspection
     6        https://bugs.webkit.org/show_bug.cgi?id=63446
     7
     8        * inspector/Inspector.json:
     9        * inspector/InspectorCSSAgent.cpp:
     10        (WebCore::computePseudoClassMask):
     11        (WebCore::InspectorCSSAgent::getStylesForNode):
     12        * inspector/InspectorCSSAgent.h:
     13        * inspector/front-end/AuditRules.js:
     14        (WebInspector.AuditRules.ImageDimensionsRule.prototype.doRun.getStyles):
     15        * inspector/front-end/CSSStyleModel.js:
     16        (WebInspector.CSSStyleModel.prototype.getStylesAsync):
     17        * inspector/front-end/StylesSidebarPane.js:
     18        (WebInspector.StylesSidebarPane.prototype.update):
     19
    1202011-06-27  Pavel Feldman  <pfeldman@google.com>
    221
  • trunk/Source/WebCore/inspector/Inspector.json

    r89652 r89822  
    12241224                "name": "getStylesForNode",
    12251225                "parameters": [
    1226                     { "name": "nodeId", "type": "integer" }
     1226                    { "name": "nodeId", "type": "integer" },
     1227                    { "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." }
    12271228                ],
    12281229                "returns": [
  • trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp

    r89224 r89822  
    131131namespace WebCore {
    132132
     133static unsigned computePseudoClassMask(InspectorArray* pseudoClassArray)
     134{
     135    DEFINE_STATIC_LOCAL(String, active, ("active"));
     136    DEFINE_STATIC_LOCAL(String, hover, ("hover"));
     137    DEFINE_STATIC_LOCAL(String, focus, ("focus"));
     138    DEFINE_STATIC_LOCAL(String, visited, ("visited"));
     139    if (!pseudoClassArray || !pseudoClassArray->length())
     140        return CSSStyleSelector::DoNotForcePseudoClassMask;
     141
     142    unsigned result = CSSStyleSelector::ForceNone;
     143    for (size_t i = 0; i < pseudoClassArray->length(); ++i) {
     144        RefPtr<InspectorValue> pseudoClassValue = pseudoClassArray->get(i);
     145        String pseudoClass;
     146        bool success = pseudoClassValue->asString(&pseudoClass);
     147        if (!success)
     148            continue;
     149        if (pseudoClass == active)
     150            result |= CSSStyleSelector::ForceActive;
     151        else if (pseudoClass == hover)
     152            result |= CSSStyleSelector::ForceHover;
     153        else if (pseudoClass == focus)
     154            result |= CSSStyleSelector::ForceFocus;
     155        else if (pseudoClass == visited)
     156            result |= CSSStyleSelector::ForceVisited;
     157    }
     158
     159    return result;
     160}
     161
    133162// static
    134163CSSStyleSheet* InspectorCSSAgent::parentStyleSheet(StyleBase* styleBase)
     
    183212}
    184213
    185 void InspectorCSSAgent::getStylesForNode(ErrorString* errorString, int nodeId, RefPtr<InspectorObject>* result)
     214void InspectorCSSAgent::getStylesForNode(ErrorString* errorString, int nodeId, const PassRefPtr<InspectorArray>* forcedPseudoClasses, PassRefPtr<InspectorObject>* result)
    186215{
    187216    Element* element = elementForId(errorString, nodeId);
     
    199228    resultObject->setObject("computedStyle", computedInspectorStyle->buildObjectForStyle());
    200229
     230    unsigned forcePseudoClassMask = computePseudoClassMask(forcedPseudoClasses->get());
    201231    CSSStyleSelector* selector = element->ownerDocument()->styleSelector();
    202     RefPtr<CSSRuleList> matchedRules = selector->styleRulesForElement(element, CSSStyleSelector::AllCSSRules);
     232    RefPtr<CSSRuleList> matchedRules = selector->styleRulesForElement(element, CSSStyleSelector::AllCSSRules, forcePseudoClassMask);
    203233    resultObject->setArray("matchedCSSRules", buildArrayForRuleList(matchedRules.get()));
    204234
     
    207237    RefPtr<InspectorArray> pseudoElements = InspectorArray::create();
    208238    for (PseudoId pseudoId = FIRST_PUBLIC_PSEUDOID; pseudoId < AFTER_LAST_INTERNAL_PSEUDOID; pseudoId = static_cast<PseudoId>(pseudoId + 1)) {
    209         RefPtr<CSSRuleList> matchedRules = selector->pseudoStyleRulesForElement(element, pseudoId, CSSStyleSelector::AllCSSRules);
     239        RefPtr<CSSRuleList> matchedRules = selector->pseudoStyleRulesForElement(element, pseudoId, CSSStyleSelector::AllCSSRules, forcePseudoClassMask);
    210240        if (matchedRules && matchedRules->length()) {
    211241            RefPtr<InspectorObject> pseudoStyles = InspectorObject::create();
  • trunk/Source/WebCore/inspector/InspectorCSSAgent.h

    r89224 r89822  
    6262
    6363    void reset();
    64     void getStylesForNode(ErrorString*, int nodeId, RefPtr<InspectorObject>* result);
     64    void getStylesForNode(ErrorString*, int nodeId, const PassRefPtr<InspectorArray>* forcedPseudoClasses, PassRefPtr<InspectorObject>* result);
    6565    void getInlineStyleForNode(ErrorString*, int nodeId, RefPtr<InspectorObject>* style);
    6666    void getComputedStyleForNode(ErrorString*, int nodeId, RefPtr<InspectorObject>* style);
  • trunk/Source/WebCore/inspector/front-end/AuditRules.js

    r84909 r89822  
    713713        {
    714714            for (var i = 0; nodeIds && i < nodeIds.length; ++i)
    715                 WebInspector.cssModel.getStylesAsync(nodeIds[i], imageStylesReady.bind(this, nodeIds[i], i === nodeIds.length - 1));
     715                WebInspector.cssModel.getStylesAsync(nodeIds[i], undefined, imageStylesReady.bind(this, nodeIds[i], i === nodeIds.length - 1));
    716716        }
    717717
  • trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js

    r85324 r89822  
    4747
    4848WebInspector.CSSStyleModel.prototype = {
    49     getStylesAsync: function(nodeId, userCallback)
     49    getStylesAsync: function(nodeId, forcedPseudoClasses, userCallback)
    5050    {
    5151        function callback(userCallback, error, payload)
     
    9292        }
    9393
    94         CSSAgent.getStylesForNode(nodeId, callback.bind(null, userCallback));
     94        CSSAgent.getStylesForNode(nodeId, forcedPseudoClasses || [], callback.bind(null, userCallback));
    9595    },
    9696
  • trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js

    r89806 r89822  
    245245            WebInspector.cssModel.getComputedStyleAsync(node.id, computedStyleCallback.bind(this));
    246246        else
    247             WebInspector.cssModel.getStylesAsync(node.id, stylesCallback.bind(this));
     247            WebInspector.cssModel.getStylesAsync(node.id, undefined, stylesCallback.bind(this));
    248248    },
    249249
Note: See TracChangeset for help on using the changeset viewer.