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
Родитель 99f307f28e
Коммит 65bfe03175
1 изменённых файлов: 16 добавлений и 2 удалений

Просмотреть файл

@ -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>