dom/events/FocusEvent.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "mozilla/dom/FocusEvent.h"
michael@0 7 #include "mozilla/ContentEvents.h"
michael@0 8 #include "prtime.h"
michael@0 9
michael@0 10 namespace mozilla {
michael@0 11 namespace dom {
michael@0 12
michael@0 13 NS_IMPL_ISUPPORTS_INHERITED(FocusEvent, UIEvent, nsIDOMFocusEvent)
michael@0 14
michael@0 15 FocusEvent::FocusEvent(EventTarget* aOwner,
michael@0 16 nsPresContext* aPresContext,
michael@0 17 InternalFocusEvent* aEvent)
michael@0 18 : UIEvent(aOwner, aPresContext,
michael@0 19 aEvent ? aEvent : new InternalFocusEvent(false, NS_FOCUS_CONTENT))
michael@0 20 {
michael@0 21 if (aEvent) {
michael@0 22 mEventIsInternal = false;
michael@0 23 } else {
michael@0 24 mEventIsInternal = true;
michael@0 25 mEvent->time = PR_Now();
michael@0 26 }
michael@0 27 }
michael@0 28
michael@0 29 /* readonly attribute nsIDOMEventTarget relatedTarget; */
michael@0 30 NS_IMETHODIMP
michael@0 31 FocusEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget)
michael@0 32 {
michael@0 33 NS_ENSURE_ARG_POINTER(aRelatedTarget);
michael@0 34 NS_IF_ADDREF(*aRelatedTarget = GetRelatedTarget());
michael@0 35 return NS_OK;
michael@0 36 }
michael@0 37
michael@0 38 EventTarget*
michael@0 39 FocusEvent::GetRelatedTarget()
michael@0 40 {
michael@0 41 return mEvent->AsFocusEvent()->relatedTarget;
michael@0 42 }
michael@0 43
michael@0 44 nsresult
michael@0 45 FocusEvent::InitFocusEvent(const nsAString& aType,
michael@0 46 bool aCanBubble,
michael@0 47 bool aCancelable,
michael@0 48 nsIDOMWindow* aView,
michael@0 49 int32_t aDetail,
michael@0 50 EventTarget* aRelatedTarget)
michael@0 51 {
michael@0 52 nsresult rv =
michael@0 53 UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
michael@0 54 NS_ENSURE_SUCCESS(rv, rv);
michael@0 55 mEvent->AsFocusEvent()->relatedTarget = aRelatedTarget;
michael@0 56 return NS_OK;
michael@0 57 }
michael@0 58
michael@0 59 already_AddRefed<FocusEvent>
michael@0 60 FocusEvent::Constructor(const GlobalObject& aGlobal,
michael@0 61 const nsAString& aType,
michael@0 62 const FocusEventInit& aParam,
michael@0 63 ErrorResult& aRv)
michael@0 64 {
michael@0 65 nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
michael@0 66 nsRefPtr<FocusEvent> e = new FocusEvent(t, nullptr, nullptr);
michael@0 67 bool trusted = e->Init(t);
michael@0 68 aRv = e->InitFocusEvent(aType, aParam.mBubbles, aParam.mCancelable, aParam.mView,
michael@0 69 aParam.mDetail, aParam.mRelatedTarget);
michael@0 70 e->SetTrusted(trusted);
michael@0 71 return e.forget();
michael@0 72 }
michael@0 73
michael@0 74 } // namespace dom
michael@0 75 } // namespace mozilla
michael@0 76
michael@0 77 using namespace mozilla;
michael@0 78 using namespace mozilla::dom;
michael@0 79
michael@0 80 nsresult
michael@0 81 NS_NewDOMFocusEvent(nsIDOMEvent** aInstancePtrResult,
michael@0 82 EventTarget* aOwner,
michael@0 83 nsPresContext* aPresContext,
michael@0 84 InternalFocusEvent* aEvent)
michael@0 85 {
michael@0 86 FocusEvent* it = new FocusEvent(aOwner, aPresContext, aEvent);
michael@0 87 NS_ADDREF(it);
michael@0 88 *aInstancePtrResult = static_cast<Event*>(it);
michael@0 89 return NS_OK;
michael@0 90 }

mercurial