Bug 631152 - Search autocomplete popup opens in the wrong position in RTL mode; r=gavin

This commit is contained in:
Ehsan Akhgari 2011-02-03 19:52:46 -05:00
parent 1b6730928a
commit f096ca3c02

View File

@ -640,6 +640,12 @@
]]></body>
</method>
<!--
This method overrides the autocomplete binding's openPopup (essentially
duplicating the logic from the autocomplete popup binding's
openAutocompletePopup method), modifying it so that the popup is aligned with
the inner textbox, but sized to not extend beyond the search bar border.
-->
<method name="openPopup">
<body><![CDATA[
var popup = this.popup;
@ -662,18 +668,26 @@
document.popupNode = null;
const isRTL = getComputedStyle(this, "").direction == "rtl";
var outerRect = this.getBoundingClientRect();
var innerRect = this.inputField.getBoundingClientRect();
var width = outerRect.right - innerRect.left;
if (isRTL) {
var width = innerRect.right - outerRect.left;
} else {
var width = outerRect.right - innerRect.left;
}
popup.setAttribute("width", width > 100 ? width : 100);
var yOffset = outerRect.bottom - innerRect.bottom;
// setConsumeRollupEvent() before we call openPopup(),
// see bug #404438 for more details
popup.popupBoxObject.setConsumeRollupEvent(
this.consumeRollupEvent ?
Ci.nsIPopupBoxObject.ROLLUP_CONSUME :
Ci.nsIPopupBoxObject.ROLLUP_NO_CONSUME);
popup.openPopup(null, "", innerRect.left, outerRect.bottom, false, false);
popup.openPopup(this.inputField, "after_start", 0, yOffset, false, false);
}
]]></body>
</method>