docs: function(size) {
  
          var safeContentSize = size.clone();
  
          // if our contentDiv has a css 'padding' set on it by a stylesheet, we 
          //  must add that to the desired "size". 
          var contentDivPadding = this.getContentDivPadding();
          var wPadding = contentDivPadding.left + contentDivPadding.right;
          var hPadding = contentDivPadding.top + contentDivPadding.bottom;
  
          // take into account the popup's 'padding' property
          this.fixPadding();
          wPadding += this.padding.left + this.padding.right;
          hPadding += this.padding.top + this.padding.bottom;
  
          if (this.closeDiv) {
              var closeDivWidth = parseInt(this.closeDiv.style.width);
              wPadding += closeDivWidth + contentDivPadding.right;
          }
  
          // prevent the popup from being smaller than a specified minimal size
          if (this.minSize) {
              safeContentSize.w = Math.max(safeContentSize.w, 
                  (this.minSize.w - wPadding));
              safeContentSize.h = Math.max(safeContentSize.h, 
                  (this.minSize.h - hPadding));
          }
  
          // prevent the popup from being bigger than a specified maximum size
          if (this.maxSize) {
              safeContentSize.w = Math.min(safeContentSize.w, 
                  (this.maxSize.w - wPadding));
              safeContentSize.h = Math.min(safeContentSize.h, 
                  (this.maxSize.h - hPadding));
          }
          
          //make sure the desired size to set doesn't result in a popup that 
          // is bigger than the map's viewport.
          //
          if (this.map && this.map.size) {
              
              var extraX = 0, extraY = 0;
              if (this.keepInMap && !this.panMapIfOutOfView) {
                  var px = this.map.getPixelFromLonLat(this.lonlat);
                  switch (this.relativePosition) {
                      case "tr":
                          extraX = px.x;
                          extraY = this.map.size.h - px.y;
                          break;
                      case "tl":
                          extraX = this.map.size.w - px.x;
                          extraY = this.map.size.h - px.y;
                          break;
                      case "bl":
                          extraX = this.map.size.w - px.x;
                          extraY = px.y;
                          break;
                      case "br":
                          extraX = px.x;
                          extraY = px.y;
                          break;
                      default:    
                          extraX = px.x;
                          extraY = this.map.size.h - px.y;
                          break;
                  }
              }    
            
              var maxY = this.map.size.h - 
                  this.map.paddingForPopups.top - 
                  this.map.paddingForPopups.bottom - 
                  hPadding - extraY;
              
              var maxX = this.map.size.w - 
                  this.map.paddingForPopups.left - 
                  this.map.paddingForPopups.right - 
                  wPadding - extraX;
              
              safeContentSize.w = Math.min(safeContentSize.w, maxX);
              safeContentSize.h = Math.min(safeContentSize.h, maxY);
          }
          
          return safeContentSize;
      }