Title: [239690] trunk/Source/WebInspectorUI
Revision
239690
Author
nvasil...@apple.com
Date
2019-01-07 12:20:17 -0800 (Mon, 07 Jan 2019)

Log Message

Web Inspector: "white" isn't recognized as a color keyword
https://bugs.webkit.org/show_bug.cgi?id=193173
<rdar://problem/47068595>

Reviewed by Joseph Pecoraro.

Attempt to parse "atom" token types as colors.

Display color picker only for color-aware properties. For instance,
display it for "color: white" but not for "-apple-pay-button-style: white".

* UserInterface/Models/CSSKeywordCompletions.js:
(addKeywordsForName):
(WI.CSSKeywordCompletions.forProperty):
(WI.CSSKeywordCompletions.isColorAwareProperty):
* UserInterface/Views/SpreadsheetStyleProperty.js:
(WI.SpreadsheetStyleProperty.prototype._renderValue):
(WI.SpreadsheetStyleProperty.prototype._addColorTokens):

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (239689 => 239690)


--- trunk/Source/WebInspectorUI/ChangeLog	2019-01-07 20:10:55 UTC (rev 239689)
+++ trunk/Source/WebInspectorUI/ChangeLog	2019-01-07 20:20:17 UTC (rev 239690)
@@ -1,3 +1,24 @@
+2019-01-07  Nikita Vasilyev  <nvasil...@apple.com>
+
+        Web Inspector: "white" isn't recognized as a color keyword
+        https://bugs.webkit.org/show_bug.cgi?id=193173
+        <rdar://problem/47068595>
+
+        Reviewed by Joseph Pecoraro.
+
+        Attempt to parse "atom" token types as colors.
+
+        Display color picker only for color-aware properties. For instance,
+        display it for "color: white" but not for "-apple-pay-button-style: white".
+
+        * UserInterface/Models/CSSKeywordCompletions.js:
+        (addKeywordsForName):
+        (WI.CSSKeywordCompletions.forProperty):
+        (WI.CSSKeywordCompletions.isColorAwareProperty):
+        * UserInterface/Views/SpreadsheetStyleProperty.js:
+        (WI.SpreadsheetStyleProperty.prototype._renderValue):
+        (WI.SpreadsheetStyleProperty.prototype._addColorTokens):
+
 2019-01-04  Joseph Pecoraro  <pecor...@apple.com>
 
         Web Inspector: subclasses of WI.ClusterContentView don't save/restore content views after the initial view

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js (239689 => 239690)


--- trunk/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js	2019-01-07 20:10:55 UTC (rev 239689)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js	2019-01-07 20:20:17 UTC (rev 239690)
@@ -43,12 +43,8 @@
         else if (isNotPrefixed && ("-webkit-" + name) in WI.CSSKeywordCompletions._propertyKeywordMap)
             acceptedKeywords = acceptedKeywords.concat(WI.CSSKeywordCompletions._propertyKeywordMap["-webkit-" + name]);
 
-        if (name in WI.CSSKeywordCompletions._colorAwareProperties)
+        if (WI.CSSKeywordCompletions.isColorAwareProperty(name))
             acceptedKeywords = acceptedKeywords.concat(WI.CSSKeywordCompletions._colors);
-        else if (isNotPrefixed && ("-webkit-" + name) in WI.CSSKeywordCompletions._colorAwareProperties)
-            acceptedKeywords = acceptedKeywords.concat(WI.CSSKeywordCompletions._colors);
-        else if (name.endsWith("color"))
-            acceptedKeywords = acceptedKeywords.concat(WI.CSSKeywordCompletions._colors);
 
         // Only suggest "inherit" on inheritable properties even though it is valid on all properties.
         if (WI.CSSKeywordCompletions.InheritedProperties.has(name))
@@ -77,6 +73,21 @@
     return new WI.CSSCompletions(Array.from(new Set(acceptedKeywords)), true);
 };
 
+WI.CSSKeywordCompletions.isColorAwareProperty = function(name)
+{
+    if (name in WI.CSSKeywordCompletions._colorAwareProperties)
+        return true;
+
+    let isNotPrefixed = name.charAt(0) !== "-";
+    if (isNotPrefixed && ("-webkit-" + name) in WI.CSSKeywordCompletions._colorAwareProperties)
+        return true;
+
+    if (name.endsWith("color"))
+        return true;
+
+    return false;
+};
+
 WI.CSSKeywordCompletions.forFunction = function(functionName)
 {
     let suggestions = ["var()"];

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js (239689 => 239690)


--- trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js	2019-01-07 20:10:55 UTC (rev 239689)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js	2019-01-07 20:20:17 UTC (rev 239690)
@@ -420,8 +420,12 @@
 
         if (this._property.enabled) {
             // FIXME: <https://webkit.org/b/178636> Web Inspector: Styles: Make inline widgets work with CSS functions (var(), calc(), etc.)
-            tokens = this._addGradientTokens(tokens);
-            tokens = this._addColorTokens(tokens);
+
+            // CSS variables may contain color - display color picker for them.
+            if (this._property.variable || WI.CSSKeywordCompletions.isColorAwareProperty(this._property.name)) {
+                tokens = this._addGradientTokens(tokens);
+                tokens = this._addColorTokens(tokens);
+            }
             tokens = this._addTimingFunctionTokens(tokens, "cubic-bezier");
             tokens = this._addTimingFunctionTokens(tokens, "spring");
             tokens = this._addVariableTokens(tokens);
@@ -562,7 +566,7 @@
             } else if (WI.Color.FunctionNames.has(token.value) && token.type && (token.type.includes("atom") || token.type.includes("keyword"))) {
                 // Color Function start
                 colorFunctionStartIndex = i;
-            } else if (isNaN(colorFunctionStartIndex) && token.type && token.type.includes("keyword")) {
+            } else if (isNaN(colorFunctionStartIndex) && token.type && (token.type.includes("atom") || token.type.includes("keyword"))) {
                 // Color keyword
                 pushPossibleColorToken(token.value, token);
             } else if (!isNaN(colorFunctionStartIndex)) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to