OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 * Retrieves the statistics for a window. | 359 * Retrieves the statistics for a window. |
360 * @return {Object} Object with the properties items, blocked, whitelisted, hidd
en, filters containing statistics for the window (might be null) | 360 * @return {Object} Object with the properties items, blocked, whitelisted, hidd
en, filters containing statistics for the window (might be null) |
361 */ | 361 */ |
362 RequestNotifier.getWindowStatistics = function(/**Window*/ wnd) | 362 RequestNotifier.getWindowStatistics = function(/**Window*/ wnd) |
363 { | 363 { |
364 if (windowStats.has(wnd.document)) | 364 if (windowStats.has(wnd.document)) |
365 return windowStats.get(wnd.document); | 365 return windowStats.get(wnd.document); |
366 else | 366 else |
367 return null; | 367 return null; |
368 } | 368 } |
| 369 |
| 370 /** |
| 371 * Retrieves the request data associated with a DOM node. |
| 372 * @param {Node} node |
| 373 * @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 |
| 374 * @param {Integer} [type] request type to be looking for |
| 375 * @param {String} [location] request location to be looking for |
| 376 * @result {[Node, Object]} |
| 377 * @static |
| 378 */ |
| 379 RequestNotifier.getDataForNode = function(node, noParent, type, location) |
| 380 { |
| 381 while (node) |
| 382 { |
| 383 let data = nodeData.get(node); |
| 384 if (typeof data != "undefined") |
| 385 { |
| 386 let entry = null; |
| 387 // Look for matching entry |
| 388 for (let k in data) |
| 389 { |
| 390 if ((!entry || entry.id < data[k].id) && |
| 391 (typeof type == "undefined" || data[k].type == type) && |
| 392 (typeof location == "undefined" || data[k].location == location)) |
| 393 { |
| 394 entry = data[k]; |
| 395 } |
| 396 } |
| 397 if (entry) |
| 398 return [node, entry]; |
| 399 } |
| 400 |
| 401 // If we don't have any match on this node then maybe its parent will do |
| 402 if ((typeof noParent != "boolean" || !noParent) && |
| 403 node.parentNode instanceof Ci.nsIDOMElement) |
| 404 { |
| 405 node = node.parentNode; |
| 406 } |
| 407 else |
| 408 { |
| 409 node = null; |
| 410 } |
| 411 } |
| 412 |
| 413 return null; |
| 414 }; |
OLD | NEW |