-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Web Inspector: support OffscreenCanvas for Canvas related operations
https://bugs.webkit.org/show_bug.cgi?id=180833 <rdar://problem/36059660> Reviewed by Patrick Angle. * Source/JavaScriptCore/inspector/protocol/Canvas.json: * Source/JavaScriptCore/inspector/protocol/Recording.json: Expose the entire domain (minus a few commands/events) to the `"worker"` target. * Source/WebCore/inspector/InspectorController.cpp: (WebCore::InspectorController::createLazyAgents): * Source/WebCore/inspector/WorkerInspectorController.cpp: (WebCore::WorkerInspectorController::createLazyAgents): * Source/WebCore/inspector/agents/InspectorCanvasAgent.h: * Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp: (WebCore::InspectorCanvasAgent::InspectorCanvasAgent): (WebCore::InspectorCanvasAgent::enable): (WebCore::InspectorCanvasAgent::disable): (WebCore::InspectorCanvasAgent::enabled const): Added. (WebCore::InspectorCanvasAgent::internalEnable): Added. (WebCore::InspectorCanvasAgent::internalDisable): Added. (WebCore::InspectorCanvasAgent::didChangeCanvasSize): Added. (WebCore::InspectorCanvasAgent::didChangeCanvasMemory): (WebCore::InspectorCanvasAgent::unbindCanvas): (WebCore::InspectorCanvasAgent::requestNode): Deleted. (WebCore::InspectorCanvasAgent::requestClientNodes): Deleted. (WebCore::InspectorCanvasAgent::frameNavigated): Deleted. (WebCore::InspectorCanvasAgent::didChangeCSSCanvasClientNodes): Deleted. * Source/WebCore/inspector/agents/page/PageCanvasAgent.h: Added. * Source/WebCore/inspector/agents/page/PageCanvasAgent.cpp: Added. (WebCore::PageCanvasAgent::PageCanvasAgent): (WebCore::PageCanvasAgent::enabled const): (WebCore::PageCanvasAgent::internalEnable): (WebCore::PageCanvasAgent::internalDisable): (WebCore::PageCanvasAgent::requestNode): (WebCore::PageCanvasAgent::requestClientNodes): (WebCore::PageCanvasAgent::frameNavigated): (WebCore::PageCanvasAgent::didChangeCSSCanvasClientNodes): (WebCore::PageCanvasAgent::matchesCurrentContext const): * Source/WebCore/inspector/agents/worker/WorkerCanvasAgent.h: Added. * Source/WebCore/inspector/agents/worker/WorkerCanvasAgent.cpp: Added. (WebCore::WorkerCanvasAgent::WorkerCanvasAgent): (WebCore::WorkerCanvasAgent::requestNode): (WebCore::WorkerCanvasAgent::requestClientNodes): (WebCore::WorkerCanvasAgent::matchesCurrentContext const): Split `InspectorCanvasAgent` into `PageCanvasAgent` and `WorkerCanvasAgent`. * Source/WebInspectorUI/UserInterface/Protocol/CanvasObserver.js: (WI.CanvasObserver.prototype.canvasAdded): (WI.CanvasObserver.prototype.canvasRemoved): (WI.CanvasObserver.prototype.canvasSizeChanged): (WI.CanvasObserver.prototype.canvasMemoryChanged): (WI.CanvasObserver.prototype.clientNodesChanged): (WI.CanvasObserver.prototype.recordingStarted): (WI.CanvasObserver.prototype.recordingProgress): (WI.CanvasObserver.prototype.recordingFinished): (WI.CanvasObserver.prototype.extensionEnabled): (WI.CanvasObserver.prototype.programCreated): (WI.CanvasObserver.prototype.programDeleted): (WI.CanvasObserver.prototype.cssCanvasClientNodesChanged): Pass along the `WI.Target`. * Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js: (WI.CanvasManager): (WI.CanvasManager.prototype.disable): (WI.CanvasManager.prototype.canvasAdded): (WI.CanvasManager.prototype.canvasRemoved): (WI.CanvasManager.prototype.canvasSizeChanged): Added. (WI.CanvasManager.prototype.canvasMemoryChanged): (WI.CanvasManager.prototype.clientNodesChanged): (WI.CanvasManager.prototype.recordingStarted): (WI.CanvasManager.prototype.recordingProgress): (WI.CanvasManager.prototype.recordingFinished): (WI.CanvasManager.prototype.extensionEnabled): (WI.CanvasManager.prototype.programCreated): (WI.CanvasManager.prototype.programDeleted): (WI.CanvasManager.prototype._canvasForIdentifier): Added. (WI.CanvasManager.prototype._handleTargetRemoved): Added. (WI.CanvasManager.prototype._mainResourceDidChange): (WI.CanvasManager.prototype.get shaderPrograms): `WI.Canvas`/`WI.ShaderProgram` now need to be keyed by a `WI.Target` -> identifier combo since the same identifier could be used by two different `WI.Target` (e.g. main page and `Worker`). * Source/WebInspectorUI/UserInterface/Models/Canvas.js: (WI.Canvas): (WI.Canvas.fromPayload): (WI.Canvas.prototype.get target): Added. (WI.Canvas.prototype.get size): Added. (WI.Canvas.prototype.get memoryCost): (WI.Canvas.prototype.requestNode): (WI.Canvas.prototype.requestContent): (WI.Canvas.prototype.requestClientNodes): (WI.Canvas.prototype.startRecording): (WI.Canvas.prototype.stopRecording): (WI.Canvas.prototype.sizeChanged): Added. (WI.Canvas.prototype.memoryChanged): Renamed from `set memoryCost`. (WI.Canvas.prototype.async _calculateSize): Added. (WI.Canvas.prototype.requestSize): Deleted. * Source/WebInspectorUI/UserInterface/Models/ShaderProgram.js: (WI.ShaderProgram): (WI.ShaderProgram.prototype.get target): Added. (WI.ShaderProgram.prototype.set disabled): (WI.ShaderProgram.prototype.requestShaderSource): (WI.ShaderProgram.prototype.updateShader): (WI.ShaderProgram.prototype.showHighlight): (WI.ShaderProgram.prototype.hideHighlight): Use the `this._target` instead of `WI.assumingMainTarget()`. * Source/WebCore/html/CanvasBase.h: (WebCore::CanvasBase::setSize): Deleted. * Source/WebCore/html/CanvasBase.cpp: (WebCore::CanvasBase::setSize): Added. (WebCore::CanvasBase::setImageBuffer const): * Source/WebCore/inspector/InspectorCanvas.cpp: (WebCore::InspectorCanvas::buildObjectForCanvas): * Source/WebCore/inspector/InspectorInstrumentation.h: (WebCore::InspectorInstrumentation::didChangeCanvasSize): Added. * Source/WebCore/inspector/InspectorInstrumentation.cpp: (WebCore::InspectorInstrumentation::didCommitLoadImpl): (WebCore::InspectorInstrumentation::didChangeCSSCanvasClientNodesImpl): (WebCore::InspectorInstrumentation::didChangeCanvasSizeImpl): Added. * Source/WebCore/inspector/InstrumentingAgents.h: * Source/WebInspectorUI/UserInterface/Views/CanvasContentView.js: (WI.CanvasContentView): (WI.CanvasContentView.prototype.initialLayout): (WI.CanvasContentView.prototype.attached): (WI.CanvasContentView.prototype.detached): (WI.CanvasContentView.prototype._populateCanvasElementButtonContextMenu): (WI.CanvasContentView.prototype._updateSize): Added. (WI.CanvasContentView.prototype._refreshPixelSize): Deleted. Now that `Canvas.requestNode` won't always work, we need a different way of getting the owner to find it's size. Additionally, since the owner might not be a `Element`, we can't leverage `WI.DOMNode.Event.AttributeModified` to listen for changes in the size. Instead, add instrumentation for when the size changes in C++ and notify the frontend as such (as well as adding logic to grab the `context.canvas.{width,height}` from the `Canvas.resolveCanvasContext` instead since that will always work). * Source/WebInspectorUI/UserInterface/Models/Geometry.js: (WI.Size.fromJSON): Drive-by: Add a helper to make some logic slightly easier. * Source/WebInspectorUI/UserInterface/Models/Recording.js: (WI.Recording.displayNameForRecordingType): (WI.Recording.prototype.is2D): Drive-by: Fix display name to be consistent with `WI.Canvas.displayNameForContextType`. Drive-by: Add missing method. * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js: * LayoutTests/inspector/canvas/resources/create-context-utilities.js: (destroyCanvases): (InspectorTest.CreateContextUtilities.addSimpleTestCase): * LayoutTests/inspector/canvas/resources/worker.js: Added. (createContext): (destroyContexts): * LayoutTests/inspector/canvas/create-context-2d.html: * LayoutTests/inspector/canvas/create-context-2d-expected.txt: * LayoutTests/inspector/canvas/create-context-bitmaprenderer.html: * LayoutTests/inspector/canvas/create-context-bitmaprenderer-expected.txt: * LayoutTests/inspector/canvas/create-context-webgl.html: * LayoutTests/inspector/canvas/create-context-webgl-expected.txt: * LayoutTests/inspector/canvas/create-context-webgl2.html: * LayoutTests/inspector/canvas/create-context-webgl2-expected.txt: Canonical link: https://commits.webkit.org/267488@main
- Loading branch information
Showing
38 changed files
with
862 additions
and
353 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
globalThis.contexts = []; | ||
|
||
function createContext(contextType) { | ||
let canvas = new OffscreenCanvas(10, 10); | ||
let context = canvas.getContext(contextType); | ||
globalThis.contexts.push(context); | ||
} | ||
|
||
function destroyContexts() { | ||
globalThis.contexts = []; | ||
} | ||
|
||
addEventListener("message", (event) => { | ||
let {name, args} = event.data; | ||
globalThis[name](...args); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.