RESOLVED FIXED 133997
Web Inspector: Hexadecimal color values in all CSS editors are purple when they should be blue
https://bugs.webkit.org/show_bug.cgi?id=133997
Summary Web Inspector: Hexadecimal color values in all CSS editors are purple when th...
Jonathan Wells
Reported 2014-06-17 13:48:43 PDT
CodeMirror 4 regression.
Attachments
[PATCH] Attempted fix. (2.65 KB, patch)
2014-07-01 15:36 PDT, Jonathan Wells
no flags
[PATCH] Attempted fix with cleanup. (4.94 KB, patch)
2014-07-01 16:12 PDT, Jonathan Wells
joepeck: review+
joepeck: commit-queue-
[PATCH] Reviewed fix with small edits. (4.94 KB, patch)
2014-07-01 16:32 PDT, Jonathan Wells
no flags
Radar WebKit Bug Importer
Comment 1 2014-06-17 13:49:18 PDT
Jonathan Wells
Comment 2 2014-07-01 15:36:39 PDT
Created attachment 234206 [details] [PATCH] Attempted fix.
Joseph Pecoraro
Comment 3 2014-07-01 15:51:38 PDT
Comment on attachment 234206 [details] [PATCH] Attempted fix. View in context: https://bugs.webkit.org/attachment.cgi?id=234206&action=review > Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js:185 > + const hexColorRegex = /(#[0-9a-fA-F]{6}|#[0-9a-fA-F]{3})/g; I would suggest: /#(?:[0-9a-fA-F){6}|[0-9a-fA-F){3})/g Changes: 1. Share the "#" because it is common 2. Use a non-captured group (?:...) instead of (...) because you don't reference the group > Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js:203 > - if (style === "atom" && stream.current() === "url") { > + if (style === "atom" && hexColorRegex.test(stream.current())) > + style = style + " hex-color"; > + else if (style === "atom" && stream.current() === "url") { > // If the current text is "url" then we should expect the next string token to be a link. > state._expectLink = true; > } else if (state._expectLink && style === "atom") { Nit: There are a lot of style === "atom" checks here. Can we pull that out into a bool above the if/else chain? Also, it looks like you add style "hex-color" but the CSS below checks for .cm-hex-color. Does the ".cm-" prefix automatically get added somewhere?
Joseph Pecoraro
Comment 4 2014-07-01 15:58:20 PDT
(In reply to comment #3) > (From update of attachment 234206 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=234206&action=review > > > Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js:185 > > + const hexColorRegex = /(#[0-9a-fA-F]{6}|#[0-9a-fA-F]{3})/g; > > I would suggest: > > /#(?:[0-9a-fA-F){6}|[0-9a-fA-F){3})/g In person discussion, we may want to gracefully handle something like: #12345678 So we might want to throw a \b on the end of the regex and not match this.
Jonathan Wells
Comment 5 2014-07-01 16:07:38 PDT
I agree.
Jonathan Wells
Comment 6 2014-07-01 16:12:50 PDT
Created attachment 234210 [details] [PATCH] Attempted fix with cleanup. Cleaned up the logic and saved the regexp test for later to lower the number of calls to the RegExp API.
Joseph Pecoraro
Comment 7 2014-07-01 16:17:32 PDT
Comment on attachment 234210 [details] [PATCH] Attempted fix with cleanup. View in context: https://bugs.webkit.org/attachment.cgi?id=234210&action=review Awesome! r=me > Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js:185 > + const hexColorRegex = /(#[0-9a-fA-F]{6}|#[0-9a-fA-F]{3})\b/g; Nit: I think we still want at least the (?:...) non-capture group. As that can be a performance win with Regexs.
Jonathan Wells
Comment 8 2014-07-01 16:32:45 PDT
Created attachment 234215 [details] [PATCH] Reviewed fix with small edits.
WebKit Commit Bot
Comment 9 2014-07-01 17:13:48 PDT
Comment on attachment 234215 [details] [PATCH] Reviewed fix with small edits. Clearing flags on attachment: 234215 Committed r170681: <http://trac.webkit.org/changeset/170681>
WebKit Commit Bot
Comment 10 2014-07-01 17:13:52 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.