[Pkg-mozext-commits] [adblock-plus-element-hiding-helper] 400/483: Don't make things too complicated, EHH has no need for a complicated overlay mechanism

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 dc6e04f117d1f71ee7d04b0614d7c8dce48595be
Author: Wladimir Palant <trev at adblockplus.org>
Date:   Sat Jan 28 14:20:36 2012 +0100

    Don't make things too complicated, EHH has no need for a complicated overlay mechanism
---
 chrome/content/overlay.xul | 56 +++++++++++++++++++++-------------------------
 main.js                    | 39 ++++++++------------------------
 2 files changed, 35 insertions(+), 60 deletions(-)

diff --git a/chrome/content/overlay.xul b/chrome/content/overlay.xul
index dedd79a..e82295b 100644
--- a/chrome/content/overlay.xul
+++ b/chrome/content/overlay.xul
@@ -4,38 +4,34 @@
    - version 2.0 (the "License"). You can obtain a copy of the License at
    - http://mozilla.org/MPL/2.0/. -->
 
-<?xml-stylesheet href="chrome://elemhidehelper/skin/overlay.css" type="text/css"?>
-
 <!DOCTYPE overlay SYSTEM "chrome://elemhidehelper/locale/overlay.dtd">
 
-<overlay id="ehh-overlay"
+<popupset id="ehh-popupset"
     xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     xmlns:html="http://www.w3.org/1999/xhtml">
-  <popupset id="ehh-popupset">
-    <tooltip id="ehh-helpbox" noautohide="true" orient="vertical">
-      <description id="ehh-helpbox-title" value="&helpbox.title;"/>
+  <tooltip id="ehh-helpbox" noautohide="true" orient="vertical">
+    <description id="ehh-helpbox-title" value="&helpbox.title;"/>
 
-      <grid flex="1">
-        <columns>
-          <column/>
-          <column flex="1"/>
-        </columns>
-        <rows id="ehh-helpbox-rows"/>
-      </grid>
-    </tooltip>
-    <tooltip id="ehh-commandlabel" noautohide="true">
-      <hbox align="center">
-        <description id="ehh-commandlabel-key"/>
-        <description id="ehh-commandlabel-alternativeKey"/>
-        <description id="ehh-commandlabel-label"/>
-      </hbox>
-    </tooltip>
-    <tooltip id="ehh-viewsource" noautohide="true" orient="vertical"/>
-    <tooltip id="ehh-elementmarker">
-      <html:div>
-        <html:div class="border"/>
-        <html:div class="label"><html:span class="labelTag"/><html:span class="labelAddition"/></html:div>
-      </html:div>
-    </tooltip>
-  </popupset>
-</overlay>
+    <grid flex="1">
+      <columns>
+        <column/>
+        <column flex="1"/>
+      </columns>
+      <rows id="ehh-helpbox-rows"/>
+    </grid>
+  </tooltip>
+  <tooltip id="ehh-commandlabel" noautohide="true">
+    <hbox align="center">
+      <description id="ehh-commandlabel-key"/>
+      <description id="ehh-commandlabel-alternativeKey"/>
+      <description id="ehh-commandlabel-label"/>
+    </hbox>
+  </tooltip>
+  <tooltip id="ehh-viewsource" noautohide="true" orient="vertical"/>
+  <tooltip id="ehh-elementmarker">
+    <html:div>
+      <html:div class="border"/>
+      <html:div class="label"><html:span class="labelTag"/><html:span class="labelAddition"/></html:div>
+    </html:div>
+  </tooltip>
+</popupset>
diff --git a/main.js b/main.js
index 81aaf82..1bb3307 100644
--- a/main.js
+++ b/main.js
@@ -50,13 +50,7 @@ request.addEventListener("load", function(event)
   if (onShutdown.done)
     return;
 
-  let overlay = {__proto__: null, "_processing": []};
-  for (let child = event.target.responseXML.documentElement.firstElementChild; child; child = child.nextElementSibling)
-    if (child.hasAttribute("id"))
-      overlay[child.getAttribute("id")] = child;
-  for (let child = event.target.responseXML.firstChild; child; child = child.nextSibling)
-    if (child.nodeType == child.PROCESSING_INSTRUCTION_NODE)
-      overlay._processing.push(child);
+  let overlay = event.target.responseXML.documentElement;
 
   // Initialization done, we can start up now
   require("inspectorObserver");
@@ -68,15 +62,10 @@ request.addEventListener("load", function(event)
         if (onShutdown.done || !window.document.getElementById("abp-hooks"))
           return;
 
-        for (let id in overlay)
-          if (id != "_processing")
-            window.document.documentElement.appendChild(window.document.importNode(overlay[id], true));
-        for (let i = 0; i < overlay._processing.length; i++)
-        {
-          let node = window.document.importNode(overlay._processing[i], true);
-          node.data += ' class="elemhidehelper-node"';
-          window.document.insertBefore(node, window.document.firstChild);
-        }
+        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);
 
         window._ehhWrapper = new WindowWrapper(window, elementMarkerClass);
       }, 0);
@@ -90,23 +79,13 @@ request.addEventListener("load", function(event)
       window._ehhWrapper.shutdown();
       delete window._ehhWrapper;
 
-      let remove = [];
-      for (let id in overlay)
-      {
-        if (id != "_processing")
-        {
-          let element = window.document.getElementById(id);
-          if (element)
-            remove.push(element);
-        }
-      }
+      let element = window.document.getElementById(overlay.getAttribute("id"));
+      if (element)
+        element.parentNode.removeChild(element);
 
       for (let child = window.document.firstChild; child; child = child.nextSibling)
         if (child.nodeType == child.PROCESSING_INSTRUCTION_NODE && child.data.indexOf("elemhidehelper-node") >= 0)
-          remove.push(child);
-
-      for (let i = 0; i < remove.length; i++)
-        remove[i].parentNode.removeChild(remove[i]);
+          child.parentNode.removeChild(child);
     }
   });
 }, false);

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