⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 185757 in webkit


Ignore:
Timestamp:
Jun 19, 2015, 11:49:19 AM (11 years ago)
Author:
Joseph Pecoraro
Message:

Web Inspector: Make rule icon toggle all properties for that selector on and off
https://bugs.webkit.org/show_bug.cgi?id=146031

Patch by Devin Rousso <Devin Rousso> on 2015-06-19
Reviewed by Timothy Hatcher.

  • UserInterface/Views/CSSStyleDeclarationSection.css:

(.style-declaration-section > .header > .icon.toggle-able:hover):
(.style-declaration-section.rule-disabled > .header > .icon):

  • UserInterface/Views/CSSStyleDeclarationSection.js:

(WebInspector.CSSStyleDeclarationSection): Added event listener to selector icon to toggle commenting of all properties for that rule.
(WebInspector.CSSStyleDeclarationSection.prototype._toggleRuleOnOff): Adds or removes comments to all properties for that rule.

  • UserInterface/Views/CSSStyleDeclarationTextEditor.js:

(WebInspector.CSSStyleDeclarationTextEditor.prototype.uncommentAllProperties.uncommentProperties):
(WebInspector.CSSStyleDeclarationTextEditor.prototype.uncommentAllProperties): Uncomments all properties.
(WebInspector.CSSStyleDeclarationTextEditor.prototype.commentAllProperties): Comments out all properties.
(WebInspector.CSSStyleDeclarationTextEditor.prototype._propertyCheckboxChanged): Moved comment logic to its own function.
(WebInspector.CSSStyleDeclarationTextEditor.prototype._propertyCommentCheckboxChanged): Moved uncomment logic to its own function.

Location:
trunk/Source/WebInspectorUI
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r185750 r185757  
     12015-06-19  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Make rule icon toggle all properties for that selector on and off
     4        https://bugs.webkit.org/show_bug.cgi?id=146031
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        * UserInterface/Views/CSSStyleDeclarationSection.css:
     9        (.style-declaration-section > .header > .icon.toggle-able:hover):
     10        (.style-declaration-section.rule-disabled > .header > .icon):
     11        * UserInterface/Views/CSSStyleDeclarationSection.js:
     12        (WebInspector.CSSStyleDeclarationSection): Added event listener to selector icon to toggle commenting of all properties for that rule.
     13        (WebInspector.CSSStyleDeclarationSection.prototype._toggleRuleOnOff): Adds or removes comments to all properties for that rule.
     14        * UserInterface/Views/CSSStyleDeclarationTextEditor.js:
     15        (WebInspector.CSSStyleDeclarationTextEditor.prototype.uncommentAllProperties.uncommentProperties):
     16        (WebInspector.CSSStyleDeclarationTextEditor.prototype.uncommentAllProperties): Uncomments all properties.
     17        (WebInspector.CSSStyleDeclarationTextEditor.prototype.commentAllProperties): Comments out all properties.
     18        (WebInspector.CSSStyleDeclarationTextEditor.prototype._propertyCheckboxChanged): Moved comment logic to its own function.
     19        (WebInspector.CSSStyleDeclarationTextEditor.prototype._propertyCommentCheckboxChanged): Moved uncomment logic to its own function.
     20
    1212015-06-19  Jon Lee  <jonlee@apple.com>
    222
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r185723 r185757  
    108108localizedStrings["Collapse columns"] = "Collapse columns";
    109109localizedStrings["Comment"] = "Comment";
     110localizedStrings["Comment All Properties"] = "Comment All Properties";
    110111localizedStrings["Compressed"] = "Compressed";
    111112localizedStrings["Compression"] = "Compression";
     
    494495localizedStrings["Type information for variable: %s"] = "Type information for variable: %s";
    495496localizedStrings["Unable to determine path to property from root"] = "Unable to determine path to property from root";
     497localizedStrings["Uncomment All Properties"] = "Uncomment All Properties";
    496498localizedStrings["Unknown node"] = "Unknown node";
    497499localizedStrings["Untitled"] = "Untitled";
  • trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.css

    r183579 r185757  
    6767    width: 16px;
    6868    height: 16px;
     69}
     70
     71.style-declaration-section > .header > .icon.toggle-able:hover {
     72    -webkit-filter: brightness(0.9);
     73}
     74
     75.style-declaration-section.rule-disabled > .header > .icon {
     76    opacity: 0.5;
    6977}
    7078
  • trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js

    r185723 r185757  
    3434    this._style = style || null;
    3535    this._selectorElements = [];
     36    this._ruleDisabled = false;
    3637
    3738    this._element = document.createElement("div");
     
    8788            iconClassName = WebInspector.DOMTreeElementPathComponent.DOMElementIconStyleClassName;
    8889        break;
     90    }
     91
     92    // Matches all situations except for User Agent styles.
     93    if (!(style.ownerRule && style.ownerRule.type === WebInspector.CSSRule.Type.UserAgent)) {
     94        this._iconElement.classList.add("toggle-able");
     95        this._iconElement.title = WebInspector.UIString("Comment All Properties");
     96        this._iconElement.addEventListener("click", this._toggleRuleOnOff.bind(this));
    8997    }
    9098
     
    377385    },
    378386
     387    _toggleRuleOnOff: function()
     388    {
     389        this._ruleDisabled = this._ruleDisabled ? !this._propertiesTextEditor.uncommentAllProperties() : this._propertiesTextEditor.commentAllProperties();
     390        this._iconElement.title = this._ruleDisabled ? WebInspector.UIString("Uncomment All Properties") : WebInspector.UIString("Comment All Properties");
     391        this._element.classList.toggle("rule-disabled", this._ruleDisabled);
     392    },
     393
    379394    _commitSelector: function(mutations)
    380395    {
  • trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js

    r185723 r185757  
    303303    }
    304304
     305    uncommentAllProperties()
     306    {
     307        function uncommentProperties(properties)
     308        {
     309            if (!properties.length)
     310                return false;
     311
     312            for (var property of properties) {
     313                if (property._commentRange) {
     314                    this._uncommentRange(property._commentRange);
     315                    property._commentRange = null;
     316                }
     317            }
     318
     319            return true;
     320        }
     321
     322        return uncommentProperties.call(this, this._style.pendingProperties) || uncommentProperties.call(this, this._style.properties);
     323    }
     324
     325    commentAllProperties()
     326    {
     327        if (!this._style.properties.length)
     328            return false;
     329
     330        for (var property of this._style.properties) {
     331            if (property.__propertyTextMarker)
     332                this._commentProperty(property);
     333        }
     334
     335        return true;
     336    }
     337
    305338    // Protected
    306339
     
    713746            return;
    714747
     748        this._commentProperty(property);
     749    }
     750
     751    _commentProperty(property)
     752    {
    715753        var textMarker = property.__propertyTextMarker;
    716754        console.assert(textMarker);
     
    724762            return;
    725763
     764        property._commentRange = range;
     765        property._commentRange.to.ch += 6; // Number of characters added by comments.
     766
    726767        var text = this._codeMirror.getRange(range.from, range.to);
    727768
     
    751792            return;
    752793
     794        this._uncommentRange(range);
     795    }
     796
     797    _uncommentRange(range)
     798    {
    753799        var text = this._codeMirror.getRange(range.from, range.to);
    754800
Note: See TracChangeset for help on using the changeset viewer.