Changeset 56059 in webkit
- Timestamp:
- Mar 16, 2010 6:58:05 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r56057 r56059 1 2010-03-16 Pavel Feldman <pfeldman@chromium.org> 2 3 Reviewed by Timothy Hatcher. 4 5 Web Inspector: Errors when inspecting styles of non-renderable elements in XHTML. 6 7 https://bugs.webkit.org/show_bug.cgi?id=35025 8 9 * inspector/InspectorDOMAgent.cpp: 10 (WebCore::InspectorDOMAgent::getStyles): 11 * inspector/front-end/DOMAgent.js: 12 (WebInspector.DOMNode.prototype._addAttribute): 13 (WebInspector.DOMWindow.prototype.Object): 14 * inspector/front-end/MetricsSidebarPane.js: 15 * inspector/front-end/StylesSidebarPane.js: 16 (WebInspector.StylesSidebarPane.prototype.update.callback): 17 (WebInspector.StylesSidebarPane.prototype.update): 18 (WebInspector.StylesSidebarPane.prototype._update): 19 1 20 2010-03-12 Antonio Gomes <tonikitoo@webkit.org> 2 21 -
trunk/WebCore/inspector/InspectorDOMAgent.cpp
r56049 r56059 697 697 698 698 ScriptObject result = m_frontend->newScriptObject(); 699 result.set("inlineStyle", buildObjectForStyle(element->style(), true)); 699 if (element->style()) 700 result.set("inlineStyle", buildObjectForStyle(element->style(), true)); 700 701 result.set("computedStyle", buildObjectForStyle(computedStyle.get(), false)); 701 702 result.set("matchedCSSRules", getMatchedCSSRules(element, authorOnly)); -
trunk/WebCore/inspector/front-end/DOMAgent.js
r56049 r56059 212 212 this._attributesMap[name] = attr; 213 213 this.attributes.push(attr); 214 },215 216 _setStyles: function(computedStyle, inlineStyle, styleAttributes, matchedCSSRules)217 {218 this._computedStyle = new WebInspector.CSSStyleDeclaration(computedStyle);219 this.style = new WebInspector.CSSStyleDeclaration(inlineStyle);220 221 for (var name in styleAttributes) {222 if (this._attributesMap[name])223 this._attributesMap[name].style = new WebInspector.CSSStyleDeclaration(styleAttributes[name]);224 }225 226 this._matchedCSSRules = [];227 for (var i = 0; i < matchedCSSRules.length; i++)228 this._matchedCSSRules.push(WebInspector.CSSStyleDeclaration.parseRule(matchedCSSRules[i]));229 },230 231 _clearStyles: function()232 {233 this.computedStyle = null;234 this.style = null;235 for (var name in this._attributesMap)236 this._attributesMap[name].style = null;237 this._matchedCSSRules = null;238 214 } 239 215 } … … 309 285 Object: function() 310 286 { 311 },312 313 getComputedStyle: function(node)314 {315 return node._computedStyle;316 },317 318 getMatchedCSSRules: function(node, pseudoElement, authorOnly)319 {320 return node._matchedCSSRules;321 287 } 322 288 } -
trunk/WebCore/inspector/front-end/MetricsSidebarPane.js
r56049 r56059 186 186 editingCommitted: function(element, userInput, previousContent, context) 187 187 { 188 if (!this._inlineStyleId) { 189 // Element has no renderer. 190 return this.editingCancelled(element, context); // nothing changed, so cancel 191 } 192 188 193 if (userInput === previousContent) 189 194 return this.editingCancelled(element, context); // nothing changed, so cancel -
trunk/WebCore/inspector/front-end/StylesSidebarPane.js
r56049 r56059 112 112 if (!styles) 113 113 return; 114 node._setStyles(styles.computedStyle, styles.inlineStyle, styles.styleAttributes, styles.matchedCSSRules); 115 self._update(refresh, body, node, editedSection, forceUpdate); 114 self._update(refresh, node, styles, editedSection, forceUpdate); 116 115 } 117 116 … … 119 118 }, 120 119 121 _update: function(refresh, body, node, editedSection, forceUpdate) 122 { 120 _update: function(refresh, node, styles, editedSection, forceUpdate) 121 { 122 var nodeComputedStyle = new WebInspector.CSSStyleDeclaration(styles.computedStyle); 123 123 124 if (!refresh) { 124 body.removeChildren();125 this.bodyElement.removeChildren(); 125 126 this.sections = []; 126 127 } … … 134 135 continue; 135 136 if (section.computedStyle) 136 section.styleRule.style = node .ownerDocument.defaultView.getComputedStyle(node);137 section.styleRule.style = nodeComputedStyle; 137 138 var styleRule = { section: section, style: section.styleRule.style, computedStyle: section.computedStyle, rule: section.rule }; 138 139 styleRules.push(styleRule); 139 140 } 140 141 } else { 141 var computedStyle = node.ownerDocument.defaultView.getComputedStyle(node); 142 styleRules.push({ computedStyle: true, selectorText: WebInspector.UIString("Computed Style"), style: computedStyle, editable: false }); 143 144 var nodeName = node.nodeName.toLowerCase(); 145 for (var i = 0; i < node.attributes.length; ++i) { 146 var attr = node.attributes[i]; 147 if (attr.style) { 148 var attrStyle = { style: attr.style, editable: false }; 149 attrStyle.subtitle = WebInspector.UIString("element’s “%s” attribute", attr.name); 150 attrStyle.selectorText = nodeName + "[" + attr.name; 151 if (attr.value.length) 152 attrStyle.selectorText += "=" + attr.value; 153 attrStyle.selectorText += "]"; 154 styleRules.push(attrStyle); 155 } 142 styleRules.push({ computedStyle: true, selectorText: WebInspector.UIString("Computed Style"), style: nodeComputedStyle, editable: false }); 143 144 var styleAttributes = {}; 145 for (var name in styles.styleAttributes) { 146 var attrStyle = { style: new WebInspector.CSSStyleDeclaration(styles.styleAttributes[name]), editable: false }; 147 attrStyle.subtitle = WebInspector.UIString("element’s “%s” attribute", name); 148 attrStyle.selectorText = node.nodeName + "[" + name; 149 if (node.getAttribute(name)) 150 attrStyle.selectorText += "=" + node.getAttribute(name); 151 attrStyle.selectorText += "]"; 152 styleRules.push(attrStyle); 156 153 } 157 154 158 155 // Always Show element's Style Attributes 159 if ( node.nodeType === Node.ELEMENT_NODE) {160 var inlineStyle = { selectorText: WebInspector.UIString("Style Attribute"), style: n ode.style, isAttribute: true };156 if (styles.inlineStyle && node.nodeType === Node.ELEMENT_NODE) { 157 var inlineStyle = { selectorText: WebInspector.UIString("Style Attribute"), style: new WebInspector.CSSStyleDeclaration(styles.inlineStyle), isAttribute: true }; 161 158 inlineStyle.subtitle = WebInspector.UIString("element’s “%s” attribute", "style"); 162 159 styleRules.push(inlineStyle); 163 160 } 164 161 165 var matchedStyleRules = node.ownerDocument.defaultView.getMatchedCSSRules(node, "", !WebInspector.settings.showUserAgentStyles); 166 if (matchedStyleRules) { 167 // Add rules in reverse order to match the cascade order. 168 for (var i = (matchedStyleRules.length - 1); i >= 0; --i) { 169 var rule = matchedStyleRules[i]; 170 styleRules.push({ style: rule.style, selectorText: rule.selectorText, parentStyleSheet: rule.parentStyleSheet, rule: rule }); 171 } 162 // Add rules in reverse order to match the cascade order. 163 for (var i = styles.matchedCSSRules.length - 1; i >= 0; --i) { 164 var rule = WebInspector.CSSStyleDeclaration.parseRule(styles.matchedCSSRules[i]); 165 styleRules.push({ style: rule.style, selectorText: rule.selectorText, parentStyleSheet: rule.parentStyleSheet, rule: rule }); 172 166 } 173 167 } … … 312 306 section.expand(true); 313 307 314 body.appendChild(section.element);308 this.bodyElement.appendChild(section.element); 315 309 this.sections.push(section); 316 310 }
Note: See TracChangeset
for help on using the changeset viewer.