[Pkg-mozext-commits] [adblock-plus-element-hiding-helper] 401/483: Removed unnecessary dependencies on Adblock Plus, prepared for restartless Adblock Plus
David Prévot
taffit at moszumanska.debian.org
Thu Jan 22 21:42:01 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 6b7cf3ab2188e4debbcbeb70816913f2075b1955
Author: Wladimir Palant <trev at adblockplus.org>
Date: Sat Jan 28 14:59:42 2012 +0100
Removed unnecessary dependencies on Adblock Plus, prepared for restartless Adblock Plus
---
aardvark.js | 4 +++-
chrome/content/about.js | 30 +-----------------------------
chrome/content/about.xul | 2 +-
inspectorObserver.js | 6 +++---
main.js | 25 ++++++++++++++++---------
windowWrapper.js | 33 +++++++++++++++------------------
6 files changed, 39 insertions(+), 61 deletions(-)
diff --git a/aardvark.js b/aardvark.js
index 20ae486..724d54f 100644
--- a/aardvark.js
+++ b/aardvark.js
@@ -50,6 +50,7 @@ let Aardvark = exports.Aardvark =
this.browser.addEventListener("DOMMouseScroll", this.onMouseScroll, true);
this.browser.addEventListener("keypress", this.onKeyPress, true);
this.browser.addEventListener("mousemove", this.onMouseMove, true);
+ this.browser.addEventListener("select", this.quit, false);
this.browser.contentWindow.addEventListener("pagehide", this.onPageHide, true);
this.browser.contentWindow.focus();
@@ -542,6 +543,7 @@ let Aardvark = exports.Aardvark =
this.browser.removeEventListener("DOMMouseScroll", this.onMouseScroll, true);
this.browser.removeEventListener("keypress", this.onKeyPress, true);
this.browser.removeEventListener("mousemove", this.onMouseMove, true);
+ this.browser.removeEventListener("select", this.quit, false);
this.browser.contentWindow.removeEventListener("pagehide", this.onPageHide, true);
this.anchorElem = null;
@@ -740,5 +742,5 @@ let Aardvark = exports.Aardvark =
// Makes sure event handlers like Aardvark.onKeyPress always have the correct
// this pointer set.
-for each (let method in ["onMouseClick", "onMouseScroll", "onKeyPress", "onPageHide", "onMouseMove", "onAfterPaint"])
+for each (let method in ["onMouseClick", "onMouseScroll", "onKeyPress", "onPageHide", "onMouseMove", "onAfterPaint", "quit"])
Aardvark[method] = Aardvark[method].bind(Aardvark);
diff --git a/chrome/content/about.js b/chrome/content/about.js
index afd9c13..37ed36c 100644
--- a/chrome/content/about.js
+++ b/chrome/content/about.js
@@ -79,38 +79,10 @@ function setExtensionData(name, version, homepage, authors, contributors, transl
E("title").value = name;
E("version").value = version;
E("homepage").value = homepage;
+ E("homepage").setAttribute("href", homepage);
E("authors").textContent = authors.join(", ");
E("contributors").textContent = contributors.join(", ");
E("translators").textContent = translators.join(", ");
E("mainBox").setAttribute("loaded", "true");
}
-
-function loadInBrowser(url)
-{
- let enumerator = Services.wm.getZOrderDOMWindowEnumerator(null, true);
- if (!enumerator.hasMoreElements())
- {
- // On Linux the list returned will be empty, see bug 156333. Fall back to random order.
- enumerator = windowMediator.getEnumerator(null);
- }
- let abpHooks = null;
- while (enumerator.hasMoreElements())
- {
- let window = enumerator.getNext().QueryInterface(Ci.nsIDOMWindow);
- abpHooks = window.document.getElementById("abp-hooks");
- if (abpHooks && abpHooks.addTab)
- {
- window.focus();
- break;
- }
- }
-
- if (abpHooks && abpHooks.addTab)
- abpHooks.addTab(url);
- else
- {
- let protocolService = Cc["@mozilla.org/uriloader/external-protocol-service;1"].getService(Ci.nsIExternalProtocolService);
- protocolService.loadURI(Services.io.newURI(url, null, null), null);
- }
-}
diff --git a/chrome/content/about.xul b/chrome/content/about.xul
index ca1c229..c0a5531 100644
--- a/chrome/content/about.xul
+++ b/chrome/content/about.xul
@@ -34,7 +34,7 @@
</description>
<description id="homepageTitle" value="&homepage.label;"/>
- <description id="homepage" class="text-link" onclick="loadInBrowser(this.getAttribute('value'))"/>
+ <label id="homepage" class="text-link"/>
<vbox id="authorsBox" align="top">
<label id="authorsTitle" control="authors" value="&author.label;"/>
diff --git a/inspectorObserver.js b/inspectorObserver.js
index bca581b..0eb0c6b 100644
--- a/inspectorObserver.js
+++ b/inspectorObserver.js
@@ -28,12 +28,12 @@ let InspectorObserver =
observe: function(subject, topic, data)
{
- if (topic != "inspector-opened")
+ if (topic != "inspector-opened" || !("@adblockplus.org/abp/public;1" in Cc))
return;
let InspectorUI = subject.wrappedJSObject;
- let hooks = InspectorUI.chromeDoc.getElementById("abp-hooks");
- if (!hooks || !require("aardvark").Aardvark.canSelect(hooks.getBrowser()))
+ let window = InspectorUI.chromeWin;
+ if (!window._ehhWrapper || !require("aardvark").Aardvark.canSelect(window._ehhWrapper.browser))
return;
let [label, accesskey, tooltiptext] = this.inspectorButton;
diff --git a/main.js b/main.js
index 1bb3307..b242229 100644
--- a/main.js
+++ b/main.js
@@ -14,6 +14,15 @@ let {WindowWrapper} = require("windowWrapper");
Prefs.migrate("extensions.adblockplus.ehh-selectelement_key", "selectelement_key");
Prefs.migrate("extensions.adblockplus.ehh.showhelp", "showhelp");
+// Window types to attach to
+let knownWindowTypes =
+{
+ "navigator:browser": true,
+ "mail:3pane": true,
+ "mail:messageWindow": true,
+ __proto__: null
+};
+
// Use random marker class
let elementMarkerClass = null;
{
@@ -57,18 +66,16 @@ request.addEventListener("load", function(event)
new WindowObserver({
applyToWindow: function(window)
{
- window.setTimeout(function()
- {
- if (onShutdown.done || !window.document.getElementById("abp-hooks"))
- return;
+ let type = window.document.documentElement.getAttribute("windowtype");
+ if (!(type in knownWindowTypes) || window._ehhWrapper)
+ return;
- window.document.documentElement.appendChild(overlay.cloneNode(true));
+ window.document.documentElement.appendChild(overlay.cloneNode(true));
- let style = window.document.createProcessingInstruction("xml-stylesheet", 'class="elemhidehelper-node" href="chrome://elemhidehelper/skin/overlay.css" type="text/css"');
- window.document.insertBefore(style, window.document.firstChild);
+ let style = window.document.createProcessingInstruction("xml-stylesheet", 'class="elemhidehelper-node" href="chrome://elemhidehelper/skin/overlay.css" type="text/css"');
+ window.document.insertBefore(style, window.document.firstChild);
- window._ehhWrapper = new WindowWrapper(window, elementMarkerClass);
- }, 0);
+ window._ehhWrapper = new WindowWrapper(window, elementMarkerClass);
},
removeFromWindow: function(window)
diff --git a/windowWrapper.js b/windowWrapper.js
index 88aaa61..7757f52 100644
--- a/windowWrapper.js
+++ b/windowWrapper.js
@@ -24,14 +24,12 @@ exports.WindowWrapper = WindowWrapper;
function WindowWrapper(wnd, elementMarkerClass)
{
this.window = wnd;
- this.browser = this.E("abp-hooks").getBrowser();
this.popupShowingHandler = this.popupShowingHandler.bind(this);
this.popupHidingHandler = this.popupHidingHandler.bind(this);
this.keyPressHandler = this.keyPressHandler.bind(this);
this.toggleSelection = this.toggleSelection.bind(this);
this.hideTooltips = this.hideTooltips.bind(this);
- this.stopSelection = this.stopSelection.bind(this);
this.E("ehh-elementmarker").firstElementChild.setAttribute("class", elementMarkerClass);
@@ -40,7 +38,18 @@ function WindowWrapper(wnd, elementMarkerClass)
WindowWrapper.prototype =
{
window: null,
- browser: null,
+
+ get browser()
+ {
+ if ("gBrowser" in this.window)
+ return this.window.gBrowser; // Firefox / SeaMonkey browser
+ else if (typeof this.window.getBrowser == "function")
+ return this.window.getBrowser(); // Thunderbird
+ else if (typeof this.window.getMessageBrowser == "function")
+ return this.window.getMessageBrowser(); // SeaMonkey mail
+
+ throw new Error("Failed to find browser element in this application");
+ },
init: function()
{
@@ -48,7 +57,6 @@ WindowWrapper.prototype =
this.window.addEventListener("popuphiding", this.popupHidingHandler, false);
this.window.addEventListener("keypress", this.keyPressHandler, false);
this.window.addEventListener("blur", this.hideTooltips, true);
- this.browser.addEventListener("select", this.stopSelection, false);
},
shutdown: function()
@@ -57,7 +65,6 @@ WindowWrapper.prototype =
this.window.removeEventListener("popuphiding", this.popupHidingHandler, false);
this.window.removeEventListener("keypress", this.keyPressHandler, false);
this.window.removeEventListener("blur", this.hideTooltips, true);
- this.browser.removeEventListener("select", this.stopSelection, false);
},
E: function(id)
@@ -134,19 +141,9 @@ WindowWrapper.prototype =
toggleSelection: function()
{
- if (this.browser == Aardvark.browser)
- this.stopSelection();
+ if ("@adblockplus.org/abp/public;1" in Cc && this.browser != Aardvark.browser)
+ Aardvark.start(this);
else
- this.startSelection();
- },
-
- startSelection: function()
- {
- Aardvark.start(this);
- },
-
- stopSelection: function()
- {
- Aardvark.quit();
+ Aardvark.quit();
}
};
--
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