2012-05-29 08:52:43 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-07-18 15:07:54 -07:00
|
|
|
|
|
|
|
#include "nsHtml5SVGLoadDispatcher.h"
|
|
|
|
#include "nsPresContext.h"
|
|
|
|
#include "nsEventDispatcher.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsGUIEvent.h"
|
|
|
|
|
|
|
|
nsHtml5SVGLoadDispatcher::nsHtml5SVGLoadDispatcher(nsIContent* aElement)
|
|
|
|
: mElement(aElement)
|
2011-10-18 03:53:36 -07:00
|
|
|
, mDocument(mElement->OwnerDoc())
|
2010-07-18 15:07:54 -07:00
|
|
|
{
|
|
|
|
mDocument->BlockOnload();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHtml5SVGLoadDispatcher::Run()
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
nsEvent event(true, NS_SVG_LOAD);
|
2012-12-15 17:26:03 -08:00
|
|
|
event.mFlags.mBubbles = false;
|
2010-07-18 15:07:54 -07:00
|
|
|
// 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;
|
2011-10-18 03:53:36 -07:00
|
|
|
nsCOMPtr<nsIPresShell> shell = mElement->OwnerDoc()->GetShell();
|
2010-07-18 15:07:54 -07:00
|
|
|
if (shell) {
|
|
|
|
ctx = shell->GetPresContext();
|
|
|
|
}
|
|
|
|
nsEventDispatcher::Dispatch(mElement, ctx, &event);
|
|
|
|
// Unblocking onload on the same document that it was blocked even if
|
|
|
|
// the element has moved between docs since blocking.
|
2011-10-17 07:59:28 -07:00
|
|
|
mDocument->UnblockOnload(false);
|
2010-07-18 15:07:54 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|