Bug 858594 - Don't include associated label's bounding box by default when getting positioning rect for options popup. r=mbrubeck

This commit is contained in:
Sam Foster 2013-11-08 16:10:02 -08:00
parent e1069c4318
commit 4d1fc7f0e6

View File

@ -175,7 +175,7 @@ FormAssistant.prototype = {
// New elements can be shown when a select is updated so we need to
// reconstruct the inner elements array and to take care of possible
// focus change, this is why we use "self.currentElement" instead of
// focus change, this is why we use "self.currentElement" instead of
// using directly "currentElement".
this._executeDelayed(function(self) {
let currentElement = self.currentElement;
@ -344,7 +344,7 @@ FormAssistant.prototype = {
element = element.ownerDocument.body;
else if (element instanceof HTMLDocument)
element = element.body;
while (element && !this._isEditable(element))
element = element.parentNode;
@ -477,19 +477,22 @@ FormAssistant.prototype = {
},
/** Gets a rect bounding important parts of the element that must be seen when assisting. */
_getRect: function _formHelperGetRect() {
_getRect: function _formHelperGetRect(aOptions={}) {
const kDistanceMax = 100;
let element = this.currentElement;
let elRect = getBoundingContentRect(element);
let labels = this._getLabels();
for (let i=0; i<labels.length; i++) {
let labelRect = labels[i].rect;
if (labelRect.left < elRect.left) {
let isClose = Math.abs(labelRect.left - elRect.left) - labelRect.width < kDistanceMax &&
Math.abs(labelRect.top - elRect.top) - labelRect.height < kDistanceMax;
if (isClose) {
let width = labelRect.width + elRect.width + (elRect.left - labelRect.left - labelRect.width);
return new Rect(labelRect.left, labelRect.top, width, elRect.height).expandToIntegers();
if (aOptions.alignToLabel) {
let labels = this._getLabels();
for (let i=0; i<labels.length; i++) {
let labelRect = labels[i].rect;
if (labelRect.left < elRect.left) {
let isClose = Math.abs(labelRect.left - elRect.left) - labelRect.width < kDistanceMax &&
Math.abs(labelRect.top - elRect.top) - labelRect.height < kDistanceMax;
if (isClose) {
let width = labelRect.width + elRect.width + (elRect.left - labelRect.left - labelRect.width);
return new Rect(labelRect.left, labelRect.top, width, elRect.height).expandToIntegers();
}
}
}
}