Bug 1144905 - Clean up SortByZOrder code and comments since it now assumes the list is already in content document order. r=roc

This commit is contained in:
Mats Palmgren 2015-03-28 20:50:35 +00:00
parent c615325cb7
commit 85f77e706b
3 changed files with 9 additions and 13 deletions

View File

@ -2043,9 +2043,8 @@ static bool IsZOrderLEQ(nsDisplayItem* aItem1, nsDisplayItem* aItem2,
return aItem1->ZIndex() <= aItem2->ZIndex();
}
void nsDisplayList::SortByZOrder(nsDisplayListBuilder* aBuilder,
nsIContent* aCommonAncestor) {
Sort(aBuilder, IsZOrderLEQ, aCommonAncestor);
void nsDisplayList::SortByZOrder(nsDisplayListBuilder* aBuilder) {
Sort(aBuilder, IsZOrderLEQ, nullptr);
}
void nsDisplayList::SortByContentOrder(nsDisplayListBuilder* aBuilder,

View File

@ -1668,14 +1668,10 @@ public:
uint32_t Count() const;
/**
* Stable sort the list by the z-order of GetUnderlyingFrame() on
* each item. 'auto' is counted as zero. Content order is used as the
* secondary order.
* @param aCommonAncestor a common ancestor of all the content elements
* associated with the display items, for speeding up tree order
* checks, or nullptr if not known; it's only a hint, if it is not an
* ancestor of some elements, then we lose performance but not correctness
* each item. 'auto' is counted as zero.
* It is assumed that the list is already in content document order.
*/
void SortByZOrder(nsDisplayListBuilder* aBuilder, nsIContent* aCommonAncestor);
void SortByZOrder(nsDisplayListBuilder* aBuilder);
/**
* Stable sort the list by the tree order of the content of
* GetUnderlyingFrame() on each item. z-index is ignored.

View File

@ -2058,13 +2058,14 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder,
set.Outlines()->DeleteAll();
}
// This z-order sort also sorts secondarily by content order. We need to do
// this so that boxes produced by the same element are placed together
// Sort PositionedDescendants() in CSS 'z-order' order. The list is already
// in content document order and SortByZOrder is a stable sort which
// guarantees that boxes produced by the same element are placed together
// in the sort. Consider a position:relative inline element that breaks
// across lines and has absolutely positioned children; all the abs-pos
// children should be z-ordered after all the boxes for the position:relative
// element itself.
set.PositionedDescendants()->SortByZOrder(aBuilder, GetContent());
set.PositionedDescendants()->SortByZOrder(aBuilder);
nsDisplayList resultList;
// Now follow the rules of http://www.w3.org/TR/CSS21/zindex.html