Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "nsHtml5SVGLoadDispatcher.h"
6 #include "nsPresContext.h"
7 #include "nsIPresShell.h"
8 #include "mozilla/BasicEvents.h"
9 #include "mozilla/EventDispatcher.h"
10 #include "nsIDocument.h"
12 using namespace mozilla;
14 nsHtml5SVGLoadDispatcher::nsHtml5SVGLoadDispatcher(nsIContent* aElement)
15 : mElement(aElement)
16 , mDocument(mElement->OwnerDoc())
17 {
18 mDocument->BlockOnload();
19 }
21 NS_IMETHODIMP
22 nsHtml5SVGLoadDispatcher::Run()
23 {
24 WidgetEvent event(true, NS_SVG_LOAD);
25 event.mFlags.mBubbles = false;
26 // Do we care about forcing presshell creation if it hasn't happened yet?
27 // That is, should this code flush or something? Does it really matter?
28 // For that matter, do we really want to try getting the prescontext?
29 // Does this event ever want one?
30 nsRefPtr<nsPresContext> ctx;
31 nsCOMPtr<nsIPresShell> shell = mElement->OwnerDoc()->GetShell();
32 if (shell) {
33 ctx = shell->GetPresContext();
34 }
35 EventDispatcher::Dispatch(mElement, ctx, &event);
36 // Unblocking onload on the same document that it was blocked even if
37 // the element has moved between docs since blocking.
38 mDocument->UnblockOnload(false);
39 return NS_OK;
40 }