Changeset 249776 in webkit
- Timestamp:
- Sep 11, 2019 2:10:11 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 7 added
- 12 deleted
- 38 edited
- 1 copied
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r249768 r249776 1 2019-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 1 15 2019-09-11 Alex Christensen <achristensen@webkit.org> 2 16 -
trunk/LayoutTests/inspector/canvas/context-attributes-expected.txt
r249753 r249776 33 33 "premultipliedAlpha": true, 34 34 "preserveDrawingBuffer": false, 35 "powerPreference": "default",36 35 "failIfMajorPerformanceCaveat": false 37 36 } … … 47 46 "premultipliedAlpha": true, 48 47 "preserveDrawingBuffer": false, 49 "powerPreference": "default",50 48 "failIfMajorPerformanceCaveat": false 51 49 } -
trunk/LayoutTests/inspector/canvas/create-context-webgpu-expected.txt
r249753 r249776 6 6 PASS: CanvasManager should have no canvases. 7 7 8 -- Running test case: Canvas.CreateContextWebGPU. Device8 -- Running test case: Canvas.CreateContextWebGPU.Attached 9 9 PASS: 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] 10 16 11 17 PASS: Removed canvas has expected ID. 12 18 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 20 PASS: 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] 15 27 16 -- Running test case: Canvas.CreateContextWebGPU.Canvas.Detached 17 PASS: Inspector canvas should not be created for detached GPUCanvasContext without connected WebGPUDevice. 28 PASS: Removed canvas has expected ID. 18 29 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 31 Create CSS canvas from -webkit-canvas(css-canvas). 32 PASS: 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] 21 39 40 PASS: Canvas name should equal the identifier passed to -webkit-canvas. 41 -
trunk/LayoutTests/inspector/canvas/create-context-webgpu.html
r249753 r249776 9 9 window.internals.settings.setWebGPUEnabled(true); 10 10 11 function createDevice() { 12 function receivedDevice(device) { 13 window.contexts.push(device); 14 } 11 function test() { 12 InspectorTest.debug(); 15 13 16 function receivedAdapter(adapter) {17 adapter.requestDevice().then(receivedDevice);18 }19 20 navigator.gpu.requestAdapter().then(receivedAdapter);21 }22 23 function test() {24 14 let suite = InspectorTest.CreateContextUtilities.initializeTestSuite("Canvas.CreateContextWebGPU"); 25 15 26 16 InspectorTest.CreateContextUtilities.addSimpleTestCase({ 27 name: " Device",28 expression: `create Device()`,17 name: "Attached", 18 expression: `createAttachedCanvas("gpu")`, 29 19 contextType: WI.Canvas.ContextType.WebGPU, 30 20 }); 31 21 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, 48 26 }); 49 27 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); 85 29 86 30 suite.runTestCasesAndFinish(); -
trunk/LayoutTests/inspector/canvas/resolveCanvasContext-2d.html
r249770 r249776 12 12 function test() 13 13 { 14 let suite = InspectorTest.createAsyncSuite("Canvas.resolveC ontext2D");14 let suite = InspectorTest.createAsyncSuite("Canvas.resolveCanvasContext2D"); 15 15 16 16 suite.addTestCase({ 17 name: `Canvas.resolveC ontext2D.validIdentifier`,17 name: `Canvas.resolveCanvasContext2D.validIdentifier`, 18 18 description: "Should return a valid object for the given canvas identifier.", 19 19 test(resolve, reject) { … … 25 25 26 26 const objectGroup = "test"; 27 CanvasAgent.resolveC ontext(canvas.identifier, objectGroup)27 CanvasAgent.resolveCanvasContext(canvas.identifier, objectGroup) 28 28 .then(({object}) => { 29 29 InspectorTest.expectEqual(object.type, "object", `Payload should have type "object".`); … … 37 37 38 38 suite.addTestCase({ 39 name: "Canvas.resolveC ontext.invalidIdentifier",39 name: "Canvas.resolveCanvasContext.invalidIdentifier", 40 40 description: "Invalid canvas identifiers should cause an error.", 41 41 test(resolve, reject) { 42 42 const identifier = "DOES_NOT_EXIST"; 43 43 const objectGroup = "test"; 44 CanvasAgent.resolveC ontext(identifier, objectGroup, (error) => {44 CanvasAgent.resolveCanvasContext(identifier, objectGroup, (error) => { 45 45 InspectorTest.expectThat(error, "Should produce an error."); 46 46 InspectorTest.log("Error: " + error); … … 55 55 </head> 56 56 <body onload="load()"> 57 <p>Tests for the Canvas.resolveC ontext command for 2D contexts.</p>57 <p>Tests for the Canvas.resolveCanvasContext command for 2D contexts.</p> 58 58 </body> 59 59 </html> -
trunk/LayoutTests/inspector/canvas/resolveCanvasContext-bitmaprenderer.html
r249770 r249776 12 12 function test() 13 13 { 14 let suite = InspectorTest.createAsyncSuite("Canvas.resolveC ontextBitmapRenderer");14 let suite = InspectorTest.createAsyncSuite("Canvas.resolveCanvasContextBitmapRenderer"); 15 15 16 16 suite.addTestCase({ 17 name: `Canvas.resolveC ontextBitmapRenderer.validIdentifier`,17 name: `Canvas.resolveCanvasContextBitmapRenderer.validIdentifier`, 18 18 description: "Should return a valid object for the given canvas identifier.", 19 19 test(resolve, reject) { … … 25 25 26 26 const objectGroup = "test"; 27 CanvasAgent.resolveC ontext(canvas.identifier, objectGroup)27 CanvasAgent.resolveCanvasContext(canvas.identifier, objectGroup) 28 28 .then(({object}) => { 29 29 InspectorTest.expectEqual(object.type, "object", `Payload should have type "object".`); … … 39 39 </head> 40 40 <body onload="load()"> 41 <p>Tests for the Canvas.resolveC ontext command for BitmapRenderer contexts.</p>41 <p>Tests for the Canvas.resolveCanvasContext command for BitmapRenderer contexts.</p> 42 42 </body> 43 43 </html> -
trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgl.html
r249770 r249776 12 12 function test() 13 13 { 14 let suite = InspectorTest.createAsyncSuite("Canvas.resolveC ontextWebGL");14 let suite = InspectorTest.createAsyncSuite("Canvas.resolveCanvasContextWebGL"); 15 15 16 16 suite.addTestCase({ 17 name: `Canvas.resolveC ontextWebGL.validIdentifier`,17 name: `Canvas.resolveCanvasContextWebGL.validIdentifier`, 18 18 description: "Should return a valid object for the given canvas identifier.", 19 19 test(resolve, reject) { … … 25 25 26 26 const objectGroup = "test"; 27 CanvasAgent.resolveC ontext(canvas.identifier, objectGroup)27 CanvasAgent.resolveCanvasContext(canvas.identifier, objectGroup) 28 28 .then(({object}) => { 29 29 InspectorTest.expectEqual(object.type, "object", `Payload should have type "object".`); … … 39 39 </head> 40 40 <body onload="load()"> 41 <p>Tests for the Canvas.resolveC ontext command for WebGL contexts.</p>41 <p>Tests for the Canvas.resolveCanvasContext command for WebGL contexts.</p> 42 42 </body> 43 43 </html> -
trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgl2.html
r249770 r249776 15 15 function test() 16 16 { 17 let suite = InspectorTest.createAsyncSuite("Canvas.resolveC ontextWebGL2");17 let suite = InspectorTest.createAsyncSuite("Canvas.resolveCanvasContextWebGL2"); 18 18 19 19 suite.addTestCase({ 20 name: `Canvas.resolveC ontextWebGL2.validIdentifier`,20 name: `Canvas.resolveCanvasContextWebGL2.validIdentifier`, 21 21 description: "Should return a valid object for the given canvas identifier.", 22 22 test(resolve, reject) { … … 28 28 29 29 const objectGroup = "test"; 30 CanvasAgent.resolveC ontext(canvas.identifier, objectGroup)30 CanvasAgent.resolveCanvasContext(canvas.identifier, objectGroup) 31 31 .then(({object}) => { 32 32 InspectorTest.expectEqual(object.type, "object", `Payload should have type "object".`); … … 42 42 </head> 43 43 <body onload="load()"> 44 <p>Tests for the Canvas.resolveC ontext command for WebGL2 contexts.</p>44 <p>Tests for the Canvas.resolveCanvasContext command for WebGL2 contexts.</p> 45 45 </body> 46 46 </html> -
trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgpu.html
r249770 r249776 5 5 <script> 6 6 if (window.internals) 7 window.internals.settings.setWebG L2Enabled(true);7 window.internals.settings.setWebGPUEnabled(true); 8 8 9 9 function load() { 10 window.contextWebG L2 = document.body.appendChild(document.createElement("canvas")).getContext("webgl2");10 window.contextWebGPU = document.body.appendChild(document.createElement("canvas")).getContext("gpu"); 11 11 12 12 runTest(); … … 15 15 function test() 16 16 { 17 let suite = InspectorTest.createAsyncSuite("Canvas.resolveC ontextWebGL2");17 let suite = InspectorTest.createAsyncSuite("Canvas.resolveCanvasContextWebGPU"); 18 18 19 19 suite.addTestCase({ 20 name: `Canvas.resolveC ontextWebGL2.validIdentifier`,20 name: `Canvas.resolveCanvasContextWebGPU.validIdentifier`, 21 21 description: "Should return a valid object for the given canvas identifier.", 22 22 test(resolve, reject) { 23 let canvas = WI.canvasManager.canvases.find((canvas) => canvas.contextType === WI.Canvas.ContextType.WebG L2);23 let canvas = WI.canvasManager.canvases.find((canvas) => canvas.contextType === WI.Canvas.ContextType.WebGPU); 24 24 if (!canvas) { 25 25 reject(`Missing Canvas.`); … … 28 28 29 29 const objectGroup = "test"; 30 CanvasAgent.resolveC ontext(canvas.identifier, objectGroup)30 CanvasAgent.resolveCanvasContext(canvas.identifier, objectGroup) 31 31 .then(({object}) => { 32 32 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".`); 34 34 }) 35 35 .then(resolve, reject); … … 42 42 </head> 43 43 <body onload="load()"> 44 <p>Tests for the Canvas.resolveC ontext command for WebGL2contexts.</p>44 <p>Tests for the Canvas.resolveCanvasContext command for WebGPU contexts.</p> 45 45 </body> 46 46 </html> -
trunk/LayoutTests/inspector/canvas/resources/create-context-utilities.js
r249753 r249776 1 window.contexts = [];1 let contexts = []; 2 2 3 3 function createAttachedCanvas(contextType) { … … 6 6 if (!context) 7 7 TestPage.addResult("FAIL: missing context for type " + contextType); 8 window.contexts.push(context);8 contexts.push(context); 9 9 } 10 10 … … 13 13 if (!context) 14 14 TestPage.addResult("FAIL: missing context for type " + contextType); 15 window.contexts.push(context);15 contexts.push(context); 16 16 } 17 17 … … 20 20 if (!context) 21 21 TestPage.addResult("FAIL: missing context for type " + contextType); 22 window.contexts.push();22 contexts.push(); 23 23 } 24 24 25 25 function destroyCanvases() { 26 for (let context of window.contexts) {26 for (let context of contexts) { 27 27 if (!context) 28 28 continue; … … 33 33 } 34 34 35 window.contexts = [];35 contexts = []; 36 36 37 37 // Force GC to make sure the canvas element is destroyed, otherwise the frontend -
trunk/LayoutTests/platform/gtk/TestExpectations
r249760 r249776 517 517 webkit.org/b/166536 inspector/canvas/recording-webgl2-snapshots.html [ Skip ] 518 518 webkit.org/b/166536 inspector/canvas/requestContent-webgl2.html [ Skip ] 519 webkit.org/b/166536 inspector/canvas/resolveC ontext-webgl2.html [ Skip ]519 webkit.org/b/166536 inspector/canvas/resolveCanvasContext-webgl2.html [ Skip ] 520 520 webkit.org/b/166536 inspector/canvas/shaderProgram-add-remove-webgl2.html [ Skip ] 521 521 webkit.org/b/166536 webgl/2.0.0/ [ Skip ] … … 1151 1151 webkit.org/b/191005 webgpu/ [ Skip ] 1152 1152 webkit.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 ] 1153 webkit.org/b/191005 inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ] 1155 1154 1156 1155 # No support for resource load statistics yet -
trunk/LayoutTests/platform/ios/TestExpectations
r249753 r249776 45 45 webgpu [ Skip ] 46 46 inspector/canvas/create-context-webgpu.html [ Skip ] 47 inspector/canvas/requestClientNodes-webgpu.html [ Skip ] 48 inspector/canvas/resolveContext-webgpu.html [ Skip ] 47 inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ] 49 48 50 49 # Encrypted Media Extensions are not enabled -
trunk/LayoutTests/platform/mac-wk1/TestExpectations
r249760 r249776 47 47 webgpu [ Skip ] 48 48 inspector/canvas/create-context-webgpu.html [ Skip ] 49 inspector/canvas/requestClientNodes-webgpu.html [ Skip ] 50 inspector/canvas/resolveContext-webgpu.html [ Skip ] 49 inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ] 51 50 52 51 # Media Stream API testing is not supported for WK1 yet. -
trunk/LayoutTests/platform/mac/TestExpectations
r249753 r249776 1033 1033 webkit.org/b/178028 inspector/canvas/create-context-2d.html [ Pass Timeout ] 1034 1034 webkit.org/b/174066 inspector/canvas/create-context-webgl2.html [ Pass Timeout ] 1035 webkit.org/b/174272 inspector/canvas/css-canvas-clients.html [ Pass Failure ] 1035 1036 webkit.org/b/174066 inspector/canvas/recording-webgl2-frameCount.html [ Pass Failure Timeout ] 1036 1037 webkit.org/b/174066 inspector/canvas/recording-webgl2-full.html [ Pass Failure Timeout ] 1037 1038 webkit.org/b/174066 inspector/canvas/recording-webgl2-memoryLimit.html [ Pass Failure Timeout ] 1038 1039 webkit.org/b/174066 inspector/canvas/recording-webgl2-snapshots.html [ Pass Failure Timeout ] 1039 webkit.org/b/174272 inspector/canvas/requestClientNodes-css.html [ Pass Failure ]1040 1040 webkit.org/b/174066 inspector/canvas/shaderProgram-add-remove-webgl2.html [ Pass Failure Timeout ] 1041 1041 webkit.org/b/160048 [ Debug ] inspector/codemirror/prettyprinting-javascript.html [ Pass Timeout ] … … 1784 1784 webkit.org/b/199275 [ HighSierra ] webgpu [ Skip ] 1785 1785 webkit.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 ] 1786 webkit.org/b/199275 [ HighSierra ] inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ] 1788 1787 1789 1788 webkit.org/b/189680 platform/mac/media/audio-session-category-video-paused.html [ Pass Timeout ] -
trunk/LayoutTests/platform/win/TestExpectations
r249753 r249776 2002 2002 inspector/canvas/requestContent-webgl2.html [ Skip ] 2003 2003 inspector/canvas/requestShaderSource.html [ Skip ] 2004 inspector/canvas/resolveC ontext-webgl.html [ Skip ]2005 inspector/canvas/resolveC ontext-webgl2.html [ Skip ]2004 inspector/canvas/resolveCanvasContext-webgl.html [ Skip ] 2005 inspector/canvas/resolveCanvasContext-webgl2.html [ Skip ] 2006 2006 inspector/canvas/shaderProgram-add-remove-webgl.html [ Skip ] 2007 2007 inspector/canvas/shaderProgram-add-remove-webgl2.html [ Skip ] … … 4245 4245 webgpu [ Skip ] 4246 4246 inspector/canvas/create-context-webgpu.html [ Skip ] 4247 inspector/canvas/requestClientNodes-webgpu.html [ Skip ] 4248 inspector/canvas/resolveContext-webgpu.html [ Skip ] 4247 inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ] 4249 4248 4250 4249 webkit.org/b/191194 fast/block/basic/inline-content-with-floating-image.html [ Failure ] -
trunk/LayoutTests/platform/wincairo/TestExpectations
r249753 r249776 290 290 inspector/canvas/recording-webgl2.html [ Skip ] 291 291 inspector/canvas/recording-webgl2-snapshots.html [ Skip ] 292 inspector/canvas/resolveC ontext-webgl2.html [ Skip ]292 inspector/canvas/resolveCanvasContext-webgl2.html [ Skip ] 293 293 inspector/canvas/shaderProgram-add-remove-webgl2.html [ Skip ] 294 294 webgl/webgl2-rendering-context-defined.html [ Skip ] … … 298 298 webgpu [ Skip ] 299 299 inspector/canvas/create-context-webgpu.html [ Skip ] 300 inspector/canvas/requestClientNodes-webgpu.html [ Skip ] 301 inspector/canvas/resolveContext-webgpu.html [ Skip ] 300 inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ] 302 301 303 302 # WIRELESS_PLAYBACK_TARGET is disabled -
trunk/LayoutTests/platform/wpe/TestExpectations
r249753 r249776 303 303 webgpu [ Skip ] 304 304 inspector/canvas/create-context-webgpu.html [ Skip ] 305 inspector/canvas/requestClientNodes-webgpu.html [ Skip ] 306 inspector/canvas/resolveContext-webgpu.html [ Skip ] 305 inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ] 307 306 308 307 # Skipped due to untestable DRM key system. ClearKey counterparts are tested instead. -
trunk/Source/JavaScriptCore/ChangeLog
r249753 r249776 1 2019-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 1 15 2019-09-10 Devin Rousso <drousso@apple.com> 2 16 -
trunk/Source/JavaScriptCore/inspector/protocol/Canvas.json
r249753 r249776 31 31 "description": "Drawing surface attributes.", 32 32 "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 } 41 40 ] 42 41 }, … … 86 85 }, 87 86 { 88 "name": "requestC lientNodes",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.", 90 89 "parameters": [ 91 90 { "name": "canvasId", "$ref": "CanvasId" } … … 96 95 }, 97 96 { 98 "name": "resolveC ontext",99 "description": "Resolves JavaScript canvas /devicecontext object for given canvasId.",97 "name": "resolveCanvasContext", 98 "description": "Resolves JavaScript canvas context object for given canvasId.", 100 99 "parameters": [ 101 100 { "name": "canvasId", "$ref": "CanvasId", "description": "Canvas identifier." }, … … 194 193 }, 195 194 { 196 "name": "c lientNodesChanged",195 "name": "cssCanvasClientNodesChanged", 197 196 "parameters": [ 198 197 { "name": "canvasId", "$ref": "CanvasId", "description": "Identifier of canvas that changed." } -
trunk/Source/WebCore/ChangeLog
r249770 r249776 1 2019-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 1 15 2019-09-11 Antti Koivisto <antti@apple.com> 2 16 -
trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.cpp
r249753 r249776 42 42 auto context = std::unique_ptr<GPUCanvasContext>(new GPUCanvasContext(canvas)); 43 43 context->suspendIfNeeded(); 44 45 InspectorInstrumentation::didCreateCanvasRenderingContext(*context); 46 44 47 return context; 45 48 } … … 65 68 if (m_swapChain) 66 69 m_swapChain->destroy(); 67 68 InspectorInstrumentation::willConfigureSwapChain(*this, newSwapChain.get()); 69 70 70 71 m_swapChain = newSwapChain.copyRef(); 71 72 72 notifyCanvasContentChanged(); 73 73 } -
trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.h
r249753 r249776 44 44 HTMLCanvasElement& canvas() const { return downcast<HTMLCanvasElement>(canvasBase()); } 45 45 46 WebGPUSwapChain* swapChain() const { return m_swapChain.get(); }47 46 Ref<WebGPUSwapChain> configureSwapChain(const WebGPUSwapChainDescriptor&); 48 47 -
trunk/Source/WebCore/Modules/webgpu/WebGPUAdapter.cpp
r249753 r249776 30 30 31 31 #include "Document.h" 32 #include "InspectorInstrumentation.h"33 32 #include "JSWebGPUDevice.h" 34 33 … … 48 47 { 49 48 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())) 53 50 promise.resolve(device.releaseNonNull()); 54 }else51 else 55 52 promise.reject(); 56 53 }); -
trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp
r249753 r249776 48 48 #include "GPUTextureDescriptor.h" 49 49 #include "GPUUncapturedErrorEvent.h" 50 #include "InspectorInstrumentation.h"51 50 #include "JSDOMConvertBufferSource.h" 52 51 #include "JSGPUOutOfMemoryError.h" … … 75 74 #include <JavaScriptCore/ConsoleMessage.h> 76 75 #include <memory> 77 #include <wtf/HashSet.h>78 76 #include <wtf/IsoMallocInlines.h> 79 #include <wtf/Lock.h>80 77 #include <wtf/MainThread.h> 81 #include <wtf/NeverDestroyed.h>82 78 #include <wtf/Optional.h> 83 #include <wtf/Ref.h>84 #include <wtf/RefPtr.h>85 79 #include <wtf/Variant.h> 86 #include <wtf/Vector.h>87 80 #include <wtf/text/WTFString.h> 88 81 … … 96 89 return adoptRef(new WebGPUDevice(context, WTFMove(adapter), device.releaseNonNull())); 97 90 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();114 91 } 115 92 … … 124 101 { 125 102 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);138 103 } 139 104 -
trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h
r249753 r249776 35 35 #include "WebGPUQueue.h" 36 36 #include "WebGPUSwapChainDescriptor.h" 37 #include <wtf/ Forward.h>37 #include <wtf/Ref.h> 38 38 #include <wtf/RefCounted.h> 39 #include <wtf/RefPtr.h> 40 #include <wtf/Vector.h> 39 41 #include <wtf/WeakPtr.h> 40 42 … … 79 81 WTF_MAKE_ISO_ALLOCATED(WebGPUDevice); 80 82 public: 81 virtual ~WebGPUDevice();82 83 83 static RefPtr<WebGPUDevice> tryCreate(ScriptExecutionContext&, Ref<const WebGPUAdapter>&&); 84 85 static HashSet<WebGPUDevice*>& instances(const LockHolder&);86 static Lock& instancesMutex();87 84 88 85 const WebGPUAdapter& adapter() const { return m_adapter.get(); } … … 110 107 void popErrorScope(ErrorPromise&&); 111 108 112 ScriptExecutionContext* scriptExecutionContext() const final { return &m_scriptExecutionContext; }113 114 109 using RefCounted::ref; 115 110 using RefCounted::deref; … … 120 115 // EventTarget 121 116 EventTargetInterface eventTargetInterface() const final { return WebGPUDeviceEventTargetInterfaceType; } 117 ScriptExecutionContext* scriptExecutionContext() const final { return &m_scriptExecutionContext; } 122 118 void refEventTarget() final { ref(); } 123 119 void derefEventTarget() final { deref(); } -
trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.idl
r249753 r249776 30 30 Conditional=WEBGPU, 31 31 EnabledAtRuntime=WebGPU, 32 InterfaceName=GPUDevice, 33 JSGenerateToJSObject, 32 InterfaceName=GPUDevice 34 33 ] interface WebGPUDevice : EventTarget { 35 34 readonly attribute WebGPUAdapter adapter; -
trunk/Source/WebCore/inspector/InspectorCanvas.cpp
r249753 r249776 34 34 #include "CanvasRenderingContext2D.h" 35 35 #include "Document.h" 36 #include "Element.h"37 36 #include "FloatPoint.h" 38 37 #include "Gradient.h" … … 50 49 #include "JSCanvasLineCap.h" 51 50 #include "JSCanvasLineJoin.h" 52 #include "JSCanvasRenderingContext2D.h"53 51 #include "JSCanvasTextAlign.h" 54 52 #include "JSCanvasTextBaseline.h" 55 53 #include "JSExecState.h" 56 #include "JSImageBitmapRenderingContext.h"57 54 #include "JSImageSmoothingQuality.h" 58 55 #include "Path2D.h" … … 61 58 #include "SVGPathUtilities.h" 62 59 #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 63 72 #include <JavaScriptCore/IdentifiersFactory.h> 64 73 #include <JavaScriptCore/ScriptCallStackFactory.h> 65 74 #include <wtf/Function.h> 66 75 67 #if ENABLE(CSS_TYPED_OM)68 #include "TypedOMCSSImageValue.h"69 #endif70 71 #if ENABLE(WEBGL)72 #include "JSWebGLRenderingContext.h"73 #include "WebGLRenderingContext.h"74 #endif75 76 #if ENABLE(WEBGL2)77 #include "JSWebGL2RenderingContext.h"78 #include "WebGL2RenderingContext.h"79 #endif80 81 #if ENABLE(WEBGPU)82 #include "GPUCanvasContext.h"83 #include "JSWebGPUDevice.h"84 #include "WebGPUDevice.h"85 #endif86 87 76 namespace WebCore { 88 77 89 78 using namespace Inspector; 90 79 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 #endif108 109 80 Ref<InspectorCanvas> InspectorCanvas::create(CanvasRenderingContext& context) 110 81 { 111 82 return adoptRef(*new InspectorCanvas(context)); 112 83 } 113 114 #if ENABLE(WEBGPU)115 Ref<InspectorCanvas> InspectorCanvas::create(WebGPUDevice& device)116 {117 return adoptRef(*new InspectorCanvas(device));118 }119 #endif120 84 121 85 InspectorCanvas::InspectorCanvas(CanvasRenderingContext& context) … … 123 87 , m_context(context) 124 88 { 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 91 HTMLCanvasElement* InspectorCanvas::canvasElement() 92 { 93 if (is<HTMLCanvasElement>(m_context.canvasBase())) 94 return &downcast<HTMLCanvasElement>(m_context.canvasBase()); 143 95 return nullptr; 144 96 } 145 97 146 HTMLCanvasElement* InspectorCanvas::canvasElement() const147 {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 #endif168 [] (Monostate) {169 ASSERT_NOT_REACHED();170 return nullptr;171 }172 );173 return nullptr;174 }175 176 #if ENABLE(WEBGPU)177 WebGPUDevice* InspectorCanvas::deviceContext() const178 {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) const185 {186 if (auto* device = deviceContext())187 return canvasIfContextMatchesDevice(context, *device);188 return false;189 }190 #endif191 192 ScriptExecutionContext* InspectorCanvas::scriptExecutionContext() const193 {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 #endif205 [] (Monostate) {206 ASSERT_NOT_REACHED();207 return nullptr;208 }209 );210 }211 212 JSC::JSValue InspectorCanvas::resolveContext(ExecState* exec) const213 {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 #endif229 #if ENABLE(WEBGL2)230 if (is<WebGL2RenderingContext>(context))231 return toJS(exec, globalObject, downcast<WebGL2RenderingContext>(context));232 #endif233 return JSC::JSValue();234 },235 #if ENABLE(WEBGPU)236 [&] (std::reference_wrapper<WebGPUDevice> deviceWrapper) {237 return toJS(exec, globalObject, deviceWrapper.get());238 },239 #endif240 [] (Monostate) {241 ASSERT_NOT_REACHED();242 return JSC::JSValue();243 }244 );245 }246 247 HashSet<Element*> InspectorCanvas::clientNodes() const248 {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 #endif269 [] (Monostate) {270 ASSERT_NOT_REACHED();271 return HashSet<Element*>();272 }273 );274 }275 276 98 void InspectorCanvas::canvasChanged() 277 99 { 278 auto* context = canvasContext(); 279 ASSERT(context); 280 281 if (!context->callTracingActive()) 100 if (!m_context.callTracingActive()) 282 101 return; 283 102 284 103 // 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)) 286 105 return; 287 106 … … 303 122 m_contentChanged = false; 304 123 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); 310 125 } 311 126 … … 377 192 m_currentActions->addItem(m_lastRecordedAction.get()); 378 193 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)) 384 195 m_contentChanged = true; 385 196 #if ENABLE(WEBGL) 386 else if (is<WebGLRenderingContext>( context) && shouldSnapshotWebGLAction(name))197 else if (is<WebGLRenderingContext>(m_context) && shouldSnapshotWebGLAction(name)) 387 198 m_contentChanged = true; 388 199 #endif 389 200 #if ENABLE(WEBGL2) 390 else if (is<WebGL2RenderingContext>( context) && shouldSnapshotWebGL2Action(name))201 else if (is<WebGL2RenderingContext>(m_context) && shouldSnapshotWebGL2Action(name)) 391 202 m_contentChanged = true; 392 203 #endif … … 440 251 Ref<Inspector::Protocol::Canvas::Canvas> InspectorCanvas::buildObjectForCanvas(bool captureBacktrace) 441 252 { 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; 453 261 #endif 454 262 #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 460 266 #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 { 471 271 ASSERT_NOT_REACHED(); 472 272 contextType = Inspector::Protocol::Canvas::ContextType::Canvas2D; … … 475 275 auto canvas = Inspector::Protocol::Canvas::Canvas::create() 476 276 .setCanvasId(m_identifier) 477 .setContextType(contextType .value())277 .setContextType(contextType) 478 278 .release(); 479 279 … … 486 286 } 487 287 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)); 553 307 } 554 ); 555 if (contextAttributes) 556 canvas->setContextAttributes(WTFMove(contextAttributes)); 308 } 309 #endif 557 310 558 311 // FIXME: <https://webkit.org/b/180833> Web Inspector: support OffscreenCanvas for Canvas related operations … … 577 330 ASSERT(!m_frames); 578 331 579 auto* context = canvasContext();580 ASSERT(context);581 // FIXME: <https://webkit.org/b/201651> Web Inspector: Canvas: support canvas recordings for WebGPUDevice582 583 332 Inspector::Protocol::Recording::Type type; 584 if (is<CanvasRenderingContext2D>( context))333 if (is<CanvasRenderingContext2D>(m_context)) 585 334 type = Inspector::Protocol::Recording::Type::Canvas2D; 586 else if (is<ImageBitmapRenderingContext>( context))335 else if (is<ImageBitmapRenderingContext>(m_context)) 587 336 type = Inspector::Protocol::Recording::Type::CanvasBitmapRenderer; 588 337 #if ENABLE(WEBGL) 589 else if (is<WebGLRenderingContext>( context))338 else if (is<WebGLRenderingContext>(m_context)) 590 339 type = Inspector::Protocol::Recording::Type::CanvasWebGL; 591 340 #endif 592 341 #if ENABLE(WEBGL2) 593 else if (is<WebGL2RenderingContext>( context))342 else if (is<WebGL2RenderingContext>(m_context)) 594 343 type = Inspector::Protocol::Recording::Type::CanvasWebGL2; 595 344 #endif … … 616 365 String InspectorCanvas::getCanvasContentAsDataURL(ErrorString& errorString) 617 366 { 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 618 378 auto* node = canvasElement(); 619 379 if (!node) { 620 errorString = " Missing HTMLCanvasElement of canvas for given canvasId"_s;380 errorString = "Context isn't related to an HTMLCanvasElement"_s; 621 381 return emptyString(); 622 382 } 623 383 624 384 #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); 628 387 #endif 629 388 … … 631 390 632 391 #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); 635 394 #endif 636 395 … … 800 559 Ref<Inspector::Protocol::Recording::InitialState> InspectorCanvas::buildInitialState() 801 560 { 802 auto* context = canvasContext();803 ASSERT(context);804 // FIXME: <https://webkit.org/b/201651> Web Inspector: Canvas: support canvas recordings for WebGPUDevice805 806 561 auto initialStatePayload = Inspector::Protocol::Recording::InitialState::create().release(); 807 562 808 563 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()); 811 566 812 567 auto statesPayload = JSON::ArrayOf<JSON::Object>::create(); … … 814 569 auto parametersPayload = JSON::ArrayOf<JSON::Value>::create(); 815 570 816 if (is<CanvasRenderingContext2D>( context)) {817 auto& context2d = downcast<CanvasRenderingContext2D>( *context);571 if (is<CanvasRenderingContext2D>(m_context)) { 572 auto& context2d = downcast<CanvasRenderingContext2D>(m_context); 818 573 for (auto& state : context2d.stateStack()) { 819 574 auto statePayload = JSON::Object::create(); … … 872 627 } 873 628 #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); 876 631 if (Optional<WebGLContextAttributes> webGLContextAttributes = contextWebGLBase.getContextAttributes()) { 877 632 auto webGLContextAttributesPayload = JSON::Object::create(); -
trunk/Source/WebCore/inspector/InspectorCanvas.h
r249753 r249776 27 27 28 28 #include "CallTracerTypes.h" 29 #include "CanvasRenderingContext.h"30 29 #include <JavaScriptCore/InspectorProtocolObjects.h> 31 #include <JavaScriptCore/JSCInlines.h>32 30 #include <JavaScriptCore/ScriptCallFrame.h> 33 31 #include <JavaScriptCore/ScriptCallStack.h> 34 32 #include <initializer_list> 35 #include <wtf/HashSet.h>36 33 #include <wtf/Variant.h> 37 34 #include <wtf/Vector.h> 38 35 #include <wtf/text/WTFString.h> 39 40 #if ENABLE(WEBGPU)41 #include "WebGPUDevice.h"42 #endif43 36 44 37 namespace WebCore { … … 46 39 class CanvasGradient; 47 40 class CanvasPattern; 48 class Element;41 class CanvasRenderingContext; 49 42 class HTMLCanvasElement; 50 43 class HTMLImageElement; … … 61 54 public: 62 55 static Ref<InspectorCanvas> create(CanvasRenderingContext&); 63 #if ENABLE(WEBGPU)64 static Ref<InspectorCanvas> create(WebGPUDevice&);65 #endif66 56 67 const String& identifier() const { return m_identifier; } 57 const String& identifier() { return m_identifier; } 58 CanvasRenderingContext& context() { return m_context; } 68 59 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(); 82 61 83 62 void canvasChanged(); … … 109 88 private: 110 89 InspectorCanvas(CanvasRenderingContext&); 111 #if ENABLE(WEBGPU)112 InspectorCanvas(WebGPUDevice&);113 #endif114 115 90 void appendActionSnapshotIfNeeded(); 116 91 … … 142 117 143 118 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; 152 120 153 121 RefPtr<Inspector::Protocol::Recording::InitialState> m_initialState; -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r249753 r249776 75 75 #include <wtf/StdLibExtras.h> 76 76 77 #if ENABLE(WEBGPU)78 #include "WebGPUSwapChain.h"79 #endif80 81 77 namespace WebCore { 82 78 … … 1107 1103 #endif 1108 1104 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 #endif1128 1129 1105 #if ENABLE(RESOURCE_USAGE) 1130 1106 void InspectorInstrumentation::didHandleMemoryPressureImpl(InstrumentingAgents& instrumentingAgents, Critical critical) -
trunk/Source/WebCore/inspector/InspectorInstrumentation.h
r249753 r249776 61 61 #endif 62 62 63 #if ENABLE(WEBGPU)64 #include "GPUCanvasContext.h"65 #include "WebGPUDevice.h"66 #endif67 68 63 namespace Inspector { 69 64 class ConsoleMessage; … … 98 93 class SharedBuffer; 99 94 class TimerBase; 100 class WebKitNamedFlow;101 class WorkerInspectorProxy;102 103 95 #if ENABLE(WEBGL) 104 96 class WebGLProgram; 105 97 #endif 106 107 #if ENABLE(WEBGPU) 108 class WebGPUSwapChain; 109 #endif 98 class WebKitNamedFlow; 99 class WorkerInspectorProxy; 110 100 111 101 enum class StorageType; … … 295 285 static bool isShaderProgramHighlighted(WebGLRenderingContextBase&, WebGLProgram&); 296 286 #endif 297 #if ENABLE(WEBGPU)298 static void didCreateWebGPUDevice(WebGPUDevice&);299 static void willDestroyWebGPUDevice(WebGPUDevice&);300 static void willConfigureSwapChain(GPUCanvasContext&, WebGPUSwapChain&);301 #endif302 287 303 288 static void networkStateChanged(Page&); … … 487 472 static bool isShaderProgramHighlightedImpl(InstrumentingAgents&, WebGLProgram&); 488 473 #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 #endif494 474 495 475 static void layerTreeDidChangeImpl(InstrumentingAgents&); … … 1416 1396 #endif 1417 1397 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 #endif1440 1441 1398 inline void InspectorInstrumentation::networkStateChanged(Page& page) 1442 1399 { -
trunk/Source/WebCore/inspector/InspectorShaderProgram.cpp
r249753 r249776 56 56 WebGLRenderingContextBase& InspectorShaderProgram::context() const 57 57 { 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()); 61 60 } 62 61 -
trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp
r249753 r249776 37 37 #include "InspectorDOMAgent.h" 38 38 #include "InstrumentingAgents.h" 39 #include "JSCanvasRenderingContext2D.h" 39 40 #include "JSExecState.h" 41 #include "JSImageBitmapRenderingContext.h" 40 42 #include "Microtasks.h" 41 43 #include "OffscreenCanvas.h" … … 51 53 52 54 #if ENABLE(WEBGL) 55 #include "JSWebGLRenderingContext.h" 53 56 #include "WebGLProgram.h" 54 #include "WebGLRenderingContext.h"55 #include "WebGLRenderingContextBase.h"56 57 #include "WebGLShader.h" 57 58 #endif 58 59 59 60 #if ENABLE(WEBGL2) 60 #include " WebGL2RenderingContext.h"61 #include "JSWebGL2RenderingContext.h" 61 62 #endif 62 63 63 64 #if ENABLE(WEBGPU) 64 #include "GPUCanvasContext.h" 65 #include "WebGPUDevice.h" 65 #include "JSGPUCanvasContext.h" 66 66 #endif 67 67 … … 104 104 m_instrumentingAgents.setInspectorCanvasAgent(this); 105 105 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(); 107 111 if (!is<Document>(scriptExecutionContext)) 108 112 return false; … … 115 119 { 116 120 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); 126 124 } 127 125 } 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 #endif138 126 139 127 #if ENABLE(WEBGL) 140 128 { 141 129 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); 145 133 } 146 134 } … … 187 175 } 188 176 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 177 void InspectorCanvasAgent::requestCSSCanvasClientNodes(ErrorString& errorString, const String& canvasId, RefPtr<JSON::ArrayOf<int>>& result) 178 { 197 179 auto inspectorCanvas = assertInspectorCanvas(errorString, canvasId); 198 180 if (!inspectorCanvas) 199 181 return; 200 182 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 190 static 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 214 void InspectorCanvasAgent::resolveCanvasContext(ErrorString& errorString, const String& canvasId, const String* objectGroup, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result) 209 215 { 210 216 auto inspectorCanvas = assertInspectorCanvas(errorString, canvasId); … … 212 218 return; 213 219 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); 216 222 ASSERT(!injectedScript.hasNoValue()); 217 223 218 JSC::JSValue value = inspectorCanvas->resolveContext(state); 219 224 JSC::JSValue value = contextAsScriptValue(state, inspectorCanvas->context()); 220 225 if (!value) { 221 226 ASSERT_NOT_REACHED(); … … 242 247 return; 243 248 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()) { 251 250 errorString = "Already recording canvas"_s; 252 251 return; … … 267 266 return; 268 267 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()) { 276 269 errorString = "Not recording canvas"_s; 277 270 return; 278 271 } 279 272 280 didFinishRecordingCanvasFrame( *context, true);273 didFinishRecordingCanvasFrame(inspectorCanvas->context(), true); 281 274 } 282 275 … … 379 372 } 380 373 381 for (auto* inspectorCanvas : inspectorCanvases) 382 unbindCanvas(*inspectorCanvas); 374 for (auto* inspectorCanvas : inspectorCanvases) { 375 String identifier = unbindCanvas(*inspectorCanvas); 376 m_frontendDispatcher->canvasRemoved(identifier); 377 } 383 378 } 384 379 … … 396 391 return; 397 392 398 m_frontendDispatcher->c lientNodesChanged(inspectorCanvas->identifier());393 m_frontendDispatcher->cssCanvasClientNodesChanged(inspectorCanvas->identifier()); 399 394 } 400 395 … … 417 412 void InspectorCanvasAgent::didChangeCanvasMemory(CanvasRenderingContext& context) 418 413 { 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); 435 415 ASSERT(inspectorCanvas); 436 416 if (!inspectorCanvas) … … 457 437 // covered by the initial microtask until the next frame. 458 438 if (!inspectorCanvas->currentFrameHasData()) { 459 if (auto* scriptExecutionContext = inspectorCanvas-> scriptExecutionContext()) {439 if (auto* scriptExecutionContext = inspectorCanvas->context().canvasBase().scriptExecutionContext()) { 460 440 auto& queue = MicrotaskQueue::mainThreadQueue(); 461 441 queue.append(makeUnique<ActiveDOMCallbackMicrotask>(queue, *scriptExecutionContext, [&, protectedInspectorCanvas = inspectorCanvas.copyRef()] { … … 465 445 } 466 446 467 if ( canvasRenderingContext.callTracingActive())468 didFinishRecordingCanvasFrame( canvasRenderingContext);447 if (protectedInspectorCanvas->context().callTracingActive()) 448 didFinishRecordingCanvasFrame(protectedInspectorCanvas->context()); 469 449 })); 470 450 } … … 474 454 475 455 if (!inspectorCanvas->hasBufferSpace()) 476 didFinishRecordingCanvasFrame( canvasRenderingContext, true);456 didFinishRecordingCanvasFrame(inspectorCanvas->context(), true); 477 457 } 478 458 … … 502 482 return; 503 483 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); 505 493 } 506 494 507 495 void InspectorCanvasAgent::didFinishRecordingCanvasFrame(CanvasRenderingContext& context, bool forceDispatch) 508 496 { 509 if (!context.callTracingActive())510 return;511 512 497 auto inspectorCanvas = findInspectorCanvas(context); 513 498 ASSERT(inspectorCanvas); 514 499 if (!inspectorCanvas) 500 return; 501 502 if (!inspectorCanvas->context().callTracingActive()) 515 503 return; 516 504 … … 613 601 #endif 614 602 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 #endif653 654 603 void InspectorCanvasAgent::startRecording(InspectorCanvas& inspectorCanvas, Inspector::Protocol::Recording::Initiator initiator, RecordingOptions&& recordingOptions) 655 604 { 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) 664 610 #endif 665 611 #if ENABLE(WEBGL2) 666 && !is<WebGL2RenderingContext>(c ontext)667 #endif 668 )669 return; 670 671 if (c ontext->callTracingActive())612 && !is<WebGL2RenderingContext>(canvasRenderingContext) 613 #endif 614 && !is<ImageBitmapRenderingContext>(canvasRenderingContext)) 615 return; 616 617 if (canvasRenderingContext.callTracingActive()) 672 618 return; 673 619 … … 679 625 if (recordingOptions.name) 680 626 inspectorCanvas.setRecordingName(recordingOptions.name.value()); 681 c ontext->setCallTracingActive(true);627 canvasRenderingContext.setCallTracingActive(true); 682 628 683 629 m_frontendDispatcher->recordingStarted(inspectorCanvas.identifier(), initiator); … … 697 643 void InspectorCanvasAgent::clearCanvasData() 698 644 { 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); 703 647 704 648 m_identifierToInspectorCanvas.clear(); … … 717 661 m_identifierToInspectorCanvas.set(inspectorCanvas->identifier(), inspectorCanvas.copyRef()); 718 662 719 context.canvasBase().addObserver(*this);663 inspectorCanvas->context().canvasBase().addObserver(*this); 720 664 721 665 m_frontendDispatcher->canvasAdded(inspectorCanvas->buildObjectForCanvas(captureBacktrace)); 722 666 723 667 #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()); 726 670 if (Optional<Vector<String>> extensions = contextWebGL.getSupportedExtensions()) { 727 671 for (const String& extension : *extensions) { … … 736 680 } 737 681 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) 682 String InspectorCanvasAgent::unbindCanvas(InspectorCanvas& inspectorCanvas) 751 683 { 752 684 #if ENABLE(WEBGL) … … 761 693 #endif 762 694 763 if (auto* context = inspectorCanvas.canvasContext()) 764 context->canvasBase().removeObserver(*this); 695 inspectorCanvas.context().canvasBase().removeObserver(*this); 765 696 766 697 String identifier = inspectorCanvas.identifier(); 767 698 m_identifierToInspectorCanvas.remove(identifier); 768 699 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; 776 701 } 777 702 … … 789 714 { 790 715 for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values()) { 791 if ( inspectorCanvas->canvasContext() == &context)716 if (&inspectorCanvas->context() == &context) 792 717 return inspectorCanvas; 793 718 } 794 719 return nullptr; 795 720 } 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 #endif807 721 808 722 #if ENABLE(WEBGL) -
trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.h
r249753 r249776 54 54 class WebGLRenderingContextBase; 55 55 #endif 56 #if ENABLE(WEBGPU)57 class GPUCanvasContext;58 class WebGPUDevice;59 class WebGPUSwapChain;60 #endif61 56 62 57 typedef String ErrorString; … … 79 74 void requestNode(ErrorString&, const String& canvasId, int* nodeId); 80 75 void requestContent(ErrorString&, const String& canvasId, String* content); 81 void requestC lientNodes(ErrorString&, const String& canvasId, RefPtr<JSON::ArrayOf<int>>&);82 void resolveC ontext(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>&); 83 78 void setRecordingAutoCaptureFrameCount(ErrorString&, int count); 84 79 void startRecording(ErrorString&, const String& canvasId, const int* frameCount, const int* memoryLimit); … … 98 93 void didChangeCSSCanvasClientNodes(CanvasBase&); 99 94 void didCreateCanvasRenderingContext(CanvasRenderingContext&); 95 void willDestroyCanvasRenderingContext(CanvasRenderingContext&); 100 96 void didChangeCanvasMemory(CanvasRenderingContext&); 101 97 void recordCanvasAction(CanvasRenderingContext&, const String&, std::initializer_list<RecordCanvasActionVariant>&& = { }); … … 108 104 bool isShaderProgramDisabled(WebGLProgram&); 109 105 bool isShaderProgramHighlighted(WebGLProgram&); 110 #endif111 #if ENABLE(WEBGPU)112 void didCreateWebGPUDevice(WebGPUDevice&);113 void willDestroyWebGPUDevice(WebGPUDevice&);114 void willConfigureSwapChain(GPUCanvasContext&, WebGPUSwapChain&);115 106 #endif 116 107 … … 126 117 void clearCanvasData(); 127 118 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&); 132 120 RefPtr<InspectorCanvas> assertInspectorCanvas(ErrorString&, const String& canvasId); 133 121 RefPtr<InspectorCanvas> findInspectorCanvas(CanvasRenderingContext&); 134 #if ENABLE(WEBGPU)135 RefPtr<InspectorCanvas> findInspectorCanvas(WebGPUDevice&);136 #endif137 138 122 #if ENABLE(WEBGL) 139 123 String unbindProgram(InspectorShaderProgram&); -
trunk/Source/WebInspectorUI/ChangeLog
r249753 r249776 1 2019-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 1 15 2019-09-10 Devin Rousso <drousso@apple.com> 2 16 -
trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
r249753 r249776 195 195 localizedStrings["CPU Usage"] = "CPU Usage"; 196 196 localizedStrings["CSP Hash"] = "CSP Hash"; 197 localizedStrings["CSS"] = "CSS"; 197 198 localizedStrings["CSS Canvas"] = "CSS Canvas"; 198 199 localizedStrings["CSS Changes:"] = "CSS Changes:"; … … 246 247 localizedStrings["Click to view variable value\nShift-click to replace variable with value"] = "Click to view variable value\nShift-click to replace variable with value"; 247 248 localizedStrings["Clickable"] = "Clickable"; 248 localizedStrings["Clients"] = "Clients";249 249 localizedStrings["Close"] = "Close"; 250 250 localizedStrings["Close %s timeline view"] = "Close %s timeline view"; … … 346 346 localizedStrings["Detached"] = "Detached"; 347 347 localizedStrings["Details"] = "Details"; 348 localizedStrings["Device %d"] = "Device %d";349 348 localizedStrings["Device Settings"] = "Device Settings"; 350 349 localizedStrings["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 185 185 } 186 186 187 c lientNodesChanged(canvasIdentifier)188 { 189 let canvas = this._canvasIdentifierMap.get(canvasIdentifier); 190 console.assert(canvas); 191 if (!canvas) 192 return; 193 194 canvas.c lientNodesChanged();187 cssCanvasClientNodesChanged(canvasIdentifier) 188 { 189 let canvas = this._canvasIdentifierMap.get(canvasIdentifier); 190 console.assert(canvas); 191 if (!canvas) 192 return; 193 194 canvas.cssCanvasClientNodesChanged(); 195 195 } 196 196 -
trunk/Source/WebInspectorUI/UserInterface/Models/Canvas.js
r249753 r249776 42 42 this._backtrace = backtrace || []; 43 43 44 this._c lientNodes = null;44 this._cssCanvasClientNodes = null; 45 45 this._shaderProgramCollection = new WI.ShaderProgramCollection; 46 46 this._recordingCollection = new WI.RecordingCollection; … … 114 114 static resetUniqueDisplayNameNumbers() 115 115 { 116 Canvas._nextContextUniqueDisplayNameNumber = 1; 117 Canvas._nextDeviceUniqueDisplayNameNumber = 1; 116 WI.Canvas._nextUniqueDisplayNameNumber = 1; 118 117 } 119 118 … … 162 161 } 163 162 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 170 163 if (!this._uniqueDisplayNameNumber) 171 this._uniqueDisplayNameNumber = Canvas._nextContextUniqueDisplayNameNumber++;164 this._uniqueDisplayNameNumber = this.constructor._nextUniqueDisplayNameNumber++; 172 165 return WI.UIString("Canvas %d").format(this._uniqueDisplayNameNumber); 173 166 } … … 179 172 WI.domManager.ensureDocument(); 180 173 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}.`); 184 178 return; 185 179 } 186 187 this._domNode = WI.domManager.nodeForId(nodeId);188 if (!this._domNode) {189 resolve(null);190 return;191 }192 193 180 resolve(this._domNode); 194 }) ;181 }).catch(reject); 195 182 }); 196 183 } 184 197 185 return this._requestNodePromise; 198 186 } … … 203 191 } 204 192 205 requestC lientNodes(callback)206 { 207 if ( this._clientNodes) {208 callback( this._clientNodes);193 requestCSSCanvasClientNodes(callback) 194 { 195 if (!this._cssCanvasName) { 196 callback([]); 209 197 return; 210 198 } 211 199 200 if (this._cssCanvasClientNodes) { 201 callback(this._cssCanvasClientNodes); 202 return; 203 } 204 212 205 WI.domManager.ensureDocument(); 213 206 214 let wrappedCallback =(error, clientNodeIds) => {207 CanvasAgent.requestCSSCanvasClientNodes(this._identifier, (error, clientNodeIds) => { 215 208 if (error) { 216 209 callback([]); … … 219 212 220 213 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 }); 232 217 } 233 218 … … 261 246 262 247 return this.requestNode().then((domNode) => { 263 if (!domNode)264 return null;265 266 248 let size = calculateSize(domNode); 267 249 if (!isNaN(size.width) && !isNaN(size.height)) … … 346 328 } 347 329 348 c lientNodesChanged()330 cssCanvasClientNodesChanged() 349 331 { 350 332 // Called from WI.CanvasManager. 351 333 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); 355 340 } 356 341 … … 418 403 }; 419 404 420 WI.Canvas._nextContextUniqueDisplayNameNumber = 1; 421 WI.Canvas._nextDeviceUniqueDisplayNameNumber = 1; 405 WI.Canvas._nextUniqueDisplayNameNumber = 1; 422 406 423 407 WI.Canvas.FrameURLCookieKey = "canvas-frame-url"; … … 443 427 MemoryChanged: "canvas-memory-changed", 444 428 ExtensionEnabled: "canvas-extension-enabled", 445 C lientNodesChanged: "canvas-client-nodes-changed",429 CSSCanvasClientNodesChanged: "canvas-css-canvas-client-nodes-changed", 446 430 RecordingStarted: "canvas-recording-started", 447 431 RecordingProgress: "canvas-recording-progress", -
trunk/Source/WebInspectorUI/UserInterface/Protocol/CanvasObserver.js
r249753 r249776 43 43 } 44 44 45 c lientNodesChanged(canvasId)45 cssCanvasClientNodesChanged(canvasId) 46 46 { 47 WI.canvasManager.c lientNodesChanged(canvasId);47 WI.canvasManager.cssCanvasClientNodesChanged(canvasId); 48 48 } 49 49 … … 77 77 WI.canvasManager.programDeleted(programId); 78 78 } 79 80 // COMPATIBILITY (iOS 13): Canvas.events.cssCanvasClientNodesChanged was renamed to Canvas.events.clientNodesChanged.81 cssCanvasClientNodesChanged(canvasId)82 {83 WI.canvasManager.clientNodesChanged(canvasId);84 }85 79 }; -
trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js
r249753 r249776 164 164 console.assert(typeof callback === "function"); 165 165 166 function wrapCallback(error, object){166 CanvasAgent.resolveCanvasContext(canvas.identifier, objectGroup, (error, object) => { 167 167 if (error || !object) 168 168 callback(null); 169 169 else 170 170 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 }); 180 172 } 181 173 -
trunk/Source/WebInspectorUI/UserInterface/Views/CanvasContentView.js
r249753 r249776 211 211 212 212 this.representedObject.requestNode().then((node) => { 213 if (!node)214 return;215 216 213 console.assert(!this._canvasNode || this._canvasNode === node); 217 214 if (this._canvasNode === node) … … 285 282 }; 286 283 287 this.representedObject.requestSize().then((size) => { 284 this.representedObject.requestSize() 285 .then((size) => { 288 286 updatePixelSize(size); 287 }) 288 .catch((error) => { 289 updatePixelSize(null); 289 290 }); 290 291 } -
trunk/Source/WebInspectorUI/UserInterface/Views/CanvasDetailsSidebarPanel.js
r249753 r249776 79 79 this._canvas.removeEventListener(WI.Canvas.Event.MemoryChanged, this._canvasMemoryChanged, this); 80 80 this._canvas.removeEventListener(WI.Canvas.Event.ExtensionEnabled, this._refreshExtensionsSection, this); 81 this._canvas.removeEventListener(WI.Canvas.Event.C lientNodesChanged, this._refreshClientsSection, this);81 this._canvas.removeEventListener(WI.Canvas.Event.CSSCanvasClientNodesChanged, this._refreshCSSCanvasSection, this); 82 82 } 83 83 … … 87 87 this._canvas.addEventListener(WI.Canvas.Event.MemoryChanged, this._canvasMemoryChanged, this); 88 88 this._canvas.addEventListener(WI.Canvas.Event.ExtensionEnabled, this._refreshExtensionsSection, this); 89 this._canvas.addEventListener(WI.Canvas.Event.C lientNodesChanged, this._refreshClientsSection, this);89 this._canvas.addEventListener(WI.Canvas.Event.CSSCanvasClientNodesChanged, this._refreshCSSCanvasSection, this); 90 90 } 91 91 … … 112 112 this._widthRow = new WI.DetailsSectionSimpleRow(WI.UIString("Width")); 113 113 this._heightRow = new WI.DetailsSectionSimpleRow(WI.UIString("Height")); 114 this._d etachedRow = new WI.DetailsSectionSimpleRow(WI.UIString("Detached"));114 this._datachedRow = new WI.DetailsSectionSimpleRow(WI.UIString("Detached")); 115 115 116 116 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._d etachedRow])];117 sourceSection.groups = [new WI.DetailsSectionGroup([this._nodeRow, this._cssCanvasRow, this._widthRow, this._heightRow, this._datachedRow])]; 118 118 this._sections.push(sourceSection); 119 119 … … 129 129 this._sections.push(this._extensionsSection); 130 130 131 this._c lientNodesRow = new WI.DetailsSectionSimpleRow(WI.UIString("Nodes"));132 133 this._c lientsSection = new WI.DetailsSection("canvas-clients", WI.UIString("Clients"));134 this._c lientsSection.groups = [new WI.DetailsSectionGroup([this._clientNodesRow])];135 this._c lientsSection.element.hidden = true;136 this._sections.push(this._c lientsSection);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); 137 137 138 138 const selectable = false; … … 169 169 this._refreshAttributesSection(); 170 170 this._refreshExtensionsSection(); 171 this._refreshC lientsSection();171 this._refreshCSSCanvasSection(); 172 172 this._refreshBacktraceSection(); 173 173 } … … 195 195 return; 196 196 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; 200 198 this._cssCanvasRow.value = this._canvas.cssCanvasName || null; 201 199 this._widthRow.value = emDash; 202 200 this._heightRow.value = emDash; 203 this._d etachedRow.value = null;201 this._datachedRow.value = null; 204 202 205 203 this._canvas.requestNode().then((node) => { 206 if (!node) {207 this._nodeRow.value = null;208 return;209 }210 211 204 if (node !== this._node) { 212 205 if (this._node) { … … 223 216 } 224 217 225 if (! hideNode) {218 if (!this._canvas.cssCanvasName) 226 219 this._nodeRow.value = WI.linkifyNodeReference(this._node); 227 228 if (!this._node.parentNode)229 this._detachedRow.value = WI.UIString("Yes");230 }231 220 232 221 let setRowValueIfValidAttributeValue = (row, attribute) => { … … 260 249 }); 261 250 } 251 252 if (!this._canvas.cssCanvasName && !this._node.parentNode) 253 this._datachedRow.value = WI.UIString("Yes"); 262 254 }); 263 255 } … … 304 296 } 305 297 306 _refreshC lientsSection()298 _refreshCSSCanvasSection() 307 299 { 308 300 if (!this.didInitialLayout) 309 301 return; 310 302 311 if (!this._canvas.cssCanvasName && this._canvas.contextType !== WI.Canvas.ContextType.WebGPU) {312 this._c lientsSection.element.hidden = true;313 return; 314 } 315 316 this._c lientNodesRow.value = emDash;317 318 this._c lientsSection.element.hidden = false;319 320 this._canvas.requestC lientNodes((clientNodes) => {321 if (!c lientNodes.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) 322 314 return; 323 315 324 316 let fragment = document.createDocumentFragment(); 325 for (let clientNode of c lientNodes)317 for (let clientNode of cssCanvasClientNodes) 326 318 fragment.appendChild(WI.linkifyNodeReference(clientNode)); 327 this._c lientNodesRow.value = fragment;319 this._cssCanvasClientsRow.value = fragment; 328 320 }); 329 321 } -
trunk/Source/WebInspectorUI/UserInterface/Views/CanvasOverviewContentView.js
r249753 r249776 192 192 193 193 let canvas = contentView.representedObject; 194 if (canvas.cssCanvasName || canvas.contextType === WI.Canvas.ContextType.WebGPU) {195 canvas.requestC lientNodes((clientNodes) => {196 WI.domManager.highlightDOMNodeList(c lientNodes.map((node) => node.id));194 if (canvas.cssCanvasName) { 195 canvas.requestCSSCanvasClientNodes((cssCanvasClientNodes) => { 196 WI.domManager.highlightDOMNodeList(cssCanvasClientNodes.map((node) => node.id)); 197 197 }); 198 198 return; -
trunk/Source/WebInspectorUI/UserInterface/Views/CanvasTreeElement.js
r249753 r249776 116 116 _handleMouseOver(event) 117 117 { 118 if (this.representedObject.cssCanvasName || this.representedObject.contextType === WI.Canvas.ContextType.WebGPU) {119 this.representedObject.requestC lientNodes((clientNodes) => {120 WI.domManager.highlightDOMNodeList(c lientNodes.map((node) => node.id));118 if (this.representedObject.cssCanvasName) { 119 this.representedObject.requestCSSCanvasClientNodes((cssCanvasClientNodes) => { 120 WI.domManager.highlightDOMNodeList(cssCanvasClientNodes.map((node) => node.id), "all"); 121 121 }); 122 122 } else { … … 125 125 return; 126 126 127 WI.domManager.highlightDOMNode(node.id );127 WI.domManager.highlightDOMNode(node.id, "all"); 128 128 }); 129 129 }
Note: See TracChangeset
for help on using the changeset viewer.