Bug 766845 part 2 - Make CloneRange() return already_AddRefed<nsRange>; r=smaug

This commit is contained in:
Aryeh Gregor 2012-06-25 14:44:11 +03:00
Родитель 5a1fadd0f3
Коммит 6c6dd2829d
3 изменённых файлов: 9 добавлений и 19 удалений

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

@ -2017,30 +2017,23 @@ nsRange::CloneContents(nsIDOMDocumentFragment** aReturn)
return NS_OK;
}
nsresult
nsRange::CloneRange(nsRange** aReturn) const
already_AddRefed<nsRange>
nsRange::CloneRange() const
{
if (aReturn == 0)
return NS_ERROR_NULL_POINTER;
nsRefPtr<nsRange> range = new nsRange();
range->SetMaySpanAnonymousSubtrees(mMaySpanAnonymousSubtrees);
range->DoSetRange(mStartParent, mStartOffset, mEndParent, mEndOffset, mRoot);
range.forget(aReturn);
return NS_OK;
return range.forget();
}
NS_IMETHODIMP
nsRange::CloneRange(nsIDOMRange** aReturn)
{
nsRefPtr<nsRange> range;
nsresult rv = CloneRange(getter_AddRefs(range));
range.forget(aReturn);
return rv;
*aReturn = CloneRange().get();
return NS_OK;
}
NS_IMETHODIMP

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

@ -118,7 +118,7 @@ public:
void Reset();
nsresult SetStart(nsINode* aParent, PRInt32 aOffset);
nsresult SetEnd(nsINode* aParent, PRInt32 aOffset);
nsresult CloneRange(nsRange** aNewRange) const;
already_AddRefed<nsRange> CloneRange() const;
nsresult Set(nsINode* aStartParent, PRInt32 aStartOffset,
nsINode* aEndParent, PRInt32 aEndOffset)

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

@ -1270,7 +1270,8 @@ nsFrameSelection::MaintainSelection(nsSelectionAmount aAmount)
const nsRange* anchorFocusRange =
mDomSelections[index]->GetAnchorFocusRange();
if (anchorFocusRange) {
return anchorFocusRange->CloneRange(getter_AddRefs(mMaintainRange));
mMaintainRange = anchorFocusRange->CloneRange();
return NS_OK;
}
mMaintainRange = nsnull;
@ -4795,11 +4796,7 @@ Selection::Extend(nsINode* aParentNode, PRInt32 aOffset)
PRInt32 anchorOffset = GetAnchorOffset();
PRInt32 focusOffset = GetFocusOffset();
nsRefPtr<nsRange> range;
res = mAnchorFocusRange->CloneRange(getter_AddRefs(range));
if (NS_FAILED(res))
return res;
//range = mAnchorFocusRange;
nsRefPtr<nsRange> range = mAnchorFocusRange->CloneRange();
nsINode* startNode = range->GetStartParent();
nsINode* endNode = range->GetEndParent();