<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[237010] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/237010">237010</a></dd>
<dt>Author</dt> <dd>drousso@apple.com</dd>
<dt>Date</dt> <dd>2018-10-10 11:34:49 -0700 (Wed, 10 Oct 2018)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: notify the frontend when a canvas has started recording via console.record
https://bugs.webkit.org/show_bug.cgi?id=190306

Reviewed by Brian Burg.

Source/JavaScriptCore:

* inspector/protocol/Canvas.json:
Add `recordingStarted` event.

* inspector/protocol/Recording.json:
Add `Initiator` enum for determining who started the recording.

Source/WebCore:

Updated existing tests: LayoutTests/inspector/canvas/recording-2d.html
                        LayoutTests/inspector/canvas/recording-bitmaprenderer.html
                        LayoutTests/inspector/canvas/recording-webgl-snapshots.html
                        LayoutTests/inspector/canvas/recording-webgl.html

* inspector/agents/InspectorCanvasAgent.cpp:
(WebCore::InspectorCanvasAgent::startRecording):
(WebCore::InspectorCanvasAgent::consoleStartRecordingCanvas):

* inspector/InspectorCanvas.h:
Default `singleFrame` to false to better match the default behaviour of other `console`
functions (`profile` doesn't stop until `profileEnd` is called, so the same should be true
of `record` and `recordEnd`).

Source/WebInspectorUI:

* UserInterface/Protocol/CanvasObserver.js:
(WI.CanvasObserver.prototype.recordingStarted): Added.

* UserInterface/Protocol/CanvasManager.js:
(WI.CanvasManager.prototype.recordingStarted): Added.

* UserInterface/Models/Canvas.js:
(WI.Canvas.prototype.startRecording):
(WI.Canvas.prototype.recordingStarted): Added.
(WI.Canvas.prototype.recordingFinished):

LayoutTests:

* inspector/canvas/recording-2d.html:
* inspector/canvas/recording-bitmaprenderer.html:
* inspector/canvas/recording-webgl-snapshots.html:
* inspector/canvas/recording-webgl.html:
* inspector/canvas/resources/recording-utilities.js:
(TestPage.registerInitializer.window.startRecording):
Wait to complete the test until the "LastFrame" event is fired, ensuring that any running
commands don't affect the next test case.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsinspectorcanvasrecording2dhtml">trunk/LayoutTests/inspector/canvas/recording-2d.html</a></li>
<li><a href="#trunkLayoutTestsinspectorcanvasrecordingbitmaprendererhtml">trunk/LayoutTests/inspector/canvas/recording-bitmaprenderer.html</a></li>
<li><a href="#trunkLayoutTestsinspectorcanvasrecordingwebglsnapshotshtml">trunk/LayoutTests/inspector/canvas/recording-webgl-snapshots.html</a></li>
<li><a href="#trunkLayoutTestsinspectorcanvasrecordingwebglhtml">trunk/LayoutTests/inspector/canvas/recording-webgl.html</a></li>
<li><a href="#trunkLayoutTestsinspectorcanvasresourcesrecordingutilitiesjs">trunk/LayoutTests/inspector/canvas/resources/recording-utilities.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorprotocolCanvasjson">trunk/Source/JavaScriptCore/inspector/protocol/Canvas.json</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorprotocolRecordingjson">trunk/Source/JavaScriptCore/inspector/protocol/Recording.json</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorCanvash">trunk/Source/WebCore/inspector/InspectorCanvas.h</a></li>
<li><a href="#trunkSourceWebCoreinspectoragentsInspectorCanvasAgentcpp">trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp</a></li>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceControllersCanvasManagerjs">trunk/Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsCanvasjs">trunk/Source/WebInspectorUI/UserInterface/Models/Canvas.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsRecordingjs">trunk/Source/WebInspectorUI/UserInterface/Models/Recording.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceProtocolCanvasObserverjs">trunk/Source/WebInspectorUI/UserInterface/Protocol/CanvasObserver.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (237009 => 237010)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2018-10-10 18:29:44 UTC (rev 237009)
+++ trunk/LayoutTests/ChangeLog 2018-10-10 18:34:49 UTC (rev 237010)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2018-10-10  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: notify the frontend when a canvas has started recording via console.record
+        https://bugs.webkit.org/show_bug.cgi?id=190306
+
+        Reviewed by Brian Burg.
+
+        * inspector/canvas/recording-2d.html:
+        * inspector/canvas/recording-bitmaprenderer.html:
+        * inspector/canvas/recording-webgl-snapshots.html:
+        * inspector/canvas/recording-webgl.html:
+        * inspector/canvas/resources/recording-utilities.js:
+        (TestPage.registerInitializer.window.startRecording):
+        Wait to complete the test until the "LastFrame" event is fired, ensuring that any running
+        commands don't affect the next test case.
+
</ins><span class="cx"> 2018-10-09  Antoine Quint  <graouts@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Remove the frames() timing function
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorcanvasrecording2dhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/canvas/recording-2d.html (237009 => 237010)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/canvas/recording-2d.html     2018-10-10 18:29:44 UTC (rev 237009)
+++ trunk/LayoutTests/inspector/canvas/recording-2d.html        2018-10-10 18:34:49 UTC (rev 237010)
</span><span class="lines">@@ -427,16 +427,7 @@
</span><span class="cx">         name: "Canvas.recording2D.multipleFrames",
</span><span class="cx">         description: "Check that recording data is serialized correctly for multiple frames.",
</span><span class="cx">         test(resolve, reject) {
</span><del>-            let canvas = startRecording(WI.Canvas.ContextType.Canvas2D, resolve, reject, {singleFrame: false});
-
-            InspectorTest.singleFireEventListener("LastFrame", () => {
-                CanvasAgent.stopRecording(canvas.identifier, (error) => {
-                    if (error) {
-                        reject(error);
-                        return;
-                    }
-                });
-            });
</del><ins>+            startRecording(WI.Canvas.ContextType.Canvas2D, resolve, reject, {singleFrame: false});
</ins><span class="cx">         },
</span><span class="cx">     });
</span><span class="cx"> 
</span><span class="lines">@@ -480,15 +471,14 @@
</span><span class="cx">             })
</span><span class="cx">             .then(resolve, reject);
</span><span class="cx"> 
</span><del>-            const singleFrame = true;
-            CanvasAgent.startRecording(canvas.identifier, singleFrame, (error) => {
-                if (error) {
-                    reject(error);
-                    return;
-                }
-
</del><ins>+            canvas.awaitEvent(WI.Canvas.Event.RecordingStarted)
+            .then((event) => {
</ins><span class="cx">                 InspectorTest.evaluateInPage(`performNaNActions()`);
</span><span class="cx">             });
</span><ins>+
+            const singleFrame = true;
+            CanvasAgent.startRecording(canvas.identifier, singleFrame)
+            .catch(reject);
</ins><span class="cx">         },
</span><span class="cx">     });
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorcanvasrecordingbitmaprendererhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/canvas/recording-bitmaprenderer.html (237009 => 237010)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/canvas/recording-bitmaprenderer.html 2018-10-10 18:29:44 UTC (rev 237009)
+++ trunk/LayoutTests/inspector/canvas/recording-bitmaprenderer.html    2018-10-10 18:34:49 UTC (rev 237010)
</span><span class="lines">@@ -95,16 +95,7 @@
</span><span class="cx">         name: "Canvas.recordingBitmapRenderer.multipleFrames",
</span><span class="cx">         description: "Check that recording data is serialized correctly for multiple frames.",
</span><span class="cx">         test(resolve, reject) {
</span><del>-            let canvas = startRecording(WI.Canvas.ContextType.BitmapRenderer, resolve, reject, {singleFrame: false});
-
-            InspectorTest.singleFireEventListener("LastFrame", () => {
-                CanvasAgent.stopRecording(canvas.identifier, (error) => {
-                    if (error) {
-                        reject(error);
-                        return;
-                    }
-                });
-            });
</del><ins>+            startRecording(WI.Canvas.ContextType.BitmapRenderer, resolve, reject, {singleFrame: false});
</ins><span class="cx">         },
</span><span class="cx">     });
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorcanvasrecordingwebglsnapshotshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/canvas/recording-webgl-snapshots.html (237009 => 237010)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/canvas/recording-webgl-snapshots.html        2018-10-10 18:29:44 UTC (rev 237009)
+++ trunk/LayoutTests/inspector/canvas/recording-webgl-snapshots.html   2018-10-10 18:34:49 UTC (rev 237010)
</span><span class="lines">@@ -45,6 +45,10 @@
</span><span class="cx">     runTest();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+function cancelActions() {
+    // This function is expected by "resources/recording-utilities.js".
+}
+
</ins><span class="cx"> function performActions() {
</span><span class="cx">     context.useProgram(program);
</span><span class="cx"> 
</span><span class="lines">@@ -83,6 +87,10 @@
</span><span class="cx">     clearContext();
</span><span class="cx">     drawElements();
</span><span class="cx">     clearContext();
</span><ins>+
+    setTimeout(() => {
+        TestPage.dispatchEventToFrontend("LastFrame");
+    }, 0);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function test() {
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorcanvasrecordingwebglhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/canvas/recording-webgl.html (237009 => 237010)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/canvas/recording-webgl.html  2018-10-10 18:29:44 UTC (rev 237009)
+++ trunk/LayoutTests/inspector/canvas/recording-webgl.html     2018-10-10 18:34:49 UTC (rev 237010)
</span><span class="lines">@@ -521,16 +521,7 @@
</span><span class="cx">         name: "Canvas.recordingWebGL.multipleFrames",
</span><span class="cx">         description: "Check that recording data is serialized correctly for multiple frames.",
</span><span class="cx">         test(resolve, reject) {
</span><del>-            let canvas = startRecording(WI.Canvas.ContextType.WebGL, resolve, reject, {singleFrame: false});
-
-            InspectorTest.singleFireEventListener("LastFrame", () => {
-                CanvasAgent.stopRecording(canvas.identifier, (error) => {
-                    if (error) {
-                        reject(error);
-                        return;
-                    }
-                });
-            });
</del><ins>+            startRecording(WI.Canvas.ContextType.WebGL, resolve, reject, {singleFrame: false});
</ins><span class="cx">         },
</span><span class="cx">     });
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorcanvasresourcesrecordingutilitiesjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/canvas/resources/recording-utilities.js (237009 => 237010)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/canvas/resources/recording-utilities.js      2018-10-10 18:29:44 UTC (rev 237009)
+++ trunk/LayoutTests/inspector/canvas/resources/recording-utilities.js 2018-10-10 18:34:49 UTC (rev 237010)
</span><span class="lines">@@ -81,6 +81,24 @@
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        let stopped = false;
+        let swizzled = false;
+        let lastFrame = false;
+
+        InspectorTest.awaitEvent("LastFrame")
+        .then((event) => {
+            lastFrame = true;
+
+            if (!stopped)
+                CanvasAgent.stopRecording(canvas.identifier).catch(reject);
+            else {
+                InspectorTest.evaluateInPage(`cancelActions()`).catch(reject);
+
+                if (swizzled)
+                    resolve();
+            }
+        });
+
</ins><span class="cx">         let bufferUsed = 0;
</span><span class="cx">         let frameCount = 0;
</span><span class="cx">         function handleRecordingProgress(event) {
</span><span class="lines">@@ -93,10 +111,10 @@
</span><span class="cx">         canvas.addEventListener(WI.Canvas.Event.RecordingProgress, handleRecordingProgress);
</span><span class="cx"> 
</span><span class="cx">         canvas.awaitEvent(WI.Canvas.Event.RecordingStopped).then((event) => {
</span><ins>+            stopped = true;
+
</ins><span class="cx">             canvas.removeEventListener(WI.Canvas.Event.RecordingProgress, handleRecordingProgress);
</span><span class="cx"> 
</span><del>-            InspectorTest.evaluateInPage(`cancelActions()`);
-
</del><span class="cx">             let recording = event.data.recording;
</span><span class="cx">             InspectorTest.assert(recording.source === canvas, "Recording should be of the given canvas.");
</span><span class="cx">             InspectorTest.assert(recording.source.contextType === type, `Recording should be of a canvas with type "${type}".`);
</span><span class="lines">@@ -103,21 +121,23 @@
</span><span class="cx">             InspectorTest.assert(recording.source.recordingCollection.has(recording), "Recording should be in the canvas' list of recordings.");
</span><span class="cx">             InspectorTest.assert(recording.frames.length === frameCount, `Recording should have ${frameCount} frames.`)
</span><span class="cx"> 
</span><del>-            return Promise.all(recording.actions.map((action) => action.swizzle(recording))).then(() => {
</del><ins>+            Promise.all(recording.actions.map((action) => action.swizzle(recording))).then(() => {
+                swizzled = true;
+
</ins><span class="cx">                 logRecording(recording, type);
</span><ins>+
+                if (lastFrame) {
+                    InspectorTest.evaluateInPage(`cancelActions()`)
+                    .then(resolve, reject);
+                }
</ins><span class="cx">             });
</span><del>-        }).then(resolve, reject);
</del><ins>+        });
</ins><span class="cx"> 
</span><del>-        CanvasAgent.startRecording(canvas.identifier, singleFrame, memoryLimit, (error) => {
-            if (error) {
-                reject(error);
-                return;
-            }
-
-            InspectorTest.evaluateInPage(`performActions()`);
</del><ins>+        canvas.awaitEvent(WI.Canvas.Event.RecordingStarted).then((event) => {
+            InspectorTest.evaluateInPage(`performActions()`).catch(reject);
</ins><span class="cx">         });
</span><span class="cx"> 
</span><del>-        return canvas;
</del><ins>+        CanvasAgent.startRecording(canvas.identifier, singleFrame, memoryLimit).catch(reject);
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     window.consoleRecord = function(type, resolve, reject) {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (237009 => 237010)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog    2018-10-10 18:29:44 UTC (rev 237009)
+++ trunk/Source/JavaScriptCore/ChangeLog       2018-10-10 18:34:49 UTC (rev 237010)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2018-10-10  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: notify the frontend when a canvas has started recording via console.record
+        https://bugs.webkit.org/show_bug.cgi?id=190306
+
+        Reviewed by Brian Burg.
+
+        * inspector/protocol/Canvas.json:
+        Add `recordingStarted` event.
+
+        * inspector/protocol/Recording.json:
+        Add `Initiator` enum for determining who started the recording.
+
</ins><span class="cx"> 2018-10-10  Yusuke Suzuki  <yusukesuzuki@slowstart.org>
</span><span class="cx"> 
</span><span class="cx">         [JSC] Rename createXXX to tryCreateXXX if it can return RefPtr
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorprotocolCanvasjson"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/protocol/Canvas.json (237009 => 237010)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/protocol/Canvas.json       2018-10-10 18:29:44 UTC (rev 237009)
+++ trunk/Source/JavaScriptCore/inspector/protocol/Canvas.json  2018-10-10 18:34:49 UTC (rev 237010)
</span><span class="lines">@@ -191,6 +191,13 @@
</span><span class="cx">             ]
</span><span class="cx">         },
</span><span class="cx">         {
</span><ins>+            "name": "recordingStarted",
+            "parameters": [
+                { "name": "canvasId", "$ref": "CanvasId" },
+                { "name": "initiator", "$ref": "Recording.Initiator" }
+            ]
+        },
+        {
</ins><span class="cx">             "name": "recordingProgress",
</span><span class="cx">             "parameters": [
</span><span class="cx">                 { "name": "canvasId", "$ref": "CanvasId" },
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorprotocolRecordingjson"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/protocol/Recording.json (237009 => 237010)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/protocol/Recording.json    2018-10-10 18:29:44 UTC (rev 237009)
+++ trunk/Source/JavaScriptCore/inspector/protocol/Recording.json       2018-10-10 18:34:49 UTC (rev 237010)
</span><span class="lines">@@ -9,6 +9,11 @@
</span><span class="cx">             "description": "The type of the recording."
</span><span class="cx">         },
</span><span class="cx">         {
</span><ins>+            "id": "Initiator",
+            "type": "string",
+            "enum": ["frontend", "console"]
+        },
+        {
</ins><span class="cx">             "id": "InitialState",
</span><span class="cx">             "type": "object",
</span><span class="cx">             "description": "Information about the initial state of the recorded object.",
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (237009 => 237010)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2018-10-10 18:29:44 UTC (rev 237009)
+++ trunk/Source/WebCore/ChangeLog      2018-10-10 18:34:49 UTC (rev 237010)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2018-10-10  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: notify the frontend when a canvas has started recording via console.record
+        https://bugs.webkit.org/show_bug.cgi?id=190306
+
+        Reviewed by Brian Burg.
+
+        Updated existing tests: LayoutTests/inspector/canvas/recording-2d.html
+                                LayoutTests/inspector/canvas/recording-bitmaprenderer.html
+                                LayoutTests/inspector/canvas/recording-webgl-snapshots.html
+                                LayoutTests/inspector/canvas/recording-webgl.html
+
+        * inspector/agents/InspectorCanvasAgent.cpp:
+        (WebCore::InspectorCanvasAgent::startRecording):
+        (WebCore::InspectorCanvasAgent::consoleStartRecordingCanvas):
+
+        * inspector/InspectorCanvas.h:
+        Default `singleFrame` to false to better match the default behaviour of other `console`
+        functions (`profile` doesn't stop until `profileEnd` is called, so the same should be true
+        of `record` and `recordEnd`).
+
</ins><span class="cx"> 2018-10-10  Yusuke Suzuki  <yusukesuzuki@slowstart.org>
</span><span class="cx"> 
</span><span class="cx">         [JSC] Rename createXXX to tryCreateXXX if it can return RefPtr
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorCanvash"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorCanvas.h (237009 => 237010)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorCanvas.h 2018-10-10 18:29:44 UTC (rev 237009)
+++ trunk/Source/WebCore/inspector/InspectorCanvas.h    2018-10-10 18:34:49 UTC (rev 237010)
</span><span class="lines">@@ -116,7 +116,7 @@
</span><span class="cx">     MonotonicTime m_currentFrameStartTime { MonotonicTime::nan() };
</span><span class="cx">     size_t m_bufferLimit { 100 * 1024 * 1024 };
</span><span class="cx">     size_t m_bufferUsed { 0 };
</span><del>-    bool m_singleFrame { true };
</del><ins>+    bool m_singleFrame { false };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectoragentsInspectorCanvasAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp (237009 => 237010)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp   2018-10-10 18:29:44 UTC (rev 237009)
+++ trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp      2018-10-10 18:34:49 UTC (rev 237010)
</span><span class="lines">@@ -279,6 +279,8 @@
</span><span class="cx">         inspectorCanvas->setBufferLimit(*memoryLimit);
</span><span class="cx"> 
</span><span class="cx">     inspectorCanvas->context().setCallTracingActive(true);
</span><ins>+
+    m_frontendDispatcher->recordingStarted(inspectorCanvas->identifier(), Inspector::Protocol::Recording::Initiator::Frontend);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void InspectorCanvasAgent::stopRecording(ErrorString& errorString, const String& canvasId)
</span><span class="lines">@@ -577,6 +579,8 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     inspectorCanvas->context().setCallTracingActive(true);
</span><ins>+
+    m_frontendDispatcher->recordingStarted(inspectorCanvas->identifier(), Inspector::Protocol::Recording::Initiator::Console);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WEBGL)
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (237009 => 237010)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog    2018-10-10 18:29:44 UTC (rev 237009)
+++ trunk/Source/WebInspectorUI/ChangeLog       2018-10-10 18:34:49 UTC (rev 237010)
</span><span class="lines">@@ -1,5 +1,23 @@
</span><span class="cx"> 2018-10-10  Devin Rousso  <drousso@apple.com>
</span><span class="cx"> 
</span><ins>+        Web Inspector: notify the frontend when a canvas has started recording via console.record
+        https://bugs.webkit.org/show_bug.cgi?id=190306
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Protocol/CanvasObserver.js:
+        (WI.CanvasObserver.prototype.recordingStarted): Added.
+
+        * UserInterface/Protocol/CanvasManager.js:
+        (WI.CanvasManager.prototype.recordingStarted): Added.
+
+        * UserInterface/Models/Canvas.js:
+        (WI.Canvas.prototype.startRecording):
+        (WI.Canvas.prototype.recordingStarted): Added.
+        (WI.Canvas.prototype.recordingFinished):
+
+2018-10-10  Devin Rousso  <drousso@apple.com>
+
</ins><span class="cx">         Web Inspector: indent all network entries when "Group by Node" is checked
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=190388
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersCanvasManagerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js (237009 => 237010)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js   2018-10-10 18:29:44 UTC (rev 237009)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js      2018-10-10 18:34:49 UTC (rev 237010)
</span><span class="lines">@@ -127,6 +127,18 @@
</span><span class="cx">         canvas.cssCanvasClientNodesChanged();
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    recordingStarted(canvasIdentifier, initiator)
+    {
+        // Called from WI.CanvasObserver.
+
+        let canvas = this._canvasIdentifierMap.get(canvasIdentifier);
+        console.assert(canvas);
+        if (!canvas)
+            return;
+
+        canvas.recordingStarted(initiator);
+    }
+
</ins><span class="cx">     recordingProgress(canvasIdentifier, framesPayload, bufferUsed)
</span><span class="cx">     {
</span><span class="cx">         // Called from WI.CanvasObserver.
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsCanvasjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Canvas.js (237009 => 237010)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/Canvas.js       2018-10-10 18:29:44 UTC (rev 237009)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Canvas.js  2018-10-10 18:34:49 UTC (rev 237010)
</span><span class="lines">@@ -275,7 +275,12 @@
</span><span class="cx">                 return;
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            this._recordingState = WI.Canvas.RecordingState.Active;
</del><ins>+            this._recordingState = WI.Canvas.RecordingState.ActiveFrontend;
+
+            // COMPATIBILITY (iOS 12.1): Canvas.event.recordingStarted did not exist yet
+            if (CanvasAgent.hasEvent("recordingStarted"))
+                return;
+
</ins><span class="cx">             this._recordingFrames = [];
</span><span class="cx">             this._recordingBufferUsed = 0;
</span><span class="cx"> 
</span><span class="lines">@@ -321,6 +326,23 @@
</span><span class="cx">         this.dispatchEventToListeners(WI.Canvas.Event.CSSCanvasClientNodesChanged);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    recordingStarted(initiator)
+    {
+        // Called from WI.CanvasManager.
+
+        if (initiator === WI.Recording.Initiator.Console)
+            this._recordingState = WI.Canvas.RecordingState.ActiveConsole;
+        else {
+            console.assert(initiator === WI.Recording.Initiator.Frontend);
+            this._recordingState = WI.Canvas.RecordingState.ActiveFrontend;
+        }
+
+        this._recordingFrames = [];
+        this._recordingBufferUsed = 0;
+
+        this.dispatchEventToListeners(WI.Canvas.Event.RecordingStarted);
+    }
+
</ins><span class="cx">     recordingProgress(framesPayload, bufferUsed)
</span><span class="cx">     {
</span><span class="cx">         // Called from WI.CanvasManager.
</span><span class="lines">@@ -336,8 +358,12 @@
</span><span class="cx">     {
</span><span class="cx">         // Called from WI.CanvasManager.
</span><span class="cx"> 
</span><del>-        let fromConsole = !this.recordingActive;
</del><ins>+        let fromConsole = this._recordingState === WI.Canvas.RecordingState.ActiveConsole;
</ins><span class="cx"> 
</span><ins>+        // COMPATIBILITY (iOS 12.1): Canvas.event.recordingStarted did not exist yet
+        if (!fromConsole && !CanvasAgent.hasEvent("recordingStarted"))
+            fromConsole = !this.recordingActive;
+
</ins><span class="cx">         let recording = recordingPayload ? WI.Recording.fromPayload(recordingPayload, this._recordingFrames) : null;
</span><span class="cx">         if (recording) {
</span><span class="cx">             recording.source = this;
</span><span class="lines">@@ -377,7 +403,8 @@
</span><span class="cx"> 
</span><span class="cx"> WI.Canvas.RecordingState = {
</span><span class="cx">     Inactive: "canvas-recording-state-inactive",
</span><del>-    Active: "canvas-recording-state-active",
</del><ins>+    ActiveFrontend: "canvas-recording-state-active-frontend",
+    ActiveConsole: "canvas-recording-state-active-console",
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> WI.Canvas.Event = {
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsRecordingjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Recording.js (237009 => 237010)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/Recording.js    2018-10-10 18:29:44 UTC (rev 237009)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Recording.js       2018-10-10 18:34:49 UTC (rev 237010)
</span><span class="lines">@@ -486,6 +486,11 @@
</span><span class="cx">     CanvasWebGL: "canvas-webgl",
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+WI.Recording.Initiator = {
+    Frontend: "frontend",
+    Console: "console",
+};
+
</ins><span class="cx"> // Keep this in sync with WebCore::RecordingSwizzleTypes.
</span><span class="cx"> WI.Recording.Swizzle = {
</span><span class="cx">     None: 0,
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceProtocolCanvasObserverjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/CanvasObserver.js (237009 => 237010)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Protocol/CanvasObserver.js     2018-10-10 18:29:44 UTC (rev 237009)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/CanvasObserver.js        2018-10-10 18:34:49 UTC (rev 237010)
</span><span class="lines">@@ -47,6 +47,11 @@
</span><span class="cx">         WI.canvasManager.cssCanvasClientNodesChanged(canvasId);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    recordingStarted(canvasId, initiator)
+    {
+        WI.canvasManager.recordingStarted(canvasId, initiator);
+    }
+
</ins><span class="cx">     recordingProgress(canvasId, frames, bufferUsed)
</span><span class="cx">     {
</span><span class="cx">         WI.canvasManager.recordingProgress(canvasId, frames, bufferUsed);
</span></span></pre>
</div>
</div>

</body>
</html>