Changeset 56059 in webkit


Ignore:
Timestamp:
Mar 16, 2010 6:58:05 AM (14 years ago)
Author:
pfeldman@chromium.org
Message:

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

Reviewed by Timothy Hatcher.

Web Inspector: Errors when inspecting styles of non-renderable elements in XHTML.

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

  • inspector/InspectorDOMAgent.cpp: (WebCore::InspectorDOMAgent::getStyles):
  • inspector/front-end/DOMAgent.js: (WebInspector.DOMNode.prototype._addAttribute): (WebInspector.DOMWindow.prototype.Object):
  • inspector/front-end/MetricsSidebarPane.js:
  • inspector/front-end/StylesSidebarPane.js: (WebInspector.StylesSidebarPane.prototype.update.callback): (WebInspector.StylesSidebarPane.prototype.update): (WebInspector.StylesSidebarPane.prototype._update):
Location:
trunk/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r56057 r56059  
     12010-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
    1202010-03-12  Antonio Gomes  <tonikitoo@webkit.org>
    221
  • trunk/WebCore/inspector/InspectorDOMAgent.cpp

    r56049 r56059  
    697697
    698698    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));
    700701    result.set("computedStyle", buildObjectForStyle(computedStyle.get(), false));
    701702    result.set("matchedCSSRules", getMatchedCSSRules(element, authorOnly));
  • trunk/WebCore/inspector/front-end/DOMAgent.js

    r56049 r56059  
    212212        this._attributesMap[name] = attr;
    213213        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;
    238214    }
    239215}
     
    309285    Object: function()
    310286    {
    311     },
    312 
    313     getComputedStyle: function(node)
    314     {
    315         return node._computedStyle;
    316     },
    317 
    318     getMatchedCSSRules: function(node, pseudoElement, authorOnly)
    319     {
    320         return node._matchedCSSRules;
    321287    }
    322288}
  • trunk/WebCore/inspector/front-end/MetricsSidebarPane.js

    r56049 r56059  
    186186    editingCommitted: function(element, userInput, previousContent, context)
    187187    {
     188        if (!this._inlineStyleId) {
     189            // Element has no renderer.
     190            return this.editingCancelled(element, context); // nothing changed, so cancel
     191        }
     192
    188193        if (userInput === previousContent)
    189194            return this.editingCancelled(element, context); // nothing changed, so cancel
  • trunk/WebCore/inspector/front-end/StylesSidebarPane.js

    r56049 r56059  
    112112            if (!styles)
    113113                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);
    116115        }
    117116
     
    119118    },
    120119
    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
    123124        if (!refresh) {
    124             body.removeChildren();
     125            this.bodyElement.removeChildren();
    125126            this.sections = [];
    126127        }
     
    134135                    continue;
    135136                if (section.computedStyle)
    136                     section.styleRule.style = node.ownerDocument.defaultView.getComputedStyle(node);
     137                    section.styleRule.style = nodeComputedStyle;
    137138                var styleRule = { section: section, style: section.styleRule.style, computedStyle: section.computedStyle, rule: section.rule };
    138139                styleRules.push(styleRule);
    139140            }
    140141        } 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);
    156153            }
    157154
    158155            // Always Show element's Style Attributes
    159             if (node.nodeType === Node.ELEMENT_NODE) {
    160                 var inlineStyle = { selectorText: WebInspector.UIString("Style Attribute"), style: node.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 };
    161158                inlineStyle.subtitle = WebInspector.UIString("element’s “%s” attribute", "style");
    162159                styleRules.push(inlineStyle);
    163160            }
    164161
    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 });
    172166            }
    173167        }
     
    312306                    section.expand(true);
    313307
    314                 body.appendChild(section.element);
     308                this.bodyElement.appendChild(section.element);
    315309                this.sections.push(section);
    316310            }
Note: See TracChangeset for help on using the changeset viewer.