@@ -34,10 +34,14 @@ const XHTML_NS = "http://www.w3.org/1999/xhtml";
34
34
const ToolboxOverlayId = FireQueryToolboxOverlay . prototype . overlayId ;
35
35
36
36
/**
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).
41
45
*/
42
46
function DataTooltip ( options ) {
43
47
this . context = options . context ;
@@ -57,11 +61,15 @@ DataTooltip.prototype =
57
61
show : makeInfallible ( function ( ) {
58
62
this . tooltip . hide ( this . target ) ;
59
63
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).
60
67
let dimensions = {
61
68
width : "300" ,
62
69
height : "21"
63
70
} ;
64
71
72
+ // Load the content!
65
73
let frameUrl = self . data . url ( "./markup-tooltip.html" ) ;
66
74
this . tooltip . setIFrameContent ( dimensions , frameUrl ) .
67
75
then ( this . onTooltipLoaded ) ;
@@ -93,19 +101,26 @@ DataTooltip.prototype =
93
101
Content . exportIntoContentScope ( win , contentTrace , "Trace" ) ;
94
102
Content . exportIntoContentScope ( win , Locale , "Locale" ) ;
95
103
104
+ // We need the thread object to get client object for grips
105
+ // (using threadClient.pauseGrip).
96
106
let target = this . toolbox . target ;
97
107
target . activeTab . attachThread ( { } , ( response , threadClient ) => {
98
108
this . threadClient = threadClient ;
99
109
110
+ // The tooltip is opened for given jQuery data.
100
111
let data = JSON . stringify ( this . jQueryData ) ;
101
112
this . postContentMessage ( "initialize" , data ) ;
102
113
114
+ // Do not forget to resume the debugger.
103
115
if ( threadClient . paused ) {
104
116
threadClient . resume ( ) ;
105
117
}
106
118
} ) ;
107
119
} ,
108
120
121
+ /**
122
+ * Update size of the tooltip when the content requests that.
123
+ */
109
124
onTooltipResize : function ( size ) {
110
125
Trace . sysout ( "DataTooltip.onTooltipResize;" , size ) ;
111
126
@@ -130,12 +145,19 @@ DataTooltip.prototype =
130
145
} ) ;
131
146
} ,
132
147
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
+ */
133
153
onNavigate : function ( grip ) {
154
+ // First, get nodeFront object from give grip. Our FQ actor
155
+ // implements helper method for that.
134
156
let toolboxOverlay = this . context . getOverlay ( ToolboxOverlayId ) ;
135
157
return toolboxOverlay . front . getNode ( grip . actor ) . then ( response => {
158
+ // Show the node in the UI and make sure it's selected.
136
159
var node = response . node ;
137
160
this . markup . showNode ( node ) . then ( ( ) => {
138
- // Mark the node as selected and focused.
139
161
this . markup . markNodeAsSelected ( node ) ;
140
162
this . markup . maybeFocusNewSelection ( ) ;
141
163
} ) ;
@@ -144,6 +166,9 @@ DataTooltip.prototype =
144
166
145
167
// Tooltip Content Communication
146
168
169
+ /**
170
+ * Handle events coming from the tooltip iframe (content).
171
+ */
147
172
onContentMessage : function ( event ) {
148
173
//Trace.sysout("DataTooltip.onContentMessage;", event);
149
174
@@ -165,7 +190,7 @@ DataTooltip.prototype =
165
190
} ,
166
191
167
192
/**
168
- * Send message to the content scope (panel 's iframe)
193
+ * Send message to the content scope (tooltip 's iframe)
169
194
*/
170
195
postContentMessage : function ( type , args ) {
171
196
let win = this . contentWin ;
@@ -209,7 +234,7 @@ if (!Tooltip.prototype.setIFrameContent) {
209
234
}
210
235
iframe . addEventListener ( "load" , onLoad , true ) ;
211
236
212
- // load the document from url into the iframe
237
+ // Load the document from url into the iframe
213
238
iframe . setAttribute ( "src" , url ) ;
214
239
215
240
// Put the iframe in the tooltip
0 commit comments