Title: [236715] trunk/Source/WebInspectorUI
Revision
236715
Author
drou...@apple.com
Date
2018-10-02 01:00:37 -0700 (Tue, 02 Oct 2018)

Log Message

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.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (236714 => 236715)


--- 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)
@@ -1,3 +1,26 @@
+2018-10-02  Devin Rousso  <drou...@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.
+
 2018-10-01  Joseph Pecoraro  <pecor...@apple.com>
 
         Web Inspector: Fix a typo for execution context identifier

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/RecordingAction.js (236714 => 236715)


--- 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)
@@ -87,6 +87,49 @@
         return typeof Object.getOwnPropertyDescriptor(prototype, name).value === "function";
     }
 
+    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;
+    }
+
     static _prototypeForType(type)
     {
         if (type === WI.Recording.Type.Canvas2D)
@@ -323,6 +366,7 @@
         // WebGL
         case "blendColor":
         case "clearColor":
+        case "colorMask":
             return this._parameters;
 
         // 2D (non-standard, legacy)
@@ -348,6 +392,12 @@
         // BitmapRenderer
         case "transferFromImageBitmap":
             return this._parameters.slice(0, 1);
+
+        // WebGL
+        case "texImage2D":
+        case "texSubImage2D":
+        case "compressedTexImage2D":
+            return [this._parameters.lastValue];
         }
 
         return [];
@@ -366,6 +416,73 @@
     ValidityChanged: "recording-action-marked-invalid",
 };
 
+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],
+    },
+};
+
 WI.RecordingAction._visualNames = {
     [WI.Recording.Type.Canvas2D]: new Set([
         "clearRect",

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/RecordingActionTreeElement.css (236714 => 236715)


--- 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)
@@ -61,6 +61,12 @@
     color: var(--text-color-gray-medium);
 }
 
+.item.action > .titles .parameter.constant {
+    font-size: calc(100% - 1px);
+    font-family: Menlo, monospace;
+    font-style: italic;
+}
+
 body:not(.window-inactive, .window-docked-inactive) .tree-outline:matches(:focus, .force-focus) .item.action.selected > .titles .parameter.swizzled,
 body:not(.window-inactive, .window-docked-inactive) .tree-outline:matches(:focus, .force-focus) .item.action.selected::before {
     color: var(--selected-secondary-text-color);

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/RecordingActionTreeElement.js (236714 => 236715)


--- 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)
@@ -45,13 +45,20 @@
 
     static _generateDOM(recordingAction, recordingType)
     {
-        function createParameterElement(parameter, swizzleType) {
+        let parameterCount = recordingAction.parameters.length;
+
+        function createParameterElement(parameter, swizzleType, index) {
             let parameterElement = document.createElement("span");
             parameterElement.classList.add("parameter");
 
             switch (swizzleType) {
             case WI.Recording.Swizzle.Number:
-                parameterElement.textContent = parameter.maxDecimals(2);
+                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);
                 break;
 
             case WI.Recording.Swizzle.Boolean:
@@ -102,7 +109,7 @@
         nameContainer.classList.add("name");
         nameContainer.textContent = recordingAction.name;
 
-        if (!recordingAction.parameters.length)
+        if (!parameterCount)
             return {titleFragment, copyText};
 
         let parametersContainer = titleFragment.appendChild(document.createElement("span"));
@@ -113,10 +120,10 @@
         else
             copyText += " = ";
 
-        for (let i = 0; i < recordingAction.parameters.length; ++i) {
+        for (let i = 0; i < parameterCount; ++i) {
             let parameter = recordingAction.parameters[i];
             let swizzleType = recordingAction.swizzleTypes[i];
-            let parameterElement = createParameterElement(parameter, swizzleType);
+            let parameterElement = createParameterElement(parameter, swizzleType, i);
             parametersContainer.appendChild(parameterElement);
 
             if (i)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to