SVG Load events shouldn't need a presshell to fire.
Bug 380417, r=jwatt andsmaug, sr=tor
SVG Load events shouldn't need a presshell to fire.
Bug 380417, r=jwatt andsmaug, sr=tor
--- 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)