Bug 123468 - Web Inspector: font-family names interpreted as color
Summary: Web Inspector: font-family names interpreted as color
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac (Intel) Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2013-10-29 14:19 PDT by Andreas Eldh
Modified: 2015-06-11 13:52 PDT (History)
4 users (show)

See Also:


Attachments
Screenshot (deleted)
2013-10-29 14:20 PDT, Andreas Eldh
no flags Details
Patch (1.58 KB, patch)
2015-06-10 13:31 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 Andreas Eldh 2013-10-29 14:19:13 PDT
I had "Crimson Text" as the font-family on body, and the word "Crimson" was treated as a color, with a red (crimson?) square next to it. 

Using Safari 7.0 (9537.71) on OS X Mavericks.
Comment 1 Radar WebKit Bug Importer 2013-10-29 14:19:38 PDT
<rdar://problem/15345003>
Comment 2 Andreas Eldh 2013-10-29 14:20:07 PDT
Created attachment 215427 [details]
Screenshot
Comment 3 Joseph Pecoraro 2013-10-29 15:18:15 PDT
Heh. Well, to extend the "short term fix" we have in CSSStyleDeclarationTextEditor we have:

    // Act as a negative look-behind and disallow the color from being prefixing with certain characters.
    if (match.index > 0 && /[-.]/.test(lineContent[match.index - 1])) {
        match = colorRegex.exec(lineContent);
        continue;
    }

We could include ['"] in that list of negative look-behind characters. But that wouldn't help "Foo Red Bar".
Comment 4 Joseph Pecoraro 2013-10-29 15:20:49 PDT
Now that I think about it, we have CodeMirror's tokenizer right now, but we are still regex checking lines:

    var lineContent = this._codeMirror.getLine(i);
    var match = colorRegex.exec(lineContent);
    …

I think we be could just iterate over tokens instead of running the regex on the line?
Comment 5 Timothy Hatcher 2013-10-29 16:24:07 PDT
(In reply to comment #4)
> Now that I think about it, we have CodeMirror's tokenizer right now, but we are still regex checking lines:
> 
>     var lineContent = this._codeMirror.getLine(i);
>     var match = colorRegex.exec(lineContent);
>     …
> 
> I think we be could just iterate over tokens instead of running the regex on the line?

That would work for color words and hex, but will need to have extra logic for rgb, etc.
Comment 6 Devin Rousso 2015-06-10 13:31:43 PDT
Created attachment 254674 [details]
Patch
Comment 7 WebKit Commit Bot 2015-06-11 13:52:00 PDT
Comment on attachment 254674 [details]
Patch

Clearing flags on attachment: 254674

Committed r185471: <http://trac.webkit.org/changeset/185471>
Comment 8 WebKit Commit Bot 2015-06-11 13:52:04 PDT
All reviewed patches have been landed.  Closing bug.