Public Types | Public Member Functions | Friends

nsFrameSelection Class Reference

Methods which are marked with *unsafe* should be handled with special care. More...

#include <nsFrameSelection.h>

Collaboration diagram for nsFrameSelection:

List of all members.

Public Types

enum  HINT { HINTLEFT = 0, HINTRIGHT = 1 }

Public Member Functions

NS_DECL_CYCLE_COLLECTING_ISUPPORTS
void 
Init (nsIPresShell *aShell, nsIContent *aLimiter)
 Init will initialize the frame selector with the necessary pres shell to be used by most of the methods.
nsresult HandleClick (nsIContent *aNewFocus, PRUint32 aContentOffset, PRUint32 aContentEndOffset, PRBool aContinueSelection, PRBool aMultipleSelection, PRBool aHint)
 HandleClick will take the focus to the new frame at the new offset and will either extend the selection from the old anchor, or replace the old anchor.
void HandleDrag (nsIFrame *aFrame, nsPoint aPoint)
 HandleDrag extends the selection to contain the frame closest to aPoint.
nsresult HandleTableSelection (nsINode *aParentContent, PRInt32 aContentOffset, PRInt32 aTarget, nsMouseEvent *aMouseEvent)
 HandleTableSelection will set selection to a table, cell, etc depending on information contained in aFlags.
virtual nsresult SelectCellElement (nsIContent *aCell)
 Add cell to the selection.
virtual nsresult AddCellsToSelection (nsIContent *aTable, PRInt32 aStartRowIndex, PRInt32 aStartColumnIndex, PRInt32 aEndRowIndex, PRInt32 aEndColumnIndex)
 Add cells to the selection inside of the given cells range.
virtual nsresult RemoveCellsFromSelection (nsIContent *aTable, PRInt32 aStartRowIndex, PRInt32 aStartColumnIndex, PRInt32 aEndRowIndex, PRInt32 aEndColumnIndex)
 Remove cells from selection inside of the given cell range.
virtual nsresult RestrictCellsToSelection (nsIContent *aTable, PRInt32 aStartRowIndex, PRInt32 aStartColumnIndex, PRInt32 aEndRowIndex, PRInt32 aEndColumnIndex)
 Remove cells from selection outside of the given cell range.
nsresult StartAutoScrollTimer (nsIFrame *aFrame, nsPoint aPoint, PRUint32 aDelay)
 StartAutoScrollTimer is responsible for scrolling frames so that aPoint is always visible, and for selecting any frame that contains aPoint.
void StopAutoScrollTimer ()
 StopAutoScrollTimer stops any active auto scroll timer.
SelectionDetailsLookUpSelection (nsIContent *aContent, PRInt32 aContentOffset, PRInt32 aContentLength, PRBool aSlowCheck) const
 Lookup Selection returns in frame coordinates the selection beginning and ending with the type of selection given.
void SetMouseDownState (PRBool aState)
 SetMouseDownState(PRBool); sets the mouse state to aState for resons of drag state.
PRBool GetMouseDownState () const
 GetMouseDownState(PRBool *); gets the mouse state to aState for resons of drag state.
PRBool GetTableCellSelection () const
 if we are in table cell selection mode.
void ClearTableCellSelection ()
nsISelectionGetSelection (SelectionType aType) const
 GetSelection no query interface for selection.
nsresult ScrollSelectionIntoView (SelectionType aType, SelectionRegion aRegion, PRBool aIsSynchronous) const
 ScrollSelectionIntoView scrolls a region of the selection, so that it is visible in the scrolled view.
nsresult RepaintSelection (SelectionType aType) const
 RepaintSelection repaints the selected frames that are inside the selection specified by aSelectionType.
virtual nsIFrame * GetFrameForNodeOffset (nsIContent *aNode, PRInt32 aOffset, HINT aHint, PRInt32 *aReturnOffset) const
 GetFrameForNodeOffset given a node and its child offset, return the nsIFrame and the offset into that frame.
void CommonPageMove (PRBool aForward, PRBool aExtend, nsIScrollableFrame *aScrollableFrame)
 Scrolling then moving caret placement code in common to text areas and content areas should be located in the implementer This method will accept the following parameters and perform the scroll and caret movement.
void SetHint (HINT aHintRight)
HINT GetHint () const
nsresult CharacterMove (PRBool aForward, PRBool aExtend)
 CharacterMove will generally be called from the nsiselectioncontroller implementations.
nsresult CharacterExtendForDelete ()
 CharacterExtendForDelete extends the selection forward (logically) to the next character cell, so that the selected cell can be deleted.
nsresult WordMove (PRBool aForward, PRBool aExtend)
 WordMove will generally be called from the nsiselectioncontroller implementations.
nsresult WordExtendForDelete (PRBool aForward)
 WordExtendForDelete extends the selection backward or forward (logically) to the next word boundary, so that the selected word can be deleted.
nsresult LineMove (PRBool aForward, PRBool aExtend)
 LineMove will generally be called from the nsiselectioncontroller implementations.
nsresult IntraLineMove (PRBool aForward, PRBool aExtend)
 IntraLineMove will generally be called from the nsiselectioncontroller implementations.
nsresult SelectAll ()
 Select All will generally be called from the nsiselectioncontroller implementations.
void SetDisplaySelection (PRInt16 aState)
 Sets/Gets The display selection enum.
PRInt16 GetDisplaySelection () const
void SetDelayedCaretData (nsMouseEvent *aMouseEvent)
 This method can be used to store the data received during a MouseDown event so that we can place the caret during the MouseUp event.
nsMouseEventGetDelayedCaretData ()
 Get the delayed MouseDown event data necessary to place the caret during MouseUp processing.
nsIContent * GetLimiter () const
 Get the content node that limits the selection When searching up a nodes for parents, as in a text edit field in an browser page, we must stop at this node else we reach into the parent page, which is very bad!
nsIContent * GetAncestorLimiter () const
void SetAncestorLimiter (nsIContent *aLimiter)
void SetMouseDoubleDown (PRBool aDoubleDown)
 This will tell the frame selection that a double click has been pressed so it can track abort future drags if inside the same selection has the double click down happened.
PRBool GetMouseDoubleDown () const
 This will return whether the double down flag was set.
virtual nsPrevNextBidiLevels GetPrevNextBidiLevels (nsIContent *aNode, PRUint32 aContentOffset, PRBool aJumpLines) const
 GetPrevNextBidiLevels will return the frames and associated Bidi levels of the characters logically before and after a (collapsed) selection.
nsresult GetFrameFromLevel (nsIFrame *aFrameIn, nsDirection aDirection, PRUint8 aBidiLevel, nsIFrame **aFrameOut) const
 GetFrameFromLevel will scan in a given direction until it finds a frame with a Bidi level less than or equal to a given level.
nsresult MaintainSelection (nsSelectionAmount aAmount=eSelectNoAmount)
 MaintainSelection will track the current selection as being "sticky".
 nsFrameSelection ()
void StartBatchChanges ()
void EndBatchChanges ()
nsresult DeleteFromDocument ()
nsIPresShell * GetShell () const
void DisconnectFromPresShell ()

Friends

class nsTypedSelection

Detailed Description

Methods which are marked with *unsafe* should be handled with special care.

They may cause nsFrameSelection to be deleted, if strong pointer isn't used, or they may cause other objects to be deleted.


Member Enumeration Documentation

Enumerator:
HINTLEFT 
HINTRIGHT 

Constructor & Destructor Documentation

nsFrameSelection::nsFrameSelection (  ) 

Member Function Documentation

virtual nsresult nsFrameSelection::AddCellsToSelection ( nsIContent *  aTable,
PRInt32  aStartRowIndex,
PRInt32  aStartColumnIndex,
PRInt32  aEndRowIndex,
PRInt32  aEndColumnIndex 
) [virtual]

Add cells to the selection inside of the given cells range.

Parameters:
aTable [in] HTML table element
aStartRowIndex [in] row index where the cells range starts
aStartColumnIndex [in] column index where the cells range starts
aEndRowIndex [in] row index where the cells range ends
aEndColumnIndex [in] column index where the cells range ends
nsresult nsFrameSelection::CharacterExtendForDelete (  ) 

CharacterExtendForDelete extends the selection forward (logically) to the next character cell, so that the selected cell can be deleted.

nsresult nsFrameSelection::CharacterMove ( PRBool  aForward,
PRBool  aExtend 
)

CharacterMove will generally be called from the nsiselectioncontroller implementations.

the effect being the selection will move one character left or right.

Parameters:
aForward move forward in document.
aExtend continue selection
void nsFrameSelection::ClearTableCellSelection (  )  [inline]
void nsFrameSelection::CommonPageMove ( PRBool  aForward,
PRBool  aExtend,
nsIScrollableFrame *  aScrollableFrame 
)

Scrolling then moving caret placement code in common to text areas and content areas should be located in the implementer This method will accept the following parameters and perform the scroll and caret movement.

It remains for the caller to call the final ScrollCaretIntoView if that called wants to be sure the caret is always visible.

Parameters:
aForward if PR_TRUE, scroll forward if not scroll backward
aExtend if PR_TRUE, extend selection to the new point
aScrollableFrame the frame to scroll
nsresult nsFrameSelection::DeleteFromDocument (  ) 
void nsFrameSelection::DisconnectFromPresShell (  )  [inline]
void nsFrameSelection::EndBatchChanges (  ) 
nsIContent* nsFrameSelection::GetAncestorLimiter (  )  const [inline]
nsMouseEvent* nsFrameSelection::GetDelayedCaretData (  ) 

Get the delayed MouseDown event data necessary to place the caret during MouseUp processing.

Returns:
a pointer to the event received by the selection during MouseDown processing. It can be NULL if the data is no longer valid.
PRInt16 nsFrameSelection::GetDisplaySelection (  )  const [inline]
virtual nsIFrame* nsFrameSelection::GetFrameForNodeOffset ( nsIContent *  aNode,
PRInt32  aOffset,
HINT  aHint,
PRInt32 *  aReturnOffset 
) const [virtual]

GetFrameForNodeOffset given a node and its child offset, return the nsIFrame and the offset into that frame.

Parameters:
aNode input parameter for the node to look at
aOffset offset into above node.
aReturnOffset will contain offset into frame.
nsresult nsFrameSelection::GetFrameFromLevel ( nsIFrame *  aFrameIn,
nsDirection  aDirection,
PRUint8  aBidiLevel,
nsIFrame **  aFrameOut 
) const

GetFrameFromLevel will scan in a given direction until it finds a frame with a Bidi level less than or equal to a given level.

It will return the last frame before this.

Parameters:
aPresContext is the context to use
aFrameIn is the frame to start from
aDirection is the direction to scan
aBidiLevel is the level to search for
aFrameOut will hold the frame returned
HINT nsFrameSelection::GetHint (  )  const [inline]
nsIContent* nsFrameSelection::GetLimiter (  )  const [inline]

Get the content node that limits the selection When searching up a nodes for parents, as in a text edit field in an browser page, we must stop at this node else we reach into the parent page, which is very bad!

PRBool nsFrameSelection::GetMouseDoubleDown (  )  const [inline]

This will return whether the double down flag was set.

Returns:
whether the double down flag was set
PRBool nsFrameSelection::GetMouseDownState (  )  const [inline]

GetMouseDownState(PRBool *); gets the mouse state to aState for resons of drag state.

Parameters:
aState will hold the state of mousedown
virtual nsPrevNextBidiLevels nsFrameSelection::GetPrevNextBidiLevels ( nsIContent *  aNode,
PRUint32  aContentOffset,
PRBool  aJumpLines 
) const [virtual]

GetPrevNextBidiLevels will return the frames and associated Bidi levels of the characters logically before and after a (collapsed) selection.

Parameters:
aNode is the node containing the selection
aContentOffset is the offset of the selection in the node
aJumpLines If PR_TRUE, look across line boundaries. If PR_FALSE, behave as if there were base-level frames at line edges.
Returns:
A struct holding the before/after frame and the before/after level.

At the beginning and end of each line there is assumed to be a frame with Bidi level equal to the paragraph embedding level. In these cases the before frame and after frame respectively will be nsnull.

This method is virtual since it gets called from outside of layout.

nsISelection* nsFrameSelection::GetSelection ( SelectionType  aType  )  const

GetSelection no query interface for selection.

must use this method now.

Parameters:
aSelectionType enum value defined in nsISelection for the seleciton you want.
nsIPresShell* nsFrameSelection::GetShell (  )  const [inline]
PRBool nsFrameSelection::GetTableCellSelection (  )  const [inline]

if we are in table cell selection mode.

aka ctrl click in table cell

nsresult nsFrameSelection::HandleClick ( nsIContent *  aNewFocus,
PRUint32  aContentOffset,
PRUint32  aContentEndOffset,
PRBool  aContinueSelection,
PRBool  aMultipleSelection,
PRBool  aHint 
)

HandleClick will take the focus to the new frame at the new offset and will either extend the selection from the old anchor, or replace the old anchor.

the old anchor and focus position may also be used to deselect things

Parameters:
aNewfocus is the content that wants the focus
aContentOffset is the content offset of the parent aNewFocus
aContentOffsetEnd is the content offset of the parent aNewFocus and is specified different when you need to select to and include both start and end points
aContinueSelection is the flag that tells the selection to keep the old anchor point or not.
aMultipleSelection will tell the frame selector to replace /or not the old selection. cannot coexist with aContinueSelection
aHint will tell the selection which direction geometrically to actually show the caret on. 1 = end of this line 0 = beginning of this line
void nsFrameSelection::HandleDrag ( nsIFrame *  aFrame,
nsPoint  aPoint 
)

HandleDrag extends the selection to contain the frame closest to aPoint.

Parameters:
aPresContext is the context to use when figuring out what frame contains the point.
aFrame is the parent of all frames to use when searching for the closest frame to the point.
aPoint is relative to aFrame
nsresult nsFrameSelection::HandleTableSelection ( nsINode *  aParentContent,
PRInt32  aContentOffset,
PRInt32  aTarget,
nsMouseEvent aMouseEvent 
)

HandleTableSelection will set selection to a table, cell, etc depending on information contained in aFlags.

Parameters:
aParentContent is the paretent of either a table or cell that user clicked or dragged the mouse in
aContentOffset is the offset of the table or cell
aTarget indicates what to select (defined in nsISelectionPrivate.idl/nsISelectionPrivate.h): TABLESELECTION_CELL We should select a cell (content points to the cell) TABLESELECTION_ROW We should select a row (content points to any cell in row) TABLESELECTION_COLUMN We should select a row (content points to any cell in column) TABLESELECTION_TABLE We should select a table (content points to the table) TABLESELECTION_ALLCELLS We should select all cells (content points to any cell in table)
aMouseEvent passed in so we can get where event occurred and what keys are pressed
NS_DECL_CYCLE_COLLECTING_ISUPPORTS void nsFrameSelection::Init ( nsIPresShell *  aShell,
nsIContent *  aLimiter 
)

Init will initialize the frame selector with the necessary pres shell to be used by most of the methods.

Parameters:
aShell is the parameter to be used for most of the other calls for callbacks etc
aLimiter limits the selection to nodes with aLimiter parents
nsresult nsFrameSelection::IntraLineMove ( PRBool  aForward,
PRBool  aExtend 
)

IntraLineMove will generally be called from the nsiselectioncontroller implementations.

the effect being the selection will move to beginning or end of line

Parameters:
aForward move forward in document.
aExtend continue selection
nsresult nsFrameSelection::LineMove ( PRBool  aForward,
PRBool  aExtend 
)

LineMove will generally be called from the nsiselectioncontroller implementations.

the effect being the selection will move one line up or down.

Parameters:
aForward move forward in document.
aExtend continue selection
SelectionDetails* nsFrameSelection::LookUpSelection ( nsIContent *  aContent,
PRInt32  aContentOffset,
PRInt32  aContentLength,
PRBool  aSlowCheck 
) const

Lookup Selection returns in frame coordinates the selection beginning and ending with the type of selection given.

Parameters:
aContent is the content asking
aContentOffset is the starting content boundary
aContentLength is the length of the content piece asking
aReturnDetails linkedlist of return values for the selection.
aSlowCheck will check using slow method with no shortcuts
nsresult nsFrameSelection::MaintainSelection ( nsSelectionAmount  aAmount = eSelectNoAmount  ) 

MaintainSelection will track the current selection as being "sticky".

Dragging or extending selection will never allow for a subset (or the whole) of the maintained selection to become unselected. Primary use: double click selecting then dragging on second click

Parameters:
aAmount the initial amount of text selected (word, line or paragraph). For "line", use eSelectBeginLine.
virtual nsresult nsFrameSelection::RemoveCellsFromSelection ( nsIContent *  aTable,
PRInt32  aStartRowIndex,
PRInt32  aStartColumnIndex,
PRInt32  aEndRowIndex,
PRInt32  aEndColumnIndex 
) [virtual]

Remove cells from selection inside of the given cell range.

Parameters:
aTable [in] HTML table element
aStartRowIndex [in] row index where the cells range starts
aStartColumnIndex [in] column index where the cells range starts
aEndRowIndex [in] row index where the cells range ends
aEndColumnIndex [in] column index where the cells range ends
nsresult nsFrameSelection::RepaintSelection ( SelectionType  aType  )  const

RepaintSelection repaints the selected frames that are inside the selection specified by aSelectionType.

Parameters:
aSelectionType enum value defined in nsISelection for the seleciton you want.
virtual nsresult nsFrameSelection::RestrictCellsToSelection ( nsIContent *  aTable,
PRInt32  aStartRowIndex,
PRInt32  aStartColumnIndex,
PRInt32  aEndRowIndex,
PRInt32  aEndColumnIndex 
) [virtual]

Remove cells from selection outside of the given cell range.

Parameters:
aTable [in] HTML table element
aStartRowIndex [in] row index where the cells range starts
aStartColumnIndex [in] column index where the cells range starts
aEndRowIndex [in] row index where the cells range ends
aEndColumnIndex [in] column index where the cells range ends
nsresult nsFrameSelection::ScrollSelectionIntoView ( SelectionType  aType,
SelectionRegion  aRegion,
PRBool  aIsSynchronous 
) const

ScrollSelectionIntoView scrolls a region of the selection, so that it is visible in the scrolled view.

Parameters:
aType the selection to scroll into view.
aRegion the region inside the selection to scroll into view.
aIsSynchronous when PR_TRUE, scrolls the selection into view at some point after the method returns.request which is processed
nsresult nsFrameSelection::SelectAll (  ) 

Select All will generally be called from the nsiselectioncontroller implementations.

it will select the whole doc

virtual nsresult nsFrameSelection::SelectCellElement ( nsIContent *  aCell  )  [virtual]

Add cell to the selection.

Parameters:
aCell [in] HTML td element.
void nsFrameSelection::SetAncestorLimiter ( nsIContent *  aLimiter  ) 
void nsFrameSelection::SetDelayedCaretData ( nsMouseEvent aMouseEvent  ) 

This method can be used to store the data received during a MouseDown event so that we can place the caret during the MouseUp event.

the event received by the selection MouseDown handling method. A NULL value can be use to tell this method that any data is storing is no longer valid.

void nsFrameSelection::SetDisplaySelection ( PRInt16  aState  )  [inline]

Sets/Gets The display selection enum.

void nsFrameSelection::SetHint ( HINT  aHintRight  )  [inline]
void nsFrameSelection::SetMouseDoubleDown ( PRBool  aDoubleDown  )  [inline]

This will tell the frame selection that a double click has been pressed so it can track abort future drags if inside the same selection has the double click down happened.

void nsFrameSelection::SetMouseDownState ( PRBool  aState  ) 

SetMouseDownState(PRBool); sets the mouse state to aState for resons of drag state.

Parameters:
aState is the new state of mousedown
nsresult nsFrameSelection::StartAutoScrollTimer ( nsIFrame *  aFrame,
nsPoint  aPoint,
PRUint32  aDelay 
)

StartAutoScrollTimer is responsible for scrolling frames so that aPoint is always visible, and for selecting any frame that contains aPoint.

The timer will also reset itself to fire again if we have not scrolled to the end of the document.

Parameters:
aFrame is the outermost frame to use when searching for the closest frame for the point, i.e. the frame that is capturing the mouse
aPoint is relative to aFrame.
aDelay is the timer's interval.
void nsFrameSelection::StartBatchChanges (  ) 
void nsFrameSelection::StopAutoScrollTimer (  ) 

StopAutoScrollTimer stops any active auto scroll timer.

nsresult nsFrameSelection::WordExtendForDelete ( PRBool  aForward  ) 

WordExtendForDelete extends the selection backward or forward (logically) to the next word boundary, so that the selected word can be deleted.

Parameters:
aForward select forward in document.
nsresult nsFrameSelection::WordMove ( PRBool  aForward,
PRBool  aExtend 
)

WordMove will generally be called from the nsiselectioncontroller implementations.

the effect being the selection will move one word left or right.

Parameters:
aForward move forward in document.
aExtend continue selection

Friends And Related Function Documentation

friend class nsTypedSelection [friend]

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