Ignore:
Timestamp:
Dec 4, 2017, 1:40:55 PM (7 years ago)
Author:
[email protected]
Message:

Web Inspector: provide method for recording CanvasRenderingContext2D from JavaScript
https://bugs.webkit.org/show_bug.cgi?id=175166
<rdar://problem/34040740>

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

  • inspector/protocol/Recording.json:

Add optional name that will be used by the frontend for uniquely identifying the Recording.

  • inspector/JSGlobalObjectConsoleClient.h:
  • inspector/JSGlobalObjectConsoleClient.cpp:

(Inspector::JSGlobalObjectConsoleClient::record):
(Inspector::JSGlobalObjectConsoleClient::recordEnd):

  • runtime/ConsoleClient.h:
  • runtime/ConsoleObject.cpp:

(JSC::ConsoleObject::finishCreation):
(JSC::consoleProtoFuncRecord):
(JSC::consoleProtoFuncRecordEnd):

Source/WebCore:

No new tests, updated existing tests.

  • inspector/InspectorCanvas.h:
  • inspector/InspectorCanvas.cpp:

(WebCore::InspectorCanvas::resetRecordingData):

  • inspector/InspectorCanvasAgent.h:
  • inspector/InspectorCanvasAgent.cpp:

(WebCore::InspectorCanvasAgent::didFinishRecordingCanvasFrame):
(WebCore::InspectorCanvasAgent::consoleStartRecordingCanvas):

  • inspector/InspectorInstrumentation.h:
  • inspector/InspectorInstrumentation.cpp:

(WebCore::InspectorInstrumentation::consoleStartRecordingCanvas):
(WebCore::InspectorInstrumentation::consoleStartRecordingCanvasImpl):

  • page/PageConsoleClient.h:
  • page/PageConsoleClient.cpp:

(WebCore::PageConsoleClient::record):
(WebCore::PageConsoleClient::recordEnd):

  • workers/WorkerConsoleClient.h:
  • workers/WorkerConsoleClient.cpp:

(WebCore::WorkerConsoleClient::record):
(WebCore::WorkerConsoleClient::recordEnd):

Source/WebInspectorUI:

  • UserInterface/Controllers/CanvasManager.js:

(WI.CanvasManager.prototype.recordingFinished):
If a name is sent with the payload, use it as the suggested name.

  • UserInterface/Models/NativeFunctionParameters.js:

Add console.record and console.recordEnd.

  • UserInterface/Views/CanvasTabContentView.js:

(WI.CanvasTabContentView.prototype.showRepresentedObject):
Drive-by: remove logic that toggled the collapsed state of the navigation sidebar, as this
was not very controllable by the user and often was aggravating.

(WI.CanvasTabContentView.prototype._recordingStopped):
Only show the recording if it was not started from the console. This can determined by
CanvasManager when it recieves a recording if the recording's source is not the same as the
current canvas being recorded.

LayoutTests:

  • inspector/canvas/recording-2d-expected.txt:
  • inspector/canvas/recording-2d.html:

(performConsoleRecording):

  • inspector/canvas/recording-webgl-expected.txt:
  • inspector/canvas/recording-webgl.html:

(performConsoleRecording):

  • inspector/canvas/resources/recording-utilities.js:

(TestPage.registerInitializer):

  • js/console-expected.txt:
  • js/console.html:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/ConsoleObject.cpp

    r222473 r225488  
    5858static EncodedJSValue JSC_HOST_CALL consoleProtoFuncGroupCollapsed(ExecState*);
    5959static EncodedJSValue JSC_HOST_CALL consoleProtoFuncGroupEnd(ExecState*);
     60static EncodedJSValue JSC_HOST_CALL consoleProtoFuncRecord(ExecState*);
     61static EncodedJSValue JSC_HOST_CALL consoleProtoFuncRecordEnd(ExecState*);
    6062
    6163const ClassInfo ConsoleObject::s_info = { "Console", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(ConsoleObject) };
     
    9698    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("groupCollapsed", consoleProtoFuncGroupCollapsed, static_cast<unsigned>(PropertyAttribute::None), 0);
    9799    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);
    98102}
    99103
     
    368372}
    369373
     374static 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
     384static 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
    370394} // namespace JSC
Note: See TracChangeset for help on using the changeset viewer.