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

Changeset 272433 in webkit


Ignore:
Timestamp:
Feb 5, 2021, 12:18:09 PM (6 years ago)
Author:
Patrick Angle
Message:

Web Inspector: Implement backend support for maintaining a list of Grid layout contexts
https://bugs.webkit.org/show_bug.cgi?id=221228

Reviewed by Devin Rousso.

Source/JavaScriptCore:

Added CSS.LayoutContextType property to DOM.Node and added CSS.nodeLayoutContextTypeChanged event.

  • inspector/protocol/CSS.json:
  • Added CSS.LayoutContextType type.
  • Added DOM.nodeLayoutContextTypeChanged event.
  • inspector/protocol/DOM.json:
  • Added layoutContextType property to DOM.Node type.

Source/WebCore:

Test: inspector/dom/layout-context.html

Implemented support for getting the layout context for grid nodes as part of the existing DOM.Node protocol
object as well as firing an event when the layout context type changes for a node.

  • dom/Element.cpp:

(WebCore::Element::didChangeRenderer):

  • Handle the underlying RenderObject changing.
  • dom/Element.h:
  • dom/Node.h:

(WebCore::Node::didChangeRenderer):

  • inspector/InspectorInstrumentation.cpp:

(WebCore::InspectorInstrumentation::nodeLayoutContextChangedImpl):

  • inspector/InspectorInstrumentation.h:

(WebCore::InspectorInstrumentation::nodeLayoutContextChanged):

  • Add instrumentation for layout context changes.
  • inspector/agents/InspectorCSSAgent.cpp:

(WebCore::InspectorCSSAgent::layoutContextTypeForRenderer):
(WebCore::InspectorCSSAgent::nodeLayoutContextTypeChanged):

  • Inform the frontend when a known node changes its layout context.
  • inspector/agents/InspectorCSSAgent.h:
  • inspector/agents/InspectorDOMAgent.cpp:

(WebCore::InspectorDOMAgent::buildObjectForNode):

  • Set the layout context for nodes that will be new to the frontend.
  • rendering/RenderObject.h:

(WebCore::Node::setRenderer):

Source/WebInspectorUI:

Added layoutContextType property to WI.DOMNode and listener for CSS.nodeLayoutContextTypeChanged event.

  • UserInterface/Controllers/DOMManager.js:

(WI.DOMManager.prototype.nodeLayoutContextTypeChanged):

  • When a node's layout context changes, update the WI.DOMNode
  • UserInterface/Models/DOMNode.js:

(WI.DOMNode):
(WI.DOMNode.prototype.get layoutContextType):
(WI.DOMNode.prototype.set layoutContextType):

  • Fire an event when the layout context type changes.
  • UserInterface/Protocol/CSSObserver.js:

(WI.CSSObserver.prototype.nodeLayoutContextTypeChanged):

  • Listen for the CSS.nodeLayoutContextTypeChanged event.

LayoutTests:

Added tests for CSS.nodeLayoutContextTypeChanged event and corresponding properties.

  • inspector/css/nodeLayoutContextTypeChanged-expected.txt: Added.
  • inspector/css/nodeLayoutContextTypeChanged.html: Added.
Location:
trunk
Files:
2 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r272427 r272433  
     12021-02-05  Patrick Angle  <pangle@apple.com>
     2
     3        Web Inspector: Implement backend support for maintaining a list of Grid layout contexts
     4        https://bugs.webkit.org/show_bug.cgi?id=221228
     5
     6        Reviewed by Devin Rousso.
     7
     8        Added tests for `CSS.nodeLayoutContextTypeChanged` event and corresponding properties.
     9
     10        * inspector/css/nodeLayoutContextTypeChanged-expected.txt: Added.
     11        * inspector/css/nodeLayoutContextTypeChanged.html: Added.
     12
    1132021-02-05  Rini Patel  <rini_patel@apple.com>
    214
  • trunk/Source/JavaScriptCore/ChangeLog

    r272430 r272433  
     12021-02-05  Patrick Angle  <pangle@apple.com>
     2
     3        Web Inspector: Implement backend support for maintaining a list of Grid layout contexts
     4        https://bugs.webkit.org/show_bug.cgi?id=221228
     5
     6        Reviewed by Devin Rousso.
     7
     8        Added `CSS.LayoutContextType` property to `DOM.Node` and added `CSS.nodeLayoutContextTypeChanged` event.
     9
     10        * inspector/protocol/CSS.json:
     11        - Added `CSS.LayoutContextType` type.
     12        - Added `DOM.nodeLayoutContextTypeChanged` event.
     13        * inspector/protocol/DOM.json:
     14        - Added `layoutContextType` property to `DOM.Node` type.
     15
    1162021-02-05  Yusuke Suzuki  <ysuzuki@apple.com>
    217
  • trunk/Source/JavaScriptCore/inspector/protocol/CSS.json

    r270637 r272433  
    253253                { "name": "defaultValue", "type": "number", "description": "The value that is used for the axis when it is not otherwise controlled." }
    254254            ]
     255        },
     256        {
     257            "id": "LayoutContextType",
     258            "type": "string",
     259            "enum": ["grid"],
     260            "description": "The layout context type of a node."
    255261        }
    256262    ],
     
    442448                { "name": "styleSheetId", "$ref": "StyleSheetId", "description": "Identifier of the removed stylesheet." }
    443449            ]
     450        },
     451        {
     452            "name": "nodeLayoutContextTypeChanged",
     453            "description": "Called when a node's layout context type has changed.",
     454            "parameters": [
     455                { "name": "nodeId", "$ref": "DOM.NodeId", "description": "Identifier of the node whose layout context type changed." },
     456                { "name": "layoutContextType", "$ref": "LayoutContextType", "optional": true, "description": "The new layout context type of the node. When not provided, the <code>LayoutContextType</code> of the node is not a context for which Web Inspector has specific functionality." }
     457            ]
    444458        }
    445459    ]
  • trunk/Source/JavaScriptCore/inspector/protocol/DOM.json

    r272197 r272433  
    6767                { "name": "templateContent", "$ref": "Node", "optional": true, "description": "Content document fragment for template elements" },
    6868                { "name": "pseudoElements", "type": "array", "items": { "$ref": "Node" }, "optional": true, "description": "Pseudo elements associated with this node." },
    69                 { "name": "contentSecurityPolicyHash", "type": "string", "optional": true, "description": "Computed SHA-256 Content Security Policy hash source for given element." }
     69                { "name": "contentSecurityPolicyHash", "type": "string", "optional": true, "description": "Computed SHA-256 Content Security Policy hash source for given element." },
     70                { "name": "layoutContextType", "$ref": "CSS.LayoutContextType", "optional": true, "description": "The layout context type of the node. When not provided, the <code>LayoutContextType</code> of the node is not a context for which Web Inspector has specific functionality." }
    7071            ]
    7172        },
  • trunk/Source/WebCore/ChangeLog

    r272429 r272433  
     12021-02-05  Patrick Angle  <pangle@apple.com>
     2
     3        Web Inspector: Implement backend support for maintaining a list of Grid layout contexts
     4        https://bugs.webkit.org/show_bug.cgi?id=221228
     5
     6        Reviewed by Devin Rousso.
     7
     8        Test: inspector/dom/layout-context.html
     9
     10        Implemented support for getting the layout context for `grid` nodes as part of the existing `DOM.Node` protocol
     11        object as well as firing an event when the layout context type changes for a node.
     12
     13        * dom/Element.cpp:
     14        (WebCore::Element::didChangeRenderer):
     15        - Handle the underlying RenderObject changing.
     16        * dom/Element.h:
     17        * dom/Node.h:
     18        (WebCore::Node::didChangeRenderer):
     19        * inspector/InspectorInstrumentation.cpp:
     20        (WebCore::InspectorInstrumentation::nodeLayoutContextChangedImpl):
     21        * inspector/InspectorInstrumentation.h:
     22        (WebCore::InspectorInstrumentation::nodeLayoutContextChanged):
     23        - Add instrumentation for layout context changes.
     24        * inspector/agents/InspectorCSSAgent.cpp:
     25        (WebCore::InspectorCSSAgent::layoutContextTypeForRenderer):
     26        (WebCore::InspectorCSSAgent::nodeLayoutContextTypeChanged):
     27        - Inform the frontend when a known node changes its layout context.
     28        * inspector/agents/InspectorCSSAgent.h:
     29        * inspector/agents/InspectorDOMAgent.cpp:
     30        (WebCore::InspectorDOMAgent::buildObjectForNode):
     31        - Set the layout context for nodes that will be new to the frontend.
     32        * rendering/RenderObject.h:
     33        (WebCore::Node::setRenderer):
     34
    1352021-02-05  Chris Dumez  <cdumez@apple.com>
    236
  • trunk/Source/WebCore/dom/Element.cpp

    r272370 r272433  
    45504550}
    45514551
     4552void Element::didChangeRenderer(RenderObject* oldRenderer)
     4553{
     4554    InspectorInstrumentation::nodeLayoutContextChanged(*this, oldRenderer);
     4555}
     4556
    45524557#if ENABLE(CSS_TYPED_OM)
    45534558
  • trunk/Source/WebCore/dom/Element.h

    r271930 r272433  
    728728   
    729729    void attachAttributeNodeIfNeeded(Attr&);
     730   
     731    void didChangeRenderer(RenderObject*) final;
    730732
    731733#if ASSERT_ENABLED
  • trunk/Source/WebCore/dom/Node.h

    r272117 r272433  
    707707    static void moveTreeToNewScope(Node&, TreeScope& oldScope, TreeScope& newScope);
    708708    void moveNodeToNewDocument(Document& oldDocument, Document& newDocument);
     709   
     710    virtual void didChangeRenderer(RenderObject*) { };
    709711
    710712    struct NodeRareDataDeleter {
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r268900 r272433  
    177177}
    178178
     179void InspectorInstrumentation::nodeLayoutContextChangedImpl(InstrumentingAgents& instrumentingAgents, Node& node, RenderObject* oldRenderer)
     180{
     181    if (auto* cssAgent = instrumentingAgents.enabledCSSAgent())
     182        cssAgent->nodeLayoutContextTypeChanged(node, oldRenderer);
     183}
     184
    179185void InspectorInstrumentation::willModifyDOMAttrImpl(InstrumentingAgents& instrumentingAgents, Element& element, const AtomString& oldValue, const AtomString& newValue)
    180186{
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r268900 r272433  
    127127    static void willRemoveDOMNode(Document&, Node&);
    128128    static void didRemoveDOMNode(Document&, Node&);
     129    static void nodeLayoutContextChanged(Node&, RenderObject*);
    129130    static void willModifyDOMAttr(Document&, Element&, const AtomString& oldValue, const AtomString& newValue);
    130131    static void didModifyDOMAttr(Document&, Element&, const AtomString& name, const AtomString& value);
     
    351352    static void willRemoveDOMNodeImpl(InstrumentingAgents&, Node&);
    352353    static void didRemoveDOMNodeImpl(InstrumentingAgents&, Node&);
     354    static void nodeLayoutContextChangedImpl(InstrumentingAgents&, Node&, RenderObject*);
    353355    static void willModifyDOMAttrImpl(InstrumentingAgents&, Element&, const AtomString& oldValue, const AtomString& newValue);
    354356    static void didModifyDOMAttrImpl(InstrumentingAgents&, Element&, const AtomString& name, const AtomString& value);
     
    603605}
    604606
     607inline void InspectorInstrumentation::nodeLayoutContextChanged(Node& node, RenderObject* oldRenderer)
     608{
     609    FAST_RETURN_IF_NO_FRONTENDS(void());
     610    if (auto* agents = instrumentingAgents(node.document()))
     611        nodeLayoutContextChangedImpl(*agents, node, oldRenderer);
     612}
     613
    605614inline void InspectorInstrumentation::willModifyDOMAttr(Document& document, Element& element, const AtomString& oldValue, const AtomString& newValue)
    606615{
  • trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp

    r270637 r272433  
    5555#include "NodeList.h"
    5656#include "PseudoElement.h"
     57#include "RenderGrid.h"
    5758#include "RenderStyleConstants.h"
    5859#include "SVGStyleElement.h"
     
    925926}
    926927
     928Optional<Protocol::CSS::LayoutContextType> InspectorCSSAgent::layoutContextTypeForRenderer(RenderObject* renderer)
     929{
     930    if (is<RenderGrid>(renderer))
     931        return Protocol::CSS::LayoutContextType::Grid;
     932    return WTF::nullopt;
     933}
     934
     935void InspectorCSSAgent::nodeLayoutContextTypeChanged(Node& node, RenderObject* oldRenderer)
     936{
     937    auto* domAgent = m_instrumentingAgents.persistentDOMAgent();
     938    if (!domAgent)
     939        return;
     940   
     941    auto newLayoutContextType = layoutContextTypeForRenderer(node.renderer());
     942    if (newLayoutContextType == layoutContextTypeForRenderer(oldRenderer))
     943        return;
     944   
     945    // FIXME: <https://webkit.org/b/221449> Support enabling events for uninstrumented nodes.
     946    auto nodeId = domAgent->boundNodeId(&node);
     947    if (!nodeId)
     948        return;
     949   
     950    m_frontendDispatcher->nodeLayoutContextTypeChanged(nodeId, WTFMove(newLayoutContextType));
     951}
     952
    927953InspectorStyleSheetForInlineStyle& InspectorCSSAgent::asInspectorStyleSheet(StyledElement& element)
    928954{
  • trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.h

    r270637 r272433  
    5151class Node;
    5252class NodeList;
     53class RenderObject;
    5354class StyleRule;
    5455
     
    8283
    8384    static CSSStyleRule* asCSSStyleRule(CSSRule&);
     85    static Optional<Inspector::Protocol::CSS::LayoutContextType> layoutContextTypeForRenderer(RenderObject*);
    8486
    8587    // InspectorAgentBase
     
    114116    void activeStyleSheetsUpdated(Document&);
    115117    bool forcePseudoState(const Element&, CSSSelector::PseudoClassType);
     118    void nodeLayoutContextTypeChanged(Node&, RenderObject*);
    116119
    117120    // InspectorDOMAgent hooks
  • trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp

    r272197 r272433  
    9494#include "Pasteboard.h"
    9595#include "PseudoElement.h"
     96#include "RenderGrid.h"
    9697#include "RenderStyle.h"
    9798#include "RenderStyleConstants.h"
     
    17571758            value->setChildren(WTFMove(children));
    17581759    }
     1760   
     1761    if (auto layoutContextType = InspectorCSSAgent::layoutContextTypeForRenderer(node->renderer()))
     1762        value->setLayoutContextType(layoutContextType.value());
    17591763
    17601764    auto* pageAgent = m_instrumentingAgents.enabledPageAgent();
  • trunk/Source/WebCore/rendering/RenderObject.h

    r271559 r272433  
    11481148inline void Node::setRenderer(RenderObject* renderer)
    11491149{
     1150    auto oldRenderer = this->renderer();
    11501151    m_rendererWithStyleFlags.setPointer(renderer);
     1152    didChangeRenderer(oldRenderer);
    11511153}
    11521154
  • trunk/Source/WebInspectorUI/ChangeLog

    r272372 r272433  
     12021-02-05  Patrick Angle  <pangle@apple.com>
     2
     3        Web Inspector: Implement backend support for maintaining a list of Grid layout contexts
     4        https://bugs.webkit.org/show_bug.cgi?id=221228
     5
     6        Reviewed by Devin Rousso.
     7
     8        Added `layoutContextType` property to `WI.DOMNode` and listener for `CSS.nodeLayoutContextTypeChanged` event.
     9
     10        * UserInterface/Controllers/DOMManager.js:
     11        (WI.DOMManager.prototype.nodeLayoutContextTypeChanged):
     12        - When a node's layout context changes, update the WI.DOMNode
     13        * UserInterface/Models/DOMNode.js:
     14        (WI.DOMNode):
     15        (WI.DOMNode.prototype.get layoutContextType):
     16        (WI.DOMNode.prototype.set layoutContextType):
     17        - Fire an event when the layout context type changes.
     18        * UserInterface/Protocol/CSSObserver.js:
     19        (WI.CSSObserver.prototype.nodeLayoutContextTypeChanged):
     20        - Listen for the `CSS.nodeLayoutContextTypeChanged` event.
     21
    1222021-02-04  Razvan Caliman  <rcaliman@apple.com>
    223
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js

    r272197 r272433  
    222222    }
    223223
     224    nodeLayoutContextTypeChanged(nodeId, layoutContextType)
     225    {
     226        let domNode = this._idToDOMNode[nodeId];
     227        console.assert(domNode instanceof WI.DOMNode, domNode, nodeId);
     228        if (!domNode)
     229            return;
     230
     231        domNode.layoutContextType = layoutContextType;
     232    }
     233
    224234    // Private
    225235
  • trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js

    r272197 r272433  
    5353        this._computedRole = null;
    5454        this._contentSecurityPolicyHash = payload.contentSecurityPolicyHash;
     55        this._layoutContextType = payload.layoutContextType;
    5556
    5657        if (this._nodeType === Node.DOCUMENT_NODE)
     
    241242    {
    242243        this._childNodeCount = count;
     244    }
     245
     246    get layoutContextType()
     247    {
     248        return this._layoutContextType;
     249    }
     250
     251    set layoutContextType(layoutContextType)
     252    {
     253        console.assert(layoutContextType !== this._layoutContextType);
     254        this._layoutContextType = layoutContextType;
     255        this.dispatchEventToListeners(WI.DOMNode.Event.LayoutContextTypeChanged);
    243256    }
    244257
     
    11231136    DidFireEvent: "dom-node-did-fire-event",
    11241137    PowerEfficientPlaybackStateChanged: "dom-node-power-efficient-playback-state-changed",
     1138    LayoutContextTypeChanged: "dom-node-layout-context-type-changed",
    11251139};
    11261140
     
    11421156    Failed: "failed",
    11431157};
     1158
     1159// Corresponds to `CSS.LayoutContextType`.
     1160WI.DOMNode.LayoutContextType = {
     1161    Grid: "grid",
     1162};
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/CSSObserver.js

    r261105 r272433  
    4848    }
    4949
     50    nodeLayoutContextTypeChanged(nodeId, layoutContextType)
     51    {
     52        WI.domManager.nodeLayoutContextTypeChanged(nodeId, layoutContextType);
     53    }
     54
    5055    namedFlowCreated(namedFlow)
    5156    {
Note: See TracChangeset for help on using the changeset viewer.