Bug 146676 - Web Inspector: Tabbing in the styles sidebar doesn't highlight the next section of text
Summary: Web Inspector: Tabbing in the styles sidebar doesn't highlight the next secti...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-07-07 00:20 PDT by Devin Rousso
Modified: 2015-07-07 11:29 PDT (History)
8 users (show)

See Also:


Attachments
Actual (202.17 KB, image/gif)
2015-07-07 00:20 PDT, Devin Rousso
no flags Details
Patch (3.27 KB, patch)
2015-07-07 00:28 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (3.30 KB, patch)
2015-07-07 00:43 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (3.27 KB, patch)
2015-07-07 10:24 PDT, 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 Devin Rousso 2015-07-07 00:20:16 PDT
Created attachment 256284 [details]
Actual

This occurs when the value of the property can be entirely found in the name of that property.  For example, "border-collapse: collapse;" will highlight the "border-collapse" and then just the "collapse" because the code is trying to find the first index of the value (which is "collapse") and that happens to be inside the name.

Thanks to @Nikita for the gif.
Comment 1 Radar WebKit Bug Importer 2015-07-07 00:20:38 PDT
<rdar://problem/21699601>
Comment 2 Devin Rousso 2015-07-07 00:28:09 PDT
Created attachment 256286 [details]
Patch
Comment 3 Nikita Vasilyev 2015-07-07 00:32:52 PDT
Comment on attachment 256286 [details]
Patch

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

> Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js:400
> +        var substringIndex = text.includes(":") && cursor.ch >= text.indexOf(":") ? text.indexOf(":") : 0;

Nit: text.indexOf(":") used twice here, it should be pulled into a variable.
Comment 4 Devin Rousso 2015-07-07 00:43:56 PDT
Created attachment 256288 [details]
Patch
Comment 5 Timothy Hatcher 2015-07-07 09:31:08 PDT
Comment on attachment 256288 [details]
Patch

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

> Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js:400
> +        var colonIndex = text.indexOf(":");

What if this returns -1?

> Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js:403
> +        var match = /(?:[^:;\s]\s*)+/.exec(remaining);

You can do this without doing a substring. If you make the regex, then set regex.lastIndex = colonIndex, it will only search after that.
Comment 6 Devin Rousso 2015-07-07 10:07:29 PDT
Comment on attachment 256288 [details]
Patch

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

>> Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js:400
>> +        var colonIndex = text.indexOf(":");
> 
> What if this returns -1?

On the next line, it checks if colonIndex >= 0 and if not then set the start to 0 since the entire string should be matched.
Comment 7 Timothy Hatcher 2015-07-07 10:11:16 PDT
Comment on attachment 256288 [details]
Patch

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

>>> Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js:400
>>> +        var colonIndex = text.indexOf(":");
>> 
>> What if this returns -1?
> 
> On the next line, it checks if colonIndex >= 0 and if not then set the start to 0 since the entire string should be matched.

Oh, I see it now.
Comment 8 Devin Rousso 2015-07-07 10:24:30 PDT
Created attachment 256307 [details]
Patch
Comment 9 WebKit Commit Bot 2015-07-07 11:29:49 PDT
Comment on attachment 256307 [details]
Patch

Clearing flags on attachment: 256307

Committed r186468: <http://trac.webkit.org/changeset/186468>
Comment 10 WebKit Commit Bot 2015-07-07 11:29:53 PDT
All reviewed patches have been landed.  Closing bug.