[Pkg-mozext-commits] [adblock-plus-element-hiding-helper] 249/483: Don't descend into data: frames and such when selecting
David Prévot
taffit at moszumanska.debian.org
Thu Jan 22 21:41:46 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository adblock-plus-element-hiding-helper.
commit fff157bb79f0a266705aa036bf8927c5ca69ce3f
Author: Wladimir Palant <trev at adblockplus.org>
Date: Tue Oct 26 08:11:17 2010 +0200
Don't descend into data: frames and such when selecting
---
modules/Aardvark.jsm | 31 ++++++++++++++++++++++++++++++-
modules/AppIntegration.jsm | 33 +--------------------------------
2 files changed, 31 insertions(+), 33 deletions(-)
diff --git a/modules/Aardvark.jsm b/modules/Aardvark.jsm
index 01eec3a..24013f3 100644
--- a/modules/Aardvark.jsm
+++ b/modules/Aardvark.jsm
@@ -55,6 +55,9 @@ var Aardvark = {
};
Aardvark.start = function(wrapper) {
+ if (!this.canSelect(wrapper.browser))
+ return;
+
if (this.browser)
this.quit();
@@ -88,6 +91,32 @@ Aardvark.start = function(wrapper) {
this.onMouseMove({clientX: wndWidth / 2, clientY: wndHeight / 2, screenX: -1, screenY: -1, target: null});
}
+Aardvark.canSelect = function(browser)
+{
+ if (!browser || !browser.contentWindow ||
+ !(browser.contentDocument instanceof Ci.nsIDOMHTMLDocument))
+ {
+ return false;
+ }
+
+ let location = browser.contentWindow.location;
+ if (location.href == "about:blank")
+ {
+ return false;
+ }
+
+ if (location.hostname == "" &&
+ location.protocol != "mailbox:" &&
+ location.protocol != "imap:" &&
+ location.protocol != "news:" &&
+ location.protocol != "snews:")
+ {
+ return false;
+ }
+
+ return true;
+},
+
Aardvark.doCommand = function(command, event) {
if (this[command](this.selectedElem)) {
this.showCommandLabel(this.commands[command + "_key"], this.commands[command + "_label"]);
@@ -211,7 +240,7 @@ Aardvark.onMouseMove = function(event) {
}
let elem = this.browser.contentDocument.elementFromPoint(x, y);
- while (elem && "contentDocument" in elem)
+ while (elem && "contentDocument" in elem && this.canSelect(elem))
{
let rect = elem.getBoundingClientRect();
x -= rect.left;
diff --git a/modules/AppIntegration.jsm b/modules/AppIntegration.jsm
index 03eb769..298c5c5 100644
--- a/modules/AppIntegration.jsm
+++ b/modules/AppIntegration.jsm
@@ -281,7 +281,7 @@ WindowWrapper.prototype =
return;
let prefix = RegExp.$1;
- let enabled = this.canSelect(this.browser);
+ let enabled = Aardvark.canSelect(this.browser);
let running = (enabled && this.browser == Aardvark.browser);
this.E(prefix + "ehh-selectelement").setAttribute("disabled", !enabled);
@@ -289,34 +289,6 @@ WindowWrapper.prototype =
this.E(prefix + "ehh-stopselection").hidden = !running;
},
- canSelect: function()
- {
- let browser = this.browser;
- if (!browser || !browser.contentWindow ||
- !(browser.contentDocument instanceof Ci.nsIDOMHTMLDocument) ||
- !browser.contentDocument.body)
- {
- return false;
- }
-
- let location = browser.contentWindow.location;
- if (location.href == "about:blank")
- {
- return false;
- }
-
- if (location.hostname == "" &&
- location.protocol != "mailbox:" &&
- location.protocol != "imap:" &&
- location.protocol != "news:" &&
- location.protocol != "snews:")
- {
- return false;
- }
-
- return true;
- },
-
toggleSelection: function()
{
if (this.browser == Aardvark.browser)
@@ -327,9 +299,6 @@ WindowWrapper.prototype =
startSelection: function()
{
- if (!this.canSelect())
- return;
-
Aardvark.start(this);
},
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus-element-hiding-helper.git
More information about the Pkg-mozext-commits
mailing list