michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsHtml5SVGLoadDispatcher.h" michael@0: #include "nsPresContext.h" michael@0: #include "nsIPresShell.h" michael@0: #include "mozilla/BasicEvents.h" michael@0: #include "mozilla/EventDispatcher.h" michael@0: #include "nsIDocument.h" michael@0: michael@0: using namespace mozilla; michael@0: michael@0: nsHtml5SVGLoadDispatcher::nsHtml5SVGLoadDispatcher(nsIContent* aElement) michael@0: : mElement(aElement) michael@0: , mDocument(mElement->OwnerDoc()) michael@0: { michael@0: mDocument->BlockOnload(); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsHtml5SVGLoadDispatcher::Run() michael@0: { michael@0: WidgetEvent event(true, NS_SVG_LOAD); michael@0: event.mFlags.mBubbles = false; michael@0: // Do we care about forcing presshell creation if it hasn't happened yet? michael@0: // That is, should this code flush or something? Does it really matter? michael@0: // For that matter, do we really want to try getting the prescontext? michael@0: // Does this event ever want one? michael@0: nsRefPtr ctx; michael@0: nsCOMPtr shell = mElement->OwnerDoc()->GetShell(); michael@0: if (shell) { michael@0: ctx = shell->GetPresContext(); michael@0: } michael@0: EventDispatcher::Dispatch(mElement, ctx, &event); michael@0: // Unblocking onload on the same document that it was blocked even if michael@0: // the element has moved between docs since blocking. michael@0: mDocument->UnblockOnload(false); michael@0: return NS_OK; michael@0: }