Bug 237215 - Web Inspector: [Flexbox] Add options to show each area's CSS `order` and/or DOM index in the parent flex container
Summary: Web Inspector: [Flexbox] Add options to show each area's CSS `order` and/or D...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Devin Rousso
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-02-25 10:33 PST by Devin Rousso
Modified: 2022-02-28 13:22 PST (History)
11 users (show)

See Also:


Attachments
[fast-cq] Patch (25.86 KB, patch)
2022-02-25 11:28 PST, Devin Rousso
no flags Details | Formatted Diff | Diff
[Image] after Patch is applied (Page Overlay) (966.98 KB, image/png)
2022-02-25 11:29 PST, Devin Rousso
no flags Details
[Image] after Patch is applied (Layout panel) (43.45 KB, image/png)
2022-02-25 13:10 PST, Devin Rousso
no flags Details
[fast-cq] Patch (26.00 KB, patch)
2022-02-28 10:47 PST, Devin Rousso
no flags Details | Formatted Diff | Diff
[fast-cq] Patch (25.99 KB, patch)
2022-02-28 13:15 PST, Devin Rousso
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Devin Rousso 2022-02-25 10:33:54 PST
this will help developers better understand how CSS `order` and the DOM index of each flex item interact and result in what's eventually rendered
Comment 1 Devin Rousso 2022-02-25 11:28:04 PST
Created attachment 453234 [details]
[fast-cq] Patch
Comment 2 Devin Rousso 2022-02-25 11:29:36 PST
Created attachment 453236 [details]
[Image] after Patch is applied (Page Overlay)
Comment 3 EWS Watchlist 2022-02-25 11:33:27 PST
This patch modifies the inspector protocol. Please ensure that any frontend changes appropriately use feature checks for new protocol features.
Comment 4 Devin Rousso 2022-02-25 13:10:21 PST
Created attachment 453249 [details]
[Image] after Patch is applied (Layout panel)
Comment 5 Patrick Angle 2022-02-25 13:27:06 PST
Comment on attachment 453234 [details]
[fast-cq] Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=453234&action=review

Looks good - just the one concern re: child indexes and how they are counted

> Source/WebCore/inspector/InspectorOverlay.cpp:1896
> +                if (renderChildrenInFlexOrder.contains(renderer))

It seems odd to me that we wouldn't count children of the flex container that happen to not be participating in the flex layout - it kinda messes with the meaning of `Child #`. For example, it would make more sense, IMO, to still count non-participating children so that the child number corresponds with the node more closely, so if I'm counting to the third child in the DOM tree I don't need to remember that I'm actually looking for the 4th child because a previous sibling to a child isn't participating in the flex layout.

> Source/WebCore/inspector/InspectorOverlay.cpp:1919
> +                Vector<InspectorOverlayLabel::Content> orderNumbers;
> +                auto addOrderNumber = [&] (String&& number) {
> +                    if (!orderNumbers.isEmpty())
> +                        orderNumbers.append({ "\n"_s, Color::black });
> +                    orderNumbers.append({ WTFMove(number), Color::black });
> +                };

Nit: Because all the `Content`s have the same styling, we could just use a StringBuilder to construct a single string. InspectorOverlayLabel will handle splitting the lines even when `\n` is in middle of other text.

> Source/WebCore/inspector/InspectorOverlay.cpp:1925
> +                if (auto order = renderChild->style().order())
> +                    addOrderNumber(makeString("order: ", order));

Is there a way we could show `order: 0` when other children has a non-zero order value? It might look cleaner for all the items to have the same pieces of information, as well as prevent the "wait, why doesn't this one tell me the order but the other ones do" confusion before someone realizes that we are dropping all `order: 0`s, even when other children may have an `order` other than zero.
Comment 6 Devin Rousso 2022-02-25 16:10:26 PST
Comment on attachment 453234 [details]
[fast-cq] Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=453234&action=review

>> Source/WebCore/inspector/InspectorOverlay.cpp:1896
>> +                if (renderChildrenInFlexOrder.contains(renderer))
> 
> It seems odd to me that we wouldn't count children of the flex container that happen to not be participating in the flex layout - it kinda messes with the meaning of `Child #`. For example, it would make more sense, IMO, to still count non-participating children so that the child number corresponds with the node more closely, so if I'm counting to the third child in the DOM tree I don't need to remember that I'm actually looking for the 4th child because a previous sibling to a child isn't participating in the flex layout.

My thinking here is that I was really just trying to visualize "what's the DOM order of the visible flex items", not "what is the index of this flex child in the `childNodes` of the flex container".  I found that doing the latter confused me because I would think "wait why is there no Child #2 where is it???" (and it would be even worse if we considered non-visible children, e.g. whitespace).

As we discussed offline, I think just changing this to "Item #" will immediately clarify that intention (and will match the "Flex Item" that's now shown in the element tooltip).

>> Source/WebCore/inspector/InspectorOverlay.cpp:1919
>> +                };
> 
> Nit: Because all the `Content`s have the same styling, we could just use a StringBuilder to construct a single string. InspectorOverlayLabel will handle splitting the lines even when `\n` is in middle of other text.

Yeah I could do that.  This was kinda leftover from an old structure, so I'll adjust :)

>> Source/WebCore/inspector/InspectorOverlay.cpp:1925
>> +                    addOrderNumber(makeString("order: ", order));
> 
> Is there a way we could show `order: 0` when other children has a non-zero order value? It might look cleaner for all the items to have the same pieces of information, as well as prevent the "wait, why doesn't this one tell me the order but the other ones do" confusion before someone realizes that we are dropping all `order: 0`s, even when other children may have an `order` other than zero.

Good idea.  Will change.
Comment 7 Patrick Angle 2022-02-25 16:43:12 PST
Comment on attachment 453234 [details]
[fast-cq] Patch

r=me based on our discussion - thank you for clarifying!
Comment 8 Devin Rousso 2022-02-28 10:47:16 PST
Created attachment 453410 [details]
[fast-cq] Patch
Comment 9 EWS 2022-02-28 13:03:16 PST
ChangeLog entry in Source/JavaScriptCore/ChangeLog contains OOPS!.
Comment 10 Devin Rousso 2022-02-28 13:15:52 PST
Created attachment 453419 [details]
[fast-cq] Patch
Comment 11 EWS 2022-02-28 13:21:09 PST
Committed r290613 (247886@main): <https://commits.webkit.org/247886@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 453419 [details].
Comment 12 Radar WebKit Bug Importer 2022-02-28 13:22:19 PST
<rdar://problem/89577732>