SVG Load events shouldn't need a presshell to fire. Bug 380417, r=jwatt andsmaug, sr=tor
authorbzbarsky@mit.edu
Wed, 23 May 2007 13:05:53 -0700
changeset 1795 5c3fd4c56510087f8f45e66a0ed6741cb7da9908
parent 1794 ce6840837eaae8a3361c9f540d3d3dcfe41cf61d
child 1796 0dc2656e5f08b83dfee3cfe9c1ee6e11c570c8ab
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt, tor
bugs380417
milestone1.9a5pre
SVG Load events shouldn't need a presshell to fire. Bug 380417, r=jwatt andsmaug, sr=tor
content/xml/document/src/nsXMLContentSink.cpp
--- a/content/xml/document/src/nsXMLContentSink.cpp
+++ b/content/xml/document/src/nsXMLContentSink.cpp
@@ -91,16 +91,17 @@
 #include "nsNodeInfoManager.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsIContentPolicy.h"
 #include "nsContentPolicyUtils.h"
 #include "nsContentErrors.h"
 #include "nsIDOMProcessingInstruction.h"
 #include "nsNodeUtils.h"
 #include "nsIScriptGlobalObject.h"
+#include "nsEventDispatcher.h"
 
 #ifdef MOZ_SVG
 #include "nsGUIEvent.h"
 #endif
 
 #define kXSLType "text/xsl"
 
 // XXX Open Issues:
@@ -1093,24 +1094,32 @@ nsXMLContentSink::HandleEndElement(const
     }
     mNotifyLevel = stackLen - 1;
   }
   DidAddContent();
 
 #ifdef MOZ_SVG
   if (content->GetNameSpaceID() == kNameSpaceID_SVG &&
       content->HasAttr(kNameSpaceID_None, nsGkAtoms::onload)) {
-    nsEventStatus status = nsEventStatus_eIgnore;
+    FlushTags();
+
     nsEvent event(PR_TRUE, NS_SVG_LOAD);
     event.eventStructType = NS_SVG_EVENT;
-    nsCOMPtr<nsIPresShell> presShell = mDocument->GetPrimaryShell();
-    if (presShell) {
-      FlushTags();
-      presShell->HandleDOMEventWithTarget(content, &event, &status);
+    event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
+
+    // Do we care about forcing presshell creation if it hasn't happened yet?
+    // That is, should this code flush or something?  Does it really matter?
+    // For that matter, do we really want to try getting the prescontext?  Does
+    // this event ever want one?
+    nsRefPtr<nsPresContext> ctx;
+    nsCOMPtr<nsIPresShell> shell = mDocument->GetPrimaryShell();
+    if (shell) {
+      ctx = shell->GetPresContext();
     }
+    nsEventDispatcher::Dispatch(content, ctx, &event);
   }
 #endif
 
   return NS_SUCCEEDED(result) ? DidProcessATokenImpl() : result;
 }
 
 NS_IMETHODIMP 
 nsXMLContentSink::HandleComment(const PRUnichar *aName)