Title: [293565] trunk
Revision
293565
Author
pan...@apple.com
Date
2022-04-27 22:32:05 -0700 (Wed, 27 Apr 2022)

Log Message

Web Inspector: [Flexbox] `<button>` and `<select>` elements are appearing in list of Flex containers
https://bugs.webkit.org/show_bug.cgi?id=239425

Reviewed by Devin Rousso.

Source/WebCore:

Added test cases to inspector/css/nodeLayoutContextTypeChanged.html.

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

LayoutTests:

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

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (293564 => 293565)


--- trunk/LayoutTests/ChangeLog	2022-04-28 05:01:24 UTC (rev 293564)
+++ trunk/LayoutTests/ChangeLog	2022-04-28 05:32:05 UTC (rev 293565)
@@ -1,3 +1,13 @@
+2022-04-27  Patrick Angle  <pan...@apple.com>
+
+        Web Inspector: [Flexbox] `<button>` and `<select>` elements are appearing in list of Flex containers
+        https://bugs.webkit.org/show_bug.cgi?id=239425
+
+        Reviewed by Devin Rousso.
+
+        * inspector/css/nodeLayoutContextTypeChanged-expected.txt:
+        * inspector/css/nodeLayoutContextTypeChanged.html:
+
 2022-04-27  Karl Rackler  <rack...@apple.com>
 
         [ macOS wk1 ] Fourteen webgl/2.0.0/conformance tests are a flaky timeout

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


--- trunk/LayoutTests/inspector/css/nodeLayoutContextTypeChanged-expected.txt	2022-04-28 05:01:24 UTC (rev 293564)
+++ trunk/LayoutTests/inspector/css/nodeLayoutContextTypeChanged-expected.txt	2022-04-28 05:32:05 UTC (rev 293565)
@@ -1,6 +1,7 @@
 Tests for the CSS.nodeLayoutContextTypeChanged event.
 
 
+
 == Running test suite: CSS.nodeLayoutContextTypeChanged
 -- Running test case: CSS.nodeLayoutContextTypeChanged.GridToNonGrid
 PASS: Layout context should be `grid`.
@@ -22,3 +23,12 @@
 PASS: Layout context should now be `grid`.
 PASS: Layout context should now be `flex`.
 
+-- Running test case: CSS.nodeLayoutContextTypeChanged.NotFlex.SubmitInput
+PASS: Layout context should be `null`.
+
+-- Running test case: CSS.nodeLayoutContextTypeChanged.NotFlex.Select
+PASS: Layout context should be `null`.
+
+-- Running test case: CSS.nodeLayoutContextTypeChanged.NotFlex.Button
+PASS: Layout context should be `null`.
+

Modified: trunk/LayoutTests/inspector/css/nodeLayoutContextTypeChanged.html (293564 => 293565)


--- trunk/LayoutTests/inspector/css/nodeLayoutContextTypeChanged.html	2022-04-28 05:01:24 UTC (rev 293564)
+++ trunk/LayoutTests/inspector/css/nodeLayoutContextTypeChanged.html	2022-04-28 05:32:05 UTC (rev 293565)
@@ -113,6 +113,35 @@
         }
     });
 
+    function addEnsureLayoutContextTypeTestCase({name, description, selector, expectedLayoutContextType})
+    {
+        addTestCase({name, description, selector, async domNodeHandler(domNode) {
+                InspectorTest.expectEqual(domNode.layoutContextType, expectedLayoutContextType, `Layout context should be \`${expectedLayoutContextType}\`.`);
+            }
+        });
+    }
+
+    addEnsureLayoutContextTypeTestCase({
+        name: "CSS.nodeLayoutContextTypeChanged.NotFlex.SubmitInput",
+        description: "Make sure an `input` element of type `submit` is not considered a flex container.",
+        selector: "#flexSubmitInput",
+        expectedLayoutContextType: null,
+    });
+
+    addEnsureLayoutContextTypeTestCase({
+        name: "CSS.nodeLayoutContextTypeChanged.NotFlex.Select",
+        description: "Make sure a `select` element is not considered a flex container.",
+        selector: "#flexSelect",
+        expectedLayoutContextType: null,
+    });
+
+    addEnsureLayoutContextTypeTestCase({
+        name: "CSS.nodeLayoutContextTypeChanged.NotFlex.Button",
+        description: "Make sure a `button` is not considered a flex container.",
+        selector: "#flexButton",
+        expectedLayoutContextType: null,
+    });
+
     WI.domManager.requestDocument().then((doc) => {
         documentNode = doc;
         suite.runTestCasesAndFinish();
@@ -155,5 +184,9 @@
         <div></div>
         <div></div>
     </div>
+    
+    <input type="submit" id="flexSubmitInput" />
+    <select id="flexSelect"></select>
+    <button id="flexButton"></button>
 </body>
 </html>

Modified: trunk/Source/WebCore/ChangeLog (293564 => 293565)


--- trunk/Source/WebCore/ChangeLog	2022-04-28 05:01:24 UTC (rev 293564)
+++ trunk/Source/WebCore/ChangeLog	2022-04-28 05:32:05 UTC (rev 293565)
@@ -1,3 +1,15 @@
+2022-04-27  Patrick Angle  <pan...@apple.com>
+
+        Web Inspector: [Flexbox] `<button>` and `<select>` elements are appearing in list of Flex containers
+        https://bugs.webkit.org/show_bug.cgi?id=239425
+
+        Reviewed by Devin Rousso.
+
+        Added test cases to inspector/css/nodeLayoutContextTypeChanged.html.
+
+        * inspector/agents/InspectorCSSAgent.cpp:
+        (WebCore::InspectorCSSAgent::layoutContextTypeForRenderer):
+
 2022-04-27  Sihui Liu  <sihui_...@apple.com>
 
         Ensure completion handler is called in SWServer::clear

Modified: trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp (293564 => 293565)


--- trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp	2022-04-28 05:01:24 UTC (rev 293564)
+++ trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp	2022-04-28 05:32:05 UTC (rev 293565)
@@ -940,8 +940,13 @@
 
 std::optional<Protocol::CSS::LayoutContextType> InspectorCSSAgent::layoutContextTypeForRenderer(RenderObject* renderer)
 {
-    if (is<RenderFlexibleBox>(renderer))
+    if (auto* renderFlexibleBox = dynamicDowncast<RenderFlexibleBox>(renderer)) {
+        // Subclasses of RenderFlexibleBox (buttons, selection inputs, etc.) should not be considered flex containers,
+        // as it is an internal implementation detail.
+        if (renderFlexibleBox->isFlexibleBoxImpl())
+            return std::nullopt;
         return Protocol::CSS::LayoutContextType::Flex;
+    }
     if (is<RenderGrid>(renderer))
         return Protocol::CSS::LayoutContextType::Grid;
     return std::nullopt;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to