Bug 684638 part 2. Make it simpler to set up a range. r=smaug

This commit is contained in:
Boris Zbarsky 2011-11-04 01:32:09 -04:00
parent c58747aa09
commit cba75ef2b0
2 changed files with 16 additions and 7 deletions

View File

@ -5020,14 +5020,12 @@ nsDocument::GetAnonymousNodes(nsIDOMElement* aElement,
NS_IMETHODIMP
nsDocument::CreateRange(nsIDOMRange** aReturn)
{
nsresult rv = NS_NewRange(aReturn);
nsRefPtr<nsRange> range = new nsRange();
nsresult rv = range->Set(this, 0, this, 0);
NS_ENSURE_SUCCESS(rv, rv);
if (NS_SUCCEEDED(rv)) {
(*aReturn)->SetStart(this, 0);
(*aReturn)->SetEnd(this, 0);
}
return rv;
range.forget(aReturn);
return NS_OK;
}
NS_IMETHODIMP

View File

@ -98,6 +98,17 @@ public:
virtual nsresult SetEnd(nsINode* aParent, PRInt32 aOffset);
virtual nsresult CloneRange(nsIRange** aNewRange) const;
nsresult Set(nsINode* aStartParent, PRInt32 aStartOffset,
nsINode* aEndParent, PRInt32 aEndOffset)
{
// If this starts being hot, we may be able to optimize this a bit,
// but for now just set start and end separately.
nsresult rv = SetStart(aStartParent, aStartOffset);
NS_ENSURE_SUCCESS(rv, rv);
return SetEnd(aEndParent, aEndOffset);
}
NS_IMETHOD GetUsedFontFaces(nsIDOMFontFaceList** aResult);
// nsIMutationObserver methods