backout fix for bug 345428 due to memory leaks
authordveditz@cruzio.com
Thu, 20 Sep 2007 13:40:43 -0700
changeset 6156 231d29bf3c003cc753024207495bbe90ff57fd1f
parent 6155 57e8e87929722e826d11526ac904d9af6bc2cfeb
child 6157 0477cae38a8c38aea079110dbed38e8e9f642bd5
push idunknown
push userunknown
push dateunknown
bugs345428
milestone1.9a8pre
backout fix for bug 345428 due to memory leaks
extensions/spellcheck/src/mozInlineSpellChecker.cpp
extensions/spellcheck/src/mozInlineSpellChecker.h
--- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ -68,17 +68,16 @@
 #include "mozInlineSpellWordUtil.h"
 #include "mozISpellI18NManager.h"
 #include "nsCOMPtr.h"
 #include "nsCRT.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMDocumentRange.h"
 #include "nsIDOMElement.h"
-#include "nsPIDOMWindow.h"
 #include "nsIDOMEventTarget.h"
 #include "nsPIDOMEventTarget.h"
 #include "nsIDOMMouseEvent.h"
 #include "nsIDOMKeyEvent.h"
 #include "nsIDOMNode.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMNSRange.h"
 #include "nsIDOMRange.h"
@@ -500,17 +499,16 @@ public:
     return NS_OK;
   }
 };
 
 
 NS_INTERFACE_MAP_BEGIN(mozInlineSpellChecker)
 NS_INTERFACE_MAP_ENTRY(nsIInlineSpellChecker)
 NS_INTERFACE_MAP_ENTRY(nsIEditActionListener)
-NS_INTERFACE_MAP_ENTRY(nsIDOMFocusListener)
 NS_INTERFACE_MAP_ENTRY(nsIDOMMouseListener)
 NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMKeyListener)
 NS_INTERFACE_MAP_ENTRY(nsIDOMKeyListener)
 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener, nsIDOMKeyListener)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_ADDREF(mozInlineSpellChecker)
@@ -621,34 +619,21 @@ mozInlineSpellChecker::RegisterEventList
 {
   nsCOMPtr<nsIEditor> editor (do_QueryReferent(mEditor));
   NS_ENSURE_TRUE(editor, NS_ERROR_NULL_POINTER);
 
   editor->AddEditActionListener(this);
 
   nsCOMPtr<nsIDOMDocument> doc;
   nsresult rv = editor->GetDocument(getter_AddRefs(doc));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsCOMPtr<nsIDocument> doc2 = do_QueryInterface(doc);
-  NS_ENSURE_TRUE(doc2, nsnull);
-  nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(doc2->GetWindow());
-  nsPIDOMEventTarget* chromeEventHandler = nsnull;
-  if (win)
-    chromeEventHandler = win->GetChromeEventHandler();
-
-  nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(chromeEventHandler, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+  NS_ENSURE_SUCCESS(rv, rv); 
 
   nsCOMPtr<nsPIDOMEventTarget> piTarget = do_QueryInterface(doc, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+  NS_ENSURE_SUCCESS(rv, rv); 
 
-  target->AddEventListener(NS_LITERAL_STRING("blur"),
-                           static_cast<nsIDOMFocusListener *>(this),
-                           PR_TRUE);
   piTarget->AddEventListenerByIID(static_cast<nsIDOMMouseListener*>(this),
                                   NS_GET_IID(nsIDOMMouseListener));
   piTarget->AddEventListenerByIID(static_cast<nsIDOMKeyListener*>(this),
                                   NS_GET_IID(nsIDOMKeyListener));
 
   return NS_OK;
 }
 
@@ -664,30 +649,16 @@ mozInlineSpellChecker::UnregisterEventLi
 
   nsCOMPtr<nsIDOMDocument> doc;
   editor->GetDocument(getter_AddRefs(doc));
   NS_ENSURE_TRUE(doc, NS_ERROR_NULL_POINTER);
   
   nsCOMPtr<nsPIDOMEventTarget> piTarget = do_QueryInterface(doc);
   NS_ENSURE_TRUE(piTarget, NS_ERROR_NULL_POINTER);
 
-  nsCOMPtr<nsIDocument> doc2 = do_QueryInterface(doc);
-  NS_ENSURE_TRUE(doc2, nsnull);
-  nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(doc2->GetWindow());
-  nsPIDOMEventTarget* chromeEventHandler = nsnull;
-  if (win)
-    chromeEventHandler = win->GetChromeEventHandler();
-
-  nsresult rv;
-  nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(chromeEventHandler, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  target->RemoveEventListener(NS_LITERAL_STRING("blur"),
-                              static_cast<nsIDOMFocusListener *>(this),
-                              PR_TRUE);
   piTarget->RemoveEventListenerByIID(static_cast<nsIDOMMouseListener*>(this),
                                      NS_GET_IID(nsIDOMMouseListener));
   piTarget->RemoveEventListenerByIID(static_cast<nsIDOMKeyListener*>(this),
                                      NS_GET_IID(nsIDOMKeyListener));
   
   return NS_OK;
 }
 
@@ -1675,28 +1646,16 @@ mozInlineSpellChecker::HandleNavigationE
   return NS_OK;
 }
 
 NS_IMETHODIMP mozInlineSpellChecker::HandleEvent(nsIDOMEvent* aEvent)
 {
   return NS_OK;
 }
 
-NS_IMETHODIMP mozInlineSpellChecker::Focus(nsIDOMEvent* aEvent)
-{
-  return NS_OK;
-}
-
-NS_IMETHODIMP mozInlineSpellChecker::Blur(nsIDOMEvent* aEvent)
-{
-  // force spellcheck on blur, for instance when tabbing out of a textbox
-  HandleNavigationEvent(aEvent, PR_TRUE);
-  return NS_OK;
-}
-
 NS_IMETHODIMP mozInlineSpellChecker::MouseClick(nsIDOMEvent *aMouseEvent)
 {
   nsCOMPtr<nsIDOMMouseEvent>mouseEvent = do_QueryInterface(aMouseEvent);
   NS_ENSURE_TRUE(mouseEvent, NS_OK);
 
   // ignore any errors from HandleNavigationEvent as we don't want to prevent 
   // anyone else from seeing this event.
   PRUint16 button;
--- a/extensions/spellcheck/src/mozInlineSpellChecker.h
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.h
@@ -43,17 +43,16 @@
 #include "nsIDOMRange.h"
 #include "nsIEditorSpellCheck.h"
 #include "nsIEditActionListener.h"
 #include "nsIInlineSpellChecker.h"
 #include "nsITextServicesDocument.h"
 #include "nsIDOMTreeWalker.h"
 #include "nsWeakReference.h"
 #include "nsIEditor.h"
-#include "nsIDOMFocusListener.h"
 #include "nsIDOMMouseListener.h"
 #include "nsIDOMKeyListener.h"
 #include "nsWeakReference.h"
 #include "mozISpellI18NUtil.h"
 
 class nsIDOMDocumentRange;
 class nsIDOMMouseEventListener;
 class mozInlineSpellWordUtil;
@@ -134,17 +133,17 @@ protected:
   nsresult FillNoCheckRangeFromAnchor(mozInlineSpellWordUtil& aWordUtil);
 
   nsresult GetDocumentRange(nsIDOMDocumentRange** aDocRange);
   nsresult PositionToCollapsedRange(nsIDOMDocumentRange* aDocRange,
                                     nsIDOMNode* aNode, PRInt32 aOffset,
                                     nsIDOMRange** aRange);
 };
 
-class mozInlineSpellChecker : public nsIInlineSpellChecker, nsIEditActionListener, nsIDOMFocusListener, nsIDOMMouseListener, nsIDOMKeyListener,
+class mozInlineSpellChecker : public nsIInlineSpellChecker, nsIEditActionListener, nsIDOMMouseListener, nsIDOMKeyListener,
                                      nsSupportsWeakReference
 {
 private:
   friend class mozInlineSpellStatus;
 
   // Access with CanEnableInlineSpellChecking
   enum SpellCheckingState { SpellCheck_Uninitialized = -1,
                             SpellCheck_NotAvailable = 0,
@@ -220,21 +219,16 @@ public:
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIEDITACTIONLISTENER
   NS_DECL_NSIINLINESPELLCHECKER
 
   // returns true if it looks likely that we can enable real-time spell checking
   static PRBool CanEnableInlineSpellChecking();
 
-  /*BEGIN implementations of focus event handler interface*/
-  NS_IMETHOD Focus(nsIDOMEvent* aEvent);
-  NS_IMETHOD Blur(nsIDOMEvent* aEvent);
-  /*END implementations of focus event handler interface*/
-
   /*BEGIN implementations of mouseevent handler interface*/
   NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
   NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
   NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent);
   NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent);
   NS_IMETHOD MouseDblClick(nsIDOMEvent* aMouseEvent);
   NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent);
   NS_IMETHOD MouseOut(nsIDOMEvent* aMouseEvent);