tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsHtml5SVGLoadDispatcher.cpp (1436B)


      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 "mozilla/BasicEvents.h"
      7 #include "mozilla/EventDispatcher.h"
      8 #include "mozilla/dom/Document.h"
      9 #include "mozilla/dom/DocumentInlines.h"
     10 #include "nsPresContext.h"
     11 
     12 using namespace mozilla;
     13 
     14 nsHtml5SVGLoadDispatcher::nsHtml5SVGLoadDispatcher(nsIContent* aElement)
     15    : Runnable("nsHtml5SVGLoadDispatcher"),
     16      mElement(aElement),
     17      mDocument(mElement->OwnerDoc()) {
     18  mDocument->BlockOnload();
     19 }
     20 
     21 // TODO: Convert this to MOZ_CAN_RUN_SCRIPT (bug 1415230, bug 1535398)
     22 MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP nsHtml5SVGLoadDispatcher::Run() {
     23  WidgetEvent event(true, eSVGLoad);
     24  event.mFlags.mBubbles = false;
     25  // Do we care about forcing presshell creation if it hasn't happened yet?
     26  // That is, should this code flush or something?  Does it really matter?
     27  // For that matter, do we really want to try getting the prescontext?
     28  // Does this event ever want one?
     29  RefPtr<nsPresContext> ctx = mElement->OwnerDoc()->GetPresContext();
     30  EventDispatcher::Dispatch(mElement, ctx, &event);
     31  // Unblocking onload on the same document that it was blocked even if
     32  // the element has moved between docs since blocking.
     33  mDocument->UnblockOnload(false);
     34  return NS_OK;
     35 }