/usr/include/firefox/nsFrameSelection.h is in firefox-dev 11.0+build1-0ubuntu4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 | /*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* a mozilla.org contributor.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsFrameSelection_h___
#define nsFrameSelection_h___
#include "nsIFrame.h"
#include "nsIContent.h"
#include "nsISelectionController.h"
#include "nsITableLayout.h"
#include "nsITableCellLayout.h"
#include "nsIDOMElement.h"
#include "nsGUIEvent.h"
#include "nsIRange.h"
// IID for the nsFrameSelection interface
// 3c6ae2d0-4cf1-44a1-9e9d-2411867f19c6
#define NS_FRAME_SELECTION_IID \
{ 0x3c6ae2d0, 0x4cf1, 0x44a1, \
{ 0x9e, 0x9d, 0x24, 0x11, 0x86, 0x7f, 0x19, 0xc6 } }
#ifdef IBMBIDI // Constant for Set/Get CaretBidiLevel
#define BIDI_LEVEL_UNDEFINED 0x80
#endif
//----------------------------------------------------------------------
// Selection interface
struct SelectionDetails
{
#ifdef NS_BUILD_REFCNT_LOGGING
SelectionDetails() {
MOZ_COUNT_CTOR(SelectionDetails);
}
~SelectionDetails() {
MOZ_COUNT_DTOR(SelectionDetails);
}
#endif
PRInt32 mStart;
PRInt32 mEnd;
SelectionType mType;
nsTextRangeStyle mTextRangeStyle;
SelectionDetails *mNext;
};
class nsIPresShell;
class nsIScrollableFrame;
enum EWordMovementType { eStartWord, eEndWord, eDefaultBehavior };
/** PeekOffsetStruct is used to group various arguments (both input and output)
* that are passed to nsFrame::PeekOffset(). See below for the description of
* individual arguments.
*/
struct NS_STACK_CLASS nsPeekOffsetStruct
{
void SetData(nsSelectionAmount aAmount,
nsDirection aDirection,
PRInt32 aStartOffset,
nscoord aDesiredX,
bool aJumpLines,
bool aScrollViewStop,
bool aIsKeyboardSelect,
bool aVisual,
EWordMovementType aWordMovementType = eDefaultBehavior)
{
mAmount = aAmount;
mDirection = aDirection;
mStartOffset = aStartOffset;
mDesiredX = aDesiredX;
mJumpLines = aJumpLines;
mScrollViewStop = aScrollViewStop;
mIsKeyboardSelect = aIsKeyboardSelect;
mVisual = aVisual;
mWordMovementType = aWordMovementType;
}
// Note: Most arguments (input and output) are only used with certain values
// of mAmount. These values are indicated for each argument below.
// Arguments with no such indication are used with all values of mAmount.
/*** Input arguments ***/
// Note: The value of some of the input arguments may be changed upon exit.
// mAmount: The type of movement requested (by character, word, line, etc.)
nsSelectionAmount mAmount;
// mDirection: eDirPrevious or eDirNext.
// * Note for visual bidi movement:
// eDirPrevious means 'left-then-up' if the containing block is LTR,
// 'right-then-up' if it is RTL.
// eDirNext means 'right-then-down' if the containing block is LTR,
// 'left-then-down' if it is RTL.
// Between paragraphs, eDirPrevious means "go to the visual end of the
// previous paragraph", and eDirNext means "go to the visual beginning
// of the next paragraph".
// Used with: eSelectCharacter, eSelectWord, eSelectLine, eSelectParagraph.
nsDirection mDirection;
// mStartOffset: Offset into the content of the current frame where the peek starts.
// Used with: eSelectCharacter, eSelectWord
PRInt32 mStartOffset;
// mDesiredX: The desired x coordinate for the caret.
// Used with: eSelectLine.
nscoord mDesiredX;
// mWordMovementType: An enum that determines whether to prefer the start or end of a word
// or to use the default beahvior, which is a combination of
// direction and the platform-based pref
// "layout.word_select.eat_space_to_next_word"
EWordMovementType mWordMovementType;
// mJumpLines: Whether to allow jumping across line boundaries.
// Used with: eSelectCharacter, eSelectWord.
bool mJumpLines;
// mScrollViewStop: Whether to stop when reaching a scroll view boundary.
// Used with: eSelectCharacter, eSelectWord, eSelectLine.
bool mScrollViewStop;
// mIsKeyboardSelect: Whether the peeking is done in response to a keyboard action.
// Used with: eSelectWord.
bool mIsKeyboardSelect;
// mVisual: Whether bidi caret behavior is visual (true) or logical (false).
// Used with: eSelectCharacter, eSelectWord, eSelectBeginLine, eSelectEndLine.
bool mVisual;
/*** Output arguments ***/
// mResultContent: Content reached as a result of the peek.
nsCOMPtr<nsIContent> mResultContent;
// mResultFrame: Frame reached as a result of the peek.
// Used with: eSelectCharacter, eSelectWord.
nsIFrame *mResultFrame;
// mContentOffset: Offset into content reached as a result of the peek.
PRInt32 mContentOffset;
// mAttachForward: When the result position is between two frames,
// indicates which of the two frames the caret should be painted in.
// false means "the end of the frame logically before the caret",
// true means "the beginning of the frame logically after the caret".
// Used with: eSelectLine, eSelectBeginLine, eSelectEndLine.
bool mAttachForward;
};
struct nsPrevNextBidiLevels
{
void SetData(nsIFrame* aFrameBefore,
nsIFrame* aFrameAfter,
PRUint8 aLevelBefore,
PRUint8 aLevelAfter)
{
mFrameBefore = aFrameBefore;
mFrameAfter = aFrameAfter;
mLevelBefore = aLevelBefore;
mLevelAfter = aLevelAfter;
}
nsIFrame* mFrameBefore;
nsIFrame* mFrameAfter;
PRUint8 mLevelBefore;
PRUint8 mLevelAfter;
};
class nsTypedSelection;
class nsIScrollableFrame;
/**
* 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.
*/
class nsFrameSelection : public nsISupports {
public:
enum HINT { HINTLEFT = 0, HINTRIGHT = 1}; //end of this line or beginning of next
/*interfaces for addref and release and queryinterface*/
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(nsFrameSelection)
/** Init will initialize the frame selector with the necessary pres shell to
* be used by most of the methods
* @param aShell is the parameter to be used for most of the other calls for callbacks etc
* @param aLimiter limits the selection to nodes with aLimiter parents
*/
void Init(nsIPresShell *aShell, nsIContent *aLimiter);
/** 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
* @param aNewfocus is the content that wants the focus
* @param aContentOffset is the content offset of the parent aNewFocus
* @param 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
* @param aContinueSelection is the flag that tells the selection to keep the old anchor point or not.
* @param aMultipleSelection will tell the frame selector to replace /or not the old selection.
* cannot coexist with aContinueSelection
* @param aHint will tell the selection which direction geometrically to actually show the caret on.
* 1 = end of this line 0 = beginning of this line
*/
/*unsafe*/
nsresult HandleClick(nsIContent *aNewFocus,
PRUint32 aContentOffset,
PRUint32 aContentEndOffset,
bool aContinueSelection,
bool aMultipleSelection,
bool aHint);
/** HandleDrag extends the selection to contain the frame closest to aPoint.
* @param aPresContext is the context to use when figuring out what frame contains the point.
* @param aFrame is the parent of all frames to use when searching for the closest frame to the point.
* @param aPoint is relative to aFrame
*/
/*unsafe*/
void HandleDrag(nsIFrame *aFrame, nsPoint aPoint);
/** HandleTableSelection will set selection to a table, cell, etc
* depending on information contained in aFlags
* @param aParentContent is the paretent of either a table or cell that user clicked or dragged the mouse in
* @param aContentOffset is the offset of the table or cell
* @param 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)
* @param aMouseEvent passed in so we can get where event occurred and what keys are pressed
*/
/*unsafe*/
nsresult HandleTableSelection(nsINode *aParentContent,
PRInt32 aContentOffset,
PRInt32 aTarget,
nsMouseEvent *aMouseEvent);
/**
* Add cell to the selection.
*
* @param aCell [in] HTML td element.
*/
virtual nsresult SelectCellElement(nsIContent *aCell);
/**
* Add cells to the selection inside of the given cells range.
*
* @param aTable [in] HTML table element
* @param aStartRowIndex [in] row index where the cells range starts
* @param aStartColumnIndex [in] column index where the cells range starts
* @param aEndRowIndex [in] row index where the cells range ends
* @param aEndColumnIndex [in] column index where the cells range ends
*/
virtual nsresult AddCellsToSelection(nsIContent *aTable,
PRInt32 aStartRowIndex,
PRInt32 aStartColumnIndex,
PRInt32 aEndRowIndex,
PRInt32 aEndColumnIndex);
/**
* Remove cells from selection inside of the given cell range.
*
* @param aTable [in] HTML table element
* @param aStartRowIndex [in] row index where the cells range starts
* @param aStartColumnIndex [in] column index where the cells range starts
* @param aEndRowIndex [in] row index where the cells range ends
* @param aEndColumnIndex [in] column index where the cells range ends
*/
virtual nsresult RemoveCellsFromSelection(nsIContent *aTable,
PRInt32 aStartRowIndex,
PRInt32 aStartColumnIndex,
PRInt32 aEndRowIndex,
PRInt32 aEndColumnIndex);
/**
* Remove cells from selection outside of the given cell range.
*
* @param aTable [in] HTML table element
* @param aStartRowIndex [in] row index where the cells range starts
* @param aStartColumnIndex [in] column index where the cells range starts
* @param aEndRowIndex [in] row index where the cells range ends
* @param aEndColumnIndex [in] column index where the cells range ends
*/
virtual nsresult RestrictCellsToSelection(nsIContent *aTable,
PRInt32 aStartRowIndex,
PRInt32 aStartColumnIndex,
PRInt32 aEndRowIndex,
PRInt32 aEndColumnIndex);
/** 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.
* @param 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
* @param aPoint is relative to aFrame.
* @param aDelay is the timer's interval.
*/
/*unsafe*/
nsresult StartAutoScrollTimer(nsIFrame *aFrame,
nsPoint aPoint,
PRUint32 aDelay);
/** StopAutoScrollTimer stops any active auto scroll timer.
*/
void StopAutoScrollTimer();
/** Lookup Selection
* returns in frame coordinates the selection beginning and ending with the type of selection given
* @param aContent is the content asking
* @param aContentOffset is the starting content boundary
* @param aContentLength is the length of the content piece asking
* @param aReturnDetails linkedlist of return values for the selection.
* @param aSlowCheck will check using slow method with no shortcuts
*/
SelectionDetails* LookUpSelection(nsIContent *aContent,
PRInt32 aContentOffset,
PRInt32 aContentLength,
bool aSlowCheck) const;
/** SetMouseDownState(bool);
* sets the mouse state to aState for resons of drag state.
* @param aState is the new state of mousedown
*/
/*unsafe*/
void SetMouseDownState(bool aState);
/** GetMouseDownState(bool *);
* gets the mouse state to aState for resons of drag state.
* @param aState will hold the state of mousedown
*/
bool GetMouseDownState() const { return mMouseDownState; }
/**
if we are in table cell selection mode. aka ctrl click in table cell
*/
bool GetTableCellSelection() const { return mSelectingTableCellMode != 0; }
void ClearTableCellSelection() { mSelectingTableCellMode = 0; }
/** GetSelection
* no query interface for selection. must use this method now.
* @param aSelectionType enum value defined in nsISelection for the seleciton you want.
*/
nsISelection* GetSelection(SelectionType aType) const;
/**
* ScrollSelectionIntoView scrolls a region of the selection,
* so that it is visible in the scrolled view.
*
* @param aType the selection to scroll into view.
* @param aRegion the region inside the selection to scroll into view.
* @param 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.
*/
/*unsafe*/
nsresult ScrollSelectionIntoView(SelectionType aType,
SelectionRegion aRegion,
PRInt16 aFlags) const;
/** RepaintSelection repaints the selected frames that are inside the selection
* specified by aSelectionType.
* @param aSelectionType enum value defined in nsISelection for the seleciton you want.
*/
nsresult RepaintSelection(SelectionType aType) const;
/** GetFrameForNodeOffset given a node and its child offset, return the nsIFrame and
* the offset into that frame.
* @param aNode input parameter for the node to look at
* @param aOffset offset into above node.
* @param aReturnOffset will contain offset into frame.
*/
virtual nsIFrame* GetFrameForNodeOffset(nsIContent *aNode,
PRInt32 aOffset,
HINT aHint,
PRInt32 *aReturnOffset) const;
/**
* 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.
*
* @param aForward if true, scroll forward if not scroll backward
* @param aExtend if true, extend selection to the new point
* @param aScrollableFrame the frame to scroll
*/
/*unsafe*/
void CommonPageMove(bool aForward,
bool aExtend,
nsIScrollableFrame* aScrollableFrame);
void SetHint(HINT aHintRight) { mHint = aHintRight; }
HINT GetHint() const { return mHint; }
#ifdef IBMBIDI
/** SetCaretBidiLevel sets the caret bidi level
* @param aLevel the caret bidi level
* This method is virtual since it gets called from outside of layout.
*/
virtual void SetCaretBidiLevel (PRUint8 aLevel);
/** GetCaretBidiLevel gets the caret bidi level
* This method is virtual since it gets called from outside of layout.
*/
virtual PRUint8 GetCaretBidiLevel() const;
/** UndefineCaretBidiLevel sets the caret bidi level to "undefined"
* This method is virtual since it gets called from outside of layout.
*/
virtual void UndefineCaretBidiLevel();
#endif
/** CharacterMove will generally be called from the nsiselectioncontroller implementations.
* the effect being the selection will move one character left or right.
* @param aForward move forward in document.
* @param aExtend continue selection
*/
/*unsafe*/
nsresult CharacterMove(bool aForward, bool aExtend);
/** CharacterExtendForDelete extends the selection forward (logically) to
* the next character cell, so that the selected cell can be deleted.
*/
/*unsafe*/
nsresult CharacterExtendForDelete();
/** CharacterExtendForBackspace extends the selection backward (logically) to
* the previous character cell, so that the selected cell can be deleted.
*/
/*unsafe*/
nsresult CharacterExtendForBackspace();
/** WordMove will generally be called from the nsiselectioncontroller implementations.
* the effect being the selection will move one word left or right.
* @param aForward move forward in document.
* @param aExtend continue selection
*/
/*unsafe*/
nsresult WordMove(bool aForward, bool aExtend);
/** WordExtendForDelete extends the selection backward or forward (logically) to the
* next word boundary, so that the selected word can be deleted.
* @param aForward select forward in document.
*/
/*unsafe*/
nsresult WordExtendForDelete(bool aForward);
/** LineMove will generally be called from the nsiselectioncontroller implementations.
* the effect being the selection will move one line up or down.
* @param aForward move forward in document.
* @param aExtend continue selection
*/
/*unsafe*/
nsresult LineMove(bool aForward, bool aExtend);
/** IntraLineMove will generally be called from the nsiselectioncontroller implementations.
* the effect being the selection will move to beginning or end of line
* @param aForward move forward in document.
* @param aExtend continue selection
*/
/*unsafe*/
nsresult IntraLineMove(bool aForward, bool aExtend);
/** Select All will generally be called from the nsiselectioncontroller implementations.
* it will select the whole doc
*/
/*unsafe*/
nsresult SelectAll();
/** Sets/Gets The display selection enum.
*/
void SetDisplaySelection(PRInt16 aState) { mDisplaySelection = aState; }
PRInt16 GetDisplaySelection() const { return mDisplaySelection; }
/** 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.
* @aMouseEvent 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 SetDelayedCaretData(nsMouseEvent *aMouseEvent);
/** Get the delayed MouseDown event data necessary to place the
* caret during MouseUp processing.
* @return a pointer to the event received
* by the selection during MouseDown processing. It can be NULL
* if the data is no longer valid.
*/
nsMouseEvent* GetDelayedCaretData();
/** 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* GetLimiter() const { return mLimiter; }
nsIContent* GetAncestorLimiter() const { return mAncestorLimiter; }
/*unsafe*/
void SetAncestorLimiter(nsIContent *aLimiter);
/** 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
* @aDoubleDown has the double click down happened
*/
void SetMouseDoubleDown(bool aDoubleDown) { mMouseDoubleDownState = aDoubleDown; }
/** This will return whether the double down flag was set.
* @return whether the double down flag was set
*/
bool GetMouseDoubleDown() const { return mMouseDoubleDownState; }
/** GetPrevNextBidiLevels will return the frames and associated Bidi levels of the characters
* logically before and after a (collapsed) selection.
* @param aNode is the node containing the selection
* @param aContentOffset is the offset of the selection in the node
* @param aJumpLines If true, look across line boundaries.
* If false, behave as if there were base-level frames at line edges.
*
* @return 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.
*/
virtual nsPrevNextBidiLevels GetPrevNextBidiLevels(nsIContent *aNode,
PRUint32 aContentOffset,
bool aJumpLines) 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.
* @param aPresContext is the context to use
* @param aFrameIn is the frame to start from
* @param aDirection is the direction to scan
* @param aBidiLevel is the level to search for
* @param aFrameOut will hold the frame returned
*/
nsresult GetFrameFromLevel(nsIFrame *aFrameIn,
nsDirection aDirection,
PRUint8 aBidiLevel,
nsIFrame **aFrameOut) const;
/**
* 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
* @param aAmount the initial amount of text selected (word, line or paragraph).
* For "line", use eSelectBeginLine.
*/
nsresult MaintainSelection(nsSelectionAmount aAmount = eSelectNoAmount);
nsFrameSelection();
void StartBatchChanges();
void EndBatchChanges();
/*unsafe*/
nsresult DeleteFromDocument();
nsIPresShell *GetShell()const { return mShell; }
void DisconnectFromPresShell();
private:
nsresult TakeFocus(nsIContent *aNewFocus,
PRUint32 aContentOffset,
PRUint32 aContentEndOffset,
HINT aHint,
bool aContinueSelection,
bool aMultipleSelection);
void BidiLevelFromMove(nsIPresShell* aPresShell,
nsIContent *aNode,
PRUint32 aContentOffset,
PRUint32 aKeycode,
HINT aHint);
void BidiLevelFromClick(nsIContent *aNewFocus, PRUint32 aContentOffset);
nsPrevNextBidiLevels GetPrevNextBidiLevels(nsIContent *aNode,
PRUint32 aContentOffset,
HINT aHint,
bool aJumpLines) const;
bool AdjustForMaintainedSelection(nsIContent *aContent, PRInt32 aOffset);
// post and pop reasons for notifications. we may stack these later
void PostReason(PRInt16 aReason) { mSelectionChangeReason = aReason; }
PRInt16 PopReason()
{
PRInt16 retval = mSelectionChangeReason;
mSelectionChangeReason = 0;
return retval;
}
friend class nsTypedSelection;
#ifdef DEBUG
void printSelection(); // for debugging
#endif /* DEBUG */
void ResizeBuffer(PRUint32 aNewBufSize);
/*HELPER METHODS*/
nsresult MoveCaret(PRUint32 aKeycode, bool aContinueSelection,
nsSelectionAmount aAmount);
nsresult MoveCaret(PRUint32 aKeycode, bool aContinueSelection,
nsSelectionAmount aAmount,
bool aVisualMovement);
nsresult FetchDesiredX(nscoord &aDesiredX); //the x position requested by the Key Handling for up down
void InvalidateDesiredX(); //do not listen to mDesiredX you must get another.
void SetDesiredX(nscoord aX); //set the mDesiredX
nsresult ConstrainFrameAndPointToAnchorSubtree(nsIFrame *aFrame, nsPoint& aPoint, nsIFrame **aRetFrame, nsPoint& aRetPoint);
PRUint32 GetBatching() const {return mBatching; }
bool GetNotifyFrames() const { return mNotifyFrames; }
void SetDirty(bool aDirty=true){if (mBatching) mChangesDuringBatching = aDirty;}
// nsFrameSelection may get deleted when calling this,
// so remember to use nsCOMPtr when needed.
nsresult NotifySelectionListeners(SelectionType aType); // add parameters to say collapsed etc?
nsRefPtr<nsTypedSelection> mDomSelections[nsISelectionController::NUM_SELECTIONTYPES];
// Table selection support.
// Interfaces that let us get info based on cellmap locations
nsITableLayout* GetTableLayout(nsIContent *aTableContent) const;
nsITableCellLayout* GetCellLayout(nsIContent *aCellContent) const;
nsresult SelectBlockOfCells(nsIContent *aStartNode, nsIContent *aEndNode);
nsresult SelectRowOrColumn(nsIContent *aCellContent, PRUint32 aTarget);
nsresult UnselectCells(nsIContent *aTable,
PRInt32 aStartRowIndex, PRInt32 aStartColumnIndex,
PRInt32 aEndRowIndex, PRInt32 aEndColumnIndex,
bool aRemoveOutsideOfCellRange);
nsresult GetCellIndexes(nsIContent *aCell, PRInt32 &aRowIndex, PRInt32 &aColIndex);
// Get our first range, if its first selected node is a cell. If this does
// not return null, then the first node in the returned range is a cell
// (according to GetFirstCellNodeInRange).
nsIRange* GetFirstCellRange();
// Get our next range, if its first selected node is a cell. If this does
// not return null, then the first node in the returned range is a cell
// (according to GetFirstCellNodeInRange).
nsIRange* GetNextCellRange();
nsIContent* GetFirstCellNodeInRange(nsIRange *aRange) const;
// Returns non-null table if in same table, null otherwise
nsIContent* IsInSameTable(nsIContent *aContent1, nsIContent *aContent2) const;
// Might return null
nsIContent* GetParentTable(nsIContent *aCellNode) const;
nsresult CreateAndAddRange(nsINode *aParentNode, PRInt32 aOffset);
nsresult ClearNormalSelection();
nsCOMPtr<nsINode> mCellParent; //used to snap to table selection
nsCOMPtr<nsIContent> mStartSelectedCell;
nsCOMPtr<nsIContent> mEndSelectedCell;
nsCOMPtr<nsIContent> mAppendStartSelectedCell;
nsCOMPtr<nsIContent> mUnselectCellOnMouseUp;
PRInt32 mSelectingTableCellMode;
PRInt32 mSelectedCellIndex;
// maintain selection
nsCOMPtr<nsIRange> mMaintainRange;
nsSelectionAmount mMaintainedAmount;
//batching
PRInt32 mBatching;
nsIContent *mLimiter; //limit selection navigation to a child of this node.
nsIContent *mAncestorLimiter; // Limit selection navigation to a descendant of
// this node.
nsIPresShell *mShell;
PRInt16 mSelectionChangeReason; // reason for notifications of selection changing
PRInt16 mDisplaySelection; //for visual display purposes.
HINT mHint; //hint to tell if the selection is at the end of this line or beginning of next
#ifdef IBMBIDI
PRUint8 mCaretBidiLevel;
#endif
PRInt32 mDesiredX;
nsMouseEvent mDelayedMouseEvent;
bool mDelayedMouseEventValid;
bool mChangesDuringBatching;
bool mNotifyFrames;
bool mDragSelectingCells;
bool mMouseDownState; //for drag purposes
bool mMouseDoubleDownState; //has the doubleclick down happened
bool mDesiredXSet;
PRInt8 mCaretMovementStyle;
};
#endif /* nsFrameSelection_h___ */
|