Bug 380454, r=benjamin, sr=sicking
authorOlli.Pettay@helsinki.fi
Tue, 19 Feb 2008 05:06:22 -0800
changeset 11860 0521f93cf8fb0d8cc64501fa24d68d93198b758b
parent 11859 2db1177c190d46c7fe4e29f9ecedb59b1d0a5c19
child 11861 01eb3f6401d517426983511931077fb17e662f3f
push idunknown
push userunknown
push dateunknown
reviewersbenjamin, sicking
bugs380454
milestone1.9b4pre
Bug 380454, r=benjamin, sr=sicking
content/html/content/src/nsHTMLLinkElement.cpp
xpcom/threads/nsThreadManager.cpp
xpcom/threads/nsThreadManager.h
--- a/content/html/content/src/nsHTMLLinkElement.cpp
+++ b/content/html/content/src/nsHTMLLinkElement.cpp
@@ -53,16 +53,17 @@
 #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);
@@ -268,19 +269,20 @@ 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;
 
-  nsContentUtils::DispatchTrustedEvent(aDoc,
-                                       static_cast<nsIContent*>(this),
-                                       aEventName, PR_TRUE, PR_TRUE);
+  nsRefPtr<nsPLDOMEvent> event = new nsPLDOMEvent(this, aEventName);
+  if (event) {
+    event->PostDOMEvent();
+  }
 }
 
 nsresult
 nsHTMLLinkElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
                            nsIAtom* aPrefix, const nsAString& aValue,
                            PRBool aNotify)
 {
   if (aName == nsGkAtoms::href && kNameSpaceID_None == aNameSpaceID) {
--- a/xpcom/threads/nsThreadManager.cpp
+++ b/xpcom/threads/nsThreadManager.cpp
@@ -195,16 +195,19 @@ 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,17 +64,18 @@ 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.
+  // Returns the current thread.  Returns null if OOM or if ThreadManager isn't
+  // initialized.
   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()