Changeset 249776 in webkit


Ignore:
Timestamp:
Sep 11, 2019 2:10:11 PM (5 years ago)
Author:
Truitt Savell
Message:

Unreviewed, rolling out r249753.

caused inspector/canvas/shaderProgram-add-remove-webgl.html to
crash on all Mac platforms.

Reverted changeset:

"Web Inspector: Canvas: instrument WebGPUDevice instead of
GPUCanvasContext"
https://bugs.webkit.org/show_bug.cgi?id=201650
https://trac.webkit.org/changeset/249753

Location:
trunk
Files:
7 added
12 deleted
38 edited
1 copied
4 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r249768 r249776  
     12019-09-11  Truitt Savell  <tsavell@apple.com>
     2
     3        Unreviewed, rolling out r249753.
     4
     5        caused inspector/canvas/shaderProgram-add-remove-webgl.html to
     6        crash on all Mac platforms.
     7
     8        Reverted changeset:
     9
     10        "Web Inspector: Canvas: instrument WebGPUDevice instead of
     11        GPUCanvasContext"
     12        https://bugs.webkit.org/show_bug.cgi?id=201650
     13        https://trac.webkit.org/changeset/249753
     14
    1152019-09-11  Alex Christensen  <achristensen@webkit.org>
    216
  • trunk/LayoutTests/inspector/canvas/context-attributes-expected.txt

    r249753 r249776  
    3333  "premultipliedAlpha": true,
    3434  "preserveDrawingBuffer": false,
    35   "powerPreference": "default",
    3635  "failIfMajorPerformanceCaveat": false
    3736}
     
    4746  "premultipliedAlpha": true,
    4847  "preserveDrawingBuffer": false,
    49   "powerPreference": "default",
    5048  "failIfMajorPerformanceCaveat": false
    5149}
  • trunk/LayoutTests/inspector/canvas/create-context-webgpu-expected.txt

    r249753 r249776  
    66PASS: CanvasManager should have no canvases.
    77
    8 -- Running test case: Canvas.CreateContextWebGPU.Device
     8-- Running test case: Canvas.CreateContextWebGPU.Attached
    99PASS: Canvas context should be Web GPU.
     10  0: getContext - [native code]
     11  1: createAttachedCanvas - inspector/canvas/resources/create-context-utilities.js:4:36
     12  2: Global Code - [program code]
     13  3: evaluateWithScopeExtension - [native code]
     14  4: (anonymous function) - [native code]
     15  5: _wrapCall - [native code]
    1016
    1117PASS: Removed canvas has expected ID.
    1218
    13 -- Running test case: Canvas.CreateContextWebGPU.Canvas.Attached
    14 PASS: Inspector canvas should not be created for attached GPUCanvasContext without connected WebGPUDevice.
     19-- Running test case: Canvas.CreateContextWebGPU.Detached
     20PASS: Canvas context should be Web GPU.
     21  0: getContext - [native code]
     22  1: createDetachedCanvas - inspector/canvas/resources/create-context-utilities.js:11:62
     23  2: Global Code - [program code]
     24  3: evaluateWithScopeExtension - [native code]
     25  4: (anonymous function) - [native code]
     26  5: _wrapCall - [native code]
    1527
    16 -- Running test case: Canvas.CreateContextWebGPU.Canvas.Detached
    17 PASS: Inspector canvas should not be created for detached GPUCanvasContext without connected WebGPUDevice.
     28PASS: Removed canvas has expected ID.
    1829
    19 -- Running test case: Canvas.CreateContextWebGPU.Canvas.CSS
    20 PASS: Inspector canvas should not be created for CSS GPUCanvasContext without connected WebGPUDevice.
     30-- Running test case: Canvas.CreateContextWebGPU.CSSCanvas
     31Create CSS canvas from -webkit-canvas(css-canvas).
     32PASS: Canvas context should be Web GPU.
     33  0: getCSSCanvasContext - [native code]
     34  1: createCSSCanvas - inspector/canvas/resources/create-context-utilities.js:18:47
     35  2: Global Code - [program code]
     36  3: evaluateWithScopeExtension - [native code]
     37  4: (anonymous function) - [native code]
     38  5: _wrapCall - [native code]
    2139
     40PASS: Canvas name should equal the identifier passed to -webkit-canvas.
     41
  • trunk/LayoutTests/inspector/canvas/create-context-webgpu.html

    r249753 r249776  
    99    window.internals.settings.setWebGPUEnabled(true);
    1010
    11 function createDevice() {
    12     function receivedDevice(device) {
    13         window.contexts.push(device);
    14     }
     11function test() {
     12    InspectorTest.debug();
    1513
    16     function receivedAdapter(adapter) {
    17         adapter.requestDevice().then(receivedDevice);
    18     }
    19 
    20     navigator.gpu.requestAdapter().then(receivedAdapter);
    21 }
    22 
    23 function test() {
    2414    let suite = InspectorTest.CreateContextUtilities.initializeTestSuite("Canvas.CreateContextWebGPU");
    2515
    2616    InspectorTest.CreateContextUtilities.addSimpleTestCase({
    27         name: "Device",
    28         expression: `createDevice()`,
     17        name: "Attached",
     18        expression: `createAttachedCanvas("gpu")`,
    2919        contextType: WI.Canvas.ContextType.WebGPU,
    3020    });
    3121
    32     suite.addTestCase({
    33         name: "Canvas.CreateContextWebGPU.Canvas.Attached",
    34         description: "Ensure that attached GPUCanvasContext aren't tracked as a canvas, instead of the WebGPUDevice.",
    35         async test() {
    36             let created = false;
    37             let listener = WI.canvasManager.addEventListener(WI.CanvasManager.Event.CanvasAdded, (event) => {
    38                 InspectorTest.assert(event.target.contextType === WI.Canvas.ContextType.WebGPU);
    39                 created = true;
    40             });
    41 
    42             await InspectorTest.evaluateInPage(`createAttachedCanvas("gpu")`)
    43 
    44             WI.canvasManager.removeEventListener(WI.CanvasManager.Event.CanvasAdded, listener);
    45 
    46             InspectorTest.expectFalse(created, "Inspector canvas should not be created for attached GPUCanvasContext without connected WebGPUDevice.");
    47         },
     22    InspectorTest.CreateContextUtilities.addSimpleTestCase({
     23        name: "Detached",
     24        expression: `createDetachedCanvas("gpu")`,
     25        contextType: WI.Canvas.ContextType.WebGPU,
    4826    });
    4927
    50     suite.addTestCase({
    51         name: "Canvas.CreateContextWebGPU.Canvas.Detached",
    52         description: "Ensure that detached GPUCanvasContext aren't tracked as a canvas, instead of the WebGPUDevice.",
    53         async test() {
    54             let created = false;
    55             let listener = WI.canvasManager.addEventListener(WI.CanvasManager.Event.CanvasAdded, (event) => {
    56                 InspectorTest.assert(event.target.contextType === WI.Canvas.ContextType.WebGPU);
    57                 created = true;
    58             });
    59 
    60             await InspectorTest.evaluateInPage(`createDetachedCanvas("gpu")`)
    61 
    62             WI.canvasManager.removeEventListener(WI.CanvasManager.Event.CanvasAdded, listener);
    63 
    64             InspectorTest.expectFalse(created, "Inspector canvas should not be created for detached GPUCanvasContext without connected WebGPUDevice.");
    65         },
    66     });
    67 
    68     suite.addTestCase({
    69         name: "Canvas.CreateContextWebGPU.Canvas.CSS",
    70         description: "Ensure that CSS GPUCanvasContext aren't tracked as a canvas, instead of the WebGPUDevice.",
    71         async test() {
    72             let created = false;
    73             let listener = WI.canvasManager.addEventListener(WI.CanvasManager.Event.CanvasAdded, (event) => {
    74                 InspectorTest.assert(event.target.contextType === WI.Canvas.ContextType.WebGPU);
    75                 created = true;
    76             });
    77 
    78             await InspectorTest.evaluateInPage(`createCSSCanvas("gpu", "css-canvas")`)
    79 
    80             WI.canvasManager.removeEventListener(WI.CanvasManager.Event.CanvasAdded, listener);
    81 
    82             InspectorTest.expectFalse(created, "Inspector canvas should not be created for CSS GPUCanvasContext without connected WebGPUDevice.");
    83         },
    84     });
     28    InspectorTest.CreateContextUtilities.addCSSCanvasTestCase(WI.Canvas.ContextType.WebGPU);
    8529
    8630    suite.runTestCasesAndFinish();
  • trunk/LayoutTests/inspector/canvas/resolveCanvasContext-2d.html

    r249770 r249776  
    1212function test()
    1313{
    14     let suite = InspectorTest.createAsyncSuite("Canvas.resolveContext2D");
     14    let suite = InspectorTest.createAsyncSuite("Canvas.resolveCanvasContext2D");
    1515
    1616    suite.addTestCase({
    17         name: `Canvas.resolveContext2D.validIdentifier`,
     17        name: `Canvas.resolveCanvasContext2D.validIdentifier`,
    1818        description: "Should return a valid object for the given canvas identifier.",
    1919        test(resolve, reject) {
     
    2525
    2626            const objectGroup = "test";
    27             CanvasAgent.resolveContext(canvas.identifier, objectGroup)
     27            CanvasAgent.resolveCanvasContext(canvas.identifier, objectGroup)
    2828            .then(({object}) => {
    2929                InspectorTest.expectEqual(object.type, "object", `Payload should have type "object".`);
     
    3737
    3838    suite.addTestCase({
    39         name: "Canvas.resolveContext.invalidIdentifier",
     39        name: "Canvas.resolveCanvasContext.invalidIdentifier",
    4040        description: "Invalid canvas identifiers should cause an error.",
    4141        test(resolve, reject) {
    4242            const identifier = "DOES_NOT_EXIST";
    4343            const objectGroup = "test";
    44             CanvasAgent.resolveContext(identifier, objectGroup, (error) => {
     44            CanvasAgent.resolveCanvasContext(identifier, objectGroup, (error) => {
    4545                InspectorTest.expectThat(error, "Should produce an error.");
    4646                InspectorTest.log("Error: " + error);
     
    5555</head>
    5656<body onload="load()">
    57     <p>Tests for the Canvas.resolveContext command for 2D contexts.</p>
     57    <p>Tests for the Canvas.resolveCanvasContext command for 2D contexts.</p>
    5858</body>
    5959</html>
  • trunk/LayoutTests/inspector/canvas/resolveCanvasContext-bitmaprenderer.html

    r249770 r249776  
    1212function test()
    1313{
    14     let suite = InspectorTest.createAsyncSuite("Canvas.resolveContextBitmapRenderer");
     14    let suite = InspectorTest.createAsyncSuite("Canvas.resolveCanvasContextBitmapRenderer");
    1515
    1616    suite.addTestCase({
    17         name: `Canvas.resolveContextBitmapRenderer.validIdentifier`,
     17        name: `Canvas.resolveCanvasContextBitmapRenderer.validIdentifier`,
    1818        description: "Should return a valid object for the given canvas identifier.",
    1919        test(resolve, reject) {
     
    2525
    2626            const objectGroup = "test";
    27             CanvasAgent.resolveContext(canvas.identifier, objectGroup)
     27            CanvasAgent.resolveCanvasContext(canvas.identifier, objectGroup)
    2828            .then(({object}) => {
    2929                InspectorTest.expectEqual(object.type, "object", `Payload should have type "object".`);
     
    3939</head>
    4040<body onload="load()">
    41     <p>Tests for the Canvas.resolveContext command for BitmapRenderer contexts.</p>
     41    <p>Tests for the Canvas.resolveCanvasContext command for BitmapRenderer contexts.</p>
    4242</body>
    4343</html>
  • trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgl.html

    r249770 r249776  
    1212function test()
    1313{
    14     let suite = InspectorTest.createAsyncSuite("Canvas.resolveContextWebGL");
     14    let suite = InspectorTest.createAsyncSuite("Canvas.resolveCanvasContextWebGL");
    1515
    1616    suite.addTestCase({
    17         name: `Canvas.resolveContextWebGL.validIdentifier`,
     17        name: `Canvas.resolveCanvasContextWebGL.validIdentifier`,
    1818        description: "Should return a valid object for the given canvas identifier.",
    1919        test(resolve, reject) {
     
    2525
    2626            const objectGroup = "test";
    27             CanvasAgent.resolveContext(canvas.identifier, objectGroup)
     27            CanvasAgent.resolveCanvasContext(canvas.identifier, objectGroup)
    2828            .then(({object}) => {
    2929                InspectorTest.expectEqual(object.type, "object", `Payload should have type "object".`);
     
    3939</head>
    4040<body onload="load()">
    41     <p>Tests for the Canvas.resolveContext command for WebGL contexts.</p>
     41    <p>Tests for the Canvas.resolveCanvasContext command for WebGL contexts.</p>
    4242</body>
    4343</html>
  • trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgl2.html

    r249770 r249776  
    1515function test()
    1616{
    17     let suite = InspectorTest.createAsyncSuite("Canvas.resolveContextWebGL2");
     17    let suite = InspectorTest.createAsyncSuite("Canvas.resolveCanvasContextWebGL2");
    1818
    1919    suite.addTestCase({
    20         name: `Canvas.resolveContextWebGL2.validIdentifier`,
     20        name: `Canvas.resolveCanvasContextWebGL2.validIdentifier`,
    2121        description: "Should return a valid object for the given canvas identifier.",
    2222        test(resolve, reject) {
     
    2828
    2929            const objectGroup = "test";
    30             CanvasAgent.resolveContext(canvas.identifier, objectGroup)
     30            CanvasAgent.resolveCanvasContext(canvas.identifier, objectGroup)
    3131            .then(({object}) => {
    3232                InspectorTest.expectEqual(object.type, "object", `Payload should have type "object".`);
     
    4242</head>
    4343<body onload="load()">
    44     <p>Tests for the Canvas.resolveContext command for WebGL2 contexts.</p>
     44    <p>Tests for the Canvas.resolveCanvasContext command for WebGL2 contexts.</p>
    4545</body>
    4646</html>
  • trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgpu.html

    r249770 r249776  
    55<script>
    66if (window.internals)
    7     window.internals.settings.setWebGL2Enabled(true);
     7    window.internals.settings.setWebGPUEnabled(true);
    88
    99function load() {
    10     window.contextWebGL2 = document.body.appendChild(document.createElement("canvas")).getContext("webgl2");
     10    window.contextWebGPU = document.body.appendChild(document.createElement("canvas")).getContext("gpu");
    1111
    1212    runTest();
     
    1515function test()
    1616{
    17     let suite = InspectorTest.createAsyncSuite("Canvas.resolveContextWebGL2");
     17    let suite = InspectorTest.createAsyncSuite("Canvas.resolveCanvasContextWebGPU");
    1818
    1919    suite.addTestCase({
    20         name: `Canvas.resolveContextWebGL2.validIdentifier`,
     20        name: `Canvas.resolveCanvasContextWebGPU.validIdentifier`,
    2121        description: "Should return a valid object for the given canvas identifier.",
    2222        test(resolve, reject) {
    23             let canvas = WI.canvasManager.canvases.find((canvas) => canvas.contextType === WI.Canvas.ContextType.WebGL2);
     23            let canvas = WI.canvasManager.canvases.find((canvas) => canvas.contextType === WI.Canvas.ContextType.WebGPU);
    2424            if (!canvas) {
    2525                reject(`Missing Canvas.`);
     
    2828
    2929            const objectGroup = "test";
    30             CanvasAgent.resolveContext(canvas.identifier, objectGroup)
     30            CanvasAgent.resolveCanvasContext(canvas.identifier, objectGroup)
    3131            .then(({object}) => {
    3232                InspectorTest.expectEqual(object.type, "object", `Payload should have type "object".`);
    33                 InspectorTest.expectEqual(object.className, "WebGL2RenderingContext", `Payload should have className "WebGL2RenderingContext".`);
     33                InspectorTest.expectEqual(object.className, "GPUCanvasContext", `Payload should have className "GPUCanvasContext".`);
    3434            })
    3535            .then(resolve, reject);
     
    4242</head>
    4343<body onload="load()">
    44     <p>Tests for the Canvas.resolveContext command for WebGL2 contexts.</p>
     44    <p>Tests for the Canvas.resolveCanvasContext command for WebGPU contexts.</p>
    4545</body>
    4646</html>
  • trunk/LayoutTests/inspector/canvas/resources/create-context-utilities.js

    r249753 r249776  
    1 window.contexts = [];
     1let contexts = [];
    22
    33function createAttachedCanvas(contextType) {
     
    66    if (!context)
    77        TestPage.addResult("FAIL: missing context for type " + contextType);
    8     window.contexts.push(context);
     8    contexts.push(context);
    99}
    1010
     
    1313    if (!context)
    1414        TestPage.addResult("FAIL: missing context for type " + contextType);
    15     window.contexts.push(context);
     15    contexts.push(context);
    1616}
    1717
     
    2020    if (!context)
    2121        TestPage.addResult("FAIL: missing context for type " + contextType);
    22     window.contexts.push();
     22    contexts.push();
    2323}
    2424
    2525function destroyCanvases() {
    26     for (let context of window.contexts) {
     26    for (let context of contexts) {
    2727        if (!context)
    2828            continue;
     
    3333    }
    3434
    35     window.contexts = [];
     35    contexts = [];
    3636
    3737    // Force GC to make sure the canvas element is destroyed, otherwise the frontend
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r249760 r249776  
    517517webkit.org/b/166536 inspector/canvas/recording-webgl2-snapshots.html [ Skip ]
    518518webkit.org/b/166536 inspector/canvas/requestContent-webgl2.html [ Skip ]
    519 webkit.org/b/166536 inspector/canvas/resolveContext-webgl2.html [ Skip ]
     519webkit.org/b/166536 inspector/canvas/resolveCanvasContext-webgl2.html [ Skip ]
    520520webkit.org/b/166536 inspector/canvas/shaderProgram-add-remove-webgl2.html [ Skip ]
    521521webkit.org/b/166536 webgl/2.0.0/ [ Skip ]
     
    11511151webkit.org/b/191005 webgpu/ [ Skip ]
    11521152webkit.org/b/191005 inspector/canvas/create-context-webgpu.html [ Skip ]
    1153 webkit.org/b/191005 inspector/canvas/requestClientNodes-webgpu.html [ Skip ]
    1154 webkit.org/b/191005 inspector/canvas/resolveContext-webgpu.html [ Skip ]
     1153webkit.org/b/191005 inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ]
    11551154
    11561155# No support for resource load statistics yet
  • trunk/LayoutTests/platform/ios/TestExpectations

    r249753 r249776  
    4545webgpu [ Skip ]
    4646inspector/canvas/create-context-webgpu.html [ Skip ]
    47 inspector/canvas/requestClientNodes-webgpu.html [ Skip ]
    48 inspector/canvas/resolveContext-webgpu.html [ Skip ]
     47inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ]
    4948
    5049# Encrypted Media Extensions are not enabled
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r249760 r249776  
    4747webgpu [ Skip ]
    4848inspector/canvas/create-context-webgpu.html [ Skip ]
    49 inspector/canvas/requestClientNodes-webgpu.html [ Skip ]
    50 inspector/canvas/resolveContext-webgpu.html [ Skip ]
     49inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ]
    5150
    5251# Media Stream API testing is not supported for WK1 yet.
  • trunk/LayoutTests/platform/mac/TestExpectations

    r249753 r249776  
    10331033webkit.org/b/178028 inspector/canvas/create-context-2d.html [ Pass Timeout ]
    10341034webkit.org/b/174066 inspector/canvas/create-context-webgl2.html [ Pass Timeout ]
     1035webkit.org/b/174272 inspector/canvas/css-canvas-clients.html [ Pass Failure ]
    10351036webkit.org/b/174066 inspector/canvas/recording-webgl2-frameCount.html [ Pass Failure Timeout ]
    10361037webkit.org/b/174066 inspector/canvas/recording-webgl2-full.html [ Pass Failure Timeout ]
    10371038webkit.org/b/174066 inspector/canvas/recording-webgl2-memoryLimit.html [ Pass Failure Timeout ]
    10381039webkit.org/b/174066 inspector/canvas/recording-webgl2-snapshots.html [ Pass Failure Timeout ]
    1039 webkit.org/b/174272 inspector/canvas/requestClientNodes-css.html [ Pass Failure ]
    10401040webkit.org/b/174066 inspector/canvas/shaderProgram-add-remove-webgl2.html [ Pass Failure Timeout ]
    10411041webkit.org/b/160048 [ Debug ] inspector/codemirror/prettyprinting-javascript.html [ Pass Timeout ]
     
    17841784webkit.org/b/199275 [ HighSierra ] webgpu [ Skip ]
    17851785webkit.org/b/199275 [ HighSierra ] inspector/canvas/create-context-webgpu.html [ Skip ]
    1786 webkit.org/b/199275 [ HighSierra ] inspector/canvas/requestClientNodes-webgpu.html [ Skip ]
    1787 webkit.org/b/199275 [ HighSierra ] inspector/canvas/resolveContext-webgpu.html [ Skip ]
     1786webkit.org/b/199275 [ HighSierra ] inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ]
    17881787
    17891788webkit.org/b/189680 platform/mac/media/audio-session-category-video-paused.html [ Pass Timeout ]
  • trunk/LayoutTests/platform/win/TestExpectations

    r249753 r249776  
    20022002inspector/canvas/requestContent-webgl2.html [ Skip ]
    20032003inspector/canvas/requestShaderSource.html [ Skip ]
    2004 inspector/canvas/resolveContext-webgl.html [ Skip ]
    2005 inspector/canvas/resolveContext-webgl2.html [ Skip ]
     2004inspector/canvas/resolveCanvasContext-webgl.html [ Skip ]
     2005inspector/canvas/resolveCanvasContext-webgl2.html [ Skip ]
    20062006inspector/canvas/shaderProgram-add-remove-webgl.html [ Skip ]
    20072007inspector/canvas/shaderProgram-add-remove-webgl2.html [ Skip ]
     
    42454245webgpu [ Skip ]
    42464246inspector/canvas/create-context-webgpu.html [ Skip ]
    4247 inspector/canvas/requestClientNodes-webgpu.html [ Skip ]
    4248 inspector/canvas/resolveContext-webgpu.html [ Skip ]
     4247inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ]
    42494248
    42504249webkit.org/b/191194 fast/block/basic/inline-content-with-floating-image.html [ Failure ]
  • trunk/LayoutTests/platform/wincairo/TestExpectations

    r249753 r249776  
    290290inspector/canvas/recording-webgl2.html [ Skip ]
    291291inspector/canvas/recording-webgl2-snapshots.html [ Skip ]
    292 inspector/canvas/resolveContext-webgl2.html [ Skip ]
     292inspector/canvas/resolveCanvasContext-webgl2.html [ Skip ]
    293293inspector/canvas/shaderProgram-add-remove-webgl2.html [ Skip ]
    294294webgl/webgl2-rendering-context-defined.html [ Skip ]
     
    298298webgpu [ Skip ]
    299299inspector/canvas/create-context-webgpu.html [ Skip ]
    300 inspector/canvas/requestClientNodes-webgpu.html [ Skip ]
    301 inspector/canvas/resolveContext-webgpu.html [ Skip ]
     300inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ]
    302301
    303302# WIRELESS_PLAYBACK_TARGET is disabled
  • trunk/LayoutTests/platform/wpe/TestExpectations

    r249753 r249776  
    303303webgpu [ Skip ]
    304304inspector/canvas/create-context-webgpu.html [ Skip ]
    305 inspector/canvas/requestClientNodes-webgpu.html [ Skip ]
    306 inspector/canvas/resolveContext-webgpu.html [ Skip ]
     305inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ]
    307306
    308307# Skipped due to untestable DRM key system. ClearKey counterparts are tested instead.
  • trunk/Source/JavaScriptCore/ChangeLog

    r249753 r249776  
     12019-09-11  Truitt Savell  <tsavell@apple.com>
     2
     3        Unreviewed, rolling out r249753.
     4
     5        caused inspector/canvas/shaderProgram-add-remove-webgl.html to
     6        crash on all Mac platforms.
     7
     8        Reverted changeset:
     9
     10        "Web Inspector: Canvas: instrument WebGPUDevice instead of
     11        GPUCanvasContext"
     12        https://bugs.webkit.org/show_bug.cgi?id=201650
     13        https://trac.webkit.org/changeset/249753
     14
    1152019-09-10  Devin Rousso  <drousso@apple.com>
    216
  • trunk/Source/JavaScriptCore/inspector/protocol/Canvas.json

    r249753 r249776  
    3131            "description": "Drawing surface attributes.",
    3232            "properties": [
    33                 { "name": "alpha", "type": "boolean", "optional": true, "description": "WebGL, WebGL2, ImageBitmapRenderingContext" },
    34                 { "name": "depth", "type": "boolean", "optional": true, "description": "WebGL, WebGL2" },
    35                 { "name": "stencil", "type": "boolean", "optional": true, "description": "WebGL, WebGL2" },
    36                 { "name": "antialias", "type": "boolean", "optional": true, "description": "WebGL, WebGL2" },
    37                 { "name": "premultipliedAlpha", "type": "boolean", "optional": true, "description": "WebGL, WebGL2" },
    38                 { "name": "preserveDrawingBuffer", "type": "boolean", "optional": true, "description": "WebGL, WebGL2" },
    39                 { "name": "failIfMajorPerformanceCaveat", "type": "boolean", "optional": true, "description": "WebGL, WebGL2" },
    40                 { "name": "powerPreference", "type": "string", "optional": true, "description": "WebGL, WebGL2, WebGPU" }
     33                { "name": "alpha", "type": "boolean", "optional": true },
     34                { "name": "depth", "type": "boolean", "optional": true },
     35                { "name": "stencil", "type": "boolean", "optional": true },
     36                { "name": "antialias", "type": "boolean", "optional": true },
     37                { "name": "premultipliedAlpha", "type": "boolean", "optional": true },
     38                { "name": "preserveDrawingBuffer", "type": "boolean", "optional": true },
     39                { "name": "failIfMajorPerformanceCaveat", "type": "boolean", "optional": true }
    4140            ]
    4241        },
     
    8685        },
    8786        {
    88             "name": "requestClientNodes",
    89             "description": "Gets all <code>-webkit-canvas</code> nodes or active <code>HTMLCanvasElement</code> for a <code>WebGPUDevice</code>.",
     87            "name": "requestCSSCanvasClientNodes",
     88            "description": "Gets all the nodes that are using this canvas via -webkit-canvas.",
    9089            "parameters": [
    9190                { "name": "canvasId", "$ref": "CanvasId" }
     
    9695        },
    9796        {
    98             "name": "resolveContext",
    99             "description": "Resolves JavaScript canvas/device context object for given canvasId.",
     97            "name": "resolveCanvasContext",
     98            "description": "Resolves JavaScript canvas context object for given canvasId.",
    10099            "parameters": [
    101100                { "name": "canvasId", "$ref": "CanvasId", "description": "Canvas identifier." },
     
    194193        },
    195194        {
    196             "name": "clientNodesChanged",
     195            "name": "cssCanvasClientNodesChanged",
    197196            "parameters": [
    198197                { "name": "canvasId", "$ref": "CanvasId", "description": "Identifier of canvas that changed." }
  • trunk/Source/WebCore/ChangeLog

    r249770 r249776  
     12019-09-11  Truitt Savell  <tsavell@apple.com>
     2
     3        Unreviewed, rolling out r249753.
     4
     5        caused inspector/canvas/shaderProgram-add-remove-webgl.html to
     6        crash on all Mac platforms.
     7
     8        Reverted changeset:
     9
     10        "Web Inspector: Canvas: instrument WebGPUDevice instead of
     11        GPUCanvasContext"
     12        https://bugs.webkit.org/show_bug.cgi?id=201650
     13        https://trac.webkit.org/changeset/249753
     14
    1152019-09-11  Antti Koivisto  <antti@apple.com>
    216
  • trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.cpp

    r249753 r249776  
    4242    auto context = std::unique_ptr<GPUCanvasContext>(new GPUCanvasContext(canvas));
    4343    context->suspendIfNeeded();
     44
     45    InspectorInstrumentation::didCreateCanvasRenderingContext(*context);
     46
    4447    return context;
    4548}
     
    6568        if (m_swapChain)
    6669            m_swapChain->destroy();
    67 
    68         InspectorInstrumentation::willConfigureSwapChain(*this, newSwapChain.get());
    69 
     70       
    7071        m_swapChain = newSwapChain.copyRef();
    71 
    7272        notifyCanvasContentChanged();
    7373    }
  • trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.h

    r249753 r249776  
    4444    HTMLCanvasElement& canvas() const { return downcast<HTMLCanvasElement>(canvasBase()); }
    4545
    46     WebGPUSwapChain* swapChain() const { return m_swapChain.get(); }
    4746    Ref<WebGPUSwapChain> configureSwapChain(const WebGPUSwapChainDescriptor&);
    4847
  • trunk/Source/WebCore/Modules/webgpu/WebGPUAdapter.cpp

    r249753 r249776  
    3030
    3131#include "Document.h"
    32 #include "InspectorInstrumentation.h"
    3332#include "JSWebGPUDevice.h"
    3433
     
    4847{
    4948    document.postTask([protectedThis = makeRef(*this), promise = WTFMove(promise)] (ScriptExecutionContext& context) mutable {
    50         if (auto device = WebGPUDevice::tryCreate(context, protectedThis.get())) {
    51             InspectorInstrumentation::didCreateWebGPUDevice(*device);
    52 
     49        if (auto device = WebGPUDevice::tryCreate(context, protectedThis.get()))
    5350            promise.resolve(device.releaseNonNull());
    54         } else
     51        else
    5552            promise.reject();
    5653    });
  • trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp

    r249753 r249776  
    4848#include "GPUTextureDescriptor.h"
    4949#include "GPUUncapturedErrorEvent.h"
    50 #include "InspectorInstrumentation.h"
    5150#include "JSDOMConvertBufferSource.h"
    5251#include "JSGPUOutOfMemoryError.h"
     
    7574#include <JavaScriptCore/ConsoleMessage.h>
    7675#include <memory>
    77 #include <wtf/HashSet.h>
    7876#include <wtf/IsoMallocInlines.h>
    79 #include <wtf/Lock.h>
    8077#include <wtf/MainThread.h>
    81 #include <wtf/NeverDestroyed.h>
    8278#include <wtf/Optional.h>
    83 #include <wtf/Ref.h>
    84 #include <wtf/RefPtr.h>
    8579#include <wtf/Variant.h>
    86 #include <wtf/Vector.h>
    8780#include <wtf/text/WTFString.h>
    8881
     
    9689        return adoptRef(new WebGPUDevice(context, WTFMove(adapter), device.releaseNonNull()));
    9790    return nullptr;
    98 }
    99 
    100 HashSet<WebGPUDevice*>& WebGPUDevice::instances(const LockHolder&)
    101 {
    102     static NeverDestroyed<HashSet<WebGPUDevice*>> instances;
    103     return instances;
    104 }
    105 
    106 Lock& WebGPUDevice::instancesMutex()
    107 {
    108     static LazyNeverDestroyed<Lock> mutex;
    109     static std::once_flag initializeMutex;
    110     std::call_once(initializeMutex, [] {
    111         mutex.construct();
    112     });
    113     return mutex.get();
    11491}
    11592
     
    124101{
    125102    ASSERT(m_scriptExecutionContext.isDocument());
    126 
    127     LockHolder lock(instancesMutex());
    128     instances(lock).add(this);
    129 }
    130 
    131 WebGPUDevice::~WebGPUDevice()
    132 {
    133     InspectorInstrumentation::willDestroyWebGPUDevice(*this);
    134 
    135     LockHolder lock(instancesMutex());
    136     ASSERT(instances(lock).contains(this));
    137     instances(lock).remove(this);
    138103}
    139104
  • trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h

    r249753 r249776  
    3535#include "WebGPUQueue.h"
    3636#include "WebGPUSwapChainDescriptor.h"
    37 #include <wtf/Forward.h>
     37#include <wtf/Ref.h>
    3838#include <wtf/RefCounted.h>
     39#include <wtf/RefPtr.h>
     40#include <wtf/Vector.h>
    3941#include <wtf/WeakPtr.h>
    4042
     
    7981    WTF_MAKE_ISO_ALLOCATED(WebGPUDevice);
    8082public:
    81     virtual ~WebGPUDevice();
    82 
    8383    static RefPtr<WebGPUDevice> tryCreate(ScriptExecutionContext&, Ref<const WebGPUAdapter>&&);
    84 
    85     static HashSet<WebGPUDevice*>& instances(const LockHolder&);
    86     static Lock& instancesMutex();
    8784
    8885    const WebGPUAdapter& adapter() const { return m_adapter.get(); }
     
    110107    void popErrorScope(ErrorPromise&&);
    111108
    112     ScriptExecutionContext* scriptExecutionContext() const final { return &m_scriptExecutionContext; }
    113 
    114109    using RefCounted::ref;
    115110    using RefCounted::deref;
     
    120115    // EventTarget
    121116    EventTargetInterface eventTargetInterface() const final { return WebGPUDeviceEventTargetInterfaceType; }
     117    ScriptExecutionContext* scriptExecutionContext() const final { return &m_scriptExecutionContext; }
    122118    void refEventTarget() final { ref(); }
    123119    void derefEventTarget() final { deref(); }
  • trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.idl

    r249753 r249776  
    3030    Conditional=WEBGPU,
    3131    EnabledAtRuntime=WebGPU,
    32     InterfaceName=GPUDevice,
    33     JSGenerateToJSObject,
     32    InterfaceName=GPUDevice
    3433] interface WebGPUDevice : EventTarget {
    3534    readonly attribute WebGPUAdapter adapter;
  • trunk/Source/WebCore/inspector/InspectorCanvas.cpp

    r249753 r249776  
    3434#include "CanvasRenderingContext2D.h"
    3535#include "Document.h"
    36 #include "Element.h"
    3736#include "FloatPoint.h"
    3837#include "Gradient.h"
     
    5049#include "JSCanvasLineCap.h"
    5150#include "JSCanvasLineJoin.h"
    52 #include "JSCanvasRenderingContext2D.h"
    5351#include "JSCanvasTextAlign.h"
    5452#include "JSCanvasTextBaseline.h"
    5553#include "JSExecState.h"
    56 #include "JSImageBitmapRenderingContext.h"
    5754#include "JSImageSmoothingQuality.h"
    5855#include "Path2D.h"
     
    6158#include "SVGPathUtilities.h"
    6259#include "StringAdaptors.h"
     60#if ENABLE(CSS_TYPED_OM)
     61#include "TypedOMCSSImageValue.h"
     62#endif
     63#if ENABLE(WEBGL)
     64#include "WebGLRenderingContext.h"
     65#endif
     66#if ENABLE(WEBGL2)
     67#include "WebGL2RenderingContext.h"
     68#endif
     69#if ENABLE(WEBGPU)
     70#include "GPUCanvasContext.h"
     71#endif
    6372#include <JavaScriptCore/IdentifiersFactory.h>
    6473#include <JavaScriptCore/ScriptCallStackFactory.h>
    6574#include <wtf/Function.h>
    6675
    67 #if ENABLE(CSS_TYPED_OM)
    68 #include "TypedOMCSSImageValue.h"
    69 #endif
    70 
    71 #if ENABLE(WEBGL)
    72 #include "JSWebGLRenderingContext.h"
    73 #include "WebGLRenderingContext.h"
    74 #endif
    75 
    76 #if ENABLE(WEBGL2)
    77 #include "JSWebGL2RenderingContext.h"
    78 #include "WebGL2RenderingContext.h"
    79 #endif
    80 
    81 #if ENABLE(WEBGPU)
    82 #include "GPUCanvasContext.h"
    83 #include "JSWebGPUDevice.h"
    84 #include "WebGPUDevice.h"
    85 #endif
    86 
    8776namespace WebCore {
    8877
    8978using namespace Inspector;
    9079
    91 #if ENABLE(WEBGPU)
    92 static HTMLCanvasElement* canvasIfContextMatchesDevice(CanvasRenderingContext& context, WebGPUDevice& device)
    93 {
    94     if (is<GPUCanvasContext>(context)) {
    95         auto& contextGPU = downcast<GPUCanvasContext>(context);
    96         if (auto* webGPUSwapChain = contextGPU.swapChain()) {
    97             if (auto* gpuSwapChain = webGPUSwapChain->swapChain()) {
    98                 if (gpuSwapChain == device.device().swapChain()) {
    99                     if (is<HTMLCanvasElement>(contextGPU.canvasBase()))
    100                         return &downcast<HTMLCanvasElement>(contextGPU.canvasBase());
    101                 }
    102             }
    103         }
    104     }
    105     return nullptr;
    106 }
    107 #endif
    108 
    10980Ref<InspectorCanvas> InspectorCanvas::create(CanvasRenderingContext& context)
    11081{
    11182    return adoptRef(*new InspectorCanvas(context));
    11283}
    113 
    114 #if ENABLE(WEBGPU)
    115 Ref<InspectorCanvas> InspectorCanvas::create(WebGPUDevice& device)
    116 {
    117     return adoptRef(*new InspectorCanvas(device));
    118 }
    119 #endif
    12084
    12185InspectorCanvas::InspectorCanvas(CanvasRenderingContext& context)
     
    12387    , m_context(context)
    12488{
    125 #if ENABLE(WEBGPU)
    126     // The actual "context" for WebGPU is the `WebGPUDevice`, not the <canvas>.
    127     ASSERT(!is<GPUCanvasContext>(context));
    128 #endif
    129 }
    130 
    131 #if ENABLE(WEBGPU)
    132 InspectorCanvas::InspectorCanvas(WebGPUDevice& device)
    133     : m_identifier("canvas:" + IdentifiersFactory::createIdentifier())
    134     , m_context(device)
    135 {
    136 }
    137 #endif
    138 
    139 CanvasRenderingContext* InspectorCanvas::canvasContext() const
    140 {
    141     if (auto* contextWrapper = WTF::get_if<std::reference_wrapper<CanvasRenderingContext>>(m_context))
    142         return &contextWrapper->get();
     89}
     90
     91HTMLCanvasElement* InspectorCanvas::canvasElement()
     92{
     93    if (is<HTMLCanvasElement>(m_context.canvasBase()))
     94        return &downcast<HTMLCanvasElement>(m_context.canvasBase());
    14395    return nullptr;
    14496}
    14597
    146 HTMLCanvasElement* InspectorCanvas::canvasElement() const
    147 {
    148     return WTF::switchOn(m_context,
    149         [] (std::reference_wrapper<CanvasRenderingContext> contextWrapper) -> HTMLCanvasElement* {
    150             auto& context = contextWrapper.get();
    151             if (is<HTMLCanvasElement>(context.canvasBase()))
    152                 return &downcast<HTMLCanvasElement>(context.canvasBase());
    153             return nullptr;
    154         },
    155 #if ENABLE(WEBGPU)
    156         [&] (std::reference_wrapper<WebGPUDevice> deviceWrapper) -> HTMLCanvasElement* {
    157             auto& device = deviceWrapper.get();
    158             {
    159                 LockHolder lock(CanvasRenderingContext::instancesMutex());
    160                 for (auto* canvasRenderingContext : CanvasRenderingContext::instances(lock)) {
    161                     if (auto* canvasElement = canvasIfContextMatchesDevice(*canvasRenderingContext, device))
    162                         return canvasElement;
    163                 }
    164             }
    165             return nullptr;
    166         },
    167 #endif
    168         [] (Monostate) {
    169             ASSERT_NOT_REACHED();
    170             return nullptr;
    171         }
    172     );
    173     return nullptr;
    174 }
    175 
    176 #if ENABLE(WEBGPU)
    177 WebGPUDevice* InspectorCanvas::deviceContext() const
    178 {
    179     if (auto* deviceWrapper = WTF::get_if<std::reference_wrapper<WebGPUDevice>>(m_context))
    180         return &deviceWrapper->get();
    181     return nullptr;
    182 }
    183 
    184 bool InspectorCanvas::isDeviceForCanvasContext(CanvasRenderingContext& context) const
    185 {
    186     if (auto* device = deviceContext())
    187         return canvasIfContextMatchesDevice(context, *device);
    188     return false;
    189 }
    190 #endif
    191 
    192 ScriptExecutionContext* InspectorCanvas::scriptExecutionContext() const
    193 {
    194     return WTF::switchOn(m_context,
    195         [] (std::reference_wrapper<CanvasRenderingContext> contextWrapper) {
    196             auto& context = contextWrapper.get();
    197             return context.canvasBase().scriptExecutionContext();
    198         },
    199 #if ENABLE(WEBGPU)
    200         [] (std::reference_wrapper<WebGPUDevice> deviceWrapper) {
    201             auto& device = deviceWrapper.get();
    202             return device.scriptExecutionContext();
    203         },
    204 #endif
    205         [] (Monostate) {
    206             ASSERT_NOT_REACHED();
    207             return nullptr;
    208         }
    209     );
    210 }
    211 
    212 JSC::JSValue InspectorCanvas::resolveContext(ExecState* exec) const
    213 {
    214     JSC::JSLockHolder lock(exec);
    215 
    216     auto* globalObject = deprecatedGlobalObjectForPrototype(exec);
    217 
    218     return WTF::switchOn(m_context,
    219         [&] (std::reference_wrapper<CanvasRenderingContext> contextWrapper) {
    220             auto& context = contextWrapper.get();
    221             if (is<CanvasRenderingContext2D>(context))
    222                 return toJS(exec, globalObject, downcast<CanvasRenderingContext2D>(context));
    223             if (is<ImageBitmapRenderingContext>(context))
    224                 return toJS(exec, globalObject, downcast<ImageBitmapRenderingContext>(context));
    225 #if ENABLE(WEBGL)
    226             if (is<WebGLRenderingContext>(context))
    227                 return toJS(exec, globalObject, downcast<WebGLRenderingContext>(context));
    228 #endif
    229 #if ENABLE(WEBGL2)
    230             if (is<WebGL2RenderingContext>(context))
    231                 return toJS(exec, globalObject, downcast<WebGL2RenderingContext>(context));
    232 #endif
    233             return JSC::JSValue();
    234         },
    235 #if ENABLE(WEBGPU)
    236         [&] (std::reference_wrapper<WebGPUDevice> deviceWrapper) {
    237             return toJS(exec, globalObject, deviceWrapper.get());
    238         },
    239 #endif
    240         [] (Monostate) {
    241             ASSERT_NOT_REACHED();
    242             return JSC::JSValue();
    243         }
    244     );
    245 }
    246 
    247 HashSet<Element*> InspectorCanvas::clientNodes() const
    248 {
    249     return WTF::switchOn(m_context,
    250         [] (std::reference_wrapper<CanvasRenderingContext> contextWrapper) {
    251             auto& context = contextWrapper.get();
    252             return context.canvasBase().cssCanvasClients();
    253         },
    254 #if ENABLE(WEBGPU)
    255         [&] (std::reference_wrapper<WebGPUDevice> deviceWrapper) {
    256             auto& device = deviceWrapper.get();
    257 
    258             HashSet<Element*> canvasElementClients;
    259             {
    260                 LockHolder lock(CanvasRenderingContext::instancesMutex());
    261                 for (auto* canvasRenderingContext : CanvasRenderingContext::instances(lock)) {
    262                     if (auto* canvasElement = canvasIfContextMatchesDevice(*canvasRenderingContext, device))
    263                         canvasElementClients.add(canvasElement);
    264                 }
    265             }
    266             return canvasElementClients;
    267         },
    268 #endif
    269         [] (Monostate) {
    270             ASSERT_NOT_REACHED();
    271             return HashSet<Element*>();
    272         }
    273     );
    274 }
    275 
    27698void InspectorCanvas::canvasChanged()
    27799{
    278     auto* context = canvasContext();
    279     ASSERT(context);
    280 
    281     if (!context->callTracingActive())
     100    if (!m_context.callTracingActive())
    282101        return;
    283102
    284103    // Since 2D contexts are able to be fully reproduced in the frontend, we don't need snapshots.
    285     if (is<CanvasRenderingContext2D>(context))
     104    if (is<CanvasRenderingContext2D>(m_context))
    286105        return;
    287106
     
    303122    m_contentChanged = false;
    304123
    305     auto* context = canvasContext();
    306     ASSERT(context);
    307     // FIXME: <https://webkit.org/b/201651> Web Inspector: Canvas: support canvas recordings for WebGPUDevice
    308 
    309     context->setCallTracingActive(false);
     124    m_context.setCallTracingActive(false);
    310125}
    311126
     
    377192    m_currentActions->addItem(m_lastRecordedAction.get());
    378193
    379     auto* context = canvasContext();
    380     ASSERT(context);
    381     // FIXME: <https://webkit.org/b/201651> Web Inspector: Canvas: support canvas recordings for WebGPUDevice
    382 
    383     if (is<ImageBitmapRenderingContext>(context) && shouldSnapshotBitmapRendererAction(name))
     194    if (is<ImageBitmapRenderingContext>(m_context) && shouldSnapshotBitmapRendererAction(name))
    384195        m_contentChanged = true;
    385196#if ENABLE(WEBGL)
    386     else if (is<WebGLRenderingContext>(context) && shouldSnapshotWebGLAction(name))
     197    else if (is<WebGLRenderingContext>(m_context) && shouldSnapshotWebGLAction(name))
    387198        m_contentChanged = true;
    388199#endif
    389200#if ENABLE(WEBGL2)
    390     else if (is<WebGL2RenderingContext>(context) && shouldSnapshotWebGL2Action(name))
     201    else if (is<WebGL2RenderingContext>(m_context) && shouldSnapshotWebGL2Action(name))
    391202        m_contentChanged = true;
    392203#endif
     
    440251Ref<Inspector::Protocol::Canvas::Canvas> InspectorCanvas::buildObjectForCanvas(bool captureBacktrace)
    441252{
    442     using ContextTypeType = Optional<Inspector::Protocol::Canvas::ContextType>;
    443     auto contextType = WTF::switchOn(m_context,
    444         [] (std::reference_wrapper<CanvasRenderingContext> contextWrapper) -> ContextTypeType {
    445             auto& context = contextWrapper.get();
    446             if (is<CanvasRenderingContext2D>(context))
    447                 return Inspector::Protocol::Canvas::ContextType::Canvas2D;
    448             if (is<ImageBitmapRenderingContext>(context))
    449                 return Inspector::Protocol::Canvas::ContextType::BitmapRenderer;
    450 #if ENABLE(WEBGL)
    451             if (is<WebGLRenderingContext>(context))
    452                 return Inspector::Protocol::Canvas::ContextType::WebGL;
     253    Inspector::Protocol::Canvas::ContextType contextType;
     254    if (is<CanvasRenderingContext2D>(m_context))
     255        contextType = Inspector::Protocol::Canvas::ContextType::Canvas2D;
     256    else if (is<ImageBitmapRenderingContext>(m_context))
     257        contextType = Inspector::Protocol::Canvas::ContextType::BitmapRenderer;
     258#if ENABLE(WEBGL)
     259    else if (is<WebGLRenderingContext>(m_context))
     260        contextType = Inspector::Protocol::Canvas::ContextType::WebGL;
    453261#endif
    454262#if ENABLE(WEBGL2)
    455             if (is<WebGL2RenderingContext>(context))
    456                 return Inspector::Protocol::Canvas::ContextType::WebGL2;
    457 #endif
    458             return WTF::nullopt;
    459         },
     263    else if (is<WebGL2RenderingContext>(m_context))
     264        contextType = Inspector::Protocol::Canvas::ContextType::WebGL2;
     265#endif
    460266#if ENABLE(WEBGPU)
    461         [] (std::reference_wrapper<WebGPUDevice>) {
    462             return Inspector::Protocol::Canvas::ContextType::WebGPU;
    463         },
    464 #endif
    465         [] (Monostate) {
    466             ASSERT_NOT_REACHED();
    467             return WTF::nullopt;
    468         }
    469     );
    470     if (!contextType) {
     267    else if (is<GPUCanvasContext>(m_context))
     268        contextType = Inspector::Protocol::Canvas::ContextType::WebGPU;
     269#endif
     270    else {
    471271        ASSERT_NOT_REACHED();
    472272        contextType = Inspector::Protocol::Canvas::ContextType::Canvas2D;
     
    475275    auto canvas = Inspector::Protocol::Canvas::Canvas::create()
    476276        .setCanvasId(m_identifier)
    477         .setContextType(contextType.value())
     277        .setContextType(contextType)
    478278        .release();
    479279
     
    486286    }
    487287
    488     using ContextAttributesType = RefPtr<Inspector::Protocol::Canvas::ContextAttributes>;
    489     auto contextAttributes = WTF::switchOn(m_context,
    490         [] (std::reference_wrapper<CanvasRenderingContext> contextWrapper) -> ContextAttributesType {
    491             auto& context = contextWrapper.get();
    492             if (is<ImageBitmapRenderingContext>(context)) {
    493                 auto contextAttributesPayload = Inspector::Protocol::Canvas::ContextAttributes::create()
    494                     .release();
    495                 contextAttributesPayload->setAlpha(downcast<ImageBitmapRenderingContext>(context).hasAlpha());
    496                 return WTFMove(contextAttributesPayload);
    497             }
    498 
    499 #if ENABLE(WEBGL)
    500             if (is<WebGLRenderingContextBase>(context)) {
    501                 if (const auto& attributes = downcast<WebGLRenderingContextBase>(context).getContextAttributes()) {
    502                     auto contextAttributesPayload = Inspector::Protocol::Canvas::ContextAttributes::create()
    503                         .release();
    504                     contextAttributesPayload->setAlpha(attributes->alpha);
    505                     contextAttributesPayload->setDepth(attributes->depth);
    506                     contextAttributesPayload->setStencil(attributes->stencil);
    507                     contextAttributesPayload->setAntialias(attributes->antialias);
    508                     contextAttributesPayload->setPremultipliedAlpha(attributes->premultipliedAlpha);
    509                     contextAttributesPayload->setPreserveDrawingBuffer(attributes->preserveDrawingBuffer);
    510                     switch (attributes->powerPreference) {
    511                     case WebGLPowerPreference::Default:
    512                         contextAttributesPayload->setPowerPreference("default");
    513                         break;
    514                     case WebGLPowerPreference::LowPower:
    515                         contextAttributesPayload->setPowerPreference("low-power");
    516                         break;
    517                     case WebGLPowerPreference::HighPerformance:
    518                         contextAttributesPayload->setPowerPreference("high-performance");
    519                         break;
    520                     }
    521                     contextAttributesPayload->setFailIfMajorPerformanceCaveat(attributes->failIfMajorPerformanceCaveat);
    522                     return WTFMove(contextAttributesPayload);
    523                 }
    524             }
    525 #endif
    526             return nullptr;
    527         },
    528 #if ENABLE(WEBGPU)
    529         [] (std::reference_wrapper<WebGPUDevice> deviceWrapper) -> ContextAttributesType {
    530             auto& device = deviceWrapper.get();
    531             if (const auto& options = device.adapter().options()) {
    532                 auto contextAttributesPayload = Inspector::Protocol::Canvas::ContextAttributes::create()
    533                     .release();
    534                 if (const auto& powerPreference = options->powerPreference) {
    535                     switch (powerPreference.value()) {
    536                     case GPUPowerPreference::LowPower:
    537                         contextAttributesPayload->setPowerPreference("low-power");
    538                         break;
    539 
    540                     case GPUPowerPreference::HighPerformance:
    541                         contextAttributesPayload->setPowerPreference("high-performance");
    542                         break;
    543                     }
    544                 }
    545                 return WTFMove(contextAttributesPayload);
    546             }
    547             return nullptr;
    548         },
    549 #endif
    550         [] (Monostate) {
    551             ASSERT_NOT_REACHED();
    552             return nullptr;
     288    if (is<ImageBitmapRenderingContext>(m_context)) {
     289        auto contextAttributes = Inspector::Protocol::Canvas::ContextAttributes::create()
     290            .release();
     291        contextAttributes->setAlpha(downcast<ImageBitmapRenderingContext>(m_context).hasAlpha());
     292        canvas->setContextAttributes(WTFMove(contextAttributes));
     293    }
     294#if ENABLE(WEBGL)
     295    else if (is<WebGLRenderingContextBase>(m_context)) {
     296        if (Optional<WebGLContextAttributes> attributes = downcast<WebGLRenderingContextBase>(m_context).getContextAttributes()) {
     297            auto contextAttributes = Inspector::Protocol::Canvas::ContextAttributes::create()
     298                .release();
     299            contextAttributes->setAlpha(attributes->alpha);
     300            contextAttributes->setDepth(attributes->depth);
     301            contextAttributes->setStencil(attributes->stencil);
     302            contextAttributes->setAntialias(attributes->antialias);
     303            contextAttributes->setPremultipliedAlpha(attributes->premultipliedAlpha);
     304            contextAttributes->setPreserveDrawingBuffer(attributes->preserveDrawingBuffer);
     305            contextAttributes->setFailIfMajorPerformanceCaveat(attributes->failIfMajorPerformanceCaveat);
     306            canvas->setContextAttributes(WTFMove(contextAttributes));
    553307        }
    554     );
    555     if (contextAttributes)
    556         canvas->setContextAttributes(WTFMove(contextAttributes));
     308    }
     309#endif
    557310
    558311    // FIXME: <https://webkit.org/b/180833> Web Inspector: support OffscreenCanvas for Canvas related operations
     
    577330    ASSERT(!m_frames);
    578331
    579     auto* context = canvasContext();
    580     ASSERT(context);
    581     // FIXME: <https://webkit.org/b/201651> Web Inspector: Canvas: support canvas recordings for WebGPUDevice
    582 
    583332    Inspector::Protocol::Recording::Type type;
    584     if (is<CanvasRenderingContext2D>(context))
     333    if (is<CanvasRenderingContext2D>(m_context))
    585334        type = Inspector::Protocol::Recording::Type::Canvas2D;
    586     else if (is<ImageBitmapRenderingContext>(context))
     335    else if (is<ImageBitmapRenderingContext>(m_context))
    587336        type = Inspector::Protocol::Recording::Type::CanvasBitmapRenderer;
    588337#if ENABLE(WEBGL)
    589     else if (is<WebGLRenderingContext>(context))
     338    else if (is<WebGLRenderingContext>(m_context))
    590339        type = Inspector::Protocol::Recording::Type::CanvasWebGL;
    591340#endif
    592341#if ENABLE(WEBGL2)
    593     else if (is<WebGL2RenderingContext>(context))
     342    else if (is<WebGL2RenderingContext>(m_context))
    594343        type = Inspector::Protocol::Recording::Type::CanvasWebGL2;
    595344#endif
     
    616365String InspectorCanvas::getCanvasContentAsDataURL(ErrorString& errorString)
    617366{
     367    // FIXME: <https://webkit.org/b/173621> Web Inspector: Support getting the content of WebMetal context;
     368    if (!is<CanvasRenderingContext2D>(m_context)
     369#if ENABLE(WEBGL)
     370        && !is<WebGLRenderingContextBase>(m_context)
     371#endif
     372        && !is<ImageBitmapRenderingContext>(m_context)) {
     373        errorString = "Unsupported canvas context type"_s;
     374        return emptyString();
     375    }
     376
     377    // FIXME: <https://webkit.org/b/180833> Web Inspector: support OffscreenCanvas for Canvas related operations
    618378    auto* node = canvasElement();
    619379    if (!node) {
    620         errorString = "Missing HTMLCanvasElement of canvas for given canvasId"_s;
     380        errorString = "Context isn't related to an HTMLCanvasElement"_s;
    621381        return emptyString();
    622382    }
    623383
    624384#if ENABLE(WEBGL)
    625     auto* context = node->renderingContext();
    626     if (is<WebGLRenderingContextBase>(context))
    627         downcast<WebGLRenderingContextBase>(*context).setPreventBufferClearForInspector(true);
     385    if (is<WebGLRenderingContextBase>(m_context))
     386        downcast<WebGLRenderingContextBase>(m_context).setPreventBufferClearForInspector(true);
    628387#endif
    629388
     
    631390
    632391#if ENABLE(WEBGL)
    633     if (is<WebGLRenderingContextBase>(context))
    634         downcast<WebGLRenderingContextBase>(*context).setPreventBufferClearForInspector(false);
     392    if (is<WebGLRenderingContextBase>(m_context))
     393        downcast<WebGLRenderingContextBase>(m_context).setPreventBufferClearForInspector(false);
    635394#endif
    636395
     
    800559Ref<Inspector::Protocol::Recording::InitialState> InspectorCanvas::buildInitialState()
    801560{
    802     auto* context = canvasContext();
    803     ASSERT(context);
    804     // FIXME: <https://webkit.org/b/201651> Web Inspector: Canvas: support canvas recordings for WebGPUDevice
    805 
    806561    auto initialStatePayload = Inspector::Protocol::Recording::InitialState::create().release();
    807562
    808563    auto attributesPayload = JSON::Object::create();
    809     attributesPayload->setInteger("width"_s, context->canvasBase().width());
    810     attributesPayload->setInteger("height"_s, context->canvasBase().height());
     564    attributesPayload->setInteger("width"_s, m_context.canvasBase().width());
     565    attributesPayload->setInteger("height"_s, m_context.canvasBase().height());
    811566
    812567    auto statesPayload = JSON::ArrayOf<JSON::Object>::create();
     
    814569    auto parametersPayload = JSON::ArrayOf<JSON::Value>::create();
    815570
    816     if (is<CanvasRenderingContext2D>(context)) {
    817         auto& context2d = downcast<CanvasRenderingContext2D>(*context);
     571    if (is<CanvasRenderingContext2D>(m_context)) {
     572        auto& context2d = downcast<CanvasRenderingContext2D>(m_context);
    818573        for (auto& state : context2d.stateStack()) {
    819574            auto statePayload = JSON::Object::create();
     
    872627    }
    873628#if ENABLE(WEBGL)
    874     else if (is<WebGLRenderingContextBase>(context)) {
    875         auto& contextWebGLBase = downcast<WebGLRenderingContextBase>(*context);
     629    else if (is<WebGLRenderingContextBase>(m_context)) {
     630        WebGLRenderingContextBase& contextWebGLBase = downcast<WebGLRenderingContextBase>(m_context);
    876631        if (Optional<WebGLContextAttributes> webGLContextAttributes = contextWebGLBase.getContextAttributes()) {
    877632            auto webGLContextAttributesPayload = JSON::Object::create();
  • trunk/Source/WebCore/inspector/InspectorCanvas.h

    r249753 r249776  
    2727
    2828#include "CallTracerTypes.h"
    29 #include "CanvasRenderingContext.h"
    3029#include <JavaScriptCore/InspectorProtocolObjects.h>
    31 #include <JavaScriptCore/JSCInlines.h>
    3230#include <JavaScriptCore/ScriptCallFrame.h>
    3331#include <JavaScriptCore/ScriptCallStack.h>
    3432#include <initializer_list>
    35 #include <wtf/HashSet.h>
    3633#include <wtf/Variant.h>
    3734#include <wtf/Vector.h>
    3835#include <wtf/text/WTFString.h>
    39 
    40 #if ENABLE(WEBGPU)
    41 #include "WebGPUDevice.h"
    42 #endif
    4336
    4437namespace WebCore {
     
    4639class CanvasGradient;
    4740class CanvasPattern;
    48 class Element;
     41class CanvasRenderingContext;
    4942class HTMLCanvasElement;
    5043class HTMLImageElement;
     
    6154public:
    6255    static Ref<InspectorCanvas> create(CanvasRenderingContext&);
    63 #if ENABLE(WEBGPU)
    64     static Ref<InspectorCanvas> create(WebGPUDevice&);
    65 #endif
    6656
    67     const String& identifier() const { return m_identifier; }
     57    const String& identifier() { return m_identifier; }
     58    CanvasRenderingContext& context() { return m_context; }
    6859
    69     CanvasRenderingContext* canvasContext() const;
    70     HTMLCanvasElement* canvasElement() const;
    71 
    72 #if ENABLE(WEBGPU)
    73     WebGPUDevice* deviceContext() const;
    74     bool isDeviceForCanvasContext(CanvasRenderingContext&) const;
    75 #endif
    76 
    77     ScriptExecutionContext* scriptExecutionContext() const;
    78 
    79     JSC::JSValue resolveContext(JSC::ExecState*) const;
    80 
    81     HashSet<Element*> clientNodes() const;
     60    HTMLCanvasElement* canvasElement();
    8261
    8362    void canvasChanged();
     
    10988private:
    11089    InspectorCanvas(CanvasRenderingContext&);
    111 #if ENABLE(WEBGPU)
    112     InspectorCanvas(WebGPUDevice&);
    113 #endif
    114 
    11590    void appendActionSnapshotIfNeeded();
    11691
     
    142117
    143118    String m_identifier;
    144 
    145     Variant<
    146         std::reference_wrapper<CanvasRenderingContext>,
    147 #if ENABLE(WEBGPU)
    148         std::reference_wrapper<WebGPUDevice>,
    149 #endif
    150         Monostate
    151     > m_context;
     119    CanvasRenderingContext& m_context;
    152120
    153121    RefPtr<Inspector::Protocol::Recording::InitialState> m_initialState;
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r249753 r249776  
    7575#include <wtf/StdLibExtras.h>
    7676
    77 #if ENABLE(WEBGPU)
    78 #include "WebGPUSwapChain.h"
    79 #endif
    80 
    8177namespace WebCore {
    8278
     
    11071103#endif
    11081104
    1109 #if ENABLE(WEBGPU)
    1110 void InspectorInstrumentation::didCreateWebGPUDeviceImpl(InstrumentingAgents& instrumentingAgents, WebGPUDevice& device)
    1111 {
    1112     if (auto* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
    1113         canvasAgent->didCreateWebGPUDevice(device);
    1114 }
    1115 
    1116 void InspectorInstrumentation::willDestroyWebGPUDeviceImpl(InstrumentingAgents& instrumentingAgents, WebGPUDevice& device)
    1117 {
    1118     if (auto* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
    1119         canvasAgent->willDestroyWebGPUDevice(device);
    1120 }
    1121 
    1122 void InspectorInstrumentation::willConfigureSwapChainImpl(InstrumentingAgents& instrumentingAgents, GPUCanvasContext& contextGPU, WebGPUSwapChain& newSwapChain)
    1123 {
    1124     if (auto* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
    1125         canvasAgent->willConfigureSwapChain(contextGPU, newSwapChain);
    1126 }
    1127 #endif
    1128 
    11291105#if ENABLE(RESOURCE_USAGE)
    11301106void InspectorInstrumentation::didHandleMemoryPressureImpl(InstrumentingAgents& instrumentingAgents, Critical critical)
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r249753 r249776  
    6161#endif
    6262
    63 #if ENABLE(WEBGPU)
    64 #include "GPUCanvasContext.h"
    65 #include "WebGPUDevice.h"
    66 #endif
    67 
    6863namespace Inspector {
    6964class ConsoleMessage;
     
    9893class SharedBuffer;
    9994class TimerBase;
    100 class WebKitNamedFlow;
    101 class WorkerInspectorProxy;
    102 
    10395#if ENABLE(WEBGL)
    10496class WebGLProgram;
    10597#endif
    106 
    107 #if ENABLE(WEBGPU)
    108 class WebGPUSwapChain;
    109 #endif
     98class WebKitNamedFlow;
     99class WorkerInspectorProxy;
    110100
    111101enum class StorageType;
     
    295285    static bool isShaderProgramHighlighted(WebGLRenderingContextBase&, WebGLProgram&);
    296286#endif
    297 #if ENABLE(WEBGPU)
    298     static void didCreateWebGPUDevice(WebGPUDevice&);
    299     static void willDestroyWebGPUDevice(WebGPUDevice&);
    300     static void willConfigureSwapChain(GPUCanvasContext&, WebGPUSwapChain&);
    301 #endif
    302287
    303288    static void networkStateChanged(Page&);
     
    487472    static bool isShaderProgramHighlightedImpl(InstrumentingAgents&, WebGLProgram&);
    488473#endif
    489 #if ENABLE(WEBGPU)
    490     static void didCreateWebGPUDeviceImpl(InstrumentingAgents&, WebGPUDevice&);
    491     static void willDestroyWebGPUDeviceImpl(InstrumentingAgents&, WebGPUDevice&);
    492     static void willConfigureSwapChainImpl(InstrumentingAgents&, GPUCanvasContext&, WebGPUSwapChain&);
    493 #endif
    494474
    495475    static void layerTreeDidChangeImpl(InstrumentingAgents&);
     
    14161396#endif
    14171397
    1418 #if ENABLE(WEBGPU)
    1419 inline void InspectorInstrumentation::didCreateWebGPUDevice(WebGPUDevice& device)
    1420 {
    1421     FAST_RETURN_IF_NO_FRONTENDS(void());
    1422     if (auto* instrumentingAgents = instrumentingAgentsForContext(device.scriptExecutionContext()))
    1423         didCreateWebGPUDeviceImpl(*instrumentingAgents, device);
    1424 }
    1425 
    1426 inline void InspectorInstrumentation::willDestroyWebGPUDevice(WebGPUDevice& device)
    1427 {
    1428     FAST_RETURN_IF_NO_FRONTENDS(void());
    1429     if (auto* instrumentingAgents = instrumentingAgentsForContext(device.scriptExecutionContext()))
    1430         willDestroyWebGPUDeviceImpl(*instrumentingAgents, device);
    1431 }
    1432 
    1433 inline void InspectorInstrumentation::willConfigureSwapChain(GPUCanvasContext& contextGPU, WebGPUSwapChain& newSwapChain)
    1434 {
    1435     FAST_RETURN_IF_NO_FRONTENDS(void());
    1436     if (auto* instrumentingAgents = instrumentingAgentsForContext(contextGPU.canvasBase().scriptExecutionContext()))
    1437         willConfigureSwapChainImpl(*instrumentingAgents, contextGPU, newSwapChain);
    1438 }
    1439 #endif
    1440 
    14411398inline void InspectorInstrumentation::networkStateChanged(Page& page)
    14421399{
  • trunk/Source/WebCore/inspector/InspectorShaderProgram.cpp

    r249753 r249776  
    5656WebGLRenderingContextBase& InspectorShaderProgram::context() const
    5757{
    58     ASSERT(m_canvas.canvasContext());
    59     ASSERT(is<WebGLRenderingContextBase>(*m_canvas.canvasContext()));
    60     return downcast<WebGLRenderingContextBase>(*m_canvas.canvasContext());
     58    ASSERT(is<WebGLRenderingContextBase>(m_canvas.context()));
     59    return downcast<WebGLRenderingContextBase>(m_canvas.context());
    6160}
    6261
  • trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp

    r249753 r249776  
    3737#include "InspectorDOMAgent.h"
    3838#include "InstrumentingAgents.h"
     39#include "JSCanvasRenderingContext2D.h"
    3940#include "JSExecState.h"
     41#include "JSImageBitmapRenderingContext.h"
    4042#include "Microtasks.h"
    4143#include "OffscreenCanvas.h"
     
    5153
    5254#if ENABLE(WEBGL)
     55#include "JSWebGLRenderingContext.h"
    5356#include "WebGLProgram.h"
    54 #include "WebGLRenderingContext.h"
    55 #include "WebGLRenderingContextBase.h"
    5657#include "WebGLShader.h"
    5758#endif
    5859
    5960#if ENABLE(WEBGL2)
    60 #include "WebGL2RenderingContext.h"
     61#include "JSWebGL2RenderingContext.h"
    6162#endif
    6263
    6364#if ENABLE(WEBGPU)
    64 #include "GPUCanvasContext.h"
    65 #include "WebGPUDevice.h"
     65#include "JSGPUCanvasContext.h"
    6666#endif
    6767
     
    104104    m_instrumentingAgents.setInspectorCanvasAgent(this);
    105105
    106     const auto existsInCurrentPage = [&] (ScriptExecutionContext* scriptExecutionContext) {
     106    const auto canvasExistsInCurrentPage = [&] (CanvasRenderingContext* canvasRenderingContext) {
     107        if (!canvasRenderingContext)
     108            return false;
     109
     110        auto* scriptExecutionContext = canvasRenderingContext->canvasBase().scriptExecutionContext();
    107111        if (!is<Document>(scriptExecutionContext))
    108112            return false;
     
    115119    {
    116120        LockHolder lock(CanvasRenderingContext::instancesMutex());
    117         for (auto* context : CanvasRenderingContext::instances(lock)) {
    118 #if ENABLE(WEBGPU)
    119             // The actual "context" for WebGPU is the `WebGPUDevice`, not the <canvas>.
    120             if (is<GPUCanvasContext>(context))
    121                 continue;
    122 #endif
    123 
    124             if (existsInCurrentPage(context->canvasBase().scriptExecutionContext()))
    125                 bindCanvas(*context, false);
     121        for (auto* canvasRenderingContext : CanvasRenderingContext::instances(lock)) {
     122            if (canvasExistsInCurrentPage(canvasRenderingContext))
     123                bindCanvas(*canvasRenderingContext, false);
    126124        }
    127125    }
    128 
    129 #if ENABLE(WEBGPU)
    130     {
    131         LockHolder lock(WebGPUDevice::instancesMutex());
    132         for (auto* device : WebGPUDevice::instances(lock)) {
    133             if (existsInCurrentPage(device->scriptExecutionContext()))
    134                 bindCanvas(*device, false);
    135         }
    136     }
    137 #endif
    138126
    139127#if ENABLE(WEBGL)
    140128    {
    141129        LockHolder lock(WebGLProgram::instancesMutex());
    142         for (auto& [program, contextWebGLBase] : WebGLProgram::instances(lock)) {
    143             if (existsInCurrentPage(contextWebGLBase->canvasBase().scriptExecutionContext()))
    144                 didCreateProgram(*contextWebGLBase, *program);
     130        for (auto& entry : WebGLProgram::instances(lock)) {
     131            if (canvasExistsInCurrentPage(entry.value))
     132                didCreateProgram(*entry.value, *entry.key);
    145133        }
    146134    }
     
    187175}
    188176
    189 void InspectorCanvasAgent::requestClientNodes(ErrorString& errorString, const String& canvasId, RefPtr<JSON::ArrayOf<int>>& clientNodeIds)
    190 {
    191     auto* domAgent = m_instrumentingAgents.inspectorDOMAgent();
    192     if (!domAgent) {
    193         errorString = "DOM domain must be enabled"_s;
    194         return;
    195     }
    196 
     177void InspectorCanvasAgent::requestCSSCanvasClientNodes(ErrorString& errorString, const String& canvasId, RefPtr<JSON::ArrayOf<int>>& result)
     178{
    197179    auto inspectorCanvas = assertInspectorCanvas(errorString, canvasId);
    198180    if (!inspectorCanvas)
    199181        return;
    200182
    201     clientNodeIds = JSON::ArrayOf<int>::create();
    202     for (auto& clientNode : inspectorCanvas->clientNodes()) {
    203         if (auto documentNodeId = domAgent->boundNodeId(&clientNode->document()))
    204             clientNodeIds->addItem(domAgent->pushNodeToFrontend(errorString, documentNodeId, clientNode));
    205     }
    206 }
    207 
    208 void InspectorCanvasAgent::resolveContext(ErrorString& errorString, const String& canvasId, const String* objectGroup, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result)
     183    result = JSON::ArrayOf<int>::create();
     184    for (auto* client : inspectorCanvas->context().canvasBase().cssCanvasClients()) {
     185        if (int documentNodeId = m_instrumentingAgents.inspectorDOMAgent()->boundNodeId(&client->document()))
     186            result->addItem(m_instrumentingAgents.inspectorDOMAgent()->pushNodeToFrontend(errorString, documentNodeId, client));
     187    }
     188}
     189
     190static JSC::JSValue contextAsScriptValue(JSC::ExecState& state, CanvasRenderingContext& context)
     191{
     192    JSC::JSLockHolder lock(&state);
     193
     194    if (is<CanvasRenderingContext2D>(context))
     195        return toJS(&state, deprecatedGlobalObjectForPrototype(&state), downcast<CanvasRenderingContext2D>(context));
     196#if ENABLE(WEBGL)
     197    if (is<WebGLRenderingContext>(context))
     198        return toJS(&state, deprecatedGlobalObjectForPrototype(&state), downcast<WebGLRenderingContext>(context));
     199#endif
     200#if ENABLE(WEBGL2)
     201    if (is<WebGL2RenderingContext>(context))
     202        return toJS(&state, deprecatedGlobalObjectForPrototype(&state), downcast<WebGL2RenderingContext>(context));
     203#endif
     204#if ENABLE(WEBGPU)
     205    if (is<GPUCanvasContext>(context))
     206        return toJS(&state, deprecatedGlobalObjectForPrototype(&state), downcast<GPUCanvasContext>(context));
     207#endif
     208    if (is<ImageBitmapRenderingContext>(context))
     209        return toJS(&state, deprecatedGlobalObjectForPrototype(&state), downcast<ImageBitmapRenderingContext>(context));
     210
     211    return { };
     212}
     213
     214void InspectorCanvasAgent::resolveCanvasContext(ErrorString& errorString, const String& canvasId, const String* objectGroup, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result)
    209215{
    210216    auto inspectorCanvas = assertInspectorCanvas(errorString, canvasId);
     
    212218        return;
    213219
    214     auto* state = inspectorCanvas->scriptExecutionContext()->execState();
    215     auto injectedScript = m_injectedScriptManager.injectedScriptFor(state);
     220    auto& state = *inspectorCanvas->context().canvasBase().scriptExecutionContext()->execState();
     221    auto injectedScript = m_injectedScriptManager.injectedScriptFor(&state);
    216222    ASSERT(!injectedScript.hasNoValue());
    217223
    218     JSC::JSValue value = inspectorCanvas->resolveContext(state);
    219 
     224    JSC::JSValue value = contextAsScriptValue(state, inspectorCanvas->context());
    220225    if (!value) {
    221226        ASSERT_NOT_REACHED();
     
    242247        return;
    243248
    244     // FIXME: <https://webkit.org/b/201651> Web Inspector: Canvas: support canvas recordings for WebGPUDevice
    245 
    246     auto* context = inspectorCanvas->canvasContext();
    247     if (!context)
    248         return;
    249 
    250     if (context->callTracingActive()) {
     249    if (inspectorCanvas->context().callTracingActive()) {
    251250        errorString = "Already recording canvas"_s;
    252251        return;
     
    267266        return;
    268267
    269     // FIXME: <https://webkit.org/b/201651> Web Inspector: Canvas: support canvas recordings for WebGPUDevice
    270 
    271     auto* context = inspectorCanvas->canvasContext();
    272     if (!context)
    273         return;
    274 
    275     if (!context->callTracingActive()) {
     268    if (!inspectorCanvas->context().callTracingActive()) {
    276269        errorString = "Not recording canvas"_s;
    277270        return;
    278271    }
    279272
    280     didFinishRecordingCanvasFrame(*context, true);
     273    didFinishRecordingCanvasFrame(inspectorCanvas->context(), true);
    281274}
    282275
     
    379372    }
    380373
    381     for (auto* inspectorCanvas : inspectorCanvases)
    382         unbindCanvas(*inspectorCanvas);
     374    for (auto* inspectorCanvas : inspectorCanvases) {
     375        String identifier = unbindCanvas(*inspectorCanvas);
     376        m_frontendDispatcher->canvasRemoved(identifier);
     377    }
    383378}
    384379
     
    396391        return;
    397392
    398     m_frontendDispatcher->clientNodesChanged(inspectorCanvas->identifier());
     393    m_frontendDispatcher->cssCanvasClientNodesChanged(inspectorCanvas->identifier());
    399394}
    400395
     
    417412void InspectorCanvasAgent::didChangeCanvasMemory(CanvasRenderingContext& context)
    418413{
    419     RefPtr<InspectorCanvas> inspectorCanvas;
    420 
    421 #if ENABLE(WEBGPU)
    422     if (is<GPUCanvasContext>(context)) {
    423         for (auto& item : m_identifierToInspectorCanvas.values()) {
    424             if (item->isDeviceForCanvasContext(context)) {
    425                 inspectorCanvas = item;
    426                 break;
    427             }
    428         }
    429     }
    430 #endif
    431 
    432     if (!inspectorCanvas)
    433         inspectorCanvas = findInspectorCanvas(context);
    434 
     414    auto inspectorCanvas = findInspectorCanvas(context);
    435415    ASSERT(inspectorCanvas);
    436416    if (!inspectorCanvas)
     
    457437    // covered by the initial microtask until the next frame.
    458438    if (!inspectorCanvas->currentFrameHasData()) {
    459         if (auto* scriptExecutionContext = inspectorCanvas->scriptExecutionContext()) {
     439        if (auto* scriptExecutionContext = inspectorCanvas->context().canvasBase().scriptExecutionContext()) {
    460440            auto& queue = MicrotaskQueue::mainThreadQueue();
    461441            queue.append(makeUnique<ActiveDOMCallbackMicrotask>(queue, *scriptExecutionContext, [&, protectedInspectorCanvas = inspectorCanvas.copyRef()] {
     
    465445                }
    466446
    467                 if (canvasRenderingContext.callTracingActive())
    468                     didFinishRecordingCanvasFrame(canvasRenderingContext);
     447                if (protectedInspectorCanvas->context().callTracingActive())
     448                    didFinishRecordingCanvasFrame(protectedInspectorCanvas->context());
    469449            }));
    470450        }
     
    474454
    475455    if (!inspectorCanvas->hasBufferSpace())
    476         didFinishRecordingCanvasFrame(canvasRenderingContext, true);
     456        didFinishRecordingCanvasFrame(inspectorCanvas->context(), true);
    477457}
    478458
     
    502482        return;
    503483
    504     unbindCanvas(*inspectorCanvas);
     484    String identifier = unbindCanvas(*inspectorCanvas);
     485
     486    // WebCore::CanvasObserver::canvasDestroyed is called in response to the GC destroying the CanvasBase.
     487    // Due to the single-process model used in WebKit1, the event must be dispatched from a timer to prevent
     488    // the frontend from making JS allocations while the GC is still active.
     489    m_removedCanvasIdentifiers.append(identifier);
     490
     491    if (!m_canvasDestroyedTimer.isActive())
     492        m_canvasDestroyedTimer.startOneShot(0_s);
    505493}
    506494
    507495void InspectorCanvasAgent::didFinishRecordingCanvasFrame(CanvasRenderingContext& context, bool forceDispatch)
    508496{
    509     if (!context.callTracingActive())
    510         return;
    511 
    512497    auto inspectorCanvas = findInspectorCanvas(context);
    513498    ASSERT(inspectorCanvas);
    514499    if (!inspectorCanvas)
     500        return;
     501
     502    if (!inspectorCanvas->context().callTracingActive())
    515503        return;
    516504
     
    613601#endif
    614602
    615 #if ENABLE(WEBGPU)
    616 void InspectorCanvasAgent::didCreateWebGPUDevice(WebGPUDevice& device)
    617 {
    618     if (findInspectorCanvas(device)) {
    619         ASSERT_NOT_REACHED();
    620         return;
    621     }
    622 
    623     bindCanvas(device, true);
    624 }
    625 
    626 void InspectorCanvasAgent::willDestroyWebGPUDevice(WebGPUDevice& device)
    627 {
    628     auto inspectorCanvas = findInspectorCanvas(device);
    629     ASSERT(inspectorCanvas);
    630     if (!inspectorCanvas)
    631         return;
    632 
    633     unbindCanvas(*inspectorCanvas);
    634 }
    635 
    636 void InspectorCanvasAgent::willConfigureSwapChain(GPUCanvasContext& contextGPU, WebGPUSwapChain& newSwapChain)
    637 {
    638     auto notifyDeviceForSwapChain = [&] (WebGPUSwapChain& webGPUSwapChain) {
    639         for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values()) {
    640             if (auto* device = inspectorCanvas->deviceContext()) {
    641                 if (device->device().swapChain() == webGPUSwapChain.swapChain())
    642                     m_frontendDispatcher->clientNodesChanged(inspectorCanvas->identifier());
    643             }
    644         }
    645     };
    646 
    647     if (auto* existingSwapChain = contextGPU.swapChain())
    648         notifyDeviceForSwapChain(*existingSwapChain);
    649 
    650     notifyDeviceForSwapChain(newSwapChain);
    651 }
    652 #endif
    653 
    654603void InspectorCanvasAgent::startRecording(InspectorCanvas& inspectorCanvas, Inspector::Protocol::Recording::Initiator initiator, RecordingOptions&& recordingOptions)
    655604{
    656     auto* context = inspectorCanvas.canvasContext();
    657     ASSERT(context);
    658     // FIXME: <https://webkit.org/b/201651> Web Inspector: Canvas: support canvas recordings for WebGPUDevice
    659 
    660     if (!is<CanvasRenderingContext2D>(context)
    661         && !is<ImageBitmapRenderingContext>(context)
    662 #if ENABLE(WEBGL)
    663         && !is<WebGLRenderingContext>(context)
     605    auto& canvasRenderingContext = inspectorCanvas.context();
     606
     607    if (!is<CanvasRenderingContext2D>(canvasRenderingContext)
     608#if ENABLE(WEBGL)
     609        && !is<WebGLRenderingContext>(canvasRenderingContext)
    664610#endif
    665611#if ENABLE(WEBGL2)
    666         && !is<WebGL2RenderingContext>(context)
    667 #endif
    668     )
    669         return;
    670 
    671     if (context->callTracingActive())
     612        && !is<WebGL2RenderingContext>(canvasRenderingContext)
     613#endif
     614        && !is<ImageBitmapRenderingContext>(canvasRenderingContext))
     615        return;
     616
     617    if (canvasRenderingContext.callTracingActive())
    672618        return;
    673619
     
    679625    if (recordingOptions.name)
    680626        inspectorCanvas.setRecordingName(recordingOptions.name.value());
    681     context->setCallTracingActive(true);
     627    canvasRenderingContext.setCallTracingActive(true);
    682628
    683629    m_frontendDispatcher->recordingStarted(inspectorCanvas.identifier(), initiator);
     
    697643void InspectorCanvasAgent::clearCanvasData()
    698644{
    699     for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values()) {
    700         if (auto* context = inspectorCanvas->canvasContext())
    701             context->canvasBase().removeObserver(*this);
    702     }
     645    for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values())
     646        inspectorCanvas->context().canvasBase().removeObserver(*this);
    703647
    704648    m_identifierToInspectorCanvas.clear();
     
    717661    m_identifierToInspectorCanvas.set(inspectorCanvas->identifier(), inspectorCanvas.copyRef());
    718662
    719     context.canvasBase().addObserver(*this);
     663    inspectorCanvas->context().canvasBase().addObserver(*this);
    720664
    721665    m_frontendDispatcher->canvasAdded(inspectorCanvas->buildObjectForCanvas(captureBacktrace));
    722666
    723667#if ENABLE(WEBGL)
    724     if (is<WebGLRenderingContextBase>(context)) {
    725         auto& contextWebGL = downcast<WebGLRenderingContextBase>(context);
     668    if (is<WebGLRenderingContextBase>(inspectorCanvas->context())) {
     669        WebGLRenderingContextBase& contextWebGL = downcast<WebGLRenderingContextBase>(inspectorCanvas->context());
    726670        if (Optional<Vector<String>> extensions = contextWebGL.getSupportedExtensions()) {
    727671            for (const String& extension : *extensions) {
     
    736680}
    737681
    738 #if ENABLE(WEBGPU)
    739 InspectorCanvas& InspectorCanvasAgent::bindCanvas(WebGPUDevice& device, bool captureBacktrace)
    740 {
    741     auto inspectorCanvas = InspectorCanvas::create(device);
    742     m_identifierToInspectorCanvas.set(inspectorCanvas->identifier(), inspectorCanvas.copyRef());
    743 
    744     m_frontendDispatcher->canvasAdded(inspectorCanvas->buildObjectForCanvas(captureBacktrace));
    745 
    746     return inspectorCanvas;
    747 }
    748 #endif
    749 
    750 void InspectorCanvasAgent::unbindCanvas(InspectorCanvas& inspectorCanvas)
     682String InspectorCanvasAgent::unbindCanvas(InspectorCanvas& inspectorCanvas)
    751683{
    752684#if ENABLE(WEBGL)
     
    761693#endif
    762694
    763     if (auto* context = inspectorCanvas.canvasContext())
    764         context->canvasBase().removeObserver(*this);
     695    inspectorCanvas.context().canvasBase().removeObserver(*this);
    765696
    766697    String identifier = inspectorCanvas.identifier();
    767698    m_identifierToInspectorCanvas.remove(identifier);
    768699
    769     // This can be called in response to GC. Due to the single-process model used in WebKit1, the
    770     // event must be dispatched from a timer to prevent the frontend from making JS allocations
    771     // while the GC is still active.
    772     m_removedCanvasIdentifiers.append(identifier);
    773 
    774     if (!m_canvasDestroyedTimer.isActive())
    775         m_canvasDestroyedTimer.startOneShot(0_s);
     700    return identifier;
    776701}
    777702
     
    789714{
    790715    for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values()) {
    791         if (inspectorCanvas->canvasContext() == &context)
     716        if (&inspectorCanvas->context() == &context)
    792717            return inspectorCanvas;
    793718    }
    794719    return nullptr;
    795720}
    796 
    797 #if ENABLE(WEBGPU)
    798 RefPtr<InspectorCanvas> InspectorCanvasAgent::findInspectorCanvas(WebGPUDevice& device)
    799 {
    800     for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values()) {
    801         if (inspectorCanvas->deviceContext() == &device)
    802             return inspectorCanvas;
    803     }
    804     return nullptr;
    805 }
    806 #endif
    807721
    808722#if ENABLE(WEBGL)
  • trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.h

    r249753 r249776  
    5454class WebGLRenderingContextBase;
    5555#endif
    56 #if ENABLE(WEBGPU)
    57 class GPUCanvasContext;
    58 class WebGPUDevice;
    59 class WebGPUSwapChain;
    60 #endif
    6156
    6257typedef String ErrorString;
     
    7974    void requestNode(ErrorString&, const String& canvasId, int* nodeId);
    8075    void requestContent(ErrorString&, const String& canvasId, String* content);
    81     void requestClientNodes(ErrorString&, const String& canvasId, RefPtr<JSON::ArrayOf<int>>&);
    82     void resolveContext(ErrorString&, const String& canvasId, const String* objectGroup, RefPtr<Inspector::Protocol::Runtime::RemoteObject>&);
     76    void requestCSSCanvasClientNodes(ErrorString&, const String& canvasId, RefPtr<JSON::ArrayOf<int>>&);
     77    void resolveCanvasContext(ErrorString&, const String& canvasId, const String* objectGroup, RefPtr<Inspector::Protocol::Runtime::RemoteObject>&);
    8378    void setRecordingAutoCaptureFrameCount(ErrorString&, int count);
    8479    void startRecording(ErrorString&, const String& canvasId, const int* frameCount, const int* memoryLimit);
     
    9893    void didChangeCSSCanvasClientNodes(CanvasBase&);
    9994    void didCreateCanvasRenderingContext(CanvasRenderingContext&);
     95    void willDestroyCanvasRenderingContext(CanvasRenderingContext&);
    10096    void didChangeCanvasMemory(CanvasRenderingContext&);
    10197    void recordCanvasAction(CanvasRenderingContext&, const String&, std::initializer_list<RecordCanvasActionVariant>&& = { });
     
    108104    bool isShaderProgramDisabled(WebGLProgram&);
    109105    bool isShaderProgramHighlighted(WebGLProgram&);
    110 #endif
    111 #if ENABLE(WEBGPU)
    112     void didCreateWebGPUDevice(WebGPUDevice&);
    113     void willDestroyWebGPUDevice(WebGPUDevice&);
    114     void willConfigureSwapChain(GPUCanvasContext&, WebGPUSwapChain&);
    115106#endif
    116107
     
    126117    void clearCanvasData();
    127118    InspectorCanvas& bindCanvas(CanvasRenderingContext&, bool captureBacktrace);
    128 #if ENABLE(WEBGPU)
    129     InspectorCanvas& bindCanvas(WebGPUDevice&, bool captureBacktrace);
    130 #endif
    131     void unbindCanvas(InspectorCanvas&);
     119    String unbindCanvas(InspectorCanvas&);
    132120    RefPtr<InspectorCanvas> assertInspectorCanvas(ErrorString&, const String& canvasId);
    133121    RefPtr<InspectorCanvas> findInspectorCanvas(CanvasRenderingContext&);
    134 #if ENABLE(WEBGPU)
    135     RefPtr<InspectorCanvas> findInspectorCanvas(WebGPUDevice&);
    136 #endif
    137 
    138122#if ENABLE(WEBGL)
    139123    String unbindProgram(InspectorShaderProgram&);
  • trunk/Source/WebInspectorUI/ChangeLog

    r249753 r249776  
     12019-09-11  Truitt Savell  <tsavell@apple.com>
     2
     3        Unreviewed, rolling out r249753.
     4
     5        caused inspector/canvas/shaderProgram-add-remove-webgl.html to
     6        crash on all Mac platforms.
     7
     8        Reverted changeset:
     9
     10        "Web Inspector: Canvas: instrument WebGPUDevice instead of
     11        GPUCanvasContext"
     12        https://bugs.webkit.org/show_bug.cgi?id=201650
     13        https://trac.webkit.org/changeset/249753
     14
    1152019-09-10  Devin Rousso  <drousso@apple.com>
    216
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r249753 r249776  
    195195localizedStrings["CPU Usage"] = "CPU Usage";
    196196localizedStrings["CSP Hash"] = "CSP Hash";
     197localizedStrings["CSS"] = "CSS";
    197198localizedStrings["CSS Canvas"] = "CSS Canvas";
    198199localizedStrings["CSS Changes:"] = "CSS Changes:";
     
    246247localizedStrings["Click to view variable value\nShift-click to replace variable with value"] = "Click to view variable value\nShift-click to replace variable with value";
    247248localizedStrings["Clickable"] = "Clickable";
    248 localizedStrings["Clients"] = "Clients";
    249249localizedStrings["Close"] = "Close";
    250250localizedStrings["Close %s timeline view"] = "Close %s timeline view";
     
    346346localizedStrings["Detached"] = "Detached";
    347347localizedStrings["Details"] = "Details";
    348 localizedStrings["Device %d"] = "Device %d";
    349348localizedStrings["Device Settings"] = "Device Settings";
    350349localizedStrings["Diagnoses common accessibility problems affecting screen readers and other assistive technology."] = "Diagnoses common accessibility problems affecting screen readers and other assistive technology.";
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js

    r249753 r249776  
    185185    }
    186186
    187     clientNodesChanged(canvasIdentifier)
    188     {
    189         let canvas = this._canvasIdentifierMap.get(canvasIdentifier);
    190         console.assert(canvas);
    191         if (!canvas)
    192             return;
    193 
    194         canvas.clientNodesChanged();
     187    cssCanvasClientNodesChanged(canvasIdentifier)
     188    {
     189        let canvas = this._canvasIdentifierMap.get(canvasIdentifier);
     190        console.assert(canvas);
     191        if (!canvas)
     192            return;
     193
     194        canvas.cssCanvasClientNodesChanged();
    195195    }
    196196
  • trunk/Source/WebInspectorUI/UserInterface/Models/Canvas.js

    r249753 r249776  
    4242        this._backtrace = backtrace || [];
    4343
    44         this._clientNodes = null;
     44        this._cssCanvasClientNodes = null;
    4545        this._shaderProgramCollection = new WI.ShaderProgramCollection;
    4646        this._recordingCollection = new WI.RecordingCollection;
     
    114114    static resetUniqueDisplayNameNumbers()
    115115    {
    116         Canvas._nextContextUniqueDisplayNameNumber = 1;
    117         Canvas._nextDeviceUniqueDisplayNameNumber = 1;
     116        WI.Canvas._nextUniqueDisplayNameNumber = 1;
    118117    }
    119118
     
    162161        }
    163162
    164         if (this._contextType === Canvas.ContextType.WebGPU) {
    165             if (!this._uniqueDisplayNameNumber)
    166                 this._uniqueDisplayNameNumber = Canvas._nextDeviceUniqueDisplayNameNumber++;
    167             return WI.UIString("Device %d").format(this._uniqueDisplayNameNumber);
    168         }
    169 
    170163        if (!this._uniqueDisplayNameNumber)
    171             this._uniqueDisplayNameNumber = Canvas._nextContextUniqueDisplayNameNumber++;
     164            this._uniqueDisplayNameNumber = this.constructor._nextUniqueDisplayNameNumber++;
    172165        return WI.UIString("Canvas %d").format(this._uniqueDisplayNameNumber);
    173166    }
     
    179172                WI.domManager.ensureDocument();
    180173
    181                 CanvasAgent.requestNode(this._identifier, (error, nodeId) => {
    182                     if (error) {
    183                         resolve(null);
     174                CanvasAgent.requestNode(this._identifier).then((result) => {
     175                    this._domNode = WI.domManager.nodeForId(result.nodeId);
     176                    if (!this._domNode) {
     177                        reject(`No DOM node for identifier: ${result.nodeId}.`);
    184178                        return;
    185179                    }
    186 
    187                     this._domNode = WI.domManager.nodeForId(nodeId);
    188                     if (!this._domNode) {
    189                         resolve(null);
    190                         return;
    191                     }
    192 
    193180                    resolve(this._domNode);
    194                 });
     181                }).catch(reject);
    195182            });
    196183        }
     184
    197185        return this._requestNodePromise;
    198186    }
     
    203191    }
    204192
    205     requestClientNodes(callback)
    206     {
    207         if (this._clientNodes) {
    208             callback(this._clientNodes);
     193    requestCSSCanvasClientNodes(callback)
     194    {
     195        if (!this._cssCanvasName) {
     196            callback([]);
    209197            return;
    210198        }
    211199
     200        if (this._cssCanvasClientNodes) {
     201            callback(this._cssCanvasClientNodes);
     202            return;
     203        }
     204
    212205        WI.domManager.ensureDocument();
    213206
    214         let wrappedCallback = (error, clientNodeIds) => {
     207        CanvasAgent.requestCSSCanvasClientNodes(this._identifier, (error, clientNodeIds) => {
    215208            if (error) {
    216209                callback([]);
     
    219212
    220213            clientNodeIds = Array.isArray(clientNodeIds) ? clientNodeIds : [];
    221             this._clientNodes = clientNodeIds.map((clientNodeId) => WI.domManager.nodeForId(clientNodeId));
    222             callback(this._clientNodes);
    223         };
    224 
    225         // COMPATIBILITY (iOS 13): Canvas.requestCSSCanvasClientNodes was renamed to Canvas.requestClientNodes.
    226         if (!CanvasAgent.requestClientNodes) {
    227             CanvasAgent.requestCSSCanvasClientNodes(this._identifier, wrappedCallback);
    228             return;
    229         }
    230 
    231         CanvasAgent.requestClientNodes(this._identifier, wrappedCallback);
     214            this._cssCanvasClientNodes = clientNodeIds.map((clientNodeId) => WI.domManager.nodeForId(clientNodeId));
     215            callback(this._cssCanvasClientNodes);
     216        });
    232217    }
    233218
     
    261246
    262247        return this.requestNode().then((domNode) => {
    263             if (!domNode)
    264                 return null;
    265 
    266248            let size = calculateSize(domNode);
    267249            if (!isNaN(size.width) && !isNaN(size.height))
     
    346328    }
    347329
    348     clientNodesChanged()
     330    cssCanvasClientNodesChanged()
    349331    {
    350332        // Called from WI.CanvasManager.
    351333
    352         this._clientNodes = null;
    353 
    354         this.dispatchEventToListeners(Canvas.Event.ClientNodesChanged);
     334        if (!this._cssCanvasName)
     335            return;
     336
     337        this._cssCanvasClientNodes = null;
     338
     339        this.dispatchEventToListeners(WI.Canvas.Event.CSSCanvasClientNodesChanged);
    355340    }
    356341
     
    418403};
    419404
    420 WI.Canvas._nextContextUniqueDisplayNameNumber = 1;
    421 WI.Canvas._nextDeviceUniqueDisplayNameNumber = 1;
     405WI.Canvas._nextUniqueDisplayNameNumber = 1;
    422406
    423407WI.Canvas.FrameURLCookieKey = "canvas-frame-url";
     
    443427    MemoryChanged: "canvas-memory-changed",
    444428    ExtensionEnabled: "canvas-extension-enabled",
    445     ClientNodesChanged: "canvas-client-nodes-changed",
     429    CSSCanvasClientNodesChanged: "canvas-css-canvas-client-nodes-changed",
    446430    RecordingStarted: "canvas-recording-started",
    447431    RecordingProgress: "canvas-recording-progress",
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/CanvasObserver.js

    r249753 r249776  
    4343    }
    4444
    45     clientNodesChanged(canvasId)
     45    cssCanvasClientNodesChanged(canvasId)
    4646    {
    47         WI.canvasManager.clientNodesChanged(canvasId);
     47        WI.canvasManager.cssCanvasClientNodesChanged(canvasId);
    4848    }
    4949
     
    7777        WI.canvasManager.programDeleted(programId);
    7878    }
    79 
    80     // COMPATIBILITY (iOS 13): Canvas.events.cssCanvasClientNodesChanged was renamed to Canvas.events.clientNodesChanged.
    81     cssCanvasClientNodesChanged(canvasId)
    82     {
    83         WI.canvasManager.clientNodesChanged(canvasId);
    84     }
    8579};
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js

    r249753 r249776  
    164164        console.assert(typeof callback === "function");
    165165
    166         function wrapCallback(error, object) {
     166        CanvasAgent.resolveCanvasContext(canvas.identifier, objectGroup, (error, object) => {
    167167            if (error || !object)
    168168                callback(null);
    169169            else
    170170                callback(WI.RemoteObject.fromPayload(object, WI.mainTarget));
    171         }
    172 
    173         // COMPATIBILITY (iOS 13): Canvas.resolveCanvasContext was renamed to Canvas.resolveContext.
    174         if (!CanvasAgent.resolveContext) {
    175             CanvasAgent.resolveCanvasContext(canvas.identifier, objectGroup, wrapCallback);
    176             return;
    177         }
    178 
    179         CanvasAgent.resolveContext(canvas.identifier, objectGroup, wrapCallback);
     171        });
    180172    }
    181173
  • trunk/Source/WebInspectorUI/UserInterface/Views/CanvasContentView.js

    r249753 r249776  
    211211
    212212        this.representedObject.requestNode().then((node) => {
    213             if (!node)
    214                 return;
    215 
    216213            console.assert(!this._canvasNode || this._canvasNode === node);
    217214            if (this._canvasNode === node)
     
    285282        };
    286283
    287         this.representedObject.requestSize().then((size) => {
     284        this.representedObject.requestSize()
     285        .then((size) => {
    288286            updatePixelSize(size);
     287        })
     288        .catch((error) => {
     289            updatePixelSize(null);
    289290        });
    290291    }
  • trunk/Source/WebInspectorUI/UserInterface/Views/CanvasDetailsSidebarPanel.js

    r249753 r249776  
    7979            this._canvas.removeEventListener(WI.Canvas.Event.MemoryChanged, this._canvasMemoryChanged, this);
    8080            this._canvas.removeEventListener(WI.Canvas.Event.ExtensionEnabled, this._refreshExtensionsSection, this);
    81             this._canvas.removeEventListener(WI.Canvas.Event.ClientNodesChanged, this._refreshClientsSection, this);
     81            this._canvas.removeEventListener(WI.Canvas.Event.CSSCanvasClientNodesChanged, this._refreshCSSCanvasSection, this);
    8282        }
    8383
     
    8787            this._canvas.addEventListener(WI.Canvas.Event.MemoryChanged, this._canvasMemoryChanged, this);
    8888            this._canvas.addEventListener(WI.Canvas.Event.ExtensionEnabled, this._refreshExtensionsSection, this);
    89             this._canvas.addEventListener(WI.Canvas.Event.ClientNodesChanged, this._refreshClientsSection, this);
     89            this._canvas.addEventListener(WI.Canvas.Event.CSSCanvasClientNodesChanged, this._refreshCSSCanvasSection, this);
    9090        }
    9191
     
    112112        this._widthRow = new WI.DetailsSectionSimpleRow(WI.UIString("Width"));
    113113        this._heightRow = new WI.DetailsSectionSimpleRow(WI.UIString("Height"));
    114         this._detachedRow = new WI.DetailsSectionSimpleRow(WI.UIString("Detached"));
     114        this._datachedRow = new WI.DetailsSectionSimpleRow(WI.UIString("Detached"));
    115115
    116116        let sourceSection = new WI.DetailsSection("canvas-source", WI.UIString("Source"));
    117         sourceSection.groups = [new WI.DetailsSectionGroup([this._nodeRow, this._cssCanvasRow, this._widthRow, this._heightRow, this._detachedRow])];
     117        sourceSection.groups = [new WI.DetailsSectionGroup([this._nodeRow, this._cssCanvasRow, this._widthRow, this._heightRow, this._datachedRow])];
    118118        this._sections.push(sourceSection);
    119119
     
    129129        this._sections.push(this._extensionsSection);
    130130
    131         this._clientNodesRow = new WI.DetailsSectionSimpleRow(WI.UIString("Nodes"));
    132 
    133         this._clientsSection = new WI.DetailsSection("canvas-clients", WI.UIString("Clients"));
    134         this._clientsSection.groups = [new WI.DetailsSectionGroup([this._clientNodesRow])];
    135         this._clientsSection.element.hidden = true;
    136         this._sections.push(this._clientsSection);
     131        this._cssCanvasClientsRow = new WI.DetailsSectionSimpleRow(WI.UIString("Nodes"));
     132
     133        this._cssCanvasSection = new WI.DetailsSection("canvas-css", WI.UIString("CSS"));
     134        this._cssCanvasSection.groups = [new WI.DetailsSectionGroup([this._cssCanvasClientsRow])];
     135        this._cssCanvasSection.element.hidden = true;
     136        this._sections.push(this._cssCanvasSection);
    137137
    138138        const selectable = false;
     
    169169        this._refreshAttributesSection();
    170170        this._refreshExtensionsSection();
    171         this._refreshClientsSection();
     171        this._refreshCSSCanvasSection();
    172172        this._refreshBacktraceSection();
    173173    }
     
    195195            return;
    196196
    197         let hideNode = this._canvas.cssCanvasName || this._canvas.contextType === WI.Canvas.ContextType.WebGPU;
    198 
    199         this._nodeRow.value = hideNode ? null : emDash;
     197        this._nodeRow.value = this._canvas.cssCanvasName ? null : emDash;
    200198        this._cssCanvasRow.value = this._canvas.cssCanvasName || null;
    201199        this._widthRow.value = emDash;
    202200        this._heightRow.value = emDash;
    203         this._detachedRow.value = null;
     201        this._datachedRow.value = null;
    204202
    205203        this._canvas.requestNode().then((node) => {
    206             if (!node) {
    207                 this._nodeRow.value = null;
    208                 return;
    209             }
    210 
    211204            if (node !== this._node) {
    212205                if (this._node) {
     
    223216            }
    224217
    225             if (!hideNode) {
     218            if (!this._canvas.cssCanvasName)
    226219                this._nodeRow.value = WI.linkifyNodeReference(this._node);
    227 
    228                 if (!this._node.parentNode)
    229                     this._detachedRow.value = WI.UIString("Yes");
    230             }
    231220
    232221            let setRowValueIfValidAttributeValue = (row, attribute) => {
     
    260249                });
    261250            }
     251
     252            if (!this._canvas.cssCanvasName && !this._node.parentNode)
     253                this._datachedRow.value = WI.UIString("Yes");
    262254        });
    263255    }
     
    304296    }
    305297
    306     _refreshClientsSection()
     298    _refreshCSSCanvasSection()
    307299    {
    308300        if (!this.didInitialLayout)
    309301            return;
    310302
    311         if (!this._canvas.cssCanvasName && this._canvas.contextType !== WI.Canvas.ContextType.WebGPU) {
    312             this._clientsSection.element.hidden = true;
    313             return;
    314         }
    315 
    316         this._clientNodesRow.value = emDash;
    317 
    318         this._clientsSection.element.hidden = false;
    319 
    320         this._canvas.requestClientNodes((clientNodes) => {
    321             if (!clientNodes.length)
     303        if (!this._canvas.cssCanvasName) {
     304            this._cssCanvasSection.element.hidden = true;
     305            return;
     306        }
     307
     308        this._cssCanvasClientsRow.value = emDash;
     309
     310        this._cssCanvasSection.element.hidden = false;
     311
     312        this._canvas.requestCSSCanvasClientNodes((cssCanvasClientNodes) => {
     313            if (!cssCanvasClientNodes.length)
    322314                return;
    323315
    324316            let fragment = document.createDocumentFragment();
    325             for (let clientNode of clientNodes)
     317            for (let clientNode of cssCanvasClientNodes)
    326318                fragment.appendChild(WI.linkifyNodeReference(clientNode));
    327             this._clientNodesRow.value = fragment;
     319            this._cssCanvasClientsRow.value = fragment;
    328320        });
    329321    }
  • trunk/Source/WebInspectorUI/UserInterface/Views/CanvasOverviewContentView.js

    r249753 r249776  
    192192
    193193        let canvas = contentView.representedObject;
    194         if (canvas.cssCanvasName || canvas.contextType === WI.Canvas.ContextType.WebGPU) {
    195             canvas.requestClientNodes((clientNodes) => {
    196                 WI.domManager.highlightDOMNodeList(clientNodes.map((node) => node.id));
     194        if (canvas.cssCanvasName) {
     195            canvas.requestCSSCanvasClientNodes((cssCanvasClientNodes) => {
     196                WI.domManager.highlightDOMNodeList(cssCanvasClientNodes.map((node) => node.id));
    197197            });
    198198            return;
  • trunk/Source/WebInspectorUI/UserInterface/Views/CanvasTreeElement.js

    r249753 r249776  
    116116    _handleMouseOver(event)
    117117    {
    118         if (this.representedObject.cssCanvasName || this.representedObject.contextType === WI.Canvas.ContextType.WebGPU) {
    119             this.representedObject.requestClientNodes((clientNodes) => {
    120                 WI.domManager.highlightDOMNodeList(clientNodes.map((node) => node.id));
     118        if (this.representedObject.cssCanvasName) {
     119            this.representedObject.requestCSSCanvasClientNodes((cssCanvasClientNodes) => {
     120                WI.domManager.highlightDOMNodeList(cssCanvasClientNodes.map((node) => node.id), "all");
    121121            });
    122122        } else {
     
    125125                    return;
    126126
    127                 WI.domManager.highlightDOMNode(node.id);
     127                WI.domManager.highlightDOMNode(node.id, "all");
    128128            });
    129129        }
Note: See TracChangeset for help on using the changeset viewer.