[Pkg-javascript-commits] [dojo] 63/88: Refs #16115. Backport [30447] to 1.8. !strict
David Prévot
taffit at moszumanska.debian.org
Thu Aug 21 17:39:39 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag 1.8.5
in repository dojo.
commit 72c8c239752b578de9c0e8bf0a138d60eed44126
Author: Douglas Hays <doughays at dojotoolkit.org>
Date: Mon Jan 28 12:35:29 2013 +0000
Refs #16115. Backport [30447] to 1.8. !strict
git-svn-id: http://svn.dojotoolkit.org/src/branches/1.8/dojo@30475 560b804f-0ae3-0310-86f3-f6aa0a117693
---
tests/window/test_scroll.html | 742 ++++++++++++++++++++++++------------------
window.js | 125 +++++--
2 files changed, 516 insertions(+), 351 deletions(-)
diff --git a/tests/window/test_scroll.html b/tests/window/test_scroll.html
index 7e5fc8a..3130017 100644
--- a/tests/window/test_scroll.html
+++ b/tests/window/test_scroll.html
@@ -10,92 +10,41 @@
FIELDSET IFRAME { width:100px; height:100px; }
</style>
<script type="text/javascript" src="../../dojo.js"
- djConfig="isDebug: true"></script>
+ data-dojo-config="isDebug: true"></script>
<script type="text/javascript">
// Global methods accessed by iframes
var count, loading;
function initIframeMethods(iframeWin, parentWin){
- iframeWin.frameElement.findInput = function(){ return parentWin._findInput(iframeWin) };
- iframeWin.frameElement.scrollMin = function(){ parentWin._scrollMin(iframeWin) };
- iframeWin.frameElement.scrollMax = function(){ parentWin._scrollMax(iframeWin) };
- iframeWin.frameElement.getScroll = function(){ return parentWin._getScroll(iframeWin) };
- iframeWin.frameElement.scrollIntoView = function(){ parentWin._scrollIntoView(iframeWin) };
- iframeWin.frameElement.onClick = function(){ parentWin._onClick(iframeWin) };
+ iframeWin.frameElement.findInput = function(){ return parentWin._findInput(iframeWin); };
+ iframeWin.frameElement.scrollMin = function(n){ parentWin._scroll(iframeWin,true,n); };
+ iframeWin.frameElement.scrollMax = function(n){ parentWin._scroll(iframeWin,false,n); };
+ iframeWin.frameElement.getBoundingRect = function(n){ return parentWin._getBoundingRect(iframeWin, n); };
+ iframeWin.frameElement.getVisibleSize = function(n){ return parentWin._getVisibleSize(iframeWin, n); };
+ iframeWin.frameElement.scrollIntoView = function(x,y,w,h){ parentWin._scrollIntoView(iframeWin,x,y,w,h); };
+ iframeWin.frameElement.onClick = function(e){ parentWin._onClick(iframeWin);return false; };
}
+
function _findInput(win){
return win.document.getElementById('it');
}
- function _scrollMin(win){
- var n = _findInput(win);
- while(n && n.tagName){
- n.scrollTop = -9999;
- n.scrollLeft = -9999;
- n._scrollMinY = n.scrollTop;
- n._scrollMinX = n.scrollLeft;
- n.scrollTop++;
- if(((n._scrollMaxX||0)-n._scrollMinX) == innerScrollBarSize && (n.scrollWidth <= n.clientWidth || n.scrollWidth <= n.offsetWidth)){ // ignore fake scrolls
- }else if((n._scrollMaxX||0) > n._scrollMinX){
- n.scrollLeft++;
- }
- if(n.tagName == "BODY" && (n.scrollLeft || n.scrollTop)){ break; }
- n = n.parentNode;
- }
+
+ function _getBoundingRect(win, n){
+ var r = n.getBoundingClientRect();
+ return { left: r.left, right: r.right, top: r.top, bottom: r.bottom, w: Math.round(r.right - r.left), h: Math.round(r.bottom - r.top) };
}
- function _scrollMax(win){
- var n = _findInput(win);
+
+ function _scroll(win,isMin,n){
while(n && n.tagName){
- n.scrollTop = 9999;
- n.scrollLeft = 9999;
- n._scrollMaxY = n.scrollTop;
- n._scrollMaxX = n.scrollLeft;
- n.scrollTop--;
- if((n._scrollMaxX-(n._scrollMinX||0)) == innerScrollBarSize && (n.scrollWidth <= n.clientWidth || n.scrollWidth <= n.offsetWidth)){
- n._scrollMaxX = n.scrollLeft = (n._scrollMinX || 0); // ignore fake scrolls
- }else{
- n.scrollLeft--;
- }
- if(n.tagName == "BODY" && (n.scrollLeft || n.scrollTop || n._scrollMaxY || n._scrollMaxX)){
+ n.scrollTop = isMin ? -9999 : 9999;
+ n.scrollLeft = isMin ? -9999 : 9999;
+ if(n.tagName == "BODY" && (n.scrollLeft || n.scrollTop)){
break; // skip HTML
}
n = n.parentNode;
}
}
- function _getScroll(win){
- var n = _findInput(win), scroll = '';
- while(n && n.tagName){
- var left = n.scrollLeft - n._scrollMinX,
- top = n.scrollTop - n._scrollMinY,
- right = n._scrollMaxX - n.scrollLeft,
- bottom = n._scrollMaxY - n.scrollTop;
- if(left || top || n._scrollMinX || n._scrollMaxX || n._scrollMinY || n._scrollMaxY){
- //scroll += '('+(left<=right?((left==right?'':'+')+left):(right<0 ? '0' : ('-'+right)))+','+(top<=bottom?((top==bottom?'':'+')+top):(bottom<0 ? '0' : ('-'+bottom)))+')';
- scroll += "(";
- if(left <= right){
- scroll += (left != right && left > 0 ? "+" : "") + left;
- }else{
- scroll += right < 0 ? '0' : ('-' + right);
- }
- scroll += ",";
- if(top <= bottom){
- scroll += (top != bottom && top > 0 ? "+" : "") + top;
- }else{
- scroll += bottom < 0 ? '0' : ('-' + bottom);
- }
- scroll += ")";
- }
- n = n.parentNode;
- }
- return scroll || '(0,0)';
- }
- function _scrollIntoView(win){
- var n = _findInput(win);
- dojo.withGlobal(win, 'scrollIntoView', dojo.window, [n]);
- }
- function _onClick(win){
- _scrollIntoView(win);
- alert(_getScroll(win));
- }
+
var loaded = {};
function iframeLoaded(id){
if(!loaded[id]){ // ignore duplicate notifications
@@ -104,13 +53,59 @@
}
}
- require(["dojo", "doh", "dojo/sniff", "dojo/window", "dojo/domReady!"], function(dojo, doh, has) {
+ require([
+ "doh",
+ "dojo/dom", "dojo/dom-attr", "dojo/dom-geometry", "dojo/dom-style",
+ "dojo/query", "dojo/sniff", "dojo/_base/window", "dojo/window", "dojo/_base/array", "dojo/domReady!"
+ ], function(doh, dom, domAttr, domGeom, domStyle, query, has, baseWin, winUtils, array) {
+
+ // More global methods accessed by iframes
+ _scrollIntoView = function(win,x,y,w,h){
+ var n = _findInput(win);
+ var pos;
+ if(typeof x == "number" && typeof y == "number"){
+ var p = baseWin.withGlobal(win, 'position', domGeom, [ n ]);
+ pos = { x: p.x + x, y: p.y + y, w: isNaN(w) ? 1 : w, h: isNaN(h) ? 1 : h };
+ }
+ baseWin.withGlobal(win, 'scrollIntoView', winUtils, [ n, pos ]);
+ };
+ _onClick = function(win){
+ _scrollIntoView(win);
+ };
+
+ _getVisibleSize = function(win,n){
+ var html = win.document.documentElement,
+ body = win.document.body,
+ rect = n.getBoundingClientRect(),
+ width = Math.min(body.clientWidth || html.clientWidth, html.clientWidth || body.clientWidth),
+ height = Math.min(body.clientHeight || html.clientHeight, html.clientHeight || body.clientHeight),
+ pos = baseWin.withGlobal(win, 'position', domGeom, [ n ]);
+ // adjust width and height for IE nonsense
+ width += Math.round(rect.left - pos.x);
+ height += Math.round(rect.top - pos.y);
+ if(has('ie')){ width += outerScrollBarSize; } // IE10 bug
+ for(y = 0; y < height; y++){
+ for(x = 0; x < width; x++){
+ var pointElement = win.document.elementFromPoint(x,y);
+ if(pointElement == n){
+ // work around browser bugs
+ // Opera 12.12 says the element is showing beyond the browser edge
+ // IE 10 says`
+ for(var w = 1; (x+w) < width && win.document.elementFromPoint(x+w,y) == n; w++);
+ for(var h = 1; (y+h) < height && win.document.elementFromPoint(x,y+h) == n; h++);
+ return { w: w, h: h };
+ }
+ }
+ }
+ return { w: 0, h: 0 };
+ };
+
// Below is the magic code that creates the iframes from the given template.
// This should be generalized for other files to include.
function getIframeSrc(id, content, doctype, rtl){
- content = content.replace(/"/g/*balance"*/,"'").replace(/iframe.javascript/g,"text/javascript").replace(/<input\b/ig,"<INPUT readOnly ");
+ content = content.replace(/"/g/*balance"*/,"'").replace(/iframe.javascript/g,"text/javascript").replace(/<input\b/ig,"<INPUT disabled ");
var iframeSrc = 'javascript:"';
// find browser specific CSS attributes
if(has("ie")){
@@ -155,7 +150,7 @@
'<HEAD>'+
'<STYLE>'+
'* { border:0px solid white;padding:0px;margin:0px;font-style:normal;font-family:monospace;font-size:0px;line-height:normal; }\n'+
- 'INPUT { display:block;background-color:#ff0000;font-size:0px;line-height:0px;overflow:hidden;width:20px;height:20px; }\n'+
+ 'INPUT { display:block;background-color:red;font-size:0px;line-height:0px;overflow:hidden;width:20px;height:20px; }\n'+
'UL { list-style-type: none;line-height:0px;width:45px;overflow:auto; }\n'+
'LI { list-style-type: none;line-height:20px;overflow:visible;max-width:20px;max-height:20px;height:20px;width:20px;float:left; }\n'+
'HR { width:120px;height:1px;visibility:hidden;display:block; }\n'+
@@ -181,7 +176,7 @@
var text = (doctype=="strict"? 'strict': (doctype=="loose"? 'loose' : 'quirks')) + (rtl? ' RTL' : '');
var color = (rtl? 'medium': '') + (doctype=="strict"? 'SpringGreen': (doctype=="loose"? 'Turquoise' : 'Aquamarine'));
var idSuffix = (doctype=="strict"? '_strict': (doctype=="loose"? '_loose': '_quirks')) + (rtl? '_rtl' : '');
- dojo.style(container, "cssText", "display:inline;border:1px ridge gray;padding:0px;margin:0px;background-color:"+color+";text-align:"+(rtl?"right;":"left;"));
+ domStyle.set(container, "cssText", "display:inline;border:1px ridge gray;padding:0px;margin:0px;background-color:"+color+";text-align:"+(rtl?"right;":"left;"));
container.appendChild(document.createTextNode(text));
var iframe = document.createElement('iframe');
iframe.setAttribute('src', iframeSrc);
@@ -191,7 +186,7 @@
iframe.setAttribute('id', id + idSuffix);
iframe.setAttribute('name', id + idSuffix);
iframe.className = className;
- dojo.style(iframe, "cssText", "visibility:hidden;display:block;border:2px solid "+color+";background-color:transparent;margin:0px;padding:3px;"+style);
+ domStyle.set(iframe, "cssText", "visibility:hidden;display:block;border:2px solid "+color+";background-color:transparent;margin:0px;padding:3px;"+style);
container.appendChild(iframe);
srcNode.appendChild(container);
var src = iframe.getAttribute("src");
@@ -201,11 +196,9 @@
}
}
- var usingNative = !(has("mozilla") || has("ie") || has("webkit") || has("opera"));
-
- innerScrollBarSize = dojo.byId("nonscroll").clientWidth - dojo.byId("withscroll").clientWidth;
+ var innerScrollBarSize = Math.ceil(dom.byId("nonscroll").clientWidth - dom.byId("withscroll").clientWidth);
console.debug('inner scrollbar size = ' + innerScrollBarSize);
- outerScrollBarSize = (has("ie") >= 9) ? ((dojo.position(document.documentElement).w - document.documentElement.clientWidth) || innerScrollBarSize) : innerScrollBarSize;
+ var outerScrollBarSize = Math.ceil((has("ie") >= 9) ? ((domGeom.position(document.documentElement).w - document.documentElement.clientWidth) || innerScrollBarSize) : innerScrollBarSize);
console.debug('outer scrollbar size = ' + outerScrollBarSize);
doh.register("dojo.window.scroll",[
@@ -214,9 +207,10 @@
timeout: 20000,
runTest: function(){
loading = new doh.Deferred();
- var testIframes = dojo.query('DIV[type="testIframe"]');
+ var testIframes = query('DIV[type="testIframe"]');
count = testIframes.length * 4;
console.log("count is " + count);
+ // have to do all the iframes at once so the iPad doesn't resize and cause problems
for(var i=0; i < testIframes.length; i++){
var srcNode = testIframes[i];
var content = srcNode.innerHTML || '';
@@ -239,225 +233,333 @@
}
},
function checkAttrs(){
- var body = dojo.body();
- dojo.window.scrollIntoView(body);
- doh.f(dojo.hasAttr(body,'_offsetParent'));
- doh.f(dojo.hasAttr(body,'_parent'));
- },
- function test_8249(){
- generateTest('8249_strict', '(0,-10)', '(0,+10)');
- generateTest('8249_quirks', '(0,-10)', '(0,+10)');
- generateTest('8249_loose_rtl', '(0,-10)', '(0,+10)');
- generateTest('8249_quirks_rtl', '(0,-10)', '(0,+10)');
- },
- function test_8284(){
- var minScroll, maxScroll, fudge=0;
- if(has("ie") <= 8){
- minScroll = maxScroll = 11;
- if(has("ie") <= 6){
- fudge = dojo.byId('8284_quirks').contentWindow.document.body.clientHeight-100; // needed for running inside DOH runner
- }
- }else{
- minScroll = maxScroll = 10;
- }
- generateTestXY('8284_quirks', "0", -maxScroll+fudge, "0", minScroll-fudge);
- generateTestXY('8284_quirks_rtl', "0", -maxScroll+fudge, "0", minScroll-fudge);
- if(has("ie") == 8){
- minScroll = maxScroll = 10;
- }
- generateTestXY('8284_strict', "0", -maxScroll, "0", minScroll);
- generateTestXY('8284_loose_rtl', "0", -maxScroll, "0", minScroll);
- },
- function test_absContent(){
- generateTestXY('absContent_strict', 0, -10, 0, 10);
- generateTestXY('absContent_loose_rtl', 0, -10, 0, 10);
- generateTestXY('absContent_quirks', 0, -10, 0, 10);
- generateTestXY('absContent_quirks_rtl', 0, -10, 0, 10);
- },
- function test_fixedNode(){
- if(!(has("ie") <= 6)){
- generateTest('fixedNode_strict', "(-1,-1)", "(+1,+1)");
- generateTest('fixedNode_loose_rtl', "(-1,-1)", "(+1,+1)");
- }
- if(!has("ie")){
- generateTest('fixedNode_quirks', "(-1,-1)", "(+1,+1)");
- generateTest('fixedNode_quirks_rtl', "(-1,-1)", "(+1,+1)");
- }
- },
- function test_fixedScrollable(){
- if(!(has("ie") <= 6)){
- generateTest('fixedScrollable_strict', has("ie") == 7? "(0,-54)(0,-1)" : "(0,-39)(0,-1)", has("ie") == 7? "(0,+39)(0,+1)" : "(0,+38)(0,+1)");
- generateTest('fixedScrollable_loose_rtl', has("ie") == 7? "(0,-54)(0,-1)" : "(0,-39)(0,-1)", has("ie") == 7? "(0,+39)(0,+1)" : "(0,+38)(0,+1)");
- }
- if(!has("ie")){
- generateTest('fixedScrollable_quirks', "(0,-39)(0,-1)", "(0,+38)(0,+1)");
- generateTest('fixedScrollable_quirks_rtl', "(0,-39)(0,-1)", "(0,+38)(0,+1)");
- }
- },
- function test_7036_8665(){
- var maxScroll = 39;
- var minScroll = 38;
- if(has("ie") <= 7){
- maxScroll = 54;
- minScroll = 39;
- }
- generateTest('7036_8665_strict', "(0,-"+maxScroll+")(0,-1)", "(0,+"+minScroll+")(0,+1)");
- generateTest('7036_8665_loose_rtl', "(0,-"+maxScroll+")(0,-1)", "(0,+"+minScroll+")(0,+1)");
- if(has("ie") == 8){
- maxScroll = 54;
- minScroll = 39;
- }
- generateTest('7036_8665_quirks', "(0,-"+maxScroll+")(0,-1)", "(0,+"+minScroll+")(0,+1)");
- generateTest('7036_8665_quirks_rtl', "(0,-"+maxScroll+")(0,-1)", "(0,+"+minScroll+")(0,+1)");
- },
- function test_innerNoScrollBars(){
- var scroll;
- if(has("ie") <= 6){
- scroll = 53;
- }else if(has("ie") == 7){
- scroll = 46;
- }else{
- scroll = 39;
- }
- generateTestXY('innerNoScrollBars_strict', scroll, -29, scroll, -29);
- if(has("ie") <= 8){
- scroll = -38;
- }
- generateTestXY('innerNoScrollBars_quirks', scroll, -29, scroll, -29);
- if(has("ie") <= 6){
- scroll = 53;
- }else if(has("ie") == 7){
- scroll = 46;
- }else if(has("ie") >= 8 || has("opera")){
- scroll = "0";
- }else if(has("webkit")){
- scroll = "-0";
- }else{
- scroll = 39;
- }
- generateTestXY('innerNoScrollBars_loose_rtl', scroll, -29, scroll, -29);
- if(has("ie") <= 8){
- scroll = -38;
- }
- generateTestXY('innerNoScrollBars_quirks_rtl', scroll, -29, scroll, -29);
- },
- function test_noScrollBars(){
- generateTest('noScrollBars_strict', "(0,0)", "(0,0)");
- generateTest('noScrollBars_quirks', "(0,0)", "(0,0)");
- generateTest('noScrollBars_loose_rtl', "(0,0)", "(0,0)");
- generateTest('noScrollBars_quirks_rtl', "(0,0)", "(0,0)");
- },
- function test_table(){
- var minScroll, maxScroll;
- minScroll = "(0,+15)";
- maxScroll = "(0,-15)";
- generateTest('table_strict', maxScroll, minScroll);
- generateTest('table_loose_rtl', maxScroll, minScroll);
- if(has("ie") <= 6){
- var fudge = dojo.byId('table_quirks').contentWindow.document.body.clientHeight-100; // needed for running inside DOH runner
- maxScroll = "(0,-"+(15-fudge)+")";
- minScroll = "(0,+"+(15-fudge)+")";
- }
- generateTest('table_quirks', maxScroll, minScroll);
- generateTest('table_quirks_rtl', maxScroll, minScroll);
- },
- function test_innerScrollbars(){
- var scroll = innerScrollBarSize - 5;
- generateTestXY('innerScrollbars_strict', -scroll, -scroll, scroll, scroll);
- generateTestXY('innerScrollbars_loose_rtl', -scroll, -scroll, has("ie") == 7 ? -25 : scroll, scroll);
- generateTestXY('innerScrollbars_quirks', -scroll, -scroll, scroll, scroll);
- generateTestXY('innerScrollbars_quirks_rtl', -scroll, -scroll, scroll, scroll);
- },
- function test_8542(){
- var fudge = 0;
- if(has("ie") <= 6){
- fudge = dojo.byId('8542_quirks').contentWindow.document.body.clientHeight-100; // needed for running inside DOH runner
- }
- generateTest('8542_strict', "(0,-10)", "(0,+20)");
- generateTest('8542_quirks', "(0,-"+(10-fudge)+")", "(0,+"+(20-fudge)+")");
- generateTest('8542_loose_rtl', "(0,-10)", "(0,+20)");
- generateTest('8542_quirks_rtl', "(0,-"+(10-fudge)+")", "(0,+"+(20-fudge)+")");
- },
- function test_tooBig(){
- var fudge = 0;
- if(has("ie") <= 6){
- fudge = dojo.byId('tooBig_quirks').contentWindow.document.body.clientHeight-100+innerScrollBarSize; // needed for running inside DOH runner
- }
- var minScroll, maxScroll;
- generateTestXY('tooBig_strict', outerScrollBarSize+10,outerScrollBarSize+20, 1,1);
- generateTestXY('tooBig_quirks', outerScrollBarSize+10-fudge,outerScrollBarSize+20-fudge, 1,1);
- if(has("ie") <= 7 || has("mozilla") || has("webkit")){
- maxScroll = -1;
- }else if(has("ie")){
- maxScroll = +20;
- }else if(has("opera")){
- maxScroll = -90;
- }else{
- maxScroll = outerScrollBarSize+10;
- }
- if(has("ie") <= 7 || has("mozilla") || has("webkit")){
- minScroll = -20;
- }else if(has("opera")){
- minScroll = 80 + outerScrollBarSize;
- }else{
- minScroll = 1;
- }
- generateTestXY('tooBig_loose_rtl', maxScroll,outerScrollBarSize+20, minScroll,1);
- if(has("ie") >= 8){
- maxScroll = -1;
- }
- if(has("ie") == 8){
- minScroll = -20;
- }
- generateTestXY('tooBig_quirks_rtl', maxScroll,outerScrollBarSize+20-fudge, minScroll,1);
- },
- function test_htmlPadding(){
- var fudge = 0;
- if(has("ie") <= 6){
- fudge = dojo.byId('tooBig_quirks').contentWindow.document.body.clientHeight-100+innerScrollBarSize; // needed for running inside DOH runner
- }
- var minScroll, maxScroll;
- if(has("ie") <= 7){
- maxScroll = minScroll = 84;
- }else{
- maxScroll = minScroll = 70;
- }
- generateTest('htmlPadding_strict', "(0,-"+maxScroll+")", "(0,+"+minScroll+")");
- generateTest('htmlPadding_loose_rtl', "(0,-"+maxScroll+")", "(0,+"+minScroll+")");
- if(has("ie") <= 8){
- maxScroll = minScroll = 34;
- }
- generateTest('htmlPadding_quirks', "(0,-"+(maxScroll-fudge)+")", "(0,+"+(minScroll-fudge)+")");
- generateTest('htmlPadding_quirks_rtl', "(0,-"+(maxScroll-fudge)+")", "(0,+"+(minScroll-fudge)+")");
+ var body = baseWin.body();
+ winUtils.scrollIntoView(body);
+ doh.f(domAttr.has(body,'_offsetParent'));
+ doh.f(domAttr.has(body,'_parent'));
}
]);
- function generateTest(id, maxVal, minVal){
- var compare = usingNative? "isNot" : "is";
- with(dojo.byId(id)){
- scrollMin();
- scrollMax();
- scrollIntoView();
- var maxActualScroll = getScroll();
- var maxExpectedScroll = usingNative? "(-1,-1)" : maxVal;
- scrollIntoView(); // make sure the value sticks
- var repMaxActualScroll = getScroll();
- scrollMin();
- scrollIntoView();
- var minActualScroll = getScroll();
- var minExpectedScroll = usingNative? "(+1,+1)" : minVal;
- dojo.byId(id).style.visibility = 'visible';
- doh[compare](maxExpectedScroll, maxActualScroll, id+" max failed");
- doh[compare](maxExpectedScroll, repMaxActualScroll, id+" repeat max failed");
- doh[compare](minExpectedScroll, minActualScroll, id+" min failed");
- }
- }
- function generateTestXY(id, maxScrollX, maxScrollY, minScrollX, minScrollY){
- if(typeof maxScrollX == "number" && maxScrollX > 0){ maxScrollX = "+" + maxScrollX; }
- if(typeof maxScrollY == "number" && maxScrollY > 0){ maxScrollY = "+" + maxScrollY; }
- if(typeof minScrollX == "number" && minScrollX > 0){ minScrollX = "+" + minScrollX; }
- if(typeof minScrollY == "number" && minScrollY > 0){ minScrollY = "+" + minScrollY; }
- generateTest(id, "("+maxScrollX+","+maxScrollY+")", "("+minScrollX+","+minScrollY+")");
- }
+ array.forEach([ '8249',
+ '8284',
+ 'absContent',
+ 'fixedNode',
+ 'fixedScrollable',
+ '7036_8665',
+ 'innerNoScrollBars',
+ 'noScrollBars',
+ 'table',
+ 'innerScrollbars',
+ '8542',
+ 'tooBig',
+ 'htmlPadding' ],
+ function(test){
+ array.forEach([ "_strict", "_quirks", "_loose_rtl", "_quirks_rtl" ],
+ function(mode){
+ var id = test+mode,
+ n, maxWidth, maxHeight, nodeWidth, nodeHeight, rAfterScroll, vAfterScroll, rBeforeScroll, vBeforeScroll;
+ doh.register(id, [
+ {
+ timeout: 4000,
+ name: "compare to native",
+ runTest: function(){ with(dom.byId(id)){
+ n = findInput();
+ scrollMin(n);
+ var d = new doh.Deferred();
+ setTimeout(function(){
+ rBeforeScroll = getBoundingRect(n);
+ vBeforeScroll = getVisibleSize(n);
+ nodeWidth = rBeforeScroll.w;
+ nodeHeight = rBeforeScroll.h;
+ dom.byId(id).style.visibility = 'visible';
+ n.scrollIntoView(true);
+ setTimeout(function(){
+ var vAfterNativeScroll = getVisibleSize(n);
+ scrollIntoView();
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.t(vAfterScroll.w > 0, "min width " + vAfterScroll.w);
+ doh.t(vAfterScroll.h > 0, "min height " + vAfterScroll.h);
+ doh.t(vAfterScroll.w >= vAfterNativeScroll.w, "width compare " + vAfterNativeScroll.w + " to " + vAfterScroll.w);
+ doh.t(vAfterScroll.h >= vAfterNativeScroll.h, "height compare " + vAfterNativeScroll.h + " to " + vAfterScroll.h);
+ maxWidth = Math.max(vAfterNativeScroll.w, vAfterScroll.w);
+ maxHeight = Math.max(vAfterNativeScroll.h, vAfterScroll.h);
+ }), 0);
+ }, 0);
+ }, 0);
+ return d;
+ }}
+ },
+ {
+ timeout: 4000,
+ name: "min start horizontal",
+ runTest: function(){ with(dom.byId(id)){
+ scrollMin(n);
+ var d = new doh.Deferred();
+ setTimeout(function(){
+ scrollIntoView(1,0);
+ setTimeout(function(){
+ rAfterScroll = getBoundingRect(n);
+ vAfterScroll = getVisibleSize(n);
+ if(rAfterScroll.left > rBeforeScroll.left){ // shifted right so all but leftmost pixel on first row is showing
+ doh.is(nodeWidth > maxWidth ? maxWidth : (maxWidth-1), vAfterScroll.w, "min: start: shift right partial width");
+ scrollIntoView(0,0);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.w, maxWidth, "min: start: shift right full width");
+ }), 0);
+ }else if(rAfterScroll.left < rBeforeScroll.left){ // shifted left so only 2 leftmost pixels on first row are showing
+ doh.is(2, vAfterScroll.w, "min: start: shift left width");
+ scrollIntoView(nodeWidth-1,0);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.w, maxWidth, "min: start: shift left full width");
+ }), 0);
+ }else{ // no horizontal scrolling
+ scrollIntoView(0,0,nodeWidth);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(maxWidth, vAfterScroll.w, "min: start: no shift full width");
+ }), 0);
+ }
+ }, 0);
+ }, 0);
+ return d;
+ }}
+ },
+ {
+ timeout: 2000,
+ name: "min start vertical",
+ runTest: function(){ with(dom.byId(id)){
+ var d = new doh.Deferred();
+ if(rAfterScroll.top > rBeforeScroll.top){ // shifted down so all rows are showing
+ doh.is(vAfterScroll.h, maxHeight, "min: start: shift down height");
+ scrollIntoView(1,nodeHeight-1);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.h, maxHeight, "min: start: shift down full height");
+ }), 0);
+ }else if(rAfterScroll.top < rBeforeScroll.top){ // shifted up so only the first row is showing
+ doh.is(1, vAfterScroll.h, "min: start: shift up height");
+ scrollIntoView(0,nodeHeight-1);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.h, maxHeight, "min: start: shift up full height");
+ }), 0);
+ }else{ // no vertical scrolling
+ scrollIntoView(0,nodeHeight-1);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.h, maxHeight, "min: start: no shift full height");
+ }), 0);
+ }
+ return d;
+ }}
+ },
+ {
+ timeout: 4000,
+ name: "min end horizontal",
+ runTest: function(){ with(dom.byId(id)){
+ scrollMin(n);
+ var d = new doh.Deferred();
+ setTimeout(function(){
+ scrollIntoView(nodeWidth-2,nodeHeight-1);
+ setTimeout(function(){
+ rAfterScroll = getBoundingRect(n);
+ vAfterScroll = getVisibleSize(n);
+ if(rAfterScroll.left < rBeforeScroll.left){ // shifted left so all but rightmost pixel on first row is showing
+ doh.is(nodeWidth > maxWidth ? maxWidth : (maxWidth-1), vAfterScroll.w, "min: end: shift left partial width");
+ scrollIntoView(nodeWidth-1,nodeHeight-1);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.w, maxWidth, "min: end: shift left full width");
+ }), 0);
+ }else if(rAfterScroll.left > rBeforeScroll.left){ // shifted right so only 2 rightmost pixels on first row are showing
+ doh.is(2, vAfterScroll.w, "min: end: shift right width");
+ scrollIntoView(0,nodeHeight-1);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.w, maxWidth, "min: end: shift right full width");
+ }), 0);
+ }else{ // no horizontal scrolling
+ scrollIntoView(0,nodeHeight-1,nodeWidth);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.w, maxWidth, "min: end: no shift full width");
+ }), 0);
+ }
+ }, 0);
+ }, 0);
+ return d;
+ }}
+ },
+ {
+ timeout: 2000,
+ name: "min end vertical",
+ runTest: function(){ with(dom.byId(id)){
+ var d = new doh.Deferred();
+ if(rAfterScroll.top < rBeforeScroll.top){ // shifted up so all rows are showing
+ doh.is(vAfterScroll.h, maxHeight, "min: end: shift up height");
+ scrollIntoView(nodeWidth-1,0);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.h, maxHeight, "min: end: shift up full height");
+ }), 0);
+ }else if(rAfterScroll.top > rBeforeScroll.top){ // shifted down so only the last row is showing
+ doh.is(1, vAfterScroll.h, "min: end: shift down height");
+ scrollIntoView(0,0);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.h, maxHeight, "min: end: shift down full height");
+ }), 0);
+ }else{ // no vertical scrolling
+ scrollIntoView(0,nodeHeight-1);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.h, maxHeight, "min: end: no shift full height");
+ }), 0);
+ }
+ return d;
+ }}
+ },
+ {
+ timeout: 4000,
+ name: "max start horizontal",
+ runTest: function(){ with(dom.byId(id)){
+ scrollMax(n);
+ var d = new doh.Deferred();
+ setTimeout(function(){
+ rBeforeScroll = getBoundingRect(n);
+ vBeforeScroll = getVisibleSize(n);
+ scrollIntoView(1,0);
+ setTimeout(function(){
+ rAfterScroll = getBoundingRect(n);
+ vAfterScroll = getVisibleSize(n);
+ if(rAfterScroll.left > rBeforeScroll.left){ // shifted right so all but leftmost pixel on first row is showing
+ doh.is(nodeWidth > maxWidth ? maxWidth : (maxWidth-1), vAfterScroll.w, "max: start: shift right partial width");
+ scrollIntoView(0,0);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.w, maxWidth, "max: start: shift right full width");
+ }), 0);
+ }else if(rAfterScroll.left < rBeforeScroll.left){ // shifted left so only 2 leftmost pixels on first row are showing
+ doh.is(2, vAfterScroll.w, "max: start: shift left width");
+ scrollIntoView(nodeWidth-1,0);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.w, maxWidth, "max: start: shift left full width");
+ }), 0);
+ }else{ // no horizontal scrolling
+ scrollIntoView(0,0,nodeWidth);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.w, maxWidth, "max: start: no shift full width");
+ }), 0);
+ }
+ }, 0);
+ }, 0);
+ return d;
+ }}
+ },
+ {
+ timeout: 2000,
+ name: "max start vertical",
+ runTest: function(){ with(dom.byId(id)){
+ var d = new doh.Deferred();
+ if(rAfterScroll.top > rBeforeScroll.top){ // shifted down so all rows are showing
+ doh.is(vAfterScroll.h, maxHeight, "max: start: shift down height");
+ scrollIntoView(1,nodeHeight-1);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.h, maxHeight, "max: start: shift down full height");
+ }), 0);
+ }else if(rAfterScroll.top < rBeforeScroll.top){ // shifted up so only the first row is showing
+ doh.is(1, vAfterScroll.h, "max: start: shift up height");
+ scrollIntoView(0,nodeHeight-1);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.h, maxHeight, "max: start: shift up full height");
+ }), 0);
+ }else{ // no vertical scrolling
+ scrollIntoView(0,nodeHeight-1);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.h, maxHeight, "max: start: no shift full height");
+ }), 0);
+ }
+ return d;
+ }}
+ },
+ {
+ timeout: 4000,
+ name: "max end horizontal",
+ runTest: function(){ with(dom.byId(id)){
+ scrollMax(n);
+ var d = new doh.Deferred();
+ setTimeout(function(){
+ scrollIntoView(nodeWidth-2,nodeHeight-1);
+ setTimeout(function(){
+ rAfterScroll = getBoundingRect(n);
+ vAfterScroll = getVisibleSize(n);
+ if(rAfterScroll.left < rBeforeScroll.left){ // shifted left so all but rightmost pixel on first row is showing
+ doh.is(nodeWidth > maxWidth ? maxWidth : (maxWidth-1), vAfterScroll.w, "max: end: shift left partial width");
+ scrollIntoView(nodeWidth-1,nodeHeight-1);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.w, maxWidth, "max: end: shift left full width");
+ }), 0);
+ }else if(rAfterScroll.left > rBeforeScroll.left){ // shifted right so only 2 rightmost pixels on first row are showing
+ doh.is(2, vAfterScroll.w, "max: end: shift right width");
+ scrollIntoView(0,nodeHeight-1);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.w, maxWidth, "max: end: shift right full width");
+ }), 0);
+ }else{ // no horizontal scrolling
+ scrollIntoView(0,nodeHeight-1,nodeWidth);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.w, maxWidth, "max: end: no shift full width");
+ }), 0);
+ }
+ }, 0);
+ }, 0);
+ return d;
+ }}
+ },
+ {
+ timeout: 2000,
+ name: "max end vertical",
+ runTest: function(){ with(dom.byId(id)){
+ var d = new doh.Deferred();
+ if(rAfterScroll.top < rBeforeScroll.top){ // shifted up so all rows are showing
+ doh.is(vAfterScroll.h, maxHeight, "max: end: shift up height");
+ scrollIntoView(nodeWidth-1,0);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.h, maxHeight, "max: end: shift up full height");
+ }), 0);
+ }else if(rAfterScroll.top > rBeforeScroll.top){ // shifted down so only the last row is showing
+ doh.is(1, vAfterScroll.h, "max: end: shift down height");
+ scrollIntoView(0,0);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.h, maxHeight, "max: end: shift down full height");
+ }), 0);
+ }else{ // no vertical scrolling
+ scrollIntoView(0,0);
+ setTimeout(d.getTestCallback(function(){
+ vAfterScroll = getVisibleSize(n);
+ doh.is(vAfterScroll.h, maxHeight, "max: end: no shift full height");
+ }), 0);
+ }
+ return d;
+ }}
+ }]);
+ }
+ );
+ }
+ );
+
doh.run();
});
</script>
@@ -473,17 +575,19 @@
<fieldset>
<label for="8249">Scrollable parent != offsetParent:</label>
<div type="testIframe" id="8249">
- <iframestyle>INPUT { float:left; }</iframestyle>
- <div style="border-width:13px;"
- ><ul style="height:70px;"
- ><li><input style="background-color:white;"></li
- ><li><input style="background-color:white;"></li
- ><li><input style="background-color:white;"></li
- ><li><input id=it></li
- ><li><input style="background-color:white;"></li
- ><li><input style="background-color:white;"></li
- ><li><input style="background-color:white;"></li
- ></ul
+ <iframestyle>INPUT { float:left; }
+ HTML, BODY { overflow: hidden; }
+ </iframestyle>
+ <div style="height:61px;width:50px;overflow-y:scroll;margin:11px 20px"
+ ><p style="display:inline;"
+ ><li><input style="visibility:hidden;"></li
+ ><li><input style="visibility:hidden;"></li
+ ><li><input style="visibility:hidden;"></li
+ ><li><input id=it></li
+ ><li><input style="visibility:hidden;"></li
+ ><li><input style="visibility:hidden;"></li
+ ><li><input style="visibility:hidden;"></li
+ ></p
></div>
</div>
</fieldset>
@@ -516,10 +620,10 @@
<fieldset>
<label for="fixedScrollable">Fixed-positioned scrollable content:</label>
<div type="testIframe" id="fixedScrollable">
- <iframestyle>HTML { overflow-x:hidden !important; /*IE6*/ }
- INPUT { height:20px; MZT_MZQ_WKT_WKQ_IEQ_OPQ_OPT_height:28px; width:20px; MZT_MZQ_WKT_WKQ_IEQ_OPQ_OPT_width:28px; }</iframestyle>
- <div style="height:120px;width:70px;overflow-y:scroll;position:fixed;margin:-10px 0px 0px 0px;">
- <input id=it style="margin:120px 0px;border:1px solid red;padding:3px;">
+ <iframestyle>HTML { overflow:hidden !important; /*IE6*/ }
+ INPUT { height:20px; width:20px; }</iframestyle>
+ <div style="height:100px;width:70px;overflow-y:scroll;position:fixed;top:0px;left:0;">
+ <input id=it style="margin:120px 0px;">
<hr style="width:10px;">
</div>
<hr style="height:200px;width:20px;"/>
@@ -528,9 +632,9 @@
<fieldset>
<label for="7036_8665">Double scrollbars with absolute positioned content:</label>
<div type="testIframe" id="7036_8665">
- <iframestyle>INPUT { height:20px; MZT_MZQ_WKT_WKQ_IEQ_OPQ_OPT_height:28px; width:20px; MZT_MZQ_WKT_WKQ_IEQ_OPQ_OPT_width:28px; }</iframestyle>
+ <iframestyle>INPUT { height:28px; width:28px; }</iframestyle>
<div style="height:70px;width:70px;overflow-y:scroll;position:absolute;top:26px;left:5px;"
- ><input id=it style="margin:80px 0px 80px 0px;border:1px solid red;padding:3px;"
+ ><input id=it style="margin:80px 0px 80px 0px;"
><hr style="width:10px;"
></div>
<div style="height:26px;width:10px;position:absolute;top:96px;left:10px;"></div>
@@ -544,9 +648,9 @@
><div style="overflow:hidden; width:20px;height:20px;"
><fieldset style="width:59px;overflow:visible;"
><input style="background-color:green;height:15px;float:left;"
- ><nobr style="margin:7px;padding:3px;border:5px solid pink;overflow:visible;display:block;width:90px;float:left;"
+ ><nobr style="margin:7px;padding:3px;border:5px solid black;overflow:visible;display:block;width:90px;float:left;"
><input style="background-color:black;display:inline;width:24px;height:24px;float:left;"
- ><input id=it style="background-color:red;display:inline;float:left;"
+ ><input id=it style="display:inline;float:left;"
><input style="background-color:blue;display:inline;width:16px;height:16px;float:left;"
></nobr
><input style="background-color:cyan;height:10px;float:left;"
@@ -583,9 +687,9 @@
TABLE { OPR_float:left; }
</iframestyle>
<div style="overflow:scroll;height:80px;width:80px;"
- ><fieldset
- ><table cellspacing="25" cellpadding="0" border="0"
- ><tr><td><input id=it style="width:50px;height:50px;float:left;"></td></tr
+ ><fieldset style="visibility:hidden;"
+ ><table cellspacing="65" cellpadding="0" border="0"
+ ><tr><td><input id=it style="width:50px;height:50px;clear:both;float:left;visibility:visible;"></td></tr
></table
></fieldset
></div>
diff --git a/window.js b/window.js
index a13c325..c9d24b2 100644
--- a/window.js
+++ b/window.js
@@ -1,5 +1,56 @@
-define(["./_base/lang", "./sniff", "./_base/window", "./dom", "./dom-geometry", "./dom-style"],
- function(lang, has, baseWindow, dom, geom, style){
+define(["./_base/lang", "./sniff", "./_base/window", "./dom", "./dom-geometry", "./dom-style", "./dom-construct"],
+ function(lang, has, baseWindow, dom, geom, style, domConstruct){
+
+ // feature detection
+ /* not needed but included here for future reference
+ has.add("rtl-innerVerticalScrollBar-on-left", function(win, doc){
+ var body = baseWindow.body(doc),
+ scrollable = domConstruct.create('div', {
+ style: {overflow:'scroll', overflowX:'hidden', direction:'rtl', visibility:'hidden', position:'absolute', left:'0', width:'64px', height:'64px'}
+ }, body, "last"),
+ center = domConstruct.create('center', {
+ style: {overflow:'hidden', direction:'ltr'}
+ }, scrollable, "last"),
+ inner = domConstruct.create('div', {
+ style: {overflow:'visible', display:'inline' }
+ }, center, "last");
+ inner.innerHTML=" ";
+ var midPoint = Math.max(inner.offsetLeft, geom.position(inner).x);
+ var ret = midPoint >= 32;
+ center.removeChild(inner);
+ scrollable.removeChild(center);
+ body.removeChild(scrollable);
+ return ret;
+ });
+ */
+ has.add("rtl-adjust-position-for-verticalScrollBar", function(win, doc){
+ var body = baseWindow.body(doc),
+ scrollable = domConstruct.create('div', {
+ style: {overflow:'scroll', overflowX:'visible', direction:'rtl', visibility:'hidden', position:'absolute', left:'0', top:'0', width:'64px', height:'64px'}
+ }, body, "last"),
+ div = domConstruct.create('div', {
+ style: {overflow:'hidden', direction:'ltr'}
+ }, scrollable, "last"),
+ ret = geom.position(div).x != 0;
+ scrollable.removeChild(div);
+ body.removeChild(scrollable);
+ return ret;
+ });
+
+ has.add("position-fixed-support", function(win, doc){
+ // IE6, IE7+quirks, and some older mobile browsers don't support position:fixed
+ var body = baseWindow.body(doc),
+ outer = domConstruct.create('span', {
+ style: {visibility:'hidden', position:'fixed', left:'1px', top:'1px'}
+ }, body, "last"),
+ inner = domConstruct.create('span', {
+ style: {position:'fixed', left:'0', top:'0'}
+ }, outer, "last"),
+ ret = geom.position(inner).x != geom.position(outer).x;
+ outer.removeChild(inner);
+ body.removeChild(outer);
+ return ret;
+ });
// module:
// dojo/window
@@ -67,54 +118,59 @@ define(["./_base/lang", "./sniff", "./_base/window", "./dom", "./dom-geometry",
scrollIntoView: function(/*DomNode*/ node, /*Object?*/ pos){
// summary:
- // Scroll the passed node into view, if it is not already.
+ // Scroll the passed node into view using minimal movement, if it is not already.
- // don't rely on node.scrollIntoView working just because the function is there
+ // Don't rely on node.scrollIntoView working just because the function is there since
+ // it forces the node to the page's bottom or top (and left or right in IE) without consideration for the minimal movement.
+ // WebKit's node.scrollIntoViewIfNeeded doesn't work either for inner scrollbars in right-to-left mode
+ // and when there's a fixed position scrollable element
try{ // catch unexpected/unrecreatable errors (#7808) since we can recover using a semi-acceptable native method
node = dom.byId(node);
- var doc = node.ownerDocument || baseWindow.doc, // TODO: why baseWindow.doc? Isn't node.ownerDocument always defined?
+ var doc = node.ownerDocument || baseWindow.doc, // TODO: why baseWindow.doc? Isn't node.ownerDocument always defined?
body = baseWindow.body(doc),
html = doc.documentElement || body.parentNode,
- isIE = has("ie"), isWK = has("webkit");
+ isIE = has("ie"),
+ isWK = has("webkit");
// if an untested browser, then use the native method
- if((!(has("mozilla") || isIE || isWK || has("opera")) || node == body || node == html) && (typeof node.scrollIntoView != "undefined")){
+ if(node == body || node == html){ return; }
+ if(!(has("mozilla") || isIE || isWK || has("opera")) && ("scrollIntoView" in node)){
node.scrollIntoView(false); // short-circuit to native if possible
return;
}
- var backCompat = doc.compatMode == 'BackCompat',
- clientAreaRoot = (isIE >= 9 && "frameElement" in node.ownerDocument.parentWindow)
- ? ((html.clientHeight > 0 && html.clientWidth > 0 && (body.clientHeight == 0 || body.clientWidth == 0 || body.clientHeight > html.clientHeight || body.clientWidth > html.clientWidth)) ? html : body)
- : (backCompat ? body : html),
- scrollRoot = isWK ? body : clientAreaRoot,
- rootWidth = clientAreaRoot.clientWidth,
- rootHeight = clientAreaRoot.clientHeight,
- rtl = !geom.isBodyLtr(doc),
+ var backCompat = doc.compatMode == 'BackCompat',
+ rootWidth = Math.min(body.clientWidth || html.clientWidth, html.clientWidth || body.clientWidth),
+ rootHeight = Math.min(body.clientHeight || html.clientHeight, html.clientHeight || body.clientHeight),
+ scrollRoot = (isWK || backCompat) ? body : html,
nodePos = pos || geom.position(node),
el = node.parentNode,
isFixed = function(el){
- return ((isIE <= 6 || (isIE && backCompat))? false : (style.get(el, 'position').toLowerCase() == "fixed"));
+ return (isIE <= 6 || (isIE == 7 && backCompat))
+ ? false
+ : (has("position-fixed-support") && (style.get(el, 'position').toLowerCase() == "fixed"));
};
if(isFixed(node)){ return; } // nothing to do
-
while(el){
if(el == body){ el = scrollRoot; }
- var elPos = geom.position(el),
- fixedPos = isFixed(el);
+ var elPos = geom.position(el),
+ fixedPos = isFixed(el),
+ rtl = style.getComputedStyle(el).direction.toLowerCase() == "rtl";
if(el == scrollRoot){
elPos.w = rootWidth; elPos.h = rootHeight;
if(scrollRoot == html && isIE && rtl){ elPos.x += scrollRoot.offsetWidth-elPos.w; } // IE workaround where scrollbar causes negative x
- if(elPos.x < 0 || !isIE){ elPos.x = 0; } // IE can have values > 0
- if(elPos.y < 0 || !isIE){ elPos.y = 0; }
+ if(elPos.x < 0 || !isIE || isIE >= 9){ elPos.x = 0; } // older IE can have values > 0
+ if(elPos.y < 0 || !isIE || isIE >= 9){ elPos.y = 0; }
}else{
var pb = geom.getPadBorderExtents(el);
elPos.w -= pb.w; elPos.h -= pb.h; elPos.x += pb.l; elPos.y += pb.t;
var clientSize = el.clientWidth,
scrollBarSize = elPos.w - clientSize;
if(clientSize > 0 && scrollBarSize > 0){
+ if(rtl && has("rtl-adjust-position-for-verticalScrollBar")){
+ elPos.x += scrollBarSize;
+ }
elPos.w = clientSize;
- elPos.x += (rtl && (isIE || el.clientLeft > pb.l/*Chrome*/)) ? scrollBarSize : 0;
}
clientSize = el.clientHeight;
scrollBarSize = elPos.h - clientSize;
@@ -137,21 +193,26 @@ define(["./_base/lang", "./sniff", "./_base/window", "./dom", "./dom-geometry",
}
}
// calculate overflow in all 4 directions
- var l = nodePos.x - elPos.x, // beyond left: < 0
- t = nodePos.y - Math.max(elPos.y, 0), // beyond top: < 0
+ var l = nodePos.x - elPos.x, // beyond left: < 0
+// t = nodePos.y - Math.max(elPos.y, 0), // beyond top: < 0
+ t = nodePos.y - elPos.y, // beyond top: < 0
r = l + nodePos.w - elPos.w, // beyond right: > 0
bot = t + nodePos.h - elPos.h; // beyond bottom: > 0
- if(r * l > 0){
- var s = Math[l < 0? "max" : "min"](l, r);
+ var s, old;
+ if(r * l > 0 && (!!el.scrollLeft || el == scrollRoot || el.scrollWidth > el.offsetHeight)){
+ s = Math[l < 0? "max" : "min"](l, r);
if(rtl && ((isIE == 8 && !backCompat) || isIE >= 9)){ s = -s; }
- nodePos.x += el.scrollLeft;
+ old = el.scrollLeft;
el.scrollLeft += s;
- nodePos.x -= el.scrollLeft;
+ s = el.scrollLeft - old;
+ nodePos.x -= s;
}
- if(bot * t > 0){
- nodePos.y += el.scrollTop;
- el.scrollTop += Math[t < 0? "max" : "min"](t, bot);
- nodePos.y -= el.scrollTop;
+ if(bot * t > 0 && (!!el.scrollTop || el == scrollRoot || el.scrollHeight > el.offsetHeight)){
+ s = Math.ceil(Math[t < 0? "max" : "min"](t, bot));
+ old = el.scrollTop;
+ el.scrollTop += s;
+ s = el.scrollTop - old;
+ nodePos.y -= s;
}
el = (el != scrollRoot) && !fixedPos && el.parentNode;
}
--
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