Changeset 291628 in webkit


Ignore:
Timestamp:
Mar 22, 2022 10:35:06 AM (4 months ago)
Author:
Nikita Vasilyev
Message:

Web Inspector: Inline swatch popovers should hide when inline swatches are removed
https://bugs.webkit.org/show_bug.cgi?id=235047
<rdar://problem/87687975>

Reviewed by Patrick Angle.

  • UserInterface/Views/InlineSwatch.js:

(WI.InlineSwatch):
(WI.InlineSwatch.prototype.dismissPopover):
(WI.InlineSwatch.prototype._presentPopover):

  • UserInterface/Views/SpreadsheetStyleProperty.js:

(WI.SpreadsheetStyleProperty.prototype.detached):
(WI.SpreadsheetStyleProperty.prototype.spreadsheetTextFieldDidCommit):
(WI.SpreadsheetStyleProperty.prototype._renderValue):
(WI.SpreadsheetStyleProperty.prototype._createInlineSwatch):

Location:
trunk/Source/WebInspectorUI
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r291466 r291628  
     12022-03-22  Nikita Vasilyev  <nvasilyev@apple.com>
     2
     3        Web Inspector: Inline swatch popovers should hide when inline swatches are removed
     4        https://bugs.webkit.org/show_bug.cgi?id=235047
     5        <rdar://problem/87687975>
     6
     7        Reviewed by Patrick Angle.
     8
     9        * UserInterface/Views/InlineSwatch.js:
     10        (WI.InlineSwatch):
     11        (WI.InlineSwatch.prototype.dismissPopover):
     12        (WI.InlineSwatch.prototype._presentPopover):
     13
     14        * UserInterface/Views/SpreadsheetStyleProperty.js:
     15        (WI.SpreadsheetStyleProperty.prototype.detached):
     16        (WI.SpreadsheetStyleProperty.prototype.spreadsheetTextFieldDidCommit):
     17        (WI.SpreadsheetStyleProperty.prototype._renderValue):
     18        (WI.SpreadsheetStyleProperty.prototype._createInlineSwatch):
     19
    1202022-03-17  Nikita Vasilyev  <nvasilyev@apple.com>
    221
  • trunk/Source/WebInspectorUI/UserInterface/Views/InlineSwatch.js

    r286885 r291628  
    106106        this._valueEditor = null;
    107107        this._readOnly = readOnly;
     108        this._popover = null;
    108109
    109110        this._updateSwatch();
     
    134135        this._shiftClickColorEnabled = !!value;
    135136        this._updateSwatch(true);
     137    }
     138
     139    dismissPopover()
     140    {
     141        this._popover?.dismiss();
    136142    }
    137143
     
    255261            value = this._fallbackValue();
    256262
    257         let popover = new WI.Popover(this);
    258 
    259         popover.windowResizeHandler = () => {
    260             this._presentPopover(popover);
     263        this._popover = new WI.Popover(this);
     264
     265        this._popover.windowResizeHandler = () => {
     266            this._presentPopover();
    261267        };
    262268
     
    283289            this._valueEditor.addEventListener(WI.GradientEditor.Event.ColorPickerToggled, function(event) {
    284290                this.update();
    285             }, popover);
     291            }, this._popover);
    286292            break;
    287293
     
    320326            });
    321327            this._valueEditor.codeMirror.on("update", () => {
    322                 popover.update();
     328                this._popover.update();
    323329            });
    324330            break;
     
    328334            return;
    329335
    330         popover.content = this._valueEditor.element;
    331         this._presentPopover(popover);
     336        this._popover.content = this._valueEditor.element;
     337        this._presentPopover(this._popover);
    332338
    333339        this.dispatchEventToListeners(WI.InlineSwatch.Event.Activated);
     
    409415    }
    410416
    411     _presentPopover(popover)
     417    _presentPopover()
    412418    {
    413419        let bounds = WI.Rect.rectFromClientRect(this._swatchElement.getBoundingClientRect());
    414         popover.present(bounds.pad(2), [WI.RectEdge.MAX_Y, WI.RectEdge.MIN_Y, WI.RectEdge.MIN_X]);
     420        this._popover.present(bounds.pad(2), [WI.RectEdge.MAX_Y, WI.RectEdge.MIN_Y, WI.RectEdge.MIN_X]);
    415421    }
    416422
  • trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js

    r287409 r291628  
    5353        this._hasInvalidVariableValue = false;
    5454        this._cssDocumentationPopover = null;
     55        this._activeInlineSwatch = null;
    5556
    5657        this.update();
     
    135136        if (this._valueTextField)
    136137            this._valueTextField.detached();
     138
     139        this._activeInlineSwatch?.dismissPopover();
     140        this._activeInlineSwatch = null;
     141
     142        this._cssDocumentationPopover?.dismiss();
     143        this._cssDocumentationPopover = null;
    137144    }
    138145
     
    387394
    388395        this._cssDocumentationPopover?.dismiss();
     396        this._cssDocumentationPopover = null;
    389397
    390398        if (direction === "forward") {
     
    483491    {
    484492        this._hasInvalidVariableValue = false;
     493        this._activeInlineSwatch = null;
    485494
    486495        const maxValueLength = 150;
     
    604613        }
    605614
    606         if (this._delegate && typeof this._delegate.stylePropertyInlineSwatchActivated === "function") {
    607             swatch.addEventListener(WI.InlineSwatch.Event.Activated, function(event) {
    608                 this._delegate.stylePropertyInlineSwatchActivated();
    609             }, this);
    610         }
     615        swatch.addEventListener(WI.InlineSwatch.Event.Activated, function(event) {
     616            this._activeInlineSwatch = swatch;
     617            this._delegate?.stylePropertyInlineSwatchActivated();
     618        }, this);
    611619
    612620        if (this._delegate && typeof this._delegate.stylePropertyInlineSwatchDeactivated === "function") {
Note: See TracChangeset for help on using the changeset viewer.