Bug 1088054 part 2 - Reduce nsIDOMRange use in editor/; r=ehsan

This commit is contained in:
Aryeh Gregor 2014-11-02 14:04:13 +02:00
parent 5a798e4e1c
commit e8b1092a6b
22 changed files with 171 additions and 228 deletions

View File

@ -10,6 +10,7 @@
#include "mozilla/Preferences.h" // for Preferences
#include "mozilla/Services.h" // for GetXULChromeRegistryService
#include "mozilla/dom/Element.h" // for Element
#include "mozilla/dom/Selection.h"
#include "mozilla/mozalloc.h" // for operator delete, etc
#include "nsAString.h" // for nsAString_internal::IsEmpty, etc
#include "nsComponentManagerUtils.h" // for do_CreateInstance
@ -23,7 +24,6 @@
#include "nsIContentPrefService2.h" // for nsIContentPrefService2, etc
#include "nsIDOMDocument.h" // for nsIDOMDocument
#include "nsIDOMElement.h" // for nsIDOMElement
#include "nsIDOMRange.h" // for nsIDOMRange
#include "nsIDocument.h" // for nsIDocument
#include "nsIEditor.h" // for nsIEditor
#include "nsIHTMLEditor.h" // for nsIHTMLEditor
@ -38,6 +38,7 @@
#include "nsIVariant.h" // for nsIWritableVariant, etc
#include "nsLiteralString.h" // for NS_LITERAL_STRING, etc
#include "nsMemory.h" // for nsMemory
#include "nsRange.h"
#include "nsReadableUtils.h" // for ToNewUnicode, EmptyString, etc
#include "nsServiceManagerUtils.h" // for do_GetService
#include "nsString.h" // for nsAutoString, nsString, etc
@ -46,6 +47,7 @@
#include "nsXULAppAPI.h" // for XRE_GetProcessType
using namespace mozilla;
using namespace mozilla::dom;
class UpdateDictionaryHolder {
private:
@ -343,10 +345,9 @@ nsEditorSpellCheck::InitSpellChecker(nsIEditor* aEditor, bool aEnableSelectionCh
// Find out if the section is collapsed or not.
// If it isn't, we want to spellcheck just the selection.
nsCOMPtr<nsISelection> selection;
rv = aEditor->GetSelection(getter_AddRefs(selection));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISelection> domSelection;
aEditor->GetSelection(getter_AddRefs(domSelection));
nsRefPtr<Selection> selection = static_cast<Selection*>(domSelection.get());
NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
int32_t count = 0;
@ -355,10 +356,8 @@ nsEditorSpellCheck::InitSpellChecker(nsIEditor* aEditor, bool aEnableSelectionCh
NS_ENSURE_SUCCESS(rv, rv);
if (count > 0) {
nsCOMPtr<nsIDOMRange> range;
rv = selection->GetRangeAt(0, getter_AddRefs(range));
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<nsRange> range = selection->GetRangeAt(0);
NS_ENSURE_STATE(range);
bool collapsed = false;
rv = range->GetCollapsed(&collapsed);
@ -368,10 +367,7 @@ nsEditorSpellCheck::InitSpellChecker(nsIEditor* aEditor, bool aEnableSelectionCh
// We don't want to touch the range in the selection,
// so create a new copy of it.
nsCOMPtr<nsIDOMRange> rangeBounds;
rv = range->CloneRange(getter_AddRefs(rangeBounds));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(rangeBounds, NS_ERROR_FAILURE);
nsRefPtr<nsRange> rangeBounds = range->CloneRange();
// Make sure the new range spans complete words.

View File

@ -19,8 +19,6 @@
#include "nsINode.h"
#include "nsAString.h"
class nsIDOMRange;
using namespace mozilla;
using namespace mozilla::dom;

View File

@ -66,7 +66,6 @@
#include "nsIDOMMouseEvent.h" // for nsIDOMMouseEvent
#include "nsIDOMNode.h" // for nsIDOMNode, etc
#include "nsIDOMNodeList.h" // for nsIDOMNodeList
#include "nsIDOMRange.h" // for nsIDOMRange
#include "nsIDOMText.h" // for nsIDOMText
#include "nsIDocument.h" // for nsIDocument
#include "nsIDocumentStateListener.h" // for nsIDocumentStateListener
@ -4393,7 +4392,7 @@ nsEditor::CreateTxnForDeleteInsertionPoint(nsRange* aRange,
nsresult
nsEditor::CreateRange(nsIDOMNode *aStartParent, int32_t aStartOffset,
nsIDOMNode *aEndParent, int32_t aEndOffset,
nsIDOMRange **aRange)
nsRange** aRange)
{
return nsRange::CreateRange(aStartParent, aStartOffset, aEndParent,
aEndOffset, aRange);
@ -4413,7 +4412,7 @@ nsEditor::AppendNodeToSelectionAsRange(nsIDOMNode *aNode)
int32_t offset = GetChildOffset(aNode, parentNode);
nsCOMPtr<nsIDOMRange> range;
nsRefPtr<nsRange> range;
res = CreateRange(parentNode, offset, parentNode, offset+1, getter_AddRefs(range));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(range, NS_ERROR_NULL_POINTER);

View File

@ -42,7 +42,6 @@ class nsIDOMEventListener;
class nsIDOMEventTarget;
class nsIDOMKeyEvent;
class nsIDOMNode;
class nsIDOMRange;
class nsIDocument;
class nsIDocumentStateListener;
class nsIEditActionListener;
@ -625,7 +624,7 @@ public:
// Used by table cell selection methods
nsresult CreateRange(nsIDOMNode *aStartParent, int32_t aStartOffset,
nsIDOMNode *aEndParent, int32_t aEndOffset,
nsIDOMRange **aRange);
nsRange** aRange);
// Creates a range with just the supplied node and appends that to the selection
nsresult AppendNodeToSelectionAsRange(nsIDOMNode *aNode);

View File

@ -32,7 +32,6 @@
#include "nsIDOMKeyEvent.h" // for nsIDOMKeyEvent
#include "nsIDOMMouseEvent.h" // for nsIDOMMouseEvent
#include "nsIDOMNode.h" // for nsIDOMNode
#include "nsIDOMRange.h" // for nsIDOMRange
#include "nsIDocument.h" // for nsIDocument
#include "nsIEditor.h" // for nsEditor::GetSelection, etc
#include "nsIEditorIMESupport.h"
@ -49,6 +48,7 @@
#include "nsLiteralString.h" // for NS_LITERAL_STRING
#include "nsPIWindowRoot.h" // for nsPIWindowRoot
#include "nsPrintfCString.h" // for nsPrintfCString
#include "nsRange.h"
#include "nsServiceManagerUtils.h" // for do_GetService
#include "nsString.h" // for nsAutoString
#ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
@ -1007,9 +1007,8 @@ nsEditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
NS_ENSURE_SUCCESS(rv, false);
for (int32_t i = 0; i < rangeCount; i++) {
nsCOMPtr<nsIDOMRange> range;
rv = selection->GetRangeAt(i, getter_AddRefs(range));
if (NS_FAILED(rv) || !range) {
nsRefPtr<nsRange> range = selection->GetRangeAt(i);
if (!range) {
// Don't bail yet, iterate through them all
continue;
}

View File

@ -20,8 +20,8 @@
#include "nsINode.h"
#include "nsISimpleEnumerator.h"
class nsIDOMRange;
class nsISupports;
class nsRange;
using namespace mozilla;
using namespace mozilla::dom;
@ -75,7 +75,7 @@ nsDOMIterator::~nsDOMIterator()
}
nsresult
nsDOMIterator::Init(nsIDOMRange* aRange)
nsDOMIterator::Init(nsRange* aRange)
{
nsresult res;
mIter = do_CreateInstance("@mozilla.org/content/post-content-iterator;1", &res);
@ -125,7 +125,7 @@ nsDOMSubtreeIterator::~nsDOMSubtreeIterator()
}
nsresult
nsDOMSubtreeIterator::Init(nsIDOMRange* aRange)
nsDOMSubtreeIterator::Init(nsRange* aRange)
{
nsresult res;
mIter = do_CreateInstance("@mozilla.org/content/subtree-content-iterator;1", &res);

View File

@ -18,7 +18,7 @@
class nsIAtom;
class nsIContentIterator;
class nsIDOMDocument;
class nsIDOMRange;
class nsRange;
template <class E> class nsCOMArray;
namespace mozilla {
namespace dom {
@ -176,7 +176,7 @@ class MOZ_STACK_CLASS nsDOMIterator
nsDOMIterator();
virtual ~nsDOMIterator();
nsresult Init(nsIDOMRange* aRange);
nsresult Init(nsRange* aRange);
nsresult Init(nsIDOMNode* aNode);
nsresult AppendList(nsBoolDomIterFunctor& functor,
nsCOMArray<nsIDOMNode>& arrayOfNodes) const;
@ -190,7 +190,7 @@ class MOZ_STACK_CLASS nsDOMSubtreeIterator : public nsDOMIterator
nsDOMSubtreeIterator();
virtual ~nsDOMSubtreeIterator();
nsresult Init(nsIDOMRange* aRange);
nsresult Init(nsRange* aRange);
};
class nsTrivialFunctor : public nsBoolDomIterFunctor

View File

@ -48,7 +48,6 @@
#include "nsIDOMHTMLObjectElement.h"
#include "nsIDOMHTMLScriptElement.h"
#include "nsIDOMNode.h"
#include "nsIDOMRange.h"
#include "nsIDocument.h"
#include "nsIEditor.h"
#include "nsIEditorIMESupport.h"
@ -168,9 +167,7 @@ NS_IMETHODIMP nsHTMLEditor::LoadHTML(const nsAString & aInputString)
}
// Get the first range in the selection, for context:
nsCOMPtr<nsIDOMRange> range;
rv = selection->GetRangeAt(0, getter_AddRefs(range));
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<nsRange> range = selection->GetRangeAt(0);
NS_ENSURE_TRUE(range, NS_ERROR_NULL_POINTER);
// create fragment for pasted html

View File

@ -36,7 +36,6 @@
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsIDOMNode.h"
#include "nsIDOMRange.h"
#include "nsIDOMText.h"
#include "nsIHTMLAbsPosEditor.h"
#include "nsIHTMLDocument.h"
@ -833,7 +832,7 @@ nsHTMLEditRules::GetAlignment(bool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
}
else
{
nsCOMArray<nsIDOMRange> arrayOfRanges;
nsTArray<nsRefPtr<nsRange>> arrayOfRanges;
res = GetPromotedRanges(selection, arrayOfRanges, EditAction::align);
NS_ENSURE_SUCCESS(res, res);
@ -2020,26 +2019,16 @@ nsHTMLEditRules::WillDeleteSelection(Selection* aSelection,
}
else
{
nsCOMPtr<nsIDOMRange> range;
res = aSelection->GetRangeAt(0, getter_AddRefs(range));
NS_ENSURE_SUCCESS(res, res);
nsRefPtr<nsRange> range = aSelection->GetRangeAt(0);
NS_ENSURE_STATE(range);
#ifdef DEBUG
nsIDOMNode *container;
NS_ASSERTION(GetAsDOMNode(range->GetStartParent()) == visNode,
"selection start not in visNode");
NS_ASSERTION(GetAsDOMNode(range->GetEndParent()) == visNode,
"selection end not in visNode");
res = range->GetStartContainer(&container);
NS_ENSURE_SUCCESS(res, res);
NS_ASSERTION(container == visNode, "selection start not in visNode");
res = range->GetEndContainer(&container);
NS_ENSURE_SUCCESS(res, res);
NS_ASSERTION(container == visNode, "selection end not in visNode");
#endif
res = range->GetStartOffset(&so);
NS_ENSURE_SUCCESS(res, res);
res = range->GetEndOffset(&eo);
NS_ENSURE_SUCCESS(res, res);
so = range->StartOffset();
eo = range->EndOffset();
}
NS_ENSURE_STATE(mHTMLEditor);
res = nsWSRunObject::PrepareToDeleteRange(mHTMLEditor,
@ -3451,7 +3440,7 @@ nsHTMLEditRules::WillRemoveList(Selection* aSelection,
NS_ENSURE_STATE(mHTMLEditor);
nsAutoSelectionReset selectionResetter(aSelection, mHTMLEditor);
nsCOMArray<nsIDOMRange> arrayOfRanges;
nsTArray<nsRefPtr<nsRange>> arrayOfRanges;
res = GetPromotedRanges(aSelection, arrayOfRanges, EditAction::makeList);
NS_ENSURE_SUCCESS(res, res);
@ -3725,7 +3714,7 @@ nsHTMLEditRules::WillCSSIndent(Selection* aSelection,
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_STATE(mHTMLEditor);
nsAutoSelectionReset selectionResetter(aSelection, mHTMLEditor);
nsCOMArray<nsIDOMRange> arrayOfRanges;
nsTArray<nsRefPtr<nsRange>> arrayOfRanges;
nsCOMArray<nsIDOMNode> arrayOfNodes;
// short circuit: detect case of collapsed selection inside an <li>.
@ -3937,7 +3926,7 @@ nsHTMLEditRules::WillHTMLIndent(Selection* aSelection,
// block parent, and then further expands to include any ancestors
// whose children are all in the range
nsCOMArray<nsIDOMRange> arrayOfRanges;
nsTArray<nsRefPtr<nsRange>> arrayOfRanges;
res = GetPromotedRanges(aSelection, arrayOfRanges, EditAction::indent);
NS_ENSURE_SUCCESS(res, res);
@ -5292,9 +5281,7 @@ nsHTMLEditRules::ExpandSelectionForDeletion(Selection* aSelection)
if (rangeCount != 1) return NS_OK;
// find current sel start and end
nsCOMPtr<nsIDOMRange> range;
res = aSelection->GetRangeAt(0, getter_AddRefs(range));
NS_ENSURE_SUCCESS(res, res);
nsRefPtr<nsRange> range = aSelection->GetRangeAt(0);
NS_ENSURE_TRUE(range, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode> selStartNode, selEndNode, selCommon;
int32_t selStartOffset, selEndOffset;
@ -5473,9 +5460,7 @@ nsHTMLEditRules::NormalizeSelection(Selection* inSelection)
// we don't need to mess with cell selections, and we assume multirange selections are those.
if (rangeCount != 1) return NS_OK;
nsCOMPtr<nsIDOMRange> range;
res = inSelection->GetRangeAt(0, getter_AddRefs(range));
NS_ENSURE_SUCCESS(res, res);
nsRefPtr<nsRange> range = inSelection->GetRangeAt(0);
NS_ENSURE_TRUE(range, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode> startNode, endNode;
int32_t startOffset, endOffset;
@ -5800,7 +5785,7 @@ nsHTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode* aNode,
//
nsresult
nsHTMLEditRules::GetPromotedRanges(Selection* inSelection,
nsCOMArray<nsIDOMRange> &outArrayOfRanges,
nsTArray<nsRefPtr<nsRange>>& outArrayOfRanges,
EditAction inOperationType)
{
NS_ENSURE_TRUE(inSelection, NS_ERROR_NULL_POINTER);
@ -5810,17 +5795,16 @@ nsHTMLEditRules::GetPromotedRanges(Selection* inSelection,
NS_ENSURE_SUCCESS(res, res);
int32_t i;
nsCOMPtr<nsIDOMRange> selectionRange;
nsCOMPtr<nsIDOMRange> opRange;
nsRefPtr<nsRange> selectionRange;
nsRefPtr<nsRange> opRange;
for (i = 0; i < rangeCount; i++)
{
res = inSelection->GetRangeAt(i, getter_AddRefs(selectionRange));
NS_ENSURE_SUCCESS(res, res);
selectionRange = inSelection->GetRangeAt(i);
NS_ENSURE_STATE(selectionRange);
// clone range so we don't muck with actual selection ranges
res = selectionRange->CloneRange(getter_AddRefs(opRange));
NS_ENSURE_SUCCESS(res, res);
opRange = selectionRange->CloneRange();
// make a new adjusted range to represent the appropriate block content.
// The basic idea is to push out the range endpoints
@ -5830,7 +5814,7 @@ nsHTMLEditRules::GetPromotedRanges(Selection* inSelection,
NS_ENSURE_SUCCESS(res, res);
// stuff new opRange into array
outArrayOfRanges.AppendObject(opRange);
outArrayOfRanges.AppendElement(opRange);
}
return res;
}
@ -5841,8 +5825,7 @@ nsHTMLEditRules::GetPromotedRanges(Selection* inSelection,
// editable children are already in range.
//
nsresult
nsHTMLEditRules::PromoteRange(nsIDOMRange *inRange,
EditAction inOperationType)
nsHTMLEditRules::PromoteRange(nsRange* inRange, EditAction inOperationType)
{
NS_ENSURE_TRUE(inRange, NS_ERROR_NULL_POINTER);
nsresult res;
@ -5905,7 +5888,7 @@ nsHTMLEditRules::PromoteRange(nsIDOMRange *inRange,
nsCOMPtr<nsIDOMNode> opStartNode;
nsCOMPtr<nsIDOMNode> opEndNode;
int32_t opStartOffset, opEndOffset;
nsCOMPtr<nsIDOMRange> opRange;
nsRefPtr<nsRange> opRange;
GetPromotedPoint(kStart, startNode, startOffset, inOperationType,
address_of(opStartNode), &opStartOffset);
@ -5947,15 +5930,15 @@ private:
// a new array of nodes to be acted on.
//
nsresult
nsHTMLEditRules::GetNodesForOperation(nsCOMArray<nsIDOMRange>& inArrayOfRanges,
nsHTMLEditRules::GetNodesForOperation(nsTArray<nsRefPtr<nsRange>>& inArrayOfRanges,
nsCOMArray<nsIDOMNode>& outArrayOfNodes,
EditAction inOperationType,
bool aDontTouchContent)
{
int32_t rangeCount = inArrayOfRanges.Count();
int32_t rangeCount = inArrayOfRanges.Length();
int32_t i;
nsCOMPtr<nsIDOMRange> opRange;
nsRefPtr<nsRange> opRange;
nsresult res = NS_OK;
@ -5964,10 +5947,8 @@ nsHTMLEditRules::GetNodesForOperation(nsCOMArray<nsIDOMRange>& inArrayOfRanges,
if (!aDontTouchContent)
{
nsTArray<nsRefPtr<nsRangeStore> > rangeItemArray;
if (!rangeItemArray.AppendElements(rangeCount)) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsTArray<nsRefPtr<nsRangeStore>> rangeItemArray;
rangeItemArray.AppendElements(rangeCount);
NS_ASSERTION(static_cast<uint32_t>(rangeCount) == rangeItemArray.Length(),
"How did that happen?");
@ -5977,10 +5958,10 @@ nsHTMLEditRules::GetNodesForOperation(nsCOMArray<nsIDOMRange>& inArrayOfRanges,
{
opRange = inArrayOfRanges[0];
rangeItemArray[i] = new nsRangeStore();
rangeItemArray[i]->StoreRange(static_cast<nsRange*>(opRange.get()));
rangeItemArray[i]->StoreRange(opRange);
NS_ENSURE_STATE(mHTMLEditor);
mHTMLEditor->mRangeUpdater.RegisterRangeItem(rangeItemArray[i]);
inArrayOfRanges.RemoveObjectAt(0);
inArrayOfRanges.RemoveElementAt(0);
}
// now bust up inlines. Safe to start at rangeCount-1, since we
// asserted we have enough items above.
@ -5995,7 +5976,7 @@ nsHTMLEditRules::GetNodesForOperation(nsCOMArray<nsIDOMRange>& inArrayOfRanges,
NS_ENSURE_STATE(mHTMLEditor);
mHTMLEditor->mRangeUpdater.DropRangeItem(item);
opRange = item->GetRange();
inArrayOfRanges.AppendObject(opRange);
inArrayOfRanges.AppendElement(opRange);
}
NS_ENSURE_SUCCESS(res, res);
}
@ -6510,10 +6491,10 @@ nsHTMLEditRules::GetNodesFromPoint(::DOMPoint point,
NS_ENSURE_SUCCESS(res, res);
// make array of ranges
nsCOMArray<nsIDOMRange> arrayOfRanges;
nsTArray<nsRefPtr<nsRange>> arrayOfRanges;
// stuff new opRange into array
arrayOfRanges.AppendObject(range);
arrayOfRanges.AppendElement(range);
// use these ranges to contruct a list of nodes to act on.
res = GetNodesForOperation(arrayOfRanges, arrayOfNodes, operation, dontTouchContent);
@ -6535,7 +6516,7 @@ nsHTMLEditRules::GetNodesFromSelection(Selection* selection,
nsresult res;
// promote selection ranges
nsCOMArray<nsIDOMRange> arrayOfRanges;
nsTArray<nsRefPtr<nsRange>> arrayOfRanges;
res = GetPromotedRanges(selection, arrayOfRanges, operation);
NS_ENSURE_SUCCESS(res, res);
@ -8556,7 +8537,7 @@ nsHTMLEditRules::ConfirmSelectionInBody()
nsresult
nsHTMLEditRules::UpdateDocChangeRange(nsIDOMRange *aRange)
nsHTMLEditRules::UpdateDocChangeRange(nsRange* aRange)
{
nsresult res = NS_OK;
@ -8576,9 +8557,7 @@ nsHTMLEditRules::UpdateDocChangeRange(nsIDOMRange *aRange)
if (!mDocChangeRange)
{
// clone aRange.
nsCOMPtr<nsIDOMRange> range;
res = aRange->CloneRange(getter_AddRefs(range));
mDocChangeRange = static_cast<nsRange*>(range.get());
mDocChangeRange = aRange->CloneRange();
}
else
{
@ -9184,7 +9163,7 @@ nsHTMLEditRules::WillAbsolutePosition(Selection* aSelection,
// block parent, and then further expands to include any ancestors
// whose children are all in the range
nsCOMArray<nsIDOMRange> arrayOfRanges;
nsTArray<nsRefPtr<nsRange>> arrayOfRanges;
res = GetPromotedRanges(aSelection, arrayOfRanges,
EditAction::setAbsolutePosition);
NS_ENSURE_SUCCESS(res, res);

View File

@ -25,7 +25,6 @@ class nsIDOMCharacterData;
class nsIDOMDocument;
class nsIDOMElement;
class nsIDOMNode;
class nsIDOMRange;
class nsIEditor;
class nsINode;
class nsPlaintextEditor;
@ -266,11 +265,10 @@ protected:
int32_t aOffset, EditAction actionID,
nsCOMPtr<nsIDOMNode>* outNode, int32_t* outOffset);
nsresult GetPromotedRanges(mozilla::dom::Selection* aSelection,
nsCOMArray<nsIDOMRange> &outArrayOfRanges,
nsTArray<nsRefPtr<nsRange>>& outArrayOfRanges,
EditAction inOperationType);
nsresult PromoteRange(nsIDOMRange *inRange,
EditAction inOperationType);
nsresult GetNodesForOperation(nsCOMArray<nsIDOMRange>& inArrayOfRanges,
nsresult PromoteRange(nsRange* inRange, EditAction inOperationType);
nsresult GetNodesForOperation(nsTArray<nsRefPtr<nsRange>>& inArrayOfRanges,
nsCOMArray<nsIDOMNode>& outArrayOfNodes,
EditAction inOperationType,
bool aDontTouchContent=false);
@ -331,7 +329,7 @@ protected:
bool InDifferentTableElements(nsINode* aNode1, nsINode* aNode2);
nsresult RemoveEmptyNodes();
nsresult SelectionEndpointInNode(nsINode *aNode, bool *aResult);
nsresult UpdateDocChangeRange(nsIDOMRange *aRange);
nsresult UpdateDocChangeRange(nsRange* aRange);
nsresult ConfirmSelectionInBody();
nsresult InsertMozBRIfNeeded(nsIDOMNode *aNode);
bool IsEmptyInline(nsIDOMNode *aNode);

View File

@ -42,7 +42,6 @@
#include "nsIContent.h"
#include "nsIContentIterator.h"
#include "nsIDOMRange.h"
#include "nsISupportsArray.h"
#include "nsContentUtils.h"
#include "nsIDocumentEncoder.h"
@ -2360,13 +2359,12 @@ nsHTMLEditor::GetSelectedElement(const nsAString& aTagName, nsIDOMElement** aRet
bool isNamedAnchorTag = IsNamedAnchorTag(TagName);
nsCOMPtr<nsIDOMElement> selectedElement;
nsCOMPtr<nsIDOMRange> range;
nsresult res = selection->GetRangeAt(0, getter_AddRefs(range));
NS_ENSURE_SUCCESS(res, res);
nsRefPtr<nsRange> range = selection->GetRangeAt(0);
NS_ENSURE_STATE(range);
nsCOMPtr<nsIDOMNode> startParent;
int32_t startOffset, endOffset;
res = range->GetStartContainer(getter_AddRefs(startParent));
nsresult res = range->GetStartContainer(getter_AddRefs(startParent));
NS_ENSURE_SUCCESS(res, res);
res = range->GetStartOffset(&startOffset);
NS_ENSURE_SUCCESS(res, res);
@ -3711,8 +3709,8 @@ nsHTMLEditor::GetEnclosingTable(nsIDOMNode *aNode)
* Uses nsEditor::JoinNodes so action is undoable.
* Should be called within the context of a batch transaction.
*/
NS_IMETHODIMP
nsHTMLEditor::CollapseAdjacentTextNodes(nsIDOMRange *aInRange)
nsresult
nsHTMLEditor::CollapseAdjacentTextNodes(nsRange* aInRange)
{
NS_ENSURE_TRUE(aInRange, NS_ERROR_NULL_POINTER);
nsAutoTxnsConserveSelection dontSpazMySelection(this);
@ -4971,9 +4969,7 @@ nsHTMLEditor::GetSelectionContainer(nsIDOMElement ** aReturn)
if (rangeCount == 1) {
nsCOMPtr<nsIDOMRange> range;
res = selection->GetRangeAt(0, getter_AddRefs(range));
NS_ENSURE_SUCCESS(res, res);
nsRefPtr<nsRange> range = selection->GetRangeAt(0);
NS_ENSURE_TRUE(range, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode> startContainer, endContainer;
@ -5001,11 +4997,11 @@ nsHTMLEditor::GetSelectionContainer(nsIDOMElement ** aReturn)
}
else {
int32_t i;
nsCOMPtr<nsIDOMRange> range;
nsRefPtr<nsRange> range;
for (i = 0; i < rangeCount; i++)
{
res = selection->GetRangeAt(i, getter_AddRefs(range));
NS_ENSURE_SUCCESS(res, res);
range = selection->GetRangeAt(i);
NS_ENSURE_STATE(range);
nsCOMPtr<nsIDOMNode> startContainer;
res = range->GetStartContainer(getter_AddRefs(startContainer));
if (NS_FAILED(res)) continue;

View File

@ -50,6 +50,8 @@ class nsIContentFilter;
class nsIURL;
class nsILinkHandler;
class nsTableOuterFrame;
class nsIDOMRange;
class nsRange;
struct PropItem;
namespace mozilla {
@ -205,7 +207,7 @@ public:
nsIDOMElement** aTableElement);
NS_IMETHOD GetSelectedCellsType(nsIDOMElement *aElement, uint32_t *aSelectionType);
nsresult GetCellFromRange(nsIDOMRange *aRange, nsIDOMElement **aCell);
nsresult GetCellFromRange(nsRange* aRange, nsIDOMElement** aCell);
// Finds the first selected cell in first range of selection
// This is in the *order of selection*, not order in the table
@ -303,7 +305,7 @@ public:
bool aSuppressTransaction);
/** join together any adjacent editable text nodes in the range */
NS_IMETHOD CollapseAdjacentTextNodes(nsIDOMRange *aInRange);
nsresult CollapseAdjacentTextNodes(nsRange* aRange);
virtual bool AreNodesSameType(nsIContent* aNode1, nsIContent* aNode2)
MOZ_OVERRIDE;
@ -659,9 +661,9 @@ protected:
const nsAString* aAttribute,
const nsAString* aValue);
nsresult PromoteInlineRange(nsIDOMRange *inRange);
nsresult PromoteRangeIfStartsOrEndsInNamedAnchor(nsIDOMRange *inRange);
nsresult SplitStyleAboveRange(nsIDOMRange *aRange,
nsresult PromoteInlineRange(nsRange* aRange);
nsresult PromoteRangeIfStartsOrEndsInNamedAnchor(nsRange* aRange);
nsresult SplitStyleAboveRange(nsRange* aRange,
nsIAtom *aProperty,
const nsAString *aAttribute);
nsresult SplitStyleAbovePoint(nsCOMPtr<nsIDOMNode> *aNode,

View File

@ -16,13 +16,13 @@
#include "nsIDOMEventTarget.h"
#include "nsIDOMMouseEvent.h"
#include "nsIDOMNode.h"
#include "nsIDOMRange.h"
#include "nsIEditor.h"
#include "nsIHTMLEditor.h"
#include "nsIHTMLInlineTableEditor.h"
#include "nsIHTMLObjectResizer.h"
#include "nsISupportsImpl.h"
#include "nsLiteralString.h"
#include "nsRange.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -123,10 +123,8 @@ nsHTMLEditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent)
NS_ENSURE_SUCCESS(rv, rv);
for (int32_t i = 0; i < rangeCount; i++) {
nsCOMPtr<nsIDOMRange> range;
rv = selection->GetRangeAt(i, getter_AddRefs(range));
if (NS_FAILED(rv) || !range) {
nsRefPtr<nsRange> range = selection->GetRangeAt(i);
if (!range) {
// Don't bail yet, iterate through them all
continue;
}

View File

@ -29,13 +29,13 @@
#include "nsIDOMCharacterData.h"
#include "nsIDOMElement.h"
#include "nsIDOMNode.h"
#include "nsIDOMRange.h"
#include "nsIEditor.h"
#include "nsIEditorIMESupport.h"
#include "nsNameSpaceManager.h"
#include "nsINode.h"
#include "nsISupportsImpl.h"
#include "nsLiteralString.h"
#include "nsRange.h"
#include "nsReadableUtils.h"
#include "nsSelectionState.h"
#include "nsString.h"
@ -578,9 +578,9 @@ nsHTMLEditor::SetInlinePropertyOnNode(nsIContent* aNode,
}
nsresult nsHTMLEditor::SplitStyleAboveRange(nsIDOMRange *inRange,
nsIAtom *aProperty,
const nsAString *aAttribute)
nsresult
nsHTMLEditor::SplitStyleAboveRange(nsRange* inRange, nsIAtom* aProperty,
const nsAString* aAttribute)
{
NS_ENSURE_TRUE(inRange, NS_ERROR_NULL_POINTER);
nsresult res;
@ -948,7 +948,8 @@ bool nsHTMLEditor::HasAttr(nsIDOMNode* aNode,
}
nsresult nsHTMLEditor::PromoteRangeIfStartsOrEndsInNamedAnchor(nsIDOMRange *inRange)
nsresult
nsHTMLEditor::PromoteRangeIfStartsOrEndsInNamedAnchor(nsRange* inRange)
{
NS_ENSURE_TRUE(inRange, NS_ERROR_NULL_POINTER);
nsresult res;
@ -1002,7 +1003,8 @@ nsresult nsHTMLEditor::PromoteRangeIfStartsOrEndsInNamedAnchor(nsIDOMRange *inRa
return res;
}
nsresult nsHTMLEditor::PromoteInlineRange(nsIDOMRange *inRange)
nsresult
nsHTMLEditor::PromoteInlineRange(nsRange* inRange)
{
NS_ENSURE_TRUE(inRange, NS_ERROR_NULL_POINTER);
nsresult res;

View File

@ -22,7 +22,6 @@
#include "nsIDOMDragEvent.h"
#include "nsIDOMEvent.h"
#include "nsIDOMNode.h"
#include "nsIDOMRange.h"
#include "nsIDOMUIEvent.h"
#include "nsIDocument.h"
#include "nsIDragService.h"
@ -39,6 +38,7 @@
#include "nsIVariant.h"
#include "nsLiteralString.h"
#include "nsPlaintextEditor.h"
#include "nsRange.h"
#include "nsSelectionState.h"
#include "nsServiceManagerUtils.h"
#include "nsString.h"
@ -256,10 +256,11 @@ nsresult nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
for (int32_t j = 0; j < rangeCount; j++)
{
nsCOMPtr<nsIDOMRange> range;
rv = selection->GetRangeAt(j, getter_AddRefs(range));
if (NS_FAILED(rv) || !range)
continue; // don't bail yet, iterate through them all
nsRefPtr<nsRange> range = selection->GetRangeAt(j);
if (!range) {
// don't bail yet, iterate through them all
continue;
}
rv = range->IsPointInRange(newSelectionParent, newSelectionOffset, &cursorIsInSelection);
if (cursorIsInSelection)

View File

@ -15,7 +15,6 @@
#include "nsIContent.h" // for nsIContent
#include "nsIDOMCharacterData.h" // for nsIDOMCharacterData
#include "nsIDOMNode.h" // for nsIDOMNode
#include "nsIDOMRange.h" // for nsIDOMRange, etc
#include "nsISupportsImpl.h" // for nsRange::Release
#include "nsRange.h" // for nsRange
#include "nsSelectionState.h"
@ -149,7 +148,7 @@ nsSelectionState::IsEmpty()
}
/***************************************************************************
* nsRangeUpdater: class for updating nsIDOMRanges in response to editor actions.
* nsRangeUpdater: class for updating nsRanges in response to editor actions.
*/
nsRangeUpdater::nsRangeUpdater() : mArray(), mLock(false) {}

View File

@ -14,7 +14,6 @@
class nsCycleCollectionTraversalCallback;
class nsIDOMCharacterData;
class nsIDOMRange;
class nsRange;
namespace mozilla {
namespace dom {

View File

@ -22,7 +22,6 @@
#include "nsIContent.h"
#include "nsIDOMElement.h"
#include "nsIDOMNode.h"
#include "nsIDOMRange.h"
#include "nsIEditor.h"
#include "nsIFrame.h"
#include "nsIHTMLEditor.h"
@ -33,6 +32,7 @@
#include "nsITableEditor.h"
#include "nsLiteralString.h"
#include "nsQueryFrame.h"
#include "nsRange.h"
#include "nsString.h"
#include "nsTArray.h"
#include "nsTableCellFrame.h"
@ -2214,12 +2214,11 @@ nsHTMLEditor::JoinTableCells(bool aMergeNonContiguousContents)
res = selection->GetRangeCount(&rangeCount);
NS_ENSURE_SUCCESS(res, res);
nsCOMPtr<nsIDOMRange> range;
nsRefPtr<nsRange> range;
int32_t i;
for (i = 0; i < rangeCount; i++)
{
res = selection->GetRangeAt(i, getter_AddRefs(range));
NS_ENSURE_SUCCESS(res, res);
range = selection->GetRangeAt(i);
NS_ENSURE_TRUE(range, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMElement> deletedCell;
@ -2877,7 +2876,7 @@ nsHTMLEditor::GetCellContext(Selection** aSelection,
}
nsresult
nsHTMLEditor::GetCellFromRange(nsIDOMRange *aRange, nsIDOMElement **aCell)
nsHTMLEditor::GetCellFromRange(nsRange* aRange, nsIDOMElement** aCell)
{
// Note: this might return a node that is outside of the range.
// Use carefully.
@ -2936,14 +2935,12 @@ nsHTMLEditor::GetFirstSelectedCell(nsIDOMRange **aRange, nsIDOMElement **aCell)
nsRefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMRange> range;
nsresult res = selection->GetRangeAt(0, getter_AddRefs(range));
NS_ENSURE_SUCCESS(res, res);
nsRefPtr<nsRange> range = selection->GetRangeAt(0);
NS_ENSURE_TRUE(range, NS_ERROR_FAILURE);
mSelectedCellIndex = 0;
res = GetCellFromRange(range, aCell);
nsresult res = GetCellFromRange(range, aCell);
// Failure here probably means selection is in a text node,
// so there's no selected cell
if (NS_FAILED(res)) {
@ -2983,12 +2980,11 @@ nsHTMLEditor::GetNextSelectedCell(nsIDOMRange **aRange, nsIDOMElement **aCell)
return NS_EDITOR_ELEMENT_NOT_FOUND;
// Scan through ranges to find next valid selected cell
nsCOMPtr<nsIDOMRange> range;
nsRefPtr<nsRange> range;
nsresult res;
for (; mSelectedCellIndex < rangeCount; mSelectedCellIndex++)
{
res = selection->GetRangeAt(mSelectedCellIndex, getter_AddRefs(range));
NS_ENSURE_SUCCESS(res, res);
range = selection->GetRangeAt(mSelectedCellIndex);
NS_ENSURE_TRUE(range, NS_ERROR_FAILURE);
res = GetCellFromRange(range, aCell);

View File

@ -13,7 +13,6 @@
#include "nsIContent.h"
#include "nsIContentIterator.h"
#include "nsIDOMNode.h"
#include "nsIDOMRange.h"
#include "nsINode.h"
#include "nsISupportsBase.h"
#include "nsISupportsUtils.h"
@ -86,14 +85,11 @@ nsFilteredContentIterator::Init(nsIDOMRange* aRange)
mDirection = eForward;
mCurrentIterator = mPreIterator;
nsCOMPtr<nsIDOMRange> domRange;
nsresult rv = aRange->CloneRange(getter_AddRefs(domRange));
NS_ENSURE_SUCCESS(rv, rv);
mRange = do_QueryInterface(domRange);
mRange = static_cast<nsRange*>(aRange)->CloneRange();
rv = mPreIterator->Init(domRange);
nsresult rv = mPreIterator->Init(mRange);
NS_ENSURE_SUCCESS(rv, rv);
return mIterator->Init(domRange);
return mIterator->Init(mRange);
}
//------------------------------------------------------------
@ -237,7 +233,7 @@ ContentIsInTraversalRange(nsIContent *aContent, bool aIsPreMode,
}
static bool
ContentIsInTraversalRange(nsIDOMRange *aRange, nsIDOMNode* aNextNode, bool aIsPreMode)
ContentIsInTraversalRange(nsRange* aRange, nsIDOMNode* aNextNode, bool aIsPreMode)
{
nsCOMPtr<nsIContent> content(do_QueryInterface(aNextNode));
NS_ENSURE_TRUE(content && aRange, false);

View File

@ -17,6 +17,7 @@ class nsIDOMNode;
class nsIDOMRange;
class nsINode;
class nsITextServicesFilter;
class nsRange;
class nsFilteredContentIterator MOZ_FINAL : public nsIContentIterator
{
@ -65,7 +66,7 @@ protected:
nsCOMPtr<nsIAtom> mMapAtom;
nsCOMPtr<nsITextServicesFilter> mFilter;
nsCOMPtr<nsIDOMRange> mRange;
nsRefPtr<nsRange> mRange;
bool mDidSkip;
bool mIsOutOfRange;
eDirectionType mDirection;

View File

@ -6,6 +6,7 @@
#include <stddef.h> // for nullptr
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/dom/Selection.h"
#include "mozilla/mozalloc.h" // for operator new, etc
#include "nsAString.h" // for nsAString_internal::Length, etc
#include "nsAutoPtr.h" // for nsRefPtr
@ -42,6 +43,7 @@
#define UNLOCK_DOC(doc)
using namespace mozilla;
using namespace mozilla::dom;
class OffsetEntry
{
@ -234,17 +236,11 @@ nsTextServicesDocument::SetExtent(nsIDOMRange* aDOMRange)
// We need to store a copy of aDOMRange since we don't
// know where it came from.
nsresult result = aDOMRange->CloneRange(getter_AddRefs(mExtent));
if (NS_FAILED(result))
{
UNLOCK_DOC(this);
return result;
}
mExtent = static_cast<nsRange*>(aDOMRange)->CloneRange();
// Create a new iterator based on our new extent range.
result = CreateContentIterator(mExtent, getter_AddRefs(mIterator));
nsresult result = CreateContentIterator(mExtent, getter_AddRefs(mIterator));
if (NS_FAILED(result))
{
@ -268,14 +264,14 @@ NS_IMETHODIMP
nsTextServicesDocument::ExpandRangeToWordBoundaries(nsIDOMRange *aRange)
{
NS_ENSURE_ARG_POINTER(aRange);
nsRefPtr<nsRange> range = static_cast<nsRange*>(aRange);
// Get the end points of the range.
nsCOMPtr<nsIDOMNode> rngStartNode, rngEndNode;
int32_t rngStartOffset, rngEndOffset;
nsresult result = GetRangeEndPoints(aRange,
getter_AddRefs(rngStartNode),
nsresult result = GetRangeEndPoints(range, getter_AddRefs(rngStartNode),
&rngStartOffset,
getter_AddRefs(rngEndNode),
&rngEndOffset);
@ -285,7 +281,7 @@ nsTextServicesDocument::ExpandRangeToWordBoundaries(nsIDOMRange *aRange)
// Create a content iterator based on the range.
nsCOMPtr<nsIContentIterator> iter;
result = CreateContentIterator(aRange, getter_AddRefs(iter));
result = CreateContentIterator(range, getter_AddRefs(iter));
NS_ENSURE_SUCCESS(result, result);
@ -425,10 +421,10 @@ nsTextServicesDocument::ExpandRangeToWordBoundaries(nsIDOMRange *aRange)
// Now adjust the range so that it uses our new
// end points.
result = aRange->SetEnd(rngEndNode, rngEndOffset);
result = range->SetEnd(rngEndNode, rngEndOffset);
NS_ENSURE_SUCCESS(result, result);
return aRange->SetStart(rngStartNode, rngStartOffset);
return range->SetStart(rngStartNode, rngStartOffset);
}
NS_IMETHODIMP
@ -519,27 +515,21 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsISelection> selection;
bool isCollapsed = false;
result = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
nsCOMPtr<nsISelection> domSelection;
result = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
getter_AddRefs(domSelection));
if (NS_FAILED(result))
{
UNLOCK_DOC(this);
return result;
}
result = selection->GetIsCollapsed(&isCollapsed);
nsRefPtr<Selection> selection = static_cast<Selection*>(domSelection.get());
if (NS_FAILED(result))
{
UNLOCK_DOC(this);
return result;
}
bool isCollapsed = selection->IsCollapsed();
nsCOMPtr<nsIContentIterator> iter;
nsCOMPtr<nsIDOMRange> range;
nsRefPtr<nsRange> range;
nsCOMPtr<nsIDOMNode> parent;
int32_t i, rangeCount, offset;
@ -550,13 +540,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
// If the caret isn't in a text node, search forwards in
// the document, till we find a text node.
result = selection->GetRangeAt(0, getter_AddRefs(range));
if (NS_FAILED(result))
{
UNLOCK_DOC(this);
return result;
}
range = selection->GetRangeAt(0);
if (!range)
{
@ -769,10 +753,9 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
{
// Get the i'th range from the selection.
result = selection->GetRangeAt(i, getter_AddRefs(range));
range = selection->GetRangeAt(i);
if (NS_FAILED(result))
{
if (!range) {
UNLOCK_DOC(this);
return result;
}
@ -843,13 +826,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
// to the end of the document, then iterate forwards through
// it till you find a text node!
result = selection->GetRangeAt(rangeCount - 1, getter_AddRefs(range));
if (NS_FAILED(result))
{
UNLOCK_DOC(this);
return result;
}
range = selection->GetRangeAt(rangeCount - 1);
if (!range)
{
@ -1977,7 +1954,8 @@ nsTextServicesDocument::DidJoinNodes(nsIDOMNode *aLeftNode,
}
nsresult
nsTextServicesDocument::CreateContentIterator(nsIDOMRange *aRange, nsIContentIterator **aIterator)
nsTextServicesDocument::CreateContentIterator(nsRange* aRange,
nsIContentIterator** aIterator)
{
NS_ENSURE_TRUE(aRange && aIterator, NS_ERROR_NULL_POINTER);
@ -2043,7 +2021,7 @@ nsTextServicesDocument::GetDocumentContentRootNode(nsIDOMNode **aNode)
}
nsresult
nsTextServicesDocument::CreateDocumentContentRange(nsIDOMRange **aRange)
nsTextServicesDocument::CreateDocumentContentRange(nsRange** aRange)
{
*aRange = nullptr;
@ -2065,7 +2043,8 @@ nsTextServicesDocument::CreateDocumentContentRange(nsIDOMRange **aRange)
}
nsresult
nsTextServicesDocument::CreateDocumentContentRootToNodeOffsetRange(nsIDOMNode *aParent, int32_t aOffset, bool aToStart, nsIDOMRange **aRange)
nsTextServicesDocument::CreateDocumentContentRootToNodeOffsetRange(
nsIDOMNode* aParent, int32_t aOffset, bool aToStart, nsRange** aRange)
{
NS_ENSURE_TRUE(aParent && aRange, NS_ERROR_NULL_POINTER);
@ -2116,7 +2095,7 @@ nsTextServicesDocument::CreateDocumentContentIterator(nsIContentIterator **aIter
NS_ENSURE_TRUE(aIterator, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMRange> range;
nsRefPtr<nsRange> range;
result = CreateDocumentContentRange(getter_AddRefs(range));
@ -2541,10 +2520,14 @@ nsTextServicesDocument::GetSelection(nsITextServicesDocument::TSDBlockSelectionS
nsresult
nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockSelectionStatus *aSelStatus, int32_t *aSelOffset, int32_t *aSelLength)
{
nsCOMPtr<nsISelection> selection;
nsresult result = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
nsCOMPtr<nsISelection> domSelection;
nsresult result =
mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
getter_AddRefs(domSelection));
NS_ENSURE_SUCCESS(result, result);
NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(domSelection, NS_ERROR_FAILURE);
nsRefPtr<Selection> selection = static_cast<Selection*>(domSelection.get());
// The calling function should have done the GetIsCollapsed()
// check already. Just assume it's collapsed!
@ -2569,9 +2552,8 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
int32_t eStartOffset = eStart->mNodeOffset;
int32_t eEndOffset = eEnd->mNodeOffset + eEnd->mLength;
nsCOMPtr<nsIDOMRange> range;
result = selection->GetRangeAt(0, getter_AddRefs(range));
NS_ENSURE_SUCCESS(result, result);
nsRefPtr<nsRange> range = selection->GetRangeAt(0);
NS_ENSURE_STATE(range);
nsCOMPtr<nsIDOMNode> domParent;
result = range->GetStartContainer(getter_AddRefs(domParent));
@ -2754,15 +2736,16 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc
{
nsresult result;
nsCOMPtr<nsISelection> selection;
nsCOMPtr<nsIDOMRange> range;
nsRefPtr<nsRange> range;
OffsetEntry *entry;
result = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
nsCOMPtr<nsISelection> domSelection;
result = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
getter_AddRefs(domSelection));
NS_ENSURE_SUCCESS(result, result);
NS_ENSURE_TRUE(domSelection, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
nsRefPtr<Selection> selection = static_cast<Selection*>(domSelection.get());
// It is assumed that the calling function has made sure that the
// selection is not collapsed, and that the input params to this
@ -2800,9 +2783,8 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc
for (i = 0; i < rangeCount; i++)
{
result = selection->GetRangeAt(i, getter_AddRefs(range));
NS_ENSURE_SUCCESS(result, result);
range = selection->GetRangeAt(i);
NS_ENSURE_STATE(range);
result = GetRangeEndPoints(range,
getter_AddRefs(startParent), &startOffset,
@ -3054,7 +3036,7 @@ nsTextServicesDocument::SelectionIsValid()
}
nsresult
nsTextServicesDocument::GetRangeEndPoints(nsIDOMRange *aRange,
nsTextServicesDocument::GetRangeEndPoints(nsRange* aRange,
nsIDOMNode **aStartParent, int32_t *aStartOffset,
nsIDOMNode **aEndParent, int32_t *aEndOffset)
{
@ -3087,7 +3069,7 @@ nsTextServicesDocument::GetRangeEndPoints(nsIDOMRange *aRange,
nsresult
nsTextServicesDocument::CreateRange(nsIDOMNode *aStartParent, int32_t aStartOffset,
nsIDOMNode *aEndParent, int32_t aEndOffset,
nsIDOMRange **aRange)
nsRange** aRange)
{
return nsRange::CreateRange(aStartParent, aStartOffset, aEndParent,
aEndOffset, aRange);
@ -3322,8 +3304,7 @@ nsresult
nsTextServicesDocument::CreateOffsetTable(nsTArray<OffsetEntry*> *aOffsetTable,
nsIContentIterator *aIterator,
TSDIteratorStatus *aIteratorStatus,
nsIDOMRange *aIterRange,
nsString *aStr)
nsRange* aIterRange, nsString* aStr)
{
nsresult result = NS_OK;

View File

@ -83,7 +83,7 @@ private:
int32_t mSelEndIndex;
int32_t mSelEndOffset;
nsCOMPtr<nsIDOMRange> mExtent;
nsRefPtr<nsRange> mExtent;
nsCOMPtr<nsITextServicesFilter> mTxtSvcFilter;
@ -160,17 +160,25 @@ public:
NS_IMETHOD DidDeleteSelection(nsISelection *aSelection);
/* Helper functions */
static nsresult GetRangeEndPoints(nsIDOMRange *aRange, nsIDOMNode **aParent1, int32_t *aOffset1, nsIDOMNode **aParent2, int32_t *aOffset2);
static nsresult CreateRange(nsIDOMNode *aStartParent, int32_t aStartOffset, nsIDOMNode *aEndParent, int32_t aEndOffset, nsIDOMRange **aRange);
static nsresult GetRangeEndPoints(nsRange* aRange, nsIDOMNode** aParent1,
int32_t* aOffset1, nsIDOMNode** aParent2,
int32_t* aOffset2);
static nsresult CreateRange(nsIDOMNode* aStartParent, int32_t aStartOffset,
nsIDOMNode* aEndParent, int32_t aEndOffset,
nsRange** aRange);
private:
/* nsTextServicesDocument private methods. */
nsresult CreateContentIterator(nsIDOMRange *aRange, nsIContentIterator **aIterator);
nsresult CreateContentIterator(nsRange* aRange,
nsIContentIterator** aIterator);
nsresult GetDocumentContentRootNode(nsIDOMNode **aNode);
nsresult CreateDocumentContentRange(nsIDOMRange **aRange);
nsresult CreateDocumentContentRootToNodeOffsetRange(nsIDOMNode *aParent, int32_t aOffset, bool aToStart, nsIDOMRange **aRange);
nsresult CreateDocumentContentRange(nsRange** aRange);
nsresult CreateDocumentContentRootToNodeOffsetRange(nsIDOMNode* aParent,
int32_t aOffset,
bool aToStart,
nsRange** aRange);
nsresult CreateDocumentContentIterator(nsIContentIterator **aIterator);
nsresult AdjustContentIterator();
@ -205,8 +213,7 @@ private:
static nsresult CreateOffsetTable(nsTArray<OffsetEntry*> *aOffsetTable,
nsIContentIterator *aIterator,
TSDIteratorStatus *aIteratorStatus,
nsIDOMRange *aIterRange,
nsString *aStr);
nsRange* aIterRange, nsString* aStr);
static nsresult ClearOffsetTable(nsTArray<OffsetEntry*> *aOffsetTable);
static nsresult NodeHasOffsetEntry(nsTArray<OffsetEntry*> *aOffsetTable,