<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[56697] trunk/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/56697">56697</a></dd>
<dt>Author</dt> <dd>pfeldman@chromium.org</dd>
<dt>Date</dt> <dd>2010-03-28 10:41:20 -0700 (Sun, 28 Mar 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>2010-03-28  Pavel Feldman  &lt;pfeldman@chromium.org&gt;

        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):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCoreinspectorInspectorControllercpp">trunk/WebCore/inspector/InspectorController.cpp</a></li>
<li><a href="#trunkWebCoreinspectorInspectorDOMAgentcpp">trunk/WebCore/inspector/InspectorDOMAgent.cpp</a></li>
<li><a href="#trunkWebCoreinspectorInspectorDOMAgenth">trunk/WebCore/inspector/InspectorDOMAgent.h</a></li>
<li><a href="#trunkWebCoreinspectorfrontendDOMAgentjs">trunk/WebCore/inspector/front-end/DOMAgent.js</a></li>
<li><a href="#trunkWebCoreinspectorfrontendStylesSidebarPanejs">trunk/WebCore/inspector/front-end/StylesSidebarPane.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (56696 => 56697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2010-03-28 17:32:04 UTC (rev 56696)
+++ trunk/WebCore/ChangeLog        2010-03-28 17:41:20 UTC (rev 56697)
</span><span class="lines">@@ -2,6 +2,23 @@
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Timothy Hatcher.
</span><span class="cx"> 
</span><ins>+        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):
+
+2010-03-28  Pavel Feldman  &lt;pfeldman@chromium.org&gt;
+
+        Reviewed by Timothy Hatcher.
+
</ins><span class="cx">         Web Inspector: resource links should navigate to resource panel enabler when resource tracking is off.
</span><span class="cx"> 
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=36722
</span></span></pre></div>
<a id="trunkWebCoreinspectorInspectorControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/inspector/InspectorController.cpp (56696 => 56697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/inspector/InspectorController.cpp        2010-03-28 17:32:04 UTC (rev 56696)
+++ trunk/WebCore/inspector/InspectorController.cpp        2010-03-28 17:41:20 UTC (rev 56697)
</span><span class="lines">@@ -58,7 +58,6 @@
</span><span class="cx"> #include &quot;InspectorBackend.h&quot;
</span><span class="cx"> #include &quot;InspectorClient.h&quot;
</span><span class="cx"> #include &quot;InspectorFrontendClient.h&quot;
</span><del>-#include &quot;InspectorDOMAgent.h&quot;
</del><span class="cx"> #include &quot;InspectorDOMStorageResource.h&quot;
</span><span class="cx"> #include &quot;InspectorDatabaseResource.h&quot;
</span><span class="cx"> #include &quot;InspectorFrontend.h&quot;
</span></span></pre></div>
<a id="trunkWebCoreinspectorInspectorDOMAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/inspector/InspectorDOMAgent.cpp (56696 => 56697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/inspector/InspectorDOMAgent.cpp        2010-03-28 17:32:04 UTC (rev 56696)
+++ trunk/WebCore/inspector/InspectorDOMAgent.cpp        2010-03-28 17:41:20 UTC (rev 56697)
</span><span class="lines">@@ -1001,21 +1001,21 @@
</span><span class="cx">     }
</span><span class="cx">     CSSStyleDeclaration* style = it-&gt;second.get();
</span><span class="cx"> 
</span><del>-    IdToStyleMap::iterator disabledIt = m_idToDisabledStyle.find(styleId);
</del><ins>+    IdToDisabledStyleMap::iterator disabledIt = m_idToDisabledStyle.find(styleId);
</ins><span class="cx">     if (disabledIt == m_idToDisabledStyle.end())
</span><del>-        disabledIt = m_idToDisabledStyle.set(styleId, CSSMutableStyleDeclaration::create()).first;
-    CSSStyleDeclaration* disabledStyle = disabledIt-&gt;second.get();
</del><ins>+        disabledIt = m_idToDisabledStyle.set(styleId, DisabledStyleDeclaration()).first;
</ins><span class="cx"> 
</span><span class="cx">     // TODO: make sure this works with shorthands right.
</span><span class="cx">     ExceptionCode ec = 0;
</span><span class="cx">     if (disabled) {
</span><del>-        disabledStyle-&gt;setProperty(propertyName, style-&gt;getPropertyValue(propertyName), style-&gt;getPropertyPriority(propertyName), ec);
</del><ins>+        disabledIt-&gt;second.set(propertyName, std::make_pair(style-&gt;getPropertyValue(propertyName), style-&gt;getPropertyPriority(propertyName)));
</ins><span class="cx">         if (!ec)
</span><span class="cx">             style-&gt;removeProperty(propertyName, ec);
</span><del>-    } else {
-        style-&gt;setProperty(propertyName, disabledStyle-&gt;getPropertyValue(propertyName), disabledStyle-&gt;getPropertyPriority(propertyName), ec);
</del><ins>+    } else if (disabledIt-&gt;second.contains(propertyName)) {
+        PropertyValueAndPriority valueAndPriority = disabledIt-&gt;second.get(propertyName);
+        style-&gt;setProperty(propertyName, valueAndPriority.first, valueAndPriority.second, ec);
</ins><span class="cx">         if (!ec)
</span><del>-            disabledStyle-&gt;removeProperty(propertyName, ec);
</del><ins>+            disabledIt-&gt;second.remove(propertyName);
</ins><span class="cx">     }
</span><span class="cx">     if (ec) {
</span><span class="cx">         m_frontend-&gt;didToggleStyleEnabled(callId, ScriptValue::undefined());
</span><span class="lines">@@ -1128,12 +1128,9 @@
</span><span class="cx">         long styleId = bindStyle(style);
</span><span class="cx">         result.set(&quot;id&quot;, styleId);
</span><span class="cx"> 
</span><del>-        IdToStyleMap::iterator disabledIt = m_idToDisabledStyle.find(styleId);
-        if (disabledIt != m_idToDisabledStyle.end()) {
-            ScriptObject disabledStyle = m_frontend-&gt;newScriptObject();
-            populateObjectWithStyleProperties(disabledIt-&gt;second.get(), disabledStyle);
-            result.set(&quot;disabled&quot;, disabledStyle);
-        }
</del><ins>+        IdToDisabledStyleMap::iterator disabledIt = m_idToDisabledStyle.find(styleId);
+        if (disabledIt != m_idToDisabledStyle.end())
+            result.set(&quot;disabled&quot;, buildArrayForDisabledStyleProperties(disabledIt-&gt;second));
</ins><span class="cx">     }
</span><span class="cx">     result.set(&quot;width&quot;, style-&gt;getPropertyValue(&quot;width&quot;));
</span><span class="cx">     result.set(&quot;height&quot;, style-&gt;getPropertyValue(&quot;height&quot;));
</span><span class="lines">@@ -1166,6 +1163,20 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+ScriptArray InspectorDOMAgent::buildArrayForDisabledStyleProperties(DisabledStyleDeclaration&amp; declaration)
+{
+    int counter = 0;
+    ScriptArray properties = m_frontend-&gt;newScriptArray();
+    for (DisabledStyleDeclaration::iterator it = declaration.begin(); it != declaration.end(); ++it) {
+        ScriptObject property = m_frontend-&gt;newScriptObject();
+        property.set(&quot;name&quot;, it-&gt;first);
+        property.set(&quot;value&quot;, it-&gt;second.first);
+        property.set(&quot;priority&quot;, it-&gt;second.second);
+        properties.set(counter++, property);
+    }
+    return properties;
+}
+
</ins><span class="cx"> ScriptObject InspectorDOMAgent::buildObjectForStyleSheet(CSSStyleSheet* styleSheet)
</span><span class="cx"> {
</span><span class="cx">     ScriptObject result = m_frontend-&gt;newScriptObject();
</span></span></pre></div>
<a id="trunkWebCoreinspectorInspectorDOMAgenth"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/inspector/InspectorDOMAgent.h (56696 => 56697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/inspector/InspectorDOMAgent.h        2010-03-28 17:32:04 UTC (rev 56696)
+++ trunk/WebCore/inspector/InspectorDOMAgent.h        2010-03-28 17:41:20 UTC (rev 56697)
</span><span class="lines">@@ -126,7 +126,10 @@
</span><span class="cx">         long pushNodePathToFrontend(Node* node);
</span><span class="cx">         void pushChildNodesToFrontend(long nodeId);
</span><span class="cx"> 
</span><del>-   private:
</del><ins>+    private:
+        typedef std::pair&lt;String, String&gt; PropertyValueAndPriority;
+        typedef HashMap&lt;String, PropertyValueAndPriority&gt; DisabledStyleDeclaration;
+
</ins><span class="cx">         void startListening(Document* document);
</span><span class="cx">         void stopListening(Document* document);
</span><span class="cx"> 
</span><span class="lines">@@ -164,6 +167,7 @@
</span><span class="cx">         long bindRule(CSSStyleRule*);
</span><span class="cx">         ScriptObject buildObjectForStyle(CSSStyleDeclaration*, bool bind);
</span><span class="cx">         void populateObjectWithStyleProperties(CSSStyleDeclaration*, ScriptObject&amp; result);
</span><ins>+        ScriptArray buildArrayForDisabledStyleProperties(DisabledStyleDeclaration&amp;);
</ins><span class="cx">         ScriptObject buildObjectForRule(CSSStyleRule*);
</span><span class="cx">         ScriptObject buildObjectForStyleSheet(CSSStyleSheet*);
</span><span class="cx">         Vector&lt;String&gt; longhandProperties(CSSStyleDeclaration*, const String&amp; shorthandProperty);
</span><span class="lines">@@ -191,7 +195,8 @@
</span><span class="cx">         typedef HashMap&lt;long, RefPtr&lt;CSSStyleRule&gt; &gt; IdToRuleMap;
</span><span class="cx">         RuleToIdMap m_ruleToId;
</span><span class="cx">         IdToRuleMap m_idToRule;
</span><del>-        IdToStyleMap m_idToDisabledStyle;
</del><ins>+        typedef HashMap&lt;long, DisabledStyleDeclaration&gt;  IdToDisabledStyleMap;
+        IdToDisabledStyleMap m_idToDisabledStyle;
</ins><span class="cx">         RefPtr&lt;CSSStyleSheet&gt; m_inspectorStyleSheet;
</span><span class="cx"> 
</span><span class="cx">         long m_lastStyleId;
</span></span></pre></div>
<a id="trunkWebCoreinspectorfrontendDOMAgentjs"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/inspector/front-end/DOMAgent.js (56696 => 56697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/inspector/front-end/DOMAgent.js        2010-03-28 17:32:04 UTC (rev 56696)
+++ trunk/WebCore/inspector/front-end/DOMAgent.js        2010-03-28 17:41:20 UTC (rev 56697)
</span><span class="lines">@@ -495,23 +495,14 @@
</span><span class="cx">     this.__disabledPropertyValues = {};
</span><span class="cx">     this.__disabledPropertyPriorities = {};
</span><span class="cx">     if (payload.disabled) {
</span><del>-        var disabledProperties = payload.disabled.properties;
-        var shorthandValues = payload.disabled.shorthandValues;
-        for (var name in shorthandValues) {
-            this.__disabledProperties[name] = true;
-            this.__disabledPropertyValues[name] = shorthandValues[name];
</del><ins>+        for (var i = 0; i &lt; payload.disabled.length; ++i) {
+            var property = payload.disabled[i];
+            this.__disabledProperties[property.name] = true;
+            this.__disabledPropertyValues[property.name] = property.value;
+            this.__disabledPropertyPriorities[property.name] = property.priority;
</ins><span class="cx">         }
</span><del>-        for (var i = 0; i &lt; disabledProperties.length; ++i) {
-            var disabledProperty = disabledProperties[i];
-            if (disabledProperty.shorthand)
-                continue;
-            var name = disabledProperty.name;
-            this.__disabledProperties[name] = true;
-            this.__disabledPropertyValues[name] = disabledProperty.value;
-            this.__disabledPropertyPriorities[name] = disabledProperty.priority;
-        }
</del><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     this._shorthandValues = payload.shorthandValues;
</span><span class="cx">     this._propertyMap = {};
</span><span class="cx">     this._longhandProperties = {};
</span></span></pre></div>
<a id="trunkWebCoreinspectorfrontendStylesSidebarPanejs"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/inspector/front-end/StylesSidebarPane.js (56696 => 56697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/inspector/front-end/StylesSidebarPane.js        2010-03-28 17:32:04 UTC (rev 56696)
+++ trunk/WebCore/inspector/front-end/StylesSidebarPane.js        2010-03-28 17:41:20 UTC (rev 56697)
</span><span class="lines">@@ -212,7 +212,7 @@
</span><span class="cx">         for (var name in styles.styleAttributes) {
</span><span class="cx">             var attrStyle = { style: new WebInspector.CSSStyleDeclaration(styles.styleAttributes[name]), editable: false };
</span><span class="cx">             attrStyle.subtitle = WebInspector.UIString(&quot;element’s “%s” attribute&quot;, name);
</span><del>-            attrStyle.selectorText = node.nodeName + &quot;[&quot; + name;
</del><ins>+            attrStyle.selectorText = WebInspector.panels.elements.treeOutline.nodeNameToCorrectCase(node.nodeName) + &quot;[&quot; + name;
</ins><span class="cx">             if (node.getAttribute(name))
</span><span class="cx">                 attrStyle.selectorText += &quot;=&quot; + node.getAttribute(name);
</span><span class="cx">             attrStyle.selectorText += &quot;]&quot;;
</span></span></pre>
</div>
</div>

</body>
</html>