[Pkg-mozext-commits] [itsalltext] 347/459: Try two of ticket:48

David Prévot taffit at moszumanska.debian.org
Tue Feb 24 23:26:37 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository itsalltext.

commit 60da34f6271b57f5ef63c78659820f003f2bccde
Author: Christian Höltje <docwhat at gerf.org>
Date:   Tue Dec 23 01:31:22 2008 -0500

    Try two of ticket:48
    
    Added incremental locking for DOM change checks and added check to
    only add listeners to cache objects once.
    
    Thanks to ... erm,
    uh... me.yahoo.com/a/1xmqm40gvt8fnfmyfoboc3chg9lepoo-#8b7ff
---
 src/chrome/content/cacheobj.js | 29 ++++++++++++++++-------------
 src/chrome/content/monitor.js  | 22 +++++++++++++++++-----
 2 files changed, 33 insertions(+), 18 deletions(-)

diff --git a/src/chrome/content/cacheobj.js b/src/chrome/content/cacheobj.js
index 511e0e4..3a30a20 100644
--- a/src/chrome/content/cacheobj.js
+++ b/src/chrome/content/cacheobj.js
@@ -45,6 +45,7 @@ function CacheObj(node) {
     that.private_is_watching = false;
     that.button_fade_timer = null;
     that.is_focused = false;
+    that.is_listening = false;
 
     that.node_id = that.getNodeIdentifier(node);
 
@@ -591,15 +592,14 @@ CacheObj.prototype.addGumDrop = function () {
         doc,
         gumdrop,
         parent,
-        nextSibling,
-        previous_ignore = ItsAllText.monitor._ignore_DOMSubtreeModified;
+        nextSibling;
 
     try {
-        ItsAllText.monitor._ignore_DOMSubtreeModified = true;
+        ItsAllText.monitor.incrementLock();
 
         if (cache_object.button !== null) {
             cache_object.adjust();
-            ItsAllText.monitor._ignore_DOMSubtreeModified = previous_ignore;
+            ItsAllText.monitor.decrementLock();
             return; /*already done*/
         }
 
@@ -607,20 +607,23 @@ CacheObj.prototype.addGumDrop = function () {
 
         // Add the textarea mouseovers even if the button is disabled
         node = cache_object.node;
-        ItsAllText.listen(node, "mouseover", ItsAllText.hitch(cache_object, "mouseover"), false);
-        ItsAllText.listen(node, "mouseout",  ItsAllText.hitch(cache_object, "mouseout"),  false);
-        ItsAllText.listen(node, "focus",     ItsAllText.hitch(cache_object, "mouseover"), false);
-        ItsAllText.listen(node, "blur",      ItsAllText.hitch(cache_object, "mouseout"),  false);
-        ItsAllText.listen(node, "keypress",  ItsAllText.hitch(cache_object, "keypress"),  false);
+        if (!cache_object.is_listening) {
+            ItsAllText.listen(node, "mouseover", ItsAllText.hitch(cache_object, "mouseover"), false);
+            ItsAllText.listen(node, "mouseout",  ItsAllText.hitch(cache_object, "mouseout"),  false);
+            ItsAllText.listen(node, "focus",     ItsAllText.hitch(cache_object, "mouseover"), false);
+            ItsAllText.listen(node, "blur",      ItsAllText.hitch(cache_object, "mouseout"),  false);
+            ItsAllText.listen(node, "keypress",  ItsAllText.hitch(cache_object, "keypress"),  false);
+            cache_object.is_listening = true;
+        }
         if (ItsAllText.getDisableGumdrops()) {
-            ItsAllText.monitor._ignore_DOMSubtreeModified = previous_ignore;
+            ItsAllText.monitor.decrementLock();
             return;
         }
         ItsAllText.debug('addGumDrop()', cache_object);
 
         doc = node.ownerDocument;
         if (!node.parentNode) {
-            ItsAllText.monitor._ignore_DOMSubtreeModified = previous_ignore;
+            ItsAllText.monitor.decrementLock();
             return;
         }
 
@@ -669,9 +672,9 @@ CacheObj.prototype.addGumDrop = function () {
         cache_object.mouseout(null);
         cache_object.adjust();
     } catch (e) {
-        ItsAllText.monitor._ignore_DOMSubtreeModified = previous_ignore;
+        ItsAllText.monitor.decrementLock();
     }
-    ItsAllText.monitor._ignore_DOMSubtreeModified = previous_ignore;
+    ItsAllText.monitor.decrementLock();
 };
 
 /**
diff --git a/src/chrome/content/monitor.js b/src/chrome/content/monitor.js
index 2801b1f..9f22794 100644
--- a/src/chrome/content/monitor.js
+++ b/src/chrome/content/monitor.js
@@ -157,11 +157,21 @@ monitor.prototype.hitched_watcher = function (offset, init) {
     }
 };
 
-monitor.prototype._ignore_DOMSubtreeModified      = false;
+monitor.prototype._lock_count = 0;
+
+monitor.prototype.hitched_incrementLock = function () {
+    this._lock_count ++;
+};
+monitor.prototype.hitched_decrementLock = function () {
+    this._lock_count --;
+};
+monitor.prototype.hitched_isLocked = function () {
+    return this._lock_count > 0;
+};
 
 monitor.prototype.hitched_handleSubtreeModified = function (event) {
     var has_textareas;
-    if (this._ignore_DOMSubtreeModified) {
+    if (this.isLocked()) {
         return;
     }
     has_textareas = event.originalTarget.getElementsByTagName('textarea').length > 0;
@@ -169,12 +179,12 @@ monitor.prototype.hitched_handleSubtreeModified = function (event) {
         ItsAllText.debug('handleSubtreeModified: %o', event.target);
         try {
             // Ignore events while adding the gumdrops.
-            this._ignore_DOMSubtreeModified = true;
+            this.incrementLock();
             this.watcher(0, true);
         } catch (e) {
-            this._ignore_DOMSubtreeModified = false;
+            this.decrementLock();
         }
-        this._ignore_DOMSubtreeModified = false;
+        this.decrementLock();
     }
 };
 
@@ -196,7 +206,9 @@ monitor.prototype.hitched_startPage = function (event, force) {
     this.iat.listen(unsafeWin, 'DOMSubtreeModified', this.handleSubtreeModified);
 
     // Kick off a watcher now...
+    this.incrementLock();
     this.watcher(0, true);
+    this.decrementLock();
 
     // Set up the future ones
     this.restart();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/itsalltext.git



More information about the Pkg-mozext-commits mailing list