Bug 1377989 - part8: Rename aStartParent and aStartNode related to nsRange to aStartContainer r=smaug

MozReview-Commit-ID: H3wzW7eaQBg

--HG--
extra : rebase_source : 90aa8e2a20a0de27a1598925d8c70186463333cf
This commit is contained in:
Masayuki Nakano 2017-07-11 23:10:42 +09:00
Родитель e756fe8300
Коммит 4af6e5d4a7
10 изменённых файлов: 93 добавлений и 81 удалений

Просмотреть файл

@ -45,25 +45,26 @@ NodeToParentOffset(nsINode* aNode, int32_t* aOffset)
//
static bool
NodeIsInTraversalRange(nsINode* aNode, bool aIsPreMode,
nsINode* aStartNode, int32_t aStartOffset,
nsINode* aStartContainer, int32_t aStartOffset,
nsINode* aEndNode, int32_t aEndOffset)
{
if (NS_WARN_IF(!aStartNode) || NS_WARN_IF(!aEndNode) || NS_WARN_IF(!aNode)) {
if (NS_WARN_IF(!aStartContainer) || NS_WARN_IF(!aEndNode) ||
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 == aStartNode || aNode == aEndNode) {
if (aNode == aStartContainer || aNode == aEndNode) {
if (aNode->IsNodeOfType(nsINode::eDATA_NODE)) {
return true; // text node or something
}
if (!aNode->HasChildren()) {
MOZ_ASSERT(aNode != aStartNode || !aStartOffset,
"aStartNode doesn't have children and not a data node, "
MOZ_ASSERT(aNode != aStartContainer || !aStartOffset,
"aStartContainer doesn't have children and not a data node, "
"aStartOffset should be 0");
MOZ_ASSERT(aNode != aEndNode || !aEndOffset,
"aStartNode doesn't have children and not a data node, "
"aStartContainer doesn't have children and not a data node, "
"aStartOffset should be 0");
return true;
}
@ -81,7 +82,7 @@ NodeIsInTraversalRange(nsINode* aNode, bool aIsPreMode,
++indx;
}
return nsContentUtils::ComparePoints(aStartNode, aStartOffset,
return nsContentUtils::ComparePoints(aStartContainer, aStartOffset,
parent, indx) <= 0 &&
nsContentUtils::ComparePoints(aEndNode, aEndOffset,
parent, indx) >= 0;

Просмотреть файл

@ -266,15 +266,15 @@ nsRange::nsRange(nsINode* aNode)
/* static */
nsresult
nsRange::CreateRange(nsINode* aStartParent, int32_t aStartOffset,
nsRange::CreateRange(nsINode* aStartContainer, int32_t aStartOffset,
nsINode* aEndParent, int32_t aEndOffset,
nsRange** aRange)
{
MOZ_ASSERT(aRange);
*aRange = nullptr;
RefPtr<nsRange> range = new nsRange(aStartParent);
nsresult rv = range->SetStartAndEnd(aStartParent, aStartOffset,
RefPtr<nsRange> range = new nsRange(aStartContainer);
nsresult rv = range->SetStartAndEnd(aStartContainer, aStartOffset,
aEndParent, aEndOffset);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -285,23 +285,23 @@ nsRange::CreateRange(nsINode* aStartParent, int32_t aStartOffset,
/* static */
nsresult
nsRange::CreateRange(nsIDOMNode* aStartParent, int32_t aStartOffset,
nsRange::CreateRange(nsIDOMNode* aStartContainer, int32_t aStartOffset,
nsIDOMNode* aEndParent, int32_t aEndOffset,
nsRange** aRange)
{
nsCOMPtr<nsINode> startParent = do_QueryInterface(aStartParent);
nsCOMPtr<nsINode> startParent = do_QueryInterface(aStartContainer);
nsCOMPtr<nsINode> endParent = do_QueryInterface(aEndParent);
return CreateRange(startParent, aStartOffset, endParent, aEndOffset, aRange);
}
/* static */
nsresult
nsRange::CreateRange(nsIDOMNode* aStartParent, int32_t aStartOffset,
nsRange::CreateRange(nsIDOMNode* aStartContainer, int32_t aStartOffset,
nsIDOMNode* aEndParent, int32_t aEndOffset,
nsIDOMRange** aRange)
{
RefPtr<nsRange> range;
nsresult rv = nsRange::CreateRange(aStartParent, aStartOffset, aEndParent,
nsresult rv = nsRange::CreateRange(aStartContainer, aStartOffset, aEndParent,
aEndOffset, getter_AddRefs(range));
range.forget(aRange);
return rv;
@ -1019,12 +1019,12 @@ nsRange::Reset()
******************************************************/
NS_IMETHODIMP
nsRange::GetStartContainer(nsIDOMNode** aStartParent)
nsRange::GetStartContainer(nsIDOMNode** aStartContainer)
{
if (!mIsPositioned)
return NS_ERROR_NOT_INITIALIZED;
return CallQueryInterface(mStartContainer, aStartParent);
return CallQueryInterface(mStartContainer, aStartContainer);
}
nsINode*
@ -1387,22 +1387,22 @@ nsRange::SetEnd(nsINode* aContainer, int32_t aOffset)
}
nsresult
nsRange::SetStartAndEnd(nsINode* aStartParent, int32_t aStartOffset,
nsRange::SetStartAndEnd(nsINode* aStartContainer, int32_t aStartOffset,
nsINode* aEndParent, int32_t aEndOffset)
{
if (NS_WARN_IF(!aStartParent) || NS_WARN_IF(!aEndParent)) {
if (NS_WARN_IF(!aStartContainer) || NS_WARN_IF(!aEndParent)) {
return NS_ERROR_INVALID_ARG;
}
nsINode* newStartRoot = IsValidBoundary(aStartParent);
nsINode* newStartRoot = IsValidBoundary(aStartContainer);
if (!newStartRoot) {
return NS_ERROR_DOM_INVALID_NODE_TYPE_ERR;
}
if (!IsValidOffset(aStartParent, aStartOffset)) {
if (!IsValidOffset(aStartContainer, aStartOffset)) {
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
if (aStartParent == aEndParent) {
if (aStartContainer == aEndParent) {
if (!IsValidOffset(aEndParent, aEndOffset)) {
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
@ -1411,7 +1411,7 @@ nsRange::SetStartAndEnd(nsINode* aStartParent, int32_t aStartOffset,
if (aStartOffset > aEndOffset) {
DoSetRange(aEndParent, aEndOffset, aEndParent, aEndOffset, newStartRoot);
} else {
DoSetRange(aStartParent, aStartOffset,
DoSetRange(aStartContainer, aStartOffset,
aEndParent, aEndOffset, newStartRoot);
}
return NS_OK;
@ -1433,14 +1433,15 @@ nsRange::SetStartAndEnd(nsINode* aStartParent, int32_t aStartOffset,
// If the end point is before the start point, this should be collapsed at
// the end point.
if (nsContentUtils::ComparePoints(aStartParent, aStartOffset,
if (nsContentUtils::ComparePoints(aStartContainer, aStartOffset,
aEndParent, aEndOffset) == 1) {
DoSetRange(aEndParent, aEndOffset, aEndParent, aEndOffset, newEndRoot);
return NS_OK;
}
// Otherwise, set the range as specified.
DoSetRange(aStartParent, aStartOffset, aEndParent, aEndOffset, newStartRoot);
DoSetRange(aStartContainer, aStartOffset,
aEndParent, aEndOffset, newStartRoot);
return NS_OK;
}
@ -1943,24 +1944,24 @@ CollapseRangeAfterDelete(nsRange* aRange)
/**
* Split a data node into two parts.
*
* @param aStartNode The original node we are trying to split.
* @param aStartIndex The index at which to split.
* @param aStartContainer The original node we are trying to split.
* @param aStartOffset The offset at which to split.
* @param aEndNode The second node.
* @param aCloneAfterOriginal Set false if the original node should be the
* latter one after split.
*/
static nsresult SplitDataNode(nsIDOMCharacterData* aStartNode,
uint32_t aStartIndex,
static nsresult SplitDataNode(nsIDOMCharacterData* aStartContainer,
uint32_t aStartOffset,
nsIDOMCharacterData** aEndNode,
bool aCloneAfterOriginal = true)
{
nsresult rv;
nsCOMPtr<nsINode> node = do_QueryInterface(aStartNode);
nsCOMPtr<nsINode> node = do_QueryInterface(aStartContainer);
NS_ENSURE_STATE(node && node->IsNodeOfType(nsINode::eDATA_NODE));
nsGenericDOMDataNode* dataNode = static_cast<nsGenericDOMDataNode*>(node.get());
nsCOMPtr<nsIContent> newData;
rv = dataNode->SplitData(aStartIndex, getter_AddRefs(newData),
rv = dataNode->SplitData(aStartOffset, getter_AddRefs(newData),
aCloneAfterOriginal);
NS_ENSURE_SUCCESS(rv, rv);
return CallQueryInterface(newData, aEndNode);
@ -3095,23 +3096,24 @@ static nsresult GetPartialTextRect(nsLayoutUtils::RectCallback* aCallback,
nsRange::CollectClientRectsAndText(nsLayoutUtils::RectCallback* aCollector,
Sequence<nsString>* aTextList,
nsRange* aRange,
nsINode* aStartParent, int32_t aStartOffset,
nsINode* aStartContainer,
int32_t aStartOffset,
nsINode* aEndParent, int32_t aEndOffset,
bool aClampToEdge, bool aFlushLayout)
{
// Hold strong pointers across the flush
nsCOMPtr<nsINode> startContainer = aStartParent;
nsCOMPtr<nsINode> startContainer = aStartContainer;
nsCOMPtr<nsINode> endContainer = aEndParent;
// Flush out layout so our frames are up to date.
if (!aStartParent->IsInUncomposedDoc()) {
if (!aStartContainer->IsInUncomposedDoc()) {
return;
}
if (aFlushLayout) {
aStartParent->OwnerDoc()->FlushPendingNotifications(FlushType::Layout);
aStartContainer->OwnerDoc()->FlushPendingNotifications(FlushType::Layout);
// Recheck whether we're still in the document
if (!aStartParent->IsInUncomposedDoc()) {
if (!aStartContainer->IsInUncomposedDoc()) {
return;
}
}
@ -3123,7 +3125,7 @@ nsRange::CollectClientRectsAndText(nsLayoutUtils::RectCallback* aCollector,
if (iter.IsDone()) {
// the range is collapsed, only continue if the cursor is in a text node
nsCOMPtr<nsIContent> content = do_QueryInterface(aStartParent);
nsCOMPtr<nsIContent> content = do_QueryInterface(aStartContainer);
if (content && content->IsNodeOfType(nsINode::eTEXT)) {
nsTextFrame* textFrame = GetTextFrameForContent(content, aFlushLayout);
if (textFrame) {
@ -3618,22 +3620,22 @@ IsLastNonemptyRowGroupOfTable(nsIFrame* aFrame)
void
nsRange::GetInnerTextNoFlush(DOMString& aValue, ErrorResult& aError,
nsIContent* aStartParent, uint32_t aStartOffset,
nsIContent* aStartContainer, uint32_t aStartOffset,
nsIContent* aEndParent, uint32_t aEndOffset)
{
InnerTextAccumulator result(aValue);
nsIContent* currentNode = aStartParent;
nsIContent* currentNode = aStartContainer;
TreeTraversalState currentState = AFTER_NODE;
if (aStartParent->IsNodeOfType(nsINode::eTEXT)) {
auto t = static_cast<nsGenericDOMDataNode*>(aStartParent);
if (aStartParent == aEndParent) {
if (aStartContainer->IsNodeOfType(nsINode::eTEXT)) {
auto t = static_cast<nsGenericDOMDataNode*>(aStartContainer);
if (aStartContainer == aEndParent) {
AppendTransformedText(result, t, aStartOffset, aEndOffset);
return;
}
AppendTransformedText(result, t, aStartOffset, t->TextLength());
} else {
if (uint32_t(aStartOffset) < aStartParent->GetChildCount()) {
currentNode = aStartParent->GetChildAt(aStartOffset);
if (uint32_t(aStartOffset) < aStartContainer->GetChildCount()) {
currentNode = aStartContainer->GetChildAt(aStartOffset);
currentState = AT_NODE;
}
}

Просмотреть файл

@ -47,13 +47,13 @@ class nsRange final : public nsIDOMRange,
public:
explicit nsRange(nsINode* aNode);
static nsresult CreateRange(nsIDOMNode* aStartParent, int32_t aStartOffset,
static nsresult CreateRange(nsIDOMNode* aStartContainer, int32_t aStartOffset,
nsIDOMNode* aEndParent, int32_t aEndOffset,
nsRange** aRange);
static nsresult CreateRange(nsIDOMNode* aStartParent, int32_t aStartOffset,
static nsresult CreateRange(nsIDOMNode* aStartContainer, int32_t aStartOffset,
nsIDOMNode* aEndParent, int32_t aEndOffset,
nsIDOMRange** aRange);
static nsresult CreateRange(nsINode* aStartParent, int32_t aStartOffset,
static nsresult CreateRange(nsINode* aStartContainer, int32_t aStartOffset,
nsINode* aEndParent, int32_t aEndOffset,
nsRange** aRange);
@ -160,7 +160,7 @@ public:
* collapsed at the end point. Similarly, if they are in different root,
* the range will be collapsed at the end point.
*/
nsresult SetStartAndEnd(nsINode* aStartParent, int32_t aStartOffset,
nsresult SetStartAndEnd(nsINode* aStartContainer, int32_t aStartOffset,
nsINode* aEndParent, int32_t aEndOffset);
/**
@ -270,7 +270,7 @@ public:
static void GetInnerTextNoFlush(mozilla::dom::DOMString& aValue,
mozilla::ErrorResult& aError,
nsIContent* aStartParent,
nsIContent* aStartContainer,
uint32_t aStartOffset,
nsIContent* aEndParent,
uint32_t aEndOffset);
@ -326,7 +326,8 @@ public:
static void CollectClientRectsAndText(nsLayoutUtils::RectCallback* aCollector,
mozilla::dom::Sequence<nsString>* aTextList,
nsRange* aRange,
nsINode* aStartParent, int32_t aStartOffset,
nsINode* aStartContainer,
int32_t aStartOffset,
nsINode* aEndParent, int32_t aEndOffset,
bool aClampToEdge, bool aFlushLayout);

Просмотреть файл

@ -3812,14 +3812,14 @@ EditorBase::GetStartNodeAndOffset(Selection* aSelection,
nsresult
EditorBase::GetStartNodeAndOffset(Selection* aSelection,
nsINode** aStartNode,
nsINode** aStartContainer,
int32_t* aStartOffset)
{
MOZ_ASSERT(aSelection);
MOZ_ASSERT(aStartNode);
MOZ_ASSERT(aStartContainer);
MOZ_ASSERT(aStartOffset);
*aStartNode = nullptr;
*aStartContainer = nullptr;
*aStartOffset = 0;
if (!aSelection->RangeCount()) {
@ -3831,7 +3831,7 @@ EditorBase::GetStartNodeAndOffset(Selection* aSelection,
NS_ENSURE_TRUE(range->IsPositioned(), NS_ERROR_FAILURE);
NS_IF_ADDREF(*aStartNode = range->GetStartContainer());
NS_IF_ADDREF(*aStartContainer = range->GetStartContainer());
*aStartOffset = range->StartOffset();
return NS_OK;
}
@ -4662,14 +4662,14 @@ EditorBase::CreateTxnForDeleteRange(nsRange* aRangeToDelete,
}
nsresult
EditorBase::CreateRange(nsIDOMNode* aStartParent,
EditorBase::CreateRange(nsIDOMNode* aStartContainer,
int32_t aStartOffset,
nsIDOMNode* aEndParent,
int32_t aEndOffset,
nsRange** aRange)
{
return nsRange::CreateRange(aStartParent, aStartOffset, aEndParent,
aEndOffset, aRange);
return nsRange::CreateRange(aStartContainer, aStartOffset,
aEndParent, aEndOffset, aRange);
}
nsresult
@ -4816,7 +4816,7 @@ EditorBase::HandleInlineSpellCheck(EditAction action,
Selection* aSelection,
nsIDOMNode* previousSelectedNode,
int32_t previousSelectedOffset,
nsIDOMNode* aStartNode,
nsIDOMNode* aStartContainer,
int32_t aStartOffset,
nsIDOMNode* aEndNode,
int32_t aEndOffset)
@ -4825,7 +4825,7 @@ EditorBase::HandleInlineSpellCheck(EditAction action,
return mInlineSpellChecker ? mInlineSpellChecker->SpellCheckAfterEditorChange(
(int32_t)action, aSelection,
previousSelectedNode, previousSelectedOffset,
aStartNode, aStartOffset, aEndNode,
aStartContainer, aStartOffset, aEndNode,
aEndOffset)
: NS_OK;
}

Просмотреть файл

@ -806,7 +806,7 @@ public:
nsIDOMNode** outStartNode,
int32_t* outStartOffset);
static nsresult GetStartNodeAndOffset(Selection* aSelection,
nsINode** aStartNode,
nsINode** aStartContainer,
int32_t* aStartOffset);
static nsresult GetEndNodeAndOffset(Selection* aSelection,
nsIDOMNode** outEndNode,
@ -824,7 +824,7 @@ public:
* Helpers to add a node to the selection.
* Used by table cell selection methods.
*/
nsresult CreateRange(nsIDOMNode* aStartParent, int32_t aStartOffset,
nsresult CreateRange(nsIDOMNode* aStartContainer, int32_t aStartOffset,
nsIDOMNode* aEndParent, int32_t aEndOffset,
nsRange** aRange);
@ -865,7 +865,7 @@ public:
Selection* aSelection,
nsIDOMNode* previousSelectedNode,
int32_t previousSelectedOffset,
nsIDOMNode* aStartNode,
nsIDOMNode* aStartContainer,
int32_t aStartOffset,
nsIDOMNode* aEndNode,
int32_t aEndOffset);

Просмотреть файл

@ -648,7 +648,7 @@ protected:
dom::DocumentFragment** aFragment, bool aTrustedInput);
void CreateListOfNodesToPaste(dom::DocumentFragment& aFragment,
nsTArray<OwningNonNull<nsINode>>& outNodeList,
nsINode* aStartNode,
nsINode* aStartContainer,
int32_t aStartOffset,
nsINode* aEndNode,
int32_t aEndOffset);

Просмотреть файл

@ -2227,22 +2227,22 @@ void
HTMLEditor::CreateListOfNodesToPaste(
DocumentFragment& aFragment,
nsTArray<OwningNonNull<nsINode>>& outNodeList,
nsINode* aStartNode,
nsINode* aStartContainer,
int32_t aStartOffset,
nsINode* aEndNode,
int32_t aEndOffset)
{
// If no info was provided about the boundary between context and stream,
// then assume all is stream.
if (!aStartNode) {
aStartNode = &aFragment;
if (!aStartContainer) {
aStartContainer = &aFragment;
aStartOffset = 0;
aEndNode = &aFragment;
aEndOffset = aFragment.Length();
}
RefPtr<nsRange> docFragRange;
nsresult rv = nsRange::CreateRange(aStartNode, aStartOffset,
nsresult rv = nsRange::CreateRange(aStartContainer, aStartOffset,
aEndNode, aEndOffset,
getter_AddRefs(docFragRange));
MOZ_ASSERT(NS_SUCCEEDED(rv));

Просмотреть файл

@ -210,10 +210,10 @@ ContentToParentOffset(nsIContent *aContent, nsIDOMNode **aParent,
//
static bool
ContentIsInTraversalRange(nsIContent *aContent, bool aIsPreMode,
nsIDOMNode *aStartNode, int32_t aStartOffset,
nsIDOMNode *aStartContainer, int32_t aStartOffset,
nsIDOMNode *aEndNode, int32_t aEndOffset)
{
NS_ENSURE_TRUE(aStartNode && aEndNode && aContent, false);
NS_ENSURE_TRUE(aStartContainer && aEndNode && aContent, false);
nsCOMPtr<nsIDOMNode> parentNode;
int32_t indx = 0;
@ -225,8 +225,9 @@ ContentIsInTraversalRange(nsIContent *aContent, bool aIsPreMode,
if (!aIsPreMode)
++indx;
int32_t startRes = nsContentUtils::ComparePoints(aStartNode, aStartOffset,
parentNode, indx);
int32_t startRes =
nsContentUtils::ComparePoints(aStartContainer, aStartOffset,
parentNode, indx);
int32_t endRes = nsContentUtils::ComparePoints(aEndNode, aEndOffset,
parentNode, indx);
return (startRes <= 0) && (endRes >= 0);

Просмотреть файл

@ -2806,16 +2806,19 @@ nsTextServicesDocument::SelectionIsValid()
nsresult
nsTextServicesDocument::GetRangeEndPoints(nsRange* aRange,
nsIDOMNode **aStartParent, int32_t *aStartOffset,
nsIDOMNode **aEndParent, int32_t *aEndOffset)
nsIDOMNode** aStartContainer,
int32_t* aStartOffset,
nsIDOMNode** aEndParent,
int32_t* aEndOffset)
{
NS_ENSURE_TRUE(aRange && aStartParent && aStartOffset && aEndParent && aEndOffset, NS_ERROR_NULL_POINTER);
NS_ENSURE_TRUE(aRange && aStartContainer && aStartOffset &&
aEndParent && aEndOffset, NS_ERROR_NULL_POINTER);
nsresult rv = aRange->GetStartContainer(aStartParent);
nsresult rv = aRange->GetStartContainer(aStartContainer);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(aStartParent, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(aStartContainer, NS_ERROR_FAILURE);
rv = aRange->GetStartOffset(aStartOffset);
@ -2831,11 +2834,13 @@ nsTextServicesDocument::GetRangeEndPoints(nsRange* aRange,
}
nsresult
nsTextServicesDocument::CreateRange(nsIDOMNode *aStartParent, int32_t aStartOffset,
nsIDOMNode *aEndParent, int32_t aEndOffset,
nsTextServicesDocument::CreateRange(nsIDOMNode* aStartContainer,
int32_t aStartOffset,
nsIDOMNode* aEndParent,
int32_t aEndOffset,
nsRange** aRange)
{
return nsRange::CreateRange(aStartParent, aStartOffset, aEndParent,
return nsRange::CreateRange(aStartContainer, aStartOffset, aEndParent,
aEndOffset, aRange);
}

Просмотреть файл

@ -160,10 +160,12 @@ public:
NS_IMETHOD DidDeleteSelection(nsISelection *aSelection) override;
/* Helper functions */
static nsresult GetRangeEndPoints(nsRange* aRange, nsIDOMNode** aParent1,
int32_t* aOffset1, nsIDOMNode** aParent2,
static nsresult GetRangeEndPoints(nsRange* aRange,
nsIDOMNode** aStartContainer,
int32_t* aStartOffset,
nsIDOMNode** aParent2,
int32_t* aOffset2);
static nsresult CreateRange(nsIDOMNode* aStartParent, int32_t aStartOffset,
static nsresult CreateRange(nsIDOMNode* aStartContainer, int32_t aStartOffset,
nsIDOMNode* aEndParent, int32_t aEndOffset,
nsRange** aRange);