Bug 54488 - "[Mac] Non-draggable widgets in background windows should look disabled...
[mozilla-central.git] / layout / generic / nsFrameSelection.h
blob27b55c206da486bfb5fe94dd49ee42605f6ed16c
1 /*
2 * ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * a mozilla.org contributor.
19 * Portions created by the Initial Developer are Copyright (C) 2006
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef nsFrameSelection_h___
39 #define nsFrameSelection_h___
41 #include "nsIFrame.h"
42 #include "nsIContent.h"
43 #include "nsISelectionController.h"
44 #include "nsIScrollableViewProvider.h"
45 #include "nsITableLayout.h"
46 #include "nsITableCellLayout.h"
47 #include "nsIDOMElement.h"
48 #include "nsGUIEvent.h"
50 // IID for the nsFrameSelection interface
51 // d78edc5a-28d0-48f0-8abb-1597b1591556
52 #define NS_FRAME_SELECTION_IID \
53 { 0xd78edc5a, 0x28d0, 0x48f0, \
54 { 0x8a, 0xbb, 0x15, 0x97, 0xb1, 0x59, 0x15, 0x56 } }
56 #ifdef IBMBIDI // Constant for Set/Get CaretBidiLevel
57 #define BIDI_LEVEL_UNDEFINED 0x80
58 #endif
60 //----------------------------------------------------------------------
62 // Selection interface
64 struct SelectionDetails
66 #ifdef NS_BUILD_REFCNT_LOGGING
67 SelectionDetails() {
68 MOZ_COUNT_CTOR(SelectionDetails);
70 ~SelectionDetails() {
71 MOZ_COUNT_DTOR(SelectionDetails);
73 #endif
74 PRInt32 mStart;
75 PRInt32 mEnd;
76 SelectionType mType;
77 SelectionDetails *mNext;
80 class nsIPresShell;
82 enum EWordMovementType { eStartWord, eEndWord, eDefaultBehavior };
84 /** PeekOffsetStruct is used to group various arguments (both input and output)
85 * that are passed to nsFrame::PeekOffset(). See below for the description of
86 * individual arguments.
88 struct NS_STACK_CLASS nsPeekOffsetStruct
90 void SetData(nsSelectionAmount aAmount,
91 nsDirection aDirection,
92 PRInt32 aStartOffset,
93 nscoord aDesiredX,
94 PRBool aJumpLines,
95 PRBool aScrollViewStop,
96 PRBool aIsKeyboardSelect,
97 PRBool aVisual,
98 EWordMovementType aWordMovementType = eDefaultBehavior)
101 mAmount = aAmount;
102 mDirection = aDirection;
103 mStartOffset = aStartOffset;
104 mDesiredX = aDesiredX;
105 mJumpLines = aJumpLines;
106 mScrollViewStop = aScrollViewStop;
107 mIsKeyboardSelect = aIsKeyboardSelect;
108 mVisual = aVisual;
109 mWordMovementType = aWordMovementType;
112 // Note: Most arguments (input and output) are only used with certain values
113 // of mAmount. These values are indicated for each argument below.
114 // Arguments with no such indication are used with all values of mAmount.
116 /*** Input arguments ***/
117 // Note: The value of some of the input arguments may be changed upon exit.
119 // mAmount: The type of movement requested (by character, word, line, etc.)
120 nsSelectionAmount mAmount;
122 // mDirection: eDirPrevious or eDirNext.
123 // * Note for visual bidi movement:
124 // eDirPrevious means 'left-then-up' if the containing block is LTR,
125 // 'right-then-up' if it is RTL.
126 // eDirNext means 'right-then-down' if the containing block is LTR,
127 // 'left-then-down' if it is RTL.
128 // Between paragraphs, eDirPrevious means "go to the visual end of the
129 // previous paragraph", and eDirNext means "go to the visual beginning
130 // of the next paragraph".
131 // Used with: eSelectCharacter, eSelectWord, eSelectLine, eSelectParagraph.
132 nsDirection mDirection;
134 // mStartOffset: Offset into the content of the current frame where the peek starts.
135 // Used with: eSelectCharacter, eSelectWord
136 PRInt32 mStartOffset;
138 // mDesiredX: The desired x coordinate for the caret.
139 // Used with: eSelectLine.
140 nscoord mDesiredX;
142 // mJumpLines: Whether to allow jumping across line boundaries.
143 // Used with: eSelectCharacter, eSelectWord.
144 PRBool mJumpLines;
146 // mScrollViewStop: Whether to stop when reaching a scroll view boundary.
147 // Used with: eSelectCharacter, eSelectWord, eSelectLine.
148 PRBool mScrollViewStop;
150 // mIsKeyboardSelect: Whether the peeking is done in response to a keyboard action.
151 // Used with: eSelectWord.
152 PRBool mIsKeyboardSelect;
154 // mVisual: Whether bidi caret behavior is visual (PR_TRUE) or logical (PR_FALSE).
155 // Used with: eSelectCharacter, eSelectWord, eSelectBeginLine, eSelectEndLine.
156 PRBool mVisual;
158 // mWordMovementType: An enum that determines whether to prefer the start or end of a word
159 // or to use the default beahvior, which is a combination of
160 // direction and the platform-based pref
161 // "layout.word_select.eat_space_to_next_word"
162 EWordMovementType mWordMovementType;
164 /*** Output arguments ***/
166 // mResultContent: Content reached as a result of the peek.
167 nsCOMPtr<nsIContent> mResultContent;
169 // mContentOffset: Offset into content reached as a result of the peek.
170 PRInt32 mContentOffset;
172 // mResultFrame: Frame reached as a result of the peek.
173 // Used with: eSelectCharacter, eSelectWord.
174 nsIFrame *mResultFrame;
176 // mAttachForward: When the result position is between two frames,
177 // indicates which of the two frames the caret should be painted in.
178 // PR_FALSE means "the end of the frame logically before the caret",
179 // PR_TRUE means "the beginning of the frame logically after the caret".
180 // Used with: eSelectLine, eSelectBeginLine, eSelectEndLine.
181 PRBool mAttachForward;
184 struct nsPrevNextBidiLevels
186 void SetData(nsIFrame* aFrameBefore,
187 nsIFrame* aFrameAfter,
188 PRUint8 aLevelBefore,
189 PRUint8 aLevelAfter)
191 mFrameBefore = aFrameBefore;
192 mFrameAfter = aFrameAfter;
193 mLevelBefore = aLevelBefore;
194 mLevelAfter = aLevelAfter;
196 nsIFrame* mFrameBefore;
197 nsIFrame* mFrameAfter;
198 PRUint8 mLevelBefore;
199 PRUint8 mLevelAfter;
202 class nsTypedSelection;
203 class nsIScrollableView;
206 * Methods which are marked with *unsafe* should be handled with special care.
207 * They may cause nsFrameSelection to be deleted, if strong pointer isn't used,
208 * or they may cause other objects to be deleted.
211 class nsFrameSelection : public nsISupports {
212 public:
213 NS_DECLARE_STATIC_IID_ACCESSOR(NS_FRAME_SELECTION_IID)
214 enum HINT { HINTLEFT = 0, HINTRIGHT = 1}; //end of this line or beginning of next
215 /*interfaces for addref and release and queryinterface*/
217 NS_DECL_ISUPPORTS
219 /** Init will initialize the frame selector with the necessary pres shell to
220 * be used by most of the methods
221 * @param aShell is the parameter to be used for most of the other calls for callbacks etc
222 * @param aLimiter limits the selection to nodes with aLimiter parents
224 void Init(nsIPresShell *aShell, nsIContent *aLimiter);
227 * SetScrollableViewProvider sets the scroll view provider.
228 * @param aProvider The provider of the scroll view.
230 void SetScrollableViewProvider(nsIScrollableViewProvider* aProvider)
232 mScrollableViewProvider = aProvider;
236 * GetScrollableView returns the current scroll view.
238 nsIScrollableView* GetScrollableView() const
240 return mScrollableViewProvider
241 ? mScrollableViewProvider->GetScrollableView()
242 : nsnull;
245 /** HandleClick will take the focus to the new frame at the new offset and
246 * will either extend the selection from the old anchor, or replace the old anchor.
247 * the old anchor and focus position may also be used to deselect things
248 * @param aNewfocus is the content that wants the focus
249 * @param aContentOffset is the content offset of the parent aNewFocus
250 * @param aContentOffsetEnd is the content offset of the parent aNewFocus and is specified different
251 * when you need to select to and include both start and end points
252 * @param aContinueSelection is the flag that tells the selection to keep the old anchor point or not.
253 * @param aMultipleSelection will tell the frame selector to replace /or not the old selection.
254 * cannot coexist with aContinueSelection
255 * @param aHint will tell the selection which direction geometrically to actually show the caret on.
256 * 1 = end of this line 0 = beginning of this line
258 /*unsafe*/
259 nsresult HandleClick(nsIContent *aNewFocus,
260 PRUint32 aContentOffset,
261 PRUint32 aContentEndOffset,
262 PRBool aContinueSelection,
263 PRBool aMultipleSelection,
264 PRBool aHint);
266 /** HandleDrag extends the selection to contain the frame closest to aPoint.
267 * @param aPresContext is the context to use when figuring out what frame contains the point.
268 * @param aFrame is the parent of all frames to use when searching for the closest frame to the point.
269 * @param aPoint is relative to aFrame
271 /*unsafe*/
272 void HandleDrag(nsIFrame *aFrame, nsPoint aPoint);
274 /** HandleTableSelection will set selection to a table, cell, etc
275 * depending on information contained in aFlags
276 * @param aParentContent is the paretent of either a table or cell that user clicked or dragged the mouse in
277 * @param aContentOffset is the offset of the table or cell
278 * @param aTarget indicates what to select (defined in nsISelectionPrivate.idl/nsISelectionPrivate.h):
279 * TABLESELECTION_CELL We should select a cell (content points to the cell)
280 * TABLESELECTION_ROW We should select a row (content points to any cell in row)
281 * TABLESELECTION_COLUMN We should select a row (content points to any cell in column)
282 * TABLESELECTION_TABLE We should select a table (content points to the table)
283 * TABLESELECTION_ALLCELLS We should select all cells (content points to any cell in table)
284 * @param aMouseEvent passed in so we can get where event occurred and what keys are pressed
286 /*unsafe*/
287 nsresult HandleTableSelection(nsIContent *aParentContent,
288 PRInt32 aContentOffset,
289 PRInt32 aTarget,
290 nsMouseEvent *aMouseEvent);
292 /** StartAutoScrollTimer is responsible for scrolling views so that aPoint is always
293 * visible, and for selecting any frame that contains aPoint. The timer will also reset
294 * itself to fire again if we have not scrolled to the end of the document.
295 * @param aView is view to use when searching for the closest frame to the point,
296 * which is the view that is capturing the mouse
297 * @param aPoint is relative to the view.
298 * @param aDelay is the timer's interval.
300 nsresult StartAutoScrollTimer(nsIView *aView,
301 nsPoint aPoint,
302 PRUint32 aDelay);
304 /** StopAutoScrollTimer stops any active auto scroll timer.
306 void StopAutoScrollTimer();
308 /** Lookup Selection
309 * returns in frame coordinates the selection beginning and ending with the type of selection given
310 * @param aContent is the content asking
311 * @param aContentOffset is the starting content boundary
312 * @param aContentLength is the length of the content piece asking
313 * @param aReturnDetails linkedlist of return values for the selection.
314 * @param aSlowCheck will check using slow method with no shortcuts
316 SelectionDetails* LookUpSelection(nsIContent *aContent,
317 PRInt32 aContentOffset,
318 PRInt32 aContentLength,
319 PRBool aSlowCheck) const;
321 /** SetMouseDownState(PRBool);
322 * sets the mouse state to aState for resons of drag state.
323 * @param aState is the new state of mousedown
325 /*unsafe*/
326 void SetMouseDownState(PRBool aState);
328 /** GetMouseDownState(PRBool *);
329 * gets the mouse state to aState for resons of drag state.
330 * @param aState will hold the state of mousedown
332 PRBool GetMouseDownState() const { return mMouseDownState; }
335 if we are in table cell selection mode. aka ctrl click in table cell
337 PRBool GetTableCellSelection() const { return mSelectingTableCellMode != 0; }
338 void ClearTableCellSelection() { mSelectingTableCellMode = 0; }
340 /** GetSelection
341 * no query interface for selection. must use this method now.
342 * @param aSelectionType enum value defined in nsISelection for the seleciton you want.
344 nsISelection* GetSelection(SelectionType aType) const;
347 * ScrollSelectionIntoView scrolls a region of the selection,
348 * so that it is visible in the scrolled view.
350 * @param aType the selection to scroll into view.
351 * @param aRegion the region inside the selection to scroll into view.
352 * @param aIsSynchronous when PR_TRUE, scrolls the selection into view
353 * at some point after the method returns.request which is processed
355 nsresult ScrollSelectionIntoView(SelectionType aType,
356 SelectionRegion aRegion,
357 PRBool aIsSynchronous) const;
359 /** RepaintSelection repaints the selected frames that are inside the selection
360 * specified by aSelectionType.
361 * @param aSelectionType enum value defined in nsISelection for the seleciton you want.
363 nsresult RepaintSelection(SelectionType aType) const;
365 /** GetFrameForNodeOffset given a node and its child offset, return the nsIFrame and
366 * the offset into that frame.
367 * @param aNode input parameter for the node to look at
368 * @param aOffset offset into above node.
369 * @param aReturnOffset will contain offset into frame.
371 virtual nsIFrame* GetFrameForNodeOffset(nsIContent *aNode,
372 PRInt32 aOffset,
373 HINT aHint,
374 PRInt32 *aReturnOffset) const;
377 * Scrolling then moving caret placement code in common to text areas and
378 * content areas should be located in the implementer
379 * This method will accept the following parameters and perform the scroll
380 * and caret movement. It remains for the caller to call the final
381 * ScrollCaretIntoView if that called wants to be sure the caret is always
382 * visible.
384 * @param aForward if PR_TRUE, scroll forward if not scroll backward
385 * @param aExtend if PR_TRUE, extend selection to the new point
386 * @param aScrollableView the view that needs the scrolling
388 /*unsafe*/
389 void CommonPageMove(PRBool aForward,
390 PRBool aExtend,
391 nsIScrollableView *aScrollableView);
393 void SetHint(HINT aHintRight) { mHint = aHintRight; }
394 HINT GetHint() const { return mHint; }
396 #ifdef IBMBIDI
397 /** SetCaretBidiLevel sets the caret bidi level
398 * @param aLevel the caret bidi level
399 * This method is virtual since it gets called from outside of layout.
401 virtual void SetCaretBidiLevel (PRUint8 aLevel);
402 /** GetCaretBidiLevel gets the caret bidi level
403 * This method is virtual since it gets called from outside of layout.
405 virtual PRUint8 GetCaretBidiLevel() const;
406 /** UndefineCaretBidiLevel sets the caret bidi level to "undefined"
407 * This method is virtual since it gets called from outside of layout.
409 virtual void UndefineCaretBidiLevel();
410 #endif
412 /** CharacterMove will generally be called from the nsiselectioncontroller implementations.
413 * the effect being the selection will move one character left or right.
414 * @param aForward move forward in document.
415 * @param aExtend continue selection
417 /*unsafe*/
418 nsresult CharacterMove(PRBool aForward, PRBool aExtend);
420 /** WordMove will generally be called from the nsiselectioncontroller implementations.
421 * the effect being the selection will move one word left or right.
422 * @param aForward move forward in document.
423 * @param aExtend continue selection
425 /*unsafe*/
426 nsresult WordMove(PRBool aForward, PRBool aExtend);
428 /** WordExtendForDelete extends the selection backward or forward (logically) to the
429 * next word boundary, so that the selected word can be deleted.
430 * @param aForward select forward in document.
432 /*unsafe*/
433 nsresult WordExtendForDelete(PRBool aForward);
435 /** LineMove will generally be called from the nsiselectioncontroller implementations.
436 * the effect being the selection will move one line up or down.
437 * @param aForward move forward in document.
438 * @param aExtend continue selection
440 /*unsafe*/
441 nsresult LineMove(PRBool aForward, PRBool aExtend);
443 /** IntraLineMove will generally be called from the nsiselectioncontroller implementations.
444 * the effect being the selection will move to beginning or end of line
445 * @param aForward move forward in document.
446 * @param aExtend continue selection
448 /*unsafe*/
449 nsresult IntraLineMove(PRBool aForward, PRBool aExtend);
451 /** Select All will generally be called from the nsiselectioncontroller implementations.
452 * it will select the whole doc
454 /*unsafe*/
455 nsresult SelectAll();
457 /** Sets/Gets The display selection enum.
459 void SetDisplaySelection(PRInt16 aState) { mDisplaySelection = aState; }
460 PRInt16 GetDisplaySelection() const { return mDisplaySelection; }
462 /** This method can be used to store the data received during a MouseDown
463 * event so that we can place the caret during the MouseUp event.
464 * @aMouseEvent the event received by the selection MouseDown
465 * handling method. A NULL value can be use to tell this method
466 * that any data is storing is no longer valid.
468 void SetDelayedCaretData(nsMouseEvent *aMouseEvent);
470 /** Get the delayed MouseDown event data necessary to place the
471 * caret during MouseUp processing.
472 * @return a pointer to the event received
473 * by the selection during MouseDown processing. It can be NULL
474 * if the data is no longer valid.
476 nsMouseEvent* GetDelayedCaretData();
478 /** Get the content node that limits the selection
479 * When searching up a nodes for parents, as in a text edit field
480 * in an browser page, we must stop at this node else we reach into the
481 * parent page, which is very bad!
483 nsIContent* GetLimiter() const { return mLimiter; }
485 nsIContent* GetAncestorLimiter() const { return mAncestorLimiter; }
486 /*unsafe*/
487 void SetAncestorLimiter(nsIContent *aLimiter);
489 /** This will tell the frame selection that a double click has been pressed
490 * so it can track abort future drags if inside the same selection
491 * @aDoubleDown has the double click down happened
493 void SetMouseDoubleDown(PRBool aDoubleDown) { mMouseDoubleDownState = aDoubleDown; }
495 /** This will return whether the double down flag was set.
496 * @return whether the double down flag was set
498 PRBool GetMouseDoubleDown() const { return mMouseDoubleDownState; }
500 /** GetPrevNextBidiLevels will return the frames and associated Bidi levels of the characters
501 * logically before and after a (collapsed) selection.
502 * @param aNode is the node containing the selection
503 * @param aContentOffset is the offset of the selection in the node
504 * @param aJumpLines If PR_TRUE, look across line boundaries.
505 * If PR_FALSE, behave as if there were base-level frames at line edges.
507 * @return A struct holding the before/after frame and the before/after level.
509 * At the beginning and end of each line there is assumed to be a frame with
510 * Bidi level equal to the paragraph embedding level.
511 * In these cases the before frame and after frame respectively will be
512 * nsnull.
514 * This method is virtual since it gets called from outside of layout.
516 virtual nsPrevNextBidiLevels GetPrevNextBidiLevels(nsIContent *aNode,
517 PRUint32 aContentOffset,
518 PRBool aJumpLines) const;
520 /** GetFrameFromLevel will scan in a given direction
521 * until it finds a frame with a Bidi level less than or equal to a given level.
522 * It will return the last frame before this.
523 * @param aPresContext is the context to use
524 * @param aFrameIn is the frame to start from
525 * @param aDirection is the direction to scan
526 * @param aBidiLevel is the level to search for
527 * @param aFrameOut will hold the frame returned
529 nsresult GetFrameFromLevel(nsIFrame *aFrameIn,
530 nsDirection aDirection,
531 PRUint8 aBidiLevel,
532 nsIFrame **aFrameOut) const;
535 * MaintainSelection will track the current selection as being "sticky".
536 * Dragging or extending selection will never allow for a subset
537 * (or the whole) of the maintained selection to become unselected.
538 * Primary use: double click selecting then dragging on second click
539 * @param aAmount the initial amount of text selected (word, line or paragraph).
540 * For "line", use eSelectBeginLine.
542 nsresult MaintainSelection(nsSelectionAmount aAmount = eSelectNoAmount);
545 nsFrameSelection();
546 virtual ~nsFrameSelection();
548 void StartBatchChanges();
549 void EndBatchChanges();
550 /*unsafe*/
551 nsresult DeleteFromDocument();
553 nsIPresShell *GetShell()const { return mShell; }
555 void DisconnectFromPresShell() { mShell = nsnull; }
556 private:
557 nsresult TakeFocus(nsIContent *aNewFocus,
558 PRUint32 aContentOffset,
559 PRUint32 aContentEndOffset,
560 PRBool aContinueSelection,
561 PRBool aMultipleSelection);
563 void BidiLevelFromMove(nsIPresShell* aPresShell,
564 nsIContent *aNode,
565 PRUint32 aContentOffset,
566 PRUint32 aKeycode,
567 HINT aHint);
568 void BidiLevelFromClick(nsIContent *aNewFocus, PRUint32 aContentOffset);
569 nsPrevNextBidiLevels GetPrevNextBidiLevels(nsIContent *aNode,
570 PRUint32 aContentOffset,
571 HINT aHint,
572 PRBool aJumpLines) const;
573 #ifdef VISUALSELECTION
574 NS_IMETHOD VisualSelectFrames(nsIFrame* aCurrentFrame,
575 nsPeekOffsetStruct aPos);
576 NS_IMETHOD VisualSequence(nsIFrame* aSelectFrame,
577 nsIFrame* aCurrentFrame,
578 nsPeekOffsetStruct* aPos,
579 PRBool* aNeedVisualSelection);
580 NS_IMETHOD SelectToEdge(nsIFrame *aFrame,
581 nsIContent *aContent,
582 PRInt32 aOffset,
583 PRInt32 aEdge,
584 PRBool aMultipleSelection);
585 NS_IMETHOD SelectLines(nsDirection aSelectionDirection,
586 nsIDOMNode *aAnchorNode,
587 nsIFrame* aAnchorFrame,
588 PRInt32 aAnchorOffset,
589 nsIDOMNode *aCurrentNode,
590 nsIFrame* aCurrentFrame,
591 PRInt32 aCurrentOffset,
592 nsPeekOffsetStruct aPos);
593 #endif // VISUALSELECTION
595 PRBool AdjustForMaintainedSelection(nsIContent *aContent, PRInt32 aOffset);
597 // post and pop reasons for notifications. we may stack these later
598 void PostReason(PRInt16 aReason) { mSelectionChangeReason = aReason; }
599 PRInt16 PopReason()
601 PRInt16 retval = mSelectionChangeReason;
602 mSelectionChangeReason = 0;
603 return retval;
606 friend class nsTypedSelection;
607 #ifdef DEBUG
608 void printSelection(); // for debugging
609 #endif /* DEBUG */
611 void ResizeBuffer(PRUint32 aNewBufSize);
612 /*HELPER METHODS*/
613 nsresult MoveCaret(PRUint32 aKeycode, PRBool aContinueSelection, nsSelectionAmount aAmount);
615 nsresult FetchDesiredX(nscoord &aDesiredX); //the x position requested by the Key Handling for up down
616 void InvalidateDesiredX(); //do not listen to mDesiredX you must get another.
617 void SetDesiredX(nscoord aX); //set the mDesiredX
619 nsresult GetRootForContentSubtree(nsIContent *aContent, nsIContent **aParent);
620 nsresult ConstrainFrameAndPointToAnchorSubtree(nsIFrame *aFrame, nsPoint& aPoint, nsIFrame **aRetFrame, nsPoint& aRetPoint);
622 PRUint32 GetBatching() const {return mBatching; }
623 PRBool GetNotifyFrames() const { return mNotifyFrames; }
624 void SetDirty(PRBool aDirty=PR_TRUE){if (mBatching) mChangesDuringBatching = aDirty;}
626 // nsFrameSelection may get deleted when calling this,
627 // so remember to use nsCOMPtr when needed.
628 nsresult NotifySelectionListeners(SelectionType aType); // add parameters to say collapsed etc?
630 nsTypedSelection *mDomSelections[nsISelectionController::NUM_SELECTIONTYPES];
632 // Table selection support.
633 // Interfaces that let us get info based on cellmap locations
634 nsITableLayout* GetTableLayout(nsIContent *aTableContent) const;
635 nsITableCellLayout* GetCellLayout(nsIContent *aCellContent) const;
637 nsresult SelectBlockOfCells(nsIContent *aStartNode, nsIContent *aEndNode);
638 nsresult SelectRowOrColumn(nsIContent *aCellContent, PRUint32 aTarget);
639 nsresult GetCellIndexes(nsIContent *aCell, PRInt32 &aRowIndex, PRInt32 &aColIndex);
641 nsresult GetFirstSelectedCellAndRange(nsIDOMNode **aCell, nsIDOMRange **aRange);
642 nsresult GetNextSelectedCellAndRange(nsIDOMNode **aCell, nsIDOMRange **aRange);
643 nsresult GetFirstCellNodeInRange(nsIDOMRange *aRange,
644 nsIDOMNode **aCellNode) const;
645 // aTableNode may be null if table isn't needed to be returned
646 PRBool IsInSameTable(nsIContent *aContent1, nsIContent *aContent2,
647 nsIContent **aTableNode) const;
648 nsresult GetParentTable(nsIContent *aCellNode,
649 nsIContent **aTableNode) const;
650 nsresult SelectCellElement(nsIDOMElement* aCellElement);
651 nsresult CreateAndAddRange(nsIDOMNode *aParentNode, PRInt32 aOffset);
652 nsresult ClearNormalSelection();
654 nsCOMPtr<nsIDOMNode> mCellParent; //used to snap to table selection
655 nsCOMPtr<nsIContent> mStartSelectedCell;
656 nsCOMPtr<nsIContent> mEndSelectedCell;
657 nsCOMPtr<nsIContent> mAppendStartSelectedCell;
658 nsCOMPtr<nsIContent> mUnselectCellOnMouseUp;
659 PRInt32 mSelectingTableCellMode;
660 PRInt32 mSelectedCellIndex;
662 // maintain selection
663 nsCOMPtr<nsIDOMRange> mMaintainRange;
664 nsSelectionAmount mMaintainedAmount;
666 //batching
667 PRInt32 mBatching;
669 nsIContent *mLimiter; //limit selection navigation to a child of this node.
670 nsIContent *mAncestorLimiter; // Limit selection navigation to a descendant of
671 // this node.
672 nsIPresShell *mShell;
674 PRInt16 mSelectionChangeReason; // reason for notifications of selection changing
675 PRInt16 mDisplaySelection; //for visual display purposes.
677 HINT mHint; //hint to tell if the selection is at the end of this line or beginning of next
678 #ifdef IBMBIDI
679 PRUint8 mCaretBidiLevel;
680 #endif
682 PRInt32 mDesiredX;
683 nsIScrollableViewProvider* mScrollableViewProvider;
685 nsMouseEvent mDelayedMouseEvent;
687 PRPackedBool mDelayedMouseEventValid;
689 PRPackedBool mChangesDuringBatching;
690 PRPackedBool mNotifyFrames;
691 PRPackedBool mIsEditor;
692 PRPackedBool mDragSelectingCells;
693 PRPackedBool mMouseDownState; //for drag purposes
694 PRPackedBool mMouseDoubleDownState; //has the doubleclick down happened
695 PRPackedBool mDesiredXSet;
697 PRInt8 mCaretMovementStyle;
700 NS_DEFINE_STATIC_IID_ACCESSOR(nsFrameSelection, NS_FRAME_SELECTION_IID)
702 #endif /* nsFrameSelection_h___ */