Public Types | Public Member Functions

nsDisplayList Class Reference

Manages a singly-linked list of display list items. More...

#include <nsDisplayList.h>

Collaboration diagram for nsDisplayList:

List of all members.

Public Types

typedef PRBool(* SortLEQ )(nsDisplayItem *aItem1, nsDisplayItem *aItem2, void *aClosure)
 Generic stable sort.

Public Member Functions

 nsDisplayList ()
 Create an empty list.
 ~nsDisplayList ()
void AppendToTop (nsDisplayItem *aItem)
 Append an item to the top of the list.
nsresult AppendNewToTop (nsDisplayItem *aItem)
 Append a new item to the top of the list.
nsresult AppendNewToBottom (nsDisplayItem *aItem)
 Append a new item to the bottom of the list.
void AppendToBottom (nsDisplayItem *aItem)
 Append a new item to the bottom of the list.
void AppendToTop (nsDisplayList *aList)
 Removes all items from aList and appends them to the top of this list.
void AppendToBottom (nsDisplayList *aList)
 Removes all items from aList and prepends them to the bottom of this list.
nsDisplayItemRemoveBottom ()
 Remove an item from the bottom of the list and return it.
void DeleteBottom ()
 Remove an item from the bottom of the list and call its destructor.
void DeleteAll ()
 Remove all items from the list and call their destructors.
nsDisplayItemGetTop () const
nsDisplayItemGetBottom () const
PRBool IsEmpty () const
PRUint32 Count () const
 This is *linear time*!
void SortByZOrder (nsDisplayListBuilder *aBuilder, nsIContent *aCommonAncestor)
 Stable sort the list by the z-order of GetUnderlyingFrame() on each item.
void SortByContentOrder (nsDisplayListBuilder *aBuilder, nsIContent *aCommonAncestor)
 Stable sort the list by the tree order of the content of GetUnderlyingFrame() on each item.
void Sort (nsDisplayListBuilder *aBuilder, SortLEQ aCmp, void *aClosure)
void ComputeVisibility (nsDisplayListBuilder *aBuilder, nsRegion *aVisibleRegion, nsRegion *aVisibleRegionBeforeMove)
 Optimize the display list for visibility, removing any elements that are not visible.
void Paint (nsDisplayListBuilder *aBuilder, nsIRenderingContext *aCtx) const
 Paint the list to the rendering context.
nsRect GetBounds (nsDisplayListBuilder *aBuilder) const
 Get the bounds.
nsIFrame * HitTest (nsDisplayListBuilder *aBuilder, nsPoint aPt, nsDisplayItem::HitTestState *aState) const
 Find the topmost display item that returns a non-null frame, and return the frame.

Detailed Description

Manages a singly-linked list of display list items.

mSentinel is the sentinel list value, the first value in the null-terminated linked list of items. mTop is the last item in the list (whose 'above' pointer is null). This class has no virtual methods. So list objects are just two pointers.

Stepping upward through this list is very fast. Stepping downward is very slow so we don't support it. The methods that need to step downward (HitTest(), ComputeVisibility()) internally build a temporary array of all the items while they do the downward traversal, so overall they're still linear time. We have optimized for efficient AppendToTop() of both items and lists, with minimal codesize. AppendToBottom() is efficient too.


Member Typedef Documentation

typedef PRBool(* nsDisplayList::SortLEQ)(nsDisplayItem *aItem1, nsDisplayItem *aItem2, void *aClosure)

Generic stable sort.

Take care, because some of the items might be nsDisplayLists themselves. aCmp(item1, item2) should return true if item1 <= item2. We sort the items into increasing order.


Constructor & Destructor Documentation

nsDisplayList::nsDisplayList (  )  [inline]

Create an empty list.

nsDisplayList::~nsDisplayList (  )  [inline]

Member Function Documentation

nsresult nsDisplayList::AppendNewToBottom ( nsDisplayItem aItem  )  [inline]

Append a new item to the bottom of the list.

If the item is null we return NS_ERROR_OUT_OF_MEMORY. The intended usage is AppendNewToBottom(new ...);

nsresult nsDisplayList::AppendNewToTop ( nsDisplayItem aItem  )  [inline]

Append a new item to the top of the list.

If the item is null we return NS_ERROR_OUT_OF_MEMORY. The intended usage is AppendNewToTop(new ...);

void nsDisplayList::AppendToBottom ( nsDisplayItem aItem  )  [inline]

Append a new item to the bottom of the list.

The item must be non-null and not already in a list.

void nsDisplayList::AppendToBottom ( nsDisplayList aList  )  [inline]

Removes all items from aList and prepends them to the bottom of this list.

void nsDisplayList::AppendToTop ( nsDisplayItem aItem  )  [inline]

Append an item to the top of the list.

The item must not currently be in a list and cannot be null.

void nsDisplayList::AppendToTop ( nsDisplayList aList  )  [inline]

Removes all items from aList and appends them to the top of this list.

void nsDisplayList::ComputeVisibility ( nsDisplayListBuilder aBuilder,
nsRegion aVisibleRegion,
nsRegion aVisibleRegionBeforeMove 
)

Optimize the display list for visibility, removing any elements that are not visible.

We put this logic here so it can be shared by top-level painting and also display items that maintain child lists. This is also a good place to put ComputeVisibility-related logic that must be applied to every display item. In particular, this sets mVisibleRect on each display item.

Parameters:
aVisibleRegion the area that is visible, relative to the reference frame; on return, this contains the area visible under the list
PRUint32 nsDisplayList::Count (  )  const

This is *linear time*!

Returns:
the number of items in the list
void nsDisplayList::DeleteAll (  ) 

Remove all items from the list and call their destructors.

void nsDisplayList::DeleteBottom (  ) 

Remove an item from the bottom of the list and call its destructor.

nsDisplayItem* nsDisplayList::GetBottom (  )  const [inline]
Returns:
the item at the bottom of the list, or null if the list is empty
nsRect nsDisplayList::GetBounds ( nsDisplayListBuilder aBuilder  )  const

Get the bounds.

Takes the union of the bounds of all children.

nsDisplayItem* nsDisplayList::GetTop (  )  const [inline]
Returns:
the item at the top of the list, or null if the list is empty
nsIFrame* nsDisplayList::HitTest ( nsDisplayListBuilder aBuilder,
nsPoint  aPt,
nsDisplayItem::HitTestState aState 
) const

Find the topmost display item that returns a non-null frame, and return the frame.

PRBool nsDisplayList::IsEmpty (  )  const [inline]
void nsDisplayList::Paint ( nsDisplayListBuilder aBuilder,
nsIRenderingContext *  aCtx 
) const

Paint the list to the rendering context.

We assume that (0,0) in aCtx corresponds to the origin of the reference frame. For best results, aCtx's current transform should make (0,0) pixel-aligned. The rectangle in aDirtyRect is painted, which *must* be contained in the dirty rect used to construct the display list.

ComputeVisibility must be called before Paint.

nsDisplayItem* nsDisplayList::RemoveBottom (  ) 

Remove an item from the bottom of the list and return it.

void nsDisplayList::Sort ( nsDisplayListBuilder aBuilder,
SortLEQ  aCmp,
void *  aClosure 
)
void nsDisplayList::SortByContentOrder ( nsDisplayListBuilder aBuilder,
nsIContent *  aCommonAncestor 
)

Stable sort the list by the tree order of the content of GetUnderlyingFrame() on each item.

z-index is ignored.

Parameters:
aCommonAncestor a common ancestor of all the content elements associated with the display items, for speeding up tree order checks, or nsnull if not known; it's only a hint, if it is not an ancestor of some elements, then we lose performance but not correctness
void nsDisplayList::SortByZOrder ( nsDisplayListBuilder aBuilder,
nsIContent *  aCommonAncestor 
)

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.

Parameters:
aCommonAncestor a common ancestor of all the content elements associated with the display items, for speeding up tree order checks, or nsnull if not known; it's only a hint, if it is not an ancestor of some elements, then we lose performance but not correctness

The documentation for this class was generated from the following file: