Bug 649840 - Adjust the direction of the autocomplete popup list based on the textbox direction. r=neil

--HG--
extra : rebase_source : 9d9befb9c9179214cc472498bde6fdab66d9bbb5
This commit is contained in:
Anas Husseini 2011-04-27 10:09:23 +02:00
parent 5b1c23bb81
commit e52a7d8e02
3 changed files with 72 additions and 0 deletions

View File

@ -70,6 +70,7 @@ _TEST_FILES = findbar_window.xul \
test_bug451540.xul \
test_bug471776.xul \
test_bug570192.xul \
test_bug649840.xul \
test_popup_preventdefault_chrome.xul \
window_popup_preventdefault_chrome.xul \
test_largemenu.xul \

View File

@ -0,0 +1,67 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=649840
-->
<window title="Mozilla Bug 649840"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"/>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<textbox id="textLTR" type="autocomplete" autocompletesearch="simple"/>
<textbox id="textRTL" type="autocomplete" autocompletesearch="simple"/>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=649840"
target="_blank">Mozilla Bug 649840</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 649840 **/
SimpleTest.waitForExplicitFinish();
addLoadEvent(runTest);
function runTest()
{
var textLTR = $("textLTR");
var textRTL = $("textRTL");
textLTR.style.direction = "ltr";
textRTL.style.direction = "rtl";
textLTR.value="abcd";
textRTL.value="ابجد";
// open and close the popups to update the popupdir attribute value
textLTR.openPopup();
textLTR.closePopup();
textRTL.openPopup();
textRTL.closePopup();
is(textLTR.popup.style.direction, textLTR.style.direction, "LTR textbox test fails");
is(textRTL.popup.style.direction, textRTL.style.direction, "RTL textbox test fails");
// switch directions of the two textboxes
textLTR.style.direction = "rtl";
textRTL.style.direction = "ltr";
// open and close the popups to update the popupdir attribute value
textLTR.openPopup();
textLTR.closePopup();
textRTL.openPopup();
textRTL.closePopup();
is(textLTR.popup.style.direction, textLTR.style.direction, "RTL-switched textbox test fails");
is(textRTL.popup.style.direction, textRTL.style.direction, "LTR-switched textbox test fails");
SimpleTest.finish();
}
]]>
</script>
</window>

View File

@ -727,6 +727,10 @@
var width = (rect.right - rect.left) * docViewer.fullZoom;
this.setAttribute("width", width > 100 ? width : 100);
// Adjust the direction of the autocomplete popup list based on the textbox direction, bug 649840
var popupDirection = aElement.ownerDocument.defaultView.getComputedStyle(aElement).direction;
this.style.direction = popupDirection;
// setConsumeRollupEvent() before we call openPopup()
var nsIPopupBO = Components.interfaces.nsIPopupBoxObject;
this.popupBoxObject.setConsumeRollupEvent(