Changeset 228072 in webkit


Ignore:
Timestamp:
Feb 4, 2018 9:30:42 PM (6 years ago)
Author:
jmarcell@apple.com
Message:

Cherry-pick r228030. rdar://problem/37220121

Location:
branches/safari-605-branch/Source/WebInspectorUI
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-605-branch/Source/WebInspectorUI/ChangeLog

    r227822 r228072  
     12018-02-04  Jason Marcell  <jmarcell@apple.com>
     2
     3        Cherry-pick r228030. rdar://problem/37220121
     4
     5    2018-02-02  Devin Rousso  <webkit@devinrousso.com>
     6
     7            Web Inspector: Styles Redesign: Pasting multiple properties should create properties instead of a bad property
     8            https://bugs.webkit.org/show_bug.cgi?id=179622
     9            <rdar://problem/35511170>
     10
     11            Reviewed by Matt Baker.
     12
     13            * UserInterface/Views/SpreadsheetStyleProperty.js:
     14            (WI.SpreadsheetStyleProperty.prototype._remove):
     15            (WI.SpreadsheetStyleProperty.prototype._update):
     16            (WI.SpreadsheetStyleProperty.prototype.spreadsheetTextFieldDidCommit):
     17            (WI.SpreadsheetStyleProperty.prototype._handleNamePaste):
     18            When the user pastes into the name field, parse the text for a list of name-value pairs and
     19            replace the property being edited with the text of those pairs.
     20
     21            * UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js:
     22            (WI.SpreadsheetCSSStyleDeclarationEditor):
     23            (WI.SpreadsheetCSSStyleDeclarationEditor.prototype.layout):
     24            (WI.SpreadsheetCSSStyleDeclarationEditor.prototype.addBlankProperty):
     25            (WI.SpreadsheetCSSStyleDeclarationEditor.prototype.spreadsheetStylePropertyFocusMoved):
     26            (WI.SpreadsheetCSSStyleDeclarationEditor.prototype.spreadsheetStylePropertyAddBlankPropertySoon):
     27            (WI.SpreadsheetCSSStyleDeclarationEditor.prototype.spreadsheetStylePropertyRemoved):
     28            (WI.SpreadsheetCSSStyleDeclarationEditor.prototype._propertiesChanged):
     29            (WI.SpreadsheetCSSStyleDeclarationEditor.prototype.spreadsheetCSSStyleDeclarationEditorFocusMoved): Deleted.
     30            Calling `addBlankProperty` will trigger a layout on the next frame, but that might be before
     31            the CSSAgent has had a chance to finish refreshing, so we need a way to defer the creation
     32            of a new property until after we have finished the next layout (which is after the refresh).
     33            Drive-by: fix naming of some delegate functions.
     34
     35            * UserInterface/Models/CSSProperty.js:
     36            (WI.CSSProperty.prototype.replaceWithText):
     37            Provide a way for replacing the property with new text.
     38
    1392018-01-30  Jason Marcell  <jmarcell@apple.com>
    240
  • branches/safari-605-branch/Source/WebInspectorUI/UserInterface/Models/CSSProperty.js

    r227402 r228072  
    132132    }
    133133
     134    replaceWithText(text)
     135    {
     136        this._updateOwnerStyleText(this._text, text, true);
     137    }
     138
    134139    commentOut(disabled)
    135140    {
  • branches/safari-605-branch/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js

    r227661 r228072  
    4040
    4141        this._propertyPendingStartEditing = null;
     42        this._pendingAddBlankPropertyIndexOffset = NaN;
    4243        this._filterText = null;
    4344    }
     
    9192        if (this._filterText)
    9293            this.applyFilter(this._filterText);
     94
     95        if (!isNaN(this._pendingAddBlankPropertyIndexOffset))
     96            this.addBlankProperty(this._propertyViews.length - 1 - this._pendingAddBlankPropertyIndexOffset);
    9397    }
    9498
     
    205209    addBlankProperty(index)
    206210    {
     211        this._pendingAddBlankPropertyIndexOffset = NaN;
     212
    207213        if (index === -1) {
    208214            // Append to the end.
     
    214220    }
    215221
    216     spreadsheetCSSStyleDeclarationEditorFocusMoved({direction, movedFromProperty, willRemoveProperty})
    217     {
    218         let movedFromIndex = this._propertyViews.indexOf(movedFromProperty);
     222    spreadsheetStylePropertyFocusMoved(propertyView, {direction, willRemoveProperty})
     223    {
     224        let movedFromIndex = this._propertyViews.indexOf(propertyView);
    219225        console.assert(movedFromIndex !== -1, "Property doesn't exist, focusing on a selector as a fallback.");
    220226        if (movedFromIndex === -1) {
     
    255261    // SpreadsheetStyleProperty delegate
    256262
     263    spreadsheetStylePropertyAddBlankPropertySoon(propertyView, {index})
     264    {
     265        if (isNaN(index))
     266            index = this._propertyViews.length;
     267        this._pendingAddBlankPropertyIndexOffset = this._propertyViews.length - index;
     268    }
     269
    257270    spreadsheetStylePropertyRemoved(propertyView)
    258271    {
     
    261274        for (let index = 0; index < this._propertyViews.length; index++)
    262275            this._propertyViews[index].index = index;
     276
     277        this._focused = false;
    263278    }
    264279
     
    323338    _propertiesChanged(event)
    324339    {
    325         if (this.editing) {
     340        if (this.editing && isNaN(this._pendingAddBlankPropertyIndexOffset)) {
    326341            for (let propertyView of this._propertyViews)
    327342                propertyView.updateStatus();
  • branches/safari-605-branch/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js

    r227661 r228072  
    149149    // Private
    150150
    151     _remove()
     151    _remove(replacement = "")
    152152    {
    153153        this.element.remove();
    154         this._property.remove();
     154
     155        if (replacement)
     156            this._property.replaceWithText(replacement);
     157        else
     158            this._property.remove();
     159
    155160        this.detached();
    156161
     
    195200            this._nameElement.tabIndex = 0;
    196201            this._nameElement.addEventListener("beforeinput", this._handleNameBeforeInput.bind(this));
     202            this._nameElement.addEventListener("paste", this._handleNamePaste.bind(this));
    197203
    198204            this._nameTextField = new WI.SpreadsheetTextField(this, this._nameElement, this._nameCompletionDataProvider.bind(this));
     
    263269        }
    264270
    265         if (typeof this._delegate.spreadsheetCSSStyleDeclarationEditorFocusMoved === "function") {
     271        if (typeof this._delegate.spreadsheetStylePropertyFocusMoved === "function") {
    266272            // Move focus away from the current property, to the next or previous one, if exists, or to the next or previous rule, if exists.
    267             this._delegate.spreadsheetCSSStyleDeclarationEditorFocusMoved({direction, willRemoveProperty, movedFromProperty: this});
     273            this._delegate.spreadsheetStylePropertyFocusMoved(this, {direction, willRemoveProperty});
    268274        }
    269275
     
    560566    }
    561567
     568    _handleNamePaste(event)
     569    {
     570        let text = event.clipboardData.getData("text/plain");
     571        if (!text || !text.includes(":"))
     572            return;
     573
     574        event.preventDefault();
     575
     576        this._remove(text);
     577
     578        if (this._delegate.spreadsheetStylePropertyAddBlankPropertySoon) {
     579            this._delegate.spreadsheetStylePropertyAddBlankPropertySoon(this, {
     580                index: parseInt(this._element.dataset.propertyIndex) + 1,
     581            });
     582        }
     583    }
     584
    562585    _nameCompletionDataProvider(prefix)
    563586    {
Note: See TracChangeset for help on using the changeset viewer.