Bug 167949 - Web Inspector: Option+hover on -webkit-transform in Styles sidebar underlines only half the property
Summary: Web Inspector: Option+hover on -webkit-transform in Styles sidebar underlines...
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: Devin Rousso
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-02-07 12:12 PST by BJ Burg
Modified: 2017-02-09 11:30 PST (History)
6 users (show)

See Also:


Attachments
Patch (2.28 KB, patch)
2017-02-08 14:44 PST, Devin Rousso
joepeck: review+
Details | Formatted Diff | Diff
Patch (2.82 KB, patch)
2017-02-09 02:32 PST, Devin Rousso
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description BJ Burg 2017-02-07 12:12:03 PST
Via Antoine Quint:

"When you have a -wekit-transform property in the Styles sidebar and you hold down Cmd while hovering over it, the text is only partially underlined as the string is split in two tokens."
Comment 1 BJ Burg 2017-02-07 12:12:18 PST
<rdar://problem/14057565>
Comment 2 BJ Burg 2017-02-07 12:13:32 PST
Joe said in radar:

"So this is because CodeMirror is splitting it up into 2 tokens, 1 vendor prefix and 1 actual property. We can make CodeMirrorTokenTrackingController smarter here, and treat both as 1 "token" for the Cmd+Hover mode."
Comment 3 Devin Rousso 2017-02-08 14:44:23 PST
Created attachment 300969 [details]
Patch
Comment 4 Joseph Pecoraro 2017-02-08 16:57:45 PST
Comment on attachment 300969 [details]
Patch

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

> Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorTokenTrackingController.js:351
> +        let preceedingTokenPosition = Object.shallowCopy(position);
> +        preceedingTokenPosition.ch = tokenInfo.token.start - 1;

This might need to sanity check some things: What if tokenInfo.token.start was 0. Then this would set ch to -1. Would that cause a problem?
Comment 5 Devin Rousso 2017-02-08 17:09:31 PST
Comment on attachment 300969 [details]
Patch

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

>> Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorTokenTrackingController.js:351
>> +        preceedingTokenPosition.ch = tokenInfo.token.start - 1;
> 
> This might need to sanity check some things: What if tokenInfo.token.start was 0. Then this would set ch to -1. Would that cause a problem?

So I just tried this, and it appears to work fine.  I think that CodeMirror will create an "empty" token if the position is invalid.  Either way, I also check that the token exists and has a type, so it should cover both cases.
Comment 6 Joseph Pecoraro 2017-02-08 22:18:17 PST
Comment on attachment 300969 [details]
Patch

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

r=me

>>> Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorTokenTrackingController.js:351
>>> +        preceedingTokenPosition.ch = tokenInfo.token.start - 1;
>> 
>> This might need to sanity check some things: What if tokenInfo.token.start was 0. Then this would set ch to -1. Would that cause a problem?
> 
> So I just tried this, and it appears to work fine.  I think that CodeMirror will create an "empty" token if the position is invalid.  Either way, I also check that the token exists and has a type, so it should cover both cases.

I just want to make sure it doesn't throw an exception.  I see now that CodeMirror clips positions to ensure they are in bounds (clipPos and clipToLen).

> Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorTokenTrackingController.js:354
> +        if (preceedingToken && preceedingToken.type && preceedingToken.type.includes("meta")) {

Includes "meta" could false trigger if the type was something was something like "not-meta". But we seem to do this style elsewhere and meta is pretty unique =).
Comment 7 Devin Rousso 2017-02-09 02:32:42 PST
Created attachment 301027 [details]
Patch

So I just realized that I forgot to include a check for if the user highlights the meta token instead of the non-meta token.  These changes now cover both.
Comment 8 Joseph Pecoraro 2017-02-09 11:05:13 PST
Comment on attachment 301027 [details]
Patch

Nice. r=me
Comment 9 WebKit Commit Bot 2017-02-09 11:30:38 PST
Comment on attachment 301027 [details]
Patch

Clearing flags on attachment: 301027

Committed r211973: <http://trac.webkit.org/changeset/211973>
Comment 10 WebKit Commit Bot 2017-02-09 11:30:43 PST
All reviewed patches have been landed.  Closing bug.