Bug 1421553 - Part 2. Remove nsIDOMRange usages from nsTextServicesDocument. r=masayuki

nsITextServicesDocument isn't scriptable, so there is no reason to use
nsIDOMRange.

MozReview-Commit-ID: AVPgrwmz38H

--HG--
extra : rebase_source : 0cb03cdb9b0dc4ef85b1b5582b7e3a54cb002904
This commit is contained in:
Makoto Kato 2017-11-29 17:55:12 +09:00
Родитель fcf9456236
Коммит 99a7861946
3 изменённых файлов: 13 добавлений и 16 удалений

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

@ -10,9 +10,9 @@
#include "nsStringFwd.h"
class nsIDOMDocument;
class nsIDOMRange;
class nsIEditor;
class nsITextServicesFilter;
class nsRange;
/*
TextServicesDocument interface to outside world
@ -67,7 +67,7 @@ public:
* @param aDOMRange is the range to use. aDOMRange must point to a
* valid range object.
*/
NS_IMETHOD SetExtent(nsIDOMRange* aDOMRange) = 0;
NS_IMETHOD SetExtent(nsRange* aDOMRange) = 0;
/**
* Expands the end points of the range so that it spans complete words.
@ -75,7 +75,7 @@ public:
*
* @param aDOMRange the range to be expanded/adjusted.
*/
NS_IMETHOD ExpandRangeToWordBoundaries(nsIDOMRange *aRange) = 0;
NS_IMETHOD ExpandRangeToWordBoundaries(nsRange* aRange) = 0;
/**
* Sets the filter to be used while iterating over content.

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

@ -22,7 +22,6 @@
#include "nsIDOMHTMLDocument.h" // for nsIDOMHTMLDocument
#include "nsIDOMHTMLElement.h" // for nsIDOMHTMLElement
#include "nsIDOMNode.h" // for nsIDOMNode, etc
#include "nsIDOMRange.h" // for nsIDOMRange, etc
#include "nsIEditor.h" // for nsIEditor, etc
#include "nsINode.h" // for nsINode
#include "nsIPlaintextEditor.h" // for nsIPlaintextEditor
@ -193,9 +192,9 @@ nsTextServicesDocument::GetDocument(nsIDOMDocument **aDoc)
}
NS_IMETHODIMP
nsTextServicesDocument::SetExtent(nsIDOMRange* aDOMRange)
nsTextServicesDocument::SetExtent(nsRange* aRange)
{
NS_ENSURE_ARG_POINTER(aDOMRange);
NS_ENSURE_ARG_POINTER(aRange);
NS_ENSURE_TRUE(mDOMDocument, NS_ERROR_FAILURE);
LOCK_DOC(this);
@ -203,7 +202,7 @@ nsTextServicesDocument::SetExtent(nsIDOMRange* aDOMRange)
// We need to store a copy of aDOMRange since we don't
// know where it came from.
mExtent = static_cast<nsRange*>(aDOMRange)->CloneRange();
mExtent = aRange->CloneRange();
// Create a new iterator based on our new extent range.
@ -227,17 +226,16 @@ nsTextServicesDocument::SetExtent(nsIDOMRange* aDOMRange)
}
NS_IMETHODIMP
nsTextServicesDocument::ExpandRangeToWordBoundaries(nsIDOMRange *aRange)
nsTextServicesDocument::ExpandRangeToWordBoundaries(nsRange* aRange)
{
NS_ENSURE_ARG_POINTER(aRange);
RefPtr<nsRange> range = static_cast<nsRange*>(aRange);
// Get the end points of the range.
nsCOMPtr<nsINode> rngStartNode, rngEndNode;
int32_t rngStartOffset, rngEndOffset;
nsresult rv = GetRangeEndPoints(range, getter_AddRefs(rngStartNode),
nsresult rv = GetRangeEndPoints(aRange, getter_AddRefs(rngStartNode),
&rngStartOffset,
getter_AddRefs(rngEndNode),
&rngEndOffset);
@ -247,7 +245,7 @@ nsTextServicesDocument::ExpandRangeToWordBoundaries(nsIDOMRange *aRange)
// Create a content iterator based on the range.
nsCOMPtr<nsIContentIterator> iter;
rv = CreateContentIterator(range, getter_AddRefs(iter));
rv = CreateContentIterator(aRange, getter_AddRefs(iter));
NS_ENSURE_SUCCESS(rv, rv);
@ -372,8 +370,8 @@ nsTextServicesDocument::ExpandRangeToWordBoundaries(nsIDOMRange *aRange)
// Now adjust the range so that it uses our new
// end points.
rv = range->SetStartAndEnd(rngStartNode, rngStartOffset,
rngEndNode, rngEndOffset);
rv = aRange->SetStartAndEnd(rngStartNode, rngStartOffset,
rngEndNode, rngEndOffset);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}

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

@ -22,7 +22,6 @@ class nsIContentIterator;
class nsIDOMCharacterData;
class nsIDOMDocument;
class nsIDOMNode;
class nsIDOMRange;
class nsIEditor;
class nsISelection;
class nsISelectionController;
@ -77,8 +76,8 @@ public:
/* nsITextServicesDocument method implementations. */
NS_IMETHOD InitWithEditor(nsIEditor *aEditor) override;
NS_IMETHOD GetDocument(nsIDOMDocument **aDoc) override;
NS_IMETHOD SetExtent(nsIDOMRange* aDOMRange) override;
NS_IMETHOD ExpandRangeToWordBoundaries(nsIDOMRange *aRange) override;
NS_IMETHOD SetExtent(nsRange* aRange) override;
NS_IMETHOD ExpandRangeToWordBoundaries(nsRange* aRange) override;
NS_IMETHOD SetFilter(nsITextServicesFilter *aFilter) override;
NS_IMETHOD GetCurrentTextBlock(nsString *aStr) override;
NS_IMETHOD FirstBlock() override;