Bug 174229 - Web Inspector: Styles: make Computed a top-level sidebar tab
Summary: Web Inspector: Styles: make Computed a top-level sidebar tab
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: Nikita Vasilyev
URL:
Keywords: InRadar
Depends on: 179292
Blocks: 180466
  Show dependency treegraph
 
Reported: 2017-07-06 16:36 PDT by Nikita Vasilyev
Modified: 2017-12-06 00:13 PST (History)
5 users (show)

See Also:


Attachments
WIP (33.21 KB, patch)
2017-10-28 19:56 PDT, Nikita Vasilyev
nvasilyev: review-
nvasilyev: commit-queue-
Details | Formatted Diff | Diff
[Animated GIF] With patch applied (177.77 KB, image/gif)
2017-10-28 19:57 PDT, Nikita Vasilyev
no flags Details
[Animated GIF] 4 tabs overflow sidebar (278.44 KB, image/gif)
2017-11-04 18:14 PDT, Nikita Vasilyev
no flags Details
Patch (41.89 KB, patch)
2017-11-07 19:26 PST, Nikita Vasilyev
bburg: review-
bburg: commit-queue-
Details | Formatted Diff | Diff
[Animated GIF] With patch applied (540.96 KB, image/gif)
2017-11-07 19:26 PST, Nikita Vasilyev
no flags Details
Patch (47.97 KB, patch)
2017-11-10 12:43 PST, Nikita Vasilyev
no flags Details | Formatted Diff | Diff
[Image] Style sidebar tabs (135.38 KB, image/png)
2017-11-10 12:47 PST, Nikita Vasilyev
no flags Details
Patch (47.82 KB, patch)
2017-12-01 16:56 PST, Nikita Vasilyev
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nikita Vasilyev 2017-07-06 16:36:00 PDT
Two years ago, Styles second-level tabs were replaced by a dropdown menu: Bug 146878 - Web Inspector: Merge the styles sidebar navigation bar into a selectable item in the elements sidebar.

This added an extra click to switch between most commonly used Style tabs: Rules and Computed.

The two most commonly used tabs should:
1. Take a single click to switch between.
2. Be top-level tabs.
3. Be first on the list, before Node and Layers.
Comment 1 Radar WebKit Bug Importer 2017-07-06 16:36:48 PDT
<rdar://problem/33170193>
Comment 2 Nikita Vasilyev 2017-10-28 19:56:12 PDT
Created attachment 325275 [details]
WIP

Not ready for review yet, but you can apply the patch and try the new tabs.

Known issues:
— Command-clicking on a property in Computed to jump to a corresponding property in Styles is now broken.
— Ideally, the filter field should be shared between Styles and Computed, e.g. switching between Styles and Computed should preserve the filter field value. This isn't the case in Chrome. Also, I haven't yet implemented filtering in the redesigned styles panel.

The newly added StyleRulesDetailsSidebarPanel.js and StyleComputedDetailsSidebarPanel.js are trimmed down versions of CSSStyleDetailsSidebarPanel.js. I'm still thinking what's the best way to reduce code duplication between the two.
Comment 3 Nikita Vasilyev 2017-10-28 19:57:01 PDT
Created attachment 325276 [details]
[Animated GIF] With patch applied
Comment 4 Nikita Vasilyev 2017-11-04 18:14:29 PDT
Created attachment 326055 [details]
[Animated GIF] 4 tabs overflow sidebar

We have code that supposed to determine sidebar's min-width based on the navigation items' width. Unfortunately, it doesn't work.

I'm seeing WI.NavigationBar.prototype._calculateMinimumWidth returning 0 because it gets called when _visibleNavigationItems are empty. This zero value gets cached by minimumWidth getter.

Besides, there's also: Bug 179292 - REGRESSION (r221338): Web Inspector: NavigationBar incorrectly calculates minimumWidth
Comment 5 Nikita Vasilyev 2017-11-07 19:26:20 PST
Created attachment 326285 [details]
Patch
Comment 6 Nikita Vasilyev 2017-11-07 19:26:49 PST
Created attachment 326286 [details]
[Animated GIF] With patch applied
Comment 7 BJ Burg 2017-11-09 10:13:26 PST
Comment on attachment 326285 [details]
Patch

AFAIK, we have not agreed to phase out Visual Styles Sidebar right now. I think we are going to consider this in a more nuanced way later. For now, it's probably OK to keep it as a dropdown alternative for the "Styles" selector.
Comment 8 Nikita Vasilyev 2017-11-10 12:43:53 PST
Created attachment 326617 [details]
Patch

I added a setting to show Legacy Visual Styles Panel. It's off by default.
Comment 9 Nikita Vasilyev 2017-11-10 12:47:07 PST
Created attachment 326618 [details]
[Image] Style sidebar tabs

(In reply to Brian Burg from comment #7)
> Comment on attachment 326285 [details]
> Patch
> 
> AFAIK, we have not agreed to phase out Visual Styles Sidebar right now. I
> think we are going to consider this in a more nuanced way later. For now,
> it's probably OK to keep it as a dropdown alternative for the "Styles"
> selector.

I removed all dropdown tab selectors from the styles sidebar and made Visual a top-level tab, which is turned off by default.
Comment 10 Matt Baker 2017-11-27 20:25:53 PST
Comment on attachment 326617 [details]
Patch

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

Looking pretty good. The only major comment I have is that it feels like the panel class hierarchy is convoluted. A lot of this was in place before this patch, but now that the panels are all top-level, maybe the *Panel and *SidebarPanel classes could be merged together or something. Just a thought, I think it's okay for now.

Aside: I like that pseudo-class checkboxes are visible in the Visual panel now.

> Source/WebInspectorUI/ChangeLog:11
> +        "Visual" styles is no longer visible in the Styles sidebar tabs by default. It can be enabled in the settings.

Nit: no need to quote Styles, Computed, and Visual. Also this could be all one paragraph.

> Source/WebInspectorUI/ChangeLog:49
> +        CSSStyleDetailsSidebarPanel used to suppost several panels. This is no longer the case with GeneralStyleDetailsSidebarPanel:

suppost -> support

> Source/WebInspectorUI/ChangeLog:73
> +        SidebarNavigationBar wraps navigation items in an element so it can correctly calculate the width of all items with spacing between them.

I don't understand why a new class is needed. Can GroupNavigationItem be used instead?

> Source/WebInspectorUI/UserInterface/Views/StyleComputedDetailsSidebarPanel.js:26
> +WI.StyleComputedDetailsSidebarPanel = class StyleComputedDetailsSidebarPanel extends WI.GeneralStyleDetailsSidebarPanel

Should this be named RulesStyleDetailsSidebarPanel, to be consistent with its RulesStyleDetailsPanel? The same goes for the other subclasses of GeneralStyleDetailsSidebarPanel.
Comment 11 Nikita Vasilyev 2017-11-29 16:57:00 PST
Comment on attachment 326617 [details]
Patch

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

>> Source/WebInspectorUI/ChangeLog:73
>> +        SidebarNavigationBar wraps navigation items in an element so it can correctly calculate the width of all items with spacing between them.
> 
> I don't understand why a new class is needed. Can GroupNavigationItem be used instead?

It doesn't calculate the minimum width correctly. It doesn't take the margin between the items into account.
Comment 12 Nikita Vasilyev 2017-11-29 17:20:49 PST
(In reply to Nikita Vasilyev from comment #11)
> Comment on attachment 326617 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=326617&action=review
> 
> >> Source/WebInspectorUI/ChangeLog:73
> >> +        SidebarNavigationBar wraps navigation items in an element so it can correctly calculate the width of all items with spacing between them.
> > 
> > I don't understand why a new class is needed. Can GroupNavigationItem be used instead?
> 
> It doesn't calculate the minimum width correctly. It doesn't take the margin
> between the items into account.

Perhaps I should modify GroupNavigationItem to correctly calculate minimumWidth.
Do you know if GroupNavigationItem.prototype.minimumWidth is used anywhere? So far I couldn't find any instances of it.
Comment 13 Nikita Vasilyev 2017-11-30 16:58:51 PST
Comment on attachment 326617 [details]
Patch

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

>> Source/WebInspectorUI/UserInterface/Views/StyleComputedDetailsSidebarPanel.js:26
>> +WI.StyleComputedDetailsSidebarPanel = class StyleComputedDetailsSidebarPanel extends WI.GeneralStyleDetailsSidebarPanel
> 
> Should this be named RulesStyleDetailsSidebarPanel, to be consistent with its RulesStyleDetailsPanel? The same goes for the other subclasses of GeneralStyleDetailsSidebarPanel.

Did you mean to leave this comment for StyleRulesDetailsSidebarPanel? If so, than yes, it should.
Comment 14 Matt Baker 2017-11-30 17:27:48 PST
Comment on attachment 326617 [details]
Patch

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

>>>> Source/WebInspectorUI/ChangeLog:73
>>>> +        SidebarNavigationBar wraps navigation items in an element so it can correctly calculate the width of all items with spacing between them.
>>> 
>>> I don't understand why a new class is needed. Can GroupNavigationItem be used instead?
>> 
>> It doesn't calculate the minimum width correctly. It doesn't take the margin between the items into account.
> 
> Perhaps I should modify GroupNavigationItem to correctly calculate minimumWidth.
> Do you know if GroupNavigationItem.prototype.minimumWidth is used anywhere? So far I couldn't find any instances of it.

It's a property on the NavigationItem base class, which some navigation items override. It is called by NavigationBar.prototype._calculateMinimumWidth(), and by GroupNavigationItem when it calculates its own `minimumWidth`.

>>> Source/WebInspectorUI/UserInterface/Views/StyleComputedDetailsSidebarPanel.js:26
>>> +WI.StyleComputedDetailsSidebarPanel = class StyleComputedDetailsSidebarPanel extends WI.GeneralStyleDetailsSidebarPanel
>> 
>> Should this be named RulesStyleDetailsSidebarPanel, to be consistent with its RulesStyleDetailsPanel? The same goes for the other subclasses of GeneralStyleDetailsSidebarPanel.
> 
> Did you mean to leave this comment for StyleRulesDetailsSidebarPanel? If so, than yes, it should.

Oops! I meant to say that StyleComputedDetailsSidebarPanel should be renamed to ComputedStyleDetailsSidebarPanel to match ComputedStyleDetailsPanel. The same goes for RulesStyleDetailsSidebarPanel.
Comment 15 Nikita Vasilyev 2017-12-01 16:50:12 PST
I tried to use GroupNavigationItem and went down the rabbit hole. To use GroupNavigationItem, I'd have to:
- Copy several NavigationBar's methods to GroupNavigationItem: addNavigationItem, insertNavigationItem, removeNavigationItem, etc.
- Sidebar has a concept of a selected item, but GroupNavigationItem doesn't. I'd have to either implement it on GroupNavigationItem or add this logic to WI.Sidebar.

Considering how simple SidebarNavigationBar is, I'd rather use it instead.

(In reply to Matt Baker from comment #14)
> Comment on attachment 326617 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=326617&action=review
> 
> >>>> Source/WebInspectorUI/ChangeLog:73
> >>>> +        SidebarNavigationBar wraps navigation items in an element so it can correctly calculate the width of all items with spacing between them.
> >>> 
> >>> I don't understand why a new class is needed. Can GroupNavigationItem be used instead?
> >> 
> >> It doesn't calculate the minimum width correctly. It doesn't take the margin between the items into account.
> > 
> > Perhaps I should modify GroupNavigationItem to correctly calculate minimumWidth.
> > Do you know if GroupNavigationItem.prototype.minimumWidth is used anywhere? So far I couldn't find any instances of it.
> 
> It's a property on the NavigationItem base class, which some navigation
> items override. It is called by
> NavigationBar.prototype._calculateMinimumWidth(), and by GroupNavigationItem
> when it calculates its own `minimumWidth`.

I understand. I meant to write that I can't find GroupNavigationItem.prototype.minimumWidth being called anywhere.
Comment 16 Nikita Vasilyev 2017-12-01 16:52:48 PST
(In reply to Matt Baker from comment #10)
> Comment on attachment 326617 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=326617&action=review
> 
> Looking pretty good. The only major comment I have is that it feels like the
> panel class hierarchy is convoluted. A lot of this was in place before this
> patch, but now that the panels are all top-level, maybe the *Panel and
> *SidebarPanel classes could be merged together or something. Just a thought,
> I think it's okay for now.

I'll revisit this when I bring back filtering to the styles sidebar. Ideally, we want to share the filter field between Styles and Computed panels.
Comment 17 Nikita Vasilyev 2017-12-01 16:56:44 PST
Created attachment 328187 [details]
Patch
Comment 18 Matt Baker 2017-12-05 14:06:53 PST
Comment on attachment 328187 [details]
Patch

r=me
Comment 19 WebKit Commit Bot 2017-12-05 14:28:23 PST
Comment on attachment 328187 [details]
Patch

Clearing flags on attachment: 328187

Committed r225547: <https://trac.webkit.org/changeset/225547>
Comment 20 WebKit Commit Bot 2017-12-05 14:28:25 PST
All reviewed patches have been landed.  Closing bug.