Changeset 60680 in webkit


Ignore:
Timestamp:
Jun 4, 2010 7:17:07 AM (14 years ago)
Author:
apavlov@chromium.org
Message:

2010-06-04 Alexander Pavlov <apavlov@chromium.org>

Reviewed by Pavel Feldman.

Web Inspector: Eliminate direct dependency of StylesSidebarPane on InspectorBackend
https://bugs.webkit.org/show_bug.cgi?id=40069

No new tests are needed, as this is a refactoring.

  • inspector/front-end/CSSStyleModel.js: Added. (WebInspector.CSSStyleModel): (WebInspector.CSSStyleModel.prototype.getStylesAsync): (WebInspector.CSSStyleModel.prototype.getComputedStyleAsync): (WebInspector.CSSStyleModel.prototype.setRuleSelector): (WebInspector.CSSStyleModel.prototype.addRule): (WebInspector.CSSStyleModel.prototype.toggleStyleEnabled): (WebInspector.CSSStyleModel.prototype.setCSSText): (WebInspector.CSSStyleModel.prototype.applyStyleText):
  • inspector/front-end/StylesSidebarPane.js: (WebInspector.StylesSidebarPane.prototype.update.stylesCallback): (WebInspector.StylesSidebarPane.prototype.update.computedStyleCallback): (WebInspector.StylesSidebarPane.prototype.update): (WebInspector.StylesSidebarPane.prototype._arrayContainsInheritedProperty): (WebInspector.StylePropertiesSection.prototype.editingSelectorCommitted.successCallback): (WebInspector.StylePropertiesSection.prototype.editingSelectorCommitted): (WebInspector.BlankStylePropertiesSection.prototype.editingSelectorCommitted.successCallback): (WebInspector.BlankStylePropertiesSection.prototype.editingSelectorCommitted): (WebInspector.StylePropertyTreeElement.prototype.): (WebInspector.StylePropertyTreeElement.prototype):
  • inspector/front-end/inspector.html:
  • inspector/front-end/inspector.js: (WebInspector.loaded):
Location:
trunk/WebCore
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r60677 r60680  
     12010-06-04  Alexander Pavlov  <apavlov@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: Eliminate direct dependency of StylesSidebarPane on InspectorBackend
     6        https://bugs.webkit.org/show_bug.cgi?id=40069
     7
     8        No new tests are needed, as this is a refactoring.
     9
     10        * inspector/front-end/CSSStyleModel.js: Added.
     11        (WebInspector.CSSStyleModel):
     12        (WebInspector.CSSStyleModel.prototype.getStylesAsync):
     13        (WebInspector.CSSStyleModel.prototype.getComputedStyleAsync):
     14        (WebInspector.CSSStyleModel.prototype.setRuleSelector):
     15        (WebInspector.CSSStyleModel.prototype.addRule):
     16        (WebInspector.CSSStyleModel.prototype.toggleStyleEnabled):
     17        (WebInspector.CSSStyleModel.prototype.setCSSText):
     18        (WebInspector.CSSStyleModel.prototype.applyStyleText):
     19        * inspector/front-end/StylesSidebarPane.js:
     20        (WebInspector.StylesSidebarPane.prototype.update.stylesCallback):
     21        (WebInspector.StylesSidebarPane.prototype.update.computedStyleCallback):
     22        (WebInspector.StylesSidebarPane.prototype.update):
     23        (WebInspector.StylesSidebarPane.prototype._arrayContainsInheritedProperty):
     24        (WebInspector.StylePropertiesSection.prototype.editingSelectorCommitted.successCallback):
     25        (WebInspector.StylePropertiesSection.prototype.editingSelectorCommitted):
     26        (WebInspector.BlankStylePropertiesSection.prototype.editingSelectorCommitted.successCallback):
     27        (WebInspector.BlankStylePropertiesSection.prototype.editingSelectorCommitted):
     28        (WebInspector.StylePropertyTreeElement.prototype.):
     29        (WebInspector.StylePropertyTreeElement.prototype):
     30        * inspector/front-end/inspector.html:
     31        * inspector/front-end/inspector.js:
     32        (WebInspector.loaded):
     33
    1342010-06-04  Simon Hausmann  <simon.hausmann@nokia.com>
    235
  • trunk/WebCore/inspector/front-end/StylesSidebarPane.js

    r59468 r60680  
    134134        }
    135135
    136         function getStylesCallback(styles)
     136        function stylesCallback(styles)
    137137        {
    138138            if (styles)
     
    140140        }
    141141
    142         function getComputedStyleCallback(computedStyle)
     142        function computedStyleCallback(computedStyle)
    143143        {
    144144            if (computedStyle)
     
    147147
    148148        if (refresh)
    149             InspectorBackend.getComputedStyle(WebInspector.Callback.wrap(getComputedStyleCallback.bind(this)), node.id);
     149            WebInspector.cssModel.getComputedStyleAsync(node.id, computedStyleCallback.bind(this));
    150150        else
    151             InspectorBackend.getStyles(WebInspector.Callback.wrap(getStylesCallback.bind(this)), node.id, !WebInspector.settings.showUserAgentStyles);
     151            WebInspector.cssModel.getStylesAsync(node.id, !WebInspector.settings.showUserAgentStyles, stylesCallback.bind(this));
    152152    },
    153153
     
    467467        for (var i = 0; i < properties.length; ++i) {
    468468            var property = properties[i];
    469             // Does this style contain non-overriden inherited property?
     469            // Does this style contain non-overridden inherited property?
    470470            if (property.name in WebInspector.StylesSidebarPane.InheritedProperties)
    471471                return true;
     
    601601    showInheritedCheckbox.addEventListener(showInheritedToggleFunction.bind(this));
    602602}
    603  
     603
    604604WebInspector.ComputedStyleSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype;
    605605
     
    883883
    884884        var self = this;
    885         function callback(newRulePayload, doesAffectSelectedNode)
     885
     886        function successCallback(newRule, doesAffectSelectedNode)
    886887        {
    887             if (!newRulePayload) {
    888                 // Invalid Syntax for a Selector
    889                 moveToNextIfNeeded.call(self);
    890                 return;
    891             }
    892 
    893888            if (!doesAffectSelectedNode) {
    894889                self.noAffect = true;
     
    899894            }
    900895
    901             var newRule = WebInspector.CSSStyleDeclaration.parseRule(newRulePayload);
    902896            self.rule = newRule;
    903897            self.styleRule = { section: self, style: newRule.style, selectorText: newRule.selectorText, parentStyleSheet: newRule.parentStyleSheet, rule: newRule };
     
    913907        }
    914908
    915         InspectorBackend.setRuleSelector(WebInspector.Callback.wrap(callback), this.rule.id, newContent, this.pane.node.id);
     909        WebInspector.cssModel.setRuleSelector(this.rule.id, newContent, this.pane.node.id, successCallback, moveToNextIfNeeded.bind(this));
    916910    },
    917911
     
    940934    {
    941935        var self = this;
    942         function callback(rule, doesSelectorAffectSelectedNode)
     936        function successCallback(styleRule, doesSelectorAffectSelectedNode)
    943937        {
    944             if (!rule) {
    945                 // Invalid Syntax for a Selector
    946                 self.editingSelectorCancelled();
    947                 return;
    948             }
    949 
    950             var styleRule = WebInspector.CSSStyleDeclaration.parseRule(rule);
    951             styleRule.rule = rule;
    952 
    953938            self.makeNormal(styleRule);
    954939
     
    964949        }
    965950
    966         InspectorBackend.addRule(WebInspector.Callback.wrap(callback), newContent, this.pane.node.id);
     951        WebInspector.cssModel.addRule(this.pane.node.id, newContent, successCallback, this.editingSelectorCancelled.bind(this));
    967952    },
    968953
     
    12211206        this.listItemElement.removeChildren();
    12221207
     1208        if (!this.treeOutline)
     1209            return;
     1210
    12231211        // Append the checkbox for root elements of an editable section.
    12241212        if (this.treeOutline.section && this.treeOutline.section.editable && this.parent.root)
     
    12551243
    12561244        var self = this;
    1257         function callback(newPayload)
     1245        function callback(newStyle)
    12581246        {
    1259             if (!newPayload)
     1247            if (!newStyle)
    12601248                return;
    12611249
    1262             self.style = WebInspector.CSSStyleDeclaration.parseStyle(newPayload);
     1250            self.style = newStyle;
    12631251            self._styleRule.style = self.style;
    12641252
     
    12731261        }
    12741262
    1275         InspectorBackend.toggleStyleEnabled(WebInspector.Callback.wrap(callback), this.style.id, this.name, disabled);
     1263        WebInspector.cssModel.toggleStyleEnabled(this.style.id, this.name, disabled, callback);
    12761264    },
    12771265
     
    14351423            // Restore the original CSS text before applying user changes. This is needed to prevent
    14361424            // new properties from sticking around if the user adds one, then removes it.
    1437             InspectorBackend.setStyleText(WebInspector.Callback.wrap(null), this.style.id, this.originalCSSText);
     1425            WebInspector.cssModel.setCSSText(this.style.id, this.originalCSSText);
    14381426        }
    14391427
     
    14551443            this.treeOutline.removeChild(this);
    14561444        else if (this.originalCSSText) {
    1457             InspectorBackend.setStyleText(WebInspector.Callback.wrap(null), this.style.id, this.originalCSSText);
     1445            WebInspector.cssModel.setCSSText(this.style.id, this.originalCSSText);
    14581446
    14591447            if (this.treeOutline.section && this.treeOutline.section.pane)
     
    15421530
    15431531        var self = this;
    1544         function callback(success, newPayload, changedProperties)
     1532
     1533        function failureCallback()
    15451534        {
    1546             if (!success) {
    1547                 // The user typed something, but it didn't parse. Just abort and restore
    1548                 // the original title for this property.  If this was a new attribute and
    1549                 // we couldn't parse, then just remove it.
    1550                 if (self._newProperty) {
    1551                     self.parent.removeChild(self);
    1552                     return;
    1553                 }
    1554                 if (updateInterface)
    1555                     self.updateTitle();
     1535            // The user typed something, but it didn't parse. Just abort and restore
     1536            // the original title for this property.  If this was a new attribute and
     1537            // we couldn't parse, then just remove it.
     1538            if (self._newProperty) {
     1539                self.parent.removeChild(self);
    15561540                return;
    15571541            }
    1558 
     1542            if (updateInterface)
     1543                self.updateTitle();
     1544        }
     1545
     1546        function successCallback(newStyle, changedProperties)
     1547        {
    15591548            elementsPanel.removeStyleChange(section.identifier, self.style, self.name);
    15601549
     
    15631552                self.parent.removeChild(self);
    15641553            } else {
    1565                 self.style = WebInspector.CSSStyleDeclaration.parseStyle(newPayload);
     1554                self.style = newStyle;
    15661555                for (var i = 0; i < changedProperties.length; ++i)
    15671556                    elementsPanel.addStyleChange(section.identifier, self.style, changedProperties[i]);
     
    15751564                self.updateAll(true);
    15761565        }
    1577         InspectorBackend.applyStyleText(WebInspector.Callback.wrap(callback), this.style.id, styleText, this.name);
     1566
     1567        WebInspector.cssModel.applyStyleText(this.style.id, styleText, this.name, successCallback, failureCallback);
    15781568    }
    15791569}
  • trunk/WebCore/inspector/front-end/inspector.html

    r60555 r60680  
    4242    <script type="text/javascript" src="Object.js"></script>
    4343    <script type="text/javascript" src="Settings.js"></script>
     44    <script type="text/javascript" src="CSSStyleModel.js"></script>
    4445    <script type="text/javascript" src="Checkbox.js"></script>
    4546    <script type="text/javascript" src="ContextMenu.js"></script>
  • trunk/WebCore/inspector/front-end/inspector.js

    r60584 r60680  
    467467
    468468    this.breakpointManager = new WebInspector.BreakpointManager();
     469    this.cssModel = new WebInspector.CSSStyleModel();
    469470
    470471    this.panels = {};
Note: See TracChangeset for help on using the changeset viewer.