Bug 584703. Compute XUL listbox contents overlow area correctly. r=enndeakin

--HG--
extra : rebase_source : a5c20c7ad240643a734a3e0f27c5357adc13c9ae
This commit is contained in:
Robert O'Callahan 2010-09-06 15:23:44 +12:00
Родитель fd13ad317f
Коммит 2090c7128c
3 изменённых файлов: 43 добавлений и 0 удалений

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

@ -290,6 +290,24 @@ nsListBoxBodyFrame::DoLayout(nsBoxLayoutState& aBoxLayoutState)
nsresult rv = nsBoxFrame::DoLayout(aBoxLayoutState);
// determine the real height for the scrollable area from the total number
// of rows, since non-visible rows don't yet have frames
nsSize size = GetSize();
nsRect overflowRect = nsRect(nsPoint(0, 0), size);
if (mLayoutManager) {
nsIFrame* childFrame = mFrames.FirstChild();
while (childFrame) {
ConsiderChildOverflow(overflowRect, childFrame);
childFrame = childFrame->GetNextSibling();
}
nsSize prefSize = mLayoutManager->GetPrefSize(this, aBoxLayoutState);
if (prefSize.height > overflowRect.height) {
overflowRect.height = prefSize.height;
}
}
FinishAndStoreOverflow(&overflowRect, GetSize());
if (mScrolling)
aBoxLayoutState.SetPaintingDisabled(PR_FALSE);

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

@ -156,6 +156,8 @@ public:
virtual PRBool SupportsOrdinalsInChildren();
virtual PRBool ComputesOwnOverflowArea() { return PR_TRUE; }
protected:
class nsPositionChangedEvent;
friend class nsPositionChangedEvent;

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

@ -104,6 +104,8 @@ function testListbox()
ok(listbox.firstChild.getBoundingClientRect().width < listbox.getBoundingClientRect().width - 10,
id + ": Scrollbar visible");
var rowHeight = listbox.firstChild.getBoundingClientRect().height;
listbox.selectedIndex = 0;
sendKey("PAGE_DOWN", id);
is(listbox.selectedItem.id, id + "_item8", id + ": Page down should go to the item one visible page away");
@ -124,6 +126,27 @@ function testListbox()
sendKey("PAGE_UP", id);
is(listbox.selectedItem.id, id + "_item1", id + ": Third page up should return to the first visible item");
is(listbox.getIndexOfFirstVisibleRow(), 0, id + ": Third page up should not have scrolled at all");
var scrollHeight = document.getAnonymousNodes(listbox)[1].lastChild.scrollHeight;
is(scrollHeight, rowHeight * 15, id + ": scrollHeight when rows set");
listbox.minHeight = 50;
scrollHeight = document.getAnonymousNodes(listbox)[1].lastChild.scrollHeight;
is(scrollHeight, rowHeight * 15, id + ": scrollHeight when rows and minimium height set");
listbox.removeAttribute("rows");
var availHeight = document.getAnonymousNodes(listbox)[1].lastChild.getBoundingClientRect().height;
// The listbox layout adds this extra height in GetPrefSize. Not sure what it's for though.
var e = (rowHeight * 15 - availHeight) % rowHeight;
var extraHeight = (e == 0) ? 0 : rowHeight - e;
scrollHeight = document.getAnonymousNodes(listbox)[1].lastChild.scrollHeight;
is(scrollHeight, rowHeight * 15 + extraHeight, id + ": scrollHeight when minimium height set");
listbox.removeAttribute("minheight");
scrollHeight = document.getAnonymousNodes(listbox)[1].lastChild.scrollHeight;
is(scrollHeight, rowHeight * 15 + extraHeight, id + ": scrollHeight");
}
window.onload = function runTests() {