Bug 170184

Summary: Web Inspector: tabbing in Styles sidebar is broken when additional ":" and ";" are in the property value
Product: WebKit Reporter: Devin Rousso <hi>
Component: Web InspectorAssignee: Devin Rousso <hi>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, inspector-bugzilla-changes, mattbaker
Priority: P2    
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Patch
mattbaker: review+
Patch none

Devin Rousso
Reported 2017-03-28 10:44:53 PDT
If you add `background-image: url(https://webkit.org/wp-content/themes/webkit/images/webkit.svg);` to any style and try tabbing, the highlight will get stuck on "url(https". This is most likely because the way it searches for ":" and ";" is very dumb, simply finding the first instance in the remaining text.
Attachments
Patch (5.88 KB, patch)
2017-03-28 11:48 PDT, Devin Rousso
no flags
Patch (14.25 KB, patch)
2017-04-07 19:04 PDT, Devin Rousso
mattbaker: review+
Patch (13.96 KB, patch)
2017-04-09 21:44 PDT, Devin Rousso
no flags
Devin Rousso
Comment 1 2017-03-28 11:48:54 PDT
Matt Baker
Comment 2 2017-03-29 10:49:10 PDT
Comment on attachment 305618 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=305618&action=review Since we have so many editing issues in the styles sidebar, I think we should break out the range matching into a utility method (that handles plain text, not CodeMirror) so we can write tests. > Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js:408 > + _rangeForNextNameOrValue(codeMirror, cursor, text) { Style: put open brace on newline.
Matt Baker
Comment 3 2017-03-29 10:49:35 PDT
Comment on attachment 305618 [details] Patch r- until we have tests
Devin Rousso
Comment 4 2017-04-07 19:04:08 PDT
Matt Baker
Comment 5 2017-04-09 09:29:46 PDT
Comment on attachment 306562 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=306562&action=review r=me, nice tests! > Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js:408 > + _rangeForNextNameOrValue(codeMirror, cursor, text) { Nit: put open brace on its own line. > LayoutTests/inspector/unit-tests/text-utilities-expected.txt:21 > +PASS: Next highlight range of "foo: url(http://baz);" starting at index 5 is [5, 20] A couple thoughts on the test output: 1) Highlight is a higher-level UI concept, and doesn't appear in the name of the utility method. It's confusing unless you know how this is going to be used in the UI. Maybe use name/value instead. 2) It is hard to tell from the resulting range bounds alone where an error occurred. What do you think about including the resulting substring in the output? Something like: Next name/value token in "foo: url(http://baz);" starting at index 5 is "url(http://baz)" (5, 20) > LayoutTests/inspector/unit-tests/text-utilities.html:14 > + InspectorTest.expectShallowEqual(WebInspector.rangeForNextCSSNameOrValue(text, index), expected, `Next highlight range of "${text}" starting at index ${index} is [${expected.from}, ${expected.to}]`); Style: I think this would read a little better as: function testValid(text, index, expected) { let actual = WebInspector.rangeForNextCSSNameOrValue(text, index); InspectorTest.expectShallowEqual(actual, expected, ...); }
Devin Rousso
Comment 6 2017-04-09 21:44:01 PDT
WebKit Commit Bot
Comment 7 2017-04-09 22:26:48 PDT
Comment on attachment 306647 [details] Patch Clearing flags on attachment: 306647 Committed r215170: <http://trac.webkit.org/changeset/215170>
WebKit Commit Bot
Comment 8 2017-04-09 22:26:49 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.