Committing an updated fix for #1906. This fixes a 2.7->2.8 regression in

particular behavior with regard to determining the size of a popup. thanks
to the absolutely tireless work of gregers on this issue! Also, in case 
anyone was wondering? Browsers suck. (Pullup #1906)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@9384 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2009-05-15 15:36:21 +00:00
parent b768574d72
commit 51b5095d48
3 changed files with 55 additions and 6 deletions

View File

@@ -1540,9 +1540,7 @@ OpenLayers.Util.getRenderedDimensions = function(contentHTML, size, options) {
// create temp container div with restricted size
var container = document.createElement("div");
container.style.overflow= "";
container.style.position = "absolute";
container.style.left = "-9999px";
container.style.visibility = "hidden";
var containerElement = (options && options.containerElement)
? options.containerElement : document.body;
@@ -1567,12 +1565,40 @@ OpenLayers.Util.getRenderedDimensions = function(contentHTML, size, options) {
var content = document.createElement("div");
content.innerHTML = contentHTML;
// we need overflow visible when calculating the size
content.style.overflow = "visible";
if (content.childNodes) {
for (var i=0, l=content.childNodes.length; i<l; i++) {
if (!content.childNodes[i].style) continue;
content.childNodes[i].style.overflow = "visible";
}
}
// add content to restricted container
container.appendChild(content);
// append container to body for rendering
containerElement.appendChild(container);
// Opera and IE7 can't handle a node with position:aboslute if it inherits
// position:absolute from a parent.
var parentHasPositionAbsolute = false;
var parent = container.parentNode;
while (parent && parent.tagName.toLowerCase()!="body") {
var parentPosition = OpenLayers.Element.getStyle(parent, "position");
if(parentPosition == "absolute") {
parentHasPositionAbsolute = true;
break;
} else if (parentPosition && parentPosition != "static") {
break;
}
parent = parent.parentNode;
}
if(!parentHasPositionAbsolute) {
container.style.position = "absolute";
}
// calculate scroll width of content and add corners and shadow width
if (!w) {
w = parseInt(content.scrollWidth);