Fix from gregers, patch cleaned up by Erik for, "Util.getRenderedSize does not
calculate with inherited style". Includes manual regression test. r=me, (Closes #1906). CLA on file. git-svn-id: http://svn.openlayers.org/trunk/openlayers@8906 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -484,8 +484,14 @@ OpenLayers.Popup = OpenLayers.Class({
|
||||
var preparedHTML = "<div class='" + this.contentDisplayClass+ "'>" +
|
||||
this.contentDiv.innerHTML +
|
||||
"<div>";
|
||||
|
||||
var containerElement = (this.map) ? this.map.layerContainerDiv
|
||||
: document.body;
|
||||
var realSize = OpenLayers.Util.getRenderedDimensions(
|
||||
preparedHTML, null, { displayClass: this.displayClass }
|
||||
preparedHTML, null, {
|
||||
displayClass: this.displayClass,
|
||||
containerElement: containerElement
|
||||
}
|
||||
);
|
||||
|
||||
// is the "real" size of the div is safe to display in our map?
|
||||
@@ -514,8 +520,10 @@ OpenLayers.Popup = OpenLayers.Class({
|
||||
//content is clipped in only one direction, so we need to
|
||||
// run getRenderedDimensions() again with a fixed dimension
|
||||
var clippedSize = OpenLayers.Util.getRenderedDimensions(
|
||||
preparedHTML, fixedSize,
|
||||
{ displayClass: this.contentDisplayClass }
|
||||
preparedHTML, fixedSize, {
|
||||
displayClass: this.contentDisplayClass,
|
||||
containerElement: containerElement
|
||||
}
|
||||
);
|
||||
|
||||
//if the clipped size is still the same as the safeSize,
|
||||
|
||||
@@ -1478,6 +1478,8 @@ OpenLayers.Util.getBrowserName = function() {
|
||||
* options - {Object}
|
||||
* displayClass - {String} Optional parameter. A CSS class name(s) string
|
||||
* to provide the CSS context of the rendered content.
|
||||
* containerElement - {DOMElement} Optional parameter. Insert the HTML to
|
||||
* this node instead of the body root when calculating dimensions.
|
||||
*
|
||||
* Returns:
|
||||
* {OpenLayers.Size}
|
||||
@@ -1492,6 +1494,9 @@ OpenLayers.Util.getRenderedDimensions = function(contentHTML, size, options) {
|
||||
container.style.position = "absolute";
|
||||
container.style.left = "-9999px";
|
||||
|
||||
var containerElement = (options && options.containerElement)
|
||||
? options.containerElement : document.body;
|
||||
|
||||
//fix a dimension, if specified.
|
||||
if (size) {
|
||||
if (size.w) {
|
||||
@@ -1516,7 +1521,7 @@ OpenLayers.Util.getRenderedDimensions = function(contentHTML, size, options) {
|
||||
container.appendChild(content);
|
||||
|
||||
// append container to body for rendering
|
||||
document.body.appendChild(container);
|
||||
containerElement.appendChild(container);
|
||||
|
||||
// calculate scroll width of content and add corners and shadow width
|
||||
if (!w) {
|
||||
@@ -1532,7 +1537,7 @@ OpenLayers.Util.getRenderedDimensions = function(contentHTML, size, options) {
|
||||
|
||||
// remove elements
|
||||
container.removeChild(content);
|
||||
document.body.removeChild(container);
|
||||
containerElement.removeChild(container);
|
||||
|
||||
return new OpenLayers.Size(w, h);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user