Back out Bug 380454
authorOlli.Pettay@helsinki.fi
Tue, 19 Feb 2008 05:47:15 -0800
changeset 11863 057effe236369269d6abb05820236c6dc5955157
parent 11862 310559e938356a468afee5707e4b122d4247a1a9
child 11864 63aee8cb8e19110cf688a0f76b1577cd99fda585
push idunknown
push userunknown
push dateunknown
bugs380454
milestone1.9b4pre
Back out Bug 380454
content/html/content/src/nsHTMLLinkElement.cpp
xpcom/glue/nsThreadUtils.cpp
xpcom/threads/nsThreadManager.cpp
xpcom/threads/nsThreadManager.h
--- a/content/html/content/src/nsHTMLLinkElement.cpp
+++ b/content/html/content/src/nsHTMLLinkElement.cpp
@@ -53,17 +53,16 @@
 #include "nsIDocument.h"
 #include "nsIDOMEvent.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsIDOMDocumentEvent.h"
 #include "nsIDOMEventTarget.h"
 #include "nsParserUtils.h"
 #include "nsContentUtils.h"
 #include "nsPIDOMWindow.h"
-#include "nsPLDOMEvent.h"
 
 class nsHTMLLinkElement : public nsGenericHTMLElement,
                           public nsIDOMHTMLLinkElement,
                           public nsILink,
                           public nsStyleLinkElement
 {
 public:
   nsHTMLLinkElement(nsINodeInfo *aNodeInfo);
@@ -269,20 +268,19 @@ nsHTMLLinkElement::CreateAndDispatchEven
     {&nsGkAtoms::_empty, &nsGkAtoms::stylesheet, nsnull};
 
   if (!nsContentUtils::HasNonEmptyAttr(this, kNameSpaceID_None,
                                        nsGkAtoms::rev) &&
       FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::rel,
                       strings, eIgnoreCase) != ATTR_VALUE_NO_MATCH)
     return;
 
-  nsRefPtr<nsPLDOMEvent> event = new nsPLDOMEvent(this, aEventName);
-  if (event) {
-    event->PostDOMEvent();
-  }
+  nsContentUtils::DispatchTrustedEvent(aDoc,
+                                       static_cast<nsIContent*>(this),
+                                       aEventName, PR_TRUE, PR_TRUE);
 }
 
 nsresult
 nsHTMLLinkElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
                            nsIAtom* aPrefix, const nsAString& aValue,
                            PRBool aNotify)
 {
   if (aName == nsGkAtoms::href && kNameSpaceID_None == aNameSpaceID) {
--- a/xpcom/glue/nsThreadUtils.cpp
+++ b/xpcom/glue/nsThreadUtils.cpp
@@ -131,17 +131,17 @@ NS_IsMainThread()
   return result;
 }
 
 NS_METHOD
 NS_DispatchToCurrentThread(nsIRunnable *event)
 {
 #ifdef MOZILLA_INTERNAL_API
   nsIThread *thread = NS_GetCurrentThread();
-  if (!thread) { return NS_ERROR_UNEXPECTED; }
+  NS_ENSURE_STATE(thread);
 #else
   nsCOMPtr<nsIThread> thread;
   nsresult rv = NS_GetCurrentThread(getter_AddRefs(thread));
   NS_ENSURE_SUCCESS(rv, rv);
 #endif
   return thread->Dispatch(event, NS_DISPATCH_NORMAL);
 }
 
--- a/xpcom/threads/nsThreadManager.cpp
+++ b/xpcom/threads/nsThreadManager.cpp
@@ -195,19 +195,16 @@ nsThreadManager::UnregisterCurrentThread
 nsThread *
 nsThreadManager::GetCurrentThread()
 {
   // read thread local storage
   void *data = PR_GetThreadPrivate(mCurThreadIndex);
   if (data)
     return static_cast<nsThread *>(data);
 
-  if (!mInitialized)
-    return nsnull;
-
   // OK, that's fine.  We'll dynamically create one :-)
   nsRefPtr<nsThread> thread = new nsThread();
   if (!thread || NS_FAILED(thread->InitCurrentThread()))
     return nsnull;
 
   return thread.get();  // reference held in TLS
 }
 
--- a/xpcom/threads/nsThreadManager.h
+++ b/xpcom/threads/nsThreadManager.h
@@ -64,18 +64,17 @@ public:
   // Called by nsThread to inform the ThreadManager it exists.  This method
   // must be called when the given thread is the current thread.
   void RegisterCurrentThread(nsThread *thread);
 
   // Called by nsThread to inform the ThreadManager it is going away.  This
   // method must be called when the given thread is the current thread.
   void UnregisterCurrentThread(nsThread *thread);
 
-  // Returns the current thread.  Returns null if OOM or if ThreadManager isn't
-  // initialized.
+  // Returns the current thread.  Returns null if OOM.
   nsThread *GetCurrentThread();
 
   // This needs to be public in order to support static instantiation of this
   // class with older compilers (e.g., egcs-2.91.66).
   ~nsThreadManager() {}
 
 private:
   nsThreadManager()