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

Changeset 295166 in webkit


Ignore:
Timestamp:
Jun 2, 2022, 6:31:02 PM (4 years ago)
Author:
Patrick Angle
Message:

Web Inspector: Layout details sidebar panel does unnecessary tracking of the selected DOM node's styles
​https://bugs.webkit.org/show_bug.cgi?id=241245
rdar://94318782

Reviewed by Devin Rousso.

Code that, among other things, causes a layout when the selected DOM node's styles change should have been removed when
the Box Model diagram was removed from this sidebar panel. Additionally, because that was the only node-specific thing
in this panel, we can persist the sidebar panel even when the selected node is not an element.

  • Source/WebInspectorUI/UserInterface/Views/LayoutDetailsSidebarPanel.js:

(WI.LayoutDetailsSidebarPanel):
(WI.LayoutDetailsSidebarPanel.prototype.inspect): Deleted.
(WI.LayoutDetailsSidebarPanel.prototype.supportsDOMNode): Deleted.
(WI.LayoutDetailsSidebarPanel.prototype._nodeStylesRefreshed): Deleted.
(WI.LayoutDetailsSidebarPanel.prototype._nodeStylesNeedsRefreshed): Deleted.

Canonical link: ​https://commits.webkit.org/251250@main

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/UserInterface/Views/LayoutDetailsSidebarPanel.js

    r294695 r295166  
    3232        this._flexNodeSet = null;
    3333        this._gridNodeSet = null;
    34         this._nodeStyles = null;
    3534        this.element.classList.add("layout-panel");
    36     }
    37 
    38     // Public
    39 
    40     inspect(objects)
    41     {
    42         // Layout panel doesn't show when hasDOMNode is false.
    43         let hasDOMNode = super.inspect(objects);
    44         if (!hasDOMNode)
    45             return false;
    46 
    47         let stylesForNode = WI.cssManager.stylesForNode(this.domNode);
    48         stylesForNode.refreshIfNeeded().then((nodeStyles) => {
    49             if (nodeStyles === this._nodeStyles)
    50                 return;
    51 
    52             if (this._nodeStyles) {
    53                 this._nodeStyles.removeEventListener(WI.DOMNodeStyles.Event.Refreshed, this._nodeStylesRefreshed, this);
    54                 this._nodeStyles.removeEventListener(WI.DOMNodeStyles.Event.NeedsRefresh, this._nodeStylesNeedsRefreshed, this);
    55             }
    56 
    57             this._nodeStyles = nodeStyles;
    58 
    59             if (this._nodeStyles) {
    60                 this._nodeStyles.addEventListener(WI.DOMNodeStyles.Event.Refreshed, this._nodeStylesRefreshed, this);
    61                 this._nodeStyles.addEventListener(WI.DOMNodeStyles.Event.NeedsRefresh, this._nodeStylesNeedsRefreshed, this);
    62             }
    63 
    64             this.needsLayout();
    65         });
    66 
    67         return hasDOMNode;
    68     }
    69 
    70     supportsDOMNode(nodeToInspect)
    71     {
    72         return nodeToInspect.nodeType() === Node.ELEMENT_NODE;
    7335    }
    7436
    … …  
    191153    }
    192154
    193     _nodeStylesRefreshed()
    194     {
    195         if (this.isAttached)
    196             this.needsLayout();
    197     }
    198 
    199     _nodeStylesNeedsRefreshed()
    200     {
    201         if (this.isAttached)
    202             this._nodeStyles?.refresh();
    203     }
    204 
    205155    _removeNodeFromNodeSets(domNode)
    206156    {
Note: See TracChangeset for help on using the changeset viewer.