Methods which are marked with *unsafe* should be handled with special care. More...
#include <nsFrameSelection.h>
Collaboration diagram for nsFrameSelection: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. | |
| SelectionDetails * | 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. | |
| 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 () |
| nsISelection * | GetSelection (SelectionType aType) const |
| GetSelection no query interface for selection. | |
| nsresult | ScrollSelectionIntoView (SelectionType aType, SelectionRegion aRegion, PRInt16 aFlags) 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 | CharacterExtendForBackspace () |
| CharacterExtendForBackspace extends the selection backward (logically) to the previous 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. | |
| nsMouseEvent * | GetDelayedCaretData () |
| 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 |
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.
| nsFrameSelection::nsFrameSelection | ( | ) |
| 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.
| 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::CharacterExtendForBackspace | ( | ) |
CharacterExtendForBackspace extends the selection backward (logically) to the previous character cell, so that the selected cell can be deleted.
| nsresult nsFrameSelection::CharacterExtendForDelete | ( | ) |
CharacterExtendForDelete extends the selection forward (logically) to the next character cell, so that the selected cell can be deleted.
CharacterMove will generally be called from the nsiselectioncontroller implementations.
the effect being the selection will move one character left or right.
| 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.
| 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.
| 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.
| 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.
| 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.
| PRBool nsFrameSelection::GetMouseDownState | ( | ) | const [inline] |
GetMouseDownState(PRBool *); gets the mouse state to aState for resons of drag state.
| 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.
| 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. |
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.
| 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
| 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.
| 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.
| 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.
| 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 |
IntraLineMove will generally be called from the nsiselectioncontroller implementations.
the effect being the selection will move to beginning or end of line
| aForward | move forward in document. | |
| aExtend | continue selection |
LineMove will generally be called from the nsiselectioncontroller implementations.
the effect being the selection will move one line up or down.
| 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.
| 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
| 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.
| 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.
| 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.
| 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, | |||
| PRInt16 | aFlags | |||
| ) | const |
ScrollSelectionIntoView scrolls a region of the selection, so that it is visible in the scrolled view.
| aType | the selection to scroll into view. | |
| aRegion | the region inside the selection to scroll into view. | |
| aFlags | the scroll flags. Valid bits include: SCROLL_SYNCHRONOUS: when set, scrolls the selection into view before returning. If not set, posts a request which is processed at some point after the method returns. SCROLL_FIRST_ANCESTOR_ONLY: if set, only the first ancestor will be scrolled into view. |
| 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.
| 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.
| 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.
| 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.
WordExtendForDelete extends the selection backward or forward (logically) to the next word boundary, so that the selected word can be deleted.
| aForward | select forward in document. |
WordMove will generally be called from the nsiselectioncontroller implementations.
the effect being the selection will move one word left or right.
| aForward | move forward in document. | |
| aExtend | continue selection |
friend class nsTypedSelection [friend] |
1.7.1