Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions
nsSelection.cpp File Reference
#include "nsCOMPtr.h"
#include "nsWeakReference.h"
#include "nsIFactory.h"
#include "nsIEnumerator.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsIDOMRange.h"
#include "nsIFrameSelection.h"
#include "nsISelection.h"
#include "nsISelection2.h"
#include "nsISelectionPrivate.h"
#include "nsISelectionListener.h"
#include "nsIComponentManager.h"
#include "nsContentCID.h"
#include "nsIContent.h"
#include "nsIDOMElement.h"
#include "nsIDOMNode.h"
#include "nsRange.h"
#include "nsCOMArray.h"
#include "nsGUIEvent.h"
#include "nsIDOMKeyEvent.h"
#include "nsITableLayout.h"
#include "nsITableCellLayout.h"
#include "nsIDOMNodeList.h"
#include "nsITextContent.h"
#include "nsTArray.h"
#include "nsIContentIterator.h"
#include "nsIDocumentEncoder.h"
#include "nsFrameTraversal.h"
#include "nsILineIterator.h"
#include "nsLayoutAtoms.h"
#include "nsIFrameTraversal.h"
#include "nsLayoutUtils.h"
#include "nsLayoutCID.h"
#include "nsIDOMText.h"
#include "nsContentUtils.h"
#include "nsPresContext.h"
#include "nsIPresShell.h"
#include "nsICaret.h"
#include "nsIViewManager.h"
#include "nsIScrollableView.h"
#include "nsIDeviceContext.h"
#include "nsITimer.h"
#include "nsIServiceManager.h"
#include "nsIEventQueue.h"
#include "nsIEventQueueService.h"
#include "nsIDOMDocument.h"
#include "nsIDocument.h"
#include "nsISelectionController.h"
#include "nsHTMLAtoms.h"
#include "nsAutoCopyListener.h"
#include "nsCopySupport.h"
#include "nsIClipboard.h"

Go to the source code of this file.

Classes

struct  CachedOffsetForFrame
struct  RangeData
class  nsTypedSelection
class  nsSelectionBatcher
class  nsSelection
class  nsSelectionIterator
class  nsAutoScrollTimer
struct  nsScrollSelectionIntoViewEvent

Defines

#define STATUS_CHECK_RETURN_MACRO()   {if (!mShell) return NS_ERROR_FAILURE;}
#define DEBUG_OUT_RANGE(x)

Functions

static NS_DEFINE_CID (kFrameTraversalCID, NS_FRAMETRAVERSAL_CID)
static NS_DEFINE_IID (kCContentIteratorCID, NS_CONTENTITERATOR_CID)
static NS_DEFINE_IID (kCSubtreeIteratorCID, NS_SUBTREEITERATOR_CID)
PRBool IsValidSelectionPoint (nsSelection *aFrameSel, nsIContent *aContent)
PRBool IsValidSelectionPoint (nsSelection *aFrameSel, nsIDOMNode *aDomNode)
static nsIAtomGetTag (nsIDOMNode *aNode)
static nsresult ParentOffset (nsIDOMNode *aNode, nsIDOMNode **aParent, PRInt32 *aChildOffset)
static nsIDOMNodeGetCellParent (nsIDOMNode *aDomNode)
nsresult NS_NewAutoScrollTimer (nsAutoScrollTimer **aResult)
nsresult NS_NewSelection (nsIFrameSelection **aFrameSelection)
nsresult NS_NewDomSelection (nsISelection **aDomSelection)
static PRInt8 GetIndexFromSelectionType (SelectionType aType)
static SelectionType GetSelectionTypeFromIndex (PRInt8 aIndex)
static PRBool IsCell (nsIContent *aContent)
static nsresult CompareToRangeStart (nsIDOMNode *aCompareNode, PRInt32 aCompareOffset, nsIDOMRange *aRange, PRInt32 *cmp)
static nsresult CompareToRangeEnd (nsIDOMNode *aCompareNode, PRInt32 aCompareOffset, nsIDOMRange *aRange, PRInt32 *cmp)
static PRBool RangeMatchesBeginPoint (nsIDOMRange *aRange, nsIDOMNode *aNode, PRInt32 aOffset)
static PRBool RangeMatchesEndPoint (nsIDOMRange *aRange, nsIDOMNode *aNode, PRInt32 aOffset)
static nsresult GetChildOffset (nsIDOMNode *aChild, nsIDOMNode *aParent, PRInt32 &aOffset)
static void PR_CALLBACK HandlePLEvent (nsScrollSelectionIntoViewEvent *aEvent)
static void PR_CALLBACK DestroyPLEvent (nsScrollSelectionIntoViewEvent *aEvent)

Define Documentation

Definition at line 162 of file nsSelection.cpp.

Definition at line 112 of file nsSelection.cpp.


Function Documentation

static nsresult CompareToRangeEnd ( nsIDOMNode aCompareNode,
PRInt32  aCompareOffset,
nsIDOMRange aRange,
PRInt32 cmp 
) [static]

Definition at line 4670 of file nsSelection.cpp.

{
  nsCOMPtr<nsIDOMNode> endNode;
  nsresult rv = aRange->GetEndContainer(getter_AddRefs(endNode));
  NS_ENSURE_SUCCESS(rv, rv);

  PRInt32 endOffset;
  rv = aRange->GetEndOffset(&endOffset);
  NS_ENSURE_SUCCESS(rv, rv);

  *cmp = nsRange::ComparePoints(aCompareNode, aCompareOffset,
                                endNode, endOffset);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult CompareToRangeStart ( nsIDOMNode aCompareNode,
PRInt32  aCompareOffset,
nsIDOMRange aRange,
PRInt32 cmp 
) [static]

Definition at line 4653 of file nsSelection.cpp.

{
  nsCOMPtr<nsIDOMNode> startNode;
  nsresult rv = aRange->GetStartContainer(getter_AddRefs(startNode));
  NS_ENSURE_SUCCESS(rv, rv);

  PRInt32 startOffset;
  rv = aRange->GetStartOffset(&startOffset);
  NS_ENSURE_SUCCESS(rv, rv);

  *cmp = nsRange::ComparePoints(aCompareNode, aCompareOffset,
                                startNode, startOffset);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 7867 of file nsSelection.cpp.

{
  NS_ASSERTION(nsnull != aEvent,"Event is null");
  delete aEvent;
}
nsIDOMNode * GetCellParent ( nsIDOMNode aDomNode) [static]

Definition at line 1305 of file nsSelection.cpp.

{
    if (!aDomNode)
      return 0;
    nsCOMPtr<nsIDOMNode> parent(aDomNode);
    nsCOMPtr<nsIDOMNode> current(aDomNode);
    PRInt32 childOffset;
    nsIAtom *tag;
    // Start with current node and look for a table cell
    while(current)
    {
      tag = GetTag(current);
      if (tag == nsHTMLAtoms::td || tag == nsHTMLAtoms::th)
        return current;
      if (NS_FAILED(ParentOffset(current,getter_AddRefs(parent),&childOffset)) || !parent)
        return 0;
      current = parent;
    }
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult GetChildOffset ( nsIDOMNode aChild,
nsIDOMNode aParent,
PRInt32 aOffset 
) [static]

Definition at line 7158 of file nsSelection.cpp.

{
  NS_ASSERTION((aChild && aParent), "bad args");
  nsCOMPtr<nsIContent> content = do_QueryInterface(aParent);
  nsCOMPtr<nsIContent> cChild = do_QueryInterface(aChild);

  if (!cChild || !content)
    return NS_ERROR_NULL_POINTER;

  aOffset = content->IndexOf(cChild);

  return NS_OK;
}

Here is the call graph for this function:

static PRInt8 GetIndexFromSelectionType ( SelectionType  aType) [static]

Definition at line 754 of file nsSelection.cpp.

{
    switch (aType)
    {
    case nsISelectionController::SELECTION_NORMAL: return 0; break;
    case nsISelectionController::SELECTION_SPELLCHECK: return 1; break;
    case nsISelectionController::SELECTION_IME_RAWINPUT: return 2; break;
    case nsISelectionController::SELECTION_IME_SELECTEDRAWTEXT: return 3; break;
    case nsISelectionController::SELECTION_IME_CONVERTEDTEXT: return 4; break;
    case nsISelectionController::SELECTION_IME_SELECTEDCONVERTEDTEXT: return 5; break;
    case nsISelectionController::SELECTION_ACCESSIBILITY: return 6; break;
    default:return -1;break;
    }
    /* NOTREACHED */
    return 0;
}

Here is the caller graph for this function:

static SelectionType GetSelectionTypeFromIndex ( PRInt8  aIndex) [static]

Definition at line 772 of file nsSelection.cpp.

Here is the caller graph for this function:

static nsIAtom * GetTag ( nsIDOMNode aNode) [static]

Definition at line 1271 of file nsSelection.cpp.

{
  nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
  if (!content) 
  {
    NS_NOTREACHED("bad node passed to GetTag()");
    return nsnull;
  }
  
  return content->Tag();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 7861 of file nsSelection.cpp.

{
  NS_ASSERTION(nsnull != aEvent,"Event is null");
  aEvent->HandleEvent();
}

Here is the call graph for this function:

static PRBool IsCell ( nsIContent aContent) [static]

Definition at line 3145 of file nsSelection.cpp.

{
  return ((aContent->Tag() == nsHTMLAtoms::td ||
           aContent->Tag() == nsHTMLAtoms::th) &&
          aContent->IsContentOfType(nsIContent::eHTML));
}

Here is the call graph for this function:

PRBool IsValidSelectionPoint ( nsSelection aFrameSel,
nsIContent aContent 
)

Definition at line 815 of file nsSelection.cpp.

{
  if (!aFrameSel || !aContent)
    return PR_FALSE;
  if (aFrameSel)
  {
    nsresult result;
    nsCOMPtr<nsIContent> tLimiter;
    result = aFrameSel->GetLimiter(getter_AddRefs(tLimiter));
    if (NS_FAILED(result))
      return PR_FALSE;
    if (tLimiter && tLimiter != aContent)
    {
      if (tLimiter != aContent->GetParent()) //if newfocus == the limiter. thats ok. but if not there and not parent bad
        return PR_FALSE; //not in the right content. tLimiter said so
    }
  }
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool IsValidSelectionPoint ( nsSelection aFrameSel,
nsIDOMNode aDomNode 
)

Definition at line 792 of file nsSelection.cpp.

{
    nsCOMPtr<nsIContent> passedContent;
    passedContent = do_QueryInterface(aDomNode);
    if (!passedContent)
      return PR_FALSE;
    return IsValidSelectionPoint(aFrameSel,passedContent);
}

Here is the call graph for this function:

static NS_DEFINE_CID ( kFrameTraversalCID  ,
NS_FRAMETRAVERSAL_CID   
) [static]
static NS_DEFINE_IID ( kCContentIteratorCID  ,
NS_CONTENTITERATOR_CID   
) [static]
static NS_DEFINE_IID ( kCSubtreeIteratorCID  ,
NS_SUBTREEITERATOR_CID   
) [static]

Definition at line 714 of file nsSelection.cpp.

{
  if (!aResult)
    return NS_ERROR_NULL_POINTER;

  *aResult = (nsAutoScrollTimer*) new nsAutoScrollTimer;

  if (!aResult)
    return NS_ERROR_OUT_OF_MEMORY;

  NS_ADDREF(*aResult);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewDomSelection ( nsISelection **  aDomSelection)

Definition at line 743 of file nsSelection.cpp.

{
  nsTypedSelection *rlist = new nsTypedSelection;
  if (!rlist)
    return NS_ERROR_OUT_OF_MEMORY;
  *aDomSelection = (nsISelection *)rlist;
  NS_ADDREF(rlist);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewSelection ( nsIFrameSelection **  aFrameSelection)

Definition at line 731 of file nsSelection.cpp.

{
  nsSelection *rlist = new nsSelection;
  if (!rlist)
    return NS_ERROR_OUT_OF_MEMORY;
  *aFrameSelection = (nsIFrameSelection *)rlist;
  NS_ADDREF(rlist);
  return NS_OK;
}

Here is the call graph for this function:

nsresult ParentOffset ( nsIDOMNode aNode,
nsIDOMNode **  aParent,
PRInt32 aChildOffset 
) [static]

Definition at line 1284 of file nsSelection.cpp.

{
  if (!aNode || !aParent || !aChildOffset)
    return NS_ERROR_NULL_POINTER;

  nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
  if (content)
  {
    nsIContent* parent = content->GetParent();
    if (parent)
    {
      *aChildOffset = parent->IndexOf(content);

      return CallQueryInterface(parent, aParent);
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool RangeMatchesBeginPoint ( nsIDOMRange aRange,
nsIDOMNode aNode,
PRInt32  aOffset 
) [static]

Definition at line 5188 of file nsSelection.cpp.

{
  PRInt32 offset;
  nsresult rv = aRange->GetStartOffset(&offset);
  if (NS_FAILED(rv) || offset != aOffset)
    return PR_FALSE;

  nsCOMPtr<nsIDOMNode> node;
  rv = aRange->GetStartContainer(getter_AddRefs(node));
  if (NS_FAILED(rv) || node != aNode)
    return PR_FALSE;

  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool RangeMatchesEndPoint ( nsIDOMRange aRange,
nsIDOMNode aNode,
PRInt32  aOffset 
) [static]

Definition at line 5204 of file nsSelection.cpp.

{
  PRInt32 offset;
  nsresult rv = aRange->GetEndOffset(&offset);
  if (NS_FAILED(rv) || offset != aOffset)
    return PR_FALSE;

  nsCOMPtr<nsIDOMNode> node;
  rv = aRange->GetEndContainer(getter_AddRefs(node));
  if (NS_FAILED(rv) || node != aNode)
    return PR_FALSE;

  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function: