Bug 684638 part 3. Speed up mozInlineSpellWordUtil::MakeRange. r=ehsan
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 04 Nov 2011 01:32:09 -0400
changeset 80384 f0c2904b8edfdb3691d4b47766623645eedcda08
parent 80383 91d660a94cc241bf49dcfc4616fd02d1718f9c47
child 80385 132b27a4fb0276e54641fe350c14053381f94563
push id506
push userclegnitto@mozilla.com
push dateWed, 09 Nov 2011 02:03:18 +0000
treeherdermozilla-aurora@63587fc7bb93 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs684638
milestone10.0a1
Bug 684638 part 3. Speed up mozInlineSpellWordUtil::MakeRange. r=ehsan
extensions/spellcheck/src/Makefile.in
extensions/spellcheck/src/mozInlineSpellWordUtil.cpp
--- a/extensions/spellcheck/src/Makefile.in
+++ b/extensions/spellcheck/src/Makefile.in
@@ -64,9 +64,10 @@ CPPSRCS		= \
 
 SHARED_LIBRARY_LIBS += ../hunspell/src/$(LIB_PREFIX)hunspell_s.$(LIB_SUFFIX)
 LOCAL_INCLUDES += -I$(srcdir)/../hunspell/src
 
 include $(topsrcdir)/config/rules.mk
 
 LOCAL_INCLUDES += \
 	-I$(topsrcdir)/xpcom/io \
+	-I$(topsrcdir)/content/base/src \
 	$(NULL)
--- a/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp
@@ -49,16 +49,17 @@
 #include "nsIDOMNode.h"
 #include "nsIDOMHTMLBRElement.h"
 #include "nsUnicharUtilCIID.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIContent.h"
 #include "nsTextFragment.h"
 #include "mozilla/dom/Element.h"
 #include "nsIFrame.h"
+#include "nsRange.h"
 
 using namespace mozilla;
 
 // IsIgnorableCharacter
 //
 //    These characters are ones that we should ignore in input.
 
 inline bool IsIgnorableCharacter(PRUnichar ch)
@@ -367,23 +368,22 @@ mozInlineSpellWordUtil::GetNextWord(nsAS
 
 nsresult
 mozInlineSpellWordUtil::MakeRange(NodeOffset aBegin, NodeOffset aEnd,
                                   nsIDOMRange** aRange)
 {
   if (!mDOMDocument)
     return NS_ERROR_NOT_INITIALIZED;
 
-  nsresult rv = mDOMDocument->CreateRange(aRange);
+  nsRefPtr<nsRange> range = new nsRange();
+  nsCOMPtr<nsINode> begin(do_QueryInterface(aBegin.mNode));
+  nsCOMPtr<nsINode> end(do_QueryInterface(aEnd.mNode));
+  nsresult rv = range->Set(begin, aBegin.mOffset, end, aEnd.mOffset);
   NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = (*aRange)->SetStart(aBegin.mNode, aBegin.mOffset);
-  NS_ENSURE_SUCCESS(rv, rv);
-  rv = (*aRange)->SetEnd(aEnd.mNode, aEnd.mOffset);
-  NS_ENSURE_SUCCESS(rv, rv);
+  range.forget(aRange);
 
   return NS_OK;
 }
 
 /*********** DOM text extraction ************/
 
 // IsDOMWordSeparator
 //