<!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>[236715] 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/236715">236715</a></dd>
<dt>Author</dt> <dd>drousso@apple.com</dd>
<dt>Date</dt> <dd>2018-10-02 01:00:37 -0700 (Tue, 02 Oct 2018)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: Canvas: replace constant numbers with their associated name on WebGL contexts
https://bugs.webkit.org/show_bug.cgi?id=190026

Reviewed by Joseph Pecoraro.

* UserInterface/Models/RecordingAction.js:
(WI.RecordingAction.constantNameForParameter): Added.
(WI.RecordingAction.prototype.getColorParameters):
(WI.RecordingAction.prototype.getImageParameters):
Drive-by: add additional swatches to color/image arguments for WebGL actions.

* UserInterface/Views/CanvasSidebarPanel.js:
(WI.CanvasSidebarPanel.prototype._treeOutlineSelectionDidChange):
Drive-by: ensure that the `WI.RecordingContentView` is showing before applying the action.

* UserInterface/Views/RecordingActionTreeElement.js:
(WI.RecordingActionTreeElement._generateDOM.createParameterElement):
(WI.RecordingActionTreeElement._generateDOM):
* UserInterface/Views/RecordingActionTreeElement.css:
(.item.action > .titles .parameter.constant): Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsRecordingActionjs">trunk/Source/WebInspectorUI/UserInterface/Models/RecordingAction.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsRecordingActionTreeElementcss">trunk/Source/WebInspectorUI/UserInterface/Views/RecordingActionTreeElement.css</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsRecordingActionTreeElementjs">trunk/Source/WebInspectorUI/UserInterface/Views/RecordingActionTreeElement.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (236714 => 236715)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog    2018-10-02 06:59:46 UTC (rev 236714)
+++ trunk/Source/WebInspectorUI/ChangeLog       2018-10-02 08:00:37 UTC (rev 236715)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2018-10-02  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Canvas: replace constant numbers with their associated name on WebGL contexts
+        https://bugs.webkit.org/show_bug.cgi?id=190026
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Models/RecordingAction.js:
+        (WI.RecordingAction.constantNameForParameter): Added.
+        (WI.RecordingAction.prototype.getColorParameters):
+        (WI.RecordingAction.prototype.getImageParameters):
+        Drive-by: add additional swatches to color/image arguments for WebGL actions.
+
+        * UserInterface/Views/CanvasSidebarPanel.js:
+        (WI.CanvasSidebarPanel.prototype._treeOutlineSelectionDidChange):
+        Drive-by: ensure that the `WI.RecordingContentView` is showing before applying the action.
+
+        * UserInterface/Views/RecordingActionTreeElement.js:
+        (WI.RecordingActionTreeElement._generateDOM.createParameterElement):
+        (WI.RecordingActionTreeElement._generateDOM):
+        * UserInterface/Views/RecordingActionTreeElement.css:
+        (.item.action > .titles .parameter.constant): Added.
+
</ins><span class="cx"> 2018-10-01  Joseph Pecoraro  <pecoraro@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Fix a typo for execution context identifier
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsRecordingActionjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Models/RecordingAction.js (236714 => 236715)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/RecordingAction.js      2018-10-02 06:59:46 UTC (rev 236714)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/RecordingAction.js 2018-10-02 08:00:37 UTC (rev 236715)
</span><span class="lines">@@ -87,6 +87,49 @@
</span><span class="cx">         return typeof Object.getOwnPropertyDescriptor(prototype, name).value === "function";
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    static constantNameForParameter(type, name, value, index, count)
+    {
+        let indexesForType = WI.RecordingAction._constantIndexes[type];
+        if (!indexesForType)
+            return null;
+
+        let indexesForAction = indexesForType[name];
+        if (!indexesForAction)
+            return null;
+
+        if (Array.isArray(indexesForAction) && !indexesForAction.includes(index))
+            return null;
+
+        if (typeof indexesForAction === "object") {
+            let indexesForActionVariant = indexesForAction[count];
+            if (!indexesForActionVariant)
+                return null;
+
+            if (Array.isArray(indexesForActionVariant) && !indexesForActionVariant.includes(index))
+                return null;
+        }
+
+        if (value === 0 && type === WI.Recording.Type.CanvasWebGL) {
+            if (name === "blendFunc" || name === "blendFuncSeparate")
+                return "ZERO";
+            if (index === 0) {
+                if (name === "drawArrays" || name === "drawElements")
+                    return "POINTS";
+                if (name === "pixelStorei")
+                    return "NONE";
+            }
+        }
+
+        let prototype = WI.RecordingAction._prototypeForType(type);
+        for (let key in prototype) {
+            let descriptor = Object.getOwnPropertyDescriptor(prototype, key);
+            if (descriptor.value === value)
+                return key;
+        }
+
+        return null;
+    }
+
</ins><span class="cx">     static _prototypeForType(type)
</span><span class="cx">     {
</span><span class="cx">         if (type === WI.Recording.Type.Canvas2D)
</span><span class="lines">@@ -323,6 +366,7 @@
</span><span class="cx">         // WebGL
</span><span class="cx">         case "blendColor":
</span><span class="cx">         case "clearColor":
</span><ins>+        case "colorMask":
</ins><span class="cx">             return this._parameters;
</span><span class="cx"> 
</span><span class="cx">         // 2D (non-standard, legacy)
</span><span class="lines">@@ -348,6 +392,12 @@
</span><span class="cx">         // BitmapRenderer
</span><span class="cx">         case "transferFromImageBitmap":
</span><span class="cx">             return this._parameters.slice(0, 1);
</span><ins>+
+        // WebGL
+        case "texImage2D":
+        case "texSubImage2D":
+        case "compressedTexImage2D":
+            return [this._parameters.lastValue];
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         return [];
</span><span class="lines">@@ -366,6 +416,73 @@
</span><span class="cx">     ValidityChanged: "recording-action-marked-invalid",
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+WI.RecordingAction._constantIndexes = {
+    [WI.Recording.Type.CanvasWebGL]: {
+        "activeTexture": true,
+        "bindBuffer": true,
+        "bindFramebuffer": true,
+        "bindRenderbuffer": true,
+        "bindTexture": true,
+        "blendEquation": true,
+        "blendEquationSeparate": true,
+        "blendFunc": true,
+        "blendFuncSeparate": true,
+        "bufferData": [0, 2],
+        "bufferSubData": [0],
+        "checkFramebufferStatus": true,
+        "compressedTexImage2D": [0, 2],
+        "compressedTexSubImage2D": [0],
+        "copyTexImage2D": [0, 2],
+        "copyTexSubImage2D": [0],
+        "createShader": true,
+        "cullFace": true,
+        "depthFunc": true,
+        "disable": true,
+        "drawArrays": [0],
+        "drawElements": [0, 2],
+        "enable": true,
+        "framebufferRenderbuffer": true,
+        "framebufferTexture2D": [0, 1, 2],
+        "frontFace": true,
+        "generateMipmap": true,
+        "getBufferParameter": true,
+        "getFramebufferAttachmentParameter": true,
+        "getParameter": true,
+        "getProgramParameter": true,
+        "getRenderbufferParameter": true,
+        "getShaderParameter": true,
+        "getShaderPrecisionFormat": true,
+        "getTexParameter": true,
+        "getVertexAttrib": [1],
+        "getVertexAttribOffset": [1],
+        "hint": true,
+        "isEnabled": true,
+        "pixelStorei": [0],
+        "readPixels": [4, 5],
+        "renderbufferStorage": [0, 1],
+        "stencilFunc": [0],
+        "stencilFuncSeparate": [0, 1],
+        "stencilMaskSeparate": [0],
+        "stencilOp": true,
+        "stencilOpSeparate": true,
+        "texImage2D": {
+            5: [0, 2, 3, 4],
+            6: [0, 2, 3, 4],
+            8: [0, 2, 6, 7],
+            9: [0, 2, 6, 7],
+        },
+        "texParameterf": [0, 1],
+        "texParameteri": [0, 1],
+        "texSubImage2D": {
+            6: [0, 4, 5],
+            7: [0, 4, 5],
+            8: [0, 6, 7],
+            9: [0, 6, 7],
+        },
+        "vertexAttribPointer": [2],
+    },
+};
+
</ins><span class="cx"> WI.RecordingAction._visualNames = {
</span><span class="cx">     [WI.Recording.Type.Canvas2D]: new Set([
</span><span class="cx">         "clearRect",
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsRecordingActionTreeElementcss"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/RecordingActionTreeElement.css (236714 => 236715)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/RecordingActionTreeElement.css   2018-10-02 06:59:46 UTC (rev 236714)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/RecordingActionTreeElement.css      2018-10-02 08:00:37 UTC (rev 236715)
</span><span class="lines">@@ -61,6 +61,12 @@
</span><span class="cx">     color: var(--text-color-gray-medium);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.item.action > .titles .parameter.constant {
+    font-size: calc(100% - 1px);
+    font-family: Menlo, monospace;
+    font-style: italic;
+}
+
</ins><span class="cx"> body:not(.window-inactive, .window-docked-inactive) .tree-outline:matches(:focus, .force-focus) .item.action.selected > .titles .parameter.swizzled,
</span><span class="cx"> body:not(.window-inactive, .window-docked-inactive) .tree-outline:matches(:focus, .force-focus) .item.action.selected::before {
</span><span class="cx">     color: var(--selected-secondary-text-color);
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsRecordingActionTreeElementjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/RecordingActionTreeElement.js (236714 => 236715)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/RecordingActionTreeElement.js    2018-10-02 06:59:46 UTC (rev 236714)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/RecordingActionTreeElement.js       2018-10-02 08:00:37 UTC (rev 236715)
</span><span class="lines">@@ -45,13 +45,20 @@
</span><span class="cx"> 
</span><span class="cx">     static _generateDOM(recordingAction, recordingType)
</span><span class="cx">     {
</span><del>-        function createParameterElement(parameter, swizzleType) {
</del><ins>+        let parameterCount = recordingAction.parameters.length;
+
+        function createParameterElement(parameter, swizzleType, index) {
</ins><span class="cx">             let parameterElement = document.createElement("span");
</span><span class="cx">             parameterElement.classList.add("parameter");
</span><span class="cx"> 
</span><span class="cx">             switch (swizzleType) {
</span><span class="cx">             case WI.Recording.Swizzle.Number:
</span><del>-                parameterElement.textContent = parameter.maxDecimals(2);
</del><ins>+                var constantNameForParameter = WI.RecordingAction.constantNameForParameter(recordingType, recordingAction.name, parameter, index, parameterCount);
+                if (constantNameForParameter) {
+                    parameterElement.classList.add("constant");
+                    parameterElement.textContent = "context." + constantNameForParameter;
+                } else
+                    parameterElement.textContent = parameter.maxDecimals(2);
</ins><span class="cx">                 break;
</span><span class="cx"> 
</span><span class="cx">             case WI.Recording.Swizzle.Boolean:
</span><span class="lines">@@ -102,7 +109,7 @@
</span><span class="cx">         nameContainer.classList.add("name");
</span><span class="cx">         nameContainer.textContent = recordingAction.name;
</span><span class="cx"> 
</span><del>-        if (!recordingAction.parameters.length)
</del><ins>+        if (!parameterCount)
</ins><span class="cx">             return {titleFragment, copyText};
</span><span class="cx"> 
</span><span class="cx">         let parametersContainer = titleFragment.appendChild(document.createElement("span"));
</span><span class="lines">@@ -113,10 +120,10 @@
</span><span class="cx">         else
</span><span class="cx">             copyText += " = ";
</span><span class="cx"> 
</span><del>-        for (let i = 0; i < recordingAction.parameters.length; ++i) {
</del><ins>+        for (let i = 0; i < parameterCount; ++i) {
</ins><span class="cx">             let parameter = recordingAction.parameters[i];
</span><span class="cx">             let swizzleType = recordingAction.swizzleTypes[i];
</span><del>-            let parameterElement = createParameterElement(parameter, swizzleType);
</del><ins>+            let parameterElement = createParameterElement(parameter, swizzleType, i);
</ins><span class="cx">             parametersContainer.appendChild(parameterElement);
</span><span class="cx"> 
</span><span class="cx">             if (i)
</span></span></pre>
</div>
</div>

</body>
</html>