Changeset 13743

Show
Ignore:
Timestamp:
05/15/08 15:12:56 (6 months ago)
Author:
peller
Message:

Compute layout with padding. Fixes #6764 !strict

Location:
dijit/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • dijit/trunk/layout/BorderContainer.js

    r13547 r13743  
    135135                var changedSide = /left|right/.test(changedRegion); 
    136136 
     137                var cs = dojo.getComputedStyle(this.domNode); 
     138                var pe = dojo._getPadExtents(this.domNode, cs); 
     139                pe.r = parseFloat(cs.paddingRight); pe.b = parseFloat(cs.paddingBottom); 
     140 
    137141                var layoutSides = !changedRegion || (!changedSide && !sidebarLayout); 
    138142                var layoutTopBottom = !changedRegion || (changedSide && sidebarLayout); 
     
    178182 
    179183                var splitterBounds = { 
    180                         left: (sidebarLayout ? leftWidth + leftSplitterThickness: "0") + "px", 
    181                         right: (sidebarLayout ? rightWidth + rightSplitterThickness: "0") + "px" 
     184                        left: (sidebarLayout ? leftWidth + leftSplitterThickness: 0) + pe.l + "px", 
     185                        right: (sidebarLayout ? rightWidth + rightSplitterThickness: 0) + pe.r + "px" 
    182186                }; 
    183187 
    184188                if(topSplitter){ 
    185189                        dojo.mixin(topSplitter.style, splitterBounds); 
    186                         topSplitter.style.top = topHeight + "px"; 
     190                        topSplitter.style.top = topHeight + pe.t + "px"; 
    187191                } 
    188192 
    189193                if(bottomSplitter){ 
    190194                        dojo.mixin(bottomSplitter.style, splitterBounds); 
    191                         bottomSplitter.style.bottom = bottomHeight + "px"; 
     195                        bottomSplitter.style.bottom = bottomHeight + pe.b + "px"; 
    192196                } 
    193197 
    194198                splitterBounds = { 
    195                         top: (sidebarLayout ? "0" : topHeight + topSplitterThickness) + "px", 
    196                         bottom: (sidebarLayout ? "0" : bottomHeight + bottomSplitterThickness) + "px" 
     199                        top: (sidebarLayout ? 0 : topHeight + topSplitterThickness) + pe.t + "px", 
     200                        bottom: (sidebarLayout ? 0 : bottomHeight + bottomSplitterThickness) + pe.b + "px" 
    197201                }; 
    198202 
    199203                if(leftSplitter){ 
    200204                        dojo.mixin(leftSplitter.style, splitterBounds); 
    201                         leftSplitter.style.left = leftWidth + "px"; 
     205                        leftSplitter.style.left = leftWidth + pe.l + "px"; 
    202206                } 
    203207 
    204208                if(rightSplitter){ 
    205209                        dojo.mixin(rightSplitter.style, splitterBounds); 
    206                         rightSplitter.style.right = rightWidth + "px"; 
     210                        rightSplitter.style.right = rightWidth + pe.r +  "px"; 
    207211                } 
    208212 
    209213                dojo.mixin(centerStyle, { 
    210                         top: topHeight + topSplitterThickness + "px", 
    211                         left: leftWidth + leftSplitterThickness + "px", 
    212                         right: rightWidth + rightSplitterThickness + "px", 
    213                         bottom: bottomHeight + bottomSplitterThickness + "px" 
     214                        top: pe.t + topHeight + topSplitterThickness + "px", 
     215                        left: pe.l + leftWidth + leftSplitterThickness + "px", 
     216                        right: pe.r + rightWidth + rightSplitterThickness + "px", 
     217                        bottom: pe.b + bottomHeight + bottomSplitterThickness + "px" 
    214218                }); 
    215219 
    216220                var bounds = { 
    217                         top: sidebarLayout ? "0" : centerStyle.top, 
    218                         bottom: sidebarLayout ? "0" : centerStyle.bottom 
     221                        top: sidebarLayout ? pe.t + "px" : centerStyle.top, 
     222                        bottom: sidebarLayout ? pe.b + "px" : centerStyle.bottom 
    219223                }; 
    220224                dojo.mixin(leftStyle, bounds); 
    221225                dojo.mixin(rightStyle, bounds); 
    222                 leftStyle.left = rightStyle.right = topStyle.top = bottomStyle.bottom = "0"; 
     226                leftStyle.left = pe.l + "px"; rightStyle.right = pe.r + "px"; topStyle.top = pe.t + "px"; bottomStyle.bottom = pe.b + "px"; 
    223227                if(sidebarLayout){ 
    224                         topStyle.left = bottomStyle.left = leftWidth + (this.isLeftToRight() ? leftSplitterThickness : 0) + "px"; 
    225                         topStyle.right = bottomStyle.right = rightWidth + (this.isLeftToRight() ? 0 : rightSplitterThickness) + "px"; 
     228                        topStyle.left = bottomStyle.left = leftWidth + (this.isLeftToRight() ? leftSplitterThickness : 0) + pe.l + "px"; 
     229                        topStyle.right = bottomStyle.right = rightWidth + (this.isLeftToRight() ? 0 : rightSplitterThickness) + pe.r + "px"; 
    226230                }else{ 
    227                         topStyle.left = topStyle.right = bottomStyle.left = bottomStyle.right = "0"; 
     231                        topStyle.left = bottomStyle.left = pe.l + "px"; 
     232                        topStyle.right = bottomStyle.right = pe.r + "px"; 
    228233                } 
    229234 
     
    236241                        // childNode.resize({h: int, w: int}) for each child node) 
    237242 
    238                         var borderBox = function(n, b){ 
     243                        var borderBox = function(n, b, s){ 
    239244                                n=dojo.byId(n); 
    240                                 var s = dojo.getComputedStyle(n); 
     245                                s = s || dojo.getComputedStyle(n); 
    241246                                if(!b){ return dojo._getBorderBox(n, s); } 
    242247                                var me = dojo._getMarginExtents(n, s); 
     
    247252                        var resizeWidget = function(widget, dim){ 
    248253                                if(widget){ 
    249                                         widget.resize ? widget.resize(dim) : dojo.marginBox(widget.domNode, dim); 
     254                                        (widget.resize ? widget.resize(dim) : dojo.marginBox(widget.domNode, dim)); 
    250255                                } 
    251256                        }; 
     
    253258                        // TODO: use dim passed in to resize() (see _LayoutWidget.js resize()) 
    254259                        // Then can make borderBox setBorderBox(), since no longer need to ever get the borderBox() size 
    255                         var thisBorderBox = borderBox(this.domNode); 
    256  
    257                         var containerHeight = thisBorderBox.h; 
     260                        var thisBorderBox = borderBox(this.domNode, null, cs); 
     261 
     262                        var containerHeight = thisBorderBox.h - pe.t - pe.b; 
    258263                        var middleHeight = containerHeight; 
    259264                        if(this._top){ middleHeight -= topHeight; } 
     
    269274                        resizeWidget(this._rightWidget, {h: sidebarHeight}); 
    270275 
    271                         var containerWidth = thisBorderBox.w; 
     276                        var containerWidth = thisBorderBox.w - pe.l - pe.r; 
    272277                        var middleWidth = containerWidth; 
    273278                        if(this._left){ middleWidth -= leftWidth; } 
  • dijit/trunk/tests/layout/test_BorderContainer.html

    r13735 r13743  
    5656        </script> 
    5757</head> 
    58 <body> 
     58<body class="tundra"> 
    5959 
    6060        <h2 class="testTitle">dijit.layout.BorderContainer tests</h2> 
     
    6262 
    6363        <div id="border1" dojoType="dijit.layout.BorderContainer" 
    64                 style="border: 2px solid black; width: 90%; height: 300px; padding: 10px;"> 
     64                style="padding: 5px; border: 2px solid blue; width: 90%; height: 300px; padding: 10px;"> 
    6565                <div dojoType="dijit.layout.ContentPane" region="top" style="background-color: #b39b86; border: 15px black solid; height: 100px;" splitter="true"> 
    6666                        top bar