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

nsCaret Class Reference

#include <nsCaret.h>

Inheritance diagram for nsCaret:
Collaboration diagram for nsCaret:

List of all members.

Classes

struct  Metrics

Public Types

enum  EViewCoordinates { eTopLevelWindowCoordinates, eRenderingViewCoordinates, eClosestViewCoordinates }

Public Member Functions

 nsCaret ()
virtual ~nsCaret ()
NS_DECL_ISUPPORTS nsresult Init (nsIPresShell *inPresShell)
void Terminate ()
nsISelectionGetCaretDOMSelection ()
nsresult SetCaretDOMSelection (nsISelection *inDOMSel)
virtual nsresult GetCaretVisible (PRBool *outMakeVisible)
 GetCaretVisible will get the visibility of the caret This function is virtual so that it can be used by nsCaretAccessible without linking.
void SetCaretVisible (PRBool intMakeVisible)
 SetCaretVisible will set the visibility of the caret.
void SetCaretReadOnly (PRBool inMakeReadonly)
 SetCaretReadOnly set the appearance of the caret.
PRBool GetCaretReadOnly ()
 GetCaretReadOnly get the appearance of the caret.
virtual nsresult GetCaretCoordinates (EViewCoordinates aRelativeToType, nsISelection *inDOMSel, nsRect *outCoordinates, PRBool *outIsCollapsed, nsIView **outView)
 GetCaretCoordinates OBSOLETE use GetGeometry instead.
virtual nsIFrame * GetGeometry (nsISelection *aSelection, nsRect *aRect)
 Replaces GetCaretCoordinates.
void EraseCaret ()
 EraseCaret this will erase the caret if its drawn and reset drawn status.
void SetVisibilityDuringSelection (PRBool aVisibility)
nsresult DrawAtPosition (nsIDOMNode *aNode, PRInt32 aOffset)
 DrawAtPosition.
nsIFrame * GetCaretFrame ()
 GetCaretFrame Get the current frame that the caret should be drawn in.
nsRect GetCaretRect ()
 GetCaretRect Get the current caret rect.
nsIContent * GetCaretContent ()
 GetCaretContent Get the content that the caret was last drawn in.
void InvalidateOutsideCaret ()
 InvalidateOutsideCaret Invalidate the area that the caret currently occupies if the caret is outside of its frame's overflow area.
void UpdateCaretPosition ()
 UpdateCaretPosition Update the caret's current frame and rect, but don't draw yet.
void PaintCaret (nsDisplayListBuilder *aBuilder, nsIRenderingContext *aCtx, nsIFrame *aForFrame, const nsPoint &aOffset)
 PaintCaret Actually paint the caret onto the given rendering context.
void SetIgnoreUserModify (PRBool aIgnoreUserModify)
 Sets whether the caret should only be visible in nodes that are not user-modify: read-only, or whether it should be visible in all nodes.
nsresult GetCaretFrameForNodeOffset (nsIContent *aContentNode, PRInt32 aOffset, nsFrameSelection::HINT aFrameHint, PRUint8 aBidiLevel, nsIFrame **aReturnFrame, PRInt32 *aReturnOffset)
virtual nsresult CheckCaretDrawingState ()

Static Public Member Functions

static
NS_DECL_NSISELECTIONLISTENER
void 
CaretBlinkCallback (nsITimer *aTimer, void *aClosure)

Protected Member Functions

void KillTimer ()
nsresult PrimeTimer ()
void StartBlinking ()
void StopBlinking ()
void GetViewForRendering (nsIFrame *caretFrame, EViewCoordinates coordType, nsPoint &viewOffset, nsIView **outRenderingView, nsIView **outRelativeView)
PRBool DrawAtPositionWithHint (nsIDOMNode *aNode, PRInt32 aOffset, nsFrameSelection::HINT aFrameHint, PRUint8 aBidiLevel, PRBool aInvalidate)
Metrics ComputeMetrics (nsIFrame *aFrame, PRInt32 aOffset, nscoord aCaretHeight)
PRBool MustDrawCaret (PRBool aIgnoreDrawnState)
void DrawCaret (PRBool aInvalidate)
void DrawCaretAfterBriefDelay ()
nsresult UpdateCaretRects (nsIFrame *aFrame, PRInt32 aFrameOffset)
nsresult UpdateHookRect (nsPresContext *aPresContext, const Metrics &aMetrics)
nsRect GetHookRect ()
void ToggleDrawnStatus ()
already_AddRefed
< nsFrameSelection
GetFrameSelection ()
PRBool IsMenuPopupHidingCaret ()

Static Protected Member Functions

static void InvalidateRects (const nsRect &aRect, const nsRect &aHook, nsIFrame *aFrame)

Protected Attributes

nsWeakPtr mPresShell
nsWeakPtr mDomSelectionWeak
nsCOMPtr< nsITimermBlinkTimer
nsCOMPtr< nsIRenderingContext > mRendContext
PRUint32 mBlinkRate
nscoord mCaretWidthCSSPx
float mCaretAspectRatio
PRPackedBool mVisible
PRPackedBool mDrawn
PRPackedBool mPendingDraw
PRPackedBool mReadOnly
PRPackedBool mShowDuringSelection
PRPackedBool mIgnoreUserModify
nsRect mCaretRect
nsCOMPtr< nsIContent > mLastContent
PRInt32 mLastContentOffset
nsFrameSelection::HINT mLastHint

Member Enumeration Documentation

Enumerator:
eTopLevelWindowCoordinates 
eRenderingViewCoordinates 
eClosestViewCoordinates 

Constructor & Destructor Documentation

nsCaret::nsCaret (  ) 
virtual nsCaret::~nsCaret (  )  [virtual]

Member Function Documentation

static NS_DECL_NSISELECTIONLISTENER void nsCaret::CaretBlinkCallback ( nsITimer aTimer,
void *  aClosure 
) [static]
virtual nsresult nsCaret::CheckCaretDrawingState (  )  [virtual]
Metrics nsCaret::ComputeMetrics ( nsIFrame *  aFrame,
PRInt32  aOffset,
nscoord  aCaretHeight 
) [protected]
nsresult nsCaret::DrawAtPosition ( nsIDOMNode aNode,
PRInt32  aOffset 
)

DrawAtPosition.

Draw the caret explicitly, at the specified node and offset. To avoid drawing glitches, you should call EraseCaret() after each call to DrawAtPosition().

Note: This call breaks the caret's ability to blink at all.

PRBool nsCaret::DrawAtPositionWithHint ( nsIDOMNode aNode,
PRInt32  aOffset,
nsFrameSelection::HINT  aFrameHint,
PRUint8  aBidiLevel,
PRBool  aInvalidate 
) [protected]
void nsCaret::DrawCaret ( PRBool  aInvalidate  )  [protected]
void nsCaret::DrawCaretAfterBriefDelay (  )  [protected]
void nsCaret::EraseCaret (  ) 

EraseCaret this will erase the caret if its drawn and reset drawn status.

nsIContent* nsCaret::GetCaretContent (  )  [inline]

GetCaretContent Get the content that the caret was last drawn in.

virtual nsresult nsCaret::GetCaretCoordinates ( EViewCoordinates  aRelativeToType,
nsISelection inDOMSel,
nsRect outCoordinates,
PRBool outIsCollapsed,
nsIView **  outView 
) [virtual]

GetCaretCoordinates OBSOLETE use GetGeometry instead.

Get the position of the caret in coordinates relative to the typed specified (aRelativeToType). This function is virtual so that it can be used by nsCaretAccessible without linking

Parameters:
outISCollapsed set to true if and only if selection is collapsed
Returns:
Caret location if selection is collapsed, otherwise, location of focus position
nsISelection* nsCaret::GetCaretDOMSelection (  ) 
nsIFrame* nsCaret::GetCaretFrame (  ) 

GetCaretFrame Get the current frame that the caret should be drawn in.

If the caret is not currently visible (i.e., it is between blinks), then this will return null.

nsresult nsCaret::GetCaretFrameForNodeOffset ( nsIContent *  aContentNode,
PRInt32  aOffset,
nsFrameSelection::HINT  aFrameHint,
PRUint8  aBidiLevel,
nsIFrame **  aReturnFrame,
PRInt32 *  aReturnOffset 
)
PRBool nsCaret::GetCaretReadOnly (  )  [inline]

GetCaretReadOnly get the appearance of the caret.

Returns:
PR_TRUE if the caret is in 'read only' state, otherwise, returns PR_FALSE
nsRect nsCaret::GetCaretRect (  )  [inline]

GetCaretRect Get the current caret rect.

Only call this when GetCaretFrame returns non-null.

virtual nsresult nsCaret::GetCaretVisible ( PRBool outMakeVisible  )  [virtual]

GetCaretVisible will get the visibility of the caret This function is virtual so that it can be used by nsCaretAccessible without linking.

Parameters:
inMakeVisible PR_TRUE it is shown, PR_FALSE it is hidden
Returns:
false if and only if inMakeVisible is null, otherwise true
already_AddRefed<nsFrameSelection> nsCaret::GetFrameSelection (  )  [protected]
virtual nsIFrame* nsCaret::GetGeometry ( nsISelection aSelection,
nsRect aRect 
) [virtual]

Replaces GetCaretCoordinates.

Gets the position and size of the caret that would be drawn for the focus node/offset of aSelection (assuming it would be drawn, i.e., disregarding blink status). The geometry is stored in aRect, and we return the frame aRect is relative to.

nsRect nsCaret::GetHookRect (  )  [inline, protected]
void nsCaret::GetViewForRendering ( nsIFrame *  caretFrame,
EViewCoordinates  coordType,
nsPoint viewOffset,
nsIView **  outRenderingView,
nsIView **  outRelativeView 
) [protected]
NS_DECL_ISUPPORTS nsresult nsCaret::Init ( nsIPresShell *  inPresShell  ) 
void nsCaret::InvalidateOutsideCaret (  ) 

InvalidateOutsideCaret Invalidate the area that the caret currently occupies if the caret is outside of its frame's overflow area.

This is used when the content that the caret is currently drawn is is being deleted or reflowed.

static void nsCaret::InvalidateRects ( const nsRect aRect,
const nsRect aHook,
nsIFrame *  aFrame 
) [static, protected]
PRBool nsCaret::IsMenuPopupHidingCaret (  )  [protected]
void nsCaret::KillTimer (  )  [protected]
PRBool nsCaret::MustDrawCaret ( PRBool  aIgnoreDrawnState  )  [protected]
void nsCaret::PaintCaret ( nsDisplayListBuilder aBuilder,
nsIRenderingContext *  aCtx,
nsIFrame *  aForFrame,
const nsPoint aOffset 
)

PaintCaret Actually paint the caret onto the given rendering context.

nsresult nsCaret::PrimeTimer (  )  [protected]
nsresult nsCaret::SetCaretDOMSelection ( nsISelection inDOMSel  ) 
void nsCaret::SetCaretReadOnly ( PRBool  inMakeReadonly  ) 

SetCaretReadOnly set the appearance of the caret.

Parameters:
inMakeReadonly PR_TRUE to show the caret in a 'read only' state, PR_FALSE to show the caret in normal, editing state
void nsCaret::SetCaretVisible ( PRBool  intMakeVisible  ) 

SetCaretVisible will set the visibility of the caret.

Parameters:
inMakeVisible PR_TRUE to show the caret, PR_FALSE to hide it
void nsCaret::SetIgnoreUserModify ( PRBool  aIgnoreUserModify  ) 

Sets whether the caret should only be visible in nodes that are not user-modify: read-only, or whether it should be visible in all nodes.

Parameters:
aIgnoreUserModify PR_TRUE to have the cursor visible in all nodes, PR_FALSE to have it visible in all nodes except those with user-modify: read-only
void nsCaret::SetVisibilityDuringSelection ( PRBool  aVisibility  ) 
void nsCaret::StartBlinking (  )  [protected]
void nsCaret::StopBlinking (  )  [protected]
void nsCaret::Terminate (  ) 
void nsCaret::ToggleDrawnStatus (  )  [inline, protected]
void nsCaret::UpdateCaretPosition (  ) 

UpdateCaretPosition Update the caret's current frame and rect, but don't draw yet.

This is useful for flickerless moving of the caret (e.g., when the frame the caret is in reflows and is moved).

nsresult nsCaret::UpdateCaretRects ( nsIFrame *  aFrame,
PRInt32  aFrameOffset 
) [protected]
nsresult nsCaret::UpdateHookRect ( nsPresContext aPresContext,
const Metrics aMetrics 
) [protected]

Member Data Documentation

PRUint32 nsCaret::mBlinkRate [protected]
float nsCaret::mCaretAspectRatio [protected]
nsWeakPtr nsCaret::mDomSelectionWeak [protected]
nsCOMPtr<nsIContent> nsCaret::mLastContent [protected]
PRInt32 nsCaret::mLastContentOffset [protected]
nsWeakPtr nsCaret::mPresShell [protected]
nsCOMPtr<nsIRenderingContext> nsCaret::mRendContext [protected]

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