Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/child/requestNotifier.js

Issue 29329839: Issue 3228 - Unbreak object tabs (Closed)
Patch Set: Added comments Created Nov. 25, 2015, 10:49 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/child/objectTabs.js ('k') | lib/contentPolicy.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/child/requestNotifier.js
===================================================================
--- a/lib/child/requestNotifier.js
+++ b/lib/child/requestNotifier.js
@@ -361,8 +361,54 @@ RequestNotifier.addNodeData = function(n
*/
RequestNotifier.getWindowStatistics = function(/**Window*/ wnd)
{
if (windowStats.has(wnd.document))
return windowStats.get(wnd.document);
else
return null;
}
+
+/**
+ * Retrieves the request data associated with a DOM node.
+ * @param {Node} node
+ * @param {Boolean} noParent if missing or false, the search will extend to the parent nodes until one is found that has data associated with it
+ * @param {Integer} [type] request type to be looking for
+ * @param {String} [location] request location to be looking for
+ * @result {[Node, Object]}
+ * @static
+ */
+RequestNotifier.getDataForNode = function(node, noParent, type, location)
+{
+ while (node)
+ {
+ let data = nodeData.get(node);
+ if (typeof data != "undefined")
+ {
+ let entry = null;
+ // Look for matching entry
+ for (let k in data)
+ {
+ if ((!entry || entry.id < data[k].id) &&
+ (typeof type == "undefined" || data[k].type == type) &&
+ (typeof location == "undefined" || data[k].location == location))
+ {
+ entry = data[k];
+ }
+ }
+ if (entry)
+ return [node, entry];
+ }
+
+ // If we don't have any match on this node then maybe its parent will do
+ if ((typeof noParent != "boolean" || !noParent) &&
+ node.parentNode instanceof Ci.nsIDOMElement)
+ {
+ node = node.parentNode;
+ }
+ else
+ {
+ node = null;
+ }
+ }
+
+ return null;
+};
« no previous file with comments | « lib/child/objectTabs.js ('k') | lib/contentPolicy.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld