зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1268458 - Decouple CustomHighlighterFront from CustomHighlighterActor;r=jryans
This commit is contained in:
Родитель
9c54ec6987
Коммит
329f51ae5a
|
@ -4,7 +4,10 @@
|
|||
"use strict";
|
||||
|
||||
const { FrontClassWithSpec } = require("devtools/shared/protocol");
|
||||
const { highlighterSpec } = require("devtools/shared/specs/highlighters");
|
||||
const {
|
||||
customHighlighterSpec,
|
||||
highlighterSpec
|
||||
} = require("devtools/shared/specs/highlighters");
|
||||
|
||||
const HighlighterFront = FrontClassWithSpec(highlighterSpec, {
|
||||
// Update the object given a form representation off the wire.
|
||||
|
@ -16,3 +19,7 @@ const HighlighterFront = FrontClassWithSpec(highlighterSpec, {
|
|||
});
|
||||
|
||||
exports.HighlighterFront = HighlighterFront;
|
||||
|
||||
const CustomHighlighterFront = FrontClassWithSpec(customHighlighterSpec, {});
|
||||
|
||||
exports.CustomHighlighterFront = CustomHighlighterFront;
|
||||
|
|
|
@ -8,11 +8,11 @@ const { Ci } = require("chrome");
|
|||
|
||||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
const events = require("sdk/event/core");
|
||||
const { HighlighterFront } = require("devtools/client/fronts/highlighters");
|
||||
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");
|
||||
const { highlighterSpec } = require("devtools/shared/specs/highlighters");
|
||||
const { highlighterSpec, customHighlighterSpec } = require("devtools/shared/specs/highlighters");
|
||||
const { isXUL, isNodeValid } = require("./highlighters/utils/markup");
|
||||
const { SimpleOutlineHighlighter } = require("./highlighters/simple-outline");
|
||||
|
||||
|
@ -400,9 +400,7 @@ var HighlighterActor = exports.HighlighterActor = protocol.ActorClassWithSpec(hi
|
|||
* A generic highlighter actor class that instantiate a highlighter given its
|
||||
* type name and allows to show/hide it.
|
||||
*/
|
||||
var CustomHighlighterActor = exports.CustomHighlighterActor = protocol.ActorClass({
|
||||
typeName: "customhighlighter",
|
||||
|
||||
var CustomHighlighterActor = exports.CustomHighlighterActor = protocol.ActorClassWithSpec(customHighlighterSpec, {
|
||||
/**
|
||||
* Create a highlighter instance given its typename
|
||||
* The typename must be one of HIGHLIGHTER_CLASSES and the class must
|
||||
|
@ -442,7 +440,7 @@ var CustomHighlighterActor = exports.CustomHighlighterActor = protocol.ActorClas
|
|||
this._inspector = null;
|
||||
},
|
||||
|
||||
release: method(function() {}, { release: true }),
|
||||
release: function() {},
|
||||
|
||||
/**
|
||||
* Show the highlighter.
|
||||
|
@ -462,38 +460,28 @@ var CustomHighlighterActor = exports.CustomHighlighterActor = protocol.ActorClas
|
|||
* @return {Boolean} True, if the highlighter has been successfully shown
|
||||
* (FF41+)
|
||||
*/
|
||||
show: method(function(node, options) {
|
||||
show: function(node, options) {
|
||||
if (!node || !isNodeValid(node.rawNode) || !this._highlighter) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this._highlighter.show(node.rawNode, options);
|
||||
}, {
|
||||
request: {
|
||||
node: Arg(0, "domnode"),
|
||||
options: Arg(1, "nullable:json")
|
||||
},
|
||||
response: {
|
||||
value: RetVal("nullable:boolean")
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
/**
|
||||
* Hide the highlighter if it was shown before
|
||||
*/
|
||||
hide: method(function() {
|
||||
hide: function() {
|
||||
if (this._highlighter) {
|
||||
this._highlighter.hide();
|
||||
}
|
||||
}, {
|
||||
request: {}
|
||||
}),
|
||||
},
|
||||
|
||||
/**
|
||||
* Kill this actor. This method is called automatically just before the actor
|
||||
* is destroyed.
|
||||
*/
|
||||
finalize: method(function() {
|
||||
finalize: function() {
|
||||
if (this._highlighter) {
|
||||
this._highlighter.destroy();
|
||||
this._highlighter = null;
|
||||
|
@ -503,13 +491,9 @@ var CustomHighlighterActor = exports.CustomHighlighterActor = protocol.ActorClas
|
|||
this._highlighterEnv.destroy();
|
||||
this._highlighterEnv = null;
|
||||
}
|
||||
}, {
|
||||
oneway: true
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
var CustomHighlighterFront = protocol.FrontClass(CustomHighlighterActor, {});
|
||||
|
||||
/**
|
||||
* The HighlighterEnvironment is an object that holds all the required data for
|
||||
* highlighters to work: the window, docShell, event listener target, ...
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
const {
|
||||
Arg,
|
||||
Option,
|
||||
RetVal,
|
||||
generateActorSpec
|
||||
} = require("devtools/shared/protocol");
|
||||
|
||||
|
@ -32,3 +33,30 @@ const highlighterSpec = generateActorSpec({
|
|||
});
|
||||
|
||||
exports.highlighterSpec = highlighterSpec;
|
||||
|
||||
const customHighlighterSpec = generateActorSpec({
|
||||
typeName: "customhighlighter",
|
||||
|
||||
methods: {
|
||||
release: {
|
||||
release: true
|
||||
},
|
||||
show: {
|
||||
request: {
|
||||
node: Arg(0, "domnode"),
|
||||
options: Arg(1, "nullable:json")
|
||||
},
|
||||
response: {
|
||||
value: RetVal("nullable:boolean")
|
||||
}
|
||||
},
|
||||
hide: {
|
||||
request: {}
|
||||
},
|
||||
finalize: {
|
||||
oneway: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
exports.customHighlighterSpec = customHighlighterSpec;
|
||||
|
|
Загрузка…
Ссылка в новой задаче