Changeset 223970 in webkit


Ignore:
Timestamp:
Oct 25, 2017 12:02:28 PM (7 years ago)
Author:
Nikita Vasilyev
Message:

Web Inspector: Styles Redesign: Newly added invalid property isn't immediately shown as invalid
https://bugs.webkit.org/show_bug.cgi?id=178488

Reviewed by Brian Burg.

  • UserInterface/Models/CSSStyleDeclaration.js:

(WI.CSSStyleDeclaration.prototype.newBlankProperty):
Call this.update to update _properties, _allProperties, _visibleProperties, and _allVisibleProperties.

  • UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.css:

(.spreadsheet-style-declaration-editor .property:matches(.invalid-name, .other-vendor, .overridden):not(.disabled)):
(.spreadsheet-style-declaration-editor .property.invalid-name:not(.disabled)):
(.spreadsheet-style-declaration-editor .property.invalid-value:not(.disabled) .value):
When the property name is valid, but the value isn't, display red line-through only for the value.
This is how it works in the old styles sidebar as well.

  • UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js:

(WI.SpreadsheetCSSStyleDeclarationEditor.prototype._propertiesChanged):
(WI.SpreadsheetCSSStyleDeclarationEditor):

  • UserInterface/Views/SpreadsheetStyleProperty.js:

(WI.SpreadsheetStyleProperty):
(WI.SpreadsheetStyleProperty.prototype.updateClassNames):
(WI.SpreadsheetStyleProperty.prototype._update):
Introduce updateClassNames method. Unlike _update, it doesn't change text selection or focus and
can be safely called on a property while it's being edited.

Location:
trunk/Source/WebInspectorUI
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r223952 r223970  
     12017-10-25  Nikita Vasilyev  <nvasilyev@apple.com>
     2
     3        Web Inspector: Styles Redesign: Newly added invalid property isn't immediately shown as invalid
     4        https://bugs.webkit.org/show_bug.cgi?id=178488
     5
     6        Reviewed by Brian Burg.
     7
     8        * UserInterface/Models/CSSStyleDeclaration.js:
     9        (WI.CSSStyleDeclaration.prototype.newBlankProperty):
     10        Call this.update to update _properties, _allProperties, _visibleProperties, and _allVisibleProperties.
     11
     12        * UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.css:
     13        (.spreadsheet-style-declaration-editor .property:matches(.invalid-name, .other-vendor, .overridden):not(.disabled)):
     14        (.spreadsheet-style-declaration-editor .property.invalid-name:not(.disabled)):
     15        (.spreadsheet-style-declaration-editor .property.invalid-value:not(.disabled) .value):
     16        When the property name is valid, but the value isn't, display red line-through only for the value.
     17        This is how it works in the old styles sidebar as well.
     18
     19        * UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js:
     20        (WI.SpreadsheetCSSStyleDeclarationEditor.prototype._propertiesChanged):
     21        (WI.SpreadsheetCSSStyleDeclarationEditor):
     22        * UserInterface/Views/SpreadsheetStyleProperty.js:
     23        (WI.SpreadsheetStyleProperty):
     24        (WI.SpreadsheetStyleProperty.prototype.updateClassNames):
     25        (WI.SpreadsheetStyleProperty.prototype._update):
     26        Introduce updateClassNames method. Unlike _update, it doesn't change text selection or focus and
     27        can be safely called on a property while it's being edited.
     28
    1292017-10-25  Devin Rousso  <webkit@devinrousso.com>
    230
  • trunk/Source/WebInspectorUI/UserInterface/Models/CSSStyleDeclaration.js

    r222959 r223970  
    362362        let text, name, value, priority, overridden, implicit, anonymous;
    363363        let enabled = true;
    364         let valid = true;
     364        let valid = false;
    365365        let styleSheetTextRange = this._rangeAfterPropertyAtIndex(insertAfterIndex);
    366         let property = new WI.CSSProperty(insertAfterIndex + 1, text, name, value, priority, enabled, overridden, implicit, anonymous, valid, styleSheetTextRange);
    367         property.ownerStyle = this;
     366
     367        let propertyIndex = insertAfterIndex + 1;
     368        let property = new WI.CSSProperty(propertyIndex, text, name, value, priority, enabled, overridden, implicit, anonymous, valid, styleSheetTextRange);
     369
     370        this._allProperties.insertAtIndex(property, propertyIndex);
     371        const suppressEvents = true;
     372        this.update(this._text, this._allProperties, this._styleSheetTextRange, suppressEvents);
    368373
    369374        return property;
  • trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.css

    r223575 r223970  
    7676}
    7777
    78 .spreadsheet-style-declaration-editor .property:matches(.invalid, .other-vendor, .overridden):not(.disabled) {
     78.spreadsheet-style-declaration-editor .property:matches(.invalid-name, .other-vendor, .overridden):not(.disabled) {
    7979    text-decoration: line-through;
    8080    -webkit-text-decoration-color: hsla(0, 0%, 0%, 0.6);
    8181}
    8282
    83 .spreadsheet-style-declaration-editor .property.invalid:not(.disabled) {
    84     -webkit-text-decoration-color: hsla(0, 100%, 50%, 0.6);
     83.spreadsheet-style-declaration-editor .property.invalid-name:not(.disabled) {
     84    -webkit-text-decoration-color: hsla(0, 100%, 50%, 0.5);
     85}
     86
     87.spreadsheet-style-declaration-editor .property.invalid-value:not(.disabled) .value {
     88    text-decoration: line-through;
     89    -webkit-text-decoration-color: hsla(0, 100%, 50%, 0.5);
    8590}
    8691
  • trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js

    r223333 r223970  
    222222    _propertiesChanged(event)
    223223    {
    224         if (!this._isFocused())
     224        if (this._isFocused()) {
     225            for (let propertyView of this._propertyViews)
     226                propertyView.updateClassNames();
     227        } else
    225228            this.needsLayout();
    226229    }
  • trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js

    r223867 r223970  
    4747        this._update();
    4848        property.addEventListener(WI.CSSProperty.Event.OverriddenStatusChanged, this._update, this);
     49        property.addEventListener(WI.CSSProperty.Event.Changed, this.updateClassNames, this);
    4950    }
    5051
     
    7172    }
    7273
    73     // Private
    74 
    75     _remove()
    76     {
    77         this.element.remove();
    78         this._property.remove();
    79         this.detached();
    80 
    81         if (this._delegate && typeof this._delegate.spreadsheetStylePropertyRemoved === "function")
    82             this._delegate.spreadsheetStylePropertyRemoved(this);
    83     }
    84 
    85     _update()
    86     {
    87         this.element.removeChildren();
    88         this.element.className = "";
    89 
     74    updateClassNames()
     75    {
    9076        let duplicatePropertyExistsBelow = (cssProperty) => {
    9177            let propertyFound = false;
     
    114100        if (!this._property.valid && this._property.hasOtherVendorNameOrKeyword())
    115101            classNames.push("other-vendor");
    116         else if (!this._property.valid) {
     102        else if (!this._property.valid && this._property.value !== "") {
    117103            let propertyNameIsValid = false;
    118104            if (WI.CSSCompletions.cssNameCompletions)
     
    120106
    121107            if (!propertyNameIsValid || duplicatePropertyExistsBelow(this._property))
    122                 classNames.push("invalid");
     108                classNames.push("invalid-name");
     109            else
     110                classNames.push("invalid-value");
    123111        }
    124112
     
    126114            classNames.push("disabled");
    127115
    128         this._element.classList.add(...classNames);
     116        this._element.className = classNames.join(" ");
     117    }
     118
     119    // Private
     120
     121    _remove()
     122    {
     123        this.element.remove();
     124        this._property.remove();
     125        this.detached();
     126
     127        if (this._delegate && typeof this._delegate.spreadsheetStylePropertyRemoved === "function")
     128            this._delegate.spreadsheetStylePropertyRemoved(this);
     129    }
     130
     131    _update()
     132    {
     133        this.element.removeChildren();
     134        this.updateClassNames();
    129135
    130136        if (this._property.editable) {
Note: See TracChangeset for help on using the changeset viewer.