зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1279302 - Decouple the ReflowFront from the ReflowActor; r=ejpbruel
This commit is contained in:
Родитель
9bc92c22aa
Коммит
323a754b9a
|
@ -10,7 +10,7 @@ const {Cc, Ci} = require("chrome");
|
|||
const {Task} = require("devtools/shared/task");
|
||||
const {InplaceEditor, editableItem} =
|
||||
require("devtools/client/shared/inplace-editor");
|
||||
const {ReflowFront} = require("devtools/server/actors/layout");
|
||||
const {ReflowFront} = require("devtools/shared/fronts/layout");
|
||||
const {LocalizationHelper} = require("devtools/client/shared/l10n");
|
||||
const {getCssProperties} = require("devtools/shared/fronts/css-properties");
|
||||
|
||||
|
|
|
@ -31,28 +31,12 @@ const {method, Arg} = protocol;
|
|||
const events = require("sdk/event/core");
|
||||
const Heritage = require("sdk/core/heritage");
|
||||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
const {reflowSpec} = require("devtools/shared/specs/layout");
|
||||
|
||||
/**
|
||||
* The reflow actor tracks reflows and emits events about them.
|
||||
*/
|
||||
var ReflowActor = exports.ReflowActor = protocol.ActorClass({
|
||||
typeName: "reflow",
|
||||
|
||||
events: {
|
||||
/**
|
||||
* The reflows event is emitted when reflows have been detected. The event
|
||||
* is sent with an array of reflows that occured. Each item has the
|
||||
* following properties:
|
||||
* - start {Number}
|
||||
* - end {Number}
|
||||
* - isInterruptible {Boolean}
|
||||
*/
|
||||
"reflows": {
|
||||
type: "reflows",
|
||||
reflows: Arg(0, "array:json")
|
||||
}
|
||||
},
|
||||
|
||||
var ReflowActor = exports.ReflowActor = protocol.ActorClassWithSpec(reflowSpec, {
|
||||
initialize: function (conn, tabActor) {
|
||||
protocol.Actor.prototype.initialize.call(this, conn);
|
||||
|
||||
|
@ -85,24 +69,24 @@ var ReflowActor = exports.ReflowActor = protocol.ActorClass({
|
|||
* This is a oneway method, do not expect a response and it won't return a
|
||||
* promise.
|
||||
*/
|
||||
start: method(function () {
|
||||
start: function () {
|
||||
if (!this._isStarted) {
|
||||
this.observer.on("reflows", this._onReflow);
|
||||
this._isStarted = true;
|
||||
}
|
||||
}, {oneway: true}),
|
||||
},
|
||||
|
||||
/**
|
||||
* Stop tracking reflows and sending events to clients about them.
|
||||
* This is a oneway method, do not expect a response and it won't return a
|
||||
* promise.
|
||||
*/
|
||||
stop: method(function () {
|
||||
stop: function () {
|
||||
if (this._isStarted) {
|
||||
this.observer.off("reflows", this._onReflow);
|
||||
this._isStarted = false;
|
||||
}
|
||||
}, {oneway: true}),
|
||||
},
|
||||
|
||||
_onReflow: function (event, reflows) {
|
||||
if (this._isStarted) {
|
||||
|
@ -111,25 +95,6 @@ var ReflowActor = exports.ReflowActor = protocol.ActorClass({
|
|||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Usage example of the reflow front:
|
||||
*
|
||||
* let front = ReflowFront(toolbox.target.client, toolbox.target.form);
|
||||
* front.on("reflows", this._onReflows);
|
||||
* front.start();
|
||||
* // now wait for events to come
|
||||
*/
|
||||
exports.ReflowFront = protocol.FrontClass(ReflowActor, {
|
||||
initialize: function (client, {reflowActor}) {
|
||||
protocol.Front.prototype.initialize.call(this, client, {actor: reflowActor});
|
||||
this.manage(this);
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
protocol.Front.prototype.destroy.call(this);
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Base class for all sorts of observers that need to listen to events on the
|
||||
* tabActor's windows.
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
const {reflowSpec} = require("devtools/shared/specs/layout");
|
||||
const protocol = require("devtools/shared/protocol");
|
||||
|
||||
/**
|
||||
* Usage example of the reflow front:
|
||||
*
|
||||
* let front = ReflowFront(toolbox.target.client, toolbox.target.form);
|
||||
* front.on("reflows", this._onReflows);
|
||||
* front.start();
|
||||
* // now wait for events to come
|
||||
*/
|
||||
const ReflowFront = protocol.FrontClassWithSpec(reflowSpec, {
|
||||
initialize: function (client, {reflowActor}) {
|
||||
protocol.Front.prototype.initialize.call(this, client, {actor: reflowActor});
|
||||
this.manage(this);
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
protocol.Front.prototype.destroy.call(this);
|
||||
},
|
||||
});
|
||||
|
||||
exports.ReflowFront = ReflowFront;
|
|
@ -18,6 +18,7 @@ DevToolsModules(
|
|||
'gcli.js',
|
||||
'highlighters.js',
|
||||
'inspector.js',
|
||||
'layout.js',
|
||||
'preference.js',
|
||||
'promises.js',
|
||||
'settings.js',
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
const {Arg, generateActorSpec} = require("devtools/shared/protocol");
|
||||
|
||||
const reflowSpec = generateActorSpec({
|
||||
typeName: "reflow",
|
||||
|
||||
events: {
|
||||
/**
|
||||
* The reflows event is emitted when reflows have been detected. The event
|
||||
* is sent with an array of reflows that occured. Each item has the
|
||||
* following properties:
|
||||
* - start {Number}
|
||||
* - end {Number}
|
||||
* - isInterruptible {Boolean}
|
||||
*/
|
||||
reflows: {
|
||||
type: "reflows",
|
||||
reflows: Arg(0, "array:json")
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
start: {oneway: true},
|
||||
stop: {oneway: true},
|
||||
},
|
||||
});
|
||||
|
||||
exports.reflowSpec = reflowSpec;
|
|
@ -22,6 +22,7 @@ DevToolsModules(
|
|||
'heap-snapshot-file.js',
|
||||
'highlighters.js',
|
||||
'inspector.js',
|
||||
'layout.js',
|
||||
'node.js',
|
||||
'preference.js',
|
||||
'promises.js',
|
||||
|
|
Загрузка…
Ссылка в новой задаче