WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 178176
Web Inspector: Styles Redesign: apply syntax highlighting to property values
https://bugs.webkit.org/show_bug.cgi?id=178176
Summary
Web Inspector: Styles Redesign: apply syntax highlighting to property values
Nikita Vasilyev
Reported
2017-10-11 11:24:32 PDT
Chrome DevTools only highlight URLs: - url(foo.png) - url('foo.png') - url("foo.png") At the very least we should do the same, but it would be also nice to highlight: Strings: - content: 'blah' - font-family: "Myriad Set Pro", "Helvetica Neue", sans-serif; Variables (highlight the --my-var part): - var(--my-var) Non matching pair characters: - content: 'blah - font-family: "Myriad Set Pro, "Helvetica Neue", sans-serif; - calc(var(--my-var + 5) --- It's possible to feed CodeMirror a CSS string and get a list of tokens back. There's no need to write our own parser.
https://codemirror.net/doc/manual.html#modeapi
<
rdar://problem/33526532
>
Attachments
Patch
(6.94 KB, patch)
2017-10-11 19:45 PDT
,
Nikita Vasilyev
no flags
Details
Formatted Diff
Diff
[Image] With patch applied
(56.21 KB, image/png)
2017-10-11 19:46 PDT
,
Nikita Vasilyev
no flags
Details
Patch
(6.91 KB, patch)
2017-10-12 18:06 PDT
,
Nikita Vasilyev
no flags
Details
Formatted Diff
Diff
Patch
(8.96 KB, patch)
2017-10-14 14:28 PDT
,
Nikita Vasilyev
no flags
Details
Formatted Diff
Diff
[Image] Long URI truncated
(34.66 KB, image/png)
2017-10-14 14:29 PDT
,
Nikita Vasilyev
no flags
Details
Patch
(8.90 KB, patch)
2017-10-16 18:45 PDT
,
Nikita Vasilyev
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Nikita Vasilyev
Comment 1
2017-10-11 19:45:53 PDT
Created
attachment 323508
[details]
Patch This patch highlights links and CSS strings. I think it's a good start.
Nikita Vasilyev
Comment 2
2017-10-11 19:46:30 PDT
Created
attachment 323509
[details]
[Image] With patch applied
Nikita Vasilyev
Comment 3
2017-10-12 18:06:55 PDT
Created
attachment 323615
[details]
Patch
Nikita Vasilyev
Comment 4
2017-10-14 14:28:26 PDT
Created
attachment 323820
[details]
Patch
Nikita Vasilyev
Comment 5
2017-10-14 14:29:49 PDT
Created
attachment 323821
[details]
[Image] Long URI truncated I addressed
Bug 124779
- Web Inspector: Styles: Truncate long URLs (e.g. base64) in this patch since it was pretty straightforward to do once we detect URL tokens. Reduction page:
http://nv.github.io/webkit-inspector-bugs/styles-redesign/tests/base64.html
I truncated URLs over 150 characters. This is the same length as in Chrome DevTools. I've learned that there's no pure-CSS way to truncate an inline element :(
Matt Baker
Comment 6
2017-10-16 18:15:50 PDT
Comment on
attachment 323820
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=323820&action=review
Looking good, just a minor correction and some nits.
> Source/WebInspectorUI/ChangeLog:26 > + Highlight links and CSS strings in values when isn't editing.
Type: when not editing.
> Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js:686 > + let cssRule = `*{X:${cssValue}}`;
I was going to suggest a different label for the fake property name, to make ita little more obvious, but then the ignore column index would need to change, and it just gets harder to figure out (and more regression prone). How about just replacing the magic number 4 with a const, which can be defined after the definition of `cssRule`. Then the meaning of each will be reinforced.
> Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js:695 > + // Ignore '*{X:'
This comment could move to be inline with the definition of the const mentioned above.
> Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js:244 > + let maxLength = 150;
Just to make it stand out, I'd move this to the top of the function: _renderValue(value) { const maxValueLength = 150; ... }
> Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js:247 > + } else
You can remove the else, since both branches return.
> Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js:82 > + if (this._delegate && typeof this._delegate.spreadsheetTextFieldWillStartEditing)
=== "function"
Nikita Vasilyev
Comment 7
2017-10-16 18:25:37 PDT
Comment on
attachment 323820
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=323820&action=review
>> Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js:686 >> + let cssRule = `*{X:${cssValue}}`; > > I was going to suggest a different label for the fake property name, to make ita little more obvious, but then the ignore column index would need to change, and it just gets harder to figure out (and more regression prone). > > How about just replacing the magic number 4 with a const, which can be defined after the definition of `cssRule`. Then the meaning of each will be reinforced.
What about: const prefix = "*{X:"; let cssRule = prefix + cssValue + "}";
>> Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js:695 >> + // Ignore '*{X:' > > This comment could move to be inline with the definition of the const mentioned above.
...and if (column < prefix.length) ?
>> Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js:82 >> + if (this._delegate && typeof this._delegate.spreadsheetTextFieldWillStartEditing) > > === "function"
Whoops!
Nikita Vasilyev
Comment 8
2017-10-16 18:45:27 PDT
Created
attachment 323968
[details]
Patch
Matt Baker
Comment 9
2017-10-16 18:58:18 PDT
Comment on
attachment 323968
[details]
Patch r=me
WebKit Commit Bot
Comment 10
2017-10-16 19:25:19 PDT
Comment on
attachment 323968
[details]
Patch Clearing flags on attachment: 323968 Committed
r223453
: <
https://trac.webkit.org/changeset/223453
>
WebKit Commit Bot
Comment 11
2017-10-16 19:25:20 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.
Top of Page
Format For Printing
XML
Clone This Bug