Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends

nsDisplayItem Class Reference

This is the unit of rendering and event testing. More...

#include <nsDisplayList.h>

Inheritance diagram for nsDisplayItem:
Collaboration diagram for nsDisplayItem:

List of all members.

Classes

struct  HitTestState

Public Types

enum  Type {
  TYPE_GENERIC, TYPE_BORDER, TYPE_CLIP, TYPE_OPACITY,
  TYPE_OUTLINE, TYPE_PLUGIN, TYPE_TRANSFORM, TYPE_WRAPLIST
}
 

It's useful to be able to dynamically check the type of certain items.

More...

Public Member Functions

 nsDisplayItem (nsIFrame *aFrame)
virtual ~nsDisplayItem ()
void * operator new (size_t aSize, nsDisplayListBuilder *aBuilder) throw ()
virtual Type GetType ()
 Some consecutive items should be rendered together as a unit, e.g., outlines for the same element.
virtual nsIFrame * HitTest (nsDisplayListBuilder *aBuilder, nsPoint aPt, HitTestState *aState)
 This is called after we've constructed a display list for event handling.
nsIFrame * GetUnderlyingFrame ()
virtual nsRect GetBounds (nsDisplayListBuilder *aBuilder)
 The default bounds is the frame border rect.
virtual PRBool IsOpaque (nsDisplayListBuilder *aBuilder)
virtual PRBool IsUniform (nsDisplayListBuilder *aBuilder)
virtual PRBool IsVaryingRelativeToMovingFrame (nsDisplayListBuilder *aBuilder)
virtual void Paint (nsDisplayListBuilder *aBuilder, nsIRenderingContext *aCtx)
 Actually paint this item to some rendering context.
virtual PRBool ComputeVisibility (nsDisplayListBuilder *aBuilder, nsRegion *aVisibleRegion, nsRegion *aVisibleRegionBeforeMove)
 On entry, aVisibleRegion contains the region (relative to ReferenceFrame()) which may be visible.
virtual PRBool TryMerge (nsDisplayListBuilder *aBuilder, nsDisplayItem *aItem)
 Try to merge with the other item (which is below us in the display list).
virtual nsDisplayListGetList ()
 If this is a leaf item we return null, otherwise we return the wrapped list.
nsDisplayItemGetAbove ()

Protected Member Functions

 nsDisplayItem ()

Protected Attributes

nsIFrame * mFrame
nsRect mVisibleRect

Friends

class nsDisplayList

Detailed Description

This is the unit of rendering and event testing.

Each instance of this class represents an entity that can be drawn on the screen, e.g., a frame's CSS background, or a frame's text string.

nsDisplayListItems can be containers --- i.e., they can perform hit testing and painting by recursively traversing a list of child items.

These are arena-allocated during display list construction. A typical subclass would just have a frame pointer, so its object would be just three pointers (vtable, next-item, frame).

Display items belong to a list at all times (except temporarily as they move from one list to another).


Member Enumeration Documentation

It's useful to be able to dynamically check the type of certain items.

For items whose type never gets checked, TYPE_GENERIC will suffice.

Enumerator:
TYPE_GENERIC 
TYPE_BORDER 
TYPE_CLIP 
TYPE_OPACITY 
TYPE_OUTLINE 
TYPE_PLUGIN 
TYPE_TRANSFORM 
TYPE_WRAPLIST 

Constructor & Destructor Documentation

nsDisplayItem::nsDisplayItem ( nsIFrame *  aFrame  )  [inline]
virtual nsDisplayItem::~nsDisplayItem (  )  [inline, virtual]
nsDisplayItem::nsDisplayItem (  )  [inline, protected]

Member Function Documentation

virtual PRBool nsDisplayItem::ComputeVisibility ( nsDisplayListBuilder aBuilder,
nsRegion aVisibleRegion,
nsRegion aVisibleRegionBeforeMove 
) [inline, virtual]

On entry, aVisibleRegion contains the region (relative to ReferenceFrame()) which may be visible.

If the display item opaquely covers an area, it can remove that area from aVisibleRegion before returning. If we're doing scroll analysis with moving frames, then aVisibleRegionBeforeMove will be non-null and contains the region that would have been visible before the move. aVisibleRegion contains the region that is visible after the move. nsDisplayList::ComputeVisibility automatically subtracts the bounds of items that return true from IsOpaque(), and automatically removes items whose bounds do not intersect the visible area, so implementations of nsDisplayItem::ComputeVisibility do not need to do these things. nsDisplayList::ComputeVisibility will already have set mVisibleRect on this item to the intersection of *aVisibleRegion (unioned with *aVisibleRegionBeforeMove, if that's non-null) and this item's bounds.

Returns:
PR_TRUE if the item is visible, PR_FALSE if no part of the item is visible

Reimplemented in nsDisplayBorder, nsDisplayBoxShadowOuter, nsDisplayBoxShadowInner, nsDisplayOutline, nsDisplayWrapList, nsDisplayOpacity, nsDisplayClip, and nsDisplayTransform.

nsDisplayItem* nsDisplayItem::GetAbove (  )  [inline]
virtual nsRect nsDisplayItem::GetBounds ( nsDisplayListBuilder aBuilder  )  [inline, virtual]

The default bounds is the frame border rect.

Returns:
a rectangle relative to aBuilder->ReferenceFrame() that contains the area drawn by this display item

Reimplemented in nsDisplayCaret, nsDisplaySolidColor, nsDisplayBackground, nsDisplayBoxShadowOuter, nsDisplayOutline, nsDisplayWrapList, nsDisplayClip, and nsDisplayTransform.

virtual nsDisplayList* nsDisplayItem::GetList (  )  [inline, virtual]

If this is a leaf item we return null, otherwise we return the wrapped list.

Reimplemented in nsDisplayWrapList.

virtual Type nsDisplayItem::GetType (  )  [inline, virtual]

Some consecutive items should be rendered together as a unit, e.g., outlines for the same element.

For this, we need a way for items to identify their type.

Reimplemented in nsDisplayBorder, nsDisplayOutline, nsDisplayWrapList, nsDisplayOpacity, nsDisplayClip, and nsDisplayTransform.

nsIFrame* nsDisplayItem::GetUnderlyingFrame (  )  [inline]
Returns:
the frame that this display item is based on. This is used to sort items by z-index and content order and for some other uses. For some items that wrap item lists, this could return nsnull because there is no single underlying frame; for leaf items it will never return nsnull.
virtual nsIFrame* nsDisplayItem::HitTest ( nsDisplayListBuilder aBuilder,
nsPoint  aPt,
HitTestState aState 
) [inline, virtual]

This is called after we've constructed a display list for event handling.

When this is called, we've already ensured that aPt is in the item's bounds.

Parameters:
aState must point to a HitTestState. If you don't have one, just create one with the default constructor and pass it in.
Returns:
the frame that the point is considered over, or nsnull if this is not over any frame

Reimplemented in nsDisplayBackground, nsDisplayEventReceiver, nsDisplayWrapList, and nsDisplayTransform.

virtual PRBool nsDisplayItem::IsOpaque ( nsDisplayListBuilder aBuilder  )  [inline, virtual]
Returns:
PR_TRUE if the item is definitely opaque --- i.e., paints every pixel within its bounds opaquely

Reimplemented in nsDisplaySolidColor, nsDisplayBackground, nsDisplayWrapList, nsDisplayOpacity, and nsDisplayTransform.

virtual PRBool nsDisplayItem::IsUniform ( nsDisplayListBuilder aBuilder  )  [inline, virtual]
Returns:
PR_TRUE if the item is guaranteed to paint every pixel in its bounds with the same (possibly translucent) color

Reimplemented in nsDisplaySolidColor, nsDisplayBackground, nsDisplayWrapList, and nsDisplayTransform.

virtual PRBool nsDisplayItem::IsVaryingRelativeToMovingFrame ( nsDisplayListBuilder aBuilder  )  [inline, virtual]
Returns:
PR_FALSE if the painting performed by the item is invariant when frame aFrame is moved relative to aBuilder->GetRootMovingFrame(). This can only be called when aBuilder->IsMovingFrame(mFrame) is true. It return PR_TRUE for all wrapped lists.

Reimplemented in nsDisplayBackground, and nsDisplayWrapList.

void* nsDisplayItem::operator new ( size_t  aSize,
nsDisplayListBuilder aBuilder 
) throw () [inline]
virtual void nsDisplayItem::Paint ( nsDisplayListBuilder aBuilder,
nsIRenderingContext *  aCtx 
) [inline, virtual]

Actually paint this item to some rendering context.

Content outside mVisibleRect need not be painted.

Reimplemented in nsDisplayGeneric, nsDisplayCaret, nsDisplayBorder, nsDisplaySolidColor, nsDisplayBackground, nsDisplayBoxShadowOuter, nsDisplayBoxShadowInner, nsDisplayOutline, nsDisplayWrapList, nsDisplayOpacity, nsDisplayClip, and nsDisplayTransform.

virtual PRBool nsDisplayItem::TryMerge ( nsDisplayListBuilder aBuilder,
nsDisplayItem aItem 
) [inline, virtual]

Try to merge with the other item (which is below us in the display list).

This gets used by nsDisplayClip to coalesce clipping operations (optimization), by nsDisplayOpacity to merge rendering for the same content element into a single opacity group (correctness), and will be used by nsDisplayOutline to merge multiple outlines for the same element (also for correctness).

Returns:
PR_TRUE if the merge was successful and the other item should be deleted

Reimplemented in nsDisplayWrapList, nsDisplayOpacity, nsDisplayClip, and nsDisplayTransform.


Friends And Related Function Documentation

friend class nsDisplayList [friend]

Reimplemented from nsDisplayItemLink.


Member Data Documentation

nsIFrame* nsDisplayItem::mFrame [protected]

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