tor-browser

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

TimeEvent.cpp (1934B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "mozilla/dom/TimeEvent.h"
      8 
      9 #include "mozilla/ContentEvents.h"
     10 #include "nsGlobalWindowInner.h"
     11 #include "nsIDocShell.h"
     12 #include "nsIInterfaceRequestorUtils.h"
     13 #include "nsPresContext.h"
     14 
     15 namespace mozilla::dom {
     16 
     17 TimeEvent::TimeEvent(EventTarget* aOwner, nsPresContext* aPresContext,
     18                     InternalSMILTimeEvent* aEvent)
     19    : Event(aOwner, aPresContext,
     20            aEvent ? aEvent : new InternalSMILTimeEvent(false, eVoidEvent)),
     21      mDetail(mEvent->AsSMILTimeEvent()->mDetail) {
     22  if (aEvent) {
     23    mEventIsInternal = false;
     24  } else {
     25    mEventIsInternal = true;
     26  }
     27 
     28  if (mPresContext) {
     29    nsCOMPtr<nsIDocShell> docShell = mPresContext->GetDocShell();
     30    if (docShell) {
     31      mView = docShell->GetWindow();
     32    }
     33  }
     34 }
     35 
     36 NS_IMPL_CYCLE_COLLECTION_INHERITED(TimeEvent, Event, mView)
     37 
     38 NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(TimeEvent, Event)
     39 
     40 void TimeEvent::InitTimeEvent(const nsAString& aType,
     41                              nsGlobalWindowInner* aView, int32_t aDetail) {
     42  NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);
     43 
     44  Event::InitEvent(aType, false /*doesn't bubble*/, false /*can't cancel*/);
     45  mDetail = aDetail;
     46  mView = aView ? aView->GetOuterWindow() : nullptr;
     47 }
     48 
     49 }  // namespace mozilla::dom
     50 
     51 using namespace mozilla;
     52 using namespace mozilla::dom;
     53 
     54 already_AddRefed<TimeEvent> NS_NewDOMTimeEvent(EventTarget* aOwner,
     55                                               nsPresContext* aPresContext,
     56                                               InternalSMILTimeEvent* aEvent) {
     57  return do_AddRef(new TimeEvent(aOwner, aPresContext, aEvent));
     58 }