michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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 "mozilla/dom/TimeEvent.h" michael@0: #include "mozilla/BasicEvents.h" michael@0: #include "nsIInterfaceRequestorUtils.h" michael@0: #include "nsPresContext.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: TimeEvent::TimeEvent(EventTarget* aOwner, michael@0: nsPresContext* aPresContext, michael@0: WidgetEvent* aEvent) michael@0: : Event(aOwner, aPresContext, michael@0: aEvent ? aEvent : new InternalUIEvent(false, 0)) michael@0: , mDetail(0) michael@0: { michael@0: SetIsDOMBinding(); michael@0: if (aEvent) { michael@0: mEventIsInternal = false; michael@0: } else { michael@0: mEventIsInternal = true; michael@0: mEvent->eventStructType = NS_SMIL_TIME_EVENT; michael@0: } michael@0: michael@0: if (mEvent->eventStructType == NS_SMIL_TIME_EVENT) { michael@0: mDetail = mEvent->AsUIEvent()->detail; michael@0: } michael@0: michael@0: mEvent->mFlags.mBubbles = false; michael@0: mEvent->mFlags.mCancelable = false; michael@0: michael@0: if (mPresContext) { michael@0: nsISupports* container = mPresContext->GetContainerWeak(); michael@0: if (container) { michael@0: nsCOMPtr window = do_GetInterface(container); michael@0: if (window) { michael@0: mView = do_QueryInterface(window); michael@0: } michael@0: } michael@0: } michael@0: } michael@0: michael@0: NS_IMPL_CYCLE_COLLECTION_INHERITED(TimeEvent, Event, michael@0: mView) michael@0: michael@0: NS_IMPL_ADDREF_INHERITED(TimeEvent, Event) michael@0: NS_IMPL_RELEASE_INHERITED(TimeEvent, Event) michael@0: michael@0: NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TimeEvent) michael@0: NS_INTERFACE_MAP_ENTRY(nsIDOMTimeEvent) michael@0: NS_INTERFACE_MAP_END_INHERITING(Event) michael@0: michael@0: NS_IMETHODIMP michael@0: TimeEvent::GetView(nsIDOMWindow** aView) michael@0: { michael@0: *aView = mView; michael@0: NS_IF_ADDREF(*aView); michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: TimeEvent::GetDetail(int32_t* aDetail) michael@0: { michael@0: *aDetail = mDetail; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: TimeEvent::InitTimeEvent(const nsAString& aTypeArg, michael@0: nsIDOMWindow* aViewArg, michael@0: int32_t aDetailArg) michael@0: { michael@0: nsresult rv = Event::InitEvent(aTypeArg, false /*doesn't bubble*/, michael@0: false /*can't cancel*/); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: mDetail = aDetailArg; michael@0: mView = aViewArg; michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: using namespace mozilla; michael@0: using namespace mozilla::dom; michael@0: michael@0: nsresult michael@0: NS_NewDOMTimeEvent(nsIDOMEvent** aInstancePtrResult, michael@0: EventTarget* aOwner, michael@0: nsPresContext* aPresContext, michael@0: WidgetEvent* aEvent) michael@0: { michael@0: TimeEvent* it = new TimeEvent(aOwner, aPresContext, aEvent); michael@0: NS_ADDREF(it); michael@0: *aInstancePtrResult = static_cast(it); michael@0: return NS_OK; michael@0: }