Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web Inspector: Fix issues with go to property arrow in Computed CSS pane when details sidebar is unified #27503

Conversation

mirnovov
Copy link
Contributor

@mirnovov mirnovov commented Apr 19, 2024

b8288eb

Web Inspector: Fix issues with go to property arrow in Computed CSS pane when details sidebar is unified
https://bugs.webkit.org/show_bug.cgi?id=272876

Reviewed by Devin Rousso.

When using the Elements tab of the Inspector, the Computed pane has a button to jump to
the respective CSS property. This works well with the default two-column view, but when
"show independent Styles sidebar" is disabled, it can fail to scroll the respective CSS
into view or replace it with white space.

This commit fixes this problem:
- When opening details panes, do not reset the scroll position.
- Fix a bug that meant that focused/highlighted properties failed to update the layout when
  being initialised (this also can happen for other reasons,
  but is outside the scope of this commit).
- Ensure that all previous properties are always deselected, as occurs already in the
  two-column view.

Combined changes:
* Source/WebInspectorUI/UserInterface/Views/GeneralStyleDetailsSidebarPanel.js:
(WI.GeneralStyleDetailsSidebarPanel.prototype.layout):
* Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js:
(WI.SpreadsheetCSSStyleDeclarationEditor):
(WI.SpreadsheetCSSStyleDeclarationEditor.prototype.initialLayout):
(WI.SpreadsheetCSSStyleDeclarationEditor.prototype.selectProperties):
* Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:
(WI.SpreadsheetCSSStyleDeclarationSection.prototype.deselectProperties):
* Source/WebInspectorUI/UserInterface/Views/SpreadsheetRulesStyleDetailsPanel.js:
(WI.SpreadsheetRulesStyleDetailsPanel.prototype.scrollToSectionAndHighlightProperty):
* Source/WebInspectorUI/UserInterface/Views/StyleDetailsPanel.js:

Canonical link: https://commits.webkit.org/278686@main

c4c8329

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ§ͺ api-wpe
βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1 βœ… πŸ›  wpe-skia
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ›  gtk
βœ… πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2 βœ… πŸ§ͺ gtk-wk2
βœ… πŸ›  tv-sim βœ… πŸ§ͺ mac-wk2-stress βœ… πŸ§ͺ api-gtk
βœ… πŸ›  πŸ§ͺ merge ❌ πŸ›  watch
βœ… πŸ›  watch-sim

@Ahmad-S792 Ahmad-S792 added the Web Inspector Bugs related to the WebKit Web Inspector. label Apr 19, 2024
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Apr 19, 2024
@mirnovov mirnovov force-pushed the eng/Web-Inspector-Computed-CSS-goto-arrow-doesnt-work-when-show-independent-Styles-sidebar-is-disabled branch from 0497d2a to 556c629 Compare April 20, 2024 09:01
@mirnovov mirnovov force-pushed the eng/Web-Inspector-Computed-CSS-goto-arrow-doesnt-work-when-show-independent-Styles-sidebar-is-disabled branch from 556c629 to 390ff95 Compare April 20, 2024 09:15
Comment on lines +93 to +94
section.deselectProperties();
section.highlightProperty(property);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than call deselectProperties here i wonder if instead we should have WI.SpreadsheetCSSStyleDeclarationEditor.prototype.highlightProperty call this if nothing matches (i.e. right before the final return false;) as that would solve this bug and any like that also exist today or are accidentally added in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks when the old selection and new selection are under the same rule. I'd have to add it for both branches of WI.SpreadsheetCSSStyleDeclarationEditor.prototype.highlightProperty to work.

Also in the future there may be other features where the property is highlighted but the selection isn't invalidated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what exactly do you mean by "under the same rule"? can you give an example?

Copy link
Contributor Author

@mirnovov mirnovov Apr 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I.e. within the same CSS rule set or section

.foo {
    color: blue;
    background: red;
}

.bar {
    border: 1px solid green;
}

If I select color and then go to the computed tab and click on the goto arrow for border, it will work, but if I click on the goto arrow next to background it will still break

@mirnovov mirnovov force-pushed the eng/Web-Inspector-Computed-CSS-goto-arrow-doesnt-work-when-show-independent-Styles-sidebar-is-disabled branch from 390ff95 to e19f0a1 Compare April 21, 2024 05:11
@mirnovov mirnovov force-pushed the eng/Web-Inspector-Computed-CSS-goto-arrow-doesnt-work-when-show-independent-Styles-sidebar-is-disabled branch from e19f0a1 to d770b63 Compare April 21, 2024 08:04
@Ahmad-S792 Ahmad-S792 removed the merging-blocked Applied to prevent a change from being merged label Apr 25, 2024
Comment on lines 65 to 66
if (this._selectionFocusOverride)
this._selectionFocusOverride = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain more why this is needed? is it that this.editing is now true? perhaps the issue is with this._style.locked?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The layout() function of this class terminates when editing is true. Until this commit, _focused was always set to true, as usually focusing meanings that we are editing the CSS and we shouldn't layout. However focusing is also done when an item is highlighted (which AFAIK is either when it is arrived at from a go to arrow or other UI element, or when it is selected manually by the user by clicking in the row but outside the text field).

So when the go to arrow was clicked, it would prevent the initial layout and therefore all of the properties could appear blank. This didn't occur with two-column view since the styles pane was already layouted.

this._style.locked doesn't seem to be checked as part of this initial condition in the layout() function, so I don't think that's the cause.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm that makes me think the real issue is that we consider highlighting as a form of focus, but i can see how it might be difficult/annoying to untangle those two concepts πŸ€”

maybe we could have the "focus" event handler only do something if it's user initiated (i.e. isTrusted)?

is the issue only on the first layout or in any layout? if the former, perhaps we instead just adjust the this.focus check inside layout to also check for this.didInitialLayout?

Copy link
Contributor Author

@mirnovov mirnovov May 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I did think the same thing - that ideally focus wouldn't do double-duty for two disparate things, but it's probably not something to do rn. I also think there may be AX concerns with unbundling it, given that both of them are "focusing" in an accessibility sense.

I have already tried this.didInitialLayout but it's not false when necessary (since it's changed after initialLayout but before the first layout in View). Similarly isTrusted is always true.

@mirnovov mirnovov force-pushed the eng/Web-Inspector-Computed-CSS-goto-arrow-doesnt-work-when-show-independent-Styles-sidebar-is-disabled branch from d770b63 to 0326b45 Compare May 1, 2024 05:24
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 1, 2024
@mirnovov mirnovov force-pushed the eng/Web-Inspector-Computed-CSS-goto-arrow-doesnt-work-when-show-independent-Styles-sidebar-is-disabled branch from 0326b45 to c4c8329 Compare May 7, 2024 04:58
@rcaliman-apple
Copy link
Contributor

@mirnovov Is this patch ready to land?

@mirnovov
Copy link
Contributor Author

I believe so, unless anyone has any issues.

@rcaliman-apple rcaliman-apple added merge-queue Applied to send a pull request to merge-queue and removed merging-blocked Applied to prevent a change from being merged labels May 13, 2024
…ane when details sidebar is unified

https://bugs.webkit.org/show_bug.cgi?id=272876

Reviewed by Devin Rousso.

When using the Elements tab of the Inspector, the Computed pane has a button to jump to
the respective CSS property. This works well with the default two-column view, but when
"show independent Styles sidebar" is disabled, it can fail to scroll the respective CSS
into view or replace it with white space.

This commit fixes this problem:
- When opening details panes, do not reset the scroll position.
- Fix a bug that meant that focused/highlighted properties failed to update the layout when
  being initialised (this also can happen for other reasons,
  but is outside the scope of this commit).
- Ensure that all previous properties are always deselected, as occurs already in the
  two-column view.

Combined changes:
* Source/WebInspectorUI/UserInterface/Views/GeneralStyleDetailsSidebarPanel.js:
(WI.GeneralStyleDetailsSidebarPanel.prototype.layout):
* Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js:
(WI.SpreadsheetCSSStyleDeclarationEditor):
(WI.SpreadsheetCSSStyleDeclarationEditor.prototype.initialLayout):
(WI.SpreadsheetCSSStyleDeclarationEditor.prototype.selectProperties):
* Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:
(WI.SpreadsheetCSSStyleDeclarationSection.prototype.deselectProperties):
* Source/WebInspectorUI/UserInterface/Views/SpreadsheetRulesStyleDetailsPanel.js:
(WI.SpreadsheetRulesStyleDetailsPanel.prototype.scrollToSectionAndHighlightProperty):
* Source/WebInspectorUI/UserInterface/Views/StyleDetailsPanel.js:

Canonical link: https://commits.webkit.org/278686@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Web-Inspector-Computed-CSS-goto-arrow-doesnt-work-when-show-independent-Styles-sidebar-is-disabled branch from c4c8329 to b8288eb Compare May 13, 2024 13:14
@webkit-commit-queue
Copy link
Collaborator

Committed 278686@main (b8288eb): https://commits.webkit.org/278686@main

Reviewed commits have been landed. Closing PR #27503 and removing active labels.

@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label May 13, 2024
@webkit-commit-queue webkit-commit-queue merged commit b8288eb into WebKit:main May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Web Inspector Bugs related to the WebKit Web Inspector.
Projects
None yet
7 participants