Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Friends
nsTypedSelection Class Reference
Inheritance diagram for nsTypedSelection:
Inheritance graph
[legend]
Collaboration diagram for nsTypedSelection:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsTypedSelection ()
 nsTypedSelection (nsSelection *aList)
virtual ~nsTypedSelection ()
NS_DECL_ISUPPORTS
NS_DECL_NSISELECTION
NS_DECL_NSISELECTION2
NS_DECL_NSISELECTIONPRIVATE
nsresult 
GetPresContext (nsPresContext **aPresContext)
nsresult GetPresShell (nsIPresShell **aPresShell)
nsresult GetRootScrollableView (nsIScrollableView **aScrollableView)
nsresult GetFrameToScrolledViewOffsets (nsIScrollableView *aScrollableView, nsIFrame *aFrame, nscoord *aXOffset, nscoord *aYOffset)
nsresult GetPointFromOffset (nsIFrame *aFrame, PRInt32 aContentOffset, nsPoint *aPoint)
nsresult GetSelectionRegionRectAndScrollableView (SelectionRegion aRegion, nsRect *aRect, nsIScrollableView **aScrollableView)
nsresult ScrollRectIntoView (nsIScrollableView *aScrollableView, nsRect &aRect, PRIntn aVPercent, PRIntn aHPercent, PRBool aScrollParentViews)
nsresult PostScrollSelectionIntoViewEvent (SelectionRegion aRegion)
NS_IMETHOD ScrollIntoView (SelectionRegion aRegion=nsISelectionController::SELECTION_FOCUS_REGION, PRBool aIsSynchronous=PR_TRUE)
nsresult AddItem (nsIDOMRange *aRange)
nsresult RemoveItem (nsIDOMRange *aRange)
nsresult Clear (nsPresContext *aPresContext)
nsIDOMNodeFetchAnchorNode ()
PRInt32 FetchAnchorOffset ()
nsIDOMNodeFetchOriginalAnchorNode ()
PRInt32 FetchOriginalAnchorOffset ()
nsIDOMNodeFetchFocusNode ()
PRInt32 FetchFocusOffset ()
nsIDOMNodeFetchStartParent (nsIDOMRange *aRange)
PRInt32 FetchStartOffset (nsIDOMRange *aRange)
nsIDOMNodeFetchEndParent (nsIDOMRange *aRange)
PRInt32 FetchEndOffset (nsIDOMRange *aRange)
nsDirection GetDirection ()
void SetDirection (nsDirection aDir)
PRBool GetTrueDirection ()
void SetTrueDirection (PRBool aBool)
NS_IMETHOD CopyRangeToAnchorFocus (nsIDOMRange *aRange)
NS_IMETHOD GetPrimaryFrameForAnchorNode (nsIFrame **aResultFrame)
NS_IMETHOD GetPrimaryFrameForFocusNode (nsIFrame **aResultFrame, PRInt32 *aOffset)
NS_IMETHOD SetOriginalAnchorPoint (nsIDOMNode *aNode, PRInt32 aOffset)
NS_IMETHOD GetOriginalAnchorPoint (nsIDOMNode **aNode, PRInt32 *aOffset)
NS_IMETHOD LookUpSelection (nsIContent *aContent, PRInt32 aContentOffset, PRInt32 aContentLength, SelectionDetails **aReturnDetails, SelectionType aType, PRBool aSlowCheck)
NS_IMETHOD Repaint (nsPresContext *aPresContext)
nsresult StartAutoScrollTimer (nsPresContext *aPresContext, nsIView *aView, nsPoint &aPoint, PRUint32 aDelay)
nsresult StopAutoScrollTimer ()
nsresult DoAutoScrollView (nsPresContext *aPresContext, nsIView *aView, nsPoint &aPoint, PRBool aScrollParentViews)
nsresult ScrollPointIntoClipView (nsPresContext *aPresContext, nsIView *aView, nsPoint &aPoint, PRBool *aDidScroll)
nsresult ScrollPointIntoView (nsPresContext *aPresContext, nsIView *aView, nsPoint &aPoint, PRBool aScrollParentViews, PRBool *aDidScroll)
nsresult GetViewAncestorOffset (nsIView *aView, nsIView *aAncestorView, nscoord *aXOffset, nscoord *aYOffset)
SelectionType GetType ()
void SetType (SelectionType aType)
nsresult NotifySelectionListeners ()
void DetachFromPresentation ()
void GetRangesForInterval (in nsIDOMNode beginNode, in PRInt32 beginOffset, in nsIDOMNode endNode, in PRInt32 endOffset, in PRBool allowAdjacent, out PRUint32 resultCount,[retval, array, size_is(resultCount)] out nsIDOMRange results)
void GetRangesForIntervalCOMArray (in nsIDOMNode beginNode, in PRInt32 beginOffset, in nsIDOMNode endNode, in PRInt32 endOffset, in PRBool allowAdjacent, in RangeArray results)
nsIDOMRange getRangeAt (in long index)
 Returns the range at the specified index.
void collapse (in nsIDOMNode parentNode, in long offset)
 Collapses the selection to a single point, at the specified offset in the given DOM node.
void extend (in nsIDOMNode parentNode, in long offset)
 Extends the selection by moving the focus to the specified node and offset, preserving the anchor postion.
void collapseToStart ()
 Collapses the whole selection to a single point at the start of the current selection (irrespective of direction).
void collapseToEnd ()
 Collapses the whole selection to a single point at the end of the current selection (irrespective of direction).
boolean containsNode (in nsIDOMNode node, in boolean entirelyContained)
 The value of entirelyContained determines the detail of the search to determine if the selection contains the node.
void selectAllChildren (in nsIDOMNode parentNode)
 Adds all children of the specified node to the selection.
void addRange (in nsIDOMRange range)
 Adds a range to the current selection.
void removeRange (in nsIDOMRange range)
 Removes a range from the current selection.
void removeAllRanges ()
 Removes all ranges from the current selection.
void deleteFromDocument ()
 Deletes this selection from document the nodes belong to.
void selectionLanguageChange (in boolean langRTL)
 Modifies the cursor Bidi level after a change in keyboard direction.
wstring toString ()
 Returns the whole selection into a plain text string.
void startBatchChanges ()
void endBatchChanges ()
nsIEnumerator getEnumerator ()
wstring toStringWithFormat (in string formatType, in unsigned long flags, in PRInt32 wrapColumn)
void addSelectionListener (in nsISelectionListener newListener)
void removeSelectionListener (in nsISelectionListener listenerToRemove)
long getTableSelectionType (in nsIDOMRange range)
 Test if supplied range points to a single table element: Result is one of above constants.
void setPresShell (in nsIPresShell aPresShell)
void getCachedFrameOffset (in nsIFrame aFrame, in PRInt32 inOffset, in nsPointRef aPoint)
nsIFrameSelection getFrameSelection ()

Public Attributes

readonly attribute nsIDOMNode anchorNode
 The node representing one end of the selection.
readonly attribute long anchorOffset
 The offset within the (text) node where the selection begins.
readonly attribute nsIDOMNode focusNode
 The node with keyboard focus.
readonly attribute long focusOffset
 The offset within the (text) node where focus starts.
readonly attribute boolean isCollapsed
 Indicates if the selection is collapsed or not.
readonly attribute long rangeCount
 Returns the number of ranges in the selection.
const short ENDOFPRECEDINGLINE = 0
const short STARTOFNEXTLINE = 1
attribute boolean interlinePosition
const long TABLESELECTION_NONE = 0
const long TABLESELECTION_CELL = 1
const long TABLESELECTION_ROW = 2
const long TABLESELECTION_COLUMN = 3
const long TABLESELECTION_TABLE = 4
const long TABLESELECTION_ALLCELLS = 5
attribute boolean canCacheFrameOffset

Private Member Functions

void setAnchorFocusRange (PRInt32 aIndex)
NS_IMETHOD selectFrames (nsPresContext *aPresContext, nsIContentIterator *aInnerIter, nsIContent *aContent, nsIDOMRange *aRange, nsIPresShell *aPresShell, PRBool aFlags)
NS_IMETHOD selectFrames (nsPresContext *aPresContext, nsIDOMRange *aRange, PRBool aSelect)
nsresult getTableCellLocationFromRange (nsIDOMRange *aRange, PRInt32 *aSelectionType, PRInt32 *aRow, PRInt32 *aCol)
nsresult addTableCellRange (nsIDOMRange *aRange, PRBool *aDidAddRange)
nsresult FindInsertionPoint (const nsTArray< PRInt32 > *aRemappingArray, nsIDOMNode *aPointNode, PRInt32 aPointOffset, nsresult(*aComparator)(nsIDOMNode *, PRInt32, nsIDOMRange *, PRInt32 *), PRInt32 *aInsertionPoint)
nsresult MoveIndexToFirstMatch (PRInt32 *aIndex, nsIDOMNode *aNode, PRInt32 aOffset, const nsTArray< PRInt32 > *aArray, PRBool aUseBeginning)
nsresult MoveIndexToNextMismatch (PRInt32 *aIndex, nsIDOMNode *aNode, PRInt32 aOffset, const nsTArray< PRInt32 > *aRemappingArray, PRBool aUseBeginning)
PRBool FindRangeGivenPoint (nsIDOMNode *aBeginNode, PRInt32 aBeginOffset, nsIDOMNode *aEndNode, PRInt32 aEndOffset, PRInt32 aStartSearchingHere)

Private Attributes

nsTArray< RangeDatamRanges
nsTArray< PRInt32mRangeEndings
nsCOMPtr< nsIDOMRangemAnchorFocusRange
nsCOMPtr< nsIDOMRangemOriginalAnchorRange
nsDirection mDirection
PRBool mFixupState
nsSelectionmFrameSelection
nsWeakPtr mPresShellWeak
SelectionType mType
nsAutoScrollTimermAutoScrollTimer
nsCOMArray< nsISelectionListenermSelectionListeners
PRBool mTrueDirection
nsCOMPtr< nsIEventQueuemEventQueue
PRBool mScrollEventPosted
CachedOffsetForFramemCachedOffsetForFrame

Friends

class nsSelectionIterator
struct nsScrollSelectionIntoViewEvent

Detailed Description

Definition at line 197 of file nsSelection.cpp.


Constructor & Destructor Documentation

Definition at line 4395 of file nsSelection.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 4777 of file nsSelection.cpp.

{
  nsresult rv;
  if (!aItem)
    return NS_ERROR_NULL_POINTER;

  NS_ASSERTION(ValidateRanges(), "Ranges out of sync");

  // a common case is that we have no ranges yet
  if (mRanges.Length() == 0) {
    if (! mRanges.AppendElement(RangeData(aItem, 0)))
      return NS_ERROR_OUT_OF_MEMORY;
    if (! mRangeEndings.AppendElement(0)) {
      mRanges.Clear();
      return NS_ERROR_OUT_OF_MEMORY;
    }
    return NS_OK;
  }

  nsCOMPtr<nsIDOMNode> beginNode;
  PRInt32 beginOffset;
  rv = aItem->GetStartContainer(getter_AddRefs(beginNode));
  NS_ENSURE_SUCCESS(rv, rv);
  rv = aItem->GetStartOffset(&beginOffset);
  NS_ENSURE_SUCCESS(rv, rv);

  PRInt32 beginInsertionPoint;
  rv = FindInsertionPoint(nsnull, beginNode, beginOffset,
                          CompareToRangeStart, &beginInsertionPoint);
  NS_ENSURE_SUCCESS(rv, rv);

  // XXX Performance: 99% of the time, the beginning array and the ending array
  // will be the same because the ranges do not overlap. We could save a few
  // compares (which can be expensive) in this common case by special casing
  // this.

  nsCOMPtr<nsIDOMNode> endNode;
  PRInt32 endOffset;
  rv = aItem->GetEndContainer(getter_AddRefs(endNode));
  NS_ENSURE_SUCCESS(rv, rv);
  rv = aItem->GetEndOffset(&endOffset);
  NS_ENSURE_SUCCESS(rv, rv);

  // make sure that this range is not already in the selection
  if (FindRangeGivenPoint(beginNode, beginOffset, endNode, endOffset,
                          beginInsertionPoint)) {
    // silently succeed, this range is already in the selection
    return NS_OK;
  }

  PRInt32 endInsertionPoint;
  rv = FindInsertionPoint(&mRangeEndings, endNode, endOffset,
                          CompareToRangeEnd, &endInsertionPoint);
  NS_ENSURE_SUCCESS(rv, rv);

  // insert the range, being careful to revert everything on error to keep
  // consistency
  if (! mRanges.InsertElementAt(beginInsertionPoint,
        RangeData(aItem, endInsertionPoint))) {
    return NS_ERROR_OUT_OF_MEMORY;
  }
  if (! mRangeEndings.InsertElementAt(endInsertionPoint, beginInsertionPoint)) {
    mRanges.RemoveElementAt(beginInsertionPoint);
    return NS_ERROR_OUT_OF_MEMORY;
  }

  // adjust the end indices that point to the main list
  PRUint32 i;
  for (i = 0; i < mRangeEndings.Length(); i ++) {
    if (mRangeEndings[i] >= beginInsertionPoint)
      mRangeEndings[i] ++;
  }

  // the last loop updated the inserted index as well, so we need to put it
  // back (this saves a comparison in that loop)
  mRangeEndings[endInsertionPoint] = beginInsertionPoint;

  // adjust the begin/end indices
  for (i = endInsertionPoint + 1; i < mRangeEndings.Length(); i ++)
    mRanges[mRangeEndings[i]].mEndIndex = i;

  NS_ASSERTION(ValidateRanges(), "Ranges out of sync");
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsISelection::addRange ( in nsIDOMRange  range) [inherited]

Adds a range to the current selection.

nsresult nsTypedSelection::addTableCellRange ( nsIDOMRange aRange,
PRBool aDidAddRange 
) [private]

Definition at line 4002 of file nsSelection.cpp.

{
  if (!aDidAddRange)
    return NS_ERROR_NULL_POINTER;

  *aDidAddRange = PR_FALSE;

  if (!mFrameSelection)
    return NS_OK;

  if (!aRange)
    return NS_ERROR_NULL_POINTER;

  nsresult result;

  // Get if we are adding a cell selection and the row, col of cell if we are
  PRInt32 newRow, newCol, tableMode;
  result = getTableCellLocationFromRange(aRange, &tableMode, &newRow, &newCol);
  if (NS_FAILED(result)) return result;
  
  // If not adding a cell range, we are done here
  if (tableMode != nsISelectionPrivate::TABLESELECTION_CELL)
  {
    mFrameSelection->mSelectingTableCellMode = tableMode;
    // Don't fail if range isn't a selected cell, aDidAddRange tells caller if we didn't proceed
    return NS_OK;
  }
  
  // Set frame selection mode only if not already set to a table mode
  //  so we don't loose the select row and column flags (not detected by getTableCellLocation)
  if (mFrameSelection->mSelectingTableCellMode == TABLESELECTION_NONE)
    mFrameSelection->mSelectingTableCellMode = tableMode;

  return AddItem(aRange);
}

Here is the call graph for this function:

Definition at line 4909 of file nsSelection.cpp.

{
  setAnchorFocusRange(-1);

  for (PRInt32 i = 0; i < (PRInt32)mRanges.Length(); i ++)
    selectFrames(aPresContext, mRanges[i].mRange, 0);
  mRanges.Clear();
  mRangeEndings.Clear();

  // Reset direction so for more dependable table selection range handling
  SetDirection(eDirNext);

  // If this was an ATTENTION selection, change it back to normal now
  PRInt16 displayresult = nsISelectionController::SELECTION_OFF;
  mFrameSelection->GetDisplaySelection(&displayresult);
  if (displayresult == nsISelectionController::SELECTION_ATTENTION) {
    mFrameSelection->SetDisplaySelection(nsISelectionController::SELECTION_ON);
  }

  return NS_OK;
}

Here is the call graph for this function:

void nsISelection::collapse ( in nsIDOMNode  parentNode,
in long  offset 
) [inherited]

Collapses the selection to a single point, at the specified offset in the given DOM node.

When the selection is collapsed, and the content is focused and editable, the caret will blink there.

Parameters:
parentNodeThe given dom node where the selection will be set
offsetWhere in given dom node to place the selection (the offset into the given node)

Collapses the whole selection to a single point at the end of the current selection (irrespective of direction).

If content is focused and editable, the caret will blink there.

Collapses the whole selection to a single point at the start of the current selection (irrespective of direction).

If content is focused and editable, the caret will blink there.

boolean nsISelection::containsNode ( in nsIDOMNode  node,
in boolean  entirelyContained 
) [inherited]

The value of entirelyContained determines the detail of the search to determine if the selection contains the node.

If entirelyContained is set to PR_TRUE, t or false if

Parameters:
nodeThe node where the selection will be extended to
entirelyContainedWhether

Definition at line 6773 of file nsSelection.cpp.

{
  nsCOMPtr<nsIDOMNode> startNode;
  nsCOMPtr<nsIDOMNode> endNode;
  PRInt32 startOffset;
  PRInt32 endOffset;
  aRange->GetStartContainer(getter_AddRefs(startNode));
  aRange->GetEndContainer(getter_AddRefs(endNode));
  aRange->GetStartOffset(&startOffset);
  aRange->GetEndOffset(&endOffset);
  if (NS_FAILED(mAnchorFocusRange->SetStart(startNode,startOffset)))
  {
    if (NS_FAILED(mAnchorFocusRange->SetEnd(endNode,endOffset)))
      return NS_ERROR_FAILURE;//???
    if (NS_FAILED(mAnchorFocusRange->SetStart(startNode,startOffset)))
      return NS_ERROR_FAILURE;//???
  }
  else if (NS_FAILED(mAnchorFocusRange->SetEnd(endNode,endOffset)))
          return NS_ERROR_FAILURE;//???
  return NS_OK;
}

Here is the call graph for this function:

Deletes this selection from document the nodes belong to.

Definition at line 4400 of file nsSelection.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsTypedSelection::DoAutoScrollView ( nsPresContext aPresContext,
nsIView aView,
nsPoint aPoint,
PRBool  aScrollParentViews 
)

Definition at line 6085 of file nsSelection.cpp.

{
  if (!aPresContext || !aView)
    return NS_ERROR_NULL_POINTER;

  nsresult result;

  if (mAutoScrollTimer)
    result = mAutoScrollTimer->Stop();

  //
  // Calculate the global offset of the view.
  //

  nsPoint globalOffset;

  result = GetViewAncestorOffset(aView, nsnull, &globalOffset.x, &globalOffset.y);

  if (NS_FAILED(result))
    return result;

  //
  // Convert aPoint into global coordinates so we can get back
  // to the same point after all the parent views have scrolled.
  //

  nsPoint globalPoint = aPoint + globalOffset;

  //
  // Now scroll aPoint into view.
  //

  PRBool didScroll = PR_FALSE;

  result = ScrollPointIntoView(aPresContext, aView, aPoint, aScrollParentViews, &didScroll);

  if (NS_FAILED(result))
    return result;

  //
  // Start the AutoScroll timer if necessary.
  //

  if (didScroll && mAutoScrollTimer)
  {
    //
    // Map the globalPoint back into aView's coordinate system. We
    // have to get the globalOffsets again because aView's
    // window and it's parents may have changed their offsets.
    //
    result = GetViewAncestorOffset(aView, nsnull, &globalOffset.x, &globalOffset.y);

    if (NS_FAILED(result))
      return result;

    nsPoint svPoint = globalPoint - globalOffset;

    result = mAutoScrollTimer->Start(aPresContext, aView, svPoint);
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsISelection::extend ( in nsIDOMNode  parentNode,
in long  offset 
) [inherited]

Extends the selection by moving the focus to the specified node and offset, preserving the anchor postion.

The new selection end result will always be from the anchor to the new focus, regardless of direction.

Parameters:
parentNodeThe node where the selection will be extended to
offsetWhere in node to place the offset in the new focused node

Definition at line 4540 of file nsSelection.cpp.

{  //where did the selection begin
  nsCOMPtr<nsIDOMNode>returnval;
  GetAnchorNode(getter_AddRefs(returnval));//this queries
  return returnval;
}//at end it will release, no addreff was called

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4550 of file nsSelection.cpp.

{
  PRInt32 returnval;
  if (NS_SUCCEEDED(GetAnchorOffset(&returnval)))//this queries
    return returnval;
  return 0;
}

Here is the caller graph for this function:

Definition at line 4642 of file nsSelection.cpp.

{
  if (!aRange)
    return nsnull;
  PRInt32 returnval;
  if (NS_SUCCEEDED(aRange->GetEndOffset(&returnval)))
    return returnval;
  return 0;
}

Definition at line 4630 of file nsSelection.cpp.

{
  if (!aRange)
    return nsnull;
  nsCOMPtr<nsIDOMNode> returnval;
  aRange->GetEndContainer(getter_AddRefs(returnval));
  return returnval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4584 of file nsSelection.cpp.

{   //where is the carret
  nsCOMPtr<nsIDOMNode>returnval;
  GetFocusNode(getter_AddRefs(returnval));//this queries
  return returnval;
}//at end it will release, no addreff was called

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4594 of file nsSelection.cpp.

{
  PRInt32 returnval;
  if (NS_SUCCEEDED(GetFocusOffset(&returnval)))//this queries
    return returnval;
  return NS_OK;
}

Here is the caller graph for this function:

Definition at line 4561 of file nsSelection.cpp.

{
  nsCOMPtr<nsIDOMNode>returnval;
  PRInt32 unused;
  GetOriginalAnchorPoint(getter_AddRefs(returnval),  &unused);//this queries
  return returnval;
}

Here is the call graph for this function:

Definition at line 4572 of file nsSelection.cpp.

{
  nsCOMPtr<nsIDOMNode>unused;
  PRInt32 returnval;
  if (NS_SUCCEEDED(GetOriginalAnchorPoint(getter_AddRefs(unused), &returnval)))//this queries
    return returnval;
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 4617 of file nsSelection.cpp.

{
  if (!aRange)
    return nsnull;
  PRInt32 returnval;
  if (NS_SUCCEEDED(aRange->GetStartOffset(&returnval)))
    return returnval;
  return 0;
}

Definition at line 4605 of file nsSelection.cpp.

{
  if (!aRange)
    return nsnull;
  nsCOMPtr<nsIDOMNode> returnval;
  aRange->GetStartContainer(getter_AddRefs(returnval));
  return returnval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsTypedSelection::FindInsertionPoint ( const nsTArray< PRInt32 > *  aRemappingArray,
nsIDOMNode aPointNode,
PRInt32  aPointOffset,
nsresult(*)(nsIDOMNode *, PRInt32, nsIDOMRange *, PRInt32 *)  aComparator,
PRInt32 aInsertionPoint 
) [private]

Definition at line 4738 of file nsSelection.cpp.

{
  nsresult rv;
  NS_ASSERTION(!aRemappingArray || aRemappingArray->Length() == mRanges.Length(),
               "Remapping array must have the same entries as the range array");

  PRInt32 beginSearch = 0;
  PRInt32 endSearch = mRanges.Length(); // one beyond what to check
  while (endSearch - beginSearch > 0) {
    PRInt32 center = (endSearch - beginSearch) / 2 + beginSearch;

    nsIDOMRange* range;
    if (aRemappingArray)
      range = mRanges[(*aRemappingArray)[center]].mRange;
    else
      range = mRanges[center].mRange;

    PRInt32 cmp;
    rv = aComparator(aPointNode, aPointOffset, range, &cmp);
    NS_ENSURE_SUCCESS(rv, rv);

    if (cmp < 0) {        // point < cur
      endSearch = center;
    } else if (cmp > 0) { // point > cur
      beginSearch = center + 1;
    } else {              // found match, done
      beginSearch = center;
      break;
    }
  }
  *aInsertionPoint = beginSearch;
  return NS_OK;
}

Here is the caller graph for this function:

PRBool nsTypedSelection::FindRangeGivenPoint ( nsIDOMNode aBeginNode,
PRInt32  aBeginOffset,
nsIDOMNode aEndNode,
PRInt32  aEndOffset,
PRInt32  aStartSearchingHere 
) [private]

Definition at line 5232 of file nsSelection.cpp.

{
  PRInt32 i;
  NS_ASSERTION(aStartSearchingHere >= 0 && aStartSearchingHere <= (PRInt32)mRanges.Length(),
               "Input searching seed is not in range.");

  // search backwards for a begin match
  for (i = aStartSearchingHere; i >= 0 && i < (PRInt32)mRanges.Length(); i --) {
    if (RangeMatchesBeginPoint(mRanges[i].mRange, aBeginNode, aBeginOffset)) {
      if (RangeMatchesEndPoint(mRanges[i].mRange, aEndNode, aEndOffset))
        return PR_TRUE;
    } else {
      // done with matches going backwards
      break;
    }
  }

  // search forwards for a begin match
  for (i = aStartSearchingHere + 1; i < (PRInt32)mRanges.Length(); i ++) {
    if (RangeMatchesBeginPoint(mRanges[i].mRange, aBeginNode, aBeginOffset)) {
      if (RangeMatchesEndPoint(mRanges[i].mRange, aEndNode, aEndOffset))
        return PR_TRUE;
    } else {
      // done with matches going forwards
      break;
    }
  }

  // match not found
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsISelectionPrivate::getCachedFrameOffset ( in nsIFrame  aFrame,
in PRInt32  inOffset,
in nsPointRef  aPoint 
) [inherited]

Definition at line 241 of file nsSelection.cpp.

{return mDirection;}

Here is the caller graph for this function:

nsresult nsTypedSelection::GetFrameToScrolledViewOffsets ( nsIScrollableView aScrollableView,
nsIFrame aFrame,
nscoord aXOffset,
nscoord aYOffset 
)

Definition at line 7353 of file nsSelection.cpp.

{
  nsresult rv = NS_OK;
  if (!mFrameSelection)
    return NS_ERROR_FAILURE;//nothing to do

  if (!aScrollableView || !aFrame || !aX || !aY) {
    return NS_ERROR_NULL_POINTER;
  }

  *aX = 0;
  *aY = 0;

  nsIView*  scrolledView;
  nsPoint   offset;
  nsIView*  closestView;
          
  // Determine the offset from aFrame to the scrolled view. We do that by
  // getting the offset from its closest view and then walking up
  aScrollableView->GetScrolledView(scrolledView);
  nsIPresShell *shell = mFrameSelection->GetShell();

  if (!shell)
    return NS_ERROR_NULL_POINTER;

  aFrame->GetOffsetFromView(offset, &closestView);

  // XXX Deal with the case where there is a scrolled element, e.g., a
  // DIV in the middle...
  offset += closestView->GetOffsetTo(scrolledView);

  *aX = offset.x;
  *aY = offset.y;

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 6756 of file nsSelection.cpp.

{
  if (!aNode || !aOffset || !mOriginalAnchorRange)
    return NS_ERROR_NULL_POINTER;
  nsresult result;
  result = mOriginalAnchorRange->GetStartContainer(aNode);
  if (NS_FAILED(result))
    return result;
  result = mOriginalAnchorRange->GetStartOffset(aOffset);
  return result;
}

Here is the caller graph for this function:

nsresult nsTypedSelection::GetPointFromOffset ( nsIFrame aFrame,
PRInt32  aContentOffset,
nsPoint aPoint 
)

Definition at line 7391 of file nsSelection.cpp.

{
  nsresult rv = NS_OK;
  if (!mFrameSelection)
    return NS_ERROR_FAILURE;//nothing to do
  if (!aFrame || !aPoint)
    return NS_ERROR_NULL_POINTER;

  aPoint->x = 0;
  aPoint->y = 0;

  //
  // Retrieve the device context. We need one to create
  // a rendering context.
  //

  nsIPresShell *shell = mFrameSelection->GetShell();
  if (!shell)
    return NS_ERROR_NULL_POINTER;

  nsPresContext *presContext = shell->GetPresContext();
  if (!presContext)
    return NS_ERROR_NULL_POINTER;
  
  //
  // Now get the closest view with a widget so we can create
  // a rendering context.
  //

  nsIWidget* widget = nsnull;
  nsIView *closestView = nsnull;
  nsPoint offset(0, 0);

  rv = aFrame->GetOffsetFromView(offset, &closestView);

  while (!widget && closestView)
  {
    widget = closestView->GetWidget();

    if (!widget)
    {
      closestView = closestView->GetParent();
    }
  }

  if (!closestView)
    return NS_ERROR_FAILURE;

  //
  // Create a rendering context. This context is used by text frames
  // to calculate text widths so it can figure out where the point is
  // in the frame.
  //

  nsCOMPtr<nsIRenderingContext> rendContext;

  rv = presContext->DeviceContext()->
    CreateRenderingContext(closestView, *getter_AddRefs(rendContext));
  
  if (NS_FAILED(rv))
    return rv;

  if (!rendContext)
    return NS_ERROR_NULL_POINTER;

  //
  // Now get the point and return!
  //

  rv = aFrame->GetPointFromOffset(presContext, rendContext, aContentOffset, aPoint);

  return rv;
}

Here is the call graph for this function:

Definition at line 7268 of file nsSelection.cpp.

{
  if (!mFrameSelection)
    return NS_ERROR_FAILURE;//nothing to do
  nsIPresShell *shell = mFrameSelection->GetShell();

  if (!shell)
    return NS_ERROR_NULL_POINTER;

  NS_IF_ADDREF(*aPresContext = shell->GetPresContext());
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 7282 of file nsSelection.cpp.

{
  if (mPresShellWeak)
  {
    nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShellWeak);
    if (presShell)
      NS_ADDREF(*aPresShell = presShell);
    return NS_OK;
  }
  nsresult rv = NS_OK;
  if (!mFrameSelection)
    return NS_ERROR_FAILURE;//nothing to do

  nsIPresShell *shell = mFrameSelection->GetShell();

  mPresShellWeak = do_GetWeakReference(shell);    // the presshell owns us, so no addref
  if (mPresShellWeak)
    NS_ADDREF(*aPresShell = shell);
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 5317 of file nsSelection.cpp.

{
  if (!aReturnFrame)
    return NS_ERROR_NULL_POINTER;
  
  PRInt32 frameOffset = 0;
  *aReturnFrame = 0;
  nsCOMPtr<nsIContent> content = do_QueryInterface(FetchAnchorNode());
  if (content && mFrameSelection)
  {
    nsIFrameSelection::HINT hint;
    mFrameSelection->GetHint(&hint);
    return mFrameSelection->GetFrameForNodeOffset(content, FetchAnchorOffset(),hint,aReturnFrame, &frameOffset);
  }
  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Definition at line 5335 of file nsSelection.cpp.

{
  if (!aReturnFrame)
    return NS_ERROR_NULL_POINTER;
  
  nsCOMPtr<nsIContent> content = do_QueryInterface(FetchFocusNode());
  if (!content || !mFrameSelection)
    return NS_ERROR_FAILURE;
  
  nsIPresShell *presShell = mFrameSelection->GetShell();

  nsCOMPtr<nsICaret> caret;
  nsresult result = presShell->GetCaret(getter_AddRefs(caret));
  if (NS_FAILED(result) || !caret)
    return NS_ERROR_FAILURE;

  PRInt32 frameOffset = 0;
  *aReturnFrame = 0;
  if (!aOffsetUsed)
    aOffsetUsed = &frameOffset;

  nsIFrameSelection::HINT hint;
  mFrameSelection->GetHint(&hint);
  
  PRUint8 caretBidiLevel;
  presShell->GetCaretBidiLevel(&caretBidiLevel);

  return caret->GetCaretFrameForNodeOffset(content, FetchFocusOffset(), hint, caretBidiLevel,
                                           aReturnFrame, aOffsetUsed);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIDOMRange nsISelection::getRangeAt ( in long  index) [inherited]

Returns the range at the specified index.

void nsISelection2::GetRangesForInterval ( in nsIDOMNode  beginNode,
in PRInt32  beginOffset,
in nsIDOMNode  endNode,
in PRInt32  endOffset,
in PRBool  allowAdjacent,
out PRUint32  resultCount,
[retval, array, size_is(resultCount)] out nsIDOMRange  results 
) [inherited]
void nsISelection2::GetRangesForIntervalCOMArray ( in nsIDOMNode  beginNode,
in PRInt32  beginOffset,
in nsIDOMNode  endNode,
in PRInt32  endOffset,
in PRBool  allowAdjacent,
in RangeArray  results 
) [inherited]

Here is the caller graph for this function:

Definition at line 7304 of file nsSelection.cpp.

{
  //
  // NOTE: This method returns a NON-AddRef'd pointer
  //       to the scrollable view!
  //
  NS_ENSURE_ARG_POINTER(aScrollableView);

  if (!mFrameSelection)
    return NS_ERROR_FAILURE;//nothing to do
  nsresult rv;
  nsIScrollableView *scrollView;
  rv = mFrameSelection->GetScrollableView(&scrollView);
  if ( NS_FAILED(rv))
    return rv;

  if (!scrollView)
  {

    nsCOMPtr<nsIPresShell> presShell;

    rv = GetPresShell(getter_AddRefs(presShell));

    if (NS_FAILED(rv))
      return rv;

    if (!presShell)
      return NS_ERROR_NULL_POINTER;

    nsIViewManager* viewManager = presShell->GetViewManager();

    if (!viewManager)
      return NS_ERROR_NULL_POINTER;

    //
    // nsIViewManager::GetRootScrollableView() does not
    // AddRef the pointer it returns.
    //
    return viewManager->GetRootScrollableView(aScrollableView);
  }
  else //SCROLLVIEW_FROM_FRAME
  {
    *aScrollableView = scrollView;
  }

  return rv;
}

Here is the call graph for this function:

Definition at line 7466 of file nsSelection.cpp.

{
  nsresult result = NS_OK;
  if (!mFrameSelection)
    return NS_ERROR_FAILURE;//nothing to do

  if (!aRect || !aScrollableView)
    return NS_ERROR_NULL_POINTER;

  // Init aRect:

  aRect->x = 0;
  aRect->y = 0;
  aRect->width  = 0;
  aRect->height = 0;

  *aScrollableView = 0;

  nsIDOMNode *node       = 0;
  PRInt32     nodeOffset = 0;
  PRBool      isEndNode  = PR_TRUE;
  nsIFrame   *frame      = 0;

  switch (aRegion)
  {
  case nsISelectionController::SELECTION_ANCHOR_REGION:
    node       = FetchAnchorNode();
    nodeOffset = FetchAnchorOffset();
    isEndNode  = GetDirection() == eDirPrevious;
    break;
  case nsISelectionController::SELECTION_FOCUS_REGION:
    node       = FetchFocusNode();
    nodeOffset = FetchFocusOffset();
    isEndNode  = GetDirection() == eDirNext;
    break;
  default:
    return NS_ERROR_FAILURE;
  }

  if (!node)
    return NS_ERROR_NULL_POINTER;

  nsCOMPtr<nsIContent> content = do_QueryInterface(node);
  PRInt32 frameOffset = 0;

  if (content)
  {
    nsIFrameSelection::HINT hint;
    mFrameSelection->GetHint(&hint);
    result = mFrameSelection->GetFrameForNodeOffset(content, nodeOffset, hint, &frame, &frameOffset);
  }
  else
    result = NS_ERROR_FAILURE;

  if(NS_FAILED(result))
    return result;

  if (!frame)
    return NS_ERROR_NULL_POINTER;

  //
  // Get the frame's scrollable view.
  //

  nsCOMPtr<nsPresContext> presContext;

  result = GetPresContext(getter_AddRefs(presContext));

  if (NS_FAILED(result))
    return result;

  if (!presContext)
    return NS_ERROR_FAILURE;


  nsIFrame *parentWithView = frame->GetAncestorWithView();

  if (!parentWithView)
    return NS_ERROR_FAILURE;

  nsIView* view = parentWithView->GetView();

  *aScrollableView =
    nsLayoutUtils::GetNearestScrollingView(view, nsLayoutUtils::eEither);

  if (!*aScrollableView)
    return NS_OK;

  //
  // Figure out what node type we have, then get the
  // appropriate rect for it's nodeOffset.
  //

  PRUint16 nodeType = nsIDOMNode::ELEMENT_NODE;

  result = node->GetNodeType(&nodeType);

  if (NS_FAILED(result))
    return NS_ERROR_NULL_POINTER;

  if (nodeType == nsIDOMNode::TEXT_NODE)
  {
    nsIFrame *childFrame = 0;
    frameOffset  = 0;

    result = frame->GetChildFrameContainingOffset(nodeOffset, mFrameSelection->mHint, &frameOffset, &childFrame);

    if (NS_FAILED(result))
      return result;

    if (!childFrame)
      return NS_ERROR_NULL_POINTER;

    frame = childFrame;

    //
    // Get the x coordinate of the offset into the text frame.
    // The x coordinate will be relative to the frame's origin,
    // so we'll have to translate it into the root view's coordinate
    // system.
    //
    nsPoint pt;
    result = GetCachedFrameOffset(frame, nodeOffset, pt);

    if (NS_FAILED(result))
      return result;
    
    //
    // Get the frame's rect.
    //
    *aRect = frame->GetRect();

    //
    // Translate the frame's rect into root view coordinates.
    //
    result = GetFrameToScrolledViewOffsets(*aScrollableView, frame, &aRect->x, &aRect->y);

    if (NS_FAILED(result))
      return result;

    //
    // Now add the offset's x coordinate.
    //
    aRect->x += pt.x;

    //
    // Adjust the width of the rect to account for any necessary
    // padding!
    //

    nsRect clipRect = (*aScrollableView)->View()->GetBounds();

    result = (*aScrollableView)->GetScrollPosition(clipRect.x, clipRect.y);

    if (NS_FAILED(result))
      return result;

    //
    // If the point we are interested is outside the clip
    // region, we will scroll it into view with a padding
    // equal to a quarter of the clip's width.
    //

    PRInt32 pad = clipRect.width >> 2;

    if (pad <= 0)
      pad = 3; // Arbitrary

    if (aRect->x >= clipRect.XMost())
      aRect->width = pad;
    else if (aRect->x <= clipRect.x)
    {
      aRect->x -= pad;
      aRect->width = pad;
    }
    else
      aRect->width = 60; // Arbitrary

    //
    // Clip the x dimensions of aRect so that they are
    // completely within the bounds of the scrolledView.
    // This helps avoid unnecessary scrolling of parent
    // scrolled views.
    //
    // Note that aRect is in the coordinate system
    // of the scrolledView, so there is no need to take
    // into account scrolledView's x and y position.
    // We can just assume that (0,0) corresponds to the
    // upper left corner, and (svRect.width, svRect.height)
    // the lower right corner of the scrolledView.
    //

    nsIView* scrolledView = 0;

    result = (*aScrollableView)->GetScrolledView(scrolledView);

    if (NS_FAILED(result))
      return result;

    nsRect svRect = scrolledView->GetBounds();

    if (aRect->x < 0)
      aRect->x = 0;
    else if (aRect->x >= svRect.width)
      aRect->x = svRect.width - 1;

    if (aRect->XMost() > svRect.width)
      aRect->width = svRect.width - aRect->x;
  }
  else
  {
    //
    // Must be a non-text frame, just scroll the frame
    // into view.
    //
    *aRect = frame->GetRect();

    result = GetFrameToScrolledViewOffsets(*aScrollableView, frame, &aRect->x, &aRect->y);
  }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsTypedSelection::getTableCellLocationFromRange ( nsIDOMRange aRange,
PRInt32 aSelectionType,
PRInt32 aRow,
PRInt32 aCol 
) [private]

Definition at line 3951 of file nsSelection.cpp.

{
  if (!aRange || !aSelectionType || !aRow || !aCol)
    return NS_ERROR_NULL_POINTER;

  *aSelectionType = nsISelectionPrivate::TABLESELECTION_NONE;
  *aRow = 0;
  *aCol = 0;

  // Must have access to frame selection to get cell info
  if (!mFrameSelection) return NS_OK;

  nsresult result = GetTableSelectionType(aRange, aSelectionType);
  if (NS_FAILED(result)) return result;
  
  // Don't fail if range does not point to a single table cell,
  //  let aSelectionType tell user if we don't have a cell
  if (*aSelectionType  != nsISelectionPrivate::TABLESELECTION_CELL)
    return NS_OK;

  // Get the child content (the cell) pointed to by starting node of range
  // We do minimal checking since GetTableSelectionType assures
  //   us that this really is a table cell
  nsCOMPtr<nsIDOMNode> startNode;
  result = aRange->GetStartContainer(getter_AddRefs(startNode));
  if (NS_FAILED(result))
    return result;

  nsCOMPtr<nsIContent> content(do_QueryInterface(startNode));
  if (!content)
    return NS_ERROR_FAILURE;
  PRInt32 startOffset;
  result = aRange->GetStartOffset(&startOffset);
  if (NS_FAILED(result))
    return result;

  nsIContent *child = content->GetChildAt(startOffset);
  if (!child)
    return NS_ERROR_FAILURE;

  //Note: This is a non-ref-counted pointer to the frame
  nsITableCellLayout *cellLayout = mFrameSelection->GetCellLayout(child);
  if (NS_FAILED(result))
    return result;
  if (!cellLayout)
    return NS_ERROR_FAILURE;

  return cellLayout->GetCellIndexes(*aRow, *aCol);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Test if supplied range points to a single table element: Result is one of above constants.

"None" means a table element isn't selected.

Definition at line 243 of file nsSelection.cpp.

{return mTrueDirection;}

Definition at line 264 of file nsSelection.cpp.

{return mType;}
nsresult nsTypedSelection::GetViewAncestorOffset ( nsIView aView,
nsIView aAncestorView,
nscoord aXOffset,
nscoord aYOffset 
)

Definition at line 5794 of file nsSelection.cpp.

{
  // Note: A NULL aAncestorView pointer means that the caller wants
  //       the view's global offset.

  if (!aView || !aXOffset || !aYOffset)
    return NS_ERROR_FAILURE;

  nsPoint offset = aView->GetOffsetTo(aAncestorView);

  *aXOffset = offset.x;
  *aYOffset = offset.y;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsTypedSelection::LookUpSelection ( nsIContent aContent,
PRInt32  aContentOffset,
PRInt32  aContentLength,
SelectionDetails **  aReturnDetails,
SelectionType  aType,
PRBool  aSlowCheck 
)

Definition at line 5575 of file nsSelection.cpp.

{
  nsresult rv;
  if (! aContent || ! aReturnDetails)
    return NS_ERROR_NULL_POINTER;

  // it is common to have no ranges, to optimize that
  if (mRanges.Length() == 0)
    return NS_OK;

  nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aContent, &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMArray<nsIDOMRange> overlappingRanges;
  rv = GetRangesForIntervalCOMArray(node, aContentOffset,
                                    node, aContentOffset + aContentLength,
                                    PR_FALSE,
                                    &overlappingRanges);
  NS_ENSURE_SUCCESS(rv, rv);
  if (overlappingRanges.Count() == 0)
    return NS_OK;

  for (PRInt32 i = 0; i < overlappingRanges.Count(); i ++) {
    nsCOMPtr<nsIDOMNode> startNode, endNode;
    PRInt32 startOffset, endOffset;
    nsIDOMRange* range = overlappingRanges[i];
    range->GetStartContainer(getter_AddRefs(startNode));
    range->GetStartOffset(&startOffset);
    range->GetEndContainer(getter_AddRefs(endNode));
    range->GetEndOffset(&endOffset);

    PRInt32 start = -1, end = -1;
    if (startNode == node && endNode == node) {
      if (startOffset < (aContentOffset + aContentLength)  &&
          endOffset > aContentOffset) {
        // this range is totally inside the requested content range
        start = PR_MAX(0, startOffset - aContentOffset);
        end = PR_MIN(aContentLength, endOffset - aContentOffset);
      }
      // otherwise, range is inside the requested node, but does not intersect
      // the requested content range, so ignore it
    } else if (startNode == node) {
      if (startOffset < (aContentOffset + aContentLength)) {
        // the beginning of the range is inside the requested node, but the
        // end is outside, select everything from there to the end
        start = PR_MAX(0, startOffset - aContentOffset);
        end = aContentLength;
      }
    } else if (endNode == node) {
      if (endOffset > aContentOffset) {
        // the end of the range is inside the requested node, but the beginning
        // is outside, select everything from the beginning to there
        start = 0;
        end = PR_MIN(aContentLength, endOffset - aContentOffset);
      }
    } else {
      // this range does not begin or end in the requested node, but since
      // GetRangesForInterval returned this range, we know it overlaps.
      // Therefore, this node is enclosed in the range, and we select all
      // of it.
      start = 0;
      end = aContentLength;
    }
    if (start < 0)
      continue; // the ranges do not overlap the input range

    SelectionDetails* details = new SelectionDetails;
    if (! details)
      return NS_ERROR_OUT_OF_MEMORY;

    details->mNext = *aReturnDetails;
    details->mStart = start;
    details->mEnd = end;
    details->mType = aType;
    *aReturnDetails = details;
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsTypedSelection::MoveIndexToFirstMatch ( PRInt32 aIndex,
nsIDOMNode aNode,
PRInt32  aOffset,
const nsTArray< PRInt32 > *  aArray,
PRBool  aUseBeginning 
) [private]

Definition at line 4953 of file nsSelection.cpp.

{
  nsresult rv;
  nsCOMPtr<nsIDOMNode> curNode;
  PRInt32 curOffset;
  while (*aIndex > 0) {
    nsIDOMRange* range;
    if (aRemappingArray)
      range = mRanges[(*aRemappingArray)[(*aIndex) - 1]].mRange;
    else
      range = mRanges[(*aIndex) - 1].mRange;

    if (aUseBeginning) {
      rv = range->GetStartContainer(getter_AddRefs(curNode));
      NS_ENSURE_SUCCESS(rv, rv);
      rv = range->GetStartOffset(&curOffset);
      NS_ENSURE_SUCCESS(rv, rv);
    } else {
      rv = range->GetEndContainer(getter_AddRefs(curNode));
      NS_ENSURE_SUCCESS(rv, rv);
      rv = range->GetEndOffset(&curOffset);
      NS_ENSURE_SUCCESS(rv, rv);
    }

    if (curNode != aNode)
      break; // not a match
    if (curOffset != aOffset)
      break; // not a match

    // the previous node matches, go back one
    (*aIndex) --;
  }
  return NS_OK;
}

Here is the call graph for this function:

nsresult nsTypedSelection::MoveIndexToNextMismatch ( PRInt32 aIndex,
nsIDOMNode aNode,
PRInt32  aOffset,
const nsTArray< PRInt32 > *  aRemappingArray,
PRBool  aUseBeginning 
) [private]

Definition at line 5015 of file nsSelection.cpp.

{
  nsresult rv;
  nsCOMPtr<nsIDOMNode> curNode;
  PRInt32 curOffset;
  while (*aIndex < (PRInt32)mRanges.Length()) {
    nsIDOMRange* range;
    if (aRemappingArray)
      range = mRanges[(*aRemappingArray)[*aIndex]].mRange;
    else
      range = mRanges[*aIndex].mRange;

    if (aUseBeginning) {
      rv = range->GetStartContainer(getter_AddRefs(curNode));
      NS_ENSURE_SUCCESS(rv, rv);
      rv = range->GetStartOffset(&curOffset);
      NS_ENSURE_SUCCESS(rv, rv);
    } else {
      rv = range->GetEndContainer(getter_AddRefs(curNode));
      NS_ENSURE_SUCCESS(rv, rv);
      rv = range->GetEndOffset(&curOffset);
      NS_ENSURE_SUCCESS(rv, rv);
    }

    if (curNode != aNode)
      break; // mismatch
    if (curOffset != aOffset)
      break; // mismatch

    // this node matches, go to the next one
    (*aIndex) ++;
  }
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 7989 of file nsSelection.cpp.

{
  if (!mFrameSelection)
    return NS_OK;//nothing to do
 
  if (mFrameSelection->GetBatching()){
    mFrameSelection->SetDirty();
    return NS_OK;
  }
  PRInt32 cnt = mSelectionListeners.Count();
  nsCOMArray<nsISelectionListener> selectionListeners(mSelectionListeners);
  
  nsCOMPtr<nsIDOMDocument> domdoc;
  nsCOMPtr<nsIPresShell> shell;
  nsresult rv = GetPresShell(getter_AddRefs(shell));
  if (NS_SUCCEEDED(rv) && shell)
    domdoc = do_QueryInterface(shell->GetDocument());
  short reason = mFrameSelection->PopReason();
  for (PRInt32 i = 0; i < cnt; i++)
  {
    nsISelectionListener* thisListener = selectionListeners[i];
    if (thisListener)
      thisListener->NotifySelectionChanged(domdoc, this, reason);
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 7874 of file nsSelection.cpp.

{
  static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);

  if (!mEventQueue) {
    nsresult rv;

    // Cache the event queue of the current UI thread
    nsCOMPtr<nsIEventQueueService> eventService = do_GetService(kEventQueueServiceCID, &rv);
    if (NS_SUCCEEDED(rv) && (nsnull != eventService)) {  // XXX this implies that the UI is the current thread.
      rv = eventService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(mEventQueue));
    }
  }

  if (mEventQueue) {
    if (mScrollEventPosted) {
      // We've already posted an event, revoke it and
      // place a new one at the end of the queue to make
      // sure that any new pending reflow events are processed
      // before we scroll. This will insure that we scroll
      // to the correct place on screen.

      mEventQueue->RevokeEvents(this);
      mScrollEventPosted = PR_FALSE;
    }

    nsScrollSelectionIntoViewEvent *ev = new nsScrollSelectionIntoViewEvent(this, aRegion);
    if (ev) {
      mEventQueue->PostEvent(ev);
      mScrollEventPosted = PR_TRUE;
      return NS_OK;
    }
  }

  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Removes all ranges from the current selection.

Definition at line 4863 of file nsSelection.cpp.

{
  if (!aItem)
    return NS_ERROR_NULL_POINTER;
  NS_ASSERTION(ValidateRanges(), "Ranges out of sync");

  // Find the range's index & remove it. We could use FindInsertionPoint to
  // get O(log n) time, but that requires many expensive DOM comparisons.
  // For even several thousand items, this is probably faster because the
  // comparisons are so fast.
  PRInt32 idx = -1;
  PRUint32 i;
  for (i = 0; i < mRanges.Length(); i ++) {
    if (mRanges[i].mRange == aItem) {
      idx = (PRInt32)i;
      break;
    }
  }
  if (idx < 0)
    return NS_ERROR_INVALID_ARG;
  mRanges.RemoveElementAt(idx);

  // need to update the range ending list to reflect the removed item
  PRInt32 endingIndex = -1;
  for (i = 0; i < mRangeEndings.Length(); i ++) {
    if (mRangeEndings[i] == idx)
      endingIndex = i;
    if (mRangeEndings[i] > idx)
      mRangeEndings[i] --;
  }
  NS_ASSERTION(endingIndex >= 0 && endingIndex < (PRInt32)mRangeEndings.Length(),
               "Index not found in ending list");

  // remove from the sorted lists
  mRangeEndings.RemoveElementAt(endingIndex);

  // adjust indices of the RangeData structures
  for (i = endingIndex; i < mRangeEndings.Length(); i ++)
    mRanges[mRangeEndings[i]].mEndIndex = i;

  NS_ASSERTION(ValidateRanges(), "Ranges out of sync");
  return NS_OK;
}

Here is the call graph for this function:

void nsISelection::removeRange ( in nsIDOMRange  range) [inherited]

Removes a range from the current selection.

Definition at line 5658 of file nsSelection.cpp.

{
  PRInt32 arrCount = (PRInt32)mRanges.Length();

  if (arrCount < 1)
    return NS_OK;

  PRInt32 i;
  nsIDOMRange* range;
  
  for (i = 0; i < arrCount; i++)
  {
    range = mRanges[i].mRange;

    if (!range)
      return NS_ERROR_UNEXPECTED;

    nsresult rv = selectFrames(aPresContext, range, PR_TRUE);

    if (NS_FAILED(rv)) {
      return rv;
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 7912 of file nsSelection.cpp.

{
  nsresult result;
  if (!mFrameSelection)
    return NS_OK;//nothing to do

  if (mFrameSelection->GetBatching())
    return NS_OK;

  if (!aIsSynchronous)
    return PostScrollSelectionIntoViewEvent(aRegion);

  //
  // Shut the caret off before scrolling to avoid
  // leaving caret turds on the screen!
  //
  nsCOMPtr<nsIPresShell> presShell;
  result = GetPresShell(getter_AddRefs(presShell));
  if (NS_FAILED(result) || !presShell)
    return result;
  nsCOMPtr<nsICaret> caret;
  presShell->GetCaret(getter_AddRefs(caret));
  if (caret)
  {
    StCaretHider  caretHider(caret);      // stack-based class hides and shows the caret

    // We are going to scroll to a character offset within a frame by
    // using APIs on the scrollable view directly. So we need to
    // flush out pending reflows to make sure that frames are up-to-date.
    // We crash otherwise - bug 252970#c97
    presShell->FlushPendingNotifications(Flush_OnlyReflow);

    //
    // Scroll the selection region into view.
    //

    nsRect rect;
    nsIScrollableView *scrollableView = 0;

    result = GetSelectionRegionRectAndScrollableView(aRegion, &rect, &scrollableView);

    if (NS_FAILED(result))
      return result;

    //
    // It's ok if we don't have a scrollable view, just return early.
    //
    if (!scrollableView)
      return NS_OK;

    result = ScrollRectIntoView(scrollableView, rect, NS_PRESSHELL_SCROLL_ANYWHERE, NS_PRESSHELL_SCROLL_ANYWHERE, PR_TRUE);
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsTypedSelection::ScrollPointIntoClipView ( nsPresContext aPresContext,
nsIView aView,
nsPoint aPoint,
PRBool aDidScroll 
)

Definition at line 5811 of file nsSelection.cpp.

{
  nsresult result;

  if (!aPresContext || !aView || !aDidScroll)
    return NS_ERROR_NULL_POINTER;

  *aDidScroll = PR_FALSE;

  //
  // Get aView's scrollable view.
  //

  nsIScrollableView *scrollableView =
    nsLayoutUtils::GetNearestScrollingView(aView, nsLayoutUtils::eEither);

  if (!scrollableView)
    return NS_OK; // Nothing to do!

  //
  // Get the view that is being scrolled.
  //

  nsIView *scrolledView = 0;

  result = scrollableView->GetScrolledView(scrolledView);
  
  //
  // Now walk up aView's hierarchy, this time keeping track of
  // the view offsets until you hit the scrolledView.
  //

  nsPoint viewOffset(0,0);

  result = GetViewAncestorOffset(aView, scrolledView, &viewOffset.x, &viewOffset.y);

  if (NS_FAILED(result))
    return result;

  //
  // See if aPoint is outside the clip view's boundaries.
  // If it is, scroll the view till it is inside the visible area!
  //

  nsRect bounds = scrollableView->View()->GetBounds();

  result = scrollableView->GetScrollPosition(bounds.x,bounds.y);

  if (NS_FAILED(result))
    return result;

  //
  // Calculate the amount we would have to scroll in
  // the vertical and horizontal directions to get the point
  // within the clip area.
  //

  nscoord dx = 0, dy = 0;

  nsPresContext::ScrollbarStyles ss =
    nsLayoutUtils::ScrollbarStylesOfView(scrollableView);

  if (ss.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN) {
    nscoord e = aPoint.x + viewOffset.x;
  
    nscoord x1 = bounds.x;
    nscoord x2 = bounds.x + bounds.width;

    if (e < x1)
      dx = e - x1;
    else if (e > x2)
      dx = e - x2;
  }

  if (ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN) {
    nscoord e = aPoint.y + viewOffset.y;

    nscoord y1 = bounds.y;
    nscoord y2 = bounds.y + bounds.height;

    if (e < y1)
      dy = e - y1;
    else if (e > y2)
      dy = e - y2;
  }

  //
  // Now clip the scroll amounts so that we don't scroll
  // beyond the ends of the document.
  //

  nscoord scrollX = 0, scrollY = 0;
  nscoord docWidth = 0, docHeight = 0;

  result = scrollableView->GetScrollPosition(scrollX, scrollY);

  if (NS_SUCCEEDED(result))
    result = scrollableView->GetContainerSize(&docWidth, &docHeight);

  if (NS_SUCCEEDED(result))
  {
    if (dx < 0 && scrollX == 0)
      dx = 0;
    else if (dx > 0)
    {
      nscoord x1 = scrollX + dx + bounds.width;

      if (x1 > docWidth)
        dx -= x1 - docWidth;
    }


    if (dy < 0 && scrollY == 0)
      dy = 0;
    else if (dy > 0)
    {
      nscoord y1 = scrollY + dy + bounds.height;

      if (y1 > docHeight)
        dy -= y1 - docHeight;
    }

    //
    // Now scroll the view if necessary.
    //

    if (dx != 0 || dy != 0)
    {
      // Make sure latest bits are available before we scroll them.
      aPresContext->GetViewManager()->Composite();

      // Now scroll the view!

      result = scrollableView->ScrollTo(scrollX + dx, scrollY + dy, NS_VMREFRESH_NO_SYNC);

      if (NS_FAILED(result))
        return result;

      nsPoint newPos;

      result = scrollableView->GetScrollPosition(newPos.x, newPos.y);

      if (NS_FAILED(result))
        return result;

      *aDidScroll = (bounds.x != newPos.x || bounds.y != newPos.y);
    }
  }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsTypedSelection::ScrollPointIntoView ( nsPresContext aPresContext,
nsIView aView,
nsPoint aPoint,
PRBool  aScrollParentViews,
PRBool aDidScroll 
)

Definition at line 5964 of file nsSelection.cpp.

{
  if (!aPresContext || !aView || !aDidScroll)
    return NS_ERROR_NULL_POINTER;

  nsresult result;

  *aDidScroll = PR_FALSE;

  //
  // Calculate the global offset of the view.
  //

  nsPoint globalOffset;

  result = GetViewAncestorOffset(aView, nsnull, &globalOffset.x, &globalOffset.y);

  if (NS_FAILED(result))
    return result;

  //
  // Convert aPoint into global coordinates so it is easier to map
  // into other views.
  //

  nsPoint globalPoint = aPoint + globalOffset;

  //
  // Scroll the point into the visible rect of the closest
  // scrollable view.
  //
  result = ScrollPointIntoClipView(aPresContext, aView, aPoint, aDidScroll);

  if (NS_FAILED(result))
    return result;

  //
  // Now scroll the parent scrollable views.
  //

  if (aScrollParentViews)
  {
    //
    // Find aView's parent scrollable view.
    //

    nsIScrollableView *scrollableView =
      nsLayoutUtils::GetNearestScrollingView(aView, nsLayoutUtils::eEither);

    if (scrollableView)
    {
      //
      // Convert scrollableView to nsIView.
      //

      nsIView *scrolledView = 0;
      nsIView *view = scrollableView->View();

      if (view)
      {
        //
        // Now get the scrollableView's parent, then search for it's
        // closest scrollable view.
        //

        view = view->GetParent();

        while (view)
        {
          scrollableView =
            nsLayoutUtils::GetNearestScrollingView(view,
                                                   nsLayoutUtils::eEither);

          if (!scrollableView)
            break;

          scrolledView = 0;
          result = scrollableView->GetScrolledView(scrolledView);
          
          if (NS_FAILED(result))
            return result;

          //
          // Map the global point into this scrolledView's coordinate space.
          //

          result = GetViewAncestorOffset(scrolledView, nsnull, &globalOffset.x, &globalOffset.y);

          if (NS_FAILED(result))
            return result;

          nsPoint newPoint = globalPoint - globalOffset;

          //
          // Scroll the point into the visible rect of the scrolled view.
          //

          PRBool parentDidScroll = PR_FALSE;

          result = ScrollPointIntoClipView(aPresContext, scrolledView, newPoint, &parentDidScroll);

          if (NS_FAILED(result))
            return result;

          *aDidScroll = *aDidScroll || parentDidScroll;

          //
          // Now get the parent of this scrollable view so we
          // can scroll the next parent view.
          //

          view = scrollableView->View()->GetParent();
        }
      }
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsTypedSelection::ScrollRectIntoView ( nsIScrollableView aScrollableView,
nsRect aRect,
PRIntn  aVPercent,
PRIntn  aHPercent,
PRBool  aScrollParentViews 
)

Definition at line 7690 of file nsSelection.cpp.

{
  nsresult rv = NS_OK;
  if (!mFrameSelection)
    return NS_OK;//nothing to do

  if (!aScrollableView)
    return NS_ERROR_NULL_POINTER;

  // Determine the visible rect in the scrolled view's coordinate space.
  // The size of the visible area is the clip view size
  nsRect visibleRect = aScrollableView->View()->GetBounds();
  aScrollableView->GetScrollPosition(visibleRect.x, visibleRect.y);

  // The actual scroll offsets
  nscoord scrollOffsetX = visibleRect.x;
  nscoord scrollOffsetY = visibleRect.y;

  nsPresContext::ScrollbarStyles ss =
    nsLayoutUtils::ScrollbarStylesOfView(aScrollableView);

  // See how aRect should be positioned vertically
  if (ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN) {
    if (NS_PRESSHELL_SCROLL_ANYWHERE == aVPercent) {
      // The caller doesn't care where aRect is positioned vertically,
      // so long as it's fully visible
      if (aRect.y < visibleRect.y) {
        // Scroll up so aRect's top edge is visible
        scrollOffsetY = aRect.y;
      } else if (aRect.YMost() > visibleRect.YMost()) {
        // Scroll down so aRect's bottom edge is visible. Make sure
        // aRect's top edge is still visible
        scrollOffsetY += aRect.YMost() - visibleRect.YMost();
        if (scrollOffsetY > aRect.y) {
          scrollOffsetY = aRect.y;
        }
      }
    } else {
      // Align the aRect edge according to the specified percentage
      nscoord frameAlignY = aRect.y + (aRect.height * aVPercent) / 100;
      scrollOffsetY = frameAlignY - (visibleRect.height * aVPercent) / 100;
    }
  }

  // See how the aRect should be positioned horizontally
  if (ss.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN) {
    if (NS_PRESSHELL_SCROLL_ANYWHERE == aHPercent) {
      // The caller doesn't care where the aRect is positioned horizontally,
      // so long as it's fully visible
      if (aRect.x < visibleRect.x) {
        // Scroll left so the aRect's left edge is visible
        scrollOffsetX = aRect.x;
      } else if (aRect.XMost() > visibleRect.XMost()) {
        // Scroll right so the aRect's right edge is visible. Make sure the
        // aRect's left edge is still visible
        scrollOffsetX += aRect.XMost() - visibleRect.XMost();
        if (scrollOffsetX > aRect.x) {
          scrollOffsetX = aRect.x;
        }
      }
        
    } else {
      // Align the aRect edge according to the specified percentage
      nscoord frameAlignX = aRect.x + (aRect.width * aHPercent) / 100;
      scrollOffsetX = frameAlignX - (visibleRect.width * aHPercent) / 100;
    }
  }

  aScrollableView->ScrollTo(scrollOffsetX, scrollOffsetY, NS_VMREFRESH_IMMEDIATE);

  if (aScrollParentViews)
  {
    //
    // Get aScrollableView's scrolled view.
    //

    nsIView *scrolledView = 0;

    rv = aScrollableView->GetScrolledView(scrolledView);

    if (NS_FAILED(rv))
      return rv;

    if (!scrolledView)
      return NS_ERROR_FAILURE;

    //
    // Check if aScrollableRect has a parent scrollable view!
    //

    nsIView *view = aScrollableView->View()->GetParent();

    if (view)
    {
      nsIScrollableView *parentSV =
        nsLayoutUtils::GetNearestScrollingView(view, nsLayoutUtils::eEither);

      if (parentSV)
      {
        //
        // We have a parent scrollable view, so now map aRect
        // into it's scrolled view's coordinate space.
        //
        
        nsRect newRect;

        rv = parentSV->GetScrolledView(view);

        if (NS_FAILED(rv))
          return rv;

        if (!view)
          return NS_ERROR_FAILURE;

        rv = GetViewAncestorOffset(scrolledView, view, &newRect.x, &newRect.y);

        if (NS_FAILED(rv))
          return rv;

        newRect.x     += aRect.x;
        newRect.y     += aRect.y;
        newRect.width  = aRect.width;
        newRect.height = aRect.height;

        //
        // Now scroll the rect into the parent's view.
        //

        rv = ScrollRectIntoView(parentSV, newRect, aVPercent, aHPercent, aScrollParentViews);
      }
    }
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsISelection::selectAllChildren ( in nsIDOMNode  parentNode) [inherited]

Adds all children of the specified node to the selection.

Parameters:
parentNodethe parent of the children to be added to the selection.
NS_IMETHODIMP nsTypedSelection::selectFrames ( nsPresContext aPresContext,
nsIContentIterator aInnerIter,
nsIContent aContent,
nsIDOMRange aRange,
nsIPresShell aPresShell,
PRBool  aFlags 
) [private]

Definition at line 5370 of file nsSelection.cpp.

{
  if (!mFrameSelection)
    return NS_OK;//nothing to do
  nsresult result;
  if (!aInnerIter)
    return NS_ERROR_NULL_POINTER;
#ifdef USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE
  nsCOMPtr<nsIGeneratedContentIterator> genericiter = do_QueryInterface(aInnerIter);
  if (genericiter && aPresShell)
  {
    result = genericiter->Init(aPresShell,aContent);
  }
  else
#endif // USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE
    result = aInnerIter->Init(aContent);
  nsIFrame *frame;
  if (NS_SUCCEEDED(result))
  {
    // First select frame of content passed in
    result = mFrameSelection->GetShell()->GetPrimaryFrameFor(aContent, &frame);
    if (NS_SUCCEEDED(result) && frame)
    {
      //NOTE: eSpreadDown is now IGNORED. Selected state is set only for given frame
      frame->SetSelected(aPresContext, nsnull, aFlags, eSpreadDown);
#ifndef OLD_TABLE_SELECTION
      PRBool tablesel;
      mFrameSelection->GetTableCellSelection(&tablesel);
      if (tablesel)
      {
        nsITableCellLayout *tcl = nsnull;
        CallQueryInterface(frame, &tcl);
        if (tcl)
        {
          return NS_OK;
        }
      }
#endif //OLD_TABLE_SELECTION
    }
    // Now iterated through the child frames and set them
    while (!aInnerIter->IsDone())
    {
      nsIContent *innercontent = aInnerIter->GetCurrentNode();

      result = mFrameSelection->GetShell()->GetPrimaryFrameFor(innercontent, &frame);
      if (NS_SUCCEEDED(result) && frame)
      {
        //NOTE: eSpreadDown is now IGNORED. Selected state is set only
        //for given frame

        //spread from here to hit all frames in flow
        frame->SetSelected(aPresContext, nsnull,aFlags,eSpreadDown);
        nsRect frameRect = frame->GetRect();

        //if a rect is 0 height/width then try to notify next
        //available in flow of selection status.
        while (!frameRect.width || !frameRect.height)
        {
          //try to notify next in flow that its content is selected.
          frame = frame->GetNextInFlow();
          if (frame)
          {
            frameRect = frame->GetRect();
            frame->SetSelected(aPresContext, nsnull,aFlags,eSpreadDown);
          }
          else
            break;
        }
        //if the frame is splittable and this frame is 0,0 then set
        //the next in flow frame to be selected also
      }

      aInnerIter->Next();
    }

#if 0
    result = mFrameSelection->GetShell()->GetPrimaryFrameFor(content, &frame);
    if (NS_SUCCEEDED(result) && frame)
      frame->SetSelected(aRange,aFlags,eSpreadDown);//spread from here to hit all frames in flow
#endif

    return NS_OK;
  }

  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsTypedSelection::selectFrames ( nsPresContext aPresContext,
nsIDOMRange aRange,
PRBool  aSelect 
) [private]

Definition at line 5466 of file nsSelection.cpp.

{
  if (!mFrameSelection)
    return NS_OK;//nothing to do
  if (!aRange || !aPresContext) 
    return NS_ERROR_NULL_POINTER;

  nsresult result;
  nsCOMPtr<nsIContentIterator> iter = do_CreateInstance(
#ifdef USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE
                                              kCGenSubtreeIteratorCID,
#else
                                              kCSubtreeIteratorCID,
#endif // USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE
                                              &result);
  if (NS_FAILED(result))
    return result;

  nsCOMPtr<nsIContentIterator> inneriter = do_CreateInstance(
#ifdef USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE
                                              kCGenContentIteratorCID,
#else
                                              kCContentIteratorCID,
#endif // USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE
                                              &result);

  if ((NS_SUCCEEDED(result)) && iter && inneriter)
  {
    nsIPresShell *presShell = aPresContext->GetPresShell();
#ifdef USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE
    nsCOMPtr<nsIGeneratedContentIterator> genericiter = do_QueryInterface(iter);
    if (genericiter && presShell)
      result = genericiter->Init(presShell,aRange);
    else
#endif // USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE
      result = iter->Init(aRange);

    // loop through the content iterator for each content node
    // for each text node:
    // get the frame for the content, and from it the style context
    // ask the style context about the property
    nsCOMPtr<nsIContent> content;
    nsIFrame *frame;
//we must call first one explicitly
    content = do_QueryInterface(FetchStartParent(aRange), &result);
    if (NS_FAILED(result) || !content)
      return result;

    if (!content->IsContentOfType(nsIContent::eELEMENT))
    {
      result = mFrameSelection->GetShell()->GetPrimaryFrameFor(content, &frame);
      if (NS_SUCCEEDED(result) && frame)
        frame->SetSelected(aPresContext, aRange,aFlags,eSpreadDown);//spread from here to hit all frames in flow
    }
//end start content
    iter->First();

    while (!iter->IsDone())
    {
      content = iter->GetCurrentNode();

      selectFrames(aPresContext, inneriter, content, aRange, presShell,aFlags);

      iter->Next();
    }
//we must now do the last one  if it is not the same as the first
    if (FetchEndParent(aRange) != FetchStartParent(aRange))
    {
      content = do_QueryInterface(FetchEndParent(aRange), &result);
      if (NS_FAILED(result) || !content)
        return result;

      if (!content->IsContentOfType(nsIContent::eELEMENT))
      {
        result = mFrameSelection->GetShell()->GetPrimaryFrameFor(content, &frame);
        if (NS_SUCCEEDED(result) && frame)
           frame->SetSelected(aPresContext, aRange,aFlags,eSpreadDown);//spread from here to hit all frames in flow
      }
    }
//end end parent
  }
  return result;
}

Here is the call graph for this function:

Modifies the cursor Bidi level after a change in keyboard direction.

Parameters:
langRTLis PR_TRUE if the new language is right-to-left or PR_FALSE if the new language is left-to-right.

Definition at line 4524 of file nsSelection.cpp.

{
  if (indx >= (PRInt32)mRanges.Length())
    return;
  if (indx < 0) //release all
  {
    mAnchorFocusRange = nsnull;
  }
  else{
    mAnchorFocusRange = mRanges[indx].mRange;
  }
}

Here is the caller graph for this function:

Definition at line 242 of file nsSelection.cpp.

{mDirection = aDir;}

Here is the caller graph for this function:

Definition at line 6731 of file nsSelection.cpp.

{
  if (!aNode){
    mOriginalAnchorRange = 0;
    return NS_OK;
  }
  nsCOMPtr<nsIDOMRange> newRange;
  nsresult result;
  NS_NewRange(getter_AddRefs(newRange));
  if (!newRange) return NS_ERROR_OUT_OF_MEMORY;

  result = newRange->SetStart(aNode,aOffset);
  if (NS_FAILED(result))
    return result;
  result = newRange->SetEnd(aNode,aOffset);
  if (NS_FAILED(result))
    return result;

  mOriginalAnchorRange = newRange;
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 244 of file nsSelection.cpp.

{mTrueDirection = aBool;}

Definition at line 265 of file nsSelection.cpp.

{mType = aType;}

Here is the caller graph for this function:

nsresult nsTypedSelection::StartAutoScrollTimer ( nsPresContext aPresContext,
nsIView aView,
nsPoint aPoint,
PRUint32  aDelay 
)

Definition at line 5754 of file nsSelection.cpp.

{
  nsresult result;
  if (!mFrameSelection)
    return NS_OK;//nothing to do

  if (!mAutoScrollTimer)
  {
    result = NS_NewAutoScrollTimer(&mAutoScrollTimer);

    if (NS_FAILED(result))
      return result;

    if (!mAutoScrollTimer)
      return NS_ERROR_OUT_OF_MEMORY;

    result = mAutoScrollTimer->Init(mFrameSelection, this);

    if (NS_FAILED(result))
      return result;
  }

  result = mAutoScrollTimer->SetDelay(aDelay);

  if (NS_FAILED(result))
    return result;

  return DoAutoScrollView(aPresContext, aView, aPoint, PR_TRUE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 5785 of file nsSelection.cpp.

{
  if (mAutoScrollTimer)
    return mAutoScrollTimer->Stop();

  return NS_OK; 
}

Here is the call graph for this function:

Here is the caller graph for this function:

wstring nsISelection::toString ( ) [inherited]

Returns the whole selection into a plain text string.

wstring nsISelectionPrivate::toStringWithFormat ( in string  formatType,
in unsigned long  flags,
in PRInt32  wrapColumn 
) [inherited]

Friends And Related Function Documentation

friend struct nsScrollSelectionIntoViewEvent [friend]

Definition at line 273 of file nsSelection.cpp.

friend class nsSelectionIterator [friend]

Definition at line 272 of file nsSelection.cpp.


Member Data Documentation

The node representing one end of the selection.

Definition at line 59 of file nsISelection.idl.

The offset within the (text) node where the selection begins.

Definition at line 64 of file nsISelection.idl.

Definition at line 106 of file nsISelectionPrivate.idl.

Definition at line 59 of file nsISelectionPrivate.idl.

The node with keyboard focus.

Definition at line 69 of file nsISelection.idl.

The offset within the (text) node where focus starts.

Definition at line 74 of file nsISelection.idl.

Definition at line 62 of file nsISelectionPrivate.idl.

Indicates if the selection is collapsed or not.

Definition at line 79 of file nsISelection.idl.

Definition at line 339 of file nsSelection.cpp.

Definition at line 347 of file nsSelection.cpp.

Definition at line 352 of file nsSelection.cpp.

Definition at line 341 of file nsSelection.cpp.

Definition at line 350 of file nsSelection.cpp.

Definition at line 342 of file nsSelection.cpp.

Definition at line 344 of file nsSelection.cpp.

Definition at line 340 of file nsSelection.cpp.

Definition at line 345 of file nsSelection.cpp.

Definition at line 317 of file nsSelection.cpp.

Definition at line 316 of file nsSelection.cpp.

Definition at line 351 of file nsSelection.cpp.

Definition at line 348 of file nsSelection.cpp.

Definition at line 349 of file nsSelection.cpp.

Definition at line 346 of file nsSelection.cpp.

readonly attribute long nsISelection::rangeCount [inherited]

Returns the number of ranges in the selection.

Definition at line 84 of file nsISelection.idl.

Definition at line 60 of file nsISelectionPrivate.idl.

Definition at line 89 of file nsISelectionPrivate.idl.

Definition at line 85 of file nsISelectionPrivate.idl.

Definition at line 87 of file nsISelectionPrivate.idl.

Definition at line 84 of file nsISelectionPrivate.idl.

Definition at line 86 of file nsISelectionPrivate.idl.

Definition at line 88 of file nsISelectionPrivate.idl.


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