Skip to content

Commit 003dda1

Browse files
committed
#1 Bug 1036949 - New API: MarkupView customization
1 parent 75aef02 commit 003dda1

File tree

4 files changed

+38
-113
lines changed

4 files changed

+38
-113
lines changed

lib/firequery-actor.js

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ var FireQueryActor = ActorClass(
9696
this.parent = parent;
9797
this.state = "detached";
9898

99-
this.onDomNodeForm = this.onDomNodeForm.bind(this);
99+
this.onNodeActorForm = this.onNodeActorForm.bind(this);
100100
this.onNavigate = this.onNavigate.bind(this);
101101
},
102102

@@ -138,7 +138,7 @@ var FireQueryActor = ActorClass(
138138
Previewers.Object.unshift(this.onBuildPreview.bind(this));
139139

140140
Events.on(this.parent, "navigate", this.onNavigate);
141-
DebuggerServer.on("domnode-form", this.onDomNodeForm);
141+
Events.on(NodeActor, "form", this.onNodeActorForm);
142142
}), {
143143
request: {},
144144
response: {
@@ -156,7 +156,7 @@ var FireQueryActor = ActorClass(
156156
this.state = "detached";
157157

158158
Events.off(this.parent, "navigate", this.onNavigate);
159-
DebuggerServer.off("domnode-form", this.onDomNodeForm);
159+
Events.off(NodeActor, "form", this.onNodeActorForm);
160160

161161
// xxxHonza: remove previewer
162162
}), {
@@ -305,17 +305,21 @@ var FireQueryActor = ActorClass(
305305

306306
// Debugger Server Events
307307

308-
onDomNodeForm: makeInfallible(function(eventId, nodeActor, form) {
308+
onNodeActorForm: makeInfallible(function(event) {
309+
let nodeActor = event.target;
310+
let form = event.data;
309311
let data = hasJQueryData(nodeActor.rawNode);
310312

313+
// xxxHonza: check that the event comes from an actor in the
314+
// same connection as this actor.
315+
311316
// Pass only a flag that says whether there are any jQuery
312317
// data associated or not. The data itself will be fetched
313318
// on demand (when displayed e.g. in a tooltip)
314-
//form.setProperty("jQueryData", data);
315-
form.setProperty("hasJQueryData", !!data)
319+
form.setFormProperty("hasJQueryData", !!data)
316320

317321
let json = data ? JSON.stringify(data) : "";
318-
Trace.sysout("FireQueryActor.onDomNodeForm; " + json, arguments);
322+
Trace.sysout("FireQueryActor.onNodeActorForm; " + json, arguments);
319323
})
320324
});
321325

@@ -362,22 +366,37 @@ function hasJQueryData(object) {
362366
};
363367

364368
// Patching NodeActor (add custom info into actor form)
365-
// xxxHonza: Bug 1036949 - New API: MarkupView customization
366-
/*let originalForm = NodeActor.prototype.form;
369+
// Bug 1036949 - New API: MarkupView customization
370+
// xxxHonza: Can be removed as soon as Firefox 41 is the
371+
// minimum required version.
372+
let originalForm = NodeActor.prototype.form;
367373
NodeActor.prototype.form = function() {
368374
let form = originalForm.apply(this, arguments);
369-
if (!form.setProperty) {
370-
form.setProperty = (name, value) => {
375+
376+
// form.setFormProperty has been introduced in Bug 1036949
377+
// (released in Firefox 41)
378+
// The content of the following if block is taken from the
379+
// patch attached to Bug 1036949
380+
if (!form.setFormProperty) {
381+
// Add an extra API for custom properties added by other
382+
// modules/extensions.
383+
form.setFormProperty = (name, value) => {
371384
if (!form.props) {
372385
form.props = {};
373386
}
374387
form.props[name] = value;
375388
};
376389

377-
DebuggerServer.emit("domnode-form", this, form);
390+
// Fire an event so, other modules can create its own properties
391+
// that should be passed to the client (within the form.props field).
392+
Events.emit(NodeActor, "form", {
393+
target: this,
394+
data: form
395+
});
378396
}
397+
379398
return form;
380-
}*/
399+
}
381400

382401
// Exports from this module
383402
exports.FireQueryActor = FireQueryActor;

lib/inspector-overlay.js

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,13 @@ const InspectorOverlay = Class(
187187
onMarkupViewContainerCreated: function(eventId, container) {
188188
Trace.sysout("InspectorOverlay.onMarkupViewContainerCreated; ", arguments);
189189

190+
// nodeFront.getFormProperty has been introduced in Bug 1036949
191+
// (released in Firefox 41)
192+
// xxxHonza: Checking existence of the method can be removed
193+
// as soon as Firefox 41 is the minimum required version.
190194
let nodeFront = container.node;
191-
let hasJQueryData = nodeFront.getProperty ?
192-
nodeFront.getProperty("hasJQueryData") :
195+
let hasJQueryData = nodeFront.getFormProperty ?
196+
nodeFront.getFormProperty("hasJQueryData") :
193197
nodeFront._form.props.hasJQueryData;
194198

195199
if (!hasJQueryData) {
@@ -199,47 +203,6 @@ const InspectorOverlay = Class(
199203
this.createDataIcon(container.elt);
200204
},
201205

202-
// xxxHonza: TODO remove
203-
renderNode: function(node, type, data) {
204-
if (type != "element") {
205-
return;
206-
}
207-
208-
// Get custom 'hasJQueryData' property send from the backed.
209-
// If the node has some jQuery data the property is set to true.
210-
// xxxHonza: back compatibility, can be removed when
211-
// Bug 1036949 - New API: MarkupView customization
212-
// .. is in the release channel. It implements the
213-
// nodeFront.getProperty() method.
214-
let nodeFront = data.node;
215-
let hasJQueryData = nodeFront.getProperty ?
216-
nodeFront.getProperty("hasJQueryData") :
217-
nodeFront._form.props.hasJQueryData;
218-
219-
if (!hasJQueryData) {
220-
return;
221-
}
222-
223-
let icon = this.createDataIcon(node);
224-
//icon.jQueryData = jQueryData;
225-
226-
// xxxHonza: jQuery data value isn't rendered within the MarkupView
227-
// it's now displayed inside a tooltip.
228-
/*let item = {
229-
element: node,
230-
jQueryData: jQueryData
231-
};
232-
233-
// Render now if MarkupView content script is already loaded.
234-
// Otherwise push it into an array and render as soon as
235-
// the content is properly initialized.
236-
if (this.markupScriptReady) {
237-
this.postContentMessage("render", [item]);
238-
} else {
239-
this.nodes.push(item);
240-
}*/
241-
},
242-
243206
createDataIcon: function(element) {
244207
let icon = element.querySelector(".fireQueryData");
245208
if (icon) {

lib/main.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ const { ConsoleOverlay } = require("./console-overlay.js");
1717
const { InspectorOverlay } = require("./inspector-overlay.js");
1818
const { FireQueryToolboxOverlay } = require("./firequery-toolbox-overlay.js");
1919

20-
// Platform patch (should be removed as soon as it's built-in).
21-
const MarkupViewPatch = require("./markup-view-patch.js");
22-
2320
// Localization files. All strings in the UI should be loaded from these
2421
// files, so the entire extension can be localized into other languages.
2522
Locale.registerStringBundle("chrome://firequery/locale/firequery.properties");

lib/markup-view-patch.js

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)