Bug 455806: outparamdel nsIPrivateTextEvent r+sr=jst
authorTaras Glek <tglek@mozilla.com>
Thu, 09 Oct 2008 16:31:19 -0700
changeset 20236 98b7850b016840a123a6b5f589f9176361be925d
parent 20235 ad837c22e1912743b56f1affe3411885568aa319
child 20237 51c533bbac70bd11d41679eceec3ba68ba84d2e5
push idunknown
push userunknown
push dateunknown
bugs455806
milestone1.9.1b2pre
Bug 455806: outparamdel nsIPrivateTextEvent r+sr=jst
content/events/public/nsIPrivateTextEvent.h
content/events/src/nsDOMTextEvent.cpp
content/events/src/nsDOMTextEvent.h
editor/libeditor/text/nsEditorEventListeners.cpp
--- a/content/events/public/nsIPrivateTextEvent.h
+++ b/content/events/public/nsIPrivateTextEvent.h
@@ -48,16 +48,16 @@ 0x37b69251, 0x4ace, 0x11d3, \
 {0x9e, 0xa6, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b} }
 
 class nsIPrivateTextEvent : public nsISupports {
 
 public:
 	NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPRIVATETEXTEVENT_IID)
 
 	NS_IMETHOD GetText(nsString& aText) = 0;
-	NS_IMETHOD GetInputRange(nsIPrivateTextRangeList** aInputRange) = 0;
-	NS_IMETHOD GetEventReply(struct nsTextEventReply** aReply) = 0;
+	NS_IMETHOD_(already_AddRefed<nsIPrivateTextRangeList>) GetInputRange() = 0;
+	NS_IMETHOD_(nsTextEventReply*) GetEventReply() = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIPrivateTextEvent, NS_IPRIVATETEXTEVENT_IID)
 
 #endif // nsIPrivateTextEvent_h__
 
--- a/content/events/src/nsDOMTextEvent.cpp
+++ b/content/events/src/nsDOMTextEvent.cpp
@@ -92,37 +92,33 @@ NS_INTERFACE_MAP_BEGIN(nsDOMTextEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
 
 NS_METHOD nsDOMTextEvent::GetText(nsString& aText)
 {
   aText = mText;
   return NS_OK;
 }
 
-NS_METHOD nsDOMTextEvent::GetInputRange(nsIPrivateTextRangeList** aInputRange)
+NS_METHOD_(already_AddRefed<nsIPrivateTextRangeList>) nsDOMTextEvent::GetInputRange()
 {
-  if (mEvent->message == NS_TEXT_TEXT)
-  {
-    *aInputRange = mTextRange;
-    NS_IF_ADDREF(*aInputRange);
-    return NS_OK;
+  if (mEvent->message == NS_TEXT_TEXT) {
+    nsRefPtr<nsPrivateTextRangeList> textRange = mTextRange;
+    nsPrivateTextRangeList *textRangePtr = nsnull;
+    textRange.swap(textRangePtr);
+    return textRangePtr;
   }
-  *aInputRange = nsnull;
-  return NS_ERROR_FAILURE;
+  return nsnull;
 }
 
-NS_METHOD nsDOMTextEvent::GetEventReply(nsTextEventReply** aReply)
+NS_METHOD_(nsTextEventReply*) nsDOMTextEvent::GetEventReply()
 {
-  if (mEvent->message == NS_TEXT_TEXT)
-  {
-     *aReply = &(static_cast<nsTextEvent*>(mEvent)->theReply);
-     return NS_OK;
+  if (mEvent->message == NS_TEXT_TEXT) {
+     return &(static_cast<nsTextEvent*>(mEvent)->theReply);
   }
-  aReply = 0;
-  return NS_ERROR_FAILURE;
+  return nsnull;
 }
 
 nsresult NS_NewDOMTextEvent(nsIDOMEvent** aInstancePtrResult,
                             nsPresContext* aPresContext,
                             nsTextEvent *aEvent)
 {
   nsDOMTextEvent* it = new nsDOMTextEvent(aPresContext, aEvent);
   if (nsnull == it) {
--- a/content/events/src/nsDOMTextEvent.h
+++ b/content/events/src/nsDOMTextEvent.h
@@ -51,17 +51,17 @@ public:
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // Forward to base class
   NS_FORWARD_TO_NSDOMUIEVENT
 
   // nsIPrivateTextEvent interface
   NS_IMETHOD GetText(nsString& aText);
-  NS_IMETHOD GetInputRange(nsIPrivateTextRangeList** aInputRange);
-  NS_IMETHOD GetEventReply(nsTextEventReply** aReply);
+  NS_IMETHOD_(already_AddRefed<nsIPrivateTextRangeList>) GetInputRange();
+  NS_IMETHOD_(nsTextEventReply*) GetEventReply();
   
 protected:
   nsString mText;
   nsRefPtr<nsPrivateTextRangeList> mTextRange;
 };
 
 #endif // nsDOMTextEvent_h__
--- a/editor/libeditor/text/nsEditorEventListeners.cpp
+++ b/editor/libeditor/text/nsEditorEventListeners.cpp
@@ -455,18 +455,18 @@ nsTextEditorTextListener::HandleText(nsI
    }
 
    nsAutoString                      composedText;
    nsresult                          result;
    nsCOMPtr<nsIPrivateTextRangeList> textRangeList;
    nsTextEventReply*                 textEventReply;
 
    textEvent->GetText(composedText);
-   textEvent->GetInputRange(getter_AddRefs(textRangeList));
-   textEvent->GetEventReply(&textEventReply);
+   textRangeList = textEvent->GetInputRange();
+   textEventReply = textEvent->GetEventReply();
    nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(mEditor, &result);
    if (imeEditor) {
      PRUint32 flags;
      // if we are readonly or disabled, then do nothing.
      if (NS_SUCCEEDED(mEditor->GetFlags(&flags))) {
        if (flags & nsIPlaintextEditor::eEditorReadonlyMask || 
            flags & nsIPlaintextEditor::eEditorDisabledMask) {
 #if DEBUG_IME