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.
<rdar://problem/15345003>
Created attachment 215427 [details] Screenshot
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".
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?
(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.
Created attachment 254674 [details] Patch
Comment on attachment 254674 [details] Patch Clearing flags on attachment: 254674 Committed r185471: <http://trac.webkit.org/changeset/185471>
All reviewed patches have been landed. Closing bug.