Skip to content

Commit de49a7f

Browse files
committed
Update comments
1 parent 4afe0df commit de49a7f

File tree

3 files changed

+60
-11
lines changed

3 files changed

+60
-11
lines changed

lib/data-tooltip.js

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@ const XHTML_NS = "http://www.w3.org/1999/xhtml";
3434
const ToolboxOverlayId = FireQueryToolboxOverlay.prototype.overlayId;
3535

3636
/**
37-
* This object implements a tooltip used in the MarkupView that
38-
* displays jQuery data as an expandable tree.
39-
* Content of the tooltip is rendered using an iframe. Content
40-
* of the iframe is implemented by markup-tooltip.html
37+
* This object implements a tooltip used in the MarkupView (Inspector panel)
38+
* that displays jQuery data as an expandable tree. Content of the tooltip
39+
* is rendered using an iframe. Content of the iframe is implemented
40+
* in markup-tooltip.html
41+
*
42+
* markup-tooltip.html uses require.js and react.js to render its content.
43+
* Communication between the iframe content and this object is done
44+
* through events (win.dispatchEvent).
4145
*/
4246
function DataTooltip(options) {
4347
this.context = options.context;
@@ -57,11 +61,15 @@ DataTooltip.prototype =
5761
show: makeInfallible(function() {
5862
this.tooltip.hide(this.target);
5963

64+
// Initial size of the tooltip. It's changed as the content
65+
// requires it (e.g. when the user is expanding tree-nodes
66+
// and more space is required).
6067
let dimensions = {
6168
width: "300",
6269
height: "21"
6370
};
6471

72+
// Load the content!
6573
let frameUrl = self.data.url("./markup-tooltip.html");
6674
this.tooltip.setIFrameContent(dimensions, frameUrl).
6775
then(this.onTooltipLoaded);
@@ -93,19 +101,26 @@ DataTooltip.prototype =
93101
Content.exportIntoContentScope(win, contentTrace, "Trace");
94102
Content.exportIntoContentScope(win, Locale, "Locale");
95103

104+
// We need the thread object to get client object for grips
105+
// (using threadClient.pauseGrip).
96106
let target = this.toolbox.target;
97107
target.activeTab.attachThread({}, (response, threadClient) => {
98108
this.threadClient = threadClient;
99109

110+
// The tooltip is opened for given jQuery data.
100111
let data = JSON.stringify(this.jQueryData);
101112
this.postContentMessage("initialize", data);
102113

114+
// Do not forget to resume the debugger.
103115
if (threadClient.paused) {
104116
threadClient.resume();
105117
}
106118
});
107119
},
108120

121+
/**
122+
* Update size of the tooltip when the content requests that.
123+
*/
109124
onTooltipResize: function(size) {
110125
Trace.sysout("DataTooltip.onTooltipResize;", size);
111126

@@ -130,12 +145,19 @@ DataTooltip.prototype =
130145
});
131146
},
132147

148+
/**
149+
* Support for UI navigation. If the user clicks on an element
150+
* value inside the tooltip, the element is selected within the
151+
* Markup View (Inspecto panel).
152+
*/
133153
onNavigate: function(grip) {
154+
// First, get nodeFront object from give grip. Our FQ actor
155+
// implements helper method for that.
134156
let toolboxOverlay = this.context.getOverlay(ToolboxOverlayId);
135157
return toolboxOverlay.front.getNode(grip.actor).then(response => {
158+
// Show the node in the UI and make sure it's selected.
136159
var node = response.node;
137160
this.markup.showNode(node).then(() => {
138-
// Mark the node as selected and focused.
139161
this.markup.markNodeAsSelected(node);
140162
this.markup.maybeFocusNewSelection();
141163
});
@@ -144,6 +166,9 @@ DataTooltip.prototype =
144166

145167
// Tooltip Content Communication
146168

169+
/**
170+
* Handle events coming from the tooltip iframe (content).
171+
*/
147172
onContentMessage: function(event) {
148173
//Trace.sysout("DataTooltip.onContentMessage;", event);
149174

@@ -165,7 +190,7 @@ DataTooltip.prototype =
165190
},
166191

167192
/**
168-
* Send message to the content scope (panel's iframe)
193+
* Send message to the content scope (tooltip's iframe)
169194
*/
170195
postContentMessage: function(type, args) {
171196
let win = this.contentWin;
@@ -209,7 +234,7 @@ if (!Tooltip.prototype.setIFrameContent) {
209234
}
210235
iframe.addEventListener("load", onLoad, true);
211236

212-
// load the document from url into the iframe
237+
// Load the document from url into the iframe
213238
iframe.setAttribute("src", url);
214239

215240
// Put the iframe in the tooltip

lib/firequery-actor.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ function expectState(expectedState, method) {
6666
* always done through RDP (Remote Debugging Protocol). Read more about
6767
* {@link https://wiki.mozilla.org/Remote_Debugging_Protocol|RDP}.
6868
*
69+
* In order to run the actor on Firefox OS device, you need to make sure
70+
* that 'devtools.debugger.forbid-certified-apps' is set to false on that
71+
* device.
72+
*
73+
* Read more about restricted privileges on Firefox OS:
74+
* https://bugzilla.mozilla.org/show_bug.cgi?id=977443#c11
75+
*
6976
* Read more about Protocol API:
7077
* https://github.com/mozilla/gecko-dev/blob/master/toolkit/devtools/server/docs/protocol.js.md
7178
*/
@@ -143,7 +150,7 @@ var FireQueryActor = ActorClass(
143150

144151
this.state = "attached";
145152

146-
// xxxHonza: it's sometimes undefined (e.g. when enabling installed FQ).
153+
// xxxHonza: it's sometimes undefined (e.g. when enabling installed FQ) FIXME
147154
let Previewers = DebuggerServer.ObjectActorPreviewers;
148155
if (typeof Previewers != "undefined") {
149156
Previewers.Object.unshift(this.onBuildPreview);
@@ -250,7 +257,7 @@ var FireQueryActor = ActorClass(
250257
data = makeDebuggeeValueIfNeeded(actor.obj, data);
251258
grip.preview.jQueryData = this.createValueGrip(actor, data);
252259

253-
// xxxHonza: generate preview for the data?
260+
// xxxHonza: generate preview for the jQuery.data?
254261
}
255262
} else {
256263
preview.items.push(null);
@@ -267,7 +274,7 @@ var FireQueryActor = ActorClass(
267274
}),
268275

269276
createValueGrip: function(actor, value) {
270-
// Introduced in Fx42
277+
// actor.hooks field has been introduced in Fx42
271278
if (actor.hooks) {
272279
return actor.hooks.createValueGrip(value);
273280
}
@@ -305,6 +312,11 @@ var FireQueryActor = ActorClass(
305312
}
306313
}),
307314

315+
/**
316+
* Patch jQuery (in order to get modification events) as soon as
317+
* jQuery has been loaded on the page. Either by the page itself
318+
* or by the 'jQuerify' button in the Console panel toolbar.
319+
*/
308320
onJQueryDetected: makeInfallible(function(event) {
309321
let win = this.parent.window.wrappedJSObject;
310322

@@ -314,6 +326,12 @@ var FireQueryActor = ActorClass(
314326
win.eval(this.patch);
315327
}),
316328

329+
/**
330+
* Sent from the page (by the jQuery patch) when jQuery.data
331+
* has been modified. The method forwards that event through
332+
* "data-modified" packet to the client side, so the Inspector
333+
* panel can be dynamically updated.
334+
*/
317335
onDataModified: makeInfallible(function(event) {
318336
let win = this.parent.window.wrappedJSObject;
319337

lib/firequery-toolbox-overlay.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ const JQUERYPATCH = "chrome://firequery-resources/content/jquery2-patch.js";
4343
*
4444
* FireQuery uses the overlay to register and attach/detach the
4545
* backend actor.
46+
*
47+
* The rest of the extension can access actor's front object
48+
* as follows:
49+
*
50+
* let toolboxOverlay = this.context.getOverlay(ToolboxOverlayId);
51+
* let front = toolboxOverlay.front;
4652
*/
4753
const FireQueryToolboxOverlay = Class(
4854
/** @lends FireQueryToolboxOverlay */
@@ -121,7 +127,7 @@ const FireQueryToolboxOverlay = Class(
121127
detach: makeInfallible(function() {
122128
Trace.sysout("FireQueryToolboxOverlay.detach;");
123129

124-
// xxxHonza: TODO
130+
// xxxHonza: TODO clean up?
125131

126132
// Emit an event indicating that the detach process is done. This
127133
// can be used e.g. by tests.

0 commit comments

Comments
 (0)