Bug 177012

Summary: Web Inspector: Styles Redesign: support editing of rule selectors
Product: WebKit Reporter: Nikita Vasilyev <nvasilyev>
Component: Web InspectorAssignee: Nikita Vasilyev <nvasilyev>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, inspector-bugzilla-changes, mattbaker, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 177471, 177711    
Attachments:
Description Flags
Patch
mattbaker: review-
[Animated GIF] With patch applied
none
Patch
none
Patch
none
Patch none

Nikita Vasilyev
Reported 2017-09-15 10:31:43 PDT
Make it possible to edit the selector for a rule. <rdar://problem/33525283>
Attachments
Patch (15.09 KB, patch)
2017-09-26 17:25 PDT, Nikita Vasilyev
mattbaker: review-
[Animated GIF] With patch applied (272.62 KB, image/gif)
2017-09-26 17:29 PDT, Nikita Vasilyev
no flags
Patch (13.99 KB, patch)
2017-10-01 14:41 PDT, Nikita Vasilyev
no flags
Patch (13.24 KB, patch)
2017-10-02 13:24 PDT, Nikita Vasilyev
no flags
Patch (13.07 KB, patch)
2017-10-02 19:33 PDT, Nikita Vasilyev
no flags
Nikita Vasilyev
Comment 1 2017-09-26 17:25:13 PDT
Nikita Vasilyev
Comment 2 2017-09-26 17:29:35 PDT
Created attachment 321905 [details] [Animated GIF] With patch applied
Nikita Vasilyev
Comment 3 2017-09-28 14:43:55 PDT
Comment on attachment 321902 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=321902&action=review > Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:300 > +WI.SpreadsheetSelectorField = class SpreadsheetSelectorField This class is likely to change as I'll need to use a similar component for editable names and values.
Nikita Vasilyev
Comment 4 2017-09-28 15:25:26 PDT
Comment on attachment 321902 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=321902&action=review >> Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:300 >> +WI.SpreadsheetSelectorField = class SpreadsheetSelectorField > > This class is likely to change as I'll need to use a similar component for editable names and values. After talking to Matt offline, we agreed that I should take a closer look at the existing EditingSupport.js.
Nikita Vasilyev
Comment 5 2017-09-28 18:13:40 PDT
Comment on attachment 321902 [details] Patch After investigating EditingSupport.js, I encountered several issues: - Unnecessary tabIndex manipulations, that prevents proper focusing order. - Option-Arrow keys functionality, that can't be turned off at this time. In addition to this, EditingSupport.js is very old and uses patterns we don't use for our recent code (such as passing config instance with event listeners). I'm changing my patch back to r?. I think we need to rewrite EditingSupport at some point, but I don't want to be blocked by it right now.
Matt Baker
Comment 6 2017-09-29 13:52:11 PDT
Comment on attachment 321902 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=321902&action=review This looks really good. Applied patch locally and it works really well, even with selectors that wrap to multiple lines. Other than a couple comments, I think two things need to be address before landing, so r- for now: - After editing stops, there shouldn’t be a visible focus ring left around the selector element. - A rule selector that doesn’t match anything after being edited will disappear. This is unexpected, and there is no way to find the rule again. Instead, the selector should become grayed out. > Source/WebInspectorUI/ChangeLog:7 > + field editable. I noticed clicking a property name/value does not select the text, it just begins editing. We should probably change that too (but can be another patch unless it's a small change). > Source/WebInspectorUI/ChangeLog:12 > + Shift-Tab should commit changes and navigate to the last rule's property value, if there's one. I think these four lines would be better as a list: Keyboard behavior while editing: - Enter should commit changes. - Escape should... > Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js:397 > + this._selectorElement.selectText(); When is this called? In testing I never saw this code run. > Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:337 > + element.selectText(); If SpreadsheetSelectorField was responsible for selecting the element's text, you could remove the `selectText` utility function and move that code here.
Nikita Vasilyev
Comment 7 2017-09-29 20:26:59 PDT
(In reply to Matt Baker from comment #6) > Comment on attachment 321902 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=321902&action=review > > - A rule selector that doesn’t match anything after being edited will > disappear. This is unexpected, and there is no way to find the rule again. > Instead, the selector should become grayed out. I agree that disappearing selectors aren't ideal. I spent last 5 hours trying to fix it. - WI.CSSRule.Event.SelectorChanged fires BEFORE CSSRule gets updated with a new selector. The current styles sidebar doesn't rely on WI.CSSRule.Event.SelectorChanged event and it doesn't try to re-parse the selector. As the result, edited selectors in the current styles sidebar are always grayed out. - In the current styles sidebar, rules with edited selectors stay visible until focus moves away from the CSS rule. It should stay visible until another DOM node is selected. This has been surprisingly difficult task. I'd prefer to address it as a follow up in Bug 177471 - Web Inspector: Styles Redesign: Selector editing quality improvements.
Nikita Vasilyev
Comment 8 2017-10-01 13:50:46 PDT
(In reply to Matt Baker from comment #6) > Comment on attachment 321902 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=321902&action=review > > This looks really good. Applied patch locally and it works really well, even > with selectors that wrap to multiple lines. > > Other than a couple comments, I think two things need to be address before > landing, so r- for now: > - After editing stops, there shouldn’t be a visible focus ring left around > the selector element. Agreed. This is being addressed in Bug 177711 - Web Inspector: Styles Redesign: Add support for keyboard navigation (Tab, Shift-Tab, Enter, Esc). >> Source/WebInspectorUI/ChangeLog:7 >> + field editable. > > I noticed clicking a property name/value does not select the text, it just begins editing. We should probably change that too (but can be another patch unless it's a small change). Being addressed in Bug 177711 - Web Inspector: Styles Redesign: Add support for keyboard navigation (Tab, Shift-Tab, Enter, Esc). >> Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:337 >> + element.selectText(); > > If SpreadsheetSelectorField was responsible for selecting the element's text, you could remove the `selectText` utility function and move that code here. It's used in for property names and values as well in my follow up patch (Bug 177711).
Nikita Vasilyev
Comment 9 2017-10-01 14:26:36 PDT
Comment on attachment 321902 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=321902&action=review >> Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js:397 >> + this._selectorElement.selectText(); > > When is this called? In testing I never saw this code run. This is the old styles sidebar. I should've not touched it!
Nikita Vasilyev
Comment 10 2017-10-01 14:41:50 PDT
Created attachment 322334 [details] Patch (In reply to Matt Baker from comment #6) > Other than a couple comments, I think two things need to be address before > landing, so r- for now: > - After editing stops, there shouldn’t be a visible focus ring left around > the selector element. I'll address it right after this patch in Bug 177711 - Web Inspector: Styles Redesign: Add support for keyboard navigation (Tab, Shift-Tab, Enter, Esc. > - A rule selector that doesn’t match anything after being edited will > disappear. This is unexpected, and there is no way to find the rule again. > Instead, the selector should become grayed out. - I'll address it in Bug 177471 - Web Inspector: Styles Redesign: Selector editing quality improvements, after I address fundamental UI components such as autocomplete and ability to add new CSS properties.
Nikita Vasilyev
Comment 11 2017-10-02 13:24:26 PDT
Created attachment 322419 [details] Patch I inlined Element.prototype.selectText and Event.prototype.stop for now.
Matt Baker
Comment 12 2017-10-02 18:02:35 PDT
Comment on attachment 322419 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=322419&action=review > Source/WebInspectorUI/ChangeLog:15 > + Reviewed by NOBODY (OOPS!). This should come before the summary. > Source/WebInspectorUI/ChangeLog:29 > + Split layout into _renderOrigin and _renderSelector, so selector field can be updated separetly separately > Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:116 > + }, this); Since the event listener is automatically removed, you can use bind and make it one line: this._style.ownerRule.singleFireEventListener(WI.CSSRule.Event.SelectorChanged, this._renderSelector.bind(this)); > Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:327 > + Remove blank line. > Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:329 > + Same here. > Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:335 > + element.textContent = element.textContent; The comment explains the effect, but what's the reason for doing this in the first place? I don't see this pattern used anywhere else. > Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:346 > + this._eventsInitialized = true; These should be unregistered in `stopEditing`, or registered in the constructor if it really doesn't matter (set and forget). > Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:396 > + this.stopEditing(); I'd add a blank line after this. The editing state change feels like the most important things about this function, and should stand out. > Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:407 > + Add a blank line before this, for the reason mentioned above.
Nikita Vasilyev
Comment 13 2017-10-02 18:58:06 PDT
Comment on attachment 322419 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=322419&action=review >> Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:116 >> + }, this); > > Since the event listener is automatically removed, you can use bind and make it one line: > > this._style.ownerRule.singleFireEventListener(WI.CSSRule.Event.SelectorChanged, this._renderSelector.bind(this)); I can avoid bind altogether: this._style.ownerRule.singleFireEventListener(WI.CSSRule.Event.SelectorChanged, this._renderSelector, this); >> Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:335 >> + element.textContent = element.textContent; > > The comment explains the effect, but what's the reason for doing this in the first place? I don't see this pattern used anywhere else. It's either this or CSS rules to undo all the possible styles of elements inside. This is more bulletproof. >> Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:346 >> + this._eventsInitialized = true; > > These should be unregistered in `stopEditing`, or registered in the constructor if it really doesn't matter (set and forget). I'll move it to the constructor.
Nikita Vasilyev
Comment 14 2017-10-02 19:33:46 PDT
Matt Baker
Comment 15 2017-10-03 11:39:42 PDT
Comment on attachment 322487 [details] Patch r=me
WebKit Commit Bot
Comment 16 2017-10-03 12:17:26 PDT
Comment on attachment 322487 [details] Patch Clearing flags on attachment: 322487 Committed r222799: <http://trac.webkit.org/changeset/222799>
WebKit Commit Bot
Comment 17 2017-10-03 12:17:28 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.