Bug 146676

Summary: Web Inspector: Tabbing in the styles sidebar doesn't highlight the next section of text
Product: WebKit Reporter: Devin Rousso <hi>
Component: Web InspectorAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, graouts, joepeck, jonowells, mattbaker, nvasilyev, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Actual
none
Patch
none
Patch
none
Patch none

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.