Web Inspector: Implement autocompletion for CSS variables
authorwebkit@devinrousso.com <webkit@devinrousso.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Apr 2017 06:51:51 +0000 (06:51 +0000)
committerwebkit@devinrousso.com <webkit@devinrousso.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Apr 2017 06:51:51 +0000 (06:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=154441

Reviewed by Joseph Pecoraro.

* UserInterface/Views/CSSStyleDeclarationTextEditor.js:
(WebInspector.CSSStyleDeclarationTextEditor.prototype.completionControllerCompletionsNeeded):
Add CSS variables to the list of matching completions based on those defined in the current
node's computed style.

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js

index bf75c35..6e9dc92 100644 (file)
@@ -1,3 +1,15 @@
+2017-04-13  Devin Rousso  <webkit@devinrousso.com>
+
+        Web Inspector: Implement autocompletion for CSS variables
+        https://bugs.webkit.org/show_bug.cgi?id=154441
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Views/CSSStyleDeclarationTextEditor.js:
+        (WebInspector.CSSStyleDeclarationTextEditor.prototype.completionControllerCompletionsNeeded):
+        Add CSS variables to the list of matching completions based on those defined in the current
+        node's computed style.
+
 2017-04-13  Ross Kirsling  <ross.kirsling@sony.com>
 
         Web Inspector: No context menu available via ENABLE_INSPECTOR_SERVER
 2017-04-13  Ross Kirsling  <ross.kirsling@sony.com>
 
         Web Inspector: No context menu available via ENABLE_INSPECTOR_SERVER
index 7023233..32e8290 100644 (file)
@@ -386,6 +386,14 @@ WebInspector.CSSStyleDeclarationTextEditor = class CSSStyleDeclarationTextEditor
             this._propertiesChanged();
     }
 
             this._propertiesChanged();
     }
 
+    completionControllerCompletionsNeeded(completionController, prefix, defaultCompletions, base, suffix, forced)
+    {
+        let properties = this._style.nodeStyles.computedStyle.properties;
+        let variables = properties.filter((property) => property.variable && property.name.startsWith(prefix));
+        let variableNames = variables.map((property) => property.name);
+        completionController.updateCompletions(defaultCompletions.concat(variableNames));
+    }
+
     layout()
     {
         this._codeMirror.refresh();
     layout()
     {
         this._codeMirror.refresh();