[Pkg-javascript-commits] [dojo] 92/149: Cleanup around getIeDocumentElementOffset().
David Prévot
taffit at moszumanska.debian.org
Sat Feb 27 03:13:51 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository dojo.
commit 779e4e2315418ce406262540891ee8db3017f65a
Author: Bill Keese <bill at dojotoolkit.org>
Date: Thu Oct 8 09:17:31 2015 +0900
Cleanup around getIeDocumentElementOffset().
Remove the calls to getIeDocumentElementOffset() since it's a no-op except for IE6-IE7,
which we desupported in Dojo 1.9. Also remove the IE6-IE7 code path from getIeDocumentElementOffset(),
but leave the method itself for backwards compatibility.
Finally, use "'pageX' in event" rather than has("dom-addeventlistener") to check if
an event defines the pageX and pageY properties.
Refs #18717.
---
dom-geometry.js | 62 +++++++++++----------------------------------------------
1 file changed, 12 insertions(+), 50 deletions(-)
diff --git a/dom-geometry.js b/dom-geometry.js
index 39f4ac7..8ef0b9a 100644
--- a/dom-geometry.js
+++ b/dom-geometry.js
@@ -431,47 +431,13 @@ define(["./sniff", "./_base/window","./dom", "./dom-style"],
{x: geom.fixIeBiDiScrollLeft(node.scrollLeft || 0, doc), y: node.scrollTop || 0 };
};
- geom.getIeDocumentElementOffset = function getIeDocumentElementOffset(/*Document?*/ doc){
+ geom.getIeDocumentElementOffset = function(/*Document?*/ doc){
// summary:
- // returns the offset in x and y from the document body to the
- // visual edge of the page for IE
- // doc: Document?
- // Optional document to query. If unspecified, use win.doc.
- // description:
- // The following values in IE contain an offset:
- // | event.clientX
- // | event.clientY
- // | node.getBoundingClientRect().left
- // | node.getBoundingClientRect().top
- // But other position related values do not contain this offset,
- // such as node.offsetLeft, node.offsetTop, node.style.left and
- // node.style.top. The offset is always (2, 2) in LTR direction.
- // When the body is in RTL direction, the offset counts the width
- // of left scroll bar's width. This function computes the actual
- // offset.
-
- //NOTE: assumes we're being called in an IE browser
-
- doc = doc || win.doc;
- var de = doc.documentElement; // only deal with HTML element here, position() handles body/quirks
-
- if(has("ie") < 8){
- var r = de.getBoundingClientRect(), // works well for IE6+
- l = r.left, t = r.top;
- if(has("ie") < 7){
- l += de.clientLeft; // scrollbar size in strict/RTL, or,
- t += de.clientTop; // HTML border size in strict
- }
- return {
- x: l < 0 ? 0 : l, // FRAME element border size can lead to inaccurate negative values
- y: t < 0 ? 0 : t
- };
- }else{
- return {
- x: 0,
- y: 0
- };
- }
+ // Deprecated method previously used for IE6-IE7. Now, just returns `{x:0, y:0}`.
+ return {
+ x: 0,
+ y: 0
+ };
};
geom.fixIeBiDiScrollLeft = function fixIeBiDiScrollLeft(/*Integer*/ scrollLeft, /*Document?*/ doc){
@@ -528,12 +494,9 @@ define(["./sniff", "./_base/window","./dom", "./dom-style"],
ret = {x: ret.left, y: ret.top, w: ret.right - ret.left, h: ret.bottom - ret.top};
if(has("ie") < 9){
- // On IE<9 there's a 2px offset that we need to adjust for, see dojo.getIeDocumentElementOffset()
- var offset = geom.getIeDocumentElementOffset(node.ownerDocument);
-
// fixes the position in IE, quirks mode
- ret.x -= offset.x + (has("quirks") ? db.clientLeft + db.offsetLeft : 0);
- ret.y -= offset.y + (has("quirks") ? db.clientTop + db.offsetTop : 0);
+ ret.x -= (has("quirks") ? db.clientLeft + db.offsetLeft : 0);
+ ret.y -= (has("quirks") ? db.clientTop + db.offsetTop : 0);
}
// account for document scrolling
@@ -581,8 +544,8 @@ define(["./sniff", "./_base/window","./dom", "./dom-style"],
event.layerX = event.offsetX;
event.layerY = event.offsetY;
}
- if(!has("dom-addeventlistener")){
- // old IE version
+
+ if(!("pageX" in event)){
// FIXME: scroll position query is duped from dojo/_base/html to
// avoid dependency on that entire module. Now that HTML is in
// Base, we should convert back to something similar there.
@@ -591,9 +554,8 @@ define(["./sniff", "./_base/window","./dom", "./dom-style"],
// DO NOT replace the following to use dojo/_base/window.body(), in IE, document.documentElement should be used
// here rather than document.body
var docBody = has("quirks") ? doc.body : doc.documentElement;
- var offset = geom.getIeDocumentElementOffset(doc);
- event.pageX = event.clientX + geom.fixIeBiDiScrollLeft(docBody.scrollLeft || 0, doc) - offset.x;
- event.pageY = event.clientY + (docBody.scrollTop || 0) - offset.y;
+ event.pageX = event.clientX + geom.fixIeBiDiScrollLeft(docBody.scrollLeft || 0, doc);
+ event.pageY = event.clientY + (docBody.scrollTop || 0);
}
};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git
More information about the Pkg-javascript-commits
mailing list