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: Created Nov. 6, 2015, 7:45 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
Index: lib/child/requestNotifier.js
===================================================================
--- a/lib/child/requestNotifier.js
+++ b/lib/child/requestNotifier.js
@@ -359,8 +359,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)
Wladimir Palant 2015/11/06 19:52:43 This function moved from lib/requestNotifier.js wi
+{
+ 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;
+};

Powered by Google App Engine
This is Rietveld