зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1265722 - Decouple InspectorFront from InspectorActor;r=jryans
This commit is contained in:
Родитель
bc22d2f478
Коммит
02ce04286e
|
@ -57,7 +57,7 @@ loader.lazyRequireGetter(this, "Hosts",
|
|||
loader.lazyRequireGetter(this, "Selection",
|
||||
"devtools/client/framework/selection", true);
|
||||
loader.lazyRequireGetter(this, "InspectorFront",
|
||||
"devtools/server/actors/inspector", true);
|
||||
"devtools/client/fronts/inspector", true);
|
||||
loader.lazyRequireGetter(this, "DevToolsUtils",
|
||||
"devtools/shared/DevToolsUtils");
|
||||
loader.lazyRequireGetter(this, "showDoorhanger",
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
const Services = require("Services");
|
||||
const { Ci } = require("chrome");
|
||||
require("devtools/client/fronts/styles");
|
||||
require("devtools/client/fronts/highlighters");
|
||||
const { ShortLongString } = require("devtools/server/actors/string");
|
||||
const {
|
||||
Front,
|
||||
|
@ -15,6 +17,7 @@ const {
|
|||
} = require("devtools/shared/protocol.js");
|
||||
const { makeInfallible } = require("devtools/shared/DevToolsUtils");
|
||||
const {
|
||||
inspectorSpec,
|
||||
nodeSpec,
|
||||
nodeListSpec,
|
||||
walkerSpec
|
||||
|
@ -925,3 +928,49 @@ const WalkerFront = FrontClassWithSpec(walkerSpec, {
|
|||
});
|
||||
|
||||
exports.WalkerFront = WalkerFront;
|
||||
|
||||
/**
|
||||
* Client side of the inspector actor, which is used to create
|
||||
* inspector-related actors, including the walker.
|
||||
*/
|
||||
var InspectorFront = FrontClassWithSpec(inspectorSpec, {
|
||||
initialize: function (client, tabForm) {
|
||||
Front.prototype.initialize.call(this, client);
|
||||
this.actorID = tabForm.inspectorActor;
|
||||
|
||||
// XXX: This is the first actor type in its hierarchy to use the protocol
|
||||
// library, so we're going to self-own on the client side for now.
|
||||
this.manage(this);
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
delete this.walker;
|
||||
Front.prototype.destroy.call(this);
|
||||
},
|
||||
|
||||
getWalker: custom(function (options = {}) {
|
||||
return this._getWalker(options).then(walker => {
|
||||
this.walker = walker;
|
||||
return walker;
|
||||
});
|
||||
}, {
|
||||
impl: "_getWalker"
|
||||
}),
|
||||
|
||||
getPageStyle: custom(function () {
|
||||
return this._getPageStyle().then(pageStyle => {
|
||||
// We need a walker to understand node references from the
|
||||
// node style.
|
||||
if (this.walker) {
|
||||
return pageStyle;
|
||||
}
|
||||
return this.getWalker().then(() => {
|
||||
return pageStyle;
|
||||
});
|
||||
});
|
||||
}, {
|
||||
impl: "_getPageStyle"
|
||||
})
|
||||
});
|
||||
|
||||
exports.InspectorFront = InspectorFront;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
require("devtools/client/fronts/stylesheets");
|
||||
const {
|
||||
Front,
|
||||
FrontClassWithSpec,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"use strict";
|
||||
|
||||
const CSSCompleter = require("devtools/client/sourceeditor/css-autocompleter");
|
||||
const {InspectorFront} = require("devtools/server/actors/inspector");
|
||||
const {InspectorFront} = require("devtools/client/fronts/inspector");
|
||||
const {TargetFactory} = require("devtools/client/framework/target");
|
||||
const { Cc, Ci } = require("chrome");
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const {InspectorFront} = require("devtools/server/actors/inspector");
|
||||
const {InspectorFront} = require("devtools/client/fronts/inspector");
|
||||
const {TargetFactory} = require("devtools/client/framework/target");
|
||||
const AUTOCOMPLETION_PREF = "devtools.editor.autocomplete";
|
||||
const TEST_URI = "data:text/html;charset=UTF-8,<html><body><bar></bar>" +
|
||||
|
|
|
@ -19,10 +19,10 @@ Cu.import("resource://devtools/client/styleeditor/StyleEditorUI.jsm");
|
|||
Cu.import("resource://devtools/client/styleeditor/StyleEditorUtil.jsm");
|
||||
|
||||
loader.lazyGetter(this, "StyleSheetsFront",
|
||||
() => require("devtools/server/actors/stylesheets").StyleSheetsFront);
|
||||
() => require("devtools/client/fronts/stylesheets").StyleSheetsFront);
|
||||
|
||||
loader.lazyGetter(this, "StyleEditorFront",
|
||||
() => require("devtools/server/actors/styleeditor").StyleEditorFront);
|
||||
() => require("devtools/client/fronts/styleeditor").StyleEditorFront);
|
||||
|
||||
var StyleEditorPanel = function StyleEditorPanel(panelWin, toolbox) {
|
||||
EventEmitter.decorate(this);
|
||||
|
|
|
@ -8,7 +8,6 @@ const { Ci } = require("chrome");
|
|||
|
||||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
const events = require("sdk/event/core");
|
||||
const { HighlighterFront, CustomHighlighterFront } = require("devtools/client/fronts/highlighters");
|
||||
const protocol = require("devtools/shared/protocol");
|
||||
const { Arg, Option, method, RetVal } = protocol;
|
||||
const { isWindowIncluded } = require("devtools/shared/layout/utils");
|
||||
|
|
|
@ -67,7 +67,6 @@ const {
|
|||
CustomHighlighterActor,
|
||||
isTypeRegistered,
|
||||
} = require("devtools/server/actors/highlighters");
|
||||
const {NodeFront, NodeListFront, WalkerFront} = require("devtools/client/fronts/inspector");
|
||||
const {
|
||||
isAnonymous,
|
||||
isNativeAnonymous,
|
||||
|
@ -81,7 +80,7 @@ const {getLayoutChangesObserver, releaseLayoutChangesObserver} =
|
|||
loader.lazyRequireGetter(this, "CSS", "CSS");
|
||||
|
||||
const {EventParsers} = require("devtools/shared/event-parsers");
|
||||
const {nodeSpec, nodeListSpec, walkerSpec} = require("devtools/shared/specs/inspector");
|
||||
const {nodeSpec, nodeListSpec, walkerSpec, inspectorSpec} = require("devtools/shared/specs/inspector");
|
||||
|
||||
const FONT_FAMILY_PREVIEW_TEXT = "The quick brown fox jumps over the lazy dog";
|
||||
const FONT_FAMILY_PREVIEW_TEXT_SIZE = 20;
|
||||
|
@ -759,8 +758,6 @@ var NodeListActor = exports.NodeListActor = protocol.ActorClassWithSpec(nodeList
|
|||
release: function () {}
|
||||
});
|
||||
|
||||
exports.NodeListFront = NodeListFront;
|
||||
|
||||
/**
|
||||
* Server side of the DOM walker.
|
||||
*/
|
||||
|
@ -2547,15 +2544,11 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, {
|
|||
},
|
||||
});
|
||||
|
||||
exports.WalkerFront = WalkerFront;
|
||||
|
||||
/**
|
||||
* Server side of the inspector actor, which is used to create
|
||||
* inspector-related actors, including the walker.
|
||||
*/
|
||||
var InspectorActor = exports.InspectorActor = protocol.ActorClass({
|
||||
typeName: "inspector",
|
||||
|
||||
var InspectorActor = exports.InspectorActor = protocol.ActorClassWithSpec(inspectorSpec, {
|
||||
initialize: function (conn, tabActor) {
|
||||
protocol.Actor.prototype.initialize.call(this, conn);
|
||||
this.tabActor = tabActor;
|
||||
|
@ -2581,7 +2574,7 @@ var InspectorActor = exports.InspectorActor = protocol.ActorClass({
|
|||
return this.tabActor.window;
|
||||
},
|
||||
|
||||
getWalker: method(function (options = {}) {
|
||||
getWalker: function (options = {}) {
|
||||
if (this._walkerPromise) {
|
||||
return this._walkerPromise;
|
||||
}
|
||||
|
@ -2609,16 +2602,9 @@ var InspectorActor = exports.InspectorActor = protocol.ActorClass({
|
|||
}
|
||||
|
||||
return this._walkerPromise;
|
||||
}, {
|
||||
request: {
|
||||
options: Arg(0, "nullable:json")
|
||||
},
|
||||
response: {
|
||||
walker: RetVal("domwalker")
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
getPageStyle: method(function () {
|
||||
getPageStyle: function () {
|
||||
if (this._pageStylePromise) {
|
||||
return this._pageStylePromise;
|
||||
}
|
||||
|
@ -2629,12 +2615,7 @@ var InspectorActor = exports.InspectorActor = protocol.ActorClass({
|
|||
return pageStyle;
|
||||
});
|
||||
return this._pageStylePromise;
|
||||
}, {
|
||||
request: {},
|
||||
response: {
|
||||
pageStyle: RetVal("pagestyle")
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
/**
|
||||
* The most used highlighter actor is the HighlighterActor which can be
|
||||
|
@ -2649,7 +2630,7 @@ var InspectorActor = exports.InspectorActor = protocol.ActorClass({
|
|||
* element has been picked
|
||||
* @return {HighlighterActor}
|
||||
*/
|
||||
getHighlighter: method(function (autohide) {
|
||||
getHighlighter: function (autohide) {
|
||||
if (this._highlighterPromise) {
|
||||
return this._highlighterPromise;
|
||||
}
|
||||
|
@ -2660,14 +2641,7 @@ var InspectorActor = exports.InspectorActor = protocol.ActorClass({
|
|||
return highlighter;
|
||||
});
|
||||
return this._highlighterPromise;
|
||||
}, {
|
||||
request: {
|
||||
autohide: Arg(0, "boolean")
|
||||
},
|
||||
response: {
|
||||
highligter: RetVal("highlighter")
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
/**
|
||||
* If consumers need to display several highlighters at the same time or
|
||||
|
@ -2680,19 +2654,12 @@ var InspectorActor = exports.InspectorActor = protocol.ActorClass({
|
|||
* @return {Highlighter} The highlighter actor instance or null if the
|
||||
* typeName passed doesn't match any available highlighter
|
||||
*/
|
||||
getHighlighterByType: method(function (typeName) {
|
||||
getHighlighterByType: function (typeName) {
|
||||
if (isTypeRegistered(typeName)) {
|
||||
return CustomHighlighterActor(this, typeName);
|
||||
}
|
||||
return null;
|
||||
}, {
|
||||
request: {
|
||||
typeName: Arg(0)
|
||||
},
|
||||
response: {
|
||||
highlighter: RetVal("nullable:customhighlighter")
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the node's image data if any (for canvas and img nodes).
|
||||
|
@ -2705,7 +2672,7 @@ var InspectorActor = exports.InspectorActor = protocol.ActorClass({
|
|||
* is important as the resizing occurs server-side so that image-data being
|
||||
* transfered in the longstring back to the client will be that much smaller
|
||||
*/
|
||||
getImageDataFromURL: method(function(url, maxDim) {
|
||||
getImageDataFromURL: function(url, maxDim) {
|
||||
let img = new this.window.Image();
|
||||
img.src = url;
|
||||
|
||||
|
@ -2716,10 +2683,7 @@ var InspectorActor = exports.InspectorActor = protocol.ActorClass({
|
|||
size: imageData.size
|
||||
};
|
||||
});
|
||||
}, {
|
||||
request: {url: Arg(0), maxDim: Arg(1, "nullable:number")},
|
||||
response: RetVal("imageData")
|
||||
}),
|
||||
},
|
||||
|
||||
/**
|
||||
* Resolve a URL to its absolute form, in the scope of a given content window.
|
||||
|
@ -2729,7 +2693,7 @@ var InspectorActor = exports.InspectorActor = protocol.ActorClass({
|
|||
* used instead.
|
||||
* @return {String} url.
|
||||
*/
|
||||
resolveRelativeURL: method(function (url, node) {
|
||||
resolveRelativeURL: function (url, node) {
|
||||
let document = isNodeDead(node)
|
||||
? this.window.document
|
||||
: nodeDocument(node.rawNode);
|
||||
|
@ -2740,58 +2704,9 @@ var InspectorActor = exports.InspectorActor = protocol.ActorClass({
|
|||
|
||||
let baseURI = Services.io.newURI(document.location.href, null, null);
|
||||
return Services.io.newURI(url, null, baseURI).spec;
|
||||
}, {
|
||||
request: {url: Arg(0, "string"), node: Arg(1, "nullable:domnode")},
|
||||
response: {value: RetVal("string")}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Client side of the inspector actor, which is used to create
|
||||
* inspector-related actors, including the walker.
|
||||
*/
|
||||
var InspectorFront = protocol.FrontClass(InspectorActor, {
|
||||
initialize: function (client, tabForm) {
|
||||
protocol.Front.prototype.initialize.call(this, client);
|
||||
this.actorID = tabForm.inspectorActor;
|
||||
|
||||
// XXX: This is the first actor type in its hierarchy to use the protocol
|
||||
// library, so we're going to self-own on the client side for now.
|
||||
this.manage(this);
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
delete this.walker;
|
||||
protocol.Front.prototype.destroy.call(this);
|
||||
},
|
||||
|
||||
getWalker: protocol.custom(function (options = {}) {
|
||||
return this._getWalker(options).then(walker => {
|
||||
this.walker = walker;
|
||||
return walker;
|
||||
});
|
||||
}, {
|
||||
impl: "_getWalker"
|
||||
}),
|
||||
|
||||
getPageStyle: protocol.custom(function () {
|
||||
return this._getPageStyle().then(pageStyle => {
|
||||
// We need a walker to understand node references from the
|
||||
// node style.
|
||||
if (this.walker) {
|
||||
return pageStyle;
|
||||
}
|
||||
return this.getWalker().then(() => {
|
||||
return pageStyle;
|
||||
});
|
||||
});
|
||||
}, {
|
||||
impl: "_getPageStyle"
|
||||
})
|
||||
});
|
||||
|
||||
exports.InspectorFront = InspectorFront;
|
||||
|
||||
// Exported for test purposes.
|
||||
exports._documentWalker = DocumentWalker;
|
||||
|
||||
|
|
|
@ -7,12 +7,11 @@
|
|||
const {Cc, Ci} = require("chrome");
|
||||
const promise = require("promise");
|
||||
const protocol = require("devtools/shared/protocol");
|
||||
const events = require("sdk/event/core");
|
||||
const {PageStyleFront, StyleRuleFront} = require("devtools/client/fronts/styles"); // eslint-disable-line
|
||||
const {LongStringActor} = require("devtools/server/actors/string");
|
||||
const {getDefinedGeometryProperties} = require("devtools/server/actors/highlighters/geometry-editor");
|
||||
const {parseDeclarations} = require("devtools/client/shared/css-parsing-utils");
|
||||
const {Task} = require("resource://gre/modules/Task.jsm");
|
||||
const events = require("sdk/event/core");
|
||||
|
||||
// This will also add the "stylesheet" actor type for protocol.js to recognize
|
||||
const {UPDATE_PRESERVING_RULES, UPDATE_GENERAL} = require("devtools/server/actors/stylesheets");
|
||||
|
|
|
@ -14,8 +14,6 @@ Cu.import("resource://gre/modules/Task.jsm");
|
|||
|
||||
const promise = require("promise");
|
||||
const events = require("sdk/event/core");
|
||||
const {OriginalSourceFront, MediaRuleFront, StyleSheetFront,
|
||||
StyleSheetsFront} = require("devtools/client/fronts/stylesheets");
|
||||
const protocol = require("devtools/shared/protocol");
|
||||
const {Arg, Option, method, RetVal, types} = protocol;
|
||||
const {LongStringActor, ShortLongString} = require("devtools/server/actors/string");
|
||||
|
@ -760,8 +758,6 @@ var StyleSheetActor = protocol.ActorClassWithSpec(styleSheetSpec, {
|
|||
|
||||
exports.StyleSheetActor = StyleSheetActor;
|
||||
|
||||
exports.StyleSheetFront = StyleSheetFront;
|
||||
|
||||
/**
|
||||
* Creates a StyleSheetsActor. StyleSheetsActor provides remote access to the
|
||||
* stylesheets of a document.
|
||||
|
@ -953,8 +949,6 @@ var StyleSheetsActor = protocol.ActorClassWithSpec(styleSheetsSpec, {
|
|||
|
||||
exports.StyleSheetsActor = StyleSheetsActor;
|
||||
|
||||
exports.StyleSheetsFront = StyleSheetsFront;
|
||||
|
||||
/**
|
||||
* Normalize multiple relative paths towards the base paths on the right.
|
||||
*/
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
// Test that StyleSheetActor.getText handles empty text correctly.
|
||||
|
||||
const {StyleSheetsFront} = require("devtools/server/actors/stylesheets");
|
||||
const {StyleSheetsFront} = require("devtools/client/fronts/stylesheets");
|
||||
|
||||
const CONTENT = "<style>body { background-color: #f0c; }</style>";
|
||||
const TEST_URI = "data:text/html;charset=utf-8," + encodeURIComponent(CONTENT);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
// Test that StyleSheetsActor.getStyleSheets() works if an iframe does not have
|
||||
// a content document.
|
||||
|
||||
const {StyleSheetsFront} = require("devtools/server/actors/stylesheets");
|
||||
const {StyleSheetsFront} = require("devtools/client/fronts/stylesheets");
|
||||
|
||||
add_task(function*() {
|
||||
let browser = yield addTab(MAIN_DOMAIN + "stylesheets-nested-iframes.html");
|
||||
|
|
|
@ -50,7 +50,7 @@ var addTab = Task.async(function* (url) {
|
|||
|
||||
function* initAnimationsFrontForUrl(url) {
|
||||
const {AnimationsFront} = require("devtools/server/actors/animation");
|
||||
const {InspectorFront} = require("devtools/server/actors/inspector");
|
||||
const {InspectorFront} = require("devtools/client/fronts/inspector");
|
||||
|
||||
yield addTab(url);
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ const {
|
|||
generateActorSpec,
|
||||
types
|
||||
} = require("devtools/shared/protocol");
|
||||
require("devtools/shared/specs/styles");
|
||||
require("devtools/shared/specs/highlighters");
|
||||
|
||||
types.addDictType("imageData", {
|
||||
// The image data
|
||||
|
@ -418,3 +420,50 @@ const walkerSpec = generateActorSpec({
|
|||
});
|
||||
|
||||
exports.walkerSpec = walkerSpec;
|
||||
|
||||
const inspectorSpec = generateActorSpec({
|
||||
typeName: "inspector",
|
||||
|
||||
methods: {
|
||||
getWalker: {
|
||||
request: {
|
||||
options: Arg(0, "nullable:json")
|
||||
},
|
||||
response: {
|
||||
walker: RetVal("domwalker")
|
||||
}
|
||||
},
|
||||
getPageStyle: {
|
||||
request: {},
|
||||
response: {
|
||||
pageStyle: RetVal("pagestyle")
|
||||
}
|
||||
},
|
||||
getHighlighter: {
|
||||
request: {
|
||||
autohide: Arg(0, "boolean")
|
||||
},
|
||||
response: {
|
||||
highligter: RetVal("highlighter")
|
||||
}
|
||||
},
|
||||
getHighlighterByType: {
|
||||
request: {
|
||||
typeName: Arg(0)
|
||||
},
|
||||
response: {
|
||||
highlighter: RetVal("nullable:customhighlighter")
|
||||
}
|
||||
},
|
||||
getImageDataFromURL: {
|
||||
request: {url: Arg(0), maxDim: Arg(1, "nullable:number")},
|
||||
response: RetVal("imageData")
|
||||
},
|
||||
resolveRelativeURL: {
|
||||
request: {url: Arg(0, "string"), node: Arg(1, "nullable:domnode")},
|
||||
response: {value: RetVal("string")}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
exports.inspectorSpec = inspectorSpec;
|
||||
|
|
|
@ -10,7 +10,7 @@ const {
|
|||
generateActorSpec,
|
||||
types
|
||||
} = require("devtools/shared/protocol.js");
|
||||
require("devtools/shared/specs/stylesheets.js");
|
||||
require("devtools/shared/specs/stylesheets");
|
||||
|
||||
// Predeclare the domnode actor type for use in requests.
|
||||
types.addActorType("domnode");
|
||||
|
|
Загрузка…
Ссылка в новой задаче