Title: [239793] branches/safari-607-branch/Source/WebInspectorUI
Revision
239793
Author
alanc...@apple.com
Date
2019-01-09 16:34:36 -0800 (Wed, 09 Jan 2019)

Log Message

Cherry-pick r239690. rdar://problem/47158814

    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):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239690 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-607-branch/Source/WebInspectorUI/ChangeLog (239792 => 239793)


--- branches/safari-607-branch/Source/WebInspectorUI/ChangeLog	2019-01-10 00:31:52 UTC (rev 239792)
+++ branches/safari-607-branch/Source/WebInspectorUI/ChangeLog	2019-01-10 00:34:36 UTC (rev 239793)
@@ -1,3 +1,50 @@
+2019-01-09  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r239690. rdar://problem/47158814
+
+    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):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239690 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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: branches/safari-607-branch/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js (239792 => 239793)


--- branches/safari-607-branch/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js	2019-01-10 00:31:52 UTC (rev 239792)
+++ branches/safari-607-branch/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js	2019-01-10 00:34:36 UTC (rev 239793)
@@ -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: branches/safari-607-branch/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js (239792 => 239793)


--- branches/safari-607-branch/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js	2019-01-10 00:31:52 UTC (rev 239792)
+++ branches/safari-607-branch/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js	2019-01-10 00:34:36 UTC (rev 239793)
@@ -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