[Pkg-mozext-commits] [adblock-plus-element-hiding-helper] 263/483: Automatically update selection position if window changes (e.g. is scrolled down)
David Prévot
taffit at moszumanska.debian.org
Thu Jan 22 21:41:47 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 dfb4eb9ead7249986c7b04923f5c72db37ea6ec7
Author: Wladimir Palant <trev at adblockplus.org>
Date: Tue Oct 26 13:29:38 2010 +0200
Automatically update selection position if window changes (e.g. is scrolled down)
---
modules/Aardvark.jsm | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/modules/Aardvark.jsm b/modules/Aardvark.jsm
index 368810c..d1bd458 100644
--- a/modules/Aardvark.jsm
+++ b/modules/Aardvark.jsm
@@ -51,9 +51,11 @@ var Aardvark =
commentElem: null,
mouseX: -1,
mouseY: -1,
+ prevSelectionUpdate: -1,
commandLabelTimer: null,
viewSourceTimer: null,
boxElem: null,
+ paintNode: null,
start: function(wrapper)
{
@@ -288,6 +290,13 @@ var Aardvark =
}
},
+ onAfterPaint: function()
+ {
+ // Don't update position too often
+ if (this.selectedElem && Date.now() - this.prevSelectionUpdate > 20)
+ this.selectElement(this.selectedElem);
+ },
+
setAnchorElement: function(anchor)
{
this.anchorElem = anchor;
@@ -346,6 +355,7 @@ var Aardvark =
selectElement: function(elem)
{
this.selectedElem = elem;
+ this.prevSelectionUpdate = Date.now();
let border = this.boxElem.getElementsByClassName("border")[0];
let label = this.boxElem.getElementsByClassName("label")[0];
@@ -374,12 +384,20 @@ var Aardvark =
if (this.boxElem.ownerDocument != doc)
this.boxElem = doc.importNode(this.boxElem, true);
doc.documentElement.appendChild(this.boxElem);
+
+ this.paintNode = doc.defaultView;
+ if (this.paintNode)
+ this.paintNode.addEventListener("MozAfterPaint", this.onAfterPaint, false);
},
hideSelection: function()
{
if (this.boxElem.parentNode)
this.boxElem.parentNode.removeChild(this.boxElem);
+
+ if (this.paintNode)
+ this.paintNode.removeEventListener("MozAfterPaint", this.onAfterPaint, false);
+ this.paintNode = null;
},
getElementPosition: function(element)
@@ -730,5 +748,5 @@ var 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"])
+for each (let method in ["onMouseClick", "onMouseScroll", "onKeyPress", "onPageHide", "onMouseMove", "onAfterPaint"])
Aardvark[method] = Aardvark.bindMethod(Aardvark[method]);
--
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