Title: [170681] trunk/Source/WebInspectorUI
- Revision
- 170681
- Author
- jonowe...@apple.com
- Date
- 2014-07-01 17:13:19 -0700 (Tue, 01 Jul 2014)
Log Message
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
Reviewed by Joseph Pecoraro.
CodeMirror 4 removed the style for hex colors from the CSS tokenizer.
Feature has been added to CodeMirrorAdditions.js.
* UserInterface/Views/CodeMirrorAdditions.js: Added hex-color to style for a valid hexadecimal color.
* UserInterface/Views/SyntaxHighlightingDefaultTheme.css: Added selector for hexadecimal color.
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (170680 => 170681)
--- trunk/Source/WebInspectorUI/ChangeLog 2014-07-02 00:12:09 UTC (rev 170680)
+++ trunk/Source/WebInspectorUI/ChangeLog 2014-07-02 00:13:19 UTC (rev 170681)
@@ -1,3 +1,16 @@
+2014-07-01 Jonathan Wells <jonowe...@apple.com>
+
+ 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
+
+ Reviewed by Joseph Pecoraro.
+
+ CodeMirror 4 removed the style for hex colors from the CSS tokenizer.
+ Feature has been added to CodeMirrorAdditions.js.
+
+ * UserInterface/Views/CodeMirrorAdditions.js: Added hex-color to style for a valid hexadecimal color.
+ * UserInterface/Views/SyntaxHighlightingDefaultTheme.css: Added selector for hexadecimal color.
+
2014-06-26 Jono Wells <jonowe...@apple.com>
Web Inspector: Command-/ (slash) now auto-comments code via CodeMirror 4. Should remove as command to pause
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js (170680 => 170681)
--- trunk/Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js 2014-07-02 00:12:09 UTC (rev 170680)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js 2014-07-02 00:13:19 UTC (rev 170681)
@@ -182,6 +182,8 @@
function extendedCSSToken(stream, state)
{
+ const hexColorRegex = /#(?:[0-9a-fA-F]{6}|[0-9a-fA-F]{3})\b/g;
+
if (state._urlTokenize) {
// Call the link tokenizer instead.
var style = state._urlTokenize(stream, state);
@@ -193,29 +195,32 @@
var style = this._token(stream, state);
if (style) {
- 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") {
- // We expected a string and got it. This is a link. Parse it the way we want it.
- delete state._expectLink;
+ if (style === "atom") {
+ if (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) {
+ // We expected a string and got it. This is a link. Parse it the way we want it.
+ delete state._expectLink;
- // This is a link, so setup the state to process it next.
- state._urlTokenize = tokenizeCSSURLString;
- state._urlBaseStyle = style;
+ // This is a link, so setup the state to process it next.
+ state._urlTokenize = tokenizeCSSURLString;
+ state._urlBaseStyle = style;
- // The url may or may not be quoted.
- var quote = stream.current()[0];
- state._urlQuoteCharacter = quote === "'" || quote === "\"" ? quote : ")";
- state._unquotedURLString = state._urlQuoteCharacter === ")";
+ // The url may or may not be quoted.
+ var quote = stream.current()[0];
+ state._urlQuoteCharacter = quote === "'" || quote === "\"" ? quote : ")";
+ state._unquotedURLString = state._urlQuoteCharacter === ")";
- // Rewind the steam to the start of this token.
- stream.pos = startPosition;
+ // Rewind the steam to the start of this token.
+ stream.pos = startPosition;
- // Eat the open quote of the string so the string style
- // will be used for the quote character.
- if (!state._unquotedURLString)
- stream.eat(state._urlQuoteCharacter);
+ // Eat the open quote of the string so the string style
+ // will be used for the quote character.
+ if (!state._unquotedURLString)
+ stream.eat(state._urlQuoteCharacter);
+ } else if (hexColorRegex.test(stream.current()))
+ style = style + " hex-color";
} else if (state._expectLink) {
// We expected a string and didn't get one. Cleanup.
delete state._expectLink;
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SyntaxHighlightingDefaultTheme.css (170680 => 170681)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SyntaxHighlightingDefaultTheme.css 2014-07-02 00:12:09 UTC (rev 170680)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SyntaxHighlightingDefaultTheme.css 2014-07-02 00:13:19 UTC (rev 170681)
@@ -60,6 +60,7 @@
}
.cm-s-default .cm-number,
+.cm-s-default .cm-atom.cm-hex-color,
.syntax-highlighted .css-number,
.syntax-highlighted ._javascript_-number {
color: rgb(28, 0, 207);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes