Changeset 218618 in webkit


Ignore:
Timestamp:
Jun 20, 2017 5:07:41 PM (7 years ago)
Author:
Devin Rousso
Message:

Web Inspector: Send context attributes for tracked canvases
https://bugs.webkit.org/show_bug.cgi?id=173327

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

  • inspector/protocol/Canvas.json:

Add ContextAttributes object type that is optionally used for WebGL canvases.

Source/WebCore:

Test: inspector/canvas/context-attributes.html

  • inspector/InspectorCanvasAgent.cpp:

(WebCore::InspectorCanvasAgent::buildObjectForCanvas):

Source/WebInspectorUI:

  • UserInterface/Models/Canvas.js:

(WebInspector.Canvas.fromPayload):
(WebInspector.Canvas.prototype.get contextAttributes):

  • UserInterface/Views/CanvasDetailsSidebarPanel.js:

(WebInspector.CanvasDetailsSidebarPanel.prototype.initialLayout):
(WebInspector.CanvasDetailsSidebarPanel.prototype.layout):
(WebInspector.CanvasDetailsSidebarPanel.prototype.sizeDidChange):
(WebInspector.CanvasDetailsSidebarPanel.prototype._refreshAttributesSection):

  • UserInterface/Views/DataGridNode.js:

(WebInspector.DataGridNode.prototype.createCellContent):
Instead of checking if the value of the cell is falsy, check that the key exists in the data.
This allows values like false to be displayed.

LayoutTests:

  • inspector/canvas/context-attributes-expected.txt: Added.
  • inspector/canvas/context-attributes.html: Added.
Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r218617 r218618  
     12017-06-20  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Send context attributes for tracked canvases
     4        https://bugs.webkit.org/show_bug.cgi?id=173327
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * inspector/canvas/context-attributes-expected.txt: Added.
     9        * inspector/canvas/context-attributes.html: Added.
     10
    1112017-06-20  Matt Lewis  <jlewis3@apple.com>
    212
  • trunk/Source/JavaScriptCore/ChangeLog

    r218594 r218618  
     12017-06-20  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Send context attributes for tracked canvases
     4        https://bugs.webkit.org/show_bug.cgi?id=173327
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * inspector/protocol/Canvas.json:
     9        Add ContextAttributes object type that is optionally used for WebGL canvases.
     10
    1112017-06-20  Konstantin Tokarev  <annulen@yandex.ru>
    212
  • trunk/Source/JavaScriptCore/inspector/protocol/Canvas.json

    r218544 r218618  
    1616        },
    1717        {
     18            "id": "ContextAttributes",
     19            "type": "object",
     20            "description": "WebGL drawing surface attributes.",
     21            "properties": [
     22                { "name": "alpha", "type": "boolean" },
     23                { "name": "depth", "type": "boolean" },
     24                { "name": "stencil", "type": "boolean" },
     25                { "name": "antialias", "type": "boolean" },
     26                { "name": "premultipliedAlpha", "type": "boolean" },
     27                { "name": "preserveDrawingBuffer", "type": "boolean" },
     28                { "name": "failIfMajorPerformanceCaveat", "type": "boolean" }
     29            ]
     30        },
     31        {
    1832            "id": "Canvas",
    1933            "type": "object",
     
    2438                { "name": "frameId", "$ref": "Network.FrameId", "description": "Parent frame identifier." },
    2539                { "name": "nodeId", "$ref": "DOM.NodeId", "optional": true, "description": "The corresponding DOM node id." },
    26                 { "name": "cssCanvasName", "type": "string", "optional": true, "description": "The CSS canvas identifier, for canvases created with <code>document.getCSSCanvasContext</code>." }
     40                { "name": "cssCanvasName", "type": "string", "optional": true, "description": "The CSS canvas identifier, for canvases created with <code>document.getCSSCanvasContext</code>." },
     41                { "name": "contextAttributes", "$ref": "ContextAttributes", "optional": true, "description": "Context attributes for WebGL rendering contexts." }
    2742            ]
    2843        }
  • trunk/Source/WebCore/ChangeLog

    r218616 r218618  
     12017-06-20  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Send context attributes for tracked canvases
     4        https://bugs.webkit.org/show_bug.cgi?id=173327
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        Test: inspector/canvas/context-attributes.html
     9
     10        * inspector/InspectorCanvasAgent.cpp:
     11        (WebCore::InspectorCanvasAgent::buildObjectForCanvas):
     12
    1132017-06-20  Myles C. Maxfield  <mmaxfield@apple.com>
    214
  • trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp

    r218544 r218618  
    3535#include "InstrumentingAgents.h"
    3636#include "MainFrame.h"
     37#include "WebGLContextAttributes.h"
     38#include "WebGLRenderingContextBase.h"
    3739#include <inspector/IdentifiersFactory.h>
    3840#include <inspector/InspectorProtocolObjects.h>
     
    278280    }
    279281
     282#if ENABLE(WEBGL)
     283    if (is<WebGLRenderingContextBase>(context)) {
     284        if (std::optional<WebGLContextAttributes> attributes = downcast<WebGLRenderingContextBase>(context)->getContextAttributes()) {
     285            canvas->setContextAttributes(Inspector::Protocol::Canvas::ContextAttributes::create()
     286                .setAlpha(attributes->alpha)
     287                .setDepth(attributes->depth)
     288                .setStencil(attributes->stencil)
     289                .setAntialias(attributes->antialias)
     290                .setPremultipliedAlpha(attributes->premultipliedAlpha)
     291                .setPreserveDrawingBuffer(attributes->preserveDrawingBuffer)
     292                .setFailIfMajorPerformanceCaveat(attributes->failIfMajorPerformanceCaveat)
     293                .release());
     294        }
     295    }
     296#endif
     297
    280298    return canvas;
    281299}
  • trunk/Source/WebInspectorUI/ChangeLog

    r218544 r218618  
     12017-06-20  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Send context attributes for tracked canvases
     4        https://bugs.webkit.org/show_bug.cgi?id=173327
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * UserInterface/Models/Canvas.js:
     9        (WebInspector.Canvas.fromPayload):
     10        (WebInspector.Canvas.prototype.get contextAttributes):
     11        * UserInterface/Views/CanvasDetailsSidebarPanel.js:
     12        (WebInspector.CanvasDetailsSidebarPanel.prototype.initialLayout):
     13        (WebInspector.CanvasDetailsSidebarPanel.prototype.layout):
     14        (WebInspector.CanvasDetailsSidebarPanel.prototype.sizeDidChange):
     15        (WebInspector.CanvasDetailsSidebarPanel.prototype._refreshAttributesSection):
     16
     17        * UserInterface/Views/DataGridNode.js:
     18        (WebInspector.DataGridNode.prototype.createCellContent):
     19        Instead of checking if the value of the cell is falsy, check that the key exists in the data.
     20        This allows values like `false` to be displayed.
     21
    1222017-06-19  Devin Rousso  <drousso@apple.com>
    223
  • trunk/Source/WebInspectorUI/UserInterface/Models/Canvas.js

    r218544 r218618  
    2626WebInspector.Canvas = class Canvas extends WebInspector.Object
    2727{
    28     constructor(identifier, contextType, frame, {domNode, cssCanvasName} = {})
     28    constructor(identifier, contextType, frame, {domNode, cssCanvasName, contextAttributes} = {})
    2929    {
    3030        super();
     
    3939        this._domNode = domNode || null;
    4040        this._cssCanvasName = cssCanvasName || "";
     41        this._contextAttributes = contextAttributes || {};
    4142    }
    4243
     
    6162            domNode: payload.nodeId ? WebInspector.domTreeManager.nodeForId(payload.nodeId) : null,
    6263            cssCanvasName: payload.cssCanvasName,
     64            contextAttributes: payload.contextAttributes,
    6365        });
    6466    }
     
    8789    get frame() { return this._frame; }
    8890    get cssCanvasName() { return this._cssCanvasName; }
     91    get contextAttributes() { return this._contextAttributes; }
    8992
    9093    get displayName()
  • trunk/Source/WebInspectorUI/UserInterface/Views/CanvasDetailsSidebarPanel.js

    r218544 r218618  
    9292        sourceSection.groups = [new WebInspector.DetailsSectionGroup([this._nodeRow, this._cssCanvasRow, this._widthRow, this._heightRow, this._datachedRow])];
    9393        this.contentView.element.appendChild(sourceSection.element);
     94
     95        this._attributesDataGridRow = new WebInspector.DetailsSectionDataGridRow(null, WebInspector.UIString("No Attributes"));
     96
     97        let attributesSection = new WebInspector.DetailsSection("canvas-attributes", WebInspector.UIString("Attributes"));
     98        attributesSection.groups = [new WebInspector.DetailsSectionGroup([this._attributesDataGridRow])];
     99        this.contentView.element.appendChild(attributesSection.element);
    94100    }
    95101
     
    103109        this._refreshIdentitySection();
    104110        this._refreshSourceSection();
     111        this._refreshAttributesSection();
     112    }
     113
     114    sizeDidChange()
     115    {
     116        super.sizeDidChange();
     117
     118        // FIXME: <https://webkit.org/b/152269> Web Inspector: Convert DetailsSection classes to use View
     119        this._attributesDataGridRow.sizeDidChange();
    105120    }
    106121
     
    186201        });
    187202    }
     203
     204    _refreshAttributesSection()
     205    {
     206        if (!this._canvas)
     207            return;
     208
     209        if (isEmptyObject(this._canvas.contextAttributes)) {
     210            // Remove the DataGrid to show the placeholder text.
     211            this._attributesDataGridRow.dataGrid = null;
     212            return;
     213        }
     214
     215        let dataGrid = this._attributesDataGridRow.dataGrid;
     216        if (!dataGrid) {
     217            dataGrid = this._attributesDataGridRow.dataGrid = new WebInspector.DataGrid({
     218                name: {title: WebInspector.UIString("Name")},
     219                value: {title: WebInspector.UIString("Value"), width: "30%"},
     220            });
     221        }
     222
     223        dataGrid.removeChildren();
     224
     225        for (let attribute in this._canvas.contextAttributes) {
     226            let data = {name: attribute, value: this._canvas.contextAttributes[attribute]};
     227            let dataGridNode = new WebInspector.DataGridNode(data);
     228            dataGrid.appendChild(dataGridNode);
     229        }
     230
     231        dataGrid.updateLayoutIfNeeded();
     232    }
    188233};
  • trunk/Source/WebInspectorUI/UserInterface/Views/DataGridNode.js

    r214405 r218618  
    384384    createCellContent(columnIdentifier)
    385385    {
     386        if (!(columnIdentifier in this.data))
     387            return zeroWidthSpace; // Zero width space to keep the cell from collapsing.
     388
    386389        let data = this.data[columnIdentifier];
    387         if (!data)
    388             return zeroWidthSpace; // Zero width space to keep the cell from collapsing.
    389 
    390390        return (typeof data === "number") ? data.maxDecimals(2).toLocaleString() : data;
    391391    }
Note: See TracChangeset for help on using the changeset viewer.