Ticket #6921: abs_wip.2.patch

File abs_wip.2.patch, 4.4 kB (added by haysmark, 6 months ago)

Another fix to dojo._abs, for wide borders.

  • _base/html.js

     
    924924 
    925925                // targetBoxType == "border-box" 
    926926                var db = d.body(); 
    927                 if(d.isIE){ 
     927                if(d.isIE || (d.isFF >= 3)){ 
    928928                        var client = node.getBoundingClientRect(); 
    929                         var offset = (d.isIE) ? d._getIeDocumentElementOffset() : { x: 0, y: 0}; 
     929                        var cs; 
     930                        if(d.isFF){ 
     931                                // in FF3 you have to subract the document element margins 
     932                                var dv = node.ownerDocument.defaultView; 
     933                                cs=dv.getComputedStyle(db.parentNode, null); 
     934                        } 
     935                        var offset = (d.isIE) ? d._getIeDocumentElementOffset() : { x: px(db.parentNode,cs.marginLeft), y: px(db.parentNode,cs.marginTop)}; 
    930936                        ret.x = client.left - offset.x; 
    931937                        ret.y = client.top - offset.y; 
    932938                }else{ 
     
    948954                                // Opera seems to be double counting for some elements 
    949955                                ret.x -= _sumAncestorProperties(node, "scrollLeft"); 
    950956                                ret.y -= _sumAncestorProperties(node, "scrollTop"); 
     957 
    951958                                var curnode = node; 
    952959                                do{ 
    953960                                        var n = curnode.offsetLeft; 
     
    964971                                                if(d.isSafari){ 
    965972                                                        ret.x += px(curnode, cs.borderLeftWidth); 
    966973                                                        ret.y += px(curnode, cs.borderTopWidth); 
    967                                                 }else if(d.isMozilla && curnode != db){ 
    968                                                         ret.x += px(curnode, cs.paddingLeft)+px(curnode, cs.marginLeft); 
    969                                                         ret.y += px(curnode, cs.paddingTop)+px(curnode, cs.marginTop); 
     974                                                }else if(d.isFF){ 
     975                                                        // tried left+right with differently sized left/right borders 
     976                                                        // it really is 2xleft border in FF, not left+right, even in RTL! 
     977                                                        ret.x += 2*px(curnode,cs.borderLeftWidth); 
     978                                                        ret.y += 2*px(curnode,cs.borderTopWidth); 
    970979                                                } 
    971980                                        } 
     981                                        // FIXME: static children in a static div in FF2 are affected by the div's border as well 
     982                                        // but offsetParent will skip this div! 
    972983                                        curnode = curnode.offsetParent; 
    973984                                }while((curnode != endNode) && curnode); 
    974985                        }else if(node.x && node.y){ 
  • tests/_base/abs.html

     
     1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
    12<html> 
    23        <head> 
    34                <title>supplementary dojo._abs() tests</title> 
     
    1213                                /* position a red square over pressed button */ 
    1314                                var pos = dojo._abs(this, true); 
    1415                                var marker = document.createElement('div'); 
     16                                document.body.appendChild(marker); 
    1517                                marker.className = "marker"; 
    16                                 with (marker.style) { 
    17                                         top = pos.y; 
    18                                         left = pos.x; 
    19                                 } 
     18                                marker.style.position="absolute"; 
     19                                marker.style.top = pos.y+"px"; 
     20                                marker.style.left = pos.x+"px"; 
    2021                                console.log(marker); 
    21                                 document.body.appendChild(marker); 
     22                                return false; 
    2223                        } 
    2324                                 
    2425                        dojo.addOnLoad(function(){ 
     
    4142                                width: 10px; 
    4243                                height: 10px; 
    4344                                border: none; 
    44                                 margin: 0; 
    45                                 padding: 0; 
     45                                margin: 0px; 
     46                                padding: 0px; 
    4647                                background-color: red; 
    4748                        } 
    4849 
     
    5253                         
    5354                        div { 
    5455                                position: absolute; 
    55                                 border: 3px solid gray; 
    56                                 padding: 6px; 
     56                                border: 17px solid gray; 
     57                                padding: 37px; 
     58                                margin: 29px; 
    5759                                overflow: auto; 
    5860                        } 
    5961 
     
    6264        <body> 
    6365                <h1>supplementary dojo._abs() tests</h1> 
    6466                <button style="top: 100px; left: 200px;">click</button> 
    65                 <button style="top: 800px; left: 200px;">click</button> 
     67                <button style="top: 900px; left: 200px;">click</button> 
    6668                <div id="outer" style="position: absolute; top: 300px; left: 100px; height: 400px; width: 600px;"> 
    6769                        <button style="top: 50px; left: 200px;">click2</button> 
    68                         <div id="middle" style="position: absolute; top: 100px; left: 100px; height: 400px; width: 400px;"> 
     70                        <div id="middle" style="position: absolute; top: 100px; left: 100px; height: 400px; width: 400px; border-width:13px 11px 23px 7px;"> 
    6971                                <div id="staticDiv" style="position: static; margin-top: 20px;"> 
    7072                                        <button style="position: static;">click3</button> 
    7173                                        <br><br><br><br><br> 
     
    7678                                        <button style="top: 500px; left: 100px;">click6</button> 
    7779                                </div> 
    7880                                <button style="position: static;">click7</button> 
    79                                 <button style="position: relative; top: 10px; left: 10px;">click8</button> 
     81                                <button style="position: relative; top: 10px; left: 10px;" id="click8">click8</button> 
    8082                                <button style="top: 300px; left: 200px;">click9</button> 
    8183                        </div> 
    8284                </div>