From 8ac3f6520d54b78fb1677fdebf9b5331f617b475 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Wed, 12 Jul 2017 00:09:37 +0900 Subject: [PATCH] Bug 1377989 - part9: Rename aEndParent and aEndNode related to nsRange to aEndContainer r=smaug MozReview-Commit-ID: 8XJbHfsg2hu --HG-- extra : rebase_source : 0ee22f0b0cf5fd8c0a8fea610c54be8492436488 --- dom/base/nsContentIterator.cpp | 14 ++--- dom/base/nsRange.cpp | 58 +++++++++++---------- dom/base/nsRange.h | 13 ++--- editor/libeditor/EditorBase.cpp | 16 +++--- editor/libeditor/EditorBase.h | 6 +-- editor/libeditor/HTMLEditor.h | 2 +- editor/libeditor/HTMLEditorDataTransfer.cpp | 6 +-- editor/txtsvc/nsFilteredContentIterator.cpp | 6 +-- editor/txtsvc/nsTextServicesDocument.cpp | 12 ++--- editor/txtsvc/nsTextServicesDocument.h | 6 +-- 10 files changed, 72 insertions(+), 67 deletions(-) diff --git a/dom/base/nsContentIterator.cpp b/dom/base/nsContentIterator.cpp index 506c100cf339f..3b4b8515c070c 100644 --- a/dom/base/nsContentIterator.cpp +++ b/dom/base/nsContentIterator.cpp @@ -46,16 +46,16 @@ NodeToParentOffset(nsINode* aNode, int32_t* aOffset) static bool NodeIsInTraversalRange(nsINode* aNode, bool aIsPreMode, nsINode* aStartContainer, int32_t aStartOffset, - nsINode* aEndNode, int32_t aEndOffset) + nsINode* aEndContainer, int32_t aEndOffset) { - if (NS_WARN_IF(!aStartContainer) || NS_WARN_IF(!aEndNode) || + if (NS_WARN_IF(!aStartContainer) || NS_WARN_IF(!aEndContainer) || NS_WARN_IF(!aNode)) { return false; } // If a leaf node contains an end point of the traversal range, it is // always in the traversal range. - if (aNode == aStartContainer || aNode == aEndNode) { + if (aNode == aStartContainer || aNode == aEndContainer) { if (aNode->IsNodeOfType(nsINode::eDATA_NODE)) { return true; // text node or something } @@ -63,9 +63,9 @@ NodeIsInTraversalRange(nsINode* aNode, bool aIsPreMode, MOZ_ASSERT(aNode != aStartContainer || !aStartOffset, "aStartContainer doesn't have children and not a data node, " "aStartOffset should be 0"); - MOZ_ASSERT(aNode != aEndNode || !aEndOffset, - "aStartContainer doesn't have children and not a data node, " - "aStartOffset should be 0"); + MOZ_ASSERT(aNode != aEndContainer || !aEndOffset, + "aEndContainer doesn't have children and not a data node, " + "aEndOffset should be 0"); return true; } } @@ -84,7 +84,7 @@ NodeIsInTraversalRange(nsINode* aNode, bool aIsPreMode, return nsContentUtils::ComparePoints(aStartContainer, aStartOffset, parent, indx) <= 0 && - nsContentUtils::ComparePoints(aEndNode, aEndOffset, + nsContentUtils::ComparePoints(aEndContainer, aEndOffset, parent, indx) >= 0; } diff --git a/dom/base/nsRange.cpp b/dom/base/nsRange.cpp index 93b20b55d644e..cc9df0399c293 100644 --- a/dom/base/nsRange.cpp +++ b/dom/base/nsRange.cpp @@ -1061,12 +1061,12 @@ nsRange::GetStartOffset(ErrorResult& aRv) const } NS_IMETHODIMP -nsRange::GetEndContainer(nsIDOMNode** aEndParent) +nsRange::GetEndContainer(nsIDOMNode** aEndContainer) { if (!mIsPositioned) return NS_ERROR_NOT_INITIALIZED; - return CallQueryInterface(mEndContainer, aEndParent); + return CallQueryInterface(mEndContainer, aEndContainer); } nsINode* @@ -1388,9 +1388,9 @@ nsRange::SetEnd(nsINode* aContainer, int32_t aOffset) nsresult nsRange::SetStartAndEnd(nsINode* aStartContainer, int32_t aStartOffset, - nsINode* aEndParent, int32_t aEndOffset) + nsINode* aEndContainer, int32_t aEndOffset) { - if (NS_WARN_IF(!aStartContainer) || NS_WARN_IF(!aEndParent)) { + if (NS_WARN_IF(!aStartContainer) || NS_WARN_IF(!aEndContainer)) { return NS_ERROR_INVALID_ARG; } @@ -1402,46 +1402,49 @@ nsRange::SetStartAndEnd(nsINode* aStartContainer, int32_t aStartOffset, return NS_ERROR_DOM_INDEX_SIZE_ERR; } - if (aStartContainer == aEndParent) { - if (!IsValidOffset(aEndParent, aEndOffset)) { + if (aStartContainer == aEndContainer) { + if (!IsValidOffset(aEndContainer, aEndOffset)) { return NS_ERROR_DOM_INDEX_SIZE_ERR; } // If the end offset is less than the start offset, this should be // collapsed at the end offset. if (aStartOffset > aEndOffset) { - DoSetRange(aEndParent, aEndOffset, aEndParent, aEndOffset, newStartRoot); + DoSetRange(aEndContainer, aEndOffset, + aEndContainer, aEndOffset, newStartRoot); } else { DoSetRange(aStartContainer, aStartOffset, - aEndParent, aEndOffset, newStartRoot); + aEndContainer, aEndOffset, newStartRoot); } return NS_OK; } - nsINode* newEndRoot = IsValidBoundary(aEndParent); + nsINode* newEndRoot = IsValidBoundary(aEndContainer); if (!newEndRoot) { return NS_ERROR_DOM_INVALID_NODE_TYPE_ERR; } - if (!IsValidOffset(aEndParent, aEndOffset)) { + if (!IsValidOffset(aEndContainer, aEndOffset)) { return NS_ERROR_DOM_INDEX_SIZE_ERR; } // If they have different root, this should be collapsed at the end point. if (newStartRoot != newEndRoot) { - DoSetRange(aEndParent, aEndOffset, aEndParent, aEndOffset, newEndRoot); + DoSetRange(aEndContainer, aEndOffset, + aEndContainer, aEndOffset, newEndRoot); return NS_OK; } // If the end point is before the start point, this should be collapsed at // the end point. if (nsContentUtils::ComparePoints(aStartContainer, aStartOffset, - aEndParent, aEndOffset) == 1) { - DoSetRange(aEndParent, aEndOffset, aEndParent, aEndOffset, newEndRoot); + aEndContainer, aEndOffset) == 1) { + DoSetRange(aEndContainer, aEndOffset, + aEndContainer, aEndOffset, newEndRoot); return NS_OK; } // Otherwise, set the range as specified. DoSetRange(aStartContainer, aStartOffset, - aEndParent, aEndOffset, newStartRoot); + aEndContainer, aEndOffset, newStartRoot); return NS_OK; } @@ -1946,13 +1949,13 @@ CollapseRangeAfterDelete(nsRange* aRange) * * @param aStartContainer The original node we are trying to split. * @param aStartOffset The offset at which to split. - * @param aEndNode The second node. + * @param aEndContainer The second node. * @param aCloneAfterOriginal Set false if the original node should be the * latter one after split. */ static nsresult SplitDataNode(nsIDOMCharacterData* aStartContainer, uint32_t aStartOffset, - nsIDOMCharacterData** aEndNode, + nsIDOMCharacterData** aEndContainer, bool aCloneAfterOriginal = true) { nsresult rv; @@ -1964,7 +1967,7 @@ static nsresult SplitDataNode(nsIDOMCharacterData* aStartContainer, rv = dataNode->SplitData(aStartOffset, getter_AddRefs(newData), aCloneAfterOriginal); NS_ENSURE_SUCCESS(rv, rv); - return CallQueryInterface(newData, aEndNode); + return CallQueryInterface(newData, aEndContainer); } NS_IMETHODIMP @@ -3098,12 +3101,13 @@ nsRange::CollectClientRectsAndText(nsLayoutUtils::RectCallback* aCollector, nsRange* aRange, nsINode* aStartContainer, int32_t aStartOffset, - nsINode* aEndParent, int32_t aEndOffset, + nsINode* aEndContainer, + int32_t aEndOffset, bool aClampToEdge, bool aFlushLayout) { // Hold strong pointers across the flush nsCOMPtr startContainer = aStartContainer; - nsCOMPtr endContainer = aEndParent; + nsCOMPtr endContainer = aEndContainer; // Flush out layout so our frames are up to date. if (!aStartContainer->IsInUncomposedDoc()) { @@ -3621,14 +3625,14 @@ IsLastNonemptyRowGroupOfTable(nsIFrame* aFrame) void nsRange::GetInnerTextNoFlush(DOMString& aValue, ErrorResult& aError, nsIContent* aStartContainer, uint32_t aStartOffset, - nsIContent* aEndParent, uint32_t aEndOffset) + nsIContent* aEndContainer, uint32_t aEndOffset) { InnerTextAccumulator result(aValue); nsIContent* currentNode = aStartContainer; TreeTraversalState currentState = AFTER_NODE; if (aStartContainer->IsNodeOfType(nsINode::eTEXT)) { auto t = static_cast(aStartContainer); - if (aStartContainer == aEndParent) { + if (aStartContainer == aEndContainer) { AppendTransformedText(result, t, aStartOffset, aEndOffset); return; } @@ -3640,13 +3644,13 @@ nsRange::GetInnerTextNoFlush(DOMString& aValue, ErrorResult& aError, } } - nsIContent* endNode = aEndParent; + nsIContent* endNode = aEndContainer; TreeTraversalState endState = AFTER_NODE; - if (aEndParent->IsNodeOfType(nsINode::eTEXT)) { + if (aEndContainer->IsNodeOfType(nsINode::eTEXT)) { endState = AT_NODE; } else { - if (uint32_t(aEndOffset) < aEndParent->GetChildCount()) { - endNode = aEndParent->GetChildAt(aEndOffset); + if (uint32_t(aEndOffset) < aEndContainer->GetChildCount()) { + endNode = aEndContainer->GetChildAt(aEndOffset); endState = AT_NODE; } } @@ -3708,8 +3712,8 @@ nsRange::GetInnerTextNoFlush(DOMString& aValue, ErrorResult& aError, } } - if (aEndParent->IsNodeOfType(nsINode::eTEXT)) { - nsGenericDOMDataNode* t = static_cast(aEndParent); + if (aEndContainer->IsNodeOfType(nsINode::eTEXT)) { + nsGenericDOMDataNode* t = static_cast(aEndContainer); AppendTransformedText(result, t, 0, aEndOffset); } // Do not flush trailing line breaks! Required breaks at the end of the text diff --git a/dom/base/nsRange.h b/dom/base/nsRange.h index aad01353b9327..9f3b1556bcf6b 100644 --- a/dom/base/nsRange.h +++ b/dom/base/nsRange.h @@ -48,13 +48,13 @@ class nsRange final : public nsIDOMRange, explicit nsRange(nsINode* aNode); static nsresult CreateRange(nsIDOMNode* aStartContainer, int32_t aStartOffset, - nsIDOMNode* aEndParent, int32_t aEndOffset, + nsIDOMNode* aEndContainer, int32_t aEndOffset, nsRange** aRange); static nsresult CreateRange(nsIDOMNode* aStartContainer, int32_t aStartOffset, - nsIDOMNode* aEndParent, int32_t aEndOffset, + nsIDOMNode* aEndContainer, int32_t aEndOffset, nsIDOMRange** aRange); static nsresult CreateRange(nsINode* aStartContainer, int32_t aStartOffset, - nsINode* aEndParent, int32_t aEndOffset, + nsINode* aEndContainer, int32_t aEndOffset, nsRange** aRange); NS_DECL_CYCLE_COLLECTING_ISUPPORTS @@ -161,7 +161,7 @@ class nsRange final : public nsIDOMRange, * the range will be collapsed at the end point. */ nsresult SetStartAndEnd(nsINode* aStartContainer, int32_t aStartOffset, - nsINode* aEndParent, int32_t aEndOffset); + nsINode* aEndContainer, int32_t aEndOffset); /** * CollapseTo() works similar to call both SetStart() and SetEnd() with @@ -272,7 +272,7 @@ class nsRange final : public nsIDOMRange, mozilla::ErrorResult& aError, nsIContent* aStartContainer, uint32_t aStartOffset, - nsIContent* aEndParent, + nsIContent* aEndContainer, uint32_t aEndOffset); nsINode* GetParentObject() const { return mOwner; } @@ -328,7 +328,8 @@ class nsRange final : public nsIDOMRange, nsRange* aRange, nsINode* aStartContainer, int32_t aStartOffset, - nsINode* aEndParent, int32_t aEndOffset, + nsINode* aEndContainer, + int32_t aEndOffset, bool aClampToEdge, bool aFlushLayout); /** diff --git a/editor/libeditor/EditorBase.cpp b/editor/libeditor/EditorBase.cpp index 01decec529ba1..8dfef19280919 100644 --- a/editor/libeditor/EditorBase.cpp +++ b/editor/libeditor/EditorBase.cpp @@ -3862,14 +3862,14 @@ EditorBase::GetEndNodeAndOffset(Selection* aSelection, nsresult EditorBase::GetEndNodeAndOffset(Selection* aSelection, - nsINode** aEndNode, + nsINode** aEndContainer, int32_t* aEndOffset) { MOZ_ASSERT(aSelection); - MOZ_ASSERT(aEndNode); + MOZ_ASSERT(aEndContainer); MOZ_ASSERT(aEndOffset); - *aEndNode = nullptr; + *aEndContainer = nullptr; *aEndOffset = 0; NS_ENSURE_TRUE(aSelection->RangeCount(), NS_ERROR_FAILURE); @@ -3879,7 +3879,7 @@ EditorBase::GetEndNodeAndOffset(Selection* aSelection, NS_ENSURE_TRUE(range->IsPositioned(), NS_ERROR_FAILURE); - NS_IF_ADDREF(*aEndNode = range->GetEndContainer()); + NS_IF_ADDREF(*aEndContainer = range->GetEndContainer()); *aEndOffset = range->EndOffset(); return NS_OK; } @@ -4664,12 +4664,12 @@ EditorBase::CreateTxnForDeleteRange(nsRange* aRangeToDelete, nsresult EditorBase::CreateRange(nsIDOMNode* aStartContainer, int32_t aStartOffset, - nsIDOMNode* aEndParent, + nsIDOMNode* aEndContainer, int32_t aEndOffset, nsRange** aRange) { return nsRange::CreateRange(aStartContainer, aStartOffset, - aEndParent, aEndOffset, aRange); + aEndContainer, aEndOffset, aRange); } nsresult @@ -4818,14 +4818,14 @@ EditorBase::HandleInlineSpellCheck(EditAction action, int32_t previousSelectedOffset, nsIDOMNode* aStartContainer, int32_t aStartOffset, - nsIDOMNode* aEndNode, + nsIDOMNode* aEndContainer, int32_t aEndOffset) { // Have to cast action here because this method is from an IDL return mInlineSpellChecker ? mInlineSpellChecker->SpellCheckAfterEditorChange( (int32_t)action, aSelection, previousSelectedNode, previousSelectedOffset, - aStartContainer, aStartOffset, aEndNode, + aStartContainer, aStartOffset, aEndContainer, aEndOffset) : NS_OK; } diff --git a/editor/libeditor/EditorBase.h b/editor/libeditor/EditorBase.h index 3a910a40d6e4f..fb080b77f1a5e 100644 --- a/editor/libeditor/EditorBase.h +++ b/editor/libeditor/EditorBase.h @@ -812,7 +812,7 @@ class EditorBase : public nsIEditor nsIDOMNode** outEndNode, int32_t* outEndOffset); static nsresult GetEndNodeAndOffset(Selection* aSelection, - nsINode** aEndNode, + nsINode** aEndContainer, int32_t* aEndOffset); #if DEBUG_JOE static void DumpNode(nsIDOMNode* aNode, int32_t indent = 0); @@ -825,7 +825,7 @@ class EditorBase : public nsIEditor * Used by table cell selection methods. */ nsresult CreateRange(nsIDOMNode* aStartContainer, int32_t aStartOffset, - nsIDOMNode* aEndParent, int32_t aEndOffset, + nsIDOMNode* aEndContainer, int32_t aEndOffset, nsRange** aRange); /** @@ -867,7 +867,7 @@ class EditorBase : public nsIEditor int32_t previousSelectedOffset, nsIDOMNode* aStartContainer, int32_t aStartOffset, - nsIDOMNode* aEndNode, + nsIDOMNode* aEndContainer, int32_t aEndOffset); virtual already_AddRefed GetDOMEventTarget() = 0; diff --git a/editor/libeditor/HTMLEditor.h b/editor/libeditor/HTMLEditor.h index 02af5f8bfe0d1..2028b17cd45e0 100644 --- a/editor/libeditor/HTMLEditor.h +++ b/editor/libeditor/HTMLEditor.h @@ -650,7 +650,7 @@ class HTMLEditor final : public TextEditor nsTArray>& outNodeList, nsINode* aStartContainer, int32_t aStartOffset, - nsINode* aEndNode, + nsINode* aEndContainer, int32_t aEndOffset); nsresult CreateTagStack(nsTArray& aTagStack, nsIDOMNode* aNode); diff --git a/editor/libeditor/HTMLEditorDataTransfer.cpp b/editor/libeditor/HTMLEditorDataTransfer.cpp index f852cb3ee91da..a990f3043a66a 100644 --- a/editor/libeditor/HTMLEditorDataTransfer.cpp +++ b/editor/libeditor/HTMLEditorDataTransfer.cpp @@ -2229,7 +2229,7 @@ HTMLEditor::CreateListOfNodesToPaste( nsTArray>& outNodeList, nsINode* aStartContainer, int32_t aStartOffset, - nsINode* aEndNode, + nsINode* aEndContainer, int32_t aEndOffset) { // If no info was provided about the boundary between context and stream, @@ -2237,13 +2237,13 @@ HTMLEditor::CreateListOfNodesToPaste( if (!aStartContainer) { aStartContainer = &aFragment; aStartOffset = 0; - aEndNode = &aFragment; + aEndContainer = &aFragment; aEndOffset = aFragment.Length(); } RefPtr docFragRange; nsresult rv = nsRange::CreateRange(aStartContainer, aStartOffset, - aEndNode, aEndOffset, + aEndContainer, aEndOffset, getter_AddRefs(docFragRange)); MOZ_ASSERT(NS_SUCCEEDED(rv)); NS_ENSURE_SUCCESS(rv, ); diff --git a/editor/txtsvc/nsFilteredContentIterator.cpp b/editor/txtsvc/nsFilteredContentIterator.cpp index 04137971dc745..bf6aaa69afae3 100644 --- a/editor/txtsvc/nsFilteredContentIterator.cpp +++ b/editor/txtsvc/nsFilteredContentIterator.cpp @@ -211,9 +211,9 @@ ContentToParentOffset(nsIContent *aContent, nsIDOMNode **aParent, static bool ContentIsInTraversalRange(nsIContent *aContent, bool aIsPreMode, nsIDOMNode *aStartContainer, int32_t aStartOffset, - nsIDOMNode *aEndNode, int32_t aEndOffset) + nsIDOMNode *aEndContainer, int32_t aEndOffset) { - NS_ENSURE_TRUE(aStartContainer && aEndNode && aContent, false); + NS_ENSURE_TRUE(aStartContainer && aEndContainer && aContent, false); nsCOMPtr parentNode; int32_t indx = 0; @@ -228,7 +228,7 @@ ContentIsInTraversalRange(nsIContent *aContent, bool aIsPreMode, int32_t startRes = nsContentUtils::ComparePoints(aStartContainer, aStartOffset, parentNode, indx); - int32_t endRes = nsContentUtils::ComparePoints(aEndNode, aEndOffset, + int32_t endRes = nsContentUtils::ComparePoints(aEndContainer, aEndOffset, parentNode, indx); return (startRes <= 0) && (endRes >= 0); } diff --git a/editor/txtsvc/nsTextServicesDocument.cpp b/editor/txtsvc/nsTextServicesDocument.cpp index 9e3b006fafc8d..13df1178ebcae 100644 --- a/editor/txtsvc/nsTextServicesDocument.cpp +++ b/editor/txtsvc/nsTextServicesDocument.cpp @@ -2808,11 +2808,11 @@ nsresult nsTextServicesDocument::GetRangeEndPoints(nsRange* aRange, nsIDOMNode** aStartContainer, int32_t* aStartOffset, - nsIDOMNode** aEndParent, + nsIDOMNode** aEndContainer, int32_t* aEndOffset) { NS_ENSURE_TRUE(aRange && aStartContainer && aStartOffset && - aEndParent && aEndOffset, NS_ERROR_NULL_POINTER); + aEndContainer && aEndOffset, NS_ERROR_NULL_POINTER); nsresult rv = aRange->GetStartContainer(aStartContainer); @@ -2824,11 +2824,11 @@ nsTextServicesDocument::GetRangeEndPoints(nsRange* aRange, NS_ENSURE_SUCCESS(rv, rv); - rv = aRange->GetEndContainer(aEndParent); + rv = aRange->GetEndContainer(aEndContainer); NS_ENSURE_SUCCESS(rv, rv); - NS_ENSURE_TRUE(aEndParent, NS_ERROR_FAILURE); + NS_ENSURE_TRUE(aEndContainer, NS_ERROR_FAILURE); return aRange->GetEndOffset(aEndOffset); } @@ -2836,11 +2836,11 @@ nsTextServicesDocument::GetRangeEndPoints(nsRange* aRange, nsresult nsTextServicesDocument::CreateRange(nsIDOMNode* aStartContainer, int32_t aStartOffset, - nsIDOMNode* aEndParent, + nsIDOMNode* aEndContainer, int32_t aEndOffset, nsRange** aRange) { - return nsRange::CreateRange(aStartContainer, aStartOffset, aEndParent, + return nsRange::CreateRange(aStartContainer, aStartOffset, aEndContainer, aEndOffset, aRange); } diff --git a/editor/txtsvc/nsTextServicesDocument.h b/editor/txtsvc/nsTextServicesDocument.h index 8e4ac5bf3a62b..25da70a012569 100644 --- a/editor/txtsvc/nsTextServicesDocument.h +++ b/editor/txtsvc/nsTextServicesDocument.h @@ -163,10 +163,10 @@ class nsTextServicesDocument final : public nsITextServicesDocument, static nsresult GetRangeEndPoints(nsRange* aRange, nsIDOMNode** aStartContainer, int32_t* aStartOffset, - nsIDOMNode** aParent2, - int32_t* aOffset2); + nsIDOMNode** aEndContainer, + int32_t* aEndOffset); static nsresult CreateRange(nsIDOMNode* aStartContainer, int32_t aStartOffset, - nsIDOMNode* aEndParent, int32_t aEndOffset, + nsIDOMNode* aEndContainer, int32_t aEndOffset, nsRange** aRange); private: