2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2014-02-27 14:51:13 +04: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/. */
|
|
|
|
|
|
|
|
#include "mozilla/dom/FocusEvent.h"
|
|
|
|
#include "mozilla/ContentEvents.h"
|
|
|
|
#include "prtime.h"
|
|
|
|
|
2020-11-04 20:04:01 +03:00
|
|
|
namespace mozilla::dom {
|
2014-02-27 14:51:13 +04:00
|
|
|
|
|
|
|
FocusEvent::FocusEvent(EventTarget* aOwner, nsPresContext* aPresContext,
|
|
|
|
InternalFocusEvent* aEvent)
|
2014-02-28 18:58:43 +04:00
|
|
|
: UIEvent(aOwner, aPresContext,
|
2015-09-02 09:08:00 +03:00
|
|
|
aEvent ? aEvent : new InternalFocusEvent(false, eFocus)) {
|
2014-02-27 14:51:13 +04:00
|
|
|
if (aEvent) {
|
|
|
|
mEventIsInternal = false;
|
|
|
|
} else {
|
|
|
|
mEventIsInternal = true;
|
2016-03-28 07:29:42 +03:00
|
|
|
mEvent->mTime = PR_Now();
|
2014-02-27 14:51:13 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<EventTarget> FocusEvent::GetRelatedTarget() {
|
2016-12-19 14:36:48 +03:00
|
|
|
return EnsureWebAccessibleRelatedTarget(
|
|
|
|
mEvent->AsFocusEvent()->mRelatedTarget);
|
2014-02-27 14:51:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void FocusEvent::InitFocusEvent(const nsAString& aType, bool aCanBubble,
|
2017-11-07 01:52:14 +03:00
|
|
|
bool aCancelable, nsGlobalWindowInner* aView,
|
2014-02-27 14:51:13 +04:00
|
|
|
int32_t aDetail, EventTarget* aRelatedTarget) {
|
2016-10-30 22:30:06 +03:00
|
|
|
MOZ_ASSERT(!mEvent->mFlags.mIsBeingDispatched);
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
|
2016-03-27 08:46:48 +03:00
|
|
|
mEvent->AsFocusEvent()->mRelatedTarget = aRelatedTarget;
|
2014-02-27 14:51:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<FocusEvent> FocusEvent::Constructor(
|
|
|
|
const GlobalObject& aGlobal, const nsAString& aType,
|
2019-09-11 17:35:28 +03:00
|
|
|
const FocusEventInit& aParam) {
|
2014-02-27 14:51:13 +04:00
|
|
|
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<FocusEvent> e = new FocusEvent(t, nullptr, nullptr);
|
2014-02-27 14:51:13 +04:00
|
|
|
bool trusted = e->Init(t);
|
2016-01-30 20:05:36 +03:00
|
|
|
e->InitFocusEvent(aType, aParam.mBubbles, aParam.mCancelable, aParam.mView,
|
|
|
|
aParam.mDetail, aParam.mRelatedTarget);
|
2014-02-27 14:51:13 +04:00
|
|
|
e->SetTrusted(trusted);
|
2016-08-31 06:16:11 +03:00
|
|
|
e->SetComposed(aParam.mComposed);
|
2014-02-27 14:51:13 +04:00
|
|
|
return e.forget();
|
|
|
|
}
|
|
|
|
|
2020-11-04 20:04:01 +03:00
|
|
|
} // namespace mozilla::dom
|
2014-02-27 14:51:13 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2015-08-12 14:39:31 +03:00
|
|
|
already_AddRefed<FocusEvent> NS_NewDOMFocusEvent(EventTarget* aOwner,
|
2014-02-27 14:51:13 +04:00
|
|
|
nsPresContext* aPresContext,
|
|
|
|
InternalFocusEvent* aEvent) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<FocusEvent> it = new FocusEvent(aOwner, aPresContext, aEvent);
|
2015-08-12 14:39:31 +03:00
|
|
|
return it.forget();
|
2014-02-27 14:51:13 +04:00
|
|
|
}
|