Bug 486821 - Misplaced white line under last visible entry of location bar autocomplete. r=enn

This commit is contained in:
Dão Gottwald 2009-04-09 08:42:01 +02:00
Родитель 07d0daac9e
Коммит 3fc98122e0
2 изменённых файлов: 26 добавлений и 17 удалений

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

@ -1038,11 +1038,11 @@
// Default the height to 0 if we have no rows to show
let height = 0;
if (numRows) {
let lastRowShown = rows[numRows - 1];
let firstRowRect = rows[0].getBoundingClientRect();
let lastRowRect = rows[numRows - 1].getBoundingClientRect();
// Calculate the height to have the first row to last row shown
height = lastRowShown.boxObject.y + lastRowShown.boxObject.height -
rows[0].boxObject.y;
height = lastRowRect.bottom - firstRowRect.top;
}
// Only update the height if we have a non-zero height and if it

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

@ -58,12 +58,14 @@
</content>
<implementation>
<field name="scrollBoxObject">null</field>
<field name="_scrollbox">
document.getAnonymousElementByAttribute(this, "anonid", "main-box");
</field>
<field name="scrollBoxObject">
this._scrollbox.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
</field>
<constructor>
<![CDATA[
var x = document.getAnonymousElementByAttribute(this, "anonid", "main-box");
this.scrollBoxObject = x.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
// add a template build listener
if (this.builder)
this.builder.addListener(this._builderListener);
@ -187,8 +189,19 @@
<parameter name="aElement"/>
<body>
<![CDATA[
if (aElement)
this.scrollBoxObject.ensureElementIsVisible(aElement);
if (!aElement)
return;
var targetRect = aElement.getBoundingClientRect();
var scrollRect = this._scrollbox.getBoundingClientRect();
var offset = targetRect.top - scrollRect.top;
if (offset >= 0) {
// scrollRect.bottom wouldn't take a horizontal scroll bar into account
let scrollRectBottom = scrollRect.top + this._scrollbox.clientHeight;
offset = targetRect.bottom - scrollRectBottom;
if (offset <= 0)
return;
}
this._scrollbox.scrollTop += offset;
]]>
</body>
</method>
@ -461,7 +474,7 @@
<handler event="click">
<![CDATA[
// clicking into nothing should unselect
if (event.originalTarget.getAttribute("anonid") == "main-box") {
if (event.originalTarget == this._scrollbox) {
this.clearSelection();
this.currentItem = null;
}
@ -470,17 +483,13 @@
<handler event="MozSwipeGesture">
<![CDATA[
// Figure out where to scroll to
let targetHeight = 0;
let scrollBox = document.getAnonymousElementByAttribute(this, "anonid", "main-box");
// Only handle swipe gestures up and down
switch (event.direction) {
case event.DIRECTION_DOWN:
targetHeight = scrollBox.scrollHeight;
// Fall through for actual action
this._scrollbox.scrollTop = this._scrollbox.scrollHeight;
break;
case event.DIRECTION_UP:
scrollBox.scrollTop = targetHeight;
this._scrollbox.scrollTop = 0;
break;
}
]]>