Bug 496823. Blocks can implement GetLastChild() much faster than by just getting first child and iterating its siblings. r=roc

This commit is contained in:
Boris Zbarsky 2009-07-26 21:27:32 -04:00
Родитель d83933dd9b
Коммит 1950f2e7c4
5 изменённых файлов: 33 добавлений и 2 удалений

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

@ -5725,13 +5725,13 @@ AdjustAppendParentForAfterContent(nsPresContext* aPresContext,
static nsIFrame*
FindAppendPrevSibling(nsIFrame* aParentFrame, nsIFrame* aAfterFrame)
{
nsFrameList childList(aParentFrame->GetFirstChild(nsnull));
if (aAfterFrame) {
nsFrameList childList(aParentFrame->GetFirstChild(nsnull));
NS_ASSERTION(aAfterFrame->GetParent() == aParentFrame, "Wrong parent");
return childList.GetPrevSiblingFor(aAfterFrame);
}
return childList.LastChild();
return aParentFrame->GetLastChild(nsnull);
}
/**

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

@ -538,6 +538,20 @@ nsBlockFrame::GetFirstChild(nsIAtom* aListName) const
return nsContainerFrame::GetFirstChild(aListName);;
}
nsIFrame*
nsBlockFrame::GetLastChild(nsIAtom* aListName) const
{
if (aListName) {
return nsBlockFrameSuper::GetLastChild(aListName);
}
if (mLines.empty()) {
return nsnull;
}
return mLines.back()->LastChild();
}
#define NS_BLOCK_FRAME_OVERFLOW_OOF_LIST_INDEX (NS_CONTAINER_LIST_COUNT_INCL_OC + 0)
#define NS_BLOCK_FRAME_FLOAT_LIST_INDEX (NS_CONTAINER_LIST_COUNT_INCL_OC + 1)
#define NS_BLOCK_FRAME_BULLET_LIST_INDEX (NS_CONTAINER_LIST_COUNT_INCL_OC + 2)

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

@ -177,6 +177,7 @@ public:
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);
virtual nsIFrame* GetFirstChild(nsIAtom* aListName) const;
virtual nsIFrame* GetLastChild(nsIAtom* aListName) const;
virtual nscoord GetBaseline() const;
virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
virtual void Destroy();

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

@ -1667,6 +1667,12 @@ nsIFrame::CreateWidgetForView(nsIView* aView)
return aView->CreateWidget(kWidgetCID);
}
nsIFrame*
nsIFrame::GetLastChild(nsIAtom* aListName) const
{
return nsLayoutUtils::GetLastSibling(GetFirstChild(aListName));
}
/**
*
*/

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

@ -856,6 +856,16 @@ public:
*/
virtual nsIFrame* GetFirstChild(nsIAtom* aListName) const = 0;
/**
* Get the last child frame from the specified child list.
*
* @param aListName the name of the child list. A NULL pointer for the atom
* name means the unnamed principal child list
* @return the child frame, or NULL if there is no such child
* @see #GetAdditionalListName()
*/
virtual nsIFrame* GetLastChild(nsIAtom* aListName) const;
/**
* Child frames are linked together in a singly-linked list
*/