Skip to content

Commit b4f7f96

Browse files
committed
Create jQuery cache grip + handle cache clicking
1 parent ea03ef0 commit b4f7f96

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

lib/firequery-actor.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,11 @@ var FireQueryActor = ActorClass(
156156

157157
let cache = hasJQueryCache(desc.value);
158158
if (cache) {
159-
grip.preview.cache = cache;
159+
cache = Cu.unwaiveXrays(cache);
160+
cache = makeDebuggeeValueIfNeeded(actor.obj, cache);
161+
grip.preview.cache = actor.threadActor.createValueGrip(cache);
162+
163+
// xxxHonza: generate preview for the cache?
160164
}
161165
} else {
162166
items.push(null);

lib/jquery-renderer.js

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ const { Trace, TraceError } = require("firebug.sdk/lib/core/trace.js").get(modul
1212
// DevTools
1313
const { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
1414
const { Widgets } = devtools.require("devtools/webconsole/console-output");
15+
const { VariablesView } = Cu.import("resource:///modules/devtools/VariablesView.jsm", {});
1516

1617
const XHTML_NS = "http://www.w3.org/1999/xhtml";
1718

1819
/**
1920
* @widget This object represents a widget that is used to render
2021
* generic jQuery object preview.
21-
*
22-
* xxxHonza: Use envelope "✉" to indicate jQuery data.
23-
2422
*/
2523
var JQueryRenderer = {
2624
byKind: "jQuery",
@@ -93,15 +91,34 @@ var JQueryRenderer = {
9391
}
9492
},
9593

96-
renderCache: function(element, parentNode) {
97-
if (!element.preview.cache) {
94+
renderCache: function(elementGrip, parentNode) {
95+
let cacheGrip = elementGrip.preview ? elementGrip.preview.cache : null;
96+
if (!cacheGrip) {
9897
return;
9998
}
10099

101-
let cache = this.document.createElementNS(XHTML_NS, "span");
102-
cache.className = "cache"
103-
cache.innerHTML = "✉"
104-
parentNode.appendChild(cache);
100+
// Render a little envelop sign if the element has jQuery data
101+
// associated. Clicking on the envelope opens the variable view
102+
// with detailed information.
103+
let node = this.document.createElementNS(XHTML_NS, "span");
104+
node.className = "cache"
105+
node.innerHTML = "✉"
106+
parentNode.appendChild(node);
107+
108+
// Click handler
109+
let clickHandler = this.onClickCache.bind(this, cacheGrip);
110+
this.message._addLinkCallback(node, clickHandler);
111+
},
112+
113+
onClickCache: function(cacheGrip) {
114+
Trace.sysout("JQueryRenderer.onClickCache;", cacheGrip);
115+
116+
// Open {@link VariablesView} displaying the jQuery object (cache).
117+
this.output.openVariablesView({
118+
label: VariablesView.getString(cacheGrip, { concise: true }),
119+
objectActor: cacheGrip,
120+
autofocus: true,
121+
});
105122
}
106123
};
107124

0 commit comments

Comments
 (0)