--- a/dom/base/TextInputProcessor.cpp
+++ b/dom/base/TextInputProcessor.cpp
@@ -339,17 +339,17 @@ TextInputProcessor::PrepareKeyboardEvent
uint32_t& aKeyFlags,
uint8_t aOptionalArgc,
WidgetKeyboardEvent*& aKeyboardEvent)
{
aKeyboardEvent = nullptr;
aKeyboardEvent =
aOptionalArgc && aDOMKeyEvent ?
- aDOMKeyEvent->GetInternalNSEvent()->AsKeyboardEvent() : nullptr;
+ aDOMKeyEvent->AsEvent()->GetInternalNSEvent()->AsKeyboardEvent() : nullptr;
if (!aKeyboardEvent || aOptionalArgc < 2) {
aKeyFlags = 0;
}
if (!aKeyboardEvent) {
return NS_OK;
}
@@ -764,17 +764,17 @@ TextInputProcessor::Keydown(nsIDOMKeyEve
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
if (!aOptionalArgc) {
aKeyFlags = 0;
}
if (NS_WARN_IF(!aDOMKeyEvent)) {
return NS_ERROR_INVALID_ARG;
}
WidgetKeyboardEvent* originalKeyEvent =
- aDOMKeyEvent->GetInternalNSEvent()->AsKeyboardEvent();
+ aDOMKeyEvent->AsEvent()->GetInternalNSEvent()->AsKeyboardEvent();
if (NS_WARN_IF(!originalKeyEvent)) {
return NS_ERROR_INVALID_ARG;
}
return KeydownInternal(*originalKeyEvent, aKeyFlags, true, *aConsumedFlags);
}
TextEventDispatcher::DispatchTo
TextInputProcessor::GetDispatchTo() const
@@ -870,17 +870,17 @@ TextInputProcessor::Keyup(nsIDOMKeyEvent
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
if (!aOptionalArgc) {
aKeyFlags = 0;
}
if (NS_WARN_IF(!aDOMKeyEvent)) {
return NS_ERROR_INVALID_ARG;
}
WidgetKeyboardEvent* originalKeyEvent =
- aDOMKeyEvent->GetInternalNSEvent()->AsKeyboardEvent();
+ aDOMKeyEvent->AsEvent()->GetInternalNSEvent()->AsKeyboardEvent();
if (NS_WARN_IF(!originalKeyEvent)) {
return NS_ERROR_INVALID_ARG;
}
return KeyupInternal(*originalKeyEvent, aKeyFlags, *aDoDefault);
}
nsresult
TextInputProcessor::KeyupInternal(const WidgetKeyboardEvent& aKeyboardEvent,
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -4950,23 +4950,23 @@ IsCaseChangeableChar(uint32_t aChar)
/* static */
void
nsContentUtils::GetAccelKeyCandidates(nsIDOMKeyEvent* aDOMKeyEvent,
nsTArray<nsShortcutCandidate>& aCandidates)
{
NS_PRECONDITION(aCandidates.IsEmpty(), "aCandidates must be empty");
nsAutoString eventType;
- aDOMKeyEvent->GetType(eventType);
+ aDOMKeyEvent->AsEvent()->GetType(eventType);
// Don't process if aDOMKeyEvent is not a keypress event.
if (!eventType.EqualsLiteral("keypress"))
return;
WidgetKeyboardEvent* nativeKeyEvent =
- aDOMKeyEvent->GetInternalNSEvent()->AsKeyboardEvent();
+ aDOMKeyEvent->AsEvent()->GetInternalNSEvent()->AsKeyboardEvent();
if (nativeKeyEvent) {
NS_ASSERTION(nativeKeyEvent->mClass == eKeyboardEventClass,
"wrong type of native event");
// nsShortcutCandidate::mCharCode is a candidate charCode.
// nsShoftcutCandidate::mIgnoreShift means the mCharCode should be tried to
// execute a command with/without shift key state. If this is TRUE, the
// shifted key state should be ignored. Otherwise, don't ignore the state.
// the priority of the charCodes are (shift key is not pressed):
--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -579,30 +579,30 @@ IMEStateManager::OnMouseButtonEventInEdi
if (!sActiveIMEContentObserver->IsManaging(aPresContext, aContent)) {
MOZ_LOG(sISMLog, LogLevel::Debug,
("ISM: IMEStateManager::OnMouseButtonEventInEditor(), "
"the active IMEContentObserver isn't managing the editor"));
return false;
}
WidgetMouseEvent* internalEvent =
- aMouseEvent->GetInternalNSEvent()->AsMouseEvent();
+ aMouseEvent->AsEvent()->GetInternalNSEvent()->AsMouseEvent();
if (NS_WARN_IF(!internalEvent)) {
MOZ_LOG(sISMLog, LogLevel::Debug,
("ISM: IMEStateManager::OnMouseButtonEventInEditor(), "
"the internal event of aMouseEvent isn't WidgetMouseEvent"));
return false;
}
bool consumed =
sActiveIMEContentObserver->OnMouseButtonEvent(aPresContext, internalEvent);
if (MOZ_LOG_TEST(sISMLog, LogLevel::Info)) {
nsAutoString eventType;
- aMouseEvent->GetType(eventType);
+ aMouseEvent->AsEvent()->GetType(eventType);
MOZ_LOG(sISMLog, LogLevel::Info,
("ISM: IMEStateManager::OnMouseButtonEventInEditor(), "
"mouse event (type=%s, button=%d) is %s",
NS_ConvertUTF16toUTF8(eventType).get(), internalEvent->button,
consumed ? "consumed" : "not consumed"));
}
return consumed;
@@ -625,17 +625,17 @@ IMEStateManager::OnClickInEditor(nsPresC
"the mouse event isn't fired on the editor managed by ISM"));
return;
}
nsCOMPtr<nsIWidget> widget = aPresContext->GetRootWidget();
NS_ENSURE_TRUE_VOID(widget);
bool isTrusted;
- nsresult rv = aMouseEvent->GetIsTrusted(&isTrusted);
+ nsresult rv = aMouseEvent->AsEvent()->GetIsTrusted(&isTrusted);
NS_ENSURE_SUCCESS_VOID(rv);
if (!isTrusted) {
MOZ_LOG(sISMLog, LogLevel::Debug,
("ISM: IMEStateManager::OnClickInEditor(), "
"the mouse event isn't a trusted event"));
return; // ignore untrusted event.
}
--- a/dom/events/UIEvent.cpp
+++ b/dom/events/UIEvent.cpp
@@ -341,16 +341,22 @@ UIEvent::GetIsChar(bool* aIsChar)
bool
UIEvent::IsChar() const
{
WidgetKeyboardEvent* keyEvent = mEvent->AsKeyboardEvent();
return keyEvent ? keyEvent->isChar : false;
}
+mozilla::dom::Event*
+UIEvent::AsEvent(void)
+{
+ return this;
+}
+
NS_IMETHODIMP
UIEvent::DuplicatePrivateData()
{
mClientPoint =
Event::GetClientCoords(mPresContext, mEvent, mEvent->refPoint,
mClientPoint);
mMovementPoint = GetMovementPoint();
mLayerPoint = GetLayerPoint();
--- a/dom/interfaces/events/nsIDOMAnimationEvent.idl
+++ b/dom/interfaces/events/nsIDOMAnimationEvent.idl
@@ -1,19 +1,20 @@
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
/* 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 "nsIDOMEvent.idl"
+#include "nsISupports.idl"
/**
* Animation events are defined in:
* http://www.w3.org/TR/css3-animations/#animation-events-
* http://dev.w3.org/csswg/css3-animations/#animation-events-
*/
-[builtinclass, uuid(772c7069-3f7d-42cf-97ab-b32f1c0b83da)]
-interface nsIDOMAnimationEvent : nsIDOMEvent {
+[builtinclass, uuid(ce6d1db3-53b8-4ade-9baa-70f4947200a2)]
+interface nsIDOMAnimationEvent : nsISupports
+{
readonly attribute DOMString animationName;
readonly attribute float elapsedTime;
readonly attribute DOMString pseudoElement;
};
--- a/dom/interfaces/events/nsIDOMBeforeUnloadEvent.idl
+++ b/dom/interfaces/events/nsIDOMBeforeUnloadEvent.idl
@@ -1,26 +1,26 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 "nsIDOMEvent.idl"
+#include "nsISupports.idl"
/**
* The nsIDOMBeforeUnloadEvent interface is the interface for events
* sent to handlers of the "beforeunload" event. This event is
* non-standard. Interface derived from Microsoft IE's event
* implementation.
*
* http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/events.asp
*
*/
-[builtinclass, uuid(96abf41b-32a8-4ff6-a0d6-4ade4ddebf89)]
-interface nsIDOMBeforeUnloadEvent : nsIDOMEvent
+[builtinclass, uuid(26c83933-a5a4-455e-8c46-69fa24dfa991)]
+interface nsIDOMBeforeUnloadEvent : nsISupports
{
/**
* Attribute used to pass back a return value from a beforeunload
* handler
*/
attribute DOMString returnValue;
};
--- a/dom/interfaces/events/nsIDOMClipboardEvent.idl
+++ b/dom/interfaces/events/nsIDOMClipboardEvent.idl
@@ -1,20 +1,20 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 "domstubs.idl"
-#include "nsIDOMEvent.idl"
+#include "nsISupports.idl"
interface nsIDOMDataTransfer;
-[builtinclass, uuid(4ef84980-52c2-425c-b41a-2ee75ec5d497)]
-interface nsIDOMClipboardEvent : nsIDOMEvent
+[builtinclass, uuid(b54d6144-3980-4895-83c7-82f158bc1cf5)]
+interface nsIDOMClipboardEvent : nsISupports
{
readonly attribute nsIDOMDataTransfer clipboardData;
// The constructor must be used from script to initialize
// clipboard events.
[noscript] void initClipboardEvent(in DOMString typeArg,
in boolean canBubbleArg,
in boolean cancelableArg,
--- a/dom/interfaces/events/nsIDOMCommandEvent.idl
+++ b/dom/interfaces/events/nsIDOMCommandEvent.idl
@@ -1,17 +1,17 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 "nsIDOMEvent.idl"
+#include "nsISupports.idl"
-[builtinclass, uuid(7efbe68a-811a-4159-801c-226948cfd08f)]
-interface nsIDOMCommandEvent : nsIDOMEvent
+[builtinclass, uuid(73a50e55-3eaa-4a38-a588-9b68a6d65032)]
+interface nsIDOMCommandEvent : nsISupports
{
readonly attribute DOMString command;
void initCommandEvent(in DOMString typeArg,
in boolean canBubbleArg,
in boolean canCancelArg,
in DOMString command);
};
--- a/dom/interfaces/events/nsIDOMDataContainerEvent.idl
+++ b/dom/interfaces/events/nsIDOMDataContainerEvent.idl
@@ -1,18 +1,18 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 "nsIDOMEvent.idl"
+#include "nsISupports.idl"
#include "nsIVariant.idl"
-[builtinclass, uuid(31ceb43e-5f49-43bf-9a18-3b60a535c814)]
-interface nsIDOMDataContainerEvent : nsIDOMEvent
+[builtinclass, uuid(a9f1f528-d106-4fea-8663-2d7f64b627a9)]
+interface nsIDOMDataContainerEvent : nsISupports
{
/**
* Return the data associated with the given key.
*
* @param key the key
* @return the data associated with the key
*/
nsIVariant getData(in DOMString key);
--- a/dom/interfaces/events/nsIDOMMessageEvent.idl
+++ b/dom/interfaces/events/nsIDOMMessageEvent.idl
@@ -1,24 +1,25 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 "nsIDOMEvent.idl"
+#include "nsISupports.idl"
+#include "nsIDOMWindow.idl"
/**
* The nsIDOMMessageEvent interface is used for server-sent events and for
* cross-domain messaging.
*
* For more information on this interface, please see
* http://www.whatwg.org/specs/web-apps/current-work/#messageevent
*/
-[builtinclass, uuid(4408a2f5-614f-40a3-8786-e16bd3f74e32)]
-interface nsIDOMMessageEvent : nsIDOMEvent
+[builtinclass, uuid(5d57bc56-30cf-4839-9e98-17f940120ec0)]
+interface nsIDOMMessageEvent : nsISupports
{
/**
* Custom string data associated with this event.
*/
[implicit_jscontext]
readonly attribute jsval data;
/**
--- a/dom/interfaces/events/nsIDOMMutationEvent.idl
+++ b/dom/interfaces/events/nsIDOMMutationEvent.idl
@@ -1,17 +1,18 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 "nsIDOMEvent.idl"
+#include "nsISupports.idl"
+#include "nsIDOMNode.idl"
-[builtinclass, uuid(df7e4cd9-e41f-4c8e-a764-2e3191d2f463)]
-interface nsIDOMMutationEvent : nsIDOMEvent
+[builtinclass, uuid(30c9997f-bc4c-4890-b890-febb6ae3051b)]
+interface nsIDOMMutationEvent : nsISupports
{
const unsigned short MODIFICATION = 1;
const unsigned short ADDITION = 2;
const unsigned short REMOVAL = 3;
readonly attribute nsIDOMNode relatedNode;
readonly attribute DOMString prevValue;
readonly attribute DOMString newValue;
--- a/dom/interfaces/events/nsIDOMNotifyPaintEvent.idl
+++ b/dom/interfaces/events/nsIDOMNotifyPaintEvent.idl
@@ -1,24 +1,26 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 "nsIDOMEvent.idl"
+#include "nsISupports.idl"
+#include "nsIDOMClientRectList.idl"
+#include "nsIDOMClientRect.idl"
interface nsIDOMPaintRequestList;
/**
* The nsIDOMNotifyPaintEvent interface is used for the MozDOMAfterPaint
* event, which fires at a window when painting has happened in
* that window.
*/
-[builtinclass, uuid(550f660c-65a5-4e17-b828-3dbec7c44304)]
-interface nsIDOMNotifyPaintEvent : nsIDOMEvent
+[builtinclass, uuid(63f573a0-3e4e-474b-a0c2-bb4ca93febaa)]
+interface nsIDOMNotifyPaintEvent : nsISupports
{
/**
* Get a list of rectangles which are affected. The rectangles are in CSS pixels
* relative to the viewport origin.
* If the caller is not trusted (e.g., regular Web content) then only painting
* caused by the current document is reported; in particular, painting in subdocuments
* is not reported.
*/
--- a/dom/interfaces/events/nsIDOMTransitionEvent.idl
+++ b/dom/interfaces/events/nsIDOMTransitionEvent.idl
@@ -1,19 +1,19 @@
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
/* 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 "nsIDOMEvent.idl"
+#include "nsISupports.idl"
/**
* Transition events are defined in:
* http://www.w3.org/TR/css3-transitions/#transition-events-
* http://dev.w3.org/csswg/css3-transitions/#transition-events-
*/
-[builtinclass, uuid(acb69403-0dcb-4db0-9ffc-8a22cc56c4eb)]
-interface nsIDOMTransitionEvent : nsIDOMEvent {
+[builtinclass, uuid(ee3499bf-0f14-4bb6-829c-19ad24fd4a85)]
+interface nsIDOMTransitionEvent : nsISupports {
readonly attribute DOMString propertyName;
readonly attribute float elapsedTime;
readonly attribute DOMString pseudoElement;
};
--- a/dom/interfaces/events/nsIDOMUIEvent.idl
+++ b/dom/interfaces/events/nsIDOMUIEvent.idl
@@ -1,25 +1,36 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 "nsIDOMEvent.idl"
+#include "nsISupports.idl"
+#include "nsIDOMWindow.idl"
/**
* The nsIDOMUIEvent interface is the datatype for all UI events in the
* Document Object Model.
*
* For more information on this interface please see
* http://www.w3.org/TR/DOM-Level-2-Events/
*/
-[builtinclass, uuid(db058d10-1db9-4cf9-bb4c-483c304a137f)]
-interface nsIDOMUIEvent : nsIDOMEvent
+%{C++
+namespace mozilla {
+namespace dom {
+class Event;
+}
+}
+%}
+
+[ptr] native EventPtr(mozilla::dom::Event);
+
+[builtinclass, uuid(75996b57-51f0-4c9c-aaaa-e35eaf347b66)]
+interface nsIDOMUIEvent : nsISupports
{
readonly attribute nsIDOMWindow view;
readonly attribute long detail;
void initUIEvent(in DOMString typeArg,
in boolean canBubbleArg,
in boolean cancelableArg,
in nsIDOMWindow viewArg,
in long detailArg);
@@ -33,9 +44,11 @@ interface nsIDOMUIEvent : nsIDOMEvent
readonly attribute long pageY;
readonly attribute unsigned long which;
readonly attribute nsIDOMNode rangeParent;
readonly attribute long rangeOffset;
attribute boolean cancelBubble;
readonly attribute boolean isChar;
+
+ [notxpcom, nostdcall] EventPtr AsEvent();
};
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -50,16 +50,17 @@ using mozilla::DefaultXDisplay;
#include "ImageContainer.h"
#include "nsIDOMHTMLCollection.h"
#include "GLContext.h"
#include "EGLUtils.h"
#include "nsIContentInlines.h"
#include "mozilla/MiscEvents.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/TextEvents.h"
+#include "mozilla/dom/Event.h"
#include "mozilla/dom/HTMLObjectElementBinding.h"
#include "mozilla/dom/TabChild.h"
#include "nsFrameSelection.h"
#include "PuppetWidget.h"
#include "nsPIWindowRoot.h"
#include "mozilla/IMEStateManager.h"
#include "mozilla/TextComposition.h"
#include "mozilla/AutoRestore.h"
--- a/dom/xbl/nsXBLEventHandler.cpp
+++ b/dom/xbl/nsXBLEventHandler.cpp
@@ -85,28 +85,28 @@ nsXBLKeyEventHandler::~nsXBLKeyEventHand
NS_IMPL_ISUPPORTS(nsXBLKeyEventHandler, nsIDOMEventListener)
bool
nsXBLKeyEventHandler::ExecuteMatchedHandlers(
nsIDOMKeyEvent* aKeyEvent,
uint32_t aCharCode,
const IgnoreModifierState& aIgnoreModifierState)
{
- WidgetEvent* event = aKeyEvent->GetInternalNSEvent();
- nsCOMPtr<EventTarget> target = aKeyEvent->InternalDOMEvent()->GetCurrentTarget();
+ WidgetEvent* event = aKeyEvent->AsEvent()->GetInternalNSEvent();
+ nsCOMPtr<EventTarget> target = aKeyEvent->AsEvent()->InternalDOMEvent()->GetCurrentTarget();
bool executed = false;
for (uint32_t i = 0; i < mProtoHandlers.Length(); ++i) {
nsXBLPrototypeHandler* handler = mProtoHandlers[i];
bool hasAllowUntrustedAttr = handler->HasAllowUntrustedAttr();
if ((event->mFlags.mIsTrusted ||
(hasAllowUntrustedAttr && handler->AllowUntrustedEvents()) ||
(!hasAllowUntrustedAttr && !mIsBoundToChrome && !mUsingContentXBLScope)) &&
handler->KeyEventMatched(aKeyEvent, aCharCode, aIgnoreModifierState)) {
- handler->ExecuteHandler(target, aKeyEvent);
+ handler->ExecuteHandler(target, aKeyEvent->AsEvent());
executed = true;
}
}
#ifdef XP_WIN
// Windows native applications ignore Windows-Logo key state when checking
// shortcut keys even if the key is pressed. Therefore, if there is no
// shortcut key which exactly matches current modifier state, we should
// retry to look for a shortcut key without the Windows-Logo key press.
--- a/dom/xbl/nsXBLPrototypeHandler.cpp
+++ b/dom/xbl/nsXBLPrototypeHandler.cpp
@@ -904,17 +904,17 @@ nsXBLPrototypeHandler::ReportKeyConflict
nullptr, EmptyString(), mLineNumber);
}
bool
nsXBLPrototypeHandler::ModifiersMatchMask(
nsIDOMUIEvent* aEvent,
const IgnoreModifierState& aIgnoreModifierState)
{
- WidgetInputEvent* inputEvent = aEvent->GetInternalNSEvent()->AsInputEvent();
+ WidgetInputEvent* inputEvent = aEvent->AsEvent()->GetInternalNSEvent()->AsInputEvent();
NS_ENSURE_TRUE(inputEvent, false);
if (mKeyMask & cMetaMask) {
if (inputEvent->IsMeta() != ((mKeyMask & cMeta) != 0)) {
return false;
}
}
--- a/dom/xbl/nsXBLWindowKeyHandler.cpp
+++ b/dom/xbl/nsXBLWindowKeyHandler.cpp
@@ -257,36 +257,36 @@ nsXBLWindowKeyHandler::EnsureHandlers()
return NS_OK;
}
nsresult
nsXBLWindowKeyHandler::WalkHandlers(nsIDOMKeyEvent* aKeyEvent, nsIAtom* aEventType)
{
bool prevent;
- aKeyEvent->GetDefaultPrevented(&prevent);
+ aKeyEvent->AsEvent()->GetDefaultPrevented(&prevent);
if (prevent)
return NS_OK;
bool trustedEvent = false;
// Don't process the event if it was not dispatched from a trusted source
- aKeyEvent->GetIsTrusted(&trustedEvent);
+ aKeyEvent->AsEvent()->GetIsTrusted(&trustedEvent);
if (!trustedEvent)
return NS_OK;
nsresult rv = EnsureHandlers();
NS_ENSURE_SUCCESS(rv, rv);
bool isDisabled;
nsCOMPtr<Element> el = GetElement(&isDisabled);
if (!el) {
if (mUserHandler) {
WalkHandlersInternal(aKeyEvent, aEventType, mUserHandler, true);
- aKeyEvent->GetDefaultPrevented(&prevent);
+ aKeyEvent->AsEvent()->GetDefaultPrevented(&prevent);
if (prevent)
return NS_OK; // Handled by the user bindings. Our work here is done.
}
}
// skip keysets that are disabled
if (el && isDisabled) {
return NS_OK;
@@ -317,24 +317,24 @@ nsXBLWindowKeyHandler::HandleEvent(nsIDO
return WalkHandlers(keyEvent, eventTypeAtom);
}
void
nsXBLWindowKeyHandler::HandleEventOnCapture(nsIDOMKeyEvent* aEvent)
{
WidgetKeyboardEvent* widgetEvent =
- aEvent->GetInternalNSEvent()->AsKeyboardEvent();
+ aEvent->AsEvent()->GetInternalNSEvent()->AsKeyboardEvent();
if (widgetEvent->mFlags.mNoCrossProcessBoundaryForwarding) {
return;
}
nsCOMPtr<mozilla::dom::Element> originalTarget =
- do_QueryInterface(aEvent->GetInternalNSEvent()->originalTarget);
+ do_QueryInterface(aEvent->AsEvent()->GetInternalNSEvent()->originalTarget);
if (!EventStateManager::IsRemoteTarget(originalTarget)) {
return;
}
bool aReservedForChrome = false;
if (!HasHandlerForEvent(aEvent, &aReservedForChrome)) {
return;
}
@@ -348,17 +348,17 @@ nsXBLWindowKeyHandler::HandleEventOnCapt
// Inform the child process that this is a event that we want a reply
// from.
widgetEvent->mFlags.mWantReplyFromContentProcess = true;
// If this event hadn't been marked as mNoCrossProcessBoundaryForwarding
// yet, it means it wasn't processed by content. We'll not call any
// of the handlers at this moment, and will wait for the event to be
// redispatched with mNoCrossProcessBoundaryForwarding = 1 to process it.
- aEvent->StopPropagation();
+ aEvent->AsEvent()->StopPropagation();
}
}
//
// EventMatched
//
// See if the given handler cares about this particular key event
//
@@ -473,17 +473,17 @@ nsXBLWindowKeyHandler::WalkHandlersAndEx
bool aExecute,
bool* aOutReservedForChrome)
{
nsresult rv;
// Try all of the handlers until we find one that matches the event.
for (nsXBLPrototypeHandler *currHandler = aHandler; currHandler;
currHandler = currHandler->GetNextHandler()) {
- bool stopped = aKeyEvent->IsDispatchStopped();
+ bool stopped = aKeyEvent->AsEvent()->IsDispatchStopped();
if (stopped) {
// The event is finished, don't execute any more handlers
return false;
}
if (!EventMatched(currHandler, aEventType, aKeyEvent,
aCharCode, aIgnoreModifierState)) {
continue; // try the next one
@@ -547,61 +547,61 @@ nsXBLWindowKeyHandler::WalkHandlersAndEx
} else {
piTarget = mTarget;
}
if (!aExecute) {
return true;
}
- rv = currHandler->ExecuteHandler(piTarget, aKeyEvent);
+ rv = currHandler->ExecuteHandler(piTarget, aKeyEvent->AsEvent());
if (NS_SUCCEEDED(rv)) {
return true;
}
}
#ifdef XP_WIN
// Windows native applications ignore Windows-Logo key state when checking
// shortcut keys even if the key is pressed. Therefore, if there is no
// shortcut key which exactly matches current modifier state, we should
// retry to look for a shortcut key without the Windows-Logo key press.
if (!aIgnoreModifierState.mOS) {
WidgetKeyboardEvent* keyEvent =
- aKeyEvent->GetInternalNSEvent()->AsKeyboardEvent();
+ aKeyEvent->AsEvent()->GetInternalNSEvent()->AsKeyboardEvent();
if (keyEvent && keyEvent->IsOS()) {
IgnoreModifierState ignoreModifierState(aIgnoreModifierState);
ignoreModifierState.mOS = true;
return WalkHandlersAndExecute(aKeyEvent, aEventType, aHandler, aCharCode,
ignoreModifierState, aExecute);
}
}
#endif
return false;
}
bool
nsXBLWindowKeyHandler::HasHandlerForEvent(nsIDOMKeyEvent* aEvent,
bool* aOutReservedForChrome)
{
- if (!aEvent->InternalDOMEvent()->IsTrusted()) {
+ if (!aEvent->AsEvent()->InternalDOMEvent()->IsTrusted()) {
return false;
}
nsresult rv = EnsureHandlers();
NS_ENSURE_SUCCESS(rv, false);
bool isDisabled;
nsCOMPtr<Element> el = GetElement(&isDisabled);
if (el && isDisabled) {
return false;
}
nsAutoString eventType;
- aEvent->GetType(eventType);
+ aEvent->AsEvent()->GetType(eventType);
nsCOMPtr<nsIAtom> eventTypeAtom = do_GetAtom(eventType);
NS_ENSURE_TRUE(eventTypeAtom, false);
return WalkHandlersInternal(aEvent, eventTypeAtom, mHandler, false,
aOutReservedForChrome);
}
already_AddRefed<Element>
--- a/dom/xul/nsXULPopupListener.cpp
+++ b/dom/xul/nsXULPopupListener.cpp
@@ -110,17 +110,17 @@ nsXULPopupListener::HandleEvent(nsIDOMEv
nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aEvent);
if (!mouseEvent) {
//non-ui event passed in. bad things.
return NS_OK;
}
// Get the node that was clicked on.
- EventTarget* target = mouseEvent->InternalDOMEvent()->GetTarget();
+ EventTarget* target = mouseEvent->AsEvent()->InternalDOMEvent()->GetTarget();
nsCOMPtr<nsIDOMNode> targetNode = do_QueryInterface(target);
if (!targetNode && mIsContext) {
// Not a DOM node, see if it's the DOM window (bug 380818).
nsCOMPtr<nsPIDOMWindow> domWin = do_QueryInterface(target);
if (!domWin) {
return NS_ERROR_DOM_WRONG_TYPE_ERR;
}
@@ -139,17 +139,17 @@ nsXULPopupListener::HandleEvent(nsIDOMEv
return NS_OK;
}
if (targetContent->IsXULElement(nsGkAtoms::browser) &&
EventStateManager::IsRemoteTarget(targetContent)) {
return NS_OK;
}
bool preventDefault;
- mouseEvent->GetDefaultPrevented(&preventDefault);
+ mouseEvent->AsEvent()->GetDefaultPrevented(&preventDefault);
if (preventDefault && targetNode && mIsContext) {
// Someone called preventDefault on a context menu.
// Let's make sure they are allowed to do so.
bool eventEnabled =
Preferences::GetBool("dom.event.contextmenu.enabled", true);
if (!eventEnabled) {
// If the target node is for plug-in, we should not open XUL context
// menu on windowless plug-ins.
--- a/editor/libeditor/nsEditor.cpp
+++ b/editor/libeditor/nsEditor.cpp
@@ -29,16 +29,17 @@
#include "mozilla/IMEStateManager.h" // for IMEStateManager
#include "mozilla/Preferences.h" // for Preferences
#include "mozilla/dom/Selection.h" // for Selection, etc
#include "mozilla/Services.h" // for GetObserverService
#include "mozilla/TextComposition.h" // for TextComposition
#include "mozilla/TextEvents.h"
#include "mozilla/dom/Element.h" // for Element, nsINode::AsElement
#include "mozilla/dom/Text.h"
+#include "mozilla/dom/Event.h"
#include "mozilla/mozalloc.h" // for operator new, etc
#include "nsAString.h" // for nsAString_internal::Length, etc
#include "nsCCUncollectableMarker.h" // for nsCCUncollectableMarker
#include "nsCaret.h" // for nsCaret
#include "nsCaseTreatment.h"
#include "nsCharTraits.h" // for NS_IS_HIGH_SURROGATE, etc
#include "nsComponentManagerUtils.h" // for do_CreateInstance
#include "nsComputedDOMStyle.h" // for nsComputedDOMStyle
@@ -4610,58 +4611,58 @@ nsEditor::HandleKeyPressEvent(nsIDOMKeyE
// NOTE: When you change this method, you should also change:
// * editor/libeditor/tests/test_texteditor_keyevent_handling.html
// * editor/libeditor/tests/test_htmleditor_keyevent_handling.html
//
// And also when you add new key handling, you need to change the subclass's
// HandleKeyPressEvent()'s switch statement.
WidgetKeyboardEvent* nativeKeyEvent =
- aKeyEvent->GetInternalNSEvent()->AsKeyboardEvent();
+ aKeyEvent->AsEvent()->GetInternalNSEvent()->AsKeyboardEvent();
NS_ENSURE_TRUE(nativeKeyEvent, NS_ERROR_UNEXPECTED);
NS_ASSERTION(nativeKeyEvent->mMessage == eKeyPress,
"HandleKeyPressEvent gets non-keypress event");
// if we are readonly or disabled, then do nothing.
if (IsReadonly() || IsDisabled()) {
// consume backspace for disabled and readonly textfields, to prevent
// back in history, which could be confusing to users
if (nativeKeyEvent->keyCode == nsIDOMKeyEvent::DOM_VK_BACK_SPACE) {
- aKeyEvent->PreventDefault();
+ aKeyEvent->AsEvent()->PreventDefault();
}
return NS_OK;
}
switch (nativeKeyEvent->keyCode) {
case nsIDOMKeyEvent::DOM_VK_META:
case nsIDOMKeyEvent::DOM_VK_WIN:
case nsIDOMKeyEvent::DOM_VK_SHIFT:
case nsIDOMKeyEvent::DOM_VK_CONTROL:
case nsIDOMKeyEvent::DOM_VK_ALT:
- aKeyEvent->PreventDefault(); // consumed
+ aKeyEvent->AsEvent()->PreventDefault(); // consumed
return NS_OK;
case nsIDOMKeyEvent::DOM_VK_BACK_SPACE:
if (nativeKeyEvent->IsControl() || nativeKeyEvent->IsAlt() ||
nativeKeyEvent->IsMeta() || nativeKeyEvent->IsOS()) {
return NS_OK;
}
DeleteSelection(nsIEditor::ePrevious, nsIEditor::eStrip);
- aKeyEvent->PreventDefault(); // consumed
+ aKeyEvent->AsEvent()->PreventDefault(); // consumed
return NS_OK;
case nsIDOMKeyEvent::DOM_VK_DELETE:
// on certain platforms (such as windows) the shift key
// modifies what delete does (cmd_cut in this case).
// bailing here to allow the keybindings to do the cut.
if (nativeKeyEvent->IsShift() || nativeKeyEvent->IsControl() ||
nativeKeyEvent->IsAlt() || nativeKeyEvent->IsMeta() ||
nativeKeyEvent->IsOS()) {
return NS_OK;
}
DeleteSelection(nsIEditor::eNext, nsIEditor::eStrip);
- aKeyEvent->PreventDefault(); // consumed
+ aKeyEvent->AsEvent()->PreventDefault(); // consumed
return NS_OK;
}
return NS_OK;
}
nsresult
nsEditor::HandleInlineSpellCheck(EditAction action,
Selection* aSelection,
--- a/editor/libeditor/nsEditorEventListener.cpp
+++ b/editor/libeditor/nsEditorEventListener.cpp
@@ -443,17 +443,17 @@ nsEditorEventListener::HandleEvent(nsIDO
// click
case eMouseClick: {
nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aEvent);
NS_ENSURE_TRUE(mouseEvent, NS_OK);
// If the preceding mousedown event or mouseup event was consumed,
// editor shouldn't handle this click event.
if (mMouseDownOrUpConsumedByIME) {
mMouseDownOrUpConsumedByIME = false;
- mouseEvent->PreventDefault();
+ mouseEvent->AsEvent()->PreventDefault();
return NS_OK;
}
return MouseClick(mouseEvent);
}
// focus
case eFocus:
return Focus(aEvent);
// blur
@@ -606,89 +606,89 @@ nsEditorEventListener::KeyDown(nsIDOMKey
}
#endif
nsresult
nsEditorEventListener::KeyPress(nsIDOMKeyEvent* aKeyEvent)
{
NS_ENSURE_TRUE(aKeyEvent, NS_OK);
- if (!mEditor->IsAcceptableInputEvent(aKeyEvent)) {
+ if (!mEditor->IsAcceptableInputEvent(aKeyEvent->AsEvent())) {
return NS_OK;
}
// DOM event handling happens in two passes, the client pass and the system
// pass. We do all of our processing in the system pass, to allow client
// handlers the opportunity to cancel events and prevent typing in the editor.
// If the client pass cancelled the event, defaultPrevented will be true
// below.
bool defaultPrevented;
- aKeyEvent->GetDefaultPrevented(&defaultPrevented);
+ aKeyEvent->AsEvent()->GetDefaultPrevented(&defaultPrevented);
if (defaultPrevented) {
return NS_OK;
}
nsresult rv = mEditor->HandleKeyPressEvent(aKeyEvent);
NS_ENSURE_SUCCESS(rv, rv);
- aKeyEvent->GetDefaultPrevented(&defaultPrevented);
+ aKeyEvent->AsEvent()->GetDefaultPrevented(&defaultPrevented);
if (defaultPrevented) {
return NS_OK;
}
if (!ShouldHandleNativeKeyBindings(aKeyEvent)) {
return NS_OK;
}
// Now, ask the native key bindings to handle the event.
WidgetKeyboardEvent* keyEvent =
- aKeyEvent->GetInternalNSEvent()->AsKeyboardEvent();
+ aKeyEvent->AsEvent()->GetInternalNSEvent()->AsKeyboardEvent();
MOZ_ASSERT(keyEvent,
"DOM key event's internal event must be WidgetKeyboardEvent");
nsIWidget* widget = keyEvent->widget;
// If the event is created by chrome script, the widget is always nullptr.
if (!widget) {
nsCOMPtr<nsIPresShell> ps = GetPresShell();
nsPresContext* pc = ps ? ps->GetPresContext() : nullptr;
widget = pc ? pc->GetNearestWidget() : nullptr;
NS_ENSURE_TRUE(widget, NS_OK);
}
nsCOMPtr<nsIDocument> doc = mEditor->GetDocument();
bool handled = widget->ExecuteNativeKeyBinding(
nsIWidget::NativeKeyBindingsForRichTextEditor,
*keyEvent, DoCommandCallback, doc);
if (handled) {
- aKeyEvent->PreventDefault();
+ aKeyEvent->AsEvent()->PreventDefault();
}
return NS_OK;
}
nsresult
nsEditorEventListener::MouseClick(nsIDOMMouseEvent* aMouseEvent)
{
// nothing to do if editor isn't editable or clicked on out of the editor.
if (mEditor->IsReadonly() || mEditor->IsDisabled() ||
- !mEditor->IsAcceptableInputEvent(aMouseEvent)) {
+ !mEditor->IsAcceptableInputEvent(aMouseEvent->AsEvent())) {
return NS_OK;
}
// Notifies clicking on editor to IMEStateManager even when the event was
// consumed.
if (EditorHasFocus()) {
nsPresContext* presContext = GetPresContext();
if (presContext) {
IMEStateManager::OnClickInEditor(presContext, GetFocusedRootContent(),
aMouseEvent);
}
}
bool preventDefault;
- nsresult rv = aMouseEvent->GetDefaultPrevented(&preventDefault);
+ nsresult rv = aMouseEvent->AsEvent()->GetDefaultPrevented(&preventDefault);
if (NS_FAILED(rv) || preventDefault) {
// We're done if 'preventdefault' is true (see for example bug 70698).
return rv;
}
// If we got a mouse down inside the editing area, we should force the
// IME to commit before we change the cursor position
mEditor->ForceCompositionEnd();
@@ -749,33 +749,33 @@ nsEditorEventListener::HandleMiddleClick
if (mailEditor) {
mailEditor->PasteAsQuotation(clipboard);
} else {
mEditor->Paste(clipboard);
}
// Prevent the event from propagating up to be possibly handled
// again by the containing window:
- aMouseEvent->StopPropagation();
- aMouseEvent->PreventDefault();
+ aMouseEvent->AsEvent()->StopPropagation();
+ aMouseEvent->AsEvent()->PreventDefault();
// We processed the event, whether drop/paste succeeded or not
return NS_OK;
}
bool
nsEditorEventListener::NotifyIMEOfMouseButtonEvent(
nsIDOMMouseEvent* aMouseEvent)
{
if (!EditorHasFocus()) {
return false;
}
bool defaultPrevented;
- nsresult rv = aMouseEvent->GetDefaultPrevented(&defaultPrevented);
+ nsresult rv = aMouseEvent->AsEvent()->GetDefaultPrevented(&defaultPrevented);
NS_ENSURE_SUCCESS(rv, false);
if (defaultPrevented) {
return false;
}
nsPresContext* presContext = GetPresContext();
NS_ENSURE_TRUE(presContext, false);
return IMEStateManager::OnMouseButtonEventInEditor(presContext,
GetFocusedRootContent(),
@@ -835,27 +835,27 @@ nsEditorEventListener::DragEnter(nsIDOMD
nsresult
nsEditorEventListener::DragOver(nsIDOMDragEvent* aDragEvent)
{
NS_ENSURE_TRUE(aDragEvent, NS_OK);
nsCOMPtr<nsIDOMNode> parent;
bool defaultPrevented;
- aDragEvent->GetDefaultPrevented(&defaultPrevented);
+ aDragEvent->AsEvent()->GetDefaultPrevented(&defaultPrevented);
if (defaultPrevented) {
return NS_OK;
}
aDragEvent->GetRangeParent(getter_AddRefs(parent));
nsCOMPtr<nsIContent> dropParent = do_QueryInterface(parent);
NS_ENSURE_TRUE(dropParent, NS_ERROR_FAILURE);
if (dropParent->IsEditable() && CanDrop(aDragEvent)) {
- aDragEvent->PreventDefault(); // consumed
+ aDragEvent->AsEvent()->PreventDefault(); // consumed
if (!mCaret) {
return NS_OK;
}
int32_t offset = 0;
nsresult rv = aDragEvent->GetRangeOffset(&offset);
NS_ENSURE_SUCCESS(rv, rv);
@@ -864,17 +864,17 @@ nsEditorEventListener::DragOver(nsIDOMDr
mCaret->SetCaretPosition(parent, offset);
return NS_OK;
}
if (!IsFileControlTextBox()) {
// This is needed when dropping on an input, to prevent the editor for
// the editable parent from receiving the event.
- aDragEvent->StopPropagation();
+ aDragEvent->AsEvent()->StopPropagation();
}
if (mCaret) {
mCaret->SetVisible(false);
}
return NS_OK;
}
@@ -909,17 +909,17 @@ nsEditorEventListener::DragExit(nsIDOMDr
nsresult
nsEditorEventListener::Drop(nsIDOMDragEvent* aDragEvent)
{
NS_ENSURE_TRUE(aDragEvent, NS_OK);
CleanupDragDropCaret();
bool defaultPrevented;
- aDragEvent->GetDefaultPrevented(&defaultPrevented);
+ aDragEvent->AsEvent()->GetDefaultPrevented(&defaultPrevented);
if (defaultPrevented) {
return NS_OK;
}
nsCOMPtr<nsIDOMNode> parent;
aDragEvent->GetRangeParent(getter_AddRefs(parent));
nsCOMPtr<nsIContent> dropParent = do_QueryInterface(parent);
NS_ENSURE_TRUE(dropParent, NS_ERROR_FAILURE);
@@ -927,24 +927,24 @@ nsEditorEventListener::Drop(nsIDOMDragEv
if (!dropParent->IsEditable() || !CanDrop(aDragEvent)) {
// was it because we're read-only?
if ((mEditor->IsReadonly() || mEditor->IsDisabled()) &&
!IsFileControlTextBox()) {
// it was decided to "eat" the event as this is the "least surprise"
// since someone else handling it might be unintentional and the
// user could probably re-drag to be not over the disabled/readonly
// editfields if that is what is desired.
- return aDragEvent->StopPropagation();
+ return aDragEvent->AsEvent()->StopPropagation();
}
return NS_OK;
}
- aDragEvent->StopPropagation();
- aDragEvent->PreventDefault();
- return mEditor->InsertFromDrop(aDragEvent);
+ aDragEvent->AsEvent()->StopPropagation();
+ aDragEvent->AsEvent()->PreventDefault();
+ return mEditor->InsertFromDrop(aDragEvent->AsEvent());
}
bool
nsEditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
{
// if the target doc is read-only, we can't drop
if (mEditor->IsReadonly() || mEditor->IsDisabled()) {
return false;
@@ -1178,17 +1178,17 @@ nsEditorEventListener::ShouldHandleNativ
// editing host in order to match the similar decision made in
// nsXBLWindowKeyHandler.
// Note that IsAcceptableInputEvent doesn't check for the active editing
// host for keyboard events, otherwise this check would have been
// unnecessary. IsAcceptableInputEvent currently makes a similar check for
// mouse events.
nsCOMPtr<nsIDOMEventTarget> target;
- aKeyEvent->GetTarget(getter_AddRefs(target));
+ aKeyEvent->AsEvent()->GetTarget(getter_AddRefs(target));
nsCOMPtr<nsIContent> targetContent = do_QueryInterface(target);
if (!targetContent) {
return false;
}
nsCOMPtr<nsIHTMLEditor> htmlEditor =
do_QueryInterface(static_cast<nsIEditor*>(mEditor));
if (!htmlEditor) {
--- a/editor/libeditor/nsHTMLEditor.cpp
+++ b/editor/libeditor/nsHTMLEditor.cpp
@@ -587,17 +587,17 @@ nsHTMLEditor::HandleKeyPressEvent(nsIDOM
if (IsReadonly() || IsDisabled()) {
// When we're not editable, the events are handled on nsEditor, so, we can
// bypass nsPlaintextEditor.
return nsEditor::HandleKeyPressEvent(aKeyEvent);
}
WidgetKeyboardEvent* nativeKeyEvent =
- aKeyEvent->GetInternalNSEvent()->AsKeyboardEvent();
+ aKeyEvent->AsEvent()->GetInternalNSEvent()->AsKeyboardEvent();
NS_ENSURE_TRUE(nativeKeyEvent, NS_ERROR_UNEXPECTED);
NS_ASSERTION(nativeKeyEvent->mMessage == eKeyPress,
"HandleKeyPressEvent gets non-keypress event");
switch (nativeKeyEvent->keyCode) {
case nsIDOMKeyEvent::DOM_VK_META:
case nsIDOMKeyEvent::DOM_VK_WIN:
case nsIDOMKeyEvent::DOM_VK_SHIFT:
@@ -646,47 +646,47 @@ nsHTMLEditor::HandleKeyPressEvent(nsIDOM
} else if (nsHTMLEditUtils::IsListItem(blockParent)) {
rv = Indent(nativeKeyEvent->IsShift()
? NS_LITERAL_STRING("outdent")
: NS_LITERAL_STRING("indent"));
handled = true;
}
NS_ENSURE_SUCCESS(rv, rv);
if (handled) {
- return aKeyEvent->PreventDefault(); // consumed
+ return aKeyEvent->AsEvent()->PreventDefault(); // consumed
}
if (nativeKeyEvent->IsShift()) {
return NS_OK; // don't type text for shift tabs
}
- aKeyEvent->PreventDefault();
+ aKeyEvent->AsEvent()->PreventDefault();
return TypedText(NS_LITERAL_STRING("\t"), eTypedText);
}
case nsIDOMKeyEvent::DOM_VK_RETURN:
if (nativeKeyEvent->IsControl() || nativeKeyEvent->IsAlt() ||
nativeKeyEvent->IsMeta() || nativeKeyEvent->IsOS()) {
return NS_OK;
}
- aKeyEvent->PreventDefault(); // consumed
+ aKeyEvent->AsEvent()->PreventDefault(); // consumed
if (nativeKeyEvent->IsShift() && !IsPlaintextEditor()) {
// only inserts a br node
return TypedText(EmptyString(), eTypedBR);
}
// uses rules to figure out what to insert
return TypedText(EmptyString(), eTypedBreak);
}
// NOTE: On some keyboard layout, some characters are inputted with Control
// key or Alt key, but at that time, widget sets FALSE to these keys.
if (nativeKeyEvent->charCode == 0 || nativeKeyEvent->IsControl() ||
nativeKeyEvent->IsAlt() || nativeKeyEvent->IsMeta() ||
nativeKeyEvent->IsOS()) {
// we don't PreventDefault() here or keybindings like control-x won't work
return NS_OK;
}
- aKeyEvent->PreventDefault();
+ aKeyEvent->AsEvent()->PreventDefault();
nsAutoString str(nativeKeyEvent->charCode);
return TypedText(str, eTypedText);
}
static void
AssertParserServiceIsCorrect(nsIAtom* aTag, bool aIsBlock)
{
#ifdef DEBUG
--- a/editor/libeditor/nsHTMLEditorEventListener.cpp
+++ b/editor/libeditor/nsHTMLEditorEventListener.cpp
@@ -56,17 +56,17 @@ nsHTMLEditorEventListener::GetHTMLEditor
}
nsresult
nsHTMLEditorEventListener::MouseUp(nsIDOMMouseEvent* aMouseEvent)
{
nsHTMLEditor* htmlEditor = GetHTMLEditor();
nsCOMPtr<nsIDOMEventTarget> target;
- nsresult rv = aMouseEvent->GetTarget(getter_AddRefs(target));
+ nsresult rv = aMouseEvent->AsEvent()->GetTarget(getter_AddRefs(target));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(target, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
int32_t clientX, clientY;
aMouseEvent->GetClientX(&clientX);
aMouseEvent->GetClientY(&clientY);
htmlEditor->MouseUp(clientX, clientY, element);
@@ -75,17 +75,17 @@ nsHTMLEditorEventListener::MouseUp(nsIDO
}
nsresult
nsHTMLEditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent)
{
nsHTMLEditor* htmlEditor = GetHTMLEditor();
// Contenteditable should disregard mousedowns outside it.
// IsAcceptableInputEvent() checks it for a mouse event.
- if (!htmlEditor->IsAcceptableInputEvent(aMouseEvent)) {
+ if (!htmlEditor->IsAcceptableInputEvent(aMouseEvent->AsEvent())) {
// If it's not acceptable mousedown event (including when mousedown event
// is fired outside of the active editing host), we need to commit
// composition because it will be change the selection to the clicked
// point. Then, we won't be able to commit the composition.
return nsEditorEventListener::MouseDown(aMouseEvent);
}
// Detect only "context menu" click
@@ -98,17 +98,17 @@ nsHTMLEditorEventListener::MouseDown(nsI
bool isContextClick = buttonNumber == 2;
int32_t clickCount;
rv = aMouseEvent->GetDetail(&clickCount);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMEventTarget> target;
- rv = aMouseEvent->GetExplicitOriginalTarget(getter_AddRefs(target));
+ rv = aMouseEvent->AsEvent()->GetExplicitOriginalTarget(getter_AddRefs(target));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(target, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
if (isContextClick || (buttonNumber == 0 && clickCount == 2)) {
RefPtr<Selection> selection = mEditor->GetSelection();
NS_ENSURE_TRUE(selection, NS_OK);
@@ -185,35 +185,35 @@ nsHTMLEditorEventListener::MouseDown(nsI
}
// HACK !!! Context click places the caret but the context menu consumes
// the event; so we need to check resizing state ourselves
htmlEditor->CheckSelectionStateForAnonymousButtons(selection);
// Prevent bubbling if we changed selection or
// for all context clicks
if (element || isContextClick) {
- aMouseEvent->PreventDefault();
+ aMouseEvent->AsEvent()->PreventDefault();
return NS_OK;
}
} else if (!isContextClick && buttonNumber == 0 && clickCount == 1) {
// if the target element is an image, we have to display resizers
int32_t clientX, clientY;
aMouseEvent->GetClientX(&clientX);
aMouseEvent->GetClientY(&clientY);
- htmlEditor->MouseDown(clientX, clientY, element, aMouseEvent);
+ htmlEditor->MouseDown(clientX, clientY, element, aMouseEvent->AsEvent());
}
return nsEditorEventListener::MouseDown(aMouseEvent);
}
nsresult
nsHTMLEditorEventListener::MouseClick(nsIDOMMouseEvent* aMouseEvent)
{
nsCOMPtr<nsIDOMEventTarget> target;
- nsresult rv = aMouseEvent->GetTarget(getter_AddRefs(target));
+ nsresult rv = aMouseEvent->AsEvent()->GetTarget(getter_AddRefs(target));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(target, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
GetHTMLEditor()->DoInlineTableEditingAction(element);
return nsEditorEventListener::MouseClick(aMouseEvent);
}
--- a/editor/libeditor/nsPlaintextEditor.cpp
+++ b/editor/libeditor/nsPlaintextEditor.cpp
@@ -4,16 +4,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsPlaintextEditor.h"
#include "gfxFontUtils.h"
#include "mozilla/Assertions.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/Selection.h"
+#include "mozilla/dom/Event.h"
#include "mozilla/TextComposition.h"
#include "mozilla/TextEvents.h"
#include "mozilla/dom/Element.h"
#include "mozilla/mozalloc.h"
#include "nsAString.h"
#include "nsAutoPtr.h"
#include "nsCRT.h"
#include "nsCaret.h"
@@ -356,17 +357,17 @@ nsPlaintextEditor::HandleKeyPressEvent(n
// HandleKeyPressEvent()'s switch statement.
if (IsReadonly() || IsDisabled()) {
// When we're not editable, the events handled on nsEditor.
return nsEditor::HandleKeyPressEvent(aKeyEvent);
}
WidgetKeyboardEvent* nativeKeyEvent =
- aKeyEvent->GetInternalNSEvent()->AsKeyboardEvent();
+ aKeyEvent->AsEvent()->GetInternalNSEvent()->AsKeyboardEvent();
NS_ENSURE_TRUE(nativeKeyEvent, NS_ERROR_UNEXPECTED);
NS_ASSERTION(nativeKeyEvent->mMessage == eKeyPress,
"HandleKeyPressEvent gets non-keypress event");
switch (nativeKeyEvent->keyCode) {
case nsIDOMKeyEvent::DOM_VK_META:
case nsIDOMKeyEvent::DOM_VK_WIN:
case nsIDOMKeyEvent::DOM_VK_SHIFT:
@@ -383,38 +384,38 @@ nsPlaintextEditor::HandleKeyPressEvent(n
if (nativeKeyEvent->IsShift() || nativeKeyEvent->IsControl() ||
nativeKeyEvent->IsAlt() || nativeKeyEvent->IsMeta() ||
nativeKeyEvent->IsOS()) {
return NS_OK;
}
// else we insert the tab straight through
- aKeyEvent->PreventDefault();
+ aKeyEvent->AsEvent()->PreventDefault();
return TypedText(NS_LITERAL_STRING("\t"), eTypedText);
}
case nsIDOMKeyEvent::DOM_VK_RETURN:
if (IsSingleLineEditor() || nativeKeyEvent->IsControl() ||
nativeKeyEvent->IsAlt() || nativeKeyEvent->IsMeta() ||
nativeKeyEvent->IsOS()) {
return NS_OK;
}
- aKeyEvent->PreventDefault();
+ aKeyEvent->AsEvent()->PreventDefault();
return TypedText(EmptyString(), eTypedBreak);
}
// NOTE: On some keyboard layout, some characters are inputted with Control
// key or Alt key, but at that time, widget sets FALSE to these keys.
if (nativeKeyEvent->charCode == 0 || nativeKeyEvent->IsControl() ||
nativeKeyEvent->IsAlt() || nativeKeyEvent->IsMeta() ||
nativeKeyEvent->IsOS()) {
// we don't PreventDefault() here or keybindings like control-x won't work
return NS_OK;
}
- aKeyEvent->PreventDefault();
+ aKeyEvent->AsEvent()->PreventDefault();
nsAutoString str(nativeKeyEvent->charCode);
return TypedText(str, eTypedText);
}
/* This routine is needed to provide a bottleneck for typing for logging
purposes. Can't use HandleKeyPress() (above) for that since it takes
a nsIDOMKeyEvent* parameter. So instead we pass enough info through
to TypedText() to determine what action to take, but without passing
--- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ -40,16 +40,17 @@
#include "nsIDOMNode.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsIDOMHTMLElement.h"
#include "nsIDOMMouseEvent.h"
#include "nsIDOMKeyEvent.h"
#include "nsIDOMNode.h"
#include "nsIDOMNodeList.h"
+#include "nsIDOMEvent.h"
#include "nsGenericHTMLElement.h"
#include "nsRange.h"
#include "mozilla/dom/Selection.h"
#include "nsIPlaintextEditor.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIRunnable.h"
#include "nsISelection.h"
--- a/layout/base/ZoomConstraintsClient.cpp
+++ b/layout/base/ZoomConstraintsClient.cpp
@@ -6,16 +6,17 @@
#include "ZoomConstraintsClient.h"
#include <inttypes.h>
#include "FrameMetrics.h"
#include "gfxPrefs.h"
#include "LayersLogging.h"
#include "mozilla/layers/APZCCallbackHelper.h"
#include "mozilla/Preferences.h"
+#include "mozilla/dom/Event.h"
#include "nsDocument.h"
#include "nsIFrame.h"
#include "nsLayoutUtils.h"
#include "nsPoint.h"
#include "nsPresShell.h"
#include "nsView.h"
#include "nsViewportInfo.h"
#include "Units.h"
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -60,16 +60,17 @@
#include "nsIIPCBackgroundChildCreateCallback.h"
#include "mozilla/layout/VsyncChild.h"
#include "VsyncSource.h"
#include "mozilla/VsyncDispatcher.h"
#include "nsThreadUtils.h"
#include "mozilla/unused.h"
#include "mozilla/TimelineConsumers.h"
#include "nsAnimationManager.h"
+#include "nsIDOMEvent.h"
#ifdef MOZ_NUWA_PROCESS
#include "ipc/Nuwa.h"
#endif
using namespace mozilla;
using namespace mozilla::widget;
using namespace mozilla::ipc;
--- a/layout/xul/nsMenuBarFrame.cpp
+++ b/layout/xul/nsMenuBarFrame.cpp
@@ -21,16 +21,17 @@
#include "nsCSSFrameConstructor.h"
#ifdef XP_WIN
#include "nsISound.h"
#include "nsWidgetsCID.h"
#endif
#include "nsContentUtils.h"
#include "nsUTF8Utils.h"
#include "mozilla/TextEvents.h"
+#include "mozilla/dom/Event.h"
using namespace mozilla;
//
// NS_NewMenuBarFrame
//
// Wrapper for creating a new menu Bar container
//
@@ -160,17 +161,17 @@ nsMenuBarFrame::ToggleMenuActiveState()
nsMenuFrame*
nsMenuBarFrame::FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent)
{
uint32_t charCode;
aKeyEvent->GetCharCode(&charCode);
nsAutoTArray<uint32_t, 10> accessKeys;
WidgetKeyboardEvent* nativeKeyEvent =
- aKeyEvent->GetInternalNSEvent()->AsKeyboardEvent();
+ aKeyEvent->AsEvent()->GetInternalNSEvent()->AsKeyboardEvent();
if (nativeKeyEvent)
nsContentUtils::GetAccessKeyCandidates(nativeKeyEvent, accessKeys);
if (accessKeys.IsEmpty() && charCode)
accessKeys.AppendElement(charCode);
if (accessKeys.IsEmpty())
return nullptr; // no character was pressed so just return
--- a/layout/xul/nsMenuBarListener.cpp
+++ b/layout/xul/nsMenuBarListener.cpp
@@ -289,17 +289,17 @@ nsMenuBarListener::IsAccessKeyPressed(ns
(modifiers & mAccessKeyMask) &&
(modifiers & ~(mAccessKeyMask | MODIFIER_SHIFT)) == 0);
}
Modifiers
nsMenuBarListener::GetModifiersForAccessKey(nsIDOMKeyEvent* aKeyEvent)
{
WidgetInputEvent* inputEvent =
- aKeyEvent->GetInternalNSEvent()->AsInputEvent();
+ aKeyEvent->AsEvent()->GetInternalNSEvent()->AsInputEvent();
MOZ_ASSERT(inputEvent);
static const Modifiers kPossibleModifiersForAccessKey =
(MODIFIER_SHIFT | MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META |
MODIFIER_OS);
return (inputEvent->modifiers & kPossibleModifiersForAccessKey);
}
--- a/layout/xul/nsMenuPopupFrame.cpp
+++ b/layout/xul/nsMenuPopupFrame.cpp
@@ -1901,17 +1901,17 @@ nsMenuPopupFrame::FindMenuWithShortcut(n
nsIContent* parentContent = mContent->GetParent();
bool isMenu = parentContent &&
!parentContent->NodeInfo()->Equals(nsGkAtoms::menulist, kNameSpaceID_XUL);
static DOMTimeStamp lastKeyTime = 0;
DOMTimeStamp keyTime;
- aKeyEvent->GetTimeStamp(&keyTime);
+ aKeyEvent->AsEvent()->GetTimeStamp(&keyTime);
if (charCode == 0) {
if (keyCode == nsIDOMKeyEvent::DOM_VK_BACK_SPACE) {
if (!isMenu && !mIncrementalString.IsEmpty()) {
mIncrementalString.SetLength(mIncrementalString.Length() - 1);
return nullptr;
}
else {
--- a/layout/xul/nsSplitterFrame.cpp
+++ b/layout/xul/nsSplitterFrame.cpp
@@ -30,16 +30,17 @@
#include "nsContainerFrame.h"
#include "nsAutoPtr.h"
#include "nsContentCID.h"
#include "nsStyleSet.h"
#include "nsLayoutUtils.h"
#include "nsDisplayList.h"
#include "nsContentUtils.h"
#include "mozilla/dom/Element.h"
+#include "mozilla/dom/Event.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/UniquePtr.h"
using namespace mozilla;
class nsSplitterInfo {
public:
nscoord min;
@@ -736,17 +737,17 @@ nsSplitterFrameInner::MouseDown(nsIDOMEv
Reverse(mChildInfosAfter, mChildInfosAfterCount);
// grow only applys to the children after. If grow is set then no space should be taken out of any children after
// us. To do this we just set the size of that list to be 0.
if (resizeAfter == Grow)
mChildInfosAfterCount = 0;
int32_t c;
- nsPoint pt = nsLayoutUtils::GetDOMEventCoordinatesRelativeTo(mouseEvent,
+ nsPoint pt = nsLayoutUtils::GetDOMEventCoordinatesRelativeTo(mouseEvent->AsEvent(),
mParentBox);
if (isHorizontal) {
c = pt.x;
mSplitterPos = mOuter->mRect.x;
} else {
c = pt.y;
mSplitterPos = mOuter->mRect.y;
}
--- a/layout/xul/nsXULPopupManager.cpp
+++ b/layout/xul/nsXULPopupManager.cpp
@@ -2003,33 +2003,33 @@ nsXULPopupManager::CancelMenuTimer(nsMen
}
bool
nsXULPopupManager::HandleShortcutNavigation(nsIDOMKeyEvent* aKeyEvent,
nsMenuPopupFrame* aFrame)
{
// On Windows, don't check shortcuts when the accelerator key is down.
#ifdef XP_WIN
- WidgetInputEvent* evt = aKeyEvent->GetInternalNSEvent()->AsInputEvent();
+ WidgetInputEvent* evt = aKeyEvent->AsEvent()->GetInternalNSEvent()->AsInputEvent();
if (evt && evt->IsAccel()) {
return false;
}
#endif
nsMenuChainItem* item = GetTopVisibleMenu();
if (!aFrame && item)
aFrame = item->Frame();
if (aFrame) {
bool action;
nsMenuFrame* result = aFrame->FindMenuWithShortcut(aKeyEvent, action);
if (result) {
aFrame->ChangeMenuItem(result, false, true);
if (action) {
- WidgetGUIEvent* evt = aKeyEvent->GetInternalNSEvent()->AsGUIEvent();
+ WidgetGUIEvent* evt = aKeyEvent->AsEvent()->GetInternalNSEvent()->AsGUIEvent();
nsMenuFrame* menuToOpen = result->Enter(evt);
if (menuToOpen) {
nsCOMPtr<nsIContent> content = menuToOpen->GetContent();
ShowMenu(content, true, false);
}
}
return true;
}
@@ -2206,19 +2206,19 @@ nsXULPopupManager::HandleKeyboardEventWi
uint32_t keyCode;
aKeyEvent->GetKeyCode(&keyCode);
// Escape should close panels, but the other keys should have no effect.
if (aTopVisibleMenuItem &&
aTopVisibleMenuItem->PopupType() != ePopupTypeMenu) {
if (keyCode == nsIDOMKeyEvent::DOM_VK_ESCAPE) {
HidePopup(aTopVisibleMenuItem->Content(), false, false, false, true);
- aKeyEvent->StopPropagation();
- aKeyEvent->StopCrossProcessForwarding();
- aKeyEvent->PreventDefault();
+ aKeyEvent->AsEvent()->StopPropagation();
+ aKeyEvent->AsEvent()->StopCrossProcessForwarding();
+ aKeyEvent->AsEvent()->PreventDefault();
}
return true;
}
bool consume = (mPopups || mActiveMenuBar);
switch (keyCode) {
case nsIDOMKeyEvent::DOM_VK_LEFT:
case nsIDOMKeyEvent::DOM_VK_RIGHT:
@@ -2265,17 +2265,19 @@ nsXULPopupManager::HandleKeyboardEventWi
// Intentional fall-through to RETURN case
MOZ_FALLTHROUGH;
case nsIDOMKeyEvent::DOM_VK_RETURN: {
// If there is a popup open, check if the current item needs to be opened.
// Otherwise, tell the active menubar, if any, to activate the menu. The
// Enter method will return a menu if one needs to be opened as a result.
nsMenuFrame* menuToOpen = nullptr;
- WidgetGUIEvent* GUIEvent = aKeyEvent->GetInternalNSEvent()->AsGUIEvent();
+ WidgetGUIEvent* GUIEvent = aKeyEvent->AsEvent()->
+ GetInternalNSEvent()->AsGUIEvent();
+
if (aTopVisibleMenuItem) {
menuToOpen = aTopVisibleMenuItem->Frame()->Enter(GUIEvent);
} else if (mActiveMenuBar) {
menuToOpen = mActiveMenuBar->Enter(GUIEvent);
}
if (menuToOpen) {
nsCOMPtr<nsIContent> content = menuToOpen->GetContent();
ShowMenu(content, true, false);
@@ -2283,19 +2285,19 @@ nsXULPopupManager::HandleKeyboardEventWi
break;
}
default:
return false;
}
if (consume) {
- aKeyEvent->StopPropagation();
- aKeyEvent->StopCrossProcessForwarding();
- aKeyEvent->PreventDefault();
+ aKeyEvent->AsEvent()->StopPropagation();
+ aKeyEvent->AsEvent()->StopCrossProcessForwarding();
+ aKeyEvent->AsEvent()->PreventDefault();
}
return true;
}
nsMenuFrame*
nsXULPopupManager::GetNextMenuItem(nsContainerFrame* aParent,
nsMenuFrame* aStart,
bool aIsPopup)
@@ -2456,17 +2458,17 @@ nsXULPopupManager::HandleEvent(nsIDOMEve
//handlers shouldn't be triggered by non-trusted events.
bool trustedEvent = false;
aEvent->GetIsTrusted(&trustedEvent);
if (!trustedEvent) {
return NS_OK;
}
nsAutoString eventType;
- keyEvent->GetType(eventType);
+ aEvent->GetType(eventType);
if (eventType.EqualsLiteral("keyup")) {
return KeyUp(keyEvent);
}
if (eventType.EqualsLiteral("keydown")) {
return KeyDown(keyEvent);
}
if (eventType.EqualsLiteral("keypress")) {
return KeyPress(keyEvent);
@@ -2482,24 +2484,24 @@ nsXULPopupManager::KeyUp(nsIDOMKeyEvent*
{
// don't do anything if a menu isn't open or a menubar isn't active
if (!mActiveMenuBar) {
nsMenuChainItem* item = GetTopVisibleMenu();
if (!item || item->PopupType() != ePopupTypeMenu)
return NS_OK;
if (item->IgnoreKeys() == eIgnoreKeys_Handled) {
- aKeyEvent->StopCrossProcessForwarding();
+ aKeyEvent->AsEvent()->StopCrossProcessForwarding();
return NS_OK;
}
}
- aKeyEvent->StopPropagation();
- aKeyEvent->StopCrossProcessForwarding();
- aKeyEvent->PreventDefault();
+ aKeyEvent->AsEvent()->StopPropagation();
+ aKeyEvent->AsEvent()->StopCrossProcessForwarding();
+ aKeyEvent->AsEvent()->PreventDefault();
return NS_OK; // I am consuming event
}
nsresult
nsXULPopupManager::KeyDown(nsIDOMKeyEvent* aKeyEvent)
{
nsMenuChainItem* item = GetTopVisibleMenu();
@@ -2540,29 +2542,29 @@ nsXULPopupManager::KeyDown(nsIDOMKeyEven
if (!(ctrl || alt || shift || meta)) {
// The access key just went down and no other
// modifiers are already down.
if (mPopups)
Rollup(0, false, nullptr, nullptr);
else if (mActiveMenuBar)
mActiveMenuBar->MenuClosed();
}
- aKeyEvent->StopPropagation();
- aKeyEvent->PreventDefault();
+ aKeyEvent->AsEvent()->StopPropagation();
+ aKeyEvent->AsEvent()->PreventDefault();
}
}
// Since a menu was open, stop propagation of the event to keep other event
// listeners from becoming confused.
if (!item || item->IgnoreKeys() != eIgnoreKeys_Handled) {
- aKeyEvent->StopPropagation();
+ aKeyEvent->AsEvent()->StopPropagation();
}
- aKeyEvent->StopCrossProcessForwarding();
+ aKeyEvent->AsEvent()->StopCrossProcessForwarding();
return NS_OK;
}
nsresult
nsXULPopupManager::KeyPress(nsIDOMKeyEvent* aKeyEvent)
{
// Don't check prevent default flag -- menus always get first shot at key events.
@@ -2579,20 +2581,20 @@ nsXULPopupManager::KeyPress(nsIDOMKeyEve
// When ignorekeys="handled" is used, we don't call preventDefault on the key
// event, which allows another listener to handle keys that the popup hasn't
// already handled. For instance, this allows global shortcuts to still apply
// while a menu is open.
bool onlyHandled = item && item->IgnoreKeys() == eIgnoreKeys_Handled;
bool handled = HandleShortcutNavigation(keyEvent, nullptr);
- aKeyEvent->StopCrossProcessForwarding();
+ aKeyEvent->AsEvent()->StopCrossProcessForwarding();
if (handled || (consume && !onlyHandled)) {
- aKeyEvent->StopPropagation();
- aKeyEvent->PreventDefault();
+ aKeyEvent->AsEvent()->StopPropagation();
+ aKeyEvent->AsEvent()->PreventDefault();
}
return NS_OK; // I am consuming event
}
NS_IMETHODIMP
nsXULPopupShowingEvent::Run()
{