Changeset 293565 in webkit


Ignore:
Timestamp:
Apr 27, 2022 10:32:05 PM (3 months ago)
Author:
Patrick Angle
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:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r293560 r293565  
     12022-04-27  Patrick Angle  <pangle@apple.com>
     2
     3        Web Inspector: [Flexbox] `<button>` and `<select>` elements are appearing in list of Flex containers
     4        https://bugs.webkit.org/show_bug.cgi?id=239425
     5
     6        Reviewed by Devin Rousso.
     7
     8        * inspector/css/nodeLayoutContextTypeChanged-expected.txt:
     9        * inspector/css/nodeLayoutContextTypeChanged.html:
     10
    1112022-04-27  Karl Rackler  <rackler@apple.com>
    212
  • trunk/LayoutTests/inspector/css/nodeLayoutContextTypeChanged-expected.txt

    r288492 r293565  
    11Tests for the CSS.nodeLayoutContextTypeChanged event.
     2
    23
    34
     
    2324PASS: Layout context should now be `flex`.
    2425
     26-- Running test case: CSS.nodeLayoutContextTypeChanged.NotFlex.SubmitInput
     27PASS: Layout context should be `null`.
     28
     29-- Running test case: CSS.nodeLayoutContextTypeChanged.NotFlex.Select
     30PASS: Layout context should be `null`.
     31
     32-- Running test case: CSS.nodeLayoutContextTypeChanged.NotFlex.Button
     33PASS: Layout context should be `null`.
     34
  • trunk/LayoutTests/inspector/css/nodeLayoutContextTypeChanged.html

    r288492 r293565  
    114114    });
    115115
     116    function addEnsureLayoutContextTypeTestCase({name, description, selector, expectedLayoutContextType})
     117    {
     118        addTestCase({name, description, selector, async domNodeHandler(domNode) {
     119                InspectorTest.expectEqual(domNode.layoutContextType, expectedLayoutContextType, `Layout context should be \`${expectedLayoutContextType}\`.`);
     120            }
     121        });
     122    }
     123
     124    addEnsureLayoutContextTypeTestCase({
     125        name: "CSS.nodeLayoutContextTypeChanged.NotFlex.SubmitInput",
     126        description: "Make sure an `input` element of type `submit` is not considered a flex container.",
     127        selector: "#flexSubmitInput",
     128        expectedLayoutContextType: null,
     129    });
     130
     131    addEnsureLayoutContextTypeTestCase({
     132        name: "CSS.nodeLayoutContextTypeChanged.NotFlex.Select",
     133        description: "Make sure a `select` element is not considered a flex container.",
     134        selector: "#flexSelect",
     135        expectedLayoutContextType: null,
     136    });
     137
     138    addEnsureLayoutContextTypeTestCase({
     139        name: "CSS.nodeLayoutContextTypeChanged.NotFlex.Button",
     140        description: "Make sure a `button` is not considered a flex container.",
     141        selector: "#flexButton",
     142        expectedLayoutContextType: null,
     143    });
     144
    116145    WI.domManager.requestDocument().then((doc) => {
    117146        documentNode = doc;
     
    156185        <div></div>
    157186    </div>
     187   
     188    <input type="submit" id="flexSubmitInput" />
     189    <select id="flexSelect"></select>
     190    <button id="flexButton"></button>
    158191</body>
    159192</html>
  • trunk/Source/WebCore/ChangeLog

    r293550 r293565  
     12022-04-27  Patrick Angle  <pangle@apple.com>
     2
     3        Web Inspector: [Flexbox] `<button>` and `<select>` elements are appearing in list of Flex containers
     4        https://bugs.webkit.org/show_bug.cgi?id=239425
     5
     6        Reviewed by Devin Rousso.
     7
     8        Added test cases to inspector/css/nodeLayoutContextTypeChanged.html.
     9
     10        * inspector/agents/InspectorCSSAgent.cpp:
     11        (WebCore::InspectorCSSAgent::layoutContextTypeForRenderer):
     12
    1132022-04-27  Sihui Liu  <sihui_liu@apple.com>
    214
  • trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp

    r293285 r293565  
    941941std::optional<Protocol::CSS::LayoutContextType> InspectorCSSAgent::layoutContextTypeForRenderer(RenderObject* renderer)
    942942{
    943     if (is<RenderFlexibleBox>(renderer))
     943    if (auto* renderFlexibleBox = dynamicDowncast<RenderFlexibleBox>(renderer)) {
     944        // Subclasses of RenderFlexibleBox (buttons, selection inputs, etc.) should not be considered flex containers,
     945        // as it is an internal implementation detail.
     946        if (renderFlexibleBox->isFlexibleBoxImpl())
     947            return std::nullopt;
    944948        return Protocol::CSS::LayoutContextType::Flex;
     949    }
    945950    if (is<RenderGrid>(renderer))
    946951        return Protocol::CSS::LayoutContextType::Grid;
Note: See TracChangeset for help on using the changeset viewer.