зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1531826 Part 1 - View event handler sources by ID, r=ochameau.
--HG-- extra : rebase_source : 372a529e62b35c985ec8c1bc49ca33e2003fe3a4
This commit is contained in:
Родитель
abb2fb97f8
Коммит
7bdab9da0c
|
@ -52,7 +52,8 @@ exports.viewSourceInStyleEditor = async function(toolbox, sourceURL,
|
|||
exports.viewSourceInDebugger = async function(toolbox, sourceURL, sourceLine, sourceId,
|
||||
reason = "unknown") {
|
||||
const dbg = await toolbox.loadTool("jsdebugger");
|
||||
const source = dbg.getSourceByURL(sourceURL) || dbg.getSourceByActorId(sourceId);
|
||||
const source =
|
||||
sourceId ? dbg.getSourceByActorId(sourceId) : dbg.getSourceByURL(sourceURL);
|
||||
if (source) {
|
||||
await toolbox.selectTool("jsdebugger", reason);
|
||||
dbg.selectSource(source.id, sourceLine);
|
||||
|
|
|
@ -184,6 +184,7 @@ EventTooltip.prototype = {
|
|||
editor: editor,
|
||||
handler: listener.handler,
|
||||
uri: listener.origin,
|
||||
sourceActor: listener.sourceActor,
|
||||
dom0: listener.DOM0,
|
||||
native: listener.native,
|
||||
appended: false,
|
||||
|
@ -263,7 +264,7 @@ EventTooltip.prototype = {
|
|||
const header = event.currentTarget;
|
||||
const content = header.nextElementSibling;
|
||||
|
||||
const {uri} = this._eventEditors.get(content);
|
||||
const {sourceActor, uri} = this._eventEditors.get(content);
|
||||
|
||||
const location = this._parseLocation(uri);
|
||||
if (location) {
|
||||
|
@ -272,7 +273,7 @@ EventTooltip.prototype = {
|
|||
|
||||
this._tooltip.hide();
|
||||
|
||||
toolbox.viewSourceInDebugger(location.url, location.line);
|
||||
toolbox.viewSourceInDebugger(location.url, location.line, sourceActor);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -708,7 +708,9 @@ class ReactEventCollector extends MainEventCollector {
|
|||
* The exposed class responsible for gathering events.
|
||||
*/
|
||||
class EventCollector {
|
||||
constructor() {
|
||||
constructor(targetActor) {
|
||||
this.targetActor = targetActor;
|
||||
|
||||
// The event collector array. Please preserve the order otherwise there will
|
||||
// be multiple failing tests.
|
||||
this.eventCollectors = [
|
||||
|
@ -864,6 +866,7 @@ class EventCollector {
|
|||
let line = 0;
|
||||
let native = false;
|
||||
let url = "";
|
||||
let sourceActor = "";
|
||||
|
||||
// If the listener is an object with a 'handleEvent' method, use that.
|
||||
if (listenerDO.class === "Object" || /^XUL\w*Element$/.test(listenerDO.class)) {
|
||||
|
@ -900,6 +903,8 @@ class EventCollector {
|
|||
|
||||
line = script.startLine;
|
||||
url = script.url;
|
||||
const actor = this.targetActor.sources.getOrCreateSourceActor(script.source);
|
||||
sourceActor = actor ? actor.actorID : null;
|
||||
|
||||
// Checking for the string "[native code]" is the only way at this point
|
||||
// to check for native code. Even if this provides a false positive then
|
||||
|
@ -957,6 +962,7 @@ class EventCollector {
|
|||
override.capturing : capturing,
|
||||
hide: typeof override.hide !== "undefined" ? override.hide : hide,
|
||||
native,
|
||||
sourceActor,
|
||||
};
|
||||
|
||||
// Hide the debugger icon for DOM0 and native listeners. DOM0 listeners are
|
||||
|
|
|
@ -48,7 +48,7 @@ const NodeActor = protocol.ActorClassWithSpec(nodeSpec, {
|
|||
protocol.Actor.prototype.initialize.call(this, null);
|
||||
this.walker = walker;
|
||||
this.rawNode = node;
|
||||
this._eventCollector = new EventCollector();
|
||||
this._eventCollector = new EventCollector(this.walker.targetActor);
|
||||
|
||||
// Store the original display type and scrollable state and whether or not the node is
|
||||
// displayed to track changes when reflows occur.
|
||||
|
|
|
@ -147,6 +147,13 @@ TabSources.prototype = {
|
|||
return sourceActor;
|
||||
},
|
||||
|
||||
getOrCreateSourceActor(source) {
|
||||
if (this.hasSourceActor(source)) {
|
||||
return this.getSourceActor(source);
|
||||
}
|
||||
return this.createSourceActor(source);
|
||||
},
|
||||
|
||||
getSourceActorByInternalSourceId: function(id) {
|
||||
if (!this._sourcesByInternalSourceId) {
|
||||
this._sourcesByInternalSourceId = new Map();
|
||||
|
@ -158,10 +165,7 @@ TabSources.prototype = {
|
|||
}
|
||||
const source = this._sourcesByInternalSourceId.get(id);
|
||||
if (source) {
|
||||
if (this.hasSourceActor(source)) {
|
||||
return this.getSourceActor(source);
|
||||
}
|
||||
return this.createSourceActor(source);
|
||||
return this.getOrCreateSourceActor(source);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче