Changeset 56697 in webkit


Ignore:
Timestamp:
Mar 28, 2010 10:41:20 AM (14 years ago)
Author:
pfeldman@chromium.org
Message:

2010-03-28 Pavel Feldman <pfeldman@chromium.org>

Reviewed by Timothy Hatcher.

Web Inspector: Toggling style properties on/off does not always work.

https://bugs.webkit.org/show_bug.cgi?id=36720

  • inspector/InspectorController.cpp:
  • inspector/InspectorDOMAgent.cpp: (WebCore::InspectorDOMAgent::toggleStyleEnabled): (WebCore::InspectorDOMAgent::buildObjectForStyle): (WebCore::InspectorDOMAgent::buildArrayForDisabledStyleProperties):
  • inspector/InspectorDOMAgent.h:
  • inspector/front-end/DOMAgent.js: (WebInspector.CSSStyleDeclaration):
Location:
trunk/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r56696 r56697  
     12010-03-28  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Timothy Hatcher.
     4
     5        Web Inspector: Toggling style properties on/off does not always work.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=36720
     8
     9        * inspector/InspectorController.cpp:
     10        * inspector/InspectorDOMAgent.cpp:
     11        (WebCore::InspectorDOMAgent::toggleStyleEnabled):
     12        (WebCore::InspectorDOMAgent::buildObjectForStyle):
     13        (WebCore::InspectorDOMAgent::buildArrayForDisabledStyleProperties):
     14        * inspector/InspectorDOMAgent.h:
     15        * inspector/front-end/DOMAgent.js:
     16        (WebInspector.CSSStyleDeclaration):
     17
    1182010-03-28  Pavel Feldman  <pfeldman@chromium.org>
    219
  • trunk/WebCore/inspector/InspectorController.cpp

    r56670 r56697  
    5959#include "InspectorClient.h"
    6060#include "InspectorFrontendClient.h"
    61 #include "InspectorDOMAgent.h"
    6261#include "InspectorDOMStorageResource.h"
    6362#include "InspectorDatabaseResource.h"
  • trunk/WebCore/inspector/InspectorDOMAgent.cpp

    r56683 r56697  
    10021002    CSSStyleDeclaration* style = it->second.get();
    10031003
    1004     IdToStyleMap::iterator disabledIt = m_idToDisabledStyle.find(styleId);
     1004    IdToDisabledStyleMap::iterator disabledIt = m_idToDisabledStyle.find(styleId);
    10051005    if (disabledIt == m_idToDisabledStyle.end())
    1006         disabledIt = m_idToDisabledStyle.set(styleId, CSSMutableStyleDeclaration::create()).first;
    1007     CSSStyleDeclaration* disabledStyle = disabledIt->second.get();
     1006        disabledIt = m_idToDisabledStyle.set(styleId, DisabledStyleDeclaration()).first;
    10081007
    10091008    // TODO: make sure this works with shorthands right.
    10101009    ExceptionCode ec = 0;
    10111010    if (disabled) {
    1012         disabledStyle->setProperty(propertyName, style->getPropertyValue(propertyName), style->getPropertyPriority(propertyName), ec);
     1011        disabledIt->second.set(propertyName, std::make_pair(style->getPropertyValue(propertyName), style->getPropertyPriority(propertyName)));
    10131012        if (!ec)
    10141013            style->removeProperty(propertyName, ec);
    1015     } else {
    1016         style->setProperty(propertyName, disabledStyle->getPropertyValue(propertyName), disabledStyle->getPropertyPriority(propertyName), ec);
     1014    } else if (disabledIt->second.contains(propertyName)) {
     1015        PropertyValueAndPriority valueAndPriority = disabledIt->second.get(propertyName);
     1016        style->setProperty(propertyName, valueAndPriority.first, valueAndPriority.second, ec);
    10171017        if (!ec)
    1018             disabledStyle->removeProperty(propertyName, ec);
     1018            disabledIt->second.remove(propertyName);
    10191019    }
    10201020    if (ec) {
     
    11291129        result.set("id", styleId);
    11301130
    1131         IdToStyleMap::iterator disabledIt = m_idToDisabledStyle.find(styleId);
    1132         if (disabledIt != m_idToDisabledStyle.end()) {
    1133             ScriptObject disabledStyle = m_frontend->newScriptObject();
    1134             populateObjectWithStyleProperties(disabledIt->second.get(), disabledStyle);
    1135             result.set("disabled", disabledStyle);
    1136         }
     1131        IdToDisabledStyleMap::iterator disabledIt = m_idToDisabledStyle.find(styleId);
     1132        if (disabledIt != m_idToDisabledStyle.end())
     1133            result.set("disabled", buildArrayForDisabledStyleProperties(disabledIt->second));
    11371134    }
    11381135    result.set("width", style->getPropertyValue("width"));
     
    11651162        properties.set(i, property);
    11661163    }
     1164}
     1165
     1166ScriptArray InspectorDOMAgent::buildArrayForDisabledStyleProperties(DisabledStyleDeclaration& declaration)
     1167{
     1168    int counter = 0;
     1169    ScriptArray properties = m_frontend->newScriptArray();
     1170    for (DisabledStyleDeclaration::iterator it = declaration.begin(); it != declaration.end(); ++it) {
     1171        ScriptObject property = m_frontend->newScriptObject();
     1172        property.set("name", it->first);
     1173        property.set("value", it->second.first);
     1174        property.set("priority", it->second.second);
     1175        properties.set(counter++, property);
     1176    }
     1177    return properties;
    11671178}
    11681179
  • trunk/WebCore/inspector/InspectorDOMAgent.h

    r56683 r56697  
    127127        void pushChildNodesToFrontend(long nodeId);
    128128
    129    private:
     129    private:
     130        typedef std::pair<String, String> PropertyValueAndPriority;
     131        typedef HashMap<String, PropertyValueAndPriority> DisabledStyleDeclaration;
     132
    130133        void startListening(Document* document);
    131134        void stopListening(Document* document);
     
    165168        ScriptObject buildObjectForStyle(CSSStyleDeclaration*, bool bind);
    166169        void populateObjectWithStyleProperties(CSSStyleDeclaration*, ScriptObject& result);
     170        ScriptArray buildArrayForDisabledStyleProperties(DisabledStyleDeclaration&);
    167171        ScriptObject buildObjectForRule(CSSStyleRule*);
    168172        ScriptObject buildObjectForStyleSheet(CSSStyleSheet*);
     
    192196        RuleToIdMap m_ruleToId;
    193197        IdToRuleMap m_idToRule;
    194         IdToStyleMap m_idToDisabledStyle;
     198        typedef HashMap<long, DisabledStyleDeclaration>  IdToDisabledStyleMap;
     199        IdToDisabledStyleMap m_idToDisabledStyle;
    195200        RefPtr<CSSStyleSheet> m_inspectorStyleSheet;
    196201
  • trunk/WebCore/inspector/front-end/DOMAgent.js

    r56683 r56697  
    496496    this.__disabledPropertyPriorities = {};
    497497    if (payload.disabled) {
    498         var disabledProperties = payload.disabled.properties;
    499         var shorthandValues = payload.disabled.shorthandValues;
    500         for (var name in shorthandValues) {
    501             this.__disabledProperties[name] = true;
    502             this.__disabledPropertyValues[name] = shorthandValues[name];
    503         }
    504         for (var i = 0; i < disabledProperties.length; ++i) {
    505             var disabledProperty = disabledProperties[i];
    506             if (disabledProperty.shorthand)
    507                 continue;
    508             var name = disabledProperty.name;
    509             this.__disabledProperties[name] = true;
    510             this.__disabledPropertyValues[name] = disabledProperty.value;
    511             this.__disabledPropertyPriorities[name] = disabledProperty.priority;
    512         }
    513     }
    514    
     498        for (var i = 0; i < payload.disabled.length; ++i) {
     499            var property = payload.disabled[i];
     500            this.__disabledProperties[property.name] = true;
     501            this.__disabledPropertyValues[property.name] = property.value;
     502            this.__disabledPropertyPriorities[property.name] = property.priority;
     503        }
     504    }
     505
    515506    this._shorthandValues = payload.shorthandValues;
    516507    this._propertyMap = {};
  • trunk/WebCore/inspector/front-end/StylesSidebarPane.js

    r56608 r56697  
    213213            var attrStyle = { style: new WebInspector.CSSStyleDeclaration(styles.styleAttributes[name]), editable: false };
    214214            attrStyle.subtitle = WebInspector.UIString("element’s “%s” attribute", name);
    215             attrStyle.selectorText = node.nodeName + "[" + name;
     215            attrStyle.selectorText = WebInspector.panels.elements.treeOutline.nodeNameToCorrectCase(node.nodeName) + "[" + name;
    216216            if (node.getAttribute(name))
    217217                attrStyle.selectorText += "=" + node.getAttribute(name);
Note: See TracChangeset for help on using the changeset viewer.