mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 23:23:33 +00:00
Bug 1395080 - Part 2. Replace nsIDOMRange::GetStartOffset and nsIDOMRange::GetEndOffset with nsRange::StartOffset and nsRange::EndOffset. r=masayuki
MozReview-Commit-ID: 4wja9Lu53IR --HG-- extra : rebase_source : 2fa7f89435645dbc90d39089b2856612bd71dfdf
This commit is contained in:
parent
c171902197
commit
09107665a4
@ -464,8 +464,8 @@ HTMLEditRules::AfterEditInner(EditAction action,
|
||||
if (mDocChangeRange) {
|
||||
mDocChangeRange->GetStartContainer(getter_AddRefs(rangeStartContainer));
|
||||
mDocChangeRange->GetEndContainer(getter_AddRefs(rangeEndContainer));
|
||||
mDocChangeRange->GetStartOffset(&rangeStartOffset);
|
||||
mDocChangeRange->GetEndOffset(&rangeEndOffset);
|
||||
rangeStartOffset = mDocChangeRange->StartOffset();
|
||||
rangeEndOffset = mDocChangeRange->EndOffset();
|
||||
if (rangeStartContainer && rangeEndContainer) {
|
||||
bDamagedRange = true;
|
||||
}
|
||||
@ -8180,10 +8180,7 @@ HTMLEditRules::UpdateDocChangeRange(nsRange* aRange)
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// Positive result means mDocChangeRange start is after aRange start.
|
||||
if (result > 0) {
|
||||
uint32_t startOffset;
|
||||
rv = aRange->GetStartOffset(&startOffset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = mDocChangeRange->SetStart(startNode, startOffset);
|
||||
rv = mDocChangeRange->SetStart(startNode, aRange->StartOffset());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
@ -8196,10 +8193,7 @@ HTMLEditRules::UpdateDocChangeRange(nsRange* aRange)
|
||||
nsCOMPtr<nsIDOMNode> endNode;
|
||||
rv = aRange->GetEndContainer(getter_AddRefs(endNode));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
uint32_t endOffset;
|
||||
rv = aRange->GetEndOffset(&endOffset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = mDocChangeRange->SetEnd(endNode, endOffset);
|
||||
rv = mDocChangeRange->SetEnd(endNode, aRange->EndOffset());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
@ -289,15 +289,13 @@ ContentIsInTraversalRange(nsRange* aRange, nsIDOMNode* aNextNode, bool aIsPreMod
|
||||
|
||||
nsCOMPtr<nsIDOMNode> sNode;
|
||||
nsCOMPtr<nsIDOMNode> eNode;
|
||||
uint32_t sOffset;
|
||||
uint32_t eOffset;
|
||||
aRange->GetStartContainer(getter_AddRefs(sNode));
|
||||
aRange->GetStartOffset(&sOffset);
|
||||
aRange->GetEndContainer(getter_AddRefs(eNode));
|
||||
aRange->GetEndOffset(&eOffset);
|
||||
return ContentIsInTraversalRange(content, aIsPreMode,
|
||||
sNode, static_cast<int32_t>(sOffset),
|
||||
eNode, static_cast<int32_t>(eOffset));
|
||||
sNode,
|
||||
static_cast<int32_t>(aRange->StartOffset()),
|
||||
eNode,
|
||||
static_cast<int32_t>(aRange->EndOffset()));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
@ -531,14 +531,6 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
uint32_t offset;
|
||||
rv = range->GetStartOffset(&offset);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
UNLOCK_DOC(this);
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (IsTextNode(parent)) {
|
||||
// The caret is in a text node. Find the beginning
|
||||
// of the text block containing this text node and
|
||||
@ -592,7 +584,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
|
||||
// till you find a text node, then find the beginning of it's block.
|
||||
|
||||
rv = CreateDocumentContentRootToNodeOffsetRange(
|
||||
parent, static_cast<int32_t>(offset), false,
|
||||
parent, range->StartOffset(), false,
|
||||
getter_AddRefs(range));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
@ -780,16 +772,9 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
uint32_t offset;
|
||||
rv = range->GetEndOffset(&offset);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
UNLOCK_DOC(this);
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = CreateDocumentContentRootToNodeOffsetRange(
|
||||
parent, static_cast<int32_t>(offset), false, getter_AddRefs(range));
|
||||
parent, range->EndOffset(), false,
|
||||
getter_AddRefs(range));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
UNLOCK_DOC(this);
|
||||
@ -1874,17 +1859,11 @@ nsTextServicesDocument::CreateDocumentContentRange(nsRange** aRange)
|
||||
|
||||
nsresult
|
||||
nsTextServicesDocument::CreateDocumentContentRootToNodeOffsetRange(
|
||||
nsIDOMNode* aParent, int32_t aOffset, bool aToStart, nsRange** aRange)
|
||||
nsIDOMNode* aParent, uint32_t aOffset, bool aToStart, nsRange** aRange)
|
||||
{
|
||||
NS_ENSURE_TRUE(aParent && aRange, NS_ERROR_NULL_POINTER);
|
||||
|
||||
*aRange = 0;
|
||||
|
||||
NS_ASSERTION(aOffset >= 0, "Invalid offset!");
|
||||
|
||||
if (aOffset < 0) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
*aRange = nullptr;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> bodyNode;
|
||||
nsresult rv = GetDocumentContentRootNode(getter_AddRefs(bodyNode));
|
||||
@ -1893,7 +1872,7 @@ nsTextServicesDocument::CreateDocumentContentRootToNodeOffsetRange(
|
||||
|
||||
nsCOMPtr<nsIDOMNode> startNode;
|
||||
nsCOMPtr<nsIDOMNode> endNode;
|
||||
int32_t startOffset, endOffset;
|
||||
uint32_t startOffset, endOffset;
|
||||
|
||||
if (aToStart) {
|
||||
// The range should begin at the start of the document
|
||||
@ -1912,7 +1891,7 @@ nsTextServicesDocument::CreateDocumentContentRootToNodeOffsetRange(
|
||||
endNode = bodyNode;
|
||||
|
||||
nsCOMPtr<nsINode> body = do_QueryInterface(bodyNode);
|
||||
endOffset = body ? int32_t(body->GetChildCount()) : 0;
|
||||
endOffset = body ? body->GetChildCount() : 0;
|
||||
}
|
||||
|
||||
return nsRange::CreateRange(startNode, startOffset, endNode, endOffset,
|
||||
@ -2347,9 +2326,7 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
|
||||
nsCOMPtr<nsINode> parent = do_QueryInterface(domParent);
|
||||
MOZ_ASSERT(parent);
|
||||
|
||||
uint32_t offset;
|
||||
rv = range->GetStartOffset(&offset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
uint32_t offset = range->StartOffset();
|
||||
|
||||
int32_t e1s1 = nsContentUtils::ComparePoints(eStart->mNode, eStartOffset,
|
||||
domParent,
|
||||
@ -2790,12 +2767,7 @@ nsTextServicesDocument::GetRangeEndPoints(nsRange* aRange,
|
||||
|
||||
NS_ENSURE_TRUE(aStartContainer, NS_ERROR_FAILURE);
|
||||
|
||||
uint32_t offset;
|
||||
rv = aRange->GetStartOffset(&offset);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
*aStartOffset = static_cast<int32_t>(offset);
|
||||
*aStartOffset = static_cast<int32_t>(aRange->StartOffset());
|
||||
|
||||
rv = aRange->GetEndContainer(aEndContainer);
|
||||
|
||||
@ -2803,11 +2775,7 @@ nsTextServicesDocument::GetRangeEndPoints(nsRange* aRange,
|
||||
|
||||
NS_ENSURE_TRUE(aEndContainer, NS_ERROR_FAILURE);
|
||||
|
||||
rv = aRange->GetEndOffset(&offset);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
*aEndOffset = static_cast<int32_t>(offset);
|
||||
*aEndOffset = static_cast<int32_t>(aRange->EndOffset());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ private:
|
||||
nsresult GetDocumentContentRootNode(nsIDOMNode **aNode);
|
||||
nsresult CreateDocumentContentRange(nsRange** aRange);
|
||||
nsresult CreateDocumentContentRootToNodeOffsetRange(nsIDOMNode* aParent,
|
||||
int32_t aOffset,
|
||||
uint32_t aOffset,
|
||||
bool aToStart,
|
||||
nsRange** aRange);
|
||||
nsresult CreateDocumentContentIterator(nsIContentIterator **aIterator);
|
||||
|
Loading…
x
Reference in New Issue
Block a user