Title: [272433] trunk
Revision
272433
Author
[email protected]
Date
2021-02-05 12:18:09 -0800 (Fri, 05 Feb 2021)

Log 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/_javascript_Core:

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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (272432 => 272433)


--- trunk/LayoutTests/ChangeLog	2021-02-05 19:26:00 UTC (rev 272432)
+++ trunk/LayoutTests/ChangeLog	2021-02-05 20:18:09 UTC (rev 272433)
@@ -1,3 +1,15 @@
+2021-02-05  Patrick Angle  <[email protected]>
+
+        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.
+
+        Added tests for `CSS.nodeLayoutContextTypeChanged` event and corresponding properties.
+
+        * inspector/css/nodeLayoutContextTypeChanged-expected.txt: Added.
+        * inspector/css/nodeLayoutContextTypeChanged.html: Added.
+
 2021-02-05  Rini Patel  <[email protected]>
 
         [GPU Process] Repopulate the TestExpectations file #2

Added: trunk/LayoutTests/inspector/css/nodeLayoutContextTypeChanged-expected.txt (0 => 272433)


--- trunk/LayoutTests/inspector/css/nodeLayoutContextTypeChanged-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/css/nodeLayoutContextTypeChanged-expected.txt	2021-02-05 20:18:09 UTC (rev 272433)
@@ -0,0 +1,12 @@
+Tests for the CSS.nodeLayoutContextTypeChanged event.
+
+
+== Running test suite: CSS.nodeLayoutContextTypeChanged
+-- Running test case: CSS.nodeLayoutContextTypeChanged.GridToNonGrid
+PASS: Layout context should be `grid`.
+PASS: Layout context should now be `undefined`.
+
+-- Running test case: CSS.nodeLayoutContextTypeChanged.NonGridToGrid
+PASS: Layout context should be `undefined`.
+PASS: Layout context should now be `grid`.
+

Added: trunk/LayoutTests/inspector/css/nodeLayoutContextTypeChanged.html (0 => 272433)


--- trunk/LayoutTests/inspector/css/nodeLayoutContextTypeChanged.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/css/nodeLayoutContextTypeChanged.html	2021-02-05 20:18:09 UTC (rev 272433)
@@ -0,0 +1,92 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function changeElementDisplayValue(id, value)
+{
+    document.getElementById(id).style.display = value;
+}
+
+function test()
+{
+    let documentNode;
+
+    let suite = InspectorTest.createAsyncSuite("CSS.nodeLayoutContextTypeChanged");
+
+    function addTestCase({name, description, selector, domNodeHandler})
+    {
+        suite.addTestCase({
+            name,
+            description,
+            async test() {
+                let nodeId = await documentNode.querySelector(selector);
+                let domNode = WI.domManager.nodeForId(nodeId);
+                InspectorTest.assert(domNode, `Should find DOM Node for selector '${selector}'.`);
+                await domNodeHandler(domNode);
+            },
+        });
+    }
+
+    async function changeElementDisplayValue(id, value)
+    {
+        await InspectorTest.evaluateInPage(`changeElementDisplayValue("${id}", "${value}")`);
+    }
+
+    addTestCase({
+        name: "CSS.nodeLayoutContextTypeChanged.GridToNonGrid",
+        description: "Change a `grid` to a non-grid.",
+        selector: "#gridToNonGrid",
+        async domNodeHandler(domNode) {
+            InspectorTest.expectEqual(domNode.layoutContextType, WI.DOMNode.LayoutContextType.Grid, "Layout context should be `grid`.");
+
+            await Promise.all([
+                domNode.awaitEvent(WI.DOMNode.Event.LayoutContextTypeChanged),
+                changeElementDisplayValue("gridToNonGrid", "block"),
+            ]);
+
+            InspectorTest.expectEqual(domNode.layoutContextType, undefined, "Layout context should now be `undefined`.");
+        }
+    });
+
+    addTestCase({
+        name: "CSS.nodeLayoutContextTypeChanged.NonGridToGrid",
+        description: "Change a non-grid to a grid.",
+        selector: "#nonGridToGrid",
+        async domNodeHandler(domNode) {
+            InspectorTest.expectEqual(domNode.layoutContextType, undefined, "Layout context should be `undefined`.");
+
+            await Promise.all([
+                domNode.awaitEvent(WI.DOMNode.Event.LayoutContextTypeChanged),
+                changeElementDisplayValue("nonGridToGrid", "grid"),
+            ]);
+
+            InspectorTest.expectEqual(domNode.layoutContextType, WI.DOMNode.LayoutContextType.Grid, "Layout context should now be `grid`.");
+        }
+    });
+
+    WI.domManager.requestDocument().then((doc) => {
+        documentNode = doc;
+        suite.runTestCasesAndFinish();
+    });
+}
+</script>
+<style>
+    .grid-container {
+        display: grid;
+    }
+</style>
+</head>
+<body _onload_="runTest()">
+    <p>Tests for the CSS.nodeLayoutContextTypeChanged event.</p>
+    <div id="gridToNonGrid" class="grid-container">
+        <div></div>
+        <div></div>
+    </div>
+
+    <div id="nonGridToGrid">
+        <div></div>
+        <div></div>
+    </div>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/_javascript_Core/ChangeLog (272432 => 272433)


--- trunk/Source/_javascript_Core/ChangeLog	2021-02-05 19:26:00 UTC (rev 272432)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-02-05 20:18:09 UTC (rev 272433)
@@ -1,3 +1,18 @@
+2021-02-05  Patrick Angle  <[email protected]>
+
+        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.
+
+        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.
+
 2021-02-05  Yusuke Suzuki  <[email protected]>
 
         Unreviewed, follow-up change after r272428

Modified: trunk/Source/_javascript_Core/inspector/protocol/CSS.json (272432 => 272433)


--- trunk/Source/_javascript_Core/inspector/protocol/CSS.json	2021-02-05 19:26:00 UTC (rev 272432)
+++ trunk/Source/_javascript_Core/inspector/protocol/CSS.json	2021-02-05 20:18:09 UTC (rev 272433)
@@ -252,6 +252,12 @@
                 { "name": "maximumValue", "type": "number", "description": "The maximum value that will affect the axis." },
                 { "name": "defaultValue", "type": "number", "description": "The value that is used for the axis when it is not otherwise controlled." }
             ]
+        },
+        {
+            "id": "LayoutContextType",
+            "type": "string",
+            "enum": ["grid"],
+            "description": "The layout context type of a node."
         }
     ],
     "commands": [
@@ -441,6 +447,14 @@
             "parameters": [
                 { "name": "styleSheetId", "$ref": "StyleSheetId", "description": "Identifier of the removed stylesheet." }
             ]
+        },
+        {
+            "name": "nodeLayoutContextTypeChanged",
+            "description": "Called when a node's layout context type has changed.",
+            "parameters": [
+                { "name": "nodeId", "$ref": "DOM.NodeId", "description": "Identifier of the node whose layout context type changed." },
+                { "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." }
+            ]
         }
     ]
 }

Modified: trunk/Source/_javascript_Core/inspector/protocol/DOM.json (272432 => 272433)


--- trunk/Source/_javascript_Core/inspector/protocol/DOM.json	2021-02-05 19:26:00 UTC (rev 272432)
+++ trunk/Source/_javascript_Core/inspector/protocol/DOM.json	2021-02-05 20:18:09 UTC (rev 272433)
@@ -66,7 +66,8 @@
                 { "name": "shadowRoots", "type": "array", "optional": true, "items": { "$ref": "Node" }, "description": "Shadow root list for given element host." },
                 { "name": "templateContent", "$ref": "Node", "optional": true, "description": "Content document fragment for template elements" },
                 { "name": "pseudoElements", "type": "array", "items": { "$ref": "Node" }, "optional": true, "description": "Pseudo elements associated with this node." },
-                { "name": "contentSecurityPolicyHash", "type": "string", "optional": true, "description": "Computed SHA-256 Content Security Policy hash source for given element." }
+                { "name": "contentSecurityPolicyHash", "type": "string", "optional": true, "description": "Computed SHA-256 Content Security Policy hash source for given element." },
+                { "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." }
             ]
         },
         {

Modified: trunk/Source/WebCore/ChangeLog (272432 => 272433)


--- trunk/Source/WebCore/ChangeLog	2021-02-05 19:26:00 UTC (rev 272432)
+++ trunk/Source/WebCore/ChangeLog	2021-02-05 20:18:09 UTC (rev 272433)
@@ -1,3 +1,37 @@
+2021-02-05  Patrick Angle  <[email protected]>
+
+        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.
+
+        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):
+
 2021-02-05  Chris Dumez  <[email protected]>
 
         [GPUProcess] If the GPUProcess crashes during fullscreen playback, video pauses and exits fullscreen

Modified: trunk/Source/WebCore/dom/Element.cpp (272432 => 272433)


--- trunk/Source/WebCore/dom/Element.cpp	2021-02-05 19:26:00 UTC (rev 272432)
+++ trunk/Source/WebCore/dom/Element.cpp	2021-02-05 20:18:09 UTC (rev 272433)
@@ -4549,6 +4549,11 @@
     return ElementIdentifier::generate();
 }
 
+void Element::didChangeRenderer(RenderObject* oldRenderer)
+{
+    InspectorInstrumentation::nodeLayoutContextChanged(*this, oldRenderer);
+}
+
 #if ENABLE(CSS_TYPED_OM)
 
 StylePropertyMap* Element::attributeStyleMap()

Modified: trunk/Source/WebCore/dom/Element.h (272432 => 272433)


--- trunk/Source/WebCore/dom/Element.h	2021-02-05 19:26:00 UTC (rev 272432)
+++ trunk/Source/WebCore/dom/Element.h	2021-02-05 20:18:09 UTC (rev 272433)
@@ -727,6 +727,8 @@
     void ownerDocument() const = delete;
     
     void attachAttributeNodeIfNeeded(Attr&);
+    
+    void didChangeRenderer(RenderObject*) final;
 
 #if ASSERT_ENABLED
     WEBCORE_EXPORT bool fastAttributeLookupAllowed(const QualifiedName&) const;

Modified: trunk/Source/WebCore/dom/Node.h (272432 => 272433)


--- trunk/Source/WebCore/dom/Node.h	2021-02-05 19:26:00 UTC (rev 272432)
+++ trunk/Source/WebCore/dom/Node.h	2021-02-05 20:18:09 UTC (rev 272433)
@@ -706,6 +706,8 @@
     static void moveShadowTreeToNewDocument(ShadowRoot&, Document& oldDocument, Document& newDocument);
     static void moveTreeToNewScope(Node&, TreeScope& oldScope, TreeScope& newScope);
     void moveNodeToNewDocument(Document& oldDocument, Document& newDocument);
+    
+    virtual void didChangeRenderer(RenderObject*) { };
 
     struct NodeRareDataDeleter {
         void operator()(NodeRareData*) const;

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (272432 => 272433)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2021-02-05 19:26:00 UTC (rev 272432)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2021-02-05 20:18:09 UTC (rev 272433)
@@ -176,6 +176,12 @@
         domAgent->didRemoveDOMNode(node);
 }
 
+void InspectorInstrumentation::nodeLayoutContextChangedImpl(InstrumentingAgents& instrumentingAgents, Node& node, RenderObject* oldRenderer)
+{
+    if (auto* cssAgent = instrumentingAgents.enabledCSSAgent())
+        cssAgent->nodeLayoutContextTypeChanged(node, oldRenderer); 
+}
+
 void InspectorInstrumentation::willModifyDOMAttrImpl(InstrumentingAgents& instrumentingAgents, Element& element, const AtomString& oldValue, const AtomString& newValue)
 {
     if (auto* pageDOMDebuggerAgent = instrumentingAgents.enabledPageDOMDebuggerAgent())

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (272432 => 272433)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2021-02-05 19:26:00 UTC (rev 272432)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2021-02-05 20:18:09 UTC (rev 272433)
@@ -126,6 +126,7 @@
     static void didInsertDOMNode(Document&, Node&);
     static void willRemoveDOMNode(Document&, Node&);
     static void didRemoveDOMNode(Document&, Node&);
+    static void nodeLayoutContextChanged(Node&, RenderObject*);
     static void willModifyDOMAttr(Document&, Element&, const AtomString& oldValue, const AtomString& newValue);
     static void didModifyDOMAttr(Document&, Element&, const AtomString& name, const AtomString& value);
     static void didRemoveDOMAttr(Document&, Element&, const AtomString& name);
@@ -350,6 +351,7 @@
     static void didInsertDOMNodeImpl(InstrumentingAgents&, Node&);
     static void willRemoveDOMNodeImpl(InstrumentingAgents&, Node&);
     static void didRemoveDOMNodeImpl(InstrumentingAgents&, Node&);
+    static void nodeLayoutContextChangedImpl(InstrumentingAgents&, Node&, RenderObject*);
     static void willModifyDOMAttrImpl(InstrumentingAgents&, Element&, const AtomString& oldValue, const AtomString& newValue);
     static void didModifyDOMAttrImpl(InstrumentingAgents&, Element&, const AtomString& name, const AtomString& value);
     static void didRemoveDOMAttrImpl(InstrumentingAgents&, Element&, const AtomString& name);
@@ -602,6 +604,13 @@
         didRemoveDOMNodeImpl(*agents, node);
 }
 
+inline void InspectorInstrumentation::nodeLayoutContextChanged(Node& node, RenderObject* oldRenderer)
+{
+    FAST_RETURN_IF_NO_FRONTENDS(void());
+    if (auto* agents = instrumentingAgents(node.document()))
+        nodeLayoutContextChangedImpl(*agents, node, oldRenderer);
+}
+
 inline void InspectorInstrumentation::willModifyDOMAttr(Document& document, Element& element, const AtomString& oldValue, const AtomString& newValue)
 {
     FAST_RETURN_IF_NO_FRONTENDS(void());

Modified: trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp (272432 => 272433)


--- trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp	2021-02-05 19:26:00 UTC (rev 272432)
+++ trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp	2021-02-05 20:18:09 UTC (rev 272433)
@@ -54,6 +54,7 @@
 #include "Node.h"
 #include "NodeList.h"
 #include "PseudoElement.h"
+#include "RenderGrid.h"
 #include "RenderStyleConstants.h"
 #include "SVGStyleElement.h"
 #include "SelectorChecker.h"
@@ -924,6 +925,31 @@
     return { };
 }
 
+Optional<Protocol::CSS::LayoutContextType> InspectorCSSAgent::layoutContextTypeForRenderer(RenderObject* renderer)
+{
+    if (is<RenderGrid>(renderer))
+        return Protocol::CSS::LayoutContextType::Grid;
+    return WTF::nullopt;
+}
+
+void InspectorCSSAgent::nodeLayoutContextTypeChanged(Node& node, RenderObject* oldRenderer)
+{
+    auto* domAgent = m_instrumentingAgents.persistentDOMAgent();
+    if (!domAgent)
+        return;
+    
+    auto newLayoutContextType = layoutContextTypeForRenderer(node.renderer());
+    if (newLayoutContextType == layoutContextTypeForRenderer(oldRenderer))
+        return;
+    
+    // FIXME: <https://webkit.org/b/221449> Support enabling events for uninstrumented nodes.
+    auto nodeId = domAgent->boundNodeId(&node);
+    if (!nodeId)
+        return;
+    
+    m_frontendDispatcher->nodeLayoutContextTypeChanged(nodeId, WTFMove(newLayoutContextType));
+}
+
 InspectorStyleSheetForInlineStyle& InspectorCSSAgent::asInspectorStyleSheet(StyledElement& element)
 {
     return m_nodeToInspectorStyleSheet.ensure(&element, [this, &element] {

Modified: trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.h (272432 => 272433)


--- trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.h	2021-02-05 19:26:00 UTC (rev 272432)
+++ trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.h	2021-02-05 20:18:09 UTC (rev 272433)
@@ -50,6 +50,7 @@
 class Element;
 class Node;
 class NodeList;
+class RenderObject;
 class StyleRule;
 
 namespace Style {
@@ -81,6 +82,7 @@
     };
 
     static CSSStyleRule* asCSSStyleRule(CSSRule&);
+    static Optional<Inspector::Protocol::CSS::LayoutContextType> layoutContextTypeForRenderer(RenderObject*);
 
     // InspectorAgentBase
     void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*);
@@ -113,6 +115,7 @@
     void mediaQueryResultChanged();
     void activeStyleSheetsUpdated(Document&);
     bool forcePseudoState(const Element&, CSSSelector::PseudoClassType);
+    void nodeLayoutContextTypeChanged(Node&, RenderObject*);
 
     // InspectorDOMAgent hooks
     void didRemoveDOMNode(Node&, Inspector::Protocol::DOM::NodeId);

Modified: trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp (272432 => 272433)


--- trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp	2021-02-05 19:26:00 UTC (rev 272432)
+++ trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp	2021-02-05 20:18:09 UTC (rev 272433)
@@ -93,6 +93,7 @@
 #include "Page.h"
 #include "Pasteboard.h"
 #include "PseudoElement.h"
+#include "RenderGrid.h"
 #include "RenderStyle.h"
 #include "RenderStyleConstants.h"
 #include "ScriptState.h"
@@ -1756,6 +1757,9 @@
         if (children->length() > 0)
             value->setChildren(WTFMove(children));
     }
+    
+    if (auto layoutContextType = InspectorCSSAgent::layoutContextTypeForRenderer(node->renderer()))
+        value->setLayoutContextType(layoutContextType.value());
 
     auto* pageAgent = m_instrumentingAgents.enabledPageAgent();
     if (pageAgent) {

Modified: trunk/Source/WebCore/rendering/RenderObject.h (272432 => 272433)


--- trunk/Source/WebCore/rendering/RenderObject.h	2021-02-05 19:26:00 UTC (rev 272432)
+++ trunk/Source/WebCore/rendering/RenderObject.h	2021-02-05 20:18:09 UTC (rev 272433)
@@ -1147,7 +1147,9 @@
 
 inline void Node::setRenderer(RenderObject* renderer)
 {
+    auto oldRenderer = this->renderer();
     m_rendererWithStyleFlags.setPointer(renderer);
+    didChangeRenderer(oldRenderer);
 }
 
 WTF::TextStream& operator<<(WTF::TextStream&, const RenderObject&);

Modified: trunk/Source/WebInspectorUI/ChangeLog (272432 => 272433)


--- trunk/Source/WebInspectorUI/ChangeLog	2021-02-05 19:26:00 UTC (rev 272432)
+++ trunk/Source/WebInspectorUI/ChangeLog	2021-02-05 20:18:09 UTC (rev 272433)
@@ -1,3 +1,24 @@
+2021-02-05  Patrick Angle  <[email protected]>
+
+        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.
+
+        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.
+
 2021-02-04  Razvan Caliman  <[email protected]>
 
         Web Inspector: Update .eslintrc to account for ECMAScript 2020

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js (272432 => 272433)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js	2021-02-05 19:26:00 UTC (rev 272432)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js	2021-02-05 20:18:09 UTC (rev 272433)
@@ -221,6 +221,16 @@
         node.powerEfficientPlaybackStateChanged(timestamp, isPowerEfficient);
     }
 
+    nodeLayoutContextTypeChanged(nodeId, layoutContextType)
+    {
+        let domNode = this._idToDOMNode[nodeId];
+        console.assert(domNode instanceof WI.DOMNode, domNode, nodeId);
+        if (!domNode)
+            return;
+
+        domNode.layoutContextType = layoutContextType;
+    }
+
     // Private
 
     _dispatchWhenDocumentAvailable(func, callback)

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js (272432 => 272433)


--- trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js	2021-02-05 19:26:00 UTC (rev 272432)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js	2021-02-05 20:18:09 UTC (rev 272433)
@@ -52,6 +52,7 @@
         this._shadowRootType = payload.shadowRootType;
         this._computedRole = null;
         this._contentSecurityPolicyHash = payload.contentSecurityPolicyHash;
+        this._layoutContextType = payload.layoutContextType;
 
         if (this._nodeType === Node.DOCUMENT_NODE)
             this.ownerDocument = this;
@@ -242,6 +243,18 @@
         this._childNodeCount = count;
     }
 
+    get layoutContextType()
+    {
+        return this._layoutContextType;
+    }
+
+    set layoutContextType(layoutContextType)
+    {
+        console.assert(layoutContextType !== this._layoutContextType);
+        this._layoutContextType = layoutContextType;
+        this.dispatchEventToListeners(WI.DOMNode.Event.LayoutContextTypeChanged);
+    }
+
     markDestroyed()
     {
         console.assert(!this._destroyed, this);
@@ -1122,6 +1135,7 @@
     EventListenersChanged: "dom-node-event-listeners-changed",
     DidFireEvent: "dom-node-did-fire-event",
     PowerEfficientPlaybackStateChanged: "dom-node-power-efficient-playback-state-changed",
+    LayoutContextTypeChanged: "dom-node-layout-context-type-changed",
 };
 
 WI.DOMNode.PseudoElementType = {
@@ -1141,3 +1155,8 @@
     Waiting: "waiting",
     Failed: "failed",
 };
+
+// Corresponds to `CSS.LayoutContextType`.
+WI.DOMNode.LayoutContextType = {
+    Grid: "grid",
+};

Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/CSSObserver.js (272432 => 272433)


--- trunk/Source/WebInspectorUI/UserInterface/Protocol/CSSObserver.js	2021-02-05 19:26:00 UTC (rev 272432)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/CSSObserver.js	2021-02-05 20:18:09 UTC (rev 272433)
@@ -47,6 +47,11 @@
         WI.cssManager.styleSheetRemoved(id);
     }
 
+    nodeLayoutContextTypeChanged(nodeId, layoutContextType)
+    {
+        WI.domManager.nodeLayoutContextTypeChanged(nodeId, layoutContextType);
+    }
+
     namedFlowCreated(namedFlow)
     {
         // COMPATIBILITY (iOS 11.3): Removed.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to