<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[212273] trunk/Source/WebInspectorUI</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/212273">212273</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2017-02-13 18:29:38 -0800 (Mon, 13 Feb 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: provide a way to show current value of CSS variables in style rules
https://bugs.webkit.org/show_bug.cgi?id=168172

Patch by Devin Rousso &lt;dcrousso+webkit@gmail.com&gt; on 2017-02-13
Reviewed by Timothy Hatcher.

* Localizations/en.lproj/localizedStrings.js:
* UserInterface/Images/CSSVariable.svg: Added.

* UserInterface/Models/TextMarker.js:
(WebInspector.TextMarker.Type):

* UserInterface/Views/CSSStyleDeclarationTextEditor.js:
(WebInspector.CSSStyleDeclarationTextEditor._createInlineSwatches.update):

* UserInterface/Views/CodeMirrorTextMarkers.js:
(createCodeMirrorTextMarkers):
(createCodeMirrorVariableTextMarkers):

* UserInterface/Views/InlineSwatch.css:
(.inline-swatch.variable):
(.inline-swatch:matches(.bezier, .spring, .variable)):
(.inline-swatch:matches(.bezier, .spring, .variable):hover):
(.inline-swatch:matches(.bezier, .spring, .variable):active):
(.inline-swatch-variable-popover):
(.inline-swatch-variable-popover .CodeMirror):
(.inline-swatch-variable-popover .CodeMirror pre):
(.inline-swatch:matches(.bezier, .spring):hover): Deleted.
(.inline-swatch:matches(.bezier, .spring):active): Deleted.

* UserInterface/Views/InlineSwatch.js:
(WebInspector.InlineSwatch):
(WebInspector.InlineSwatch.prototype._fallbackValue):
(WebInspector.InlineSwatch.prototype._swatchElementClicked):
(WebInspector.InlineSwatch.prototype._valueEditorValueDidChange):
(WebInspector.InlineSwatch.Type):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUILocalizationsenlprojlocalizedStringsjs">trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsTextMarkerjs">trunk/Source/WebInspectorUI/UserInterface/Models/TextMarker.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsCSSStyleDeclarationTextEditorjs">trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsCodeMirrorTextMarkersjs">trunk/Source/WebInspectorUI/UserInterface/Views/CodeMirrorTextMarkers.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsInlineSwatchcss">trunk/Source/WebInspectorUI/UserInterface/Views/InlineSwatch.css</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsInlineSwatchjs">trunk/Source/WebInspectorUI/UserInterface/Views/InlineSwatch.js</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceImagesCSSVariablesvg">trunk/Source/WebInspectorUI/UserInterface/Images/CSSVariable.svg</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (212272 => 212273)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2017-02-14 02:28:55 UTC (rev 212272)
+++ trunk/Source/WebInspectorUI/ChangeLog        2017-02-14 02:29:38 UTC (rev 212273)
</span><span class="lines">@@ -1,3 +1,41 @@
</span><ins>+2017-02-13  Devin Rousso  &lt;dcrousso+webkit@gmail.com&gt;
+
+        Web Inspector: provide a way to show current value of CSS variables in style rules
+        https://bugs.webkit.org/show_bug.cgi?id=168172
+
+        Reviewed by Timothy Hatcher.
+
+        * Localizations/en.lproj/localizedStrings.js:
+        * UserInterface/Images/CSSVariable.svg: Added.
+
+        * UserInterface/Models/TextMarker.js:
+        (WebInspector.TextMarker.Type):
+
+        * UserInterface/Views/CSSStyleDeclarationTextEditor.js:
+        (WebInspector.CSSStyleDeclarationTextEditor._createInlineSwatches.update):
+
+        * UserInterface/Views/CodeMirrorTextMarkers.js:
+        (createCodeMirrorTextMarkers):
+        (createCodeMirrorVariableTextMarkers):
+
+        * UserInterface/Views/InlineSwatch.css:
+        (.inline-swatch.variable):
+        (.inline-swatch:matches(.bezier, .spring, .variable)):
+        (.inline-swatch:matches(.bezier, .spring, .variable):hover):
+        (.inline-swatch:matches(.bezier, .spring, .variable):active):
+        (.inline-swatch-variable-popover):
+        (.inline-swatch-variable-popover .CodeMirror):
+        (.inline-swatch-variable-popover .CodeMirror pre):
+        (.inline-swatch:matches(.bezier, .spring):hover): Deleted.
+        (.inline-swatch:matches(.bezier, .spring):active): Deleted.
+
+        * UserInterface/Views/InlineSwatch.js:
+        (WebInspector.InlineSwatch):
+        (WebInspector.InlineSwatch.prototype._fallbackValue):
+        (WebInspector.InlineSwatch.prototype._swatchElementClicked):
+        (WebInspector.InlineSwatch.prototype._valueEditorValueDidChange):
+        (WebInspector.InlineSwatch.Type):
+
</ins><span class="cx"> 2017-02-13  Matt Baker  &lt;mattbaker@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION(r188138): Web Inspector: cannot edit next/previous DOM attribute by using tab/shift-tab
</span></span></pre></div>
<a id="trunkSourceWebInspectorUILocalizationsenlprojlocalizedStringsjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (212272 => 212273)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js        2017-02-14 02:28:55 UTC (rev 212272)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js        2017-02-14 02:29:38 UTC (rev 212273)
</span><span class="lines">@@ -828,6 +828,7 @@
</span><span class="cx"> localizedStrings[&quot;Variants&quot;] = &quot;Variants&quot;;
</span><span class="cx"> localizedStrings[&quot;Version&quot;] = &quot;Version&quot;;
</span><span class="cx"> localizedStrings[&quot;Vertical&quot;] = &quot;Vertical&quot;;
</span><ins>+localizedStrings[&quot;View variable value&quot;] = &quot;View variable value&quot;;
</ins><span class="cx"> localizedStrings[&quot;Visibility&quot;] = &quot;Visibility&quot;;
</span><span class="cx"> localizedStrings[&quot;Visible&quot;] = &quot;Visible&quot;;
</span><span class="cx"> localizedStrings[&quot;Waiting to be upgraded&quot;] = &quot;Waiting to be upgraded&quot;;
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceImagesCSSVariablesvg"></a>
<div class="addfile"><h4>Added: trunk/Source/WebInspectorUI/UserInterface/Images/CSSVariable.svg (0 => 212273)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Images/CSSVariable.svg                                (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Images/CSSVariable.svg        2017-02-14 02:29:38 UTC (rev 212273)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
+&lt;!-- Copyright © 2017 Devin Rousso &lt;dcrousso+webkit@gmail.com&gt;. All rights reserved. --&gt;
+&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; id=&quot;root&quot; version=&quot;1.1&quot; viewBox=&quot;0 0 16 16&quot;&gt;
+    &lt;rect fill=&quot;hsl(212, 92%, 54%)&quot; x=&quot;0&quot; y=&quot;0&quot; width=&quot;16&quot; height=&quot;16&quot; rx=&quot;3&quot; ry=&quot;3&quot;/&gt;
+    &lt;rect fill=&quot;white&quot; x=&quot;3.5&quot; y=&quot;4.5&quot; width=&quot;9&quot; height=&quot;2.5&quot;/&gt;
+    &lt;rect fill=&quot;white&quot; x=&quot;3.5&quot; y=&quot;9&quot; width=&quot;9&quot; height=&quot;2.5&quot;/&gt;
+&lt;/svg&gt;
</ins></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsTextMarkerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Models/TextMarker.js (212272 => 212273)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/TextMarker.js        2017-02-14 02:28:55 UTC (rev 212272)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/TextMarker.js        2017-02-14 02:29:38 UTC (rev 212273)
</span><span class="lines">@@ -85,4 +85,5 @@
</span><span class="cx">     Plain: &quot;text-marker-type-plain&quot;,
</span><span class="cx">     CubicBezier: &quot;text-marker-type-cubic-bezier&quot;,
</span><span class="cx">     Spring: &quot;text-marker-type-spring&quot;,
</span><ins>+    Variable: &quot;text-marker-type-variable&quot;,
</ins><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsCSSStyleDeclarationTextEditorjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js (212272 => 212273)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js        2017-02-14 02:28:55 UTC (rev 212272)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js        2017-02-14 02:29:38 UTC (rev 212273)
</span><span class="lines">@@ -895,6 +895,18 @@
</span><span class="cx">                 let swatch = new WebInspector.InlineSwatch(WebInspector.InlineSwatch.Type.Spring, spring, this._codeMirror.getOption(&quot;readOnly&quot;));
</span><span class="cx">                 createSwatch.call(this, swatch, marker, spring, springString);
</span><span class="cx">             });
</span><ins>+
+            // Look for CSS variables and add swatches in front of them.
+            createCodeMirrorVariableTextMarkers(this._codeMirror, range, (marker, variable, variableString) =&gt; {
+                const dontCreateIfMissing = true;
+                let variableProperty = this._style.nodeStyles.computedStyle.propertyForName(variableString, dontCreateIfMissing);
+                if (!variableProperty)
+                    return;
+
+                let trimmedValue = variableProperty.value.trim();
+                let swatch = new WebInspector.InlineSwatch(WebInspector.InlineSwatch.Type.Variable, trimmedValue, this._codeMirror.getOption(&quot;readOnly&quot;));
+                createSwatch.call(this, swatch, marker, variableProperty, trimmedValue);
+            });
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (nonatomic)
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsCodeMirrorTextMarkersjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CodeMirrorTextMarkers.js (212272 => 212273)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/CodeMirrorTextMarkers.js        2017-02-14 02:28:55 UTC (rev 212272)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CodeMirrorTextMarkers.js        2017-02-14 02:29:38 UTC (rev 212273)
</span><span class="lines">@@ -61,9 +61,9 @@
</span><span class="cx">                 continue;
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            var valueString = match[0];
-            var value = WebInspector[type].fromString(valueString);
-            if (!value) {
</del><ins>+            let valueString = match[1];
+            let value = WebInspector[type] ? WebInspector[type].fromString(valueString) : null;
+            if (WebInspector[type] &amp;&amp; !value) {
</ins><span class="cx">                 match = pattern.exec(lineContent);
</span><span class="cx">                 continue;
</span><span class="cx">             }
</span><span class="lines">@@ -201,3 +201,9 @@
</span><span class="cx">     const springRegex = /(spring\([^)]+\))/g;
</span><span class="cx">     return createCodeMirrorTextMarkers(&quot;Spring&quot;, springRegex, null, codeMirror, range, callback);
</span><span class="cx"> }
</span><ins>+
+function createCodeMirrorVariableTextMarkers(codeMirror, range, callback)
+{
+    const variableRegex = /var\((--[\w-]+)\)/g;
+    return createCodeMirrorTextMarkers(&quot;Variable&quot;, variableRegex, null, codeMirror, range, callback);
+}
</ins></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsInlineSwatchcss"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/InlineSwatch.css (212272 => 212273)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/InlineSwatch.css        2017-02-14 02:28:55 UTC (rev 212272)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/InlineSwatch.css        2017-02-14 02:29:38 UTC (rev 212273)
</span><span class="lines">@@ -47,16 +47,20 @@
</span><span class="cx">     content: url(../Images/CubicBezier.svg);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-.inline-swatch:matches(.bezier, .spring) {
</del><ins>+.inline-swatch.variable {
+    content: url(../Images/CSSVariable.svg);
+}
+
+.inline-swatch:matches(.bezier, .spring, .variable) {
</ins><span class="cx">     margin-right: 2px;
</span><span class="cx">     background: none;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-.inline-swatch:matches(.bezier, .spring):hover {
</del><ins>+.inline-swatch:matches(.bezier, .spring, .variable):hover {
</ins><span class="cx">     filter: brightness(0.9);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-.inline-swatch:matches(.bezier, .spring):active {
</del><ins>+.inline-swatch:matches(.bezier, .spring, .variable):active {
</ins><span class="cx">     filter: brightness(0.8);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -92,3 +96,18 @@
</span><span class="cx">     display: none;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.inline-swatch-variable-popover {
+    display: flex;
+    align-items: center;
+    min-height: 24px;
+    padding-top: 0.5px;
+}
+
+.inline-swatch-variable-popover .CodeMirror {
+    height: auto;
+    background-color: transparent;
+}
+
+.inline-swatch-variable-popover .CodeMirror pre {
+    padding: 0 3px;
+}
</ins></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsInlineSwatchjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/InlineSwatch.js (212272 => 212273)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/InlineSwatch.js        2017-02-14 02:28:55 UTC (rev 212272)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/InlineSwatch.js        2017-02-14 02:29:38 UTC (rev 212273)
</span><span class="lines">@@ -36,6 +36,12 @@
</span><span class="cx">         this._swatchElement.classList.add(&quot;inline-swatch&quot;, this._type.split(&quot;-&quot;).lastValue);
</span><span class="cx"> 
</span><span class="cx">         switch (this._type) {
</span><ins>+        case WebInspector.InlineSwatch.Type.Color:
+            this._swatchElement.title = WebInspector.UIString(&quot;Click to select a color. Shift-click to switch color formats.&quot;);
+            break;
+        case WebInspector.InlineSwatch.Type.Gradient:
+            this._swatchElement.title = WebInspector.UIString(&quot;Edit custom gradient&quot;);
+            break;
</ins><span class="cx">         case WebInspector.InlineSwatch.Type.Bezier:
</span><span class="cx">             this._swatchElement.title = WebInspector.UIString(&quot;Edit “cubic-bezier“ function&quot;);
</span><span class="cx">             break;
</span><span class="lines">@@ -42,12 +48,11 @@
</span><span class="cx">         case WebInspector.InlineSwatch.Type.Spring:
</span><span class="cx">             this._swatchElement.title = WebInspector.UIString(&quot;Edit “spring“ function&quot;);
</span><span class="cx">             break;
</span><del>-        case WebInspector.InlineSwatch.Type.Gradient:
-            this._swatchElement.title = WebInspector.UIString(&quot;Edit custom gradient&quot;);
</del><ins>+        case WebInspector.InlineSwatch.Type.Variable:
+            this._swatchElement.title = WebInspector.UIString(&quot;View variable value&quot;);
</ins><span class="cx">             break;
</span><span class="cx">         default:
</span><del>-            console.assert(this._type === WebInspector.InlineSwatch.Type.Color);
-            this._swatchElement.title = WebInspector.UIString(&quot;Click to select a color. Shift-click to switch color formats.&quot;);
</del><ins>+            WebInspector.reportInternalError(`Unknown InlineSwatch type &quot;${type}&quot;`);
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -108,10 +113,10 @@
</span><span class="cx">         switch (this._type) {
</span><span class="cx">         case WebInspector.InlineSwatch.Type.Bezier:
</span><span class="cx">             return WebInspector.CubicBezier.fromString(&quot;linear&quot;);
</span><ins>+        case WebInspector.InlineSwatch.Type.Gradient:
+            return WebInspector.Gradient.fromString(&quot;linear-gradient(transparent, transparent)&quot;);
</ins><span class="cx">         case WebInspector.InlineSwatch.Type.Spring:
</span><span class="cx">             return WebInspector.Spring.fromString(&quot;1 100 10 0&quot;);
</span><del>-        case WebInspector.InlineSwatch.Type.Gradient:
-            return WebInspector.Gradient.fromString(&quot;linear-gradient(transparent, transparent)&quot;);
</del><span class="cx">         case WebInspector.InlineSwatch.Type.Color:
</span><span class="cx">             return WebInspector.Color.fromString(&quot;white&quot;);
</span><span class="cx">         default:
</span><span class="lines">@@ -152,22 +157,38 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         this._valueEditor = null;
</span><del>-        if (this._type === WebInspector.InlineSwatch.Type.Bezier) {
</del><ins>+        if (this._type === WebInspector.InlineSwatch.Type.Color) {
+            this._valueEditor = new WebInspector.ColorPicker;
+            this._valueEditor.addEventListener(WebInspector.ColorPicker.Event.ColorChanged, this._valueEditorValueDidChange, this);
+            this._valueEditor.addEventListener(WebInspector.ColorPicker.Event.FormatChanged, (event) =&gt; popover.update());
+        } else if (this._type === WebInspector.InlineSwatch.Type.Gradient) {
+            this._valueEditor = new WebInspector.GradientEditor;
+            this._valueEditor.addEventListener(WebInspector.GradientEditor.Event.GradientChanged, this._valueEditorValueDidChange, this);
+            this._valueEditor.addEventListener(WebInspector.GradientEditor.Event.ColorPickerToggled, (event) =&gt; popover.update());
+        } else if (this._type === WebInspector.InlineSwatch.Type.Bezier) {
</ins><span class="cx">             this._valueEditor = new WebInspector.BezierEditor;
</span><span class="cx">             this._valueEditor.addEventListener(WebInspector.BezierEditor.Event.BezierChanged, this._valueEditorValueDidChange, this);
</span><span class="cx">         } else if (this._type === WebInspector.InlineSwatch.Type.Spring) {
</span><span class="cx">             this._valueEditor = new WebInspector.SpringEditor;
</span><span class="cx">             this._valueEditor.addEventListener(WebInspector.SpringEditor.Event.SpringChanged, this._valueEditorValueDidChange, this);
</span><del>-        } else if (this._type === WebInspector.InlineSwatch.Type.Gradient) {
-            this._valueEditor = new WebInspector.GradientEditor;
-            this._valueEditor.addEventListener(WebInspector.GradientEditor.Event.GradientChanged, this._valueEditorValueDidChange, this);
-            this._valueEditor.addEventListener(WebInspector.GradientEditor.Event.ColorPickerToggled, (event) =&gt; popover.update());
-        } else {
-            this._valueEditor = new WebInspector.ColorPicker;
-            this._valueEditor.addEventListener(WebInspector.ColorPicker.Event.ColorChanged, this._valueEditorValueDidChange, this);
-            this._valueEditor.addEventListener(WebInspector.ColorPicker.Event.FormatChanged, (event) =&gt; popover.update());
</del><ins>+        } else if (this._type === WebInspector.InlineSwatch.Type.Variable) {
+            this._valueEditor = {};
+
+            this._valueEditor.element = document.createElement(&quot;div&quot;);
+            this._valueEditor.element.classList.add(&quot;inline-swatch-variable-popover&quot;);
+
+            this._valueEditor.codeMirror = WebInspector.CodeMirrorEditor.create(this._valueEditor.element, {
+                mode: &quot;css&quot;,
+                readOnly: &quot;nocursor&quot;,
+            });
+            this._valueEditor.codeMirror.on(&quot;update&quot;, () =&gt; {
+                popover.update();
+            });
</ins><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        if (!this._valueEditor)
+            return;
+
</ins><span class="cx">         popover.content = this._valueEditor.element;
</span><span class="cx">         popover.present(bounds.pad(2), [WebInspector.RectEdge.MIN_X]);
</span><span class="cx"> 
</span><span class="lines">@@ -177,26 +198,28 @@
</span><span class="cx">         this.dispatchEventToListeners(WebInspector.InlineSwatch.Event.Activated);
</span><span class="cx"> 
</span><span class="cx">         let value = this._value || this._fallbackValue();
</span><del>-        if (this._type === WebInspector.InlineSwatch.Type.Bezier)
</del><ins>+        if (this._type === WebInspector.InlineSwatch.Type.Color)
+            this._valueEditor.color = value;
+        else if (this._type === WebInspector.InlineSwatch.Type.Gradient)
+            this._valueEditor.gradient = value;
+        else if (this._type === WebInspector.InlineSwatch.Type.Bezier)
</ins><span class="cx">             this._valueEditor.bezier = value;
</span><span class="cx">         else if (this._type === WebInspector.InlineSwatch.Type.Spring)
</span><span class="cx">             this._valueEditor.spring = value;
</span><del>-        else if (this._type === WebInspector.InlineSwatch.Type.Gradient)
-            this._valueEditor.gradient = value;
-        else
-            this._valueEditor.color = value;
</del><ins>+        else if (this._type === WebInspector.InlineSwatch.Type.Variable)
+            this._valueEditor.codeMirror.setValue(value);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     _valueEditorValueDidChange(event)
</span><span class="cx">     {
</span><del>-        if (this._type === WebInspector.InlineSwatch.Type.Bezier)
</del><ins>+        if (this._type === WebInspector.InlineSwatch.Type.Color)
+            this._value = event.data.color;
+        else if (this._type === WebInspector.InlineSwatch.Type.Gradient)
+            this._value = event.data.gradient;
+        else if (this._type === WebInspector.InlineSwatch.Type.Bezier)
</ins><span class="cx">             this._value = event.data.bezier;
</span><span class="cx">         else if (this._type === WebInspector.InlineSwatch.Type.Spring)
</span><span class="cx">             this._value = event.data.spring;
</span><del>-        else if (this._type === WebInspector.InlineSwatch.Type.Gradient)
-            this._value = event.data.gradient;
-        else
-            this._value = event.data.color;
</del><span class="cx"> 
</span><span class="cx">         this._updateSwatch();
</span><span class="cx">     }
</span><span class="lines">@@ -306,6 +329,7 @@
</span><span class="cx">     Gradient: &quot;inline-swatch-type-gradient&quot;,
</span><span class="cx">     Bezier: &quot;inline-swatch-type-bezier&quot;,
</span><span class="cx">     Spring: &quot;inline-swatch-type-spring&quot;,
</span><ins>+    Variable: &quot;inline-swatch-type-variable&quot;,
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> WebInspector.InlineSwatch.Event = {
</span></span></pre>
</div>
</div>

</body>
</html>