| Index: third_party/WebKit/Source/devtools/front_end/components_lazy/FilmStripModel.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/components_lazy/FilmStripModel.js b/third_party/WebKit/Source/devtools/front_end/components_lazy/FilmStripModel.js
|
| index 3472e161e72544fec37d754fc5c54f3d425f170a..09f1ec7ef8fcf2a57dec0b10d146d30ac97701bb 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/components_lazy/FilmStripModel.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/components_lazy/FilmStripModel.js
|
| @@ -3,100 +3,98 @@
|
| * Use of this source code is governed by a BSD-style license that can be
|
| * found in the LICENSE file.
|
| */
|
| -
|
| /**
|
| - * @constructor
|
| - * @param {!WebInspector.TracingModel} tracingModel
|
| - * @param {number=} zeroTime
|
| + * @unrestricted
|
| */
|
| -WebInspector.FilmStripModel = function(tracingModel, zeroTime)
|
| -{
|
| +WebInspector.FilmStripModel = class {
|
| + /**
|
| + * @param {!WebInspector.TracingModel} tracingModel
|
| + * @param {number=} zeroTime
|
| + */
|
| + constructor(tracingModel, zeroTime) {
|
| this.reset(tracingModel, zeroTime);
|
| + }
|
| +
|
| + /**
|
| + * @param {!WebInspector.TracingModel} tracingModel
|
| + * @param {number=} zeroTime
|
| + */
|
| + reset(tracingModel, zeroTime) {
|
| + this._zeroTime = zeroTime || tracingModel.minimumRecordTime();
|
| + this._spanTime = tracingModel.maximumRecordTime() - this._zeroTime;
|
| +
|
| + /** @type {!Array<!WebInspector.FilmStripModel.Frame>} */
|
| + this._frames = [];
|
| + var browserMain = WebInspector.TracingModel.browserMainThread(tracingModel);
|
| + if (!browserMain)
|
| + return;
|
| +
|
| + var events = browserMain.events();
|
| + for (var i = 0; i < events.length; ++i) {
|
| + var event = events[i];
|
| + if (event.startTime < this._zeroTime)
|
| + continue;
|
| + if (!event.hasCategory(WebInspector.FilmStripModel._category))
|
| + continue;
|
| + if (event.name === WebInspector.FilmStripModel.TraceEvents.CaptureFrame) {
|
| + var data = event.args['data'];
|
| + if (data)
|
| + this._frames.push(WebInspector.FilmStripModel.Frame._fromEvent(this, event, this._frames.length));
|
| + } else if (event.name === WebInspector.FilmStripModel.TraceEvents.Screenshot) {
|
| + this._frames.push(WebInspector.FilmStripModel.Frame._fromSnapshot(
|
| + this, /** @type {!WebInspector.TracingModel.ObjectSnapshot} */ (event), this._frames.length));
|
| + }
|
| + }
|
| + }
|
| +
|
| + /**
|
| + * @return {!Array<!WebInspector.FilmStripModel.Frame>}
|
| + */
|
| + frames() {
|
| + return this._frames;
|
| + }
|
| +
|
| + /**
|
| + * @return {number}
|
| + */
|
| + zeroTime() {
|
| + return this._zeroTime;
|
| + }
|
| +
|
| + /**
|
| + * @return {number}
|
| + */
|
| + spanTime() {
|
| + return this._spanTime;
|
| + }
|
| +
|
| + /**
|
| + * @param {number} timestamp
|
| + * @return {?WebInspector.FilmStripModel.Frame}
|
| + */
|
| + frameByTimestamp(timestamp) {
|
| + var index = this._frames.upperBound(timestamp, (timestamp, frame) => timestamp - frame.timestamp) - 1;
|
| + return index >= 0 ? this._frames[index] : null;
|
| + }
|
| };
|
|
|
| -WebInspector.FilmStripModel._category = "disabled-by-default-devtools.screenshot";
|
| +WebInspector.FilmStripModel._category = 'disabled-by-default-devtools.screenshot';
|
|
|
| WebInspector.FilmStripModel.TraceEvents = {
|
| - CaptureFrame: "CaptureFrame",
|
| - Screenshot: "Screenshot"
|
| -};
|
| -
|
| -WebInspector.FilmStripModel.prototype = {
|
| - /**
|
| - * @param {!WebInspector.TracingModel} tracingModel
|
| - * @param {number=} zeroTime
|
| - */
|
| - reset: function(tracingModel, zeroTime)
|
| - {
|
| - this._zeroTime = zeroTime || tracingModel.minimumRecordTime();
|
| - this._spanTime = tracingModel.maximumRecordTime() - this._zeroTime;
|
| -
|
| - /** @type {!Array<!WebInspector.FilmStripModel.Frame>} */
|
| - this._frames = [];
|
| - var browserMain = WebInspector.TracingModel.browserMainThread(tracingModel);
|
| - if (!browserMain)
|
| - return;
|
| -
|
| - var events = browserMain.events();
|
| - for (var i = 0; i < events.length; ++i) {
|
| - var event = events[i];
|
| - if (event.startTime < this._zeroTime)
|
| - continue;
|
| - if (!event.hasCategory(WebInspector.FilmStripModel._category))
|
| - continue;
|
| - if (event.name === WebInspector.FilmStripModel.TraceEvents.CaptureFrame) {
|
| - var data = event.args["data"];
|
| - if (data)
|
| - this._frames.push(WebInspector.FilmStripModel.Frame._fromEvent(this, event, this._frames.length));
|
| - } else if (event.name === WebInspector.FilmStripModel.TraceEvents.Screenshot) {
|
| - this._frames.push(WebInspector.FilmStripModel.Frame._fromSnapshot(this, /** @type {!WebInspector.TracingModel.ObjectSnapshot} */ (event), this._frames.length));
|
| - }
|
| - }
|
| - },
|
| -
|
| - /**
|
| - * @return {!Array<!WebInspector.FilmStripModel.Frame>}
|
| - */
|
| - frames: function()
|
| - {
|
| - return this._frames;
|
| - },
|
| -
|
| - /**
|
| - * @return {number}
|
| - */
|
| - zeroTime: function()
|
| - {
|
| - return this._zeroTime;
|
| - },
|
| -
|
| - /**
|
| - * @return {number}
|
| - */
|
| - spanTime: function()
|
| - {
|
| - return this._spanTime;
|
| - },
|
| -
|
| - /**
|
| - * @param {number} timestamp
|
| - * @return {?WebInspector.FilmStripModel.Frame}
|
| - */
|
| - frameByTimestamp: function(timestamp)
|
| - {
|
| - var index = this._frames.upperBound(timestamp, (timestamp, frame) => timestamp - frame.timestamp) - 1;
|
| - return index >= 0 ? this._frames[index] : null;
|
| - }
|
| + CaptureFrame: 'CaptureFrame',
|
| + Screenshot: 'Screenshot'
|
| };
|
|
|
| /**
|
| - * @constructor
|
| - * @param {!WebInspector.FilmStripModel} model
|
| - * @param {number} timestamp
|
| - * @param {number} index
|
| + * @unrestricted
|
| */
|
| -WebInspector.FilmStripModel.Frame = function(model, timestamp, index)
|
| -{
|
| +WebInspector.FilmStripModel.Frame = class {
|
| + /**
|
| + * @param {!WebInspector.FilmStripModel} model
|
| + * @param {number} timestamp
|
| + * @param {number} index
|
| + */
|
| + constructor(model, timestamp, index) {
|
| this._model = model;
|
| this.timestamp = timestamp;
|
| this.index = index;
|
| @@ -104,51 +102,48 @@ WebInspector.FilmStripModel.Frame = function(model, timestamp, index)
|
| this._imageData = null;
|
| /** @type {?WebInspector.TracingModel.ObjectSnapshot} */
|
| this._snapshot = null;
|
| -};
|
| -
|
| -/**
|
| - * @param {!WebInspector.FilmStripModel} model
|
| - * @param {!WebInspector.TracingModel.Event} event
|
| - * @param {number} index
|
| - * @return {!WebInspector.FilmStripModel.Frame}
|
| - */
|
| -WebInspector.FilmStripModel.Frame._fromEvent = function(model, event, index)
|
| -{
|
| + }
|
| +
|
| + /**
|
| + * @param {!WebInspector.FilmStripModel} model
|
| + * @param {!WebInspector.TracingModel.Event} event
|
| + * @param {number} index
|
| + * @return {!WebInspector.FilmStripModel.Frame}
|
| + */
|
| + static _fromEvent(model, event, index) {
|
| var frame = new WebInspector.FilmStripModel.Frame(model, event.startTime, index);
|
| - frame._imageData = event.args["data"];
|
| + frame._imageData = event.args['data'];
|
| return frame;
|
| -};
|
| -
|
| -/**
|
| - * @param {!WebInspector.FilmStripModel} model
|
| - * @param {!WebInspector.TracingModel.ObjectSnapshot} snapshot
|
| - * @param {number} index
|
| - * @return {!WebInspector.FilmStripModel.Frame}
|
| - */
|
| -WebInspector.FilmStripModel.Frame._fromSnapshot = function(model, snapshot, index)
|
| -{
|
| + }
|
| +
|
| + /**
|
| + * @param {!WebInspector.FilmStripModel} model
|
| + * @param {!WebInspector.TracingModel.ObjectSnapshot} snapshot
|
| + * @param {number} index
|
| + * @return {!WebInspector.FilmStripModel.Frame}
|
| + */
|
| + static _fromSnapshot(model, snapshot, index) {
|
| var frame = new WebInspector.FilmStripModel.Frame(model, snapshot.startTime, index);
|
| frame._snapshot = snapshot;
|
| return frame;
|
| + }
|
| +
|
| + /**
|
| + * @return {!WebInspector.FilmStripModel}
|
| + */
|
| + model() {
|
| + return this._model;
|
| + }
|
| +
|
| + /**
|
| + * @return {!Promise<?string>}
|
| + */
|
| + imageDataPromise() {
|
| + if (this._imageData || !this._snapshot)
|
| + return Promise.resolve(this._imageData);
|
| +
|
| + return /** @type {!Promise<?string>} */ (this._snapshot.objectPromise());
|
| + }
|
| };
|
|
|
| -WebInspector.FilmStripModel.Frame.prototype = {
|
| - /**
|
| - * @return {!WebInspector.FilmStripModel}
|
| - */
|
| - model: function()
|
| - {
|
| - return this._model;
|
| - },
|
| -
|
| - /**
|
| - * @return {!Promise<?string>}
|
| - */
|
| - imageDataPromise: function()
|
| - {
|
| - if (this._imageData || !this._snapshot)
|
| - return Promise.resolve(this._imageData);
|
| -
|
| - return /** @type {!Promise<?string>} */ (this._snapshot.objectPromise());
|
| - }
|
| -};
|
| +
|
|
|