[Pkg-mozext-commits] [adblock-plus-element-hiding-helper] 243/483: Register styles for element marker via stylesheet service, make them independent of the website

David Prévot taffit at moszumanska.debian.org
Thu Jan 22 21:41:45 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 d0bad9ddd22049465a900287bd7efcb16ed7349e
Author: Wladimir Palant <trev at adblockplus.org>
Date:   Mon Oct 25 14:32:29 2010 +0200

    Register styles for element marker via stylesheet service, make them independent of the website
---
 chrome/content/elementmarker.css | 116 +++++++++++++++++++++++++++++++++++++++
 chrome/content/overlay.xul       |   6 +-
 modules/AppIntegration.jsm       |  40 ++++++++++++++
 3 files changed, 159 insertions(+), 3 deletions(-)

diff --git a/chrome/content/elementmarker.css b/chrome/content/elementmarker.css
new file mode 100644
index 0000000..bc32cb0
--- /dev/null
+++ b/chrome/content/elementmarker.css
@@ -0,0 +1,116 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Adblock Plus Element Hiding Helper.
+ *
+ * The Initial Developer of the Original Code is
+ * Wladimir Palant.
+ * Portions created by the Initial Developer are Copyright (C) 2006-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+ at namespace url("http://www.w3.org/1999/xhtml");
+
+.%%CLASS%%,
+.%%CLASS%% > .label,
+.%%CLASS%% > .label > b,
+.%%CLASS%% > .border
+{
+  display: block !important;
+  position: static !important;
+  float: none !important;
+  clear: none !important;
+  right: auto !important;
+  bottom: auto !important;
+  z-index: 65535 !important;
+
+  background: transparent !important;
+  border: none !important;
+  clip: auto !important;
+  cursor: auto !important;
+  margin: 0px !important;
+  max-width: none !important;
+  max-height: none !important;
+  min-width: 0px !important;
+  min-height: 0px !important;
+  opacity: 1 !important;
+  outline: none !important;
+  padding: 0px !important;
+  visibility: visible !important;
+  -moz-binding: none !important;
+  -moz-border-radius: 0px !important;
+  -moz-user-focus: none !important;
+  -moz-user-input: none !important;
+  -moz-user-select: none !important;
+}
+
+.%%CLASS%%
+{
+  position: absolute !important;
+
+  width: auto !important;
+  height: auto !important;
+}
+
+.%%CLASS%% > .border
+{
+  border: 2px solid #ff0000 !important;
+}
+
+.%%CLASS%% > .label,
+.%%CLASS%% > .label > b
+{
+  font-family: Arial !important;
+  font-size: 12px !important;
+  color: #000000 !important;
+
+  width: auto !important;
+  height: auto !important;
+  direction: ltr !important;
+  font-size-adjust: none !important;
+  font-stretch: normal !important;
+  font-style: normal !important;
+  font-variant: normal !important;
+  font-weight: normal !important;
+  letter-spacing: normal !important;
+  line-height: normal !important;
+  text-align: start !important;
+  text-decoration: none !important;
+  text-indent: 0px !important;
+  text-shadow: none !important;
+  text-transform: none !important;
+  text-transform: none !important;
+  white-space: normal !important;
+  word-spacing: 0px !important;
+}
+
+.%%CLASS%% > .label
+{
+  float: left !important;
+  background-color: #fff0cc !important;
+  border-color: #000000 !important;
+  border-width: 0px 2px 1px 2px !important;
+  border-style: solid !important;
+  -moz-border-radius-bottomleft: 6px !important;
+  -moz-border-radius-bottomright: 6px !important;
+  padding: 2px 5px !important;
+}
+
+.%%CLASS%% > .label > b
+{
+  display: inline !important;
+  font-weight: bold !important;
+}
diff --git a/chrome/content/overlay.xul b/chrome/content/overlay.xul
index bd6b99f..f53de83 100644
--- a/chrome/content/overlay.xul
+++ b/chrome/content/overlay.xul
@@ -50,9 +50,9 @@
     </tooltip>
     <tooltip id="ehh-viewsource" noautohide="true" orient="vertical"/>
     <tooltip id="ehh-elementmarker">
-      <html:div style="position: absolute; z-index: 65534;">
-        <html:div class="border" style="border: 2px solid #FF0000;"/>
-        <html:div class="label" style="float:left; border: 2px solid #FF0000; background-color: #fff0cc; border-color: #000000; border-width: 0px 2px 1px 2px; -moz-border-radius-bottomleft: 6px; -moz-border-radius-bottomright: 6px; border-style solid; font-family: Arial; text-align: left; color: #000000; font-size: 12px; padding: 2px 5px;"/>
+      <html:div>
+        <html:div class="border"/>
+        <html:div class="label"/>
       </html:div>
     </tooltip>
   </popupset>
diff --git a/modules/AppIntegration.jsm b/modules/AppIntegration.jsm
index 2d9d7b2..03eb769 100644
--- a/modules/AppIntegration.jsm
+++ b/modules/AppIntegration.jsm
@@ -35,6 +35,42 @@ Cu.import(baseURI.spec + "Prefs.jsm");
 
 var AppIntegration =
 {
+  elementMarkerClass: null,
+
+  startup: function()
+  {
+    // Use random marker class
+    let rnd = [];
+    let offset = "a".charCodeAt(0);
+    for (let i = 0; i < 20; i++)
+      rnd.push(offset + Math.random() * 26);
+
+    this.elementMarkerClass = String.fromCharCode.apply(String, rnd);
+
+    // Load CSS asynchronously
+    try
+    {
+      let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIJSXMLHttpRequest);
+      request.open("GET", "chrome://elemhidehelper/content/elementmarker.css");
+      request.overrideMimeType("text/plain");
+
+      let me = this;
+      request.onload = function()
+      {
+        let data = request.responseText.replace(/%%CLASS%%/g, me.elementMarkerClass);
+        let styleService = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService);
+        let ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
+        let url = ioService.newURI("data:text/css," + encodeURIComponent(data), null, null);
+        styleService.loadAndRegisterSheet(url, Ci.nsIStyleSheetService.USER_SHEET);
+      }
+      request.send(null);
+    }
+    catch (e)
+    {
+      Cu.reportError(e);
+    }
+  },
+
   addWindow: function(wnd)
   {
     new WindowWrapper(wnd);
@@ -45,6 +81,8 @@ function WindowWrapper(wnd)
 {
   this.window = wnd;
 
+  this.E("ehh-elementmarker").firstChild.className = AppIntegration.elementMarkerClass;
+
   this.registerEventListeners();
 
   let me = this;
@@ -306,3 +344,5 @@ WindowWrapper.prototype.eventHandlers = [
   ["abp-toolbar-popup", "popupshowing", WindowWrapper.prototype.fillPopup],
   ["ehh-command-selectelement", "command", WindowWrapper.prototype.toggleSelection],
 ];
+
+AppIntegration.startup();

-- 
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