Changeset 225488 in webkit
- Timestamp:
- Dec 4, 2017 1:40:55 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r225479 r225488 1 2017-12-04 Devin Rousso <webkit@devinrousso.com> 2 3 Web Inspector: provide method for recording CanvasRenderingContext2D from JavaScript 4 https://bugs.webkit.org/show_bug.cgi?id=175166 5 <rdar://problem/34040740> 6 7 Reviewed by Joseph Pecoraro. 8 9 * inspector/canvas/recording-2d-expected.txt: 10 * inspector/canvas/recording-2d.html: 11 (performConsoleRecording): 12 * inspector/canvas/recording-webgl-expected.txt: 13 * inspector/canvas/recording-webgl.html: 14 (performConsoleRecording): 15 * inspector/canvas/resources/recording-utilities.js: 16 (TestPage.registerInitializer): 17 * js/console-expected.txt: 18 * js/console.html: 19 1 20 2017-12-04 Ms2ger <Ms2ger@igalia.com> 2 21 -
trunk/LayoutTests/inspector/canvas/recording-2d-expected.txt
r224389 r225488 1523 1523 30: [29,10,122,108] 1524 1524 1525 -- Running test case: Canvas.recording2D.Console 1526 PASS: The recording should have the name "TEST". 1527 PASS: The recording should have one frame. 1528 PASS: The first frame should have one action. 1529 1525 1530 -- Running test case: Canvas.recording2D.ActionParameterNaN 1526 1531 PASS: The recording should have 1 frame. -
trunk/LayoutTests/inspector/canvas/recording-2d.html
r223998 r225488 396 396 } 397 397 398 function performConsoleActions() { 399 console.record(ctx, {name: "TEST"}); 400 401 ctx.fill(); 402 403 console.recordEnd(ctx); 404 405 ctx.stroke(); 406 } 407 398 408 function performNaNActions() { 399 409 ctx.globalAlpha = NaN; … … 433 443 test(resolve, reject) { 434 444 startRecording(WI.Canvas.ContextType.Canvas2D, resolve, reject, {memoryLimit: 10}); 445 }, 446 }); 447 448 suite.addTestCase({ 449 name: "Canvas.recording2D.Console", 450 description: "Check that a recording can be triggered by console.record().", 451 test(resolve, reject) { 452 consoleRecord(resolve, reject); 435 453 }, 436 454 }); … … 477 495 test(resolve, reject) { 478 496 let canvas = getCanvas(WI.Canvas.ContextType.Canvas2D); 479 if (!canvas) 480 throw "Missing 2D canvas."; 497 if (!canvas) { 498 reject("Missing 2D canvas."); 499 return; 500 } 481 501 482 502 let eventCount = 0; 483 503 function handleRecordingStopped(event) { 484 504 InspectorTest.assert(event.data.canvas === canvas, "We should have stopped recording the selected canvas."); 505 InspectorTest.assert(!event.data.recording, "The recording payload should be null."); 506 485 507 ++eventCount; 486 487 508 if (eventCount == 1) 488 509 InspectorTest.pass("A recording should have been started and stopped once."); 489 490 if (eventCount >= 2) { 510 else if (eventCount >= 2) { 491 511 InspectorTest.pass("A recording should have been started and stopped twice."); 492 512 -
trunk/LayoutTests/inspector/canvas/recording-webgl-expected.txt
r224389 r225488 1501 1501 17: [16,3,122,108] 1502 1502 1503 -- Running test case: Canvas.recordingWebGL.Console 1504 PASS: The recording should have the name "TEST". 1505 PASS: The recording should have one frame. 1506 PASS: The first frame should have one action. 1507 -
trunk/LayoutTests/inspector/canvas/recording-webgl.html
r222888 r225488 497 497 } 498 498 499 function performConsoleActions() { 500 console.record(context, {name: "TEST"}); 501 502 context.createTexture(); 503 504 console.recordEnd(context); 505 506 context.createBuffer(); 507 } 508 499 509 function test() { 500 510 let suite = InspectorTest.createAsyncSuite("Canvas.recordingWebGL"); … … 533 543 }); 534 544 545 suite.addTestCase({ 546 name: "Canvas.recordingWebGL.Console", 547 description: "Check that a recording can be triggered by console.record().", 548 test(resolve, reject) { 549 consoleRecord(resolve, reject); 550 }, 551 }); 552 535 553 suite.runTestCasesAndFinish(); 536 554 } -
trunk/LayoutTests/inspector/canvas/resources/recording-utilities.js
r224726 r225488 145 145 return canvas; 146 146 }; 147 148 window.consoleRecord = function(resolve, reject) { 149 WI.canvasManager.awaitEvent(WI.CanvasManager.Event.RecordingStopped).then((event) => { 150 let recording = event.data.recording; 151 InspectorTest.expectEqual(recording.displayName, "TEST", "The recording should have the name \"TEST\"."); 152 InspectorTest.expectEqual(recording.frames.length, 1, "The recording should have one frame."); 153 InspectorTest.expectEqual(recording.frames[0].actions.length, 1, "The first frame should have one action."); 154 }).then(resolve, reject); 155 156 InspectorTest.evaluateInPage(`performConsoleActions()`); 157 }; 147 158 }); -
trunk/LayoutTests/js/console-expected.txt
r201022 r225488 164 164 PASS descriptor.enumerable is true 165 165 166 console.record 167 PASS typeof console.record is "function" 168 PASS console.record.length is 0 169 PASS descriptor.configurable is true 170 PASS descriptor.writable is true 171 PASS descriptor.enumerable is true 172 173 console.recordEnd 174 PASS typeof console.recordEnd is "function" 175 PASS console.recordEnd.length is 0 176 PASS descriptor.configurable is true 177 PASS descriptor.writable is true 178 PASS descriptor.enumerable is true 179 166 180 PASS Object.getOwnPropertyNames(console).length is enumerablePropertyCount 181 182 fuzzing of target for console.record 183 PASS console.record() did not throw exception. 184 PASS console.record(undefined) did not throw exception. 185 PASS console.record(null) did not throw exception. 186 PASS console.record(1) did not throw exception. 187 PASS console.record("test") did not throw exception. 188 PASS console.record([]) did not throw exception. 189 PASS console.record({}) did not throw exception. 190 PASS console.record(window) did not throw exception. 191 PASS console.record(console) did not throw exception. 192 193 fuzzing of options for console.record 194 PASS console.record({}, undefined) did not throw exception. 195 PASS console.record({}, null) did not throw exception. 196 PASS console.record({}, 1) did not throw exception. 197 PASS console.record({}, "test") did not throw exception. 198 PASS console.record({}, []) did not throw exception. 199 PASS console.record({}, {}) did not throw exception. 200 PASS console.record({}, window) did not throw exception. 201 PASS console.record({}, console) did not throw exception. 202 203 fuzzing of target for console.recordEnd 204 PASS console.recordEnd() did not throw exception. 205 PASS console.recordEnd(undefined) did not throw exception. 206 PASS console.recordEnd(null) did not throw exception. 207 PASS console.recordEnd(1) did not throw exception. 208 PASS console.recordEnd("test") did not throw exception. 209 PASS console.recordEnd([]) did not throw exception. 210 PASS console.recordEnd({}) did not throw exception. 211 PASS console.recordEnd(window) did not throw exception. 212 PASS console.recordEnd(console) did not throw exception. 213 214 ensure multiple calls don't throw 215 PASS console.recordEnd(window.canvas) did not throw exception. 216 PASS console.recordEnd(window.canvas) did not throw exception. 217 PASS console.recordEnd(window.canvas) did not throw exception. 218 PASS console.record(window.canvas) did not throw exception. 219 PASS console.record(window.canvas) did not throw exception. 220 PASS console.record(window.canvas) did not throw exception. 167 221 PASS successfullyParsed is true 168 222 -
trunk/LayoutTests/js/console.html
r201022 r225488 47 47 debug(""); 48 48 shouldBe("Object.getOwnPropertyNames(console).length", "enumerablePropertyCount"); 49 50 const consoleRecordArguments = [ 51 `undefined`, 52 `null`, 53 `1`, 54 `"test"`, 55 `[]`, 56 `{}`, 57 `window`, 58 `console`, 59 ]; 60 61 debug(""); 62 debug("fuzzing of target for console.record"); 63 shouldNotThrow(`console.record()`); 64 for (let argument of consoleRecordArguments) 65 shouldNotThrow(`console.record(${argument})`); 66 67 debug(""); 68 debug("fuzzing of options for console.record"); 69 for (let argument of consoleRecordArguments) 70 shouldNotThrow(`console.record({}, ${argument})`); 71 72 debug(""); 73 debug("fuzzing of target for console.recordEnd"); 74 shouldNotThrow(`console.recordEnd()`); 75 for (let argument of consoleRecordArguments) 76 shouldNotThrow(`console.recordEnd(${argument})`); 77 78 debug(""); 79 debug("ensure multiple calls don't throw"); 80 shouldNotThrow(`console.recordEnd(window.canvas)`); 81 shouldNotThrow(`console.recordEnd(window.canvas)`); 82 shouldNotThrow(`console.recordEnd(window.canvas)`); 83 shouldNotThrow(`console.record(window.canvas)`); 84 shouldNotThrow(`console.record(window.canvas)`); 85 shouldNotThrow(`console.record(window.canvas)`); 86 49 87 </script> 50 88 <script src="../resources/js-test-post.js"></script> 89 <canvas id="canvas"></canvas> 51 90 </body> 52 91 </html> -
trunk/Source/JavaScriptCore/ChangeLog
r225470 r225488 1 2017-12-04 Devin Rousso <webkit@devinrousso.com> 2 3 Web Inspector: provide method for recording CanvasRenderingContext2D from JavaScript 4 https://bugs.webkit.org/show_bug.cgi?id=175166 5 <rdar://problem/34040740> 6 7 Reviewed by Joseph Pecoraro. 8 9 * inspector/protocol/Recording.json: 10 Add optional `name` that will be used by the frontend for uniquely identifying the Recording. 11 12 * inspector/JSGlobalObjectConsoleClient.h: 13 * inspector/JSGlobalObjectConsoleClient.cpp: 14 (Inspector::JSGlobalObjectConsoleClient::record): 15 (Inspector::JSGlobalObjectConsoleClient::recordEnd): 16 17 * runtime/ConsoleClient.h: 18 * runtime/ConsoleObject.cpp: 19 (JSC::ConsoleObject::finishCreation): 20 (JSC::consoleProtoFuncRecord): 21 (JSC::consoleProtoFuncRecordEnd): 22 1 23 2017-12-03 Yusuke Suzuki <utatane.tea@gmail.com> 2 24 -
trunk/Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.cpp
r212448 r225488 166 166 } 167 167 168 void JSGlobalObjectConsoleClient::record(ExecState*, Ref<ScriptArguments>&&) { } 169 void JSGlobalObjectConsoleClient::recordEnd(ExecState*, Ref<ScriptArguments>&&) { } 170 168 171 void JSGlobalObjectConsoleClient::warnUnimplemented(const String& method) 169 172 { -
trunk/Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.h
r212448 r225488 54 54 void timeEnd(JSC::ExecState*, const String& title) override; 55 55 void timeStamp(JSC::ExecState*, Ref<ScriptArguments>&&) override; 56 void record(JSC::ExecState*, Ref<ScriptArguments>&&) override; 57 void recordEnd(JSC::ExecState*, Ref<ScriptArguments>&&) override; 56 58 57 59 private: -
trunk/Source/JavaScriptCore/inspector/protocol/Recording.json
r224726 r225488 36 36 { "name": "type", "$ref": "Type" }, 37 37 { "name": "initialState", "$ref": "InitialState", "description": "JSON data of inital state of object before recording." }, 38 { "name": "data", "type": "array", "items": { "type": "any" }, "description": "Array of objects that can be referenced by index. Used to avoid duplicating objects." } 38 { "name": "data", "type": "array", "items": { "type": "any" }, "description": "Array of objects that can be referenced by index. Used to avoid duplicating objects." }, 39 { "name": "name", "type": "string", "optional": true } 39 40 ] 40 41 } -
trunk/Source/JavaScriptCore/runtime/ConsoleClient.h
r212448 r225488 63 63 virtual void timeEnd(ExecState*, const String& title) = 0; 64 64 virtual void timeStamp(ExecState*, Ref<Inspector::ScriptArguments>&&) = 0; 65 virtual void record(ExecState*, Ref<Inspector::ScriptArguments>&&) = 0; 66 virtual void recordEnd(ExecState*, Ref<Inspector::ScriptArguments>&&) = 0; 65 67 66 68 private: -
trunk/Source/JavaScriptCore/runtime/ConsoleObject.cpp
r222473 r225488 58 58 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncGroupCollapsed(ExecState*); 59 59 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncGroupEnd(ExecState*); 60 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncRecord(ExecState*); 61 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncRecordEnd(ExecState*); 60 62 61 63 const ClassInfo ConsoleObject::s_info = { "Console", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(ConsoleObject) }; … … 96 98 JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("groupCollapsed", consoleProtoFuncGroupCollapsed, static_cast<unsigned>(PropertyAttribute::None), 0); 97 99 JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("groupEnd", consoleProtoFuncGroupEnd, static_cast<unsigned>(PropertyAttribute::None), 0); 100 JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("record", consoleProtoFuncRecord, static_cast<unsigned>(PropertyAttribute::None), 0); 101 JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("recordEnd", consoleProtoFuncRecordEnd, static_cast<unsigned>(PropertyAttribute::None), 0); 98 102 } 99 103 … … 368 372 } 369 373 374 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncRecord(ExecState* exec) 375 { 376 ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient(); 377 if (!client) 378 return JSValue::encode(jsUndefined()); 379 380 client->record(exec, Inspector::createScriptArguments(exec, 0)); 381 return JSValue::encode(jsUndefined()); 382 } 383 384 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncRecordEnd(ExecState* exec) 385 { 386 ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient(); 387 if (!client) 388 return JSValue::encode(jsUndefined()); 389 390 client->recordEnd(exec, Inspector::createScriptArguments(exec, 0)); 391 return JSValue::encode(jsUndefined()); 392 } 393 370 394 } // namespace JSC -
trunk/Source/WebCore/ChangeLog
r225486 r225488 1 2017-12-04 Devin Rousso <webkit@devinrousso.com> 2 3 Web Inspector: provide method for recording CanvasRenderingContext2D from JavaScript 4 https://bugs.webkit.org/show_bug.cgi?id=175166 5 <rdar://problem/34040740> 6 7 Reviewed by Joseph Pecoraro. 8 9 No new tests, updated existing tests. 10 11 * inspector/InspectorCanvas.h: 12 * inspector/InspectorCanvas.cpp: 13 (WebCore::InspectorCanvas::resetRecordingData): 14 15 * inspector/InspectorCanvasAgent.h: 16 * inspector/InspectorCanvasAgent.cpp: 17 (WebCore::InspectorCanvasAgent::didFinishRecordingCanvasFrame): 18 (WebCore::InspectorCanvasAgent::consoleStartRecordingCanvas): 19 20 * inspector/InspectorInstrumentation.h: 21 * inspector/InspectorInstrumentation.cpp: 22 (WebCore::InspectorInstrumentation::consoleStartRecordingCanvas): 23 (WebCore::InspectorInstrumentation::consoleStartRecordingCanvasImpl): 24 25 * page/PageConsoleClient.h: 26 * page/PageConsoleClient.cpp: 27 (WebCore::PageConsoleClient::record): 28 (WebCore::PageConsoleClient::recordEnd): 29 30 * workers/WorkerConsoleClient.h: 31 * workers/WorkerConsoleClient.cpp: 32 (WebCore::WorkerConsoleClient::record): 33 (WebCore::WorkerConsoleClient::recordEnd): 34 1 35 2017-12-04 Youenn Fablet <youenn@apple.com> 2 36 -
trunk/Source/WebCore/inspector/InspectorCanvas.cpp
r225425 r225488 103 103 m_serializedDuplicateData = nullptr; 104 104 m_indexedDuplicateData.clear(); 105 m_recordingName = { }; 105 106 m_bufferLimit = 100 * 1024 * 1024; 106 107 m_bufferUsed = 0; -
trunk/Source/WebCore/inspector/InspectorCanvas.h
r225425 r225488 69 69 void markCurrentFrameIncomplete(); 70 70 71 const String& recordingName() const { return m_recordingName; } 72 void setRecordingName(const String& name) { m_recordingName = name; } 73 71 74 void setBufferLimit(long); 72 75 bool hasBufferSpace() const; … … 117 120 RefPtr<JSON::ArrayOf<JSON::Value>> m_serializedDuplicateData; 118 121 Vector<DuplicateDataVariant> m_indexedDuplicateData; 122 123 String m_recordingName; 119 124 double m_currentFrameStartTime { NAN }; 120 125 size_t m_bufferLimit { 100 * 1024 * 1024 }; -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r225263 r225488 883 883 } 884 884 885 void InspectorInstrumentation::consoleStartRecordingCanvasImpl(InstrumentingAgents& instrumentingAgents, HTMLCanvasElement& canvasElement, JSC::ExecState& exec, JSC::JSObject* options) 886 { 887 if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent()) 888 canvasAgent->consoleStartRecordingCanvas(canvasElement, exec, options); 889 } 890 885 891 void InspectorInstrumentation::didOpenDatabaseImpl(InstrumentingAgents& instrumentingAgents, RefPtr<Database>&& database, const String& domain, const String& name, const String& version) 886 892 { -
trunk/Source/WebCore/inspector/InspectorInstrumentation.h
r225193 r225488 49 49 #include "WorkerGlobalScope.h" 50 50 #include "WorkerInspectorController.h" 51 #include <runtime/JSCInlines.h> 51 52 #include <wtf/MemoryPressureHandler.h> 52 53 #include <wtf/RefPtr.h> … … 226 227 static void startProfiling(Page&, JSC::ExecState*, const String& title); 227 228 static void stopProfiling(Page&, JSC::ExecState*, const String& title); 229 static void consoleStartRecordingCanvas(HTMLCanvasElement&, JSC::ExecState&, JSC::JSObject* options); 228 230 229 231 static void didRequestAnimationFrame(Document&, int callbackId); … … 392 394 static void stopConsoleTimingImpl(InstrumentingAgents&, const String& title, Ref<Inspector::ScriptCallStack>&&); 393 395 static void consoleTimeStampImpl(InstrumentingAgents&, Frame&, Ref<Inspector::ScriptArguments>&&); 396 static void startProfilingImpl(InstrumentingAgents&, JSC::ExecState*, const String& title); 397 static void stopProfilingImpl(InstrumentingAgents&, JSC::ExecState*, const String& title); 398 static void consoleStartRecordingCanvasImpl(InstrumentingAgents&, HTMLCanvasElement&, JSC::ExecState&, JSC::JSObject* options); 394 399 395 400 static void didRequestAnimationFrameImpl(InstrumentingAgents&, int callbackId, Document&); … … 397 402 static InspectorInstrumentationCookie willFireAnimationFrameImpl(InstrumentingAgents&, int callbackId, Document&); 398 403 static void didFireAnimationFrameImpl(const InspectorInstrumentationCookie&); 399 400 static void startProfilingImpl(InstrumentingAgents&, JSC::ExecState*, const String& title);401 static void stopProfilingImpl(InstrumentingAgents&, JSC::ExecState*, const String& title);402 404 403 405 static void didOpenDatabaseImpl(InstrumentingAgents&, RefPtr<Database>&&, const String& domain, const String& name, const String& version); … … 1390 1392 } 1391 1393 1394 inline void InspectorInstrumentation::consoleStartRecordingCanvas(HTMLCanvasElement& canvasElement, JSC::ExecState& exec, JSC::JSObject* options) 1395 { 1396 FAST_RETURN_IF_NO_FRONTENDS(void()); 1397 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(&canvasElement.document())) 1398 consoleStartRecordingCanvasImpl(*instrumentingAgents, canvasElement, exec, options); 1399 } 1400 1392 1401 inline void InspectorInstrumentation::didRequestAnimationFrame(Document& document, int callbackId) 1393 1402 { -
trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp
r225425 r225488 523 523 .release(); 524 524 525 const String& name = inspectorCanvas->recordingName(); 526 if (!name.isEmpty()) 527 recording->setName(name); 528 525 529 m_frontendDispatcher->recordingFinished(inspectorCanvas->identifier(), WTFMove(recording)); 526 530 527 531 inspectorCanvas->resetRecordingData(); 532 } 533 534 void InspectorCanvasAgent::consoleStartRecordingCanvas(HTMLCanvasElement& canvasElement, JSC::ExecState& exec, JSC::JSObject* options) 535 { 536 auto* inspectorCanvas = findInspectorCanvas(canvasElement); 537 if (!inspectorCanvas) 538 return; 539 540 if (inspectorCanvas->canvas().renderingContext()->callTracingActive()) 541 return; 542 543 inspectorCanvas->resetRecordingData(); 544 545 if (options) { 546 if (JSC::JSValue optionName = options->get(&exec, JSC::Identifier::fromString(&exec, "name"))) 547 inspectorCanvas->setRecordingName(optionName.toWTFString(&exec)); 548 if (JSC::JSValue optionSingleFrame = options->get(&exec, JSC::Identifier::fromString(&exec, "singleFrame"))) 549 inspectorCanvas->setSingleFrame(optionSingleFrame.toBoolean(&exec)); 550 if (JSC::JSValue optionMemoryLimit = options->get(&exec, JSC::Identifier::fromString(&exec, "memoryLimit"))) 551 inspectorCanvas->setBufferLimit(optionMemoryLimit.toNumber(&exec)); 552 } 553 554 inspectorCanvas->canvas().renderingContext()->setCallTracingActive(true); 528 555 } 529 556 -
trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.h
r225425 r225488 88 88 void recordCanvasAction(CanvasRenderingContext&, const String&, Vector<RecordCanvasActionVariant>&& = { }); 89 89 void didFinishRecordingCanvasFrame(HTMLCanvasElement&, bool forceDispatch = false); 90 void consoleStartRecordingCanvas(HTMLCanvasElement&, JSC::ExecState&, JSC::JSObject* options); 90 91 #if ENABLE(WEBGL) 91 92 void didEnableExtension(WebGLRenderingContextBase&, const String&); -
trunk/Source/WebCore/page/PageConsoleClient.cpp
r223728 r225488 30 30 #include "PageConsoleClient.h" 31 31 32 #include "CanvasRenderingContext2D.h" 32 33 #include "Chrome.h" 33 34 #include "ChromeClient.h" 34 35 #include "Document.h" 35 36 #include "Frame.h" 37 #include "HTMLCanvasElement.h" 36 38 #include "InspectorController.h" 37 39 #include "InspectorInstrumentation.h" 40 #include "JSCanvasRenderingContext2D.h" 41 #include "JSHTMLCanvasElement.h" 38 42 #include "JSMainThreadExecState.h" 39 43 #include "MainFrame.h" … … 41 45 #include "ScriptableDocumentParser.h" 42 46 #include "Settings.h" 47 #include <bindings/ScriptValue.h> 43 48 #include <inspector/ConsoleMessage.h> 44 49 #include <inspector/ScriptArguments.h> 45 50 #include <inspector/ScriptCallStack.h> 46 51 #include <inspector/ScriptCallStackFactory.h> 52 #include <runtime/JSCInlines.h> 53 #include <wtf/text/WTFString.h> 54 55 #if ENABLE(WEBGL) 56 #include "JSWebGLRenderingContext.h" 57 #include "WebGLRenderingContext.h" 58 #endif 47 59 48 60 … … 207 219 } 208 220 221 void PageConsoleClient::record(JSC::ExecState* exec, Ref<ScriptArguments>&& arguments) 222 { 223 if (arguments->argumentCount() < 1) 224 return; 225 226 JSC::JSObject* target = arguments->argumentAt(0).jsValue().getObject(); 227 if (!target) 228 return; 229 230 JSC::JSObject* options = nullptr; 231 if (arguments->argumentCount() >= 2) 232 options = arguments->argumentAt(1).jsValue().getObject(); 233 234 if (HTMLCanvasElement* canvasElement = JSHTMLCanvasElement::toWrapped(*target->vm(), target)) 235 InspectorInstrumentation::consoleStartRecordingCanvas(*canvasElement, *exec, options); 236 else if (CanvasRenderingContext2D* context2d = JSCanvasRenderingContext2D::toWrapped(*target->vm(), target)) 237 InspectorInstrumentation::consoleStartRecordingCanvas(context2d->canvas(), *exec, options); 238 #if ENABLE(WEBGL) 239 else if (WebGLRenderingContext* contextWebGL = JSWebGLRenderingContext::toWrapped(*target->vm(), target)) { 240 auto canvas = contextWebGL->canvas(); 241 if (WTF::holds_alternative<RefPtr<HTMLCanvasElement>>(canvas)) 242 InspectorInstrumentation::consoleStartRecordingCanvas(*WTF::get<RefPtr<HTMLCanvasElement>>(canvas), *exec, options); 243 } 244 #endif 245 } 246 247 void PageConsoleClient::recordEnd(JSC::ExecState*, Ref<ScriptArguments>&& arguments) 248 { 249 if (arguments->argumentCount() < 1) 250 return; 251 252 JSC::JSObject* target = arguments->argumentAt(0).jsValue().getObject(); 253 if (!target) 254 return; 255 256 if (HTMLCanvasElement* canvasElement = JSHTMLCanvasElement::toWrapped(*target->vm(), target)) 257 InspectorInstrumentation::didFinishRecordingCanvasFrame(*canvasElement, true); 258 else if (CanvasRenderingContext2D* context2d = JSCanvasRenderingContext2D::toWrapped(*target->vm(), target)) 259 InspectorInstrumentation::didFinishRecordingCanvasFrame(context2d->canvas(), true); 260 #if ENABLE(WEBGL) 261 else if (WebGLRenderingContext* contextWebGL = JSWebGLRenderingContext::toWrapped(*target->vm(), target)) { 262 auto canvas = contextWebGL->canvas(); 263 if (WTF::holds_alternative<RefPtr<HTMLCanvasElement>>(canvas)) 264 InspectorInstrumentation::didFinishRecordingCanvasFrame(*WTF::get<RefPtr<HTMLCanvasElement>>(canvas), true); 265 } 266 #endif 267 } 268 209 269 } // namespace WebCore -
trunk/Source/WebCore/page/PageConsoleClient.h
r218603 r225488 75 75 void timeEnd(JSC::ExecState*, const String& title) override; 76 76 void timeStamp(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override; 77 void record(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override; 78 void recordEnd(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override; 77 79 78 80 private: -
trunk/Source/WebCore/workers/WorkerConsoleClient.cpp
r223728 r225488 75 75 void WorkerConsoleClient::timeStamp(JSC::ExecState*, Ref<ScriptArguments>&&) { } 76 76 77 void WorkerConsoleClient::record(JSC::ExecState*, Ref<ScriptArguments>&&) { } 78 void WorkerConsoleClient::recordEnd(JSC::ExecState*, Ref<ScriptArguments>&&) { } 79 77 80 } // namespace WebCore -
trunk/Source/WebCore/workers/WorkerConsoleClient.h
r212448 r225488 51 51 void timeEnd(JSC::ExecState*, const String& title) override; 52 52 void timeStamp(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override; 53 void record(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override; 54 void recordEnd(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override; 53 55 54 56 private: -
trunk/Source/WebInspectorUI/ChangeLog
r225487 r225488 1 2017-12-04 Devin Rousso <webkit@devinrousso.com> 2 3 Web Inspector: provide method for recording CanvasRenderingContext2D from JavaScript 4 https://bugs.webkit.org/show_bug.cgi?id=175166 5 <rdar://problem/34040740> 6 7 Reviewed by Joseph Pecoraro. 8 9 * UserInterface/Controllers/CanvasManager.js: 10 (WI.CanvasManager.prototype.recordingFinished): 11 If a `name` is sent with the payload, use it as the suggested name. 12 13 * UserInterface/Models/NativeFunctionParameters.js: 14 Add `console.record` and `console.recordEnd`. 15 16 * UserInterface/Views/CanvasTabContentView.js: 17 (WI.CanvasTabContentView.prototype.showRepresentedObject): 18 Drive-by: remove logic that toggled the collapsed state of the navigation sidebar, as this 19 was not very controllable by the user and often was aggravating. 20 21 (WI.CanvasTabContentView.prototype._recordingStopped): 22 Only show the recording if it was not started from the console. This can determined by 23 CanvasManager when it recieves a recording if the recording's source is not the same as the 24 current canvas being recorded. 25 1 26 2017-12-04 Matt Baker <mattbaker@apple.com> 2 27 -
trunk/Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js
r224726 r225488 169 169 // Called from WI.CanvasObserver. 170 170 171 this._recordingCanvas = null; 172 173 let canvas = this._canvasIdentifierMap.get(canvasIdentifier); 174 console.assert(canvas); 171 let canvas = this._canvasIdentifierMap.get(canvasIdentifier); 172 console.assert(canvas); 173 174 let fromConsole = canvas !== this._recordingCanvas; 175 if (!fromConsole) 176 this._recordingCanvas = null; 177 175 178 if (!canvas) 176 179 return; … … 180 183 if (recording) { 181 184 recording.source = canvas; 182 recording.createDisplayName( );185 recording.createDisplayName(recordingPayload.name); 183 186 184 187 canvas.recordingCollection.add(recording); 185 188 } 186 189 187 this.dispatchEventToListeners(WI.CanvasManager.Event.RecordingStopped, {canvas, recording });190 this.dispatchEventToListeners(WI.CanvasManager.Event.RecordingStopped, {canvas, recording, fromConsole}); 188 191 } 189 192 -
trunk/Source/WebInspectorUI/UserInterface/Models/NativeFunctionParameters.js
r220119 r225488 174 174 profile: "name", 175 175 profileEnd: "name", 176 record: "object, [options]", 177 recordEnd: "object", 176 178 table: "data, [columns]", 177 179 takeHeapSnapshot: "[label]", -
trunk/Source/WebInspectorUI/UserInterface/Views/CanvasTabContentView.js
r224475 r225488 104 104 if (representedObject instanceof WI.CanvasCollection || representedObject instanceof WI.ShaderProgram) { 105 105 this._overviewNavigationItem.hidden = true; 106 WI.navigationSidebar.collapsed = true;107 106 return; 108 107 } … … 110 109 if (representedObject instanceof WI.Recording) { 111 110 this._overviewNavigationItem.hidden = false; 112 representedObject.actions.then((actions) => { 113 this.navigationSidebarPanel.recording = representedObject; 114 WI.navigationSidebar.collapsed = false; 115 }); 111 this.navigationSidebarPanel.recording = representedObject; 116 112 return; 117 113 } … … 246 242 } 247 243 248 this._recordingAdded(recording); 244 this._recordingAdded(recording, { 245 suppressShowRecording: event.data.fromConsole, 246 }); 249 247 } 250 248 -
trunk/Source/WebInspectorUI/UserInterface/Views/RecordingNavigationSidebarPanel.js
r224389 r225488 59 59 60 60 this._recording.actions.then((actions) => { 61 if (recording !== this._recording) 62 return; 63 61 64 this.contentTreeOutline.element.dataset.indent = Number.countDigits(actions.length); 62 65
Note: See TracChangeset
for help on using the changeset viewer.