Title: [288492] trunk
Revision
288492
Author
[email protected]
Date
2022-01-24 17:11:15 -0800 (Mon, 24 Jan 2022)

Log Message

Web Inspector: [Flexbox] Add instrumentation/protocol bits for flex layout containers
https://bugs.webkit.org/show_bug.cgi?id=235454

Reviewed by Devin Rousso.

Source/_javascript_Core:

* inspector/protocol/CSS.json:

Source/WebCore:

Added tests in inspector/css/nodeLayoutContextTypeChanged.html.

Add instrumentation to RenderFlexibleBox to observe elements becoming/ceasing to be flex containers. We only
instrument RenderFlexibleBox created with an Element, not a Document, since all anonymous nodes will have their
document passed, which means we would attempt to track multiple different nodes against the same document,
resulting in unexpected results. Conversely, we only instrument in the destructor for non-anonymous nodes.

* inspector/agents/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::layoutContextTypeForRenderer):
* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::RenderFlexibleBox):
(WebCore::RenderFlexibleBox::~RenderFlexibleBox):

Source/WebInspectorUI:

* UserInterface/Models/DOMNode.js:

LayoutTests:

* inspector/css/nodeLayoutContextTypeChanged-expected.txt:
* inspector/css/nodeLayoutContextTypeChanged.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (288491 => 288492)


--- trunk/LayoutTests/ChangeLog	2022-01-25 01:07:53 UTC (rev 288491)
+++ trunk/LayoutTests/ChangeLog	2022-01-25 01:11:15 UTC (rev 288492)
@@ -1,3 +1,13 @@
+2022-01-24  Patrick Angle  <[email protected]>
+
+        Web Inspector: [Flexbox] Add instrumentation/protocol bits for flex layout containers
+        https://bugs.webkit.org/show_bug.cgi?id=235454
+
+        Reviewed by Devin Rousso.
+
+        * inspector/css/nodeLayoutContextTypeChanged-expected.txt:
+        * inspector/css/nodeLayoutContextTypeChanged.html:
+
 2022-01-24  Eric Carlson  <[email protected]>
 
         REGRESSION (iOS 15): HTMLAudioElement fails to load new audio when device is locked or safari is in background

Modified: trunk/LayoutTests/inspector/css/nodeLayoutContextTypeChanged-expected.txt (288491 => 288492)


--- trunk/LayoutTests/inspector/css/nodeLayoutContextTypeChanged-expected.txt	2022-01-25 01:07:53 UTC (rev 288491)
+++ trunk/LayoutTests/inspector/css/nodeLayoutContextTypeChanged-expected.txt	2022-01-25 01:11:15 UTC (rev 288492)
@@ -10,3 +10,15 @@
 PASS: Layout context should be `null`.
 PASS: Layout context should now be `grid`.
 
+-- Running test case: CSS.nodeLayoutContextTypeChanged.FlexToNonFlex
+PASS: Layout context should be `flex`.
+PASS: Layout context should now be `null`.
+
+-- Running test case: CSS.nodeLayoutContextTypeChanged.NonFlexToFlex
+PASS: Layout context should be `null`.
+PASS: Layout context should now be `flex`.
+
+-- Running test case: CSS.nodeLayoutContextTypeChanged.GridToFlex
+PASS: Layout context should now be `grid`.
+PASS: Layout context should now be `flex`.
+

Modified: trunk/LayoutTests/inspector/css/nodeLayoutContextTypeChanged.html (288491 => 288492)


--- trunk/LayoutTests/inspector/css/nodeLayoutContextTypeChanged.html	2022-01-25 01:07:53 UTC (rev 288491)
+++ trunk/LayoutTests/inspector/css/nodeLayoutContextTypeChanged.html	2022-01-25 01:11:15 UTC (rev 288492)
@@ -65,6 +65,54 @@
         }
     });
 
+    addTestCase({
+        name: "CSS.nodeLayoutContextTypeChanged.FlexToNonFlex",
+        description: "Change a flex container to a non-flex container.",
+        selector: "#flexToNonFlex",
+        async domNodeHandler(domNode) {
+            InspectorTest.expectEqual(domNode.layoutContextType, WI.DOMNode.LayoutContextType.Flex, "Layout context should be `flex`.");
+
+            await Promise.all([
+                domNode.awaitEvent(WI.DOMNode.Event.LayoutContextTypeChanged),
+                changeElementDisplayValue("flexToNonFlex", "block"),
+            ]);
+
+            InspectorTest.expectEqual(domNode.layoutContextType, null, "Layout context should now be `null`.");
+        }
+    });
+
+    addTestCase({
+        name: "CSS.nodeLayoutContextTypeChanged.NonFlexToFlex",
+        description: "Change a non-flex container to a flex container.",
+        selector: "#nonFlexToFlex",
+        async domNodeHandler(domNode) {
+            InspectorTest.expectEqual(domNode.layoutContextType, null, "Layout context should be `null`.");
+
+            await Promise.all([
+                domNode.awaitEvent(WI.DOMNode.Event.LayoutContextTypeChanged),
+                changeElementDisplayValue("nonFlexToFlex", "flex"),
+            ]);
+
+            InspectorTest.expectEqual(domNode.layoutContextType, WI.DOMNode.LayoutContextType.Flex, "Layout context should now be `flex`.");
+        }
+    });
+
+    addTestCase({
+        name: "CSS.nodeLayoutContextTypeChanged.GridToFlex",
+        description: "Change a non-flex container to a flex container.",
+        selector: "#gridToFlex",
+        async domNodeHandler(domNode) {
+            InspectorTest.expectEqual(domNode.layoutContextType, WI.DOMNode.LayoutContextType.Grid, "Layout context should now be `grid`.");
+
+            await Promise.all([
+                domNode.awaitEvent(WI.DOMNode.Event.LayoutContextTypeChanged),
+                changeElementDisplayValue("gridToFlex", "flex"),
+            ]);
+
+            InspectorTest.expectEqual(domNode.layoutContextType, WI.DOMNode.LayoutContextType.Flex, "Layout context should now be `flex`.");
+        }
+    });
+
     WI.domManager.requestDocument().then((doc) => {
         documentNode = doc;
         suite.runTestCasesAndFinish();
@@ -75,6 +123,10 @@
     .grid-container {
         display: grid;
     }
+
+    .flex-container {
+        display: flex;
+    }
 </style>
 </head>
 <body _onload_="runTest()">
@@ -88,5 +140,20 @@
         <div></div>
         <div></div>
     </div>
+
+    <div id="flexToNonFlex" class="flex-container">
+        <div></div>
+        <div></div>
+    </div>
+
+    <div id="nonFlexToFlex">
+        <div></div>
+        <div></div>
+    </div>
+
+    <div id="gridToFlex" class="grid-container">
+        <div></div>
+        <div></div>
+    </div>
 </body>
 </html>

Modified: trunk/Source/_javascript_Core/ChangeLog (288491 => 288492)


--- trunk/Source/_javascript_Core/ChangeLog	2022-01-25 01:07:53 UTC (rev 288491)
+++ trunk/Source/_javascript_Core/ChangeLog	2022-01-25 01:11:15 UTC (rev 288492)
@@ -1,3 +1,12 @@
+2022-01-24  Patrick Angle  <[email protected]>
+
+        Web Inspector: [Flexbox] Add instrumentation/protocol bits for flex layout containers
+        https://bugs.webkit.org/show_bug.cgi?id=235454
+
+        Reviewed by Devin Rousso.
+
+        * inspector/protocol/CSS.json:
+
 2022-01-24  Mikhail R. Gadelha  <[email protected]>
 
         [JSC][32bit] Fix regexp crash on ARMv7

Modified: trunk/Source/_javascript_Core/inspector/protocol/CSS.json (288491 => 288492)


--- trunk/Source/_javascript_Core/inspector/protocol/CSS.json	2022-01-25 01:07:53 UTC (rev 288491)
+++ trunk/Source/_javascript_Core/inspector/protocol/CSS.json	2022-01-25 01:11:15 UTC (rev 288492)
@@ -257,7 +257,7 @@
         {
             "id": "LayoutContextType",
             "type": "string",
-            "enum": ["grid"],
+            "enum": ["flex", "grid"],
             "description": "The layout context type of a node."
         },
         {

Modified: trunk/Source/WebCore/ChangeLog (288491 => 288492)


--- trunk/Source/WebCore/ChangeLog	2022-01-25 01:07:53 UTC (rev 288491)
+++ trunk/Source/WebCore/ChangeLog	2022-01-25 01:11:15 UTC (rev 288492)
@@ -1,3 +1,23 @@
+2022-01-24  Patrick Angle  <[email protected]>
+
+        Web Inspector: [Flexbox] Add instrumentation/protocol bits for flex layout containers
+        https://bugs.webkit.org/show_bug.cgi?id=235454
+
+        Reviewed by Devin Rousso.
+
+        Added tests in inspector/css/nodeLayoutContextTypeChanged.html.
+
+        Add instrumentation to RenderFlexibleBox to observe elements becoming/ceasing to be flex containers. We only
+        instrument RenderFlexibleBox created with an Element, not a Document, since all anonymous nodes will have their
+        document passed, which means we would attempt to track multiple different nodes against the same document,
+        resulting in unexpected results. Conversely, we only instrument in the destructor for non-anonymous nodes.
+
+        * inspector/agents/InspectorCSSAgent.cpp:
+        (WebCore::InspectorCSSAgent::layoutContextTypeForRenderer):
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::RenderFlexibleBox):
+        (WebCore::RenderFlexibleBox::~RenderFlexibleBox):
+
 2022-01-24  Per Arne Vollan  <[email protected]>
 
         [iOS] Avoid calling IOSurfaceGetPropertyMaximum

Modified: trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp (288491 => 288492)


--- trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp	2022-01-25 01:07:53 UTC (rev 288491)
+++ trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp	2022-01-25 01:11:15 UTC (rev 288492)
@@ -56,6 +56,7 @@
 #include "Node.h"
 #include "NodeList.h"
 #include "PseudoElement.h"
+#include "RenderFlexibleBox.h"
 #include "RenderGrid.h"
 #include "RenderStyleConstants.h"
 #include "SVGStyleElement.h"
@@ -938,6 +939,8 @@
 
 std::optional<Protocol::CSS::LayoutContextType> InspectorCSSAgent::layoutContextTypeForRenderer(RenderObject* renderer)
 {
+    if (is<RenderFlexibleBox>(renderer))
+        return Protocol::CSS::LayoutContextType::Flex;
     if (is<RenderGrid>(renderer))
         return Protocol::CSS::LayoutContextType::Grid;
     return std::nullopt;

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (288491 => 288492)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2022-01-25 01:07:53 UTC (rev 288491)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2022-01-25 01:11:15 UTC (rev 288492)
@@ -33,6 +33,7 @@
 
 #include "FlexibleBoxAlgorithm.h"
 #include "HitTestResult.h"
+#include "InspectorInstrumentation.h"
 #include "LayoutRepainter.h"
 #include "RenderChildIterator.h"
 #include "RenderLayer.h"
@@ -72,6 +73,8 @@
     : RenderBlock(element, WTFMove(style), 0)
 {
     setChildrenInline(false); // All of our children must be block-level.
+
+    InspectorInstrumentation::nodeLayoutContextChanged(element, this);
 }
 
 RenderFlexibleBox::RenderFlexibleBox(Document& document, RenderStyle&& style)
@@ -80,7 +83,11 @@
     setChildrenInline(false); // All of our children must be block-level.
 }
 
-RenderFlexibleBox::~RenderFlexibleBox() = default;
+RenderFlexibleBox::~RenderFlexibleBox()
+{
+    if (!isAnonymous())
+        InspectorInstrumentation::nodeLayoutContextChanged(nodeForNonAnonymous(), nullptr);
+}
 
 const char* RenderFlexibleBox::renderName() const
 {

Modified: trunk/Source/WebInspectorUI/ChangeLog (288491 => 288492)


--- trunk/Source/WebInspectorUI/ChangeLog	2022-01-25 01:07:53 UTC (rev 288491)
+++ trunk/Source/WebInspectorUI/ChangeLog	2022-01-25 01:11:15 UTC (rev 288492)
@@ -1,3 +1,12 @@
+2022-01-24  Patrick Angle  <[email protected]>
+
+        Web Inspector: [Flexbox] Add instrumentation/protocol bits for flex layout containers
+        https://bugs.webkit.org/show_bug.cgi?id=235454
+
+        Reviewed by Devin Rousso.
+
+        * UserInterface/Models/DOMNode.js:
+
 2022-01-24  Devin Rousso  <[email protected]>
 
         Web Inspector: Network: move filtering checkboxes into a single gear-with-contextmenu to save space

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js (288491 => 288492)


--- trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js	2022-01-25 01:07:53 UTC (rev 288491)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js	2022-01-25 01:11:15 UTC (rev 288492)
@@ -1138,5 +1138,6 @@
 
 // Corresponds to `CSS.LayoutContextType`.
 WI.DOMNode.LayoutContextType = {
+    Flex: "flex",
     Grid: "grid",
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to