Line data Source code
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/. */
4 :
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"
11 :
12 : using namespace mozilla;
13 :
14 21 : nsHtml5SVGLoadDispatcher::nsHtml5SVGLoadDispatcher(nsIContent* aElement)
15 : : Runnable("nsHtml5SVGLoadDispatcher")
16 : , mElement(aElement)
17 21 : , mDocument(mElement->OwnerDoc())
18 : {
19 21 : mDocument->BlockOnload();
20 21 : }
21 :
22 : NS_IMETHODIMP
23 21 : nsHtml5SVGLoadDispatcher::Run()
24 : {
25 42 : WidgetEvent event(true, eSVGLoad);
26 21 : event.mFlags.mBubbles = false;
27 : // Do we care about forcing presshell creation if it hasn't happened yet?
28 : // That is, should this code flush or something? Does it really matter?
29 : // For that matter, do we really want to try getting the prescontext?
30 : // Does this event ever want one?
31 42 : RefPtr<nsPresContext> ctx;
32 42 : nsCOMPtr<nsIPresShell> shell = mElement->OwnerDoc()->GetShell();
33 21 : if (shell) {
34 21 : ctx = shell->GetPresContext();
35 : }
36 21 : EventDispatcher::Dispatch(mElement, ctx, &event);
37 : // Unblocking onload on the same document that it was blocked even if
38 : // the element has moved between docs since blocking.
39 21 : mDocument->UnblockOnload(false);
40 42 : return NS_OK;
41 : }
|