fix shrink rendering bug.

This commit is contained in:
Christopher Jeffrey 2013-08-14 19:56:47 -05:00
parent 34e451bbfa
commit 65fd7d2529

View File

@ -2750,25 +2750,71 @@ Element.prototype.__defineGetter__('tpadding', function() {
* Rendering - here be dragons
*/
Element.prototype._getShrinkBox = function(xi, xl, yi, yl) {
Element.prototype._getShrinkBox = function(xi, xl, yi, yl, get) {
if (!this.children.length) {
return { xi: xi, xl: xi + 1, yi: yi, yl: yi + 1 };
}
var i, el, ret, mxi = xi, mxl = xi + 1, myi = yi, myl = yi + 1;
// This is a chicken and egg problem. We need to determine how the children
// will render in order to determine how this element renders, but it in
// order to figure out how the children will render, they need to know
// exactly how their parent renders, so, we can give them what we have so
// far.
var _lpos;
if (get) {
_lpos = this.lpos;
this.lpos = { xi: xi, xl: xl, yi: yi, yl: yl };
//this.shrink = false;
}
for (i = 0; i < this.children.length; i++) {
el = this.children[i];
ret = el._getCoords();
ret = el._getCoords(get);
// Or just (seemed to work, but probably not good):
// ret = el.lpos || this.lpos;
if (!ret) continue;
// Since the parent element is shrunk, and the child elements think it's
// going to take up as much space as possible, an element anchored to the
// right or bottom will inadvertantly make the parent's shrunken size as
// large as possible. So, we can just use the height and/or width the of
// element.
// if (get) {
if (el.position.left == null && el.position.right != null) {
ret.xl = xi + (ret.xl - ret.xi);
ret.xi = xi;
if (this.screen.autoPadding) {
// Maybe just do this no matter what.
ret.xl += this.ileft;
ret.xi += this.left;
}
}
if (el.position.top == null && el.position.bottom != null) {
ret.yl = yi + (ret.yl - ret.yi);
ret.yi = yi;
if (this.screen.autoPadding) {
// Maybe just do this no matter what.
ret.yl += this.itop;
ret.yi += this.itop;
}
}
if (ret.xi < mxi) mxi = ret.xi;
if (ret.xl > mxl) mxl = ret.xl;
if (ret.yi < myi) myi = ret.yi;
if (ret.yl > myl) myl = ret.yl;
}
if (get) {
this.lpos = _lpos;
//this.shrink = true;
}
if (this.position.width == null
&& (this.position.left == null
|| this.position.right == null)) {
@ -2813,7 +2859,7 @@ Element.prototype._getShrinkBox = function(xi, xl, yi, yl) {
return { xi: xi, xl: xl, yi: yi, yl: yl };
};
Element.prototype._getShrinkContent = function(xi, xl, yi, yl) {
Element.prototype._getShrinkContent = function(xi, xl, yi, yl, get) {
var h = this._clines.length
, w = this._clines.mwidth || 1;
@ -2841,9 +2887,9 @@ Element.prototype._getShrinkContent = function(xi, xl, yi, yl) {
return { xi: xi, xl: xl, yi: yi, yl: yl };
};
Element.prototype._getShrink = function(xi, xl, yi, yl) {
var shrinkBox = this._getShrinkBox(xi, xl, yi, yl)
, shrinkContent = this._getShrinkContent(xi, xl, yi, yl)
Element.prototype._getShrink = function(xi, xl, yi, yl, get) {
var shrinkBox = this._getShrinkBox(xi, xl, yi, yl, get)
, shrinkContent = this._getShrinkContent(xi, xl, yi, yl, get)
, xll = xl
, yll = yl;
@ -2902,7 +2948,7 @@ Element.prototype._getCoords = function(get) {
// Attempt to shrink the element base on the
// size of the content and child elements.
if (this.shrink) {
coords = this._getShrink(xi, xl, yi, yl);
coords = this._getShrink(xi, xl, yi, yl, get);
xi = coords.xi, xl = coords.xl;
yi = coords.yi, yl = coords.yl;
}