--- a/accessible/base/nsCoreUtils.cpp
+++ b/accessible/base/nsCoreUtils.cpp
@@ -113,43 +113,43 @@ nsCoreUtils::DispatchClickEvent(nsITreeB
DispatchMouseEvent(NS_MOUSE_BUTTON_DOWN, cnvdX, cnvdY,
tcContent, tcFrame, presShell, rootWidget);
DispatchMouseEvent(NS_MOUSE_BUTTON_UP, cnvdX, cnvdY,
tcContent, tcFrame, presShell, rootWidget);
}
void
-nsCoreUtils::DispatchMouseEvent(uint32_t aEventType, int32_t aX, int32_t aY,
+nsCoreUtils::DispatchMouseEvent(EventMessage aMessage, int32_t aX, int32_t aY,
nsIContent *aContent, nsIFrame *aFrame,
nsIPresShell *aPresShell, nsIWidget *aRootWidget)
{
- WidgetMouseEvent event(true, aEventType, aRootWidget,
+ WidgetMouseEvent event(true, aMessage, aRootWidget,
WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal);
event.refPoint = LayoutDeviceIntPoint(aX, aY);
event.clickCount = 1;
event.button = WidgetMouseEvent::eLeftButton;
event.time = PR_IntervalNow();
event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
nsEventStatus status = nsEventStatus_eIgnore;
aPresShell->HandleEventWithTarget(&event, aFrame, aContent, &status);
}
void
-nsCoreUtils::DispatchTouchEvent(uint32_t aEventType, int32_t aX, int32_t aY,
+nsCoreUtils::DispatchTouchEvent(EventMessage aMessage, int32_t aX, int32_t aY,
nsIContent* aContent, nsIFrame* aFrame,
nsIPresShell* aPresShell, nsIWidget* aRootWidget)
{
if (!dom::TouchEvent::PrefEnabled())
return;
- WidgetTouchEvent event(true, aEventType, aRootWidget);
+ WidgetTouchEvent event(true, aMessage, aRootWidget);
event.time = PR_IntervalNow();
// XXX: Touch has an identifier of -1 to hint that it is synthesized.
nsRefPtr<dom::Touch> t = new dom::Touch(-1, LayoutDeviceIntPoint(aX, aY),
nsIntPoint(1, 1), 0.0f, 1.0f);
t->SetTarget(aContent);
event.touches.AppendElement(t);
--- a/accessible/base/nsCoreUtils.h
+++ b/accessible/base/nsCoreUtils.h
@@ -1,16 +1,17 @@
/* -*- 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/. */
#ifndef nsCoreUtils_h_
#define nsCoreUtils_h_
+#include "mozilla/EventForwards.h"
#include "nsIContent.h"
#include "nsIDocument.h" // for GetShell()
#include "nsIPresShell.h"
#include "nsPoint.h"
#include "nsTArray.h"
class nsRange;
@@ -44,40 +45,42 @@ public:
*/
static void DispatchClickEvent(nsITreeBoxObject *aTreeBoxObj,
int32_t aRowIndex, nsITreeColumn *aColumn,
const nsAString& aPseudoElt = EmptyString());
/**
* Send mouse event to the given element.
*
- * @param aEventType [in] an event type (see BasicEvents.h for constants)
+ * @param aMessage [in] an event message (see EventForwards.h)
* @param aX [in] x coordinate in dev pixels
* @param aY [in] y coordinate in dev pixels
* @param aContent [in] the element
* @param aFrame [in] frame of the element
* @param aPresShell [in] the presshell for the element
* @param aRootWidget [in] the root widget of the element
*/
- static void DispatchMouseEvent(uint32_t aEventType, int32_t aX, int32_t aY,
+ static void DispatchMouseEvent(mozilla::EventMessage aMessage,
+ int32_t aX, int32_t aY,
nsIContent *aContent, nsIFrame *aFrame,
nsIPresShell *aPresShell, nsIWidget *aRootWidget);
/**
* Send a touch event with a single touch point to the given element.
*
- * @param aEventType [in] an event type (see BasicEvents.h for constants)
+ * @param aMessage [in] an event message (see EventForwards.h)
* @param aX [in] x coordinate in dev pixels
* @param aY [in] y coordinate in dev pixels
* @param aContent [in] the element
* @param aFrame [in] frame of the element
* @param aPresShell [in] the presshell for the element
* @param aRootWidget [in] the root widget of the element
*/
- static void DispatchTouchEvent(uint32_t aEventType, int32_t aX, int32_t aY,
+ static void DispatchTouchEvent(mozilla::EventMessage aMessage,
+ int32_t aX, int32_t aY,
nsIContent* aContent, nsIFrame* aFrame,
nsIPresShell* aPresShell, nsIWidget* aRootWidget);
/**
* Return an accesskey registered on the given element by
* EventStateManager or 0 if there is no registered accesskey.
*
* @param aContent - the given element.
--- a/dom/base/FragmentOrElement.cpp
+++ b/dom/base/FragmentOrElement.cpp
@@ -828,16 +828,18 @@ nsIContent::PreHandleEvent(EventChainPre
eventType.EqualsLiteral("reset") ||
eventType.EqualsLiteral("resize") ||
eventType.EqualsLiteral("scroll") ||
eventType.EqualsLiteral("selectstart")) {
stopEvent = true;
}
}
break;
+ default:
+ break;
}
if (stopEvent) {
// If we do stop propagation, we still want to propagate
// the event to chrome (nsPIDOMWindow::GetParentTarget()).
// The load event is special in that we don't ever propagate it
// to chrome.
nsCOMPtr<nsPIDOMWindow> win = OwnerDoc()->GetWindow();
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -665,35 +665,35 @@ nsContentUtils::InitializeModifierString
sModifierSeparator = new nsString(modifierSeparator);
}
// Because of SVG/SMIL we have several atoms mapped to the same
// id, but we can rely on ID_TO_EVENT to map id to only one atom.
static bool
ShouldAddEventToStringEventTable(const EventNameMapping& aMapping)
{
- switch(aMapping.mId) {
-#define ID_TO_EVENT(name_, id_, type_, struct_) \
- case id_: return nsGkAtoms::on##name_ == aMapping.mAtom;
+ switch(aMapping.mMessage) {
+#define ID_TO_EVENT(name_, message_, type_, struct_) \
+ case message_: return nsGkAtoms::on##name_ == aMapping.mAtom;
#include "mozilla/EventNameList.h"
#undef ID_TO_EVENT
default:
break;
}
return false;
}
bool
nsContentUtils::InitializeEventTable() {
NS_ASSERTION(!sAtomEventTable, "EventTable already initialized!");
NS_ASSERTION(!sStringEventTable, "EventTable already initialized!");
static const EventNameMapping eventArray[] = {
-#define EVENT(name_, _id, _type, _class) \
- { nsGkAtoms::on##name_, _id, _type, _class },
+#define EVENT(name_, _message, _type, _class) \
+ { nsGkAtoms::on##name_, _type, _message, _class },
#define WINDOW_ONLY_EVENT EVENT
#define NON_IDL_EVENT EVENT
#include "mozilla/EventNameList.h"
#undef WINDOW_ONLY_EVENT
#undef NON_IDL_EVENT
#undef EVENT
{ nullptr }
};
@@ -719,19 +719,19 @@ nsContentUtils::InitializeEventTable() {
void
nsContentUtils::InitializeTouchEventTable()
{
static bool sEventTableInitialized = false;
if (!sEventTableInitialized && sAtomEventTable && sStringEventTable) {
sEventTableInitialized = true;
static const EventNameMapping touchEventArray[] = {
-#define EVENT(name_, _id, _type, _class)
-#define TOUCH_EVENT(name_, _id, _type, _class) \
- { nsGkAtoms::on##name_, _id, _type, _class },
+#define EVENT(name_, _message, _type, _class)
+#define TOUCH_EVENT(name_, _message, _type, _class) \
+ { nsGkAtoms::on##name_, _type, _message, _class },
#include "mozilla/EventNameList.h"
#undef TOUCH_EVENT
#undef EVENT
{ nullptr }
};
// Subtract one from the length because of the trailing null
for (uint32_t i = 0; i < ArrayLength(touchEventArray) - 1; ++i) {
sAtomEventTable->Put(touchEventArray[i].mAtom, touchEventArray[i]);
@@ -3650,23 +3650,23 @@ nsContentUtils::IsEventAttributeName(nsI
if (name[0] != 'o' || name[1] != 'n')
return false;
EventNameMapping mapping;
return (sAtomEventTable->Get(aName, &mapping) && mapping.mType & aType);
}
// static
-uint32_t
-nsContentUtils::GetEventId(nsIAtom* aName)
+EventMessage
+nsContentUtils::GetEventMessage(nsIAtom* aName)
{
if (aName) {
EventNameMapping mapping;
if (sAtomEventTable->Get(aName, &mapping)) {
- return mapping.mId;
+ return mapping.mMessage;
}
}
return NS_USER_DEFINED_EVENT;
}
// static
mozilla::EventClassID
@@ -3675,41 +3675,42 @@ nsContentUtils::GetEventClassID(const ns
EventNameMapping mapping;
if (sStringEventTable->Get(aName, &mapping))
return mapping.mEventClassID;
return eBasicEventClass;
}
nsIAtom*
-nsContentUtils::GetEventIdAndAtom(const nsAString& aName,
- mozilla::EventClassID aEventClassID,
- uint32_t* aEventID)
+nsContentUtils::GetEventMessageAndAtom(const nsAString& aName,
+ mozilla::EventClassID aEventClassID,
+ EventMessage* aEventMessage)
{
EventNameMapping mapping;
if (sStringEventTable->Get(aName, &mapping)) {
- *aEventID = mapping.mEventClassID == aEventClassID ? mapping.mId :
- NS_USER_DEFINED_EVENT;
+ *aEventMessage =
+ mapping.mEventClassID == aEventClassID ? mapping.mMessage :
+ NS_USER_DEFINED_EVENT;
return mapping.mAtom;
}
// If we have cached lots of user defined event names, clear some of them.
if (sUserDefinedEvents->Count() > 127) {
while (sUserDefinedEvents->Count() > 64) {
nsIAtom* first = sUserDefinedEvents->ObjectAt(0);
sStringEventTable->Remove(Substring(nsDependentAtomString(first), 2));
sUserDefinedEvents->RemoveObjectAt(0);
}
}
- *aEventID = NS_USER_DEFINED_EVENT;
+ *aEventMessage = NS_USER_DEFINED_EVENT;
nsCOMPtr<nsIAtom> atom = do_GetAtom(NS_LITERAL_STRING("on") + aName);
sUserDefinedEvents->AppendObject(atom);
mapping.mAtom = atom;
- mapping.mId = NS_USER_DEFINED_EVENT;
+ mapping.mMessage = NS_USER_DEFINED_EVENT;
mapping.mType = EventNameType_None;
mapping.mEventClassID = eBasicEventClass;
sStringEventTable->Put(aName, mapping);
return mapping.mAtom;
}
static
nsresult GetEventAndTarget(nsIDocument* aDoc, nsISupports* aTarget,
@@ -7701,17 +7702,17 @@ nsContentUtils::SendKeyEvent(nsIWidget*
int32_t aModifiers,
uint32_t aAdditionalFlags,
bool* aDefaultActionTaken)
{
// get the widget to send the event to
if (!aWidget)
return NS_ERROR_FAILURE;
- int32_t msg;
+ EventMessage msg;
if (aType.EqualsLiteral("keydown"))
msg = NS_KEY_DOWN;
else if (aType.EqualsLiteral("keyup"))
msg = NS_KEY_UP;
else if (aType.EqualsLiteral("keypress"))
msg = NS_KEY_PRESS;
else
return NS_ERROR_FAILURE;
@@ -7814,17 +7815,17 @@ nsContentUtils::SendMouseEvent(nsCOMPtr<
bool *aPreventDefault,
bool aIsSynthesized)
{
nsPoint offset;
nsCOMPtr<nsIWidget> widget = GetWidget(aPresShell, &offset);
if (!widget)
return NS_ERROR_FAILURE;
- int32_t msg;
+ EventMessage msg;
bool contextMenuKey = false;
if (aType.EqualsLiteral("mousedown"))
msg = NS_MOUSE_BUTTON_DOWN;
else if (aType.EqualsLiteral("mouseup"))
msg = NS_MOUSE_BUTTON_UP;
else if (aType.EqualsLiteral("mousemove"))
msg = NS_MOUSE_MOVE;
else if (aType.EqualsLiteral("mouseover"))
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -160,18 +160,18 @@ enum EventNameType {
EventNameType_All = 0xFFFF
};
struct EventNameMapping
{
// This holds pointers to nsGkAtoms members, and is therefore safe as a
// non-owning reference.
nsIAtom* MOZ_NON_OWNING_REF mAtom;
- uint32_t mId;
int32_t mType;
+ mozilla::EventMessage mMessage;
mozilla::EventClassID mEventClassID;
};
struct nsShortcutCandidate {
nsShortcutCandidate(uint32_t aCharCode, bool aIgnoreShift) :
mCharCode(aCharCode), mIgnoreShift(aIgnoreShift)
{
}
@@ -1095,45 +1095,45 @@ public:
* defined above.
*
* @param aName the event name to look up
* @param aType the type of content
*/
static bool IsEventAttributeName(nsIAtom* aName, int32_t aType);
/**
- * Return the event id for the event with the given name. The name is the
- * event name with the 'on' prefix. Returns NS_USER_DEFINED_EVENT if the
+ * Return the event message for the event with the given name. The name is
+ * the event name with the 'on' prefix. Returns NS_USER_DEFINED_EVENT if the
* event doesn't match a known event name.
*
* @param aName the event name to look up
*/
- static uint32_t GetEventId(nsIAtom* aName);
+ static mozilla::EventMessage GetEventMessage(nsIAtom* aName);
/**
* Return the EventClassID for the event with the given name. The name is the
* event name *without* the 'on' prefix. Returns eBasicEventClass if the event
* is not known to be of any particular event class.
*
* @param aName the event name to look up
*/
static mozilla::EventClassID GetEventClassID(const nsAString& aName);
/**
- * Return the event id and atom for the event with the given name.
+ * Return the event message and atom for the event with the given name.
* The name is the event name *without* the 'on' prefix.
* Returns NS_USER_DEFINED_EVENT on the aEventID if the
* event doesn't match a known event name in the category.
*
* @param aName the event name to look up
* @param aEventClassID only return event id for aEventClassID
*/
- static nsIAtom* GetEventIdAndAtom(const nsAString& aName,
- mozilla::EventClassID aEventClassID,
- uint32_t* aEventID);
+ static nsIAtom* GetEventMessageAndAtom(const nsAString& aName,
+ mozilla::EventClassID aEventClassID,
+ mozilla::EventMessage* aEventMessage);
/**
* Used only during traversal of the XPCOM graph by the cycle
* collector: push a pointer to the listener manager onto the
* children deque, if it exists. Do nothing if there is no listener
* manager.
*
* Crucially: does not perform any refcounting operations.
--- a/dom/base/nsCopySupport.cpp
+++ b/dom/base/nsCopySupport.cpp
@@ -616,24 +616,28 @@ IsSelectionInsideRuby(nsISelection* aSel
if (!IsInsideRuby(n)) {
return false;
}
}
return true;
}
bool
-nsCopySupport::FireClipboardEvent(int32_t aType, int32_t aClipboardType, nsIPresShell* aPresShell,
- nsISelection* aSelection, bool* aActionTaken)
+nsCopySupport::FireClipboardEvent(EventMessage aEventMessage,
+ int32_t aClipboardType,
+ nsIPresShell* aPresShell,
+ nsISelection* aSelection,
+ bool* aActionTaken)
{
if (aActionTaken) {
*aActionTaken = false;
}
- NS_ASSERTION(aType == NS_CUT || aType == NS_COPY || aType == NS_PASTE,
+ NS_ASSERTION(aEventMessage == NS_CUT || aEventMessage == NS_COPY ||
+ aEventMessage == NS_PASTE,
"Invalid clipboard event type");
nsCOMPtr<nsIPresShell> presShell = aPresShell;
if (!presShell)
return false;
nsCOMPtr<nsIDocument> doc = presShell->GetDocument();
if (!doc)
@@ -679,31 +683,32 @@ nsCopySupport::FireClipboardEvent(int32_
const bool chromeShell =
docShell && docShell->ItemType() == nsIDocShellTreeItem::typeChrome;
// next, fire the cut, copy or paste event
bool doDefault = true;
nsRefPtr<DataTransfer> clipboardData;
if (chromeShell || Preferences::GetBool("dom.event.clipboardevents.enabled", true)) {
clipboardData =
- new DataTransfer(piWindow, aType, aType == NS_PASTE, aClipboardType);
+ new DataTransfer(piWindow, aEventMessage, aEventMessage == NS_PASTE,
+ aClipboardType);
nsEventStatus status = nsEventStatus_eIgnore;
- InternalClipboardEvent evt(true, aType);
+ InternalClipboardEvent evt(true, aEventMessage);
evt.clipboardData = clipboardData;
EventDispatcher::Dispatch(content, presShell->GetPresContext(), &evt,
nullptr, &status);
// If the event was cancelled, don't do the clipboard operation
doDefault = (status != nsEventStatus_eConsumeNoDefault);
}
// No need to do anything special during a paste. Either an event listener
// took care of it and cancelled the event, or the caller will handle it.
// Return true to indicate that the event wasn't cancelled.
- if (aType == NS_PASTE) {
+ if (aEventMessage == NS_PASTE) {
// Clear and mark the clipboardData as readonly. This prevents someone
// from reading the clipboard contents after the paste event has fired.
if (clipboardData) {
clipboardData->ClearAll();
clipboardData->SetReadOnly();
}
if (aActionTaken) {
@@ -733,17 +738,17 @@ nsCopySupport::FireClipboardEvent(int32_
if (formControl) {
if (formControl->GetType() == NS_FORM_INPUT_PASSWORD) {
return false;
}
}
// when cutting non-editable content, do nothing
// XXX this is probably the wrong editable flag to check
- if (aType != NS_CUT || content->IsEditable()) {
+ if (aEventMessage != NS_CUT || content->IsEditable()) {
// get the data from the selection if any
bool isCollapsed;
sel->GetIsCollapsed(&isCollapsed);
if (isCollapsed) {
if (aActionTaken) {
*aActionTaken = true;
}
return false;
--- a/dom/base/nsCopySupport.h
+++ b/dom/base/nsCopySupport.h
@@ -1,17 +1,17 @@
/* -*- 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/. */
#ifndef nsCopySupport_h__
#define nsCopySupport_h__
-#include "nscore.h"
+#include "mozilla/EventForwards.h"
class nsINode;
class nsISelection;
class nsIDocument;
class nsIImageLoadingContent;
class nsIContent;
class nsITransferable;
class nsACString;
@@ -59,17 +59,17 @@ class nsCopySupport
/**
* Returns true if a copy operation is currently permitted based on the
* current focus and selection within the specified document.
*/
static bool CanCopy(nsIDocument* aDocument);
/**
* Fires a cut, copy or paste event, on the given presshell, depending
- * on the value of aType, which should be either NS_CUT, NS_COPY or
+ * on the value of aEventMessage, which should be either NS_CUT, NS_COPY or
* NS_PASTE, and perform the default copy action if the event was not
* cancelled.
*
* If aSelection is specified, then this selection is used as the target
* of the operation. Otherwise, GetSelectionForCopy is used to retrieve
* the current selection.
*
* This will fire a cut, copy or paste event at the node at the start
@@ -83,16 +83,16 @@ class nsCopySupport
*
* aClipboardType specifies which clipboard to use, from nsIClipboard.
*
* If aActionTaken is non-NULL, it will be set to true if an action was
* taken, whether it be the default action or the default being prevented.
*
* If the event is cancelled or an error occurs, false will be returned.
*/
- static bool FireClipboardEvent(int32_t aType,
+ static bool FireClipboardEvent(mozilla::EventMessage aEventMessage,
int32_t aClipboardType,
nsIPresShell* aPresShell,
nsISelection* aSelection,
bool* aActionTaken = nullptr);
};
#endif
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -695,17 +695,17 @@ nsDOMWindowUtils::SendPointerEventCommon
// get the widget to send the event to
nsPoint offset;
nsCOMPtr<nsIWidget> widget = GetWidget(&offset);
if (!widget) {
return NS_ERROR_FAILURE;
}
- int32_t msg;
+ EventMessage msg;
if (aType.EqualsLiteral("pointerdown")) {
msg = NS_POINTER_DOWN;
} else if (aType.EqualsLiteral("pointerup")) {
msg = NS_POINTER_UP;
} else if (aType.EqualsLiteral("pointermove")) {
msg = NS_POINTER_MOVE;
} else if (aType.EqualsLiteral("pointerover")) {
msg = NS_POINTER_OVER;
@@ -974,17 +974,17 @@ nsDOMWindowUtils::SendTouchEventCommon(c
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
// get the widget to send the event to
nsPoint offset;
nsCOMPtr<nsIWidget> widget = GetWidget(&offset);
if (!widget) {
return NS_ERROR_NULL_POINTER;
}
- int32_t msg;
+ EventMessage msg;
if (aType.EqualsLiteral("touchstart")) {
msg = NS_TOUCH_START;
} else if (aType.EqualsLiteral("touchmove")) {
msg = NS_TOUCH_MOVE;
} else if (aType.EqualsLiteral("touchend")) {
msg = NS_TOUCH_END;
} else if (aType.EqualsLiteral("touchcancel")) {
msg = NS_TOUCH_CANCEL;
@@ -1309,17 +1309,17 @@ nsDOMWindowUtils::SendSimpleGestureEvent
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
// get the widget to send the event to
nsPoint offset;
nsCOMPtr<nsIWidget> widget = GetWidget(&offset);
if (!widget)
return NS_ERROR_FAILURE;
- int32_t msg;
+ EventMessage msg;
if (aType.EqualsLiteral("MozSwipeGestureStart"))
msg = NS_SIMPLE_GESTURE_SWIPE_START;
else if (aType.EqualsLiteral("MozSwipeGestureUpdate"))
msg = NS_SIMPLE_GESTURE_SWIPE_UPDATE;
else if (aType.EqualsLiteral("MozSwipeGestureEnd"))
msg = NS_SIMPLE_GESTURE_SWIPE_END;
else if (aType.EqualsLiteral("MozSwipeGesture"))
msg = NS_SIMPLE_GESTURE_SWIPE;
@@ -1936,32 +1936,47 @@ nsDOMWindowUtils::SendQueryContentEvent(
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
// get the widget to send the event to
nsCOMPtr<nsIWidget> widget = GetWidget();
if (!widget) {
return NS_ERROR_FAILURE;
}
- if (aType != NS_QUERY_SELECTED_TEXT &&
- aType != NS_QUERY_TEXT_CONTENT &&
- aType != NS_QUERY_CARET_RECT &&
- aType != NS_QUERY_TEXT_RECT &&
- aType != NS_QUERY_EDITOR_RECT &&
- aType != NS_QUERY_CHARACTER_AT_POINT) {
- return NS_ERROR_INVALID_ARG;
+ EventMessage message;
+ switch (aType) {
+ case QUERY_SELECTED_TEXT:
+ message = NS_QUERY_SELECTED_TEXT;
+ break;
+ case QUERY_TEXT_CONTENT:
+ message = NS_QUERY_TEXT_CONTENT;
+ break;
+ case QUERY_CARET_RECT:
+ message = NS_QUERY_CARET_RECT;
+ break;
+ case QUERY_TEXT_RECT:
+ message = NS_QUERY_TEXT_RECT;
+ break;
+ case QUERY_EDITOR_RECT:
+ message = NS_QUERY_EDITOR_RECT;
+ break;
+ case QUERY_CHARACTER_AT_POINT:
+ message = NS_QUERY_CHARACTER_AT_POINT;
+ break;
+ default:
+ return NS_ERROR_INVALID_ARG;
}
nsCOMPtr<nsIWidget> targetWidget = widget;
LayoutDeviceIntPoint pt(aX, aY);
bool useNativeLineBreak =
!(aAdditionalFlags & QUERY_CONTENT_FLAG_USE_XP_LINE_BREAK);
- if (aType == QUERY_CHARACTER_AT_POINT) {
+ if (message == NS_QUERY_CHARACTER_AT_POINT) {
// Looking for the widget at the point.
WidgetQueryContentEvent dummyEvent(true, NS_QUERY_CONTENT_STATE, widget);
dummyEvent.mUseNativeLineBreak = useNativeLineBreak;
InitEvent(dummyEvent, &pt);
nsIFrame* popupFrame =
nsLayoutUtils::GetPopupFrameForEventCoordinates(presContext->GetRootPresContext(), &dummyEvent);
nsIntRect widgetBounds;
@@ -1978,20 +1993,20 @@ nsDOMWindowUtils::SendQueryContentEvent(
// Fire the event on the widget at the point
if (popupFrame) {
targetWidget = popupFrame->GetNearestWidget();
}
}
pt += widget->WidgetToScreenOffset() - targetWidget->WidgetToScreenOffset();
- WidgetQueryContentEvent queryEvent(true, aType, targetWidget);
+ WidgetQueryContentEvent queryEvent(true, message, targetWidget);
InitEvent(queryEvent, &pt);
- switch (aType) {
+ switch (message) {
case NS_QUERY_TEXT_CONTENT:
queryEvent.InitForQueryTextContent(aOffset, aLength, useNativeLineBreak);
break;
case NS_QUERY_CARET_RECT:
queryEvent.InitForQueryCaretRect(aOffset, useNativeLineBreak);
break;
case NS_QUERY_TEXT_RECT:
queryEvent.InitForQueryTextRect(aOffset, aLength, useNativeLineBreak);
@@ -2051,17 +2066,17 @@ nsDOMWindowUtils::SendContentCommandEven
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
// get the widget to send the event to
nsCOMPtr<nsIWidget> widget = GetWidget();
if (!widget)
return NS_ERROR_FAILURE;
- int32_t msg;
+ EventMessage msg;
if (aType.EqualsLiteral("cut"))
msg = NS_CONTENT_COMMAND_CUT;
else if (aType.EqualsLiteral("copy"))
msg = NS_CONTENT_COMMAND_COPY;
else if (aType.EqualsLiteral("paste"))
msg = NS_CONTENT_COMMAND_PASTE;
else if (aType.EqualsLiteral("delete"))
msg = NS_CONTENT_COMMAND_DELETE;
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -92,35 +92,39 @@ PRLogModuleInfo* gFocusNavigationLog;
MOZ_LOG(log, LogLevel::Debug, (format, tag.get())); \
}
#define LOGCONTENT(format, content) LOGTAG(gFocusLog, format, content)
#define LOGCONTENTNAVIGATION(format, content) LOGTAG(gFocusNavigationLog, format, content)
struct nsDelayedBlurOrFocusEvent
{
- nsDelayedBlurOrFocusEvent(uint32_t aType,
+ nsDelayedBlurOrFocusEvent(EventMessage aEventMessage,
nsIPresShell* aPresShell,
nsIDocument* aDocument,
EventTarget* aTarget)
- : mType(aType),
- mPresShell(aPresShell),
- mDocument(aDocument),
- mTarget(aTarget) { }
+ : mPresShell(aPresShell)
+ , mDocument(aDocument)
+ , mTarget(aTarget)
+ , mEventMessage(aEventMessage)
+ {
+ }
nsDelayedBlurOrFocusEvent(const nsDelayedBlurOrFocusEvent& aOther)
- : mType(aOther.mType),
- mPresShell(aOther.mPresShell),
- mDocument(aOther.mDocument),
- mTarget(aOther.mTarget) { }
-
- uint32_t mType;
+ : mPresShell(aOther.mPresShell)
+ , mDocument(aOther.mDocument)
+ , mTarget(aOther.mTarget)
+ , mEventMessage(aOther.mEventMessage)
+ {
+ }
+
nsCOMPtr<nsIPresShell> mPresShell;
nsCOMPtr<nsIDocument> mDocument;
nsCOMPtr<EventTarget> mTarget;
+ EventMessage mEventMessage;
};
inline void ImplCycleCollectionUnlink(nsDelayedBlurOrFocusEvent& aField)
{
aField.mPresShell = nullptr;
aField.mDocument = nullptr;
aField.mTarget = nullptr;
}
@@ -1033,21 +1037,21 @@ nsFocusManager::FireDelayedEvents(nsIDoc
if (!aDocument->GetInnerWindow() ||
!aDocument->GetInnerWindow()->IsCurrentInnerWindow()) {
// If the document was navigated away from or is defunct, don't bother
// firing events on it. Note the symmetry between this condition and
// the similar one in nsDocument.cpp:FireOrClearDelayedEvents.
mDelayedBlurFocusEvents.RemoveElementAt(i);
--i;
} else if (!aDocument->EventHandlingSuppressed()) {
- uint32_t type = mDelayedBlurFocusEvents[i].mType;
+ EventMessage message = mDelayedBlurFocusEvents[i].mEventMessage;
nsCOMPtr<EventTarget> target = mDelayedBlurFocusEvents[i].mTarget;
nsCOMPtr<nsIPresShell> presShell = mDelayedBlurFocusEvents[i].mPresShell;
mDelayedBlurFocusEvents.RemoveElementAt(i);
- SendFocusOrBlurEvent(type, presShell, aDocument, target, 0, false);
+ SendFocusOrBlurEvent(message, presShell, aDocument, target, 0, false);
--i;
}
}
}
return NS_OK;
}
@@ -1956,48 +1960,54 @@ nsFocusManager::Focus(nsPIDOMWindow* aWi
if (clearFirstFocusEvent)
mFirstFocusEvent = nullptr;
}
class FocusBlurEvent : public nsRunnable
{
public:
- FocusBlurEvent(nsISupports* aTarget, uint32_t aType,
+ FocusBlurEvent(nsISupports* aTarget, EventMessage aEventMessage,
nsPresContext* aContext, bool aWindowRaised,
bool aIsRefocus)
- : mTarget(aTarget), mType(aType), mContext(aContext),
- mWindowRaised(aWindowRaised), mIsRefocus(aIsRefocus) {}
+ : mTarget(aTarget)
+ , mContext(aContext)
+ , mEventMessage(aEventMessage)
+ , mWindowRaised(aWindowRaised)
+ , mIsRefocus(aIsRefocus)
+ {
+ }
NS_IMETHOD Run()
{
- InternalFocusEvent event(true, mType);
+ InternalFocusEvent event(true, mEventMessage);
event.mFlags.mBubbles = false;
event.fromRaise = mWindowRaised;
event.isRefocus = mIsRefocus;
return EventDispatcher::Dispatch(mTarget, mContext, &event);
}
nsCOMPtr<nsISupports> mTarget;
- uint32_t mType;
nsRefPtr<nsPresContext> mContext;
+ EventMessage mEventMessage;
bool mWindowRaised;
bool mIsRefocus;
};
void
-nsFocusManager::SendFocusOrBlurEvent(uint32_t aType,
+nsFocusManager::SendFocusOrBlurEvent(EventMessage aEventMessage,
nsIPresShell* aPresShell,
nsIDocument* aDocument,
nsISupports* aTarget,
uint32_t aFocusMethod,
bool aWindowRaised,
bool aIsRefocus)
{
- NS_ASSERTION(aType == NS_FOCUS_CONTENT || aType == NS_BLUR_CONTENT,
+ NS_ASSERTION(aEventMessage == NS_FOCUS_CONTENT ||
+ aEventMessage == NS_BLUR_CONTENT,
"Wrong event type for SendFocusOrBlurEvent");
nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(aTarget);
nsCOMPtr<nsINode> n = do_QueryInterface(aTarget);
if (!n) {
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aTarget);
n = win ? win->GetExtantDoc() : nullptr;
@@ -2010,42 +2020,44 @@ nsFocusManager::SendFocusOrBlurEvent(uin
if (aFocusMethod && !dontDispatchEvent &&
aDocument && aDocument->EventHandlingSuppressed()) {
// aFlags is always 0 when aWindowRaised is true so this won't be called
// on a window raise.
NS_ASSERTION(!aWindowRaised, "aWindowRaised should not be set");
for (uint32_t i = mDelayedBlurFocusEvents.Length(); i > 0; --i) {
// if this event was already queued, remove it and append it to the end
- if (mDelayedBlurFocusEvents[i - 1].mType == aType &&
+ if (mDelayedBlurFocusEvents[i - 1].mEventMessage == aEventMessage &&
mDelayedBlurFocusEvents[i - 1].mPresShell == aPresShell &&
mDelayedBlurFocusEvents[i - 1].mDocument == aDocument &&
mDelayedBlurFocusEvents[i - 1].mTarget == eventTarget) {
mDelayedBlurFocusEvents.RemoveElementAt(i - 1);
}
}
mDelayedBlurFocusEvents.AppendElement(
- nsDelayedBlurOrFocusEvent(aType, aPresShell, aDocument, eventTarget));
+ nsDelayedBlurOrFocusEvent(aEventMessage, aPresShell,
+ aDocument, eventTarget));
return;
}
#ifdef ACCESSIBILITY
nsAccessibilityService* accService = GetAccService();
if (accService) {
- if (aType == NS_FOCUS_CONTENT)
+ if (aEventMessage == NS_FOCUS_CONTENT) {
accService->NotifyOfDOMFocus(aTarget);
- else
+ } else {
accService->NotifyOfDOMBlur(aTarget);
+ }
}
#endif
if (!dontDispatchEvent) {
nsContentUtils::AddScriptRunner(
- new FocusBlurEvent(aTarget, aType, aPresShell->GetPresContext(),
+ new FocusBlurEvent(aTarget, aEventMessage, aPresShell->GetPresContext(),
aWindowRaised, aIsRefocus));
}
}
void
nsFocusManager::ScrollIntoView(nsIPresShell* aPresShell,
nsIContent* aContent,
uint32_t aFlags)
--- a/dom/base/nsFocusManager.h
+++ b/dom/base/nsFocusManager.h
@@ -275,22 +275,22 @@ protected:
bool aIsNewDocument,
bool aFocusChanged,
bool aWindowRaised,
bool aAdjustWidget);
/**
* Fires a focus or blur event at aTarget.
*
- * aType should be either NS_FOCUS_CONTENT or NS_BLUR_CONTENT. For blur
- * events, aFocusMethod should normally be non-zero.
+ * aEventMessage should be either NS_FOCUS_CONTENT or NS_BLUR_CONTENT.
+ * For blur events, aFocusMethod should normally be non-zero.
*
* aWindowRaised should only be true if called from WindowRaised.
*/
- void SendFocusOrBlurEvent(uint32_t aType,
+ void SendFocusOrBlurEvent(mozilla::EventMessage aEventMessage,
nsIPresShell* aPresShell,
nsIDocument* aDocument,
nsISupports* aTarget,
uint32_t aFocusMethod,
bool aWindowRaised,
bool aIsRefocus = false);
/**
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -3039,17 +3039,17 @@ nsGlobalWindow::GetJSContextForEventHand
return nullptr;
}
nsresult
nsGlobalWindow::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
NS_PRECONDITION(IsInnerWindow(), "PreHandleEvent is used on outer window!?");
static uint32_t count = 0;
- uint32_t msg = aVisitor.mEvent->mMessage;
+ EventMessage msg = aVisitor.mEvent->mMessage;
aVisitor.mCanHandle = true;
aVisitor.mForceContentDispatch = true; //FIXME! Bug 329119
if ((msg == NS_MOUSE_MOVE) && gEntropyCollector) {
//Chances are this counter will overflow during the life of the
//process, but that's OK for our case. Means we get a little
//more entropy.
if (count++ % 100 == 0) {
@@ -14528,17 +14528,17 @@ bool
nsGlobalWindow::GetIsPrerendered()
{
nsIDocShell* docShell = GetDocShell();
return docShell && docShell->GetIsPrerendered();
}
#ifdef MOZ_B2G
void
-nsGlobalWindow::EnableNetworkEvent(uint32_t aType)
+nsGlobalWindow::EnableNetworkEvent(EventMessage aEventMessage)
{
MOZ_ASSERT(IsInnerWindow());
nsCOMPtr<nsIPermissionManager> permMgr =
services::GetPermissionManager();
if (!permMgr) {
NS_ERROR("No PermissionManager available!");
return;
@@ -14553,55 +14553,59 @@ nsGlobalWindow::EnableNetworkEvent(uint3
}
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (!os) {
NS_ERROR("ObserverService should be available!");
return;
}
- switch (aType) {
+ switch (aEventMessage) {
case NS_NETWORK_UPLOAD_EVENT:
if (!mNetworkUploadObserverEnabled) {
mNetworkUploadObserverEnabled = true;
os->AddObserver(mObserver, NS_NETWORK_ACTIVITY_BLIP_UPLOAD_TOPIC, false);
}
break;
case NS_NETWORK_DOWNLOAD_EVENT:
if (!mNetworkDownloadObserverEnabled) {
mNetworkDownloadObserverEnabled = true;
os->AddObserver(mObserver, NS_NETWORK_ACTIVITY_BLIP_DOWNLOAD_TOPIC, false);
}
break;
- }
-}
-
-void
-nsGlobalWindow::DisableNetworkEvent(uint32_t aType)
+ default:
+ break;
+ }
+}
+
+void
+nsGlobalWindow::DisableNetworkEvent(EventMessage aEventMessage)
{
MOZ_ASSERT(IsInnerWindow());
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (!os) {
return;
}
- switch (aType) {
+ switch (aEventMessage) {
case NS_NETWORK_UPLOAD_EVENT:
if (mNetworkUploadObserverEnabled) {
mNetworkUploadObserverEnabled = false;
os->RemoveObserver(mObserver, NS_NETWORK_ACTIVITY_BLIP_UPLOAD_TOPIC);
}
break;
case NS_NETWORK_DOWNLOAD_EVENT:
if (mNetworkDownloadObserverEnabled) {
mNetworkDownloadObserverEnabled = false;
os->RemoveObserver(mObserver, NS_NETWORK_ACTIVITY_BLIP_DOWNLOAD_TOPIC);
}
break;
+ default:
+ break;
}
}
#endif // MOZ_B2G
void
nsGlobalWindow::RedefineProperty(JSContext* aCx, const char* aPropName,
JS::Handle<JS::Value> aValue,
ErrorResult& aError)
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -672,18 +672,19 @@ public:
virtual void EnableDeviceSensor(uint32_t aType) override;
virtual void DisableDeviceSensor(uint32_t aType) override;
virtual void EnableTimeChangeNotifications() override;
virtual void DisableTimeChangeNotifications() override;
#ifdef MOZ_B2G
// Inner windows only.
- virtual void EnableNetworkEvent(uint32_t aType) override;
- virtual void DisableNetworkEvent(uint32_t aType) override;
+ virtual void EnableNetworkEvent(mozilla::EventMessage aEventMessage) override;
+ virtual void DisableNetworkEvent(
+ mozilla::EventMessage aEventMessage) override;
#endif // MOZ_B2G
virtual nsresult SetArguments(nsIArray* aArguments) override;
void MaybeForgiveSpamCount();
bool IsClosedOrClosing() {
return (mIsClosed ||
mInClose ||
--- a/dom/base/nsGlobalWindowCommands.cpp
+++ b/dom/base/nsGlobalWindowCommands.cpp
@@ -515,23 +515,25 @@ nsClipboardCommand::DoCommand(const char
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
nsIDocShell *docShell = window->GetDocShell();
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
- int32_t eventType = NS_COPY;
+ EventMessage eventMessage = NS_COPY;
if (strcmp(aCommandName, "cmd_cut") == 0) {
- eventType = NS_CUT;
+ eventMessage = NS_CUT;
}
bool actionTaken = false;
- nsCopySupport::FireClipboardEvent(eventType, nsIClipboard::kGlobalClipboard, presShell, nullptr, &actionTaken);
+ nsCopySupport::FireClipboardEvent(eventMessage,
+ nsIClipboard::kGlobalClipboard,
+ presShell, nullptr, &actionTaken);
if (!strcmp(aCommandName, "cmd_copyAndCollapseToEnd")) {
dom::Selection *sel =
presShell->GetCurrentSelection(nsISelectionController::SELECTION_NORMAL);
NS_ENSURE_TRUE(sel, NS_ERROR_FAILURE);
sel->CollapseToEnd();
}
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -57,18 +57,18 @@ enum PopupControlState {
enum UIStateChangeType
{
UIStateChangeType_NoChange,
UIStateChangeType_Set,
UIStateChangeType_Clear
};
#define NS_PIDOMWINDOW_IID \
-{ 0x2aebbbd7, 0x154b, 0x4341, \
- { 0x8d, 0x02, 0x7f, 0x70, 0xf8, 0x3e, 0xf7, 0xa1 } }
+{ 0x052e675a, 0xacd3, 0x48d1, \
+ { 0x8a, 0xcd, 0xbf, 0xff, 0xbd, 0x24, 0x4c, 0xed } }
class nsPIDOMWindow : public nsIDOMWindowInternal
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_PIDOMWINDOW_IID)
virtual nsPIDOMWindow* GetPrivateRoot() = 0;
@@ -638,25 +638,25 @@ public:
#ifdef MOZ_B2G
/**
* Tell the window that it should start to listen to the network event of the
* given aType.
*
* Inner windows only.
*/
- virtual void EnableNetworkEvent(uint32_t aType) = 0;
+ virtual void EnableNetworkEvent(mozilla::EventMessage aEventMessage) = 0;
/**
* Tell the window that it should stop to listen to the network event of the
* given aType.
*
* Inner windows only.
*/
- virtual void DisableNetworkEvent(uint32_t aType) = 0;
+ virtual void DisableNetworkEvent(mozilla::EventMessage aEventMessage) = 0;
#endif // MOZ_B2G
/**
* Tell this window that there is an observer for gamepad input
*
* Inner windows only.
*/
virtual void SetHasGamepadEventListener(bool aHasGamepad = true) = 0;
--- a/dom/base/nsScriptElement.cpp
+++ b/dom/base/nsScriptElement.cpp
@@ -54,20 +54,20 @@ nsScriptElement::ScriptEvaluated(nsresul
if (!aIsInline) {
nsCOMPtr<nsIContent> cont =
do_QueryInterface((nsIScriptElement*) this);
nsRefPtr<nsPresContext> presContext =
nsContentUtils::GetContextForContent(cont);
nsEventStatus status = nsEventStatus_eIgnore;
- uint32_t type = NS_SUCCEEDED(aResult) ? NS_LOAD : NS_LOAD_ERROR;
- WidgetEvent event(true, type);
+ EventMessage message = NS_SUCCEEDED(aResult) ? NS_LOAD : NS_LOAD_ERROR;
+ WidgetEvent event(true, message);
// Load event doesn't bubble.
- event.mFlags.mBubbles = (type != NS_LOAD);
+ event.mFlags.mBubbles = (message != NS_LOAD);
EventDispatcher::Dispatch(cont, presContext, &event, nullptr, &status);
}
return rv;
}
void
--- a/dom/events/AnimationEvent.cpp
+++ b/dom/events/AnimationEvent.cpp
@@ -10,17 +10,17 @@
namespace mozilla {
namespace dom {
AnimationEvent::AnimationEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
InternalAnimationEvent* aEvent)
: Event(aOwner, aPresContext,
- aEvent ? aEvent : new InternalAnimationEvent(false, 0))
+ aEvent ? aEvent : new InternalAnimationEvent(false, NS_EVENT_NULL))
{
if (aEvent) {
mEventIsInternal = false;
}
else {
mEventIsInternal = true;
mEvent->time = PR_Now();
}
--- a/dom/events/BeforeAfterKeyboardEvent.cpp
+++ b/dom/events/BeforeAfterKeyboardEvent.cpp
@@ -12,17 +12,18 @@ namespace mozilla {
namespace dom {
BeforeAfterKeyboardEvent::BeforeAfterKeyboardEvent(
EventTarget* aOwner,
nsPresContext* aPresContext,
InternalBeforeAfterKeyboardEvent* aEvent)
: KeyboardEvent(aOwner, aPresContext,
aEvent ? aEvent :
- new InternalBeforeAfterKeyboardEvent(false, 0,
+ new InternalBeforeAfterKeyboardEvent(false,
+ NS_EVENT_NULL,
nullptr))
{
MOZ_ASSERT(mEvent->mClass == eBeforeAfterKeyboardEventClass,
"event type mismatch eBeforeAfterKeyboardEventClass");
if (!aEvent) {
mEventIsInternal = true;
mEvent->time = PR_Now();
--- a/dom/events/ClipboardEvent.cpp
+++ b/dom/events/ClipboardEvent.cpp
@@ -11,17 +11,17 @@
namespace mozilla {
namespace dom {
ClipboardEvent::ClipboardEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
InternalClipboardEvent* aEvent)
: Event(aOwner, aPresContext,
- aEvent ? aEvent : new InternalClipboardEvent(false, 0))
+ aEvent ? aEvent : new InternalClipboardEvent(false, NS_EVENT_NULL))
{
if (aEvent) {
mEventIsInternal = false;
} else {
mEventIsInternal = true;
mEvent->time = PR_Now();
}
}
--- a/dom/events/CompositionEvent.cpp
+++ b/dom/events/CompositionEvent.cpp
@@ -10,17 +10,18 @@
namespace mozilla {
namespace dom {
CompositionEvent::CompositionEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetCompositionEvent* aEvent)
: UIEvent(aOwner, aPresContext,
- aEvent ? aEvent : new WidgetCompositionEvent(false, 0, nullptr))
+ aEvent ? aEvent :
+ new WidgetCompositionEvent(false, NS_EVENT_NULL, nullptr))
{
NS_ASSERTION(mEvent->mClass == eCompositionEventClass,
"event type mismatch");
if (aEvent) {
mEventIsInternal = false;
} else {
mEventIsInternal = true;
--- a/dom/events/DataTransfer.cpp
+++ b/dom/events/DataTransfer.cpp
@@ -150,19 +150,19 @@ DataTransfer::Constructor(const GlobalOb
nsAutoCString onEventType("on");
AppendUTF16toUTF8(aEventType, onEventType);
nsCOMPtr<nsIAtom> eventTypeAtom = do_GetAtom(onEventType);
if (!eventTypeAtom) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
- uint32_t eventType = nsContentUtils::GetEventId(eventTypeAtom);
+ EventMessage eventMessage = nsContentUtils::GetEventMessage(eventTypeAtom);
nsRefPtr<DataTransfer> transfer = new DataTransfer(aGlobal.GetAsSupports(),
- eventType, aIsExternal,
+ eventMessage, aIsExternal,
-1);
return transfer.forget();
}
JSObject*
DataTransfer::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return DataTransferBinding::Wrap(aCx, this, aGivenProto);
--- a/dom/events/DragEvent.cpp
+++ b/dom/events/DragEvent.cpp
@@ -11,17 +11,18 @@
namespace mozilla {
namespace dom {
DragEvent::DragEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetDragEvent* aEvent)
: MouseEvent(aOwner, aPresContext,
- aEvent ? aEvent : new WidgetDragEvent(false, 0, nullptr))
+ aEvent ? aEvent :
+ new WidgetDragEvent(false, NS_EVENT_NULL, nullptr))
{
if (aEvent) {
mEventIsInternal = false;
}
else {
mEventIsInternal = true;
mEvent->time = PR_Now();
mEvent->refPoint.x = mEvent->refPoint.y = 0;
--- a/dom/events/Event.cpp
+++ b/dom/events/Event.cpp
@@ -101,17 +101,17 @@ Event::ConstructorInit(EventTarget* aOwn
mEventIsInternal = false;
}
else {
mEventIsInternal = true;
}
...
}
*/
- mEvent = new WidgetEvent(false, 0);
+ mEvent = new WidgetEvent(false, NS_EVENT_NULL);
mEvent->time = PR_Now();
}
InitPresContextData(aPresContext);
}
void
Event::InitPresContextData(nsPresContext* aPresContext)
@@ -558,18 +558,18 @@ Event::PreventDefaultInternal(bool aCall
}
void
Event::SetEventType(const nsAString& aEventTypeArg)
{
if (mIsMainThreadEvent) {
mEvent->typeString.Truncate();
mEvent->userType =
- nsContentUtils::GetEventIdAndAtom(aEventTypeArg, mEvent->mClass,
- &(mEvent->mMessage));
+ nsContentUtils::GetEventMessageAndAtom(aEventTypeArg, mEvent->mClass,
+ &(mEvent->mMessage));
} else {
mEvent->userType = nullptr;
mEvent->mMessage = NS_USER_DEFINED_EVENT;
mEvent->typeString = aEventTypeArg;
}
}
NS_IMETHODIMP
@@ -721,30 +721,34 @@ Event::GetEventPopupControlState(WidgetE
abuse = openControlled;
}
break;
case NS_FORM_CHANGE :
if (PopupAllowedForEvent("change")) {
abuse = openControlled;
}
break;
+ default:
+ break;
}
}
break;
case eEditorInputEventClass:
// For this following event only allow popups if it's triggered
// while handling user input. See
// nsPresShell::HandleEventInternal() for details.
if (EventStateManager::IsHandlingUserInput()) {
switch(aEvent->mMessage) {
case NS_EDITOR_INPUT:
if (PopupAllowedForEvent("input")) {
abuse = openControlled;
}
break;
+ default:
+ break;
}
}
break;
case eInputEventClass:
// For this following event only allow popups if it's triggered
// while handling user input. See
// nsPresShell::HandleEventInternal() for details.
if (EventStateManager::IsHandlingUserInput()) {
@@ -752,16 +756,18 @@ Event::GetEventPopupControlState(WidgetE
case NS_FORM_CHANGE :
if (PopupAllowedForEvent("change")) {
abuse = openControlled;
}
break;
case NS_XUL_COMMAND:
abuse = openControlled;
break;
+ default:
+ break;
}
}
break;
case eKeyboardEventClass:
if (aEvent->mFlags.mIsTrusted) {
uint32_t key = aEvent->AsKeyboardEvent()->keyCode;
switch(aEvent->mMessage) {
case NS_KEY_PRESS :
@@ -780,32 +786,36 @@ Event::GetEventPopupControlState(WidgetE
abuse = openControlled;
}
break;
case NS_KEY_DOWN :
if (PopupAllowedForEvent("keydown")) {
abuse = openControlled;
}
break;
+ default:
+ break;
}
}
break;
case eTouchEventClass:
if (aEvent->mFlags.mIsTrusted) {
switch (aEvent->mMessage) {
case NS_TOUCH_START :
if (PopupAllowedForEvent("touchstart")) {
abuse = openControlled;
}
break;
case NS_TOUCH_END :
if (PopupAllowedForEvent("touchend")) {
abuse = openControlled;
}
break;
+ default:
+ break;
}
}
break;
case eMouseEventClass:
if (aEvent->mFlags.mIsTrusted &&
aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
switch(aEvent->mMessage) {
case NS_MOUSE_BUTTON_UP :
@@ -827,16 +837,18 @@ Event::GetEventPopupControlState(WidgetE
abuse = openAllowed;
}
break;
case NS_MOUSE_DOUBLECLICK :
if (PopupAllowedForEvent("dblclick")) {
abuse = openControlled;
}
break;
+ default:
+ break;
}
}
break;
case eFormEventClass:
// For these following events only allow popups if they're
// triggered while handling user input. See
// nsPresShell::HandleEventInternal() for details.
if (EventStateManager::IsHandlingUserInput()) {
@@ -846,16 +858,18 @@ Event::GetEventPopupControlState(WidgetE
abuse = openControlled;
}
break;
case NS_FORM_RESET :
if (PopupAllowedForEvent("reset")) {
abuse = openControlled;
}
break;
+ default:
+ break;
}
}
break;
default:
break;
}
return abuse;
@@ -1021,17 +1035,17 @@ Event::GetOffsetCoords(nsPresContext* aP
}
return CSSIntPoint(0, 0);
}
// To be called ONLY by Event::GetType (which has the additional
// logic for handling user-defined events).
// static
const char*
-Event::GetEventName(uint32_t aEventType)
+Event::GetEventName(EventMessage aEventType)
{
switch(aEventType) {
#define ID_TO_EVENT(name_, _id, _type, _struct) \
case _id: return #name_;
#include "mozilla/EventNameList.h"
#undef ID_TO_EVENT
default:
break;
--- a/dom/events/Event.h
+++ b/dom/events/Event.h
@@ -119,17 +119,17 @@ public:
static PopupControlState GetEventPopupControlState(WidgetEvent* aEvent,
nsIDOMEvent* aDOMEvent = nullptr);
static void PopupAllowedEventsChanged();
static void Shutdown();
- static const char* GetEventName(uint32_t aEventType);
+ static const char* GetEventName(EventMessage aEventType);
static CSSIntPoint GetClientCoords(nsPresContext* aPresContext,
WidgetEvent* aEvent,
LayoutDeviceIntPoint aPoint,
CSSIntPoint aDefaultPoint);
static CSSIntPoint GetPageCoords(nsPresContext* aPresContext,
WidgetEvent* aEvent,
LayoutDeviceIntPoint aPoint,
CSSIntPoint aDefaultPoint);
--- a/dom/events/EventListenerManager.cpp
+++ b/dom/events/EventListenerManager.cpp
@@ -47,34 +47,34 @@
#include "nsSandboxFlags.h"
#include "xpcpublic.h"
namespace mozilla {
using namespace dom;
using namespace hal;
-#define EVENT_TYPE_EQUALS(ls, type, userType, typeString, allEvents) \
- ((ls->mEventType == type && \
- (ls->mEventType != NS_USER_DEFINED_EVENT || \
- (mIsMainThreadELM && ls->mTypeAtom == userType) || \
- (!mIsMainThreadELM && ls->mTypeString.Equals(typeString)))) || \
+#define EVENT_TYPE_EQUALS(ls, message, userType, typeString, allEvents) \
+ ((ls->mEventMessage == message && \
+ (ls->mEventMessage != NS_USER_DEFINED_EVENT || \
+ (mIsMainThreadELM && ls->mTypeAtom == userType) || \
+ (!mIsMainThreadELM && ls->mTypeString.Equals(typeString)))) || \
(allEvents && ls->mAllEvents))
static const uint32_t kAllMutationBits =
NS_EVENT_BITS_MUTATION_SUBTREEMODIFIED |
NS_EVENT_BITS_MUTATION_NODEINSERTED |
NS_EVENT_BITS_MUTATION_NODEREMOVED |
NS_EVENT_BITS_MUTATION_NODEREMOVEDFROMDOCUMENT |
NS_EVENT_BITS_MUTATION_NODEINSERTEDINTODOCUMENT |
NS_EVENT_BITS_MUTATION_ATTRMODIFIED |
NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED;
static uint32_t
-MutationBitForEventType(uint32_t aEventType)
+MutationBitForEventType(EventMessage aEventType)
{
switch (aEventType) {
case NS_MUTATION_SUBTREEMODIFIED:
return NS_EVENT_BITS_MUTATION_SUBTREEMODIFIED;
case NS_MUTATION_NODEINSERTED:
return NS_EVENT_BITS_MUTATION_NODEINSERTED;
case NS_MUTATION_NODEREMOVED:
return NS_EVENT_BITS_MUTATION_NODEREMOVED;
@@ -89,29 +89,36 @@ MutationBitForEventType(uint32_t aEventT
default:
break;
}
return 0;
}
uint32_t EventListenerManager::sMainThreadCreatedCount = 0;
-EventListenerManager::EventListenerManager(EventTarget* aTarget)
- : mMayHavePaintEventListener(false)
+EventListenerManagerBase::EventListenerManagerBase()
+ : mNoListenerForEvent(NS_EVENT_NULL)
+ , mMayHavePaintEventListener(false)
, mMayHaveMutationListeners(false)
, mMayHaveCapturingListeners(false)
, mMayHaveSystemGroupListeners(false)
, mMayHaveTouchEventListener(false)
, mMayHaveMouseEnterLeaveEventListener(false)
, mMayHavePointerEnterLeaveEventListener(false)
, mMayHaveKeyEventListener(false)
, mMayHaveInputOrCompositionEventListener(false)
, mClearingListeners(false)
, mIsMainThreadELM(NS_IsMainThread())
- , mNoListenerForEvent(0)
+{
+ static_assert(sizeof(EventListenerManagerBase) == sizeof(uint32_t),
+ "Keep the size of EventListenerManagerBase size compact!");
+}
+
+EventListenerManager::EventListenerManager(EventTarget* aTarget)
+ : EventListenerManagerBase()
, mTarget(aTarget)
{
NS_ASSERTION(aTarget, "unexpected null pointer");
if (mIsMainThreadELM) {
++sMainThreadCreatedCount;
}
}
@@ -210,25 +217,27 @@ EventListenerManager::GetTargetAsInnerWi
NS_ASSERTION(window->IsInnerWindow(), "Target should not be an outer window");
return window.forget();
}
void
EventListenerManager::AddEventListenerInternal(
const EventListenerHolder& aListenerHolder,
- uint32_t aType,
+ EventMessage aEventMessage,
nsIAtom* aTypeAtom,
const nsAString& aTypeString,
const EventListenerFlags& aFlags,
bool aHandler,
bool aAllEvents)
{
- MOZ_ASSERT((NS_IsMainThread() && aType && aTypeAtom) || // Main thread
- (!NS_IsMainThread() && aType && !aTypeString.IsEmpty()) || // non-main-thread
+ MOZ_ASSERT(// Main thread
+ (NS_IsMainThread() && aEventMessage && aTypeAtom) ||
+ // non-main-thread
+ (!NS_IsMainThread() && aEventMessage && !aTypeString.IsEmpty()) ||
aAllEvents, "Missing type"); // all-events listener
if (!aListenerHolder || mClearingListeners) {
return;
}
// Since there is no public API to call us with an EventListenerHolder, we
// know that there's an EventListenerHolder on the stack holding a strong ref
@@ -236,31 +245,30 @@ EventListenerManager::AddEventListenerIn
Listener* listener;
uint32_t count = mListeners.Length();
for (uint32_t i = 0; i < count; i++) {
listener = &mListeners.ElementAt(i);
// mListener == aListenerHolder is the last one, since it can be a bit slow.
if (listener->mListenerIsHandler == aHandler &&
listener->mFlags == aFlags &&
- EVENT_TYPE_EQUALS(listener, aType, aTypeAtom, aTypeString,
+ EVENT_TYPE_EQUALS(listener, aEventMessage, aTypeAtom, aTypeString,
aAllEvents) &&
listener->mListener == aListenerHolder) {
return;
}
}
mNoListenerForEvent = NS_EVENT_NULL;
mNoListenerForEventAtom = nullptr;
listener = aAllEvents ? mListeners.InsertElementAt(0) :
mListeners.AppendElement();
listener->mListener = aListenerHolder;
- MOZ_ASSERT(aType < PR_UINT16_MAX);
- listener->mEventType = aType;
+ listener->mEventMessage = aEventMessage;
listener->mTypeString = aTypeString;
listener->mTypeAtom = aTypeAtom;
listener->mFlags = aFlags;
listener->mListenerIsHandler = aHandler;
listener->mHandlerIsString = false;
listener->mAllEvents = aAllEvents;
// Detect the type of event listener.
@@ -279,38 +287,39 @@ EventListenerManager::AddEventListenerIn
if (aFlags.mInSystemGroup) {
mMayHaveSystemGroupListeners = true;
}
if (aFlags.mCapture) {
mMayHaveCapturingListeners = true;
}
- if (aType == NS_AFTERPAINT) {
+ if (aEventMessage == NS_AFTERPAINT) {
mMayHavePaintEventListener = true;
nsPIDOMWindow* window = GetInnerWindowForTarget();
if (window) {
window->SetHasPaintEventListeners();
}
- } else if (aType >= NS_MUTATION_START && aType <= NS_MUTATION_END) {
+ } else if (aEventMessage >= NS_MUTATION_START &&
+ aEventMessage <= NS_MUTATION_END) {
// For mutation listeners, we need to update the global bit on the DOM window.
// Otherwise we won't actually fire the mutation event.
mMayHaveMutationListeners = true;
// Go from our target to the nearest enclosing DOM window.
nsPIDOMWindow* window = GetInnerWindowForTarget();
if (window) {
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
if (doc) {
doc->WarnOnceAbout(nsIDocument::eMutationEvent);
}
- // If aType is NS_MUTATION_SUBTREEMODIFIED, we need to listen all
+ // If aEventMessage is NS_MUTATION_SUBTREEMODIFIED, we need to listen all
// mutations. nsContentUtils::HasMutationListeners relies on this.
- window->SetMutationListeners((aType == NS_MUTATION_SUBTREEMODIFIED) ?
- kAllMutationBits :
- MutationBitForEventType(aType));
+ window->SetMutationListeners(
+ (aEventMessage == NS_MUTATION_SUBTREEMODIFIED) ?
+ kAllMutationBits : MutationBitForEventType(aEventMessage));
}
} else if (aTypeAtom == nsGkAtoms::ondeviceorientation) {
EnableDevice(NS_DEVICE_ORIENTATION);
} else if (aTypeAtom == nsGkAtoms::ondeviceproximity || aTypeAtom == nsGkAtoms::onuserproximity) {
EnableDevice(NS_DEVICE_PROXIMITY);
} else if (aTypeAtom == nsGkAtoms::ondevicelight) {
EnableDevice(NS_DEVICE_LIGHT);
} else if (aTypeAtom == nsGkAtoms::ondevicemotion) {
@@ -338,17 +347,18 @@ EventListenerManager::AddEventListenerIn
aTypeAtom == nsGkAtoms::ontouchcancel) {
mMayHaveTouchEventListener = true;
nsPIDOMWindow* window = GetInnerWindowForTarget();
// we don't want touchevent listeners added by scrollbars to flip this flag
// so we ignore listeners created with system event flag
if (window && !aFlags.mInSystemGroup) {
window->SetHasTouchEventListeners();
}
- } else if (aType >= NS_POINTER_EVENT_START && aType <= NS_POINTER_LOST_CAPTURE) {
+ } else if (aEventMessage >= NS_POINTER_EVENT_START &&
+ aEventMessage <= NS_POINTER_LOST_CAPTURE) {
nsPIDOMWindow* window = GetInnerWindowForTarget();
if (aTypeAtom == nsGkAtoms::onpointerenter ||
aTypeAtom == nsGkAtoms::onpointerleave) {
mMayHavePointerEnterLeaveEventListener = true;
if (window) {
#ifdef DEBUG
nsCOMPtr<nsIDocument> d = window->GetExtantDoc();
NS_WARN_IF_FALSE(!nsContentUtils::IsChromeDoc(d),
@@ -367,18 +377,18 @@ EventListenerManager::AddEventListenerIn
nsCOMPtr<nsIDocument> d = window->GetExtantDoc();
NS_WARN_IF_FALSE(!nsContentUtils::IsChromeDoc(d),
"Please do not use mouseenter/leave events in chrome. "
"They are slower than mouseover/out!");
#endif
window->SetHasMouseEnterLeaveEventListeners();
}
#ifdef MOZ_GAMEPAD
- } else if (aType >= NS_GAMEPAD_START &&
- aType <= NS_GAMEPAD_END) {
+ } else if (aEventMessage >= NS_GAMEPAD_START &&
+ aEventMessage <= NS_GAMEPAD_END) {
nsPIDOMWindow* window = GetInnerWindowForTarget();
if (window) {
window->SetHasGamepadEventListener();
}
#endif
} else if (aTypeAtom == nsGkAtoms::onkeydown ||
aTypeAtom == nsGkAtoms::onkeypress ||
aTypeAtom == nsGkAtoms::onkeyup) {
@@ -400,40 +410,40 @@ EventListenerManager::AddEventListenerIn
if (mIsMainThreadELM && mTarget) {
EventListenerService::NotifyAboutMainThreadListenerChange(mTarget,
aTypeAtom);
}
}
bool
-EventListenerManager::IsDeviceType(uint32_t aType)
+EventListenerManager::IsDeviceType(EventMessage aEventMessage)
{
- switch (aType) {
+ switch (aEventMessage) {
case NS_DEVICE_ORIENTATION:
case NS_DEVICE_MOTION:
case NS_DEVICE_LIGHT:
case NS_DEVICE_PROXIMITY:
case NS_USER_PROXIMITY:
return true;
default:
break;
}
return false;
}
void
-EventListenerManager::EnableDevice(uint32_t aType)
+EventListenerManager::EnableDevice(EventMessage aEventMessage)
{
nsCOMPtr<nsPIDOMWindow> window = GetTargetAsInnerWindow();
if (!window) {
return;
}
- switch (aType) {
+ switch (aEventMessage) {
case NS_DEVICE_ORIENTATION:
window->EnableDeviceSensor(SENSOR_ORIENTATION);
break;
case NS_DEVICE_PROXIMITY:
case NS_USER_PROXIMITY:
window->EnableDeviceSensor(SENSOR_PROXIMITY);
break;
case NS_DEVICE_LIGHT:
@@ -446,24 +456,24 @@ EventListenerManager::EnableDevice(uint3
break;
default:
NS_WARNING("Enabling an unknown device sensor.");
break;
}
}
void
-EventListenerManager::DisableDevice(uint32_t aType)
+EventListenerManager::DisableDevice(EventMessage aEventMessage)
{
nsCOMPtr<nsPIDOMWindow> window = GetTargetAsInnerWindow();
if (!window) {
return;
}
- switch (aType) {
+ switch (aEventMessage) {
case NS_DEVICE_ORIENTATION:
window->DisableDeviceSensor(SENSOR_ORIENTATION);
break;
case NS_DEVICE_MOTION:
window->DisableDeviceSensor(SENSOR_ACCELERATION);
window->DisableDeviceSensor(SENSOR_LINEAR_ACCELERATION);
window->DisableDeviceSensor(SENSOR_GYROSCOPE);
break;
@@ -478,40 +488,40 @@ EventListenerManager::DisableDevice(uint
NS_WARNING("Disabling an unknown device sensor.");
break;
}
}
void
EventListenerManager::RemoveEventListenerInternal(
const EventListenerHolder& aListenerHolder,
- uint32_t aType,
+ EventMessage aEventMessage,
nsIAtom* aUserType,
const nsAString& aTypeString,
const EventListenerFlags& aFlags,
bool aAllEvents)
{
- if (!aListenerHolder || !aType || mClearingListeners) {
+ if (!aListenerHolder || !aEventMessage || mClearingListeners) {
return;
}
Listener* listener;
uint32_t count = mListeners.Length();
uint32_t typeCount = 0;
- bool deviceType = IsDeviceType(aType);
+ bool deviceType = IsDeviceType(aEventMessage);
#ifdef MOZ_B2G
- bool timeChangeEvent = (aType == NS_MOZ_TIME_CHANGE_EVENT);
- bool networkEvent = (aType == NS_NETWORK_UPLOAD_EVENT ||
- aType == NS_NETWORK_DOWNLOAD_EVENT);
+ bool timeChangeEvent = (aEventMessage == NS_MOZ_TIME_CHANGE_EVENT);
+ bool networkEvent = (aEventMessage == NS_NETWORK_UPLOAD_EVENT ||
+ aEventMessage == NS_NETWORK_DOWNLOAD_EVENT);
#endif // MOZ_B2G
for (uint32_t i = 0; i < count; ++i) {
listener = &mListeners.ElementAt(i);
- if (EVENT_TYPE_EQUALS(listener, aType, aUserType, aTypeString,
+ if (EVENT_TYPE_EQUALS(listener, aEventMessage, aUserType, aTypeString,
aAllEvents)) {
++typeCount;
if (listener->mListener == aListenerHolder &&
listener->mFlags.EqualsIgnoringTrustness(aFlags)) {
nsRefPtr<EventListenerManager> kungFuDeathGrip(this);
mListeners.RemoveElementAt(i);
--count;
mNoListenerForEvent = NS_EVENT_NULL;
@@ -532,123 +542,123 @@ EventListenerManager::RemoveEventListene
return;
}
--typeCount;
}
}
}
if (!aAllEvents && deviceType && typeCount == 0) {
- DisableDevice(aType);
+ DisableDevice(aEventMessage);
#ifdef MOZ_B2G
} else if (timeChangeEvent && typeCount == 0) {
nsCOMPtr<nsPIDOMWindow> window = GetTargetAsInnerWindow();
if (window) {
window->DisableTimeChangeNotifications();
}
} else if (!aAllEvents && networkEvent && typeCount == 0) {
nsCOMPtr<nsPIDOMWindow> window = GetTargetAsInnerWindow();
if (window) {
- window->DisableNetworkEvent(aType);
+ window->DisableNetworkEvent(aEventMessage);
}
#endif // MOZ_B2G
}
}
bool
EventListenerManager::ListenerCanHandle(Listener* aListener,
WidgetEvent* aEvent)
{
// This is slightly different from EVENT_TYPE_EQUALS in that it returns
// true even when aEvent->mMessage == NS_USER_DEFINED_EVENT and
- // aListener=>mEventType != NS_USER_DEFINED_EVENT as long as the atoms are
+ // aListener=>mEventMessage != NS_USER_DEFINED_EVENT as long as the atoms are
// the same
if (aListener->mAllEvents) {
return true;
}
if (aEvent->mMessage == NS_USER_DEFINED_EVENT) {
if (mIsMainThreadELM) {
return aListener->mTypeAtom == aEvent->userType;
}
return aListener->mTypeString.Equals(aEvent->typeString);
}
MOZ_ASSERT(mIsMainThreadELM);
- return aListener->mEventType == aEvent->mMessage;
+ return aListener->mEventMessage == aEvent->mMessage;
}
void
EventListenerManager::AddEventListenerByType(
const EventListenerHolder& aListenerHolder,
const nsAString& aType,
const EventListenerFlags& aFlags)
{
nsCOMPtr<nsIAtom> atom =
mIsMainThreadELM ? do_GetAtom(NS_LITERAL_STRING("on") + aType) : nullptr;
- uint32_t type = nsContentUtils::GetEventId(atom);
- AddEventListenerInternal(aListenerHolder, type, atom, aType, aFlags);
+ EventMessage message = nsContentUtils::GetEventMessage(atom);
+ AddEventListenerInternal(aListenerHolder, message, atom, aType, aFlags);
}
void
EventListenerManager::RemoveEventListenerByType(
const EventListenerHolder& aListenerHolder,
const nsAString& aType,
const EventListenerFlags& aFlags)
{
nsCOMPtr<nsIAtom> atom =
mIsMainThreadELM ? do_GetAtom(NS_LITERAL_STRING("on") + aType) : nullptr;
- uint32_t type = nsContentUtils::GetEventId(atom);
- RemoveEventListenerInternal(aListenerHolder, type, atom, aType, aFlags);
+ EventMessage message = nsContentUtils::GetEventMessage(atom);
+ RemoveEventListenerInternal(aListenerHolder, message, atom, aType, aFlags);
}
EventListenerManager::Listener*
-EventListenerManager::FindEventHandler(uint32_t aEventType,
+EventListenerManager::FindEventHandler(EventMessage aEventMessage,
nsIAtom* aTypeAtom,
const nsAString& aTypeString)
{
// Run through the listeners for this type and see if a script
// listener is registered
Listener* listener;
uint32_t count = mListeners.Length();
for (uint32_t i = 0; i < count; ++i) {
listener = &mListeners.ElementAt(i);
if (listener->mListenerIsHandler &&
- EVENT_TYPE_EQUALS(listener, aEventType, aTypeAtom, aTypeString,
+ EVENT_TYPE_EQUALS(listener, aEventMessage, aTypeAtom, aTypeString,
false)) {
return listener;
}
}
return nullptr;
}
EventListenerManager::Listener*
EventListenerManager::SetEventHandlerInternal(
nsIAtom* aName,
const nsAString& aTypeString,
const TypedEventHandler& aTypedHandler,
bool aPermitUntrustedEvents)
{
MOZ_ASSERT(aName || !aTypeString.IsEmpty());
- uint32_t eventType = nsContentUtils::GetEventId(aName);
- Listener* listener = FindEventHandler(eventType, aName, aTypeString);
+ EventMessage eventMessage = nsContentUtils::GetEventMessage(aName);
+ Listener* listener = FindEventHandler(eventMessage, aName, aTypeString);
if (!listener) {
// If we didn't find a script listener or no listeners existed
// create and add a new one.
EventListenerFlags flags;
flags.mListenerIsJSListener = true;
nsCOMPtr<JSEventHandler> jsEventHandler;
NS_NewJSEventHandler(mTarget, aName,
aTypedHandler, getter_AddRefs(jsEventHandler));
EventListenerHolder listenerHolder(jsEventHandler);
- AddEventListenerInternal(listenerHolder, eventType, aName, aTypeString,
+ AddEventListenerInternal(listenerHolder, eventMessage, aName, aTypeString,
flags, true);
- listener = FindEventHandler(eventType, aName, aTypeString);
+ listener = FindEventHandler(eventMessage, aName, aTypeString);
} else {
JSEventHandler* jsEventHandler = listener->GetJSEventHandler();
MOZ_ASSERT(jsEventHandler,
"How can we have an event handler with no JSEventHandler?");
bool same = jsEventHandler->GetTypedEventHandler() == aTypedHandler;
// Possibly the same listener, but update still the context and scope.
jsEventHandler->SetHandler(aTypedHandler);
@@ -771,18 +781,18 @@ EventListenerManager::SetEventHandler(ns
void
EventListenerManager::RemoveEventHandler(nsIAtom* aName,
const nsAString& aTypeString)
{
if (mClearingListeners) {
return;
}
- uint32_t eventType = nsContentUtils::GetEventId(aName);
- Listener* listener = FindEventHandler(eventType, aName, aTypeString);
+ EventMessage eventMessage = nsContentUtils::GetEventMessage(aName);
+ Listener* listener = FindEventHandler(eventMessage, aName, aTypeString);
if (listener) {
mListeners.RemoveElementAt(uint32_t(listener - &mListeners.ElementAt(0)));
mNoListenerForEvent = NS_EVENT_NULL;
mNoListenerForEventAtom = nullptr;
if (mTarget && aName) {
mTarget->EventListenerRemoved(aName);
}
@@ -1234,40 +1244,40 @@ EventListenerManager::RemoveListenerForA
bool
EventListenerManager::HasMutationListeners()
{
if (mMayHaveMutationListeners) {
uint32_t count = mListeners.Length();
for (uint32_t i = 0; i < count; ++i) {
Listener* listener = &mListeners.ElementAt(i);
- if (listener->mEventType >= NS_MUTATION_START &&
- listener->mEventType <= NS_MUTATION_END) {
+ if (listener->mEventMessage >= NS_MUTATION_START &&
+ listener->mEventMessage <= NS_MUTATION_END) {
return true;
}
}
}
return false;
}
uint32_t
EventListenerManager::MutationListenerBits()
{
uint32_t bits = 0;
if (mMayHaveMutationListeners) {
uint32_t count = mListeners.Length();
for (uint32_t i = 0; i < count; ++i) {
Listener* listener = &mListeners.ElementAt(i);
- if (listener->mEventType >= NS_MUTATION_START &&
- listener->mEventType <= NS_MUTATION_END) {
- if (listener->mEventType == NS_MUTATION_SUBTREEMODIFIED) {
+ if (listener->mEventMessage >= NS_MUTATION_START &&
+ listener->mEventMessage <= NS_MUTATION_END) {
+ if (listener->mEventMessage == NS_MUTATION_SUBTREEMODIFIED) {
return kAllMutationBits;
}
- bits |= MutationBitForEventType(listener->mEventType);
+ bits |= MutationBitForEventType(listener->mEventMessage);
}
}
}
return bits;
}
bool
EventListenerManager::HasListenersFor(const nsAString& aEventName)
@@ -1347,18 +1357,18 @@ EventListenerManager::GetListenerInfo(ns
}
bool
EventListenerManager::HasUnloadListeners()
{
uint32_t count = mListeners.Length();
for (uint32_t i = 0; i < count; ++i) {
Listener* listener = &mListeners.ElementAt(i);
- if (listener->mEventType == NS_PAGE_UNLOAD ||
- listener->mEventType == NS_BEFORE_PAGE_UNLOAD) {
+ if (listener->mEventMessage == NS_PAGE_UNLOAD ||
+ listener->mEventMessage == NS_BEFORE_PAGE_UNLOAD) {
return true;
}
}
return false;
}
void
EventListenerManager::SetEventHandler(nsIAtom* aEventName,
@@ -1419,18 +1429,18 @@ EventListenerManager::SetEventHandler(
!mIsMainThreadELM ||
!nsContentUtils::IsCallerChrome());
}
const TypedEventHandler*
EventListenerManager::GetTypedEventHandler(nsIAtom* aEventName,
const nsAString& aTypeString)
{
- uint32_t eventType = nsContentUtils::GetEventId(aEventName);
- Listener* listener = FindEventHandler(eventType, aEventName, aTypeString);
+ EventMessage eventMessage = nsContentUtils::GetEventMessage(aEventName);
+ Listener* listener = FindEventHandler(eventMessage, aEventName, aTypeString);
if (!listener) {
return nullptr;
}
JSEventHandler* jsEventHandler = listener->GetJSEventHandler();
if (listener->mHandlerIsString) {
--- a/dom/events/EventListenerManager.h
+++ b/dom/events/EventListenerManager.h
@@ -141,31 +141,51 @@ inline EventListenerFlags AllEventsAtSys
{
EventListenerFlags flags;
flags.mCapture = true;
flags.mInSystemGroup = true;
flags.mAllowUntrustedEvents = true;
return flags;
}
+class EventListenerManagerBase
+{
+protected:
+ EventListenerManagerBase();
+
+ EventMessage mNoListenerForEvent;
+ uint16_t mMayHavePaintEventListener : 1;
+ uint16_t mMayHaveMutationListeners : 1;
+ uint16_t mMayHaveCapturingListeners : 1;
+ uint16_t mMayHaveSystemGroupListeners : 1;
+ uint16_t mMayHaveTouchEventListener : 1;
+ uint16_t mMayHaveMouseEnterLeaveEventListener : 1;
+ uint16_t mMayHavePointerEnterLeaveEventListener : 1;
+ uint16_t mMayHaveKeyEventListener : 1;
+ uint16_t mMayHaveInputOrCompositionEventListener : 1;
+ uint16_t mClearingListeners : 1;
+ uint16_t mIsMainThreadELM : 1;
+ // uint16_t mUnused : 5;
+};
+
/*
* Event listener manager
*/
-class EventListenerManager final
+class EventListenerManager final : public EventListenerManagerBase
{
~EventListenerManager();
public:
struct Listener
{
EventListenerHolder mListener;
nsCOMPtr<nsIAtom> mTypeAtom; // for the main thread
nsString mTypeString; // for non-main-threads
- uint16_t mEventType;
+ EventMessage mEventMessage;
enum ListenerType : uint8_t
{
eNativeListener = 0,
eJSEventListener,
eWrappedJSListener,
eWebIDLListener,
eListenerTypeCount
@@ -444,35 +464,35 @@ protected:
*/
nsresult CompileEventHandlerInternal(Listener* aListener,
const nsAString* aBody,
dom::Element* aElement);
/**
* Find the Listener for the "inline" event listener for aTypeAtom.
*/
- Listener* FindEventHandler(uint32_t aEventType,
+ Listener* FindEventHandler(EventMessage aEventMessage,
nsIAtom* aTypeAtom,
const nsAString& aTypeString);
/**
* Set the "inline" event listener for aName to aHandler. aHandler may be
* have no actual handler set to indicate that we should lazily get and
* compile the string for this listener, but in that case aContext and
* aScopeGlobal must be non-null. Otherwise, aContext and aScopeGlobal are
* allowed to be null.
*/
Listener* SetEventHandlerInternal(nsIAtom* aName,
const nsAString& aTypeString,
const TypedEventHandler& aHandler,
bool aPermitUntrustedEvents);
- bool IsDeviceType(uint32_t aType);
- void EnableDevice(uint32_t aType);
- void DisableDevice(uint32_t aType);
+ bool IsDeviceType(EventMessage aEventMessage);
+ void EnableDevice(EventMessage aEventMessage);
+ void DisableDevice(EventMessage aEventMessage);
public:
/**
* Set the "inline" event listener for aEventName to aHandler. If
* aHandler is null, this will actually remove the event listener
*/
void SetEventHandler(nsIAtom* aEventName,
const nsAString& aTypeString,
@@ -524,52 +544,44 @@ protected:
const EventListenerHolder& aListener,
bool aUseCapture,
bool aWantsUntrusted);
void RemoveEventListener(const nsAString& aType,
const EventListenerHolder& aListener,
bool aUseCapture);
void AddEventListenerInternal(const EventListenerHolder& aListener,
- uint32_t aType,
+ EventMessage aEventMessage,
nsIAtom* aTypeAtom,
const nsAString& aTypeString,
const EventListenerFlags& aFlags,
bool aHandler = false,
bool aAllEvents = false);
void RemoveEventListenerInternal(const EventListenerHolder& aListener,
- uint32_t aType,
+ EventMessage aEventMessage,
nsIAtom* aUserType,
const nsAString& aTypeString,
const EventListenerFlags& aFlags,
bool aAllEvents = false);
void RemoveAllListeners();
const EventTypeData* GetTypeDataForIID(const nsIID& aIID);
const EventTypeData* GetTypeDataForEventName(nsIAtom* aName);
nsPIDOMWindow* GetInnerWindowForTarget();
already_AddRefed<nsPIDOMWindow> GetTargetAsInnerWindow() const;
bool ListenerCanHandle(Listener* aListener, WidgetEvent* aEvent);
+ // BE AWARE, a lot of instances of EventListenerManager will be created.
+ // Therefor, we need to keep this class compact. When you add integer
+ // members, please add them to EventListemerManagerBase and check the size
+ // at build time.
+
already_AddRefed<nsIScriptGlobalObject>
GetScriptGlobalAndDocument(nsIDocument** aDoc);
- uint32_t mMayHavePaintEventListener : 1;
- uint32_t mMayHaveMutationListeners : 1;
- uint32_t mMayHaveCapturingListeners : 1;
- uint32_t mMayHaveSystemGroupListeners : 1;
- uint32_t mMayHaveTouchEventListener : 1;
- uint32_t mMayHaveMouseEnterLeaveEventListener : 1;
- uint32_t mMayHavePointerEnterLeaveEventListener : 1;
- uint32_t mMayHaveKeyEventListener : 1;
- uint32_t mMayHaveInputOrCompositionEventListener : 1;
- uint32_t mClearingListeners : 1;
- uint32_t mIsMainThreadELM : 1;
- uint32_t mNoListenerForEvent : 21;
-
nsAutoTObserverArray<Listener, 2> mListeners;
dom::EventTarget* MOZ_NON_OWNING_REF mTarget;
nsCOMPtr<nsIAtom> mNoListenerForEventAtom;
friend class ELMCreationDetector;
static uint32_t sMainThreadCreatedCount;
};
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -620,17 +620,17 @@ EventStateManager::PreHandleEvent(nsPres
// then fall through...
} else {
if (sPointerEventEnabled) {
// We should synthetize corresponding pointer events
GeneratePointerEnterExit(NS_POINTER_LEAVE, mouseEvent);
}
GenerateMouseEnterExit(mouseEvent);
//This is a window level mouse exit event and should stop here
- aEvent->mMessage = 0;
+ aEvent->mMessage = NS_EVENT_NULL;
break;
}
case NS_MOUSE_MOVE:
case NS_POINTER_DOWN:
case NS_POINTER_MOVE: {
// on the Mac, GenerateDragGesture() may not return until the drag
// has completed and so |aTargetFrame| may have been deleted (moving
// a bookmark, for example). If this is the case, however, we know
@@ -831,16 +831,18 @@ EventStateManager::PreHandleEvent(nsPres
WidgetCompositionEvent* compositionEvent = aEvent->AsCompositionEvent();
WidgetQueryContentEvent selectedText(true, NS_QUERY_SELECTED_TEXT,
compositionEvent->widget);
DoQuerySelectedText(&selectedText);
NS_ASSERTION(selectedText.mSucceeded, "Failed to get selected text");
compositionEvent->mData = selectedText.mReply.mString;
}
break;
+ default:
+ break;
}
return NS_OK;
}
// static
int32_t
EventStateManager::GetAccessModifierMaskFor(nsISupports* aDocShell)
{
@@ -1189,16 +1191,18 @@ CrossProcessSafeEvent(const WidgetEvent&
return false;
}
case eDragEventClass:
switch (aEvent.mMessage) {
case NS_DRAGDROP_OVER:
case NS_DRAGDROP_EXIT:
case NS_DRAGDROP_DROP:
return true;
+ default:
+ break;
}
default:
return false;
}
}
bool
EventStateManager::HandleCrossProcessEvent(WidgetEvent* aEvent,
@@ -3327,16 +3331,19 @@ EventStateManager::PostHandleEvent(nsPre
nsCOMPtr<nsIContent> targetContent;
mCurrentTarget->GetContentForEvent(aEvent, getter_AddRefs(targetContent));
if (!NodeAllowsClickThrough(targetContent)) {
*aStatus = nsEventStatus_eConsumeNoDefault;
}
}
break;
#endif
+
+ default:
+ break;
}
//Reset target frame to null to avoid mistargeting after reentrant event
mCurrentTarget = nullptr;
mCurrentTargetContent = nullptr;
return ret;
}
@@ -3680,17 +3687,17 @@ EventStateManager::IsHandlingUserInput()
TimeDuration timeout = nsContentUtils::HandlingUserInputTimeout();
return timeout <= TimeDuration(0) ||
(TimeStamp::Now() - sHandlingInputStart) <= timeout;
}
static void
CreateMouseOrPointerWidgetEvent(WidgetMouseEvent* aMouseEvent,
- uint32_t aMessage,
+ EventMessage aMessage,
nsIContent* aRelatedContent,
nsAutoPtr<WidgetMouseEvent>& aNewEvent)
{
WidgetPointerEvent* sourcePointer = aMouseEvent->AsPointerEvent();
if (sourcePointer) {
PROFILER_LABEL("Input", "DispatchPointerEvent",
js::ProfileEntry::Category::EVENTS);
@@ -3720,17 +3727,17 @@ CreateMouseOrPointerWidgetEvent(WidgetMo
aNewEvent->buttons = aMouseEvent->buttons;
aNewEvent->pressure = aMouseEvent->pressure;
aNewEvent->mPluginEvent = aMouseEvent->mPluginEvent;
aNewEvent->inputSource = aMouseEvent->inputSource;
}
nsIFrame*
EventStateManager::DispatchMouseOrPointerEvent(WidgetMouseEvent* aMouseEvent,
- uint32_t aMessage,
+ EventMessage aMessage,
nsIContent* aTargetContent,
nsIContent* aRelatedContent)
{
// http://dvcs.w3.org/hg/webevents/raw-file/default/mouse-lock.html#methods
// "[When the mouse is locked on an element...e]vents that require the concept
// of a mouse cursor must not be dispatched (for example: mouseover, mouseout).
if (sIsPointerLocked &&
(aMessage == NS_MOUSELEAVE ||
@@ -3809,20 +3816,21 @@ EventStateManager::DispatchMouseOrPointe
return targetFrame;
}
class EnterLeaveDispatcher
{
public:
EnterLeaveDispatcher(EventStateManager* aESM,
nsIContent* aTarget, nsIContent* aRelatedTarget,
- WidgetMouseEvent* aMouseEvent, uint32_t aType)
+ WidgetMouseEvent* aMouseEvent,
+ EventMessage aEventMessage)
: mESM(aESM)
, mMouseEvent(aMouseEvent)
- , mType(aType)
+ , mEventMessage(aEventMessage)
{
nsPIDOMWindow* win =
aTarget ? aTarget->OwnerDoc()->GetInnerWindow() : nullptr;
if (aMouseEvent->AsPointerEvent() ? win && win->HasPointerEnterLeaveEventListeners() :
win && win->HasMouseEnterLeaveEventListeners()) {
mRelatedTarget = aRelatedTarget ?
aRelatedTarget->FindFirstNonChromeOnlyAccessContent() : nullptr;
nsINode* commonParent = nullptr;
@@ -3839,35 +3847,35 @@ public:
// mouseenter/leave is fired only on elements.
current = current->GetParent();
}
}
}
~EnterLeaveDispatcher()
{
- if (mType == NS_MOUSEENTER ||
- mType == NS_POINTER_ENTER) {
+ if (mEventMessage == NS_MOUSEENTER ||
+ mEventMessage == NS_POINTER_ENTER) {
for (int32_t i = mTargets.Count() - 1; i >= 0; --i) {
- mESM->DispatchMouseOrPointerEvent(mMouseEvent, mType, mTargets[i],
- mRelatedTarget);
+ mESM->DispatchMouseOrPointerEvent(mMouseEvent, mEventMessage,
+ mTargets[i], mRelatedTarget);
}
} else {
for (int32_t i = 0; i < mTargets.Count(); ++i) {
- mESM->DispatchMouseOrPointerEvent(mMouseEvent, mType, mTargets[i],
- mRelatedTarget);
+ mESM->DispatchMouseOrPointerEvent(mMouseEvent, mEventMessage,
+ mTargets[i], mRelatedTarget);
}
}
}
EventStateManager* mESM;
nsCOMArray<nsIContent> mTargets;
nsCOMPtr<nsIContent> mRelatedTarget;
WidgetMouseEvent* mMouseEvent;
- uint32_t mType;
+ EventMessage mEventMessage;
};
void
EventStateManager::NotifyMouseOut(WidgetMouseEvent* aMouseEvent,
nsIContent* aMovingInto)
{
OverOutElementsWrapper* wrapper = GetWrapperByEventID(aMouseEvent);
@@ -4050,17 +4058,18 @@ GetWindowInnerRectCenter(nsPIDOMWindow*
int32_t cssScreenY = aContext->DevPixelsToIntCSSPixels(screen.y);
return LayoutDeviceIntPoint(
aContext->CSSPixelsToDevPixels(innerX - cssScreenX + innerWidth / 2),
aContext->CSSPixelsToDevPixels(innerY - cssScreenY + innerHeight / 2));
}
void
-EventStateManager::GeneratePointerEnterExit(uint32_t aMessage, WidgetMouseEvent* aEvent)
+EventStateManager::GeneratePointerEnterExit(EventMessage aMessage,
+ WidgetMouseEvent* aEvent)
{
WidgetPointerEvent pointerEvent(*aEvent);
pointerEvent.mMessage = aMessage;
GenerateMouseEnterExit(&pointerEvent);
}
void
EventStateManager::GenerateMouseEnterExit(WidgetMouseEvent* aMouseEvent)
@@ -4173,16 +4182,18 @@ EventStateManager::GenerateMouseEnterExi
// Reset sLastRefPoint, so that we'll know not to report any
// movement the next time we re-enter the window.
sLastRefPoint = kInvalidRefPoint;
NotifyMouseOut(aMouseEvent, nullptr);
}
break;
+ default:
+ break;
}
// reset mCurretTargetContent to what it was
mCurrentTargetContent = targetBeforeEvent;
}
OverOutElementsWrapper*
EventStateManager::GetWrapperByEventID(WidgetMouseEvent* aEvent)
@@ -4319,35 +4330,38 @@ EventStateManager::GenerateDragDropEnter
FireDragEnterOrExit(lastDragOverFramePresContext,
aDragEvent, NS_DRAGDROP_LEAVE,
nullptr, lastContent, sLastDragOverFrame);
sLastDragOverFrame = nullptr;
}
}
break;
+
+ default:
+ break;
}
//reset mCurretTargetContent to what it was
mCurrentTargetContent = targetBeforeEvent;
// Now flush all pending notifications, for better responsiveness.
FlushPendingEvents(aPresContext);
}
void
EventStateManager::FireDragEnterOrExit(nsPresContext* aPresContext,
WidgetDragEvent* aDragEvent,
- uint32_t aMsg,
+ EventMessage aMessage,
nsIContent* aRelatedTarget,
nsIContent* aTargetContent,
nsWeakFrame& aTargetFrame)
{
nsEventStatus status = nsEventStatus_eIgnore;
- WidgetDragEvent event(aDragEvent->mFlags.mIsTrusted, aMsg,
+ WidgetDragEvent event(aDragEvent->mFlags.mIsTrusted, aMessage,
aDragEvent->widget);
event.refPoint = aDragEvent->refPoint;
event.modifiers = aDragEvent->modifiers;
event.buttons = aDragEvent->buttons;
event.relatedTarget = aRelatedTarget;
event.inputSource = aDragEvent->inputSource;
mCurrentTargetContent = aTargetContent;
@@ -4355,25 +4369,29 @@ EventStateManager::FireDragEnterOrExit(n
if (aTargetContent != aRelatedTarget) {
//XXX This event should still go somewhere!!
if (aTargetContent) {
EventDispatcher::Dispatch(aTargetContent, aPresContext, &event,
nullptr, &status);
}
// adjust the drag hover if the dragenter event was cancelled or this is a drag exit
- if (status == nsEventStatus_eConsumeNoDefault || aMsg == NS_DRAGDROP_EXIT)
- SetContentState((aMsg == NS_DRAGDROP_ENTER) ? aTargetContent : nullptr,
+ if (status == nsEventStatus_eConsumeNoDefault ||
+ aMessage == NS_DRAGDROP_EXIT) {
+ SetContentState((aMessage == NS_DRAGDROP_ENTER) ?
+ aTargetContent : nullptr,
NS_EVENT_STATE_DRAGOVER);
+ }
// collect any changes to moz cursor settings stored in the event's
// data transfer.
- if (aMsg == NS_DRAGDROP_LEAVE || aMsg == NS_DRAGDROP_EXIT ||
- aMsg == NS_DRAGDROP_ENTER)
+ if (aMessage == NS_DRAGDROP_LEAVE || aMessage == NS_DRAGDROP_EXIT ||
+ aMessage == NS_DRAGDROP_ENTER) {
UpdateDragDataTransfer(&event);
+ }
}
// Finally dispatch the event to the frame
if (aTargetFrame)
aTargetFrame->HandleEvent(aPresContext, &event, &status);
}
void
--- a/dom/events/EventStateManager.h
+++ b/dom/events/EventStateManager.h
@@ -298,23 +298,24 @@ protected:
nsIFrame* aTargetFrame,
nsEventStatus* aStatus);
/**
* Turn a GUI mouse/pointer event into a mouse/pointer event targeted at the specified
* content. This returns the primary frame for the content (or null
* if it goes away during the event).
*/
nsIFrame* DispatchMouseOrPointerEvent(WidgetMouseEvent* aMouseEvent,
- uint32_t aMessage,
+ EventMessage aMessage,
nsIContent* aTargetContent,
nsIContent* aRelatedContent);
/**
* Synthesize DOM pointerover and pointerout events
*/
- void GeneratePointerEnterExit(uint32_t aMessage, WidgetMouseEvent* aEvent);
+ void GeneratePointerEnterExit(EventMessage aMessage,
+ WidgetMouseEvent* aEvent);
/**
* Synthesize DOM and frame mouseover and mouseout events from this
* MOUSE_MOVE or MOUSE_EXIT event.
*/
void GenerateMouseEnterExit(WidgetMouseEvent* aMouseEvent);
/**
* Tell this ESM and ESMs in parent documents that the mouse is
* over some content in this document.
@@ -346,17 +347,17 @@ protected:
* new target.
*
* @param aRelatedTarget relatedTarget to set for the event
* @param aTargetContent target to set for the event
* @param aTargetFrame target frame for the event
*/
void FireDragEnterOrExit(nsPresContext* aPresContext,
WidgetDragEvent* aDragEvent,
- uint32_t aMsg,
+ EventMessage aMessage,
nsIContent* aRelatedTarget,
nsIContent* aTargetContent,
nsWeakFrame& aTargetFrame);
/**
* Update the initial drag session data transfer with any changes that occur
* on cloned data transfer objects used for events.
*/
void UpdateDragDataTransfer(WidgetDragEvent* dragEvent);
--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -129,17 +129,17 @@ GetIMEStateSetOpenName(IMEState::Open aO
case IMEState::CLOSED:
return "CLOSED";
default:
return "illegal value";
}
}
static const char*
-GetEventMessageName(uint32_t aMessage)
+GetEventMessageName(EventMessage aMessage)
{
switch (aMessage) {
case NS_COMPOSITION_START:
return "NS_COMPOSITION_START";
case NS_COMPOSITION_END:
return "NS_COMPOSITION_END";
case NS_COMPOSITION_UPDATE:
return "NS_COMPOSITION_UPDATE";
--- a/dom/events/InputEvent.cpp
+++ b/dom/events/InputEvent.cpp
@@ -10,17 +10,19 @@
namespace mozilla {
namespace dom {
InputEvent::InputEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
InternalEditorInputEvent* aEvent)
: UIEvent(aOwner, aPresContext,
- aEvent ? aEvent : new InternalEditorInputEvent(false, 0, nullptr))
+ aEvent ? aEvent :
+ new InternalEditorInputEvent(false, NS_EVENT_NULL,
+ nullptr))
{
NS_ASSERTION(mEvent->mClass == eEditorInputEventClass,
"event type mismatch");
if (aEvent) {
mEventIsInternal = false;
} else {
mEventIsInternal = true;
--- a/dom/events/InternalMutationEvent.h
+++ b/dom/events/InternalMutationEvent.h
@@ -14,17 +14,17 @@
namespace mozilla {
class InternalMutationEvent : public WidgetEvent
{
public:
virtual InternalMutationEvent* AsMutationEvent() override { return this; }
- InternalMutationEvent(bool aIsTrusted, uint32_t aMessage)
+ InternalMutationEvent(bool aIsTrusted, EventMessage aMessage)
: WidgetEvent(aIsTrusted, aMessage, eMutationEventClass)
, mAttrChange(0)
{
mFlags.mCancelable = false;
}
virtual WidgetEvent* Duplicate() const override
{
--- a/dom/events/KeyboardEvent.cpp
+++ b/dom/events/KeyboardEvent.cpp
@@ -10,17 +10,18 @@
namespace mozilla {
namespace dom {
KeyboardEvent::KeyboardEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetKeyboardEvent* aEvent)
: UIEvent(aOwner, aPresContext,
- aEvent ? aEvent : new WidgetKeyboardEvent(false, 0, nullptr))
+ aEvent ? aEvent :
+ new WidgetKeyboardEvent(false, NS_EVENT_NULL, nullptr))
, mInitializedByCtor(false)
, mInitializedWhichValue(0)
{
if (aEvent) {
mEventIsInternal = false;
}
else {
mEventIsInternal = true;
@@ -156,16 +157,18 @@ KeyboardEvent::CharCode()
case NS_KEY_DOWN:
case NS_KEY_AFTER_DOWN:
case NS_KEY_BEFORE_UP:
case NS_KEY_UP:
case NS_KEY_AFTER_UP:
return 0;
case NS_KEY_PRESS:
return mEvent->AsKeyboardEvent()->charCode;
+ default:
+ break;
}
return 0;
}
NS_IMETHODIMP
KeyboardEvent::GetKeyCode(uint32_t* aKeyCode)
{
NS_ENSURE_ARG_POINTER(aKeyCode);
@@ -208,16 +211,18 @@ KeyboardEvent::Which()
//more closely mirror the values that 4.x gave for RETURN and BACKSPACE
{
uint32_t keyCode = mEvent->AsKeyboardEvent()->keyCode;
if (keyCode == NS_VK_RETURN || keyCode == NS_VK_BACK) {
return keyCode;
}
return CharCode();
}
+ default:
+ break;
}
return 0;
}
NS_IMETHODIMP
KeyboardEvent::GetLocation(uint32_t* aLocation)
{
--- a/dom/events/MouseEvent.cpp
+++ b/dom/events/MouseEvent.cpp
@@ -12,18 +12,19 @@
namespace mozilla {
namespace dom {
MouseEvent::MouseEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetMouseEventBase* aEvent)
: UIEvent(aOwner, aPresContext,
- aEvent ? aEvent : new WidgetMouseEvent(false, 0, nullptr,
- WidgetMouseEvent::eReal))
+ aEvent ? aEvent :
+ new WidgetMouseEvent(false, NS_EVENT_NULL, nullptr,
+ WidgetMouseEvent::eReal))
{
// There's no way to make this class' ctor allocate an WidgetMouseScrollEvent.
// It's not that important, though, since a scroll event is not a real
// DOM event.
WidgetMouseEvent* mouseEvent = mEvent->AsMouseEvent();
if (aEvent) {
mEventIsInternal = false;
--- a/dom/events/MouseScrollEvent.cpp
+++ b/dom/events/MouseScrollEvent.cpp
@@ -10,17 +10,19 @@
namespace mozilla {
namespace dom {
MouseScrollEvent::MouseScrollEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetMouseScrollEvent* aEvent)
: MouseEvent(aOwner, aPresContext,
- aEvent ? aEvent : new WidgetMouseScrollEvent(false, 0, nullptr))
+ aEvent ? aEvent :
+ new WidgetMouseScrollEvent(false, NS_EVENT_NULL,
+ nullptr))
{
if (aEvent) {
mEventIsInternal = false;
} else {
mEventIsInternal = true;
mEvent->time = PR_Now();
mEvent->refPoint.x = mEvent->refPoint.y = 0;
static_cast<WidgetMouseEventBase*>(mEvent)->inputSource =
--- a/dom/events/MutationEvent.cpp
+++ b/dom/events/MutationEvent.cpp
@@ -12,17 +12,17 @@ class nsPresContext;
namespace mozilla {
namespace dom {
MutationEvent::MutationEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
InternalMutationEvent* aEvent)
: Event(aOwner, aPresContext,
- aEvent ? aEvent : new InternalMutationEvent(false, 0))
+ aEvent ? aEvent : new InternalMutationEvent(false, NS_EVENT_NULL))
{
mEventIsInternal = (aEvent == nullptr);
}
NS_INTERFACE_MAP_BEGIN(MutationEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMMutationEvent)
NS_INTERFACE_MAP_END_INHERITING(Event)
--- a/dom/events/NotifyPaintEvent.cpp
+++ b/dom/events/NotifyPaintEvent.cpp
@@ -13,22 +13,22 @@
#include "nsContentUtils.h"
namespace mozilla {
namespace dom {
NotifyPaintEvent::NotifyPaintEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
- uint32_t aEventType,
+ EventMessage aEventMessage,
nsInvalidateRequestList* aInvalidateRequests)
: Event(aOwner, aPresContext, aEvent)
{
if (mEvent) {
- mEvent->mMessage = aEventType;
+ mEvent->mMessage = aEventMessage;
}
if (aInvalidateRequests) {
mInvalidateRequests.AppendElements(Move(aInvalidateRequests->mRequests));
}
}
NS_INTERFACE_MAP_BEGIN(NotifyPaintEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMNotifyPaintEvent)
@@ -161,16 +161,16 @@ NotifyPaintEvent::Deserialize(const IPC:
using namespace mozilla;
using namespace mozilla::dom;
already_AddRefed<NotifyPaintEvent>
NS_NewDOMNotifyPaintEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
- uint32_t aEventType,
+ EventMessage aEventMessage,
nsInvalidateRequestList* aInvalidateRequests)
{
nsRefPtr<NotifyPaintEvent> it =
- new NotifyPaintEvent(aOwner, aPresContext, aEvent, aEventType,
+ new NotifyPaintEvent(aOwner, aPresContext, aEvent, aEventMessage,
aInvalidateRequests);
return it.forget();
}
--- a/dom/events/NotifyPaintEvent.h
+++ b/dom/events/NotifyPaintEvent.h
@@ -23,17 +23,17 @@ class PaintRequestList;
class NotifyPaintEvent : public Event,
public nsIDOMNotifyPaintEvent
{
public:
NotifyPaintEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
- uint32_t aEventType,
+ EventMessage aEventMessage,
nsInvalidateRequestList* aInvalidateRequests);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMNOTIFYPAINTEVENT
// Forward to base class
NS_FORWARD_TO_EVENT_NO_SERIALIZATION_NO_DUPLICATION
@@ -67,12 +67,14 @@ private:
} // namespace dom
} // namespace mozilla
// This empties aInvalidateRequests.
already_AddRefed<mozilla::dom::NotifyPaintEvent>
NS_NewDOMNotifyPaintEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::WidgetEvent* aEvent,
- uint32_t aEventType = 0,
- nsInvalidateRequestList* aInvalidateRequests = nullptr);
+ mozilla::EventMessage aEventMessage =
+ mozilla::NS_EVENT_NULL,
+ nsInvalidateRequestList* aInvalidateRequests =
+ nullptr);
#endif // mozilla_dom_NotifyPaintEvent_h_
--- a/dom/events/PointerEvent.cpp
+++ b/dom/events/PointerEvent.cpp
@@ -12,17 +12,18 @@
namespace mozilla {
namespace dom {
PointerEvent::PointerEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetPointerEvent* aEvent)
: MouseEvent(aOwner, aPresContext,
- aEvent ? aEvent : new WidgetPointerEvent(false, 0, nullptr))
+ aEvent ? aEvent :
+ new WidgetPointerEvent(false, NS_EVENT_NULL, nullptr))
{
NS_ASSERTION(mEvent->mClass == ePointerEventClass,
"event type mismatch ePointerEventClass");
WidgetMouseEvent* mouseEvent = mEvent->AsMouseEvent();
if (aEvent) {
mEventIsInternal = false;
} else {
--- a/dom/events/SimpleGestureEvent.cpp
+++ b/dom/events/SimpleGestureEvent.cpp
@@ -11,17 +11,18 @@
namespace mozilla {
namespace dom {
SimpleGestureEvent::SimpleGestureEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetSimpleGestureEvent* aEvent)
: MouseEvent(aOwner, aPresContext,
aEvent ? aEvent :
- new WidgetSimpleGestureEvent(false, 0, nullptr))
+ new WidgetSimpleGestureEvent(false, NS_EVENT_NULL,
+ nullptr))
{
NS_ASSERTION(mEvent->mClass == eSimpleGestureEventClass,
"event type mismatch");
if (aEvent) {
mEventIsInternal = false;
} else {
mEventIsInternal = true;
--- a/dom/events/TextComposition.cpp
+++ b/dom/events/TextComposition.cpp
@@ -95,17 +95,17 @@ TextComposition::MaybeDispatchCompositio
}
CloneAndDispatchAs(aCompositionEvent, NS_COMPOSITION_UPDATE);
return IsValidStateForComposition(aCompositionEvent->widget);
}
BaseEventFlags
TextComposition::CloneAndDispatchAs(
const WidgetCompositionEvent* aCompositionEvent,
- uint32_t aMessage,
+ EventMessage aMessage,
nsEventStatus* aStatus,
EventDispatchingCallback* aCallBack)
{
MOZ_RELEASE_ASSERT(!mTabParent);
MOZ_ASSERT(IsValidStateForComposition(aCompositionEvent->widget),
"Should be called only when it's safe to dispatch an event");
@@ -432,17 +432,17 @@ TextComposition::NotityUpdateComposition
} else {
return;
}
NotifyIME(NOTIFY_IME_OF_COMPOSITION_UPDATE);
}
void
-TextComposition::DispatchCompositionEventRunnable(uint32_t aEventMessage,
+TextComposition::DispatchCompositionEventRunnable(EventMessage aEventMessage,
const nsAString& aData,
bool aIsSynthesizingCommit)
{
nsContentUtils::AddScriptRunner(
new CompositionEventDispatcher(this, mNode, aEventMessage, aData,
aIsSynthesizingCommit));
}
@@ -580,23 +580,23 @@ TextComposition::HasEditor() const
/******************************************************************************
* TextComposition::CompositionEventDispatcher
******************************************************************************/
TextComposition::CompositionEventDispatcher::CompositionEventDispatcher(
TextComposition* aComposition,
nsINode* aEventTarget,
- uint32_t aEventMessage,
+ EventMessage aEventMessage,
const nsAString& aData,
bool aIsSynthesizedEvent)
: mTextComposition(aComposition)
, mEventTarget(aEventTarget)
+ , mData(aData)
, mEventMessage(aEventMessage)
- , mData(aData)
, mIsSynthesizedEvent(aIsSynthesizedEvent)
{
}
NS_IMETHODIMP
TextComposition::CompositionEventDispatcher::Run()
{
// The widget can be different from the widget which has dispatched
--- a/dom/events/TextComposition.h
+++ b/dom/events/TextComposition.h
@@ -314,17 +314,17 @@ private:
/**
* CloneAndDispatchAs() dispatches a composition event which is
* duplicateed from aCompositionEvent and set the aMessage.
*
* @return Returns BaseEventFlags which is the result of dispatched event.
*/
BaseEventFlags CloneAndDispatchAs(
const WidgetCompositionEvent* aCompositionEvent,
- uint32_t aMessage,
+ EventMessage aMessage,
nsEventStatus* aStatus = nullptr,
EventDispatchingCallback* aCallBack = nullptr);
/**
* If IME has already dispatched compositionend event but it was discarded
* by PresShell due to not safe to dispatch, this returns true.
*/
bool WasNativeCompositionEndEventDiscarded() const
@@ -348,26 +348,26 @@ private:
* CompositionEventDispatcher dispatches the specified composition (or text)
* event.
*/
class CompositionEventDispatcher : public nsRunnable
{
public:
CompositionEventDispatcher(TextComposition* aTextComposition,
nsINode* aEventTarget,
- uint32_t aEventMessage,
+ EventMessage aEventMessage,
const nsAString& aData,
bool aIsSynthesizedEvent = false);
NS_IMETHOD Run() override;
private:
nsRefPtr<TextComposition> mTextComposition;
nsCOMPtr<nsINode> mEventTarget;
- uint32_t mEventMessage;
nsString mData;
+ EventMessage mEventMessage;
bool mIsSynthesizedEvent;
CompositionEventDispatcher() {};
};
/**
* DispatchCompositionEventRunnable() dispatches a composition event to the
* content. Be aware, if you use this method, nsPresShellEventCB isn't used.
@@ -376,17 +376,17 @@ private:
* destroyed by this method call.
*
* @param aEventMessage Must be one of composition events.
* @param aData Used for mData value.
* @param aIsSynthesizingCommit true if this is called for synthesizing
* commit or cancel composition. Otherwise,
* false.
*/
- void DispatchCompositionEventRunnable(uint32_t aEventMessage,
+ void DispatchCompositionEventRunnable(EventMessage aEventMessage,
const nsAString& aData,
bool aIsSynthesizingCommit = false);
};
/**
* TextCompositionArray manages the instances of TextComposition class.
* Managing with array is enough because only one composition is typically
* there. Even if user switches native IME context, it's very rare that
--- a/dom/events/TouchEvent.cpp
+++ b/dom/events/TouchEvent.cpp
@@ -58,17 +58,18 @@ TouchList::IdentifiedTouch(int32_t aIden
/******************************************************************************
* TouchEvent
*****************************************************************************/
TouchEvent::TouchEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetTouchEvent* aEvent)
: UIEvent(aOwner, aPresContext,
- aEvent ? aEvent : new WidgetTouchEvent(false, 0, nullptr))
+ aEvent ? aEvent :
+ new WidgetTouchEvent(false, NS_EVENT_NULL, nullptr))
{
if (aEvent) {
mEventIsInternal = false;
for (uint32_t i = 0; i < aEvent->touches.Length(); ++i) {
Touch* touch = aEvent->touches[i];
touch->InitializePoints(mPresContext, aEvent);
}
--- a/dom/events/TransitionEvent.cpp
+++ b/dom/events/TransitionEvent.cpp
@@ -10,17 +10,17 @@
namespace mozilla {
namespace dom {
TransitionEvent::TransitionEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
InternalTransitionEvent* aEvent)
: Event(aOwner, aPresContext,
- aEvent ? aEvent : new InternalTransitionEvent(false, 0))
+ aEvent ? aEvent : new InternalTransitionEvent(false, NS_EVENT_NULL))
{
if (aEvent) {
mEventIsInternal = false;
}
else {
mEventIsInternal = true;
mEvent->time = PR_Now();
}
--- a/dom/events/UIEvent.cpp
+++ b/dom/events/UIEvent.cpp
@@ -24,17 +24,17 @@
namespace mozilla {
namespace dom {
UIEvent::UIEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetGUIEvent* aEvent)
: Event(aOwner, aPresContext,
- aEvent ? aEvent : new InternalUIEvent(false, 0, nullptr))
+ aEvent ? aEvent : new InternalUIEvent(false, NS_EVENT_NULL, nullptr))
, mClientPoint(0, 0)
, mLayerPoint(0, 0)
, mPagePoint(0, 0)
, mMovementPoint(0, 0)
, mIsPointerLocked(EventStateManager::sIsPointerLocked)
, mLastClientPoint(EventStateManager::sLastClientPoint)
{
if (aEvent) {
--- a/dom/events/WheelEvent.cpp
+++ b/dom/events/WheelEvent.cpp
@@ -11,17 +11,18 @@
namespace mozilla {
namespace dom {
WheelEvent::WheelEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetWheelEvent* aWheelEvent)
: MouseEvent(aOwner, aPresContext,
aWheelEvent ? aWheelEvent :
- new WidgetWheelEvent(false, 0, nullptr))
+ new WidgetWheelEvent(false, NS_EVENT_NULL,
+ nullptr))
, mAppUnitsPerDevPixel(0)
{
if (aWheelEvent) {
mEventIsInternal = false;
// If the delta mode is pixel, the WidgetWheelEvent's delta values are in
// device pixels. However, JS contents need the delta values in CSS pixels.
// We should store the value of mAppUnitsPerDevPixel here because
// it might be changed by changing zoom or something.
--- a/dom/events/WheelHandlingHelper.cpp
+++ b/dom/events/WheelHandlingHelper.cpp
@@ -213,16 +213,18 @@ WheelTransaction::OnEvent(WidgetEvent* a
case NS_MOUSE_BUTTON_UP:
case NS_MOUSE_BUTTON_DOWN:
case NS_MOUSE_DOUBLECLICK:
case NS_MOUSE_CLICK:
case NS_CONTEXTMENU:
case NS_DRAGDROP_DROP:
EndTransaction();
return;
+ default:
+ break;
}
}
/* static */ void
WheelTransaction::Shutdown()
{
NS_IF_RELEASE(sTimer);
}
--- a/dom/events/XULCommandEvent.cpp
+++ b/dom/events/XULCommandEvent.cpp
@@ -9,17 +9,18 @@
namespace mozilla {
namespace dom {
XULCommandEvent::XULCommandEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetInputEvent* aEvent)
: UIEvent(aOwner, aPresContext,
- aEvent ? aEvent : new WidgetInputEvent(false, 0, nullptr))
+ aEvent ? aEvent :
+ new WidgetInputEvent(false, NS_EVENT_NULL, nullptr))
{
if (aEvent) {
mEventIsInternal = false;
}
else {
mEventIsInternal = true;
mEvent->time = PR_Now();
}
--- a/dom/html/HTMLButtonElement.cpp
+++ b/dom/html/HTMLButtonElement.cpp
@@ -195,17 +195,17 @@ HTMLButtonElement::ParseAttribute(int32_
}
}
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
bool
-HTMLButtonElement::IsDisabledForEvents(uint32_t aMessage)
+HTMLButtonElement::IsDisabledForEvents(EventMessage aMessage)
{
nsIFormControlFrame* formControlFrame = GetFormControlFrame(false);
nsIFrame* formFrame = do_QueryFrame(formControlFrame);
return IsElementDisabledForEvents(aMessage, formFrame);
}
nsresult
HTMLButtonElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
--- a/dom/html/HTMLButtonElement.h
+++ b/dom/html/HTMLButtonElement.h
@@ -47,17 +47,17 @@ public:
NS_DECL_NSIDOMHTMLBUTTONELEMENT
// overriden nsIFormControl methods
NS_IMETHOD_(uint32_t) GetType() const override { return mType; }
NS_IMETHOD Reset() override;
NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission) override;
NS_IMETHOD SaveState() override;
bool RestoreState(nsPresState* aState) override;
- virtual bool IsDisabledForEvents(uint32_t aMessage) override;
+ virtual bool IsDisabledForEvents(EventMessage aMessage) override;
virtual void FieldSetDisabledChanged(bool aNotify) override;
// nsIDOMEventTarget
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) override;
virtual nsresult PostHandleEvent(
EventChainPostVisitor& aVisitor) override;
--- a/dom/html/HTMLFieldSetElement.cpp
+++ b/dom/html/HTMLFieldSetElement.cpp
@@ -58,17 +58,17 @@ NS_IMPL_ELEMENT_CLONE(HTMLFieldSetElemen
NS_IMPL_BOOL_ATTR(HTMLFieldSetElement, Disabled, disabled)
NS_IMPL_STRING_ATTR(HTMLFieldSetElement, Name, name)
// nsIConstraintValidation
NS_IMPL_NSICONSTRAINTVALIDATION(HTMLFieldSetElement)
bool
-HTMLFieldSetElement::IsDisabledForEvents(uint32_t aMessage)
+HTMLFieldSetElement::IsDisabledForEvents(EventMessage aMessage)
{
return IsElementDisabledForEvents(aMessage, nullptr);
}
// nsIContent
nsresult
HTMLFieldSetElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
--- a/dom/html/HTMLFieldSetElement.h
+++ b/dom/html/HTMLFieldSetElement.h
@@ -46,17 +46,17 @@ public:
virtual nsresult InsertChildAt(nsIContent* aChild, uint32_t aIndex,
bool aNotify) override;
virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override;
// nsIFormControl
NS_IMETHOD_(uint32_t) GetType() const override { return NS_FORM_FIELDSET; }
NS_IMETHOD Reset() override;
NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission) override;
- virtual bool IsDisabledForEvents(uint32_t aMessage) override;
+ virtual bool IsDisabledForEvents(EventMessage aMessage) override;
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
const nsIContent* GetFirstLegend() const { return mFirstLegend; }
void AddElement(nsGenericHTMLFormElement* aElement);
void RemoveElement(nsGenericHTMLFormElement* aElement);
--- a/dom/html/HTMLFormElement.cpp
+++ b/dom/html/HTMLFormElement.cpp
@@ -530,17 +530,17 @@ HTMLFormElement::WillHandleEvent(EventCh
}
return NS_OK;
}
nsresult
HTMLFormElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
{
if (aVisitor.mEvent->originalTarget == static_cast<nsIContent*>(this)) {
- uint32_t msg = aVisitor.mEvent->mMessage;
+ EventMessage msg = aVisitor.mEvent->mMessage;
if (msg == NS_FORM_SUBMIT) {
// let the form know not to defer subsequent submissions
mDeferSubmission = false;
}
if (aVisitor.mEventStatus == nsEventStatus_eIgnore) {
switch (msg) {
case NS_FORM_RESET:
@@ -550,18 +550,20 @@ HTMLFormElement::PostHandleEvent(EventCh
// tell the form to forget a possible pending submission.
// the reason is that the script returned true (the event was
// ignored) so if there is a stored submission, it will miss
// the name/value of the submitting element, thus we need
// to forget it and the form element will build a new one
mPendingSubmission = nullptr;
}
DoSubmitOrReset(aVisitor.mEvent, msg);
+ break;
}
- break;
+ default:
+ break;
}
} else {
if (msg == NS_FORM_SUBMIT) {
// tell the form to flush a possible pending submission.
// the reason is that the script returned false (the event was
// not ignored) so if there is a stored submission, it needs to
// be submitted immediatelly.
FlushPendingSubmission();
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -3035,17 +3035,17 @@ HTMLInputElement::NeedToInitializeEditor
case NS_SCROLLPORT_OVERFLOW:
return false;
default:
return true;
}
}
bool
-HTMLInputElement::IsDisabledForEvents(uint32_t aMessage)
+HTMLInputElement::IsDisabledForEvents(EventMessage aMessage)
{
return IsElementDisabledForEvents(aMessage, GetPrimaryFrame());
}
nsresult
HTMLInputElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
// Do not process any DOM events if the element is disabled
@@ -3657,16 +3657,18 @@ HTMLInputElement::PostHandleEvent(EventC
if (mForm) {
// tell the form that we are about to exit a click handler
// so the form knows not to defer subsequent submissions
// the pending ones that were created during the handler
// will be flushed or forgoten.
mForm->OnSubmitClickEnd();
}
break;
+ default:
+ break;
}
}
// Reset the flag for other content besides this text field
aVisitor.mEvent->mFlags.mNoContentDispatch = noContentDispatch;
// now check to see if the event was "cancelled"
if (mCheckedIsToggled && outerActivateEvent) {
@@ -4151,16 +4153,19 @@ HTMLInputElement::PostHandleEventForRang
}
break;
case NS_TOUCH_CANCEL:
if (mIsDraggingRange) {
CancelRangeThumbDrag();
}
break;
+
+ default:
+ break;
}
}
void
HTMLInputElement::MaybeLoadImage()
{
// Our base URI may have changed; claim that our URI changed, and the
// nsImageLoadingContent will decide whether a new image load is warranted.
--- a/dom/html/HTMLInputElement.h
+++ b/dom/html/HTMLInputElement.h
@@ -144,17 +144,17 @@ public:
// Overriden nsIFormControl methods
NS_IMETHOD_(uint32_t) GetType() const override { return mType; }
NS_IMETHOD Reset() override;
NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission) override;
NS_IMETHOD SaveState() override;
virtual bool RestoreState(nsPresState* aState) override;
virtual bool AllowDrop() override;
- virtual bool IsDisabledForEvents(uint32_t aMessage) override;
+ virtual bool IsDisabledForEvents(EventMessage aMessage) override;
virtual void FieldSetDisabledChanged(bool aNotify) override;
// nsIContent
virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex) override;
virtual bool ParseAttribute(int32_t aNamespaceID,
nsIAtom* aAttribute,
--- a/dom/html/HTMLLabelElement.cpp
+++ b/dom/html/HTMLLabelElement.cpp
@@ -192,16 +192,19 @@ HTMLLabelElement::PostHandleEvent(EventC
eventFlags.mMultipleActionsPrevented = true;
DispatchClickEvent(aVisitor.mPresContext, mouseEvent,
content, false, &eventFlags, &status);
// Do we care about the status this returned? I don't think we do...
// Don't run another <label> off of this click
mouseEvent->mFlags.mMultipleActionsPrevented = true;
}
break;
+
+ default:
+ break;
}
mHandlingEvent = false;
}
return NS_OK;
}
nsresult
HTMLLabelElement::Reset()
--- a/dom/html/HTMLObjectElement.cpp
+++ b/dom/html/HTMLObjectElement.cpp
@@ -219,16 +219,18 @@ HTMLObjectElement::HandleFocusBlurPlugin
case NS_FOCUS_CONTENT: {
OnFocusBlurPlugin(aElement, true);
break;
}
case NS_BLUR_CONTENT: {
OnFocusBlurPlugin(aElement, false);
break;
}
+ default:
+ break;
}
}
NS_IMETHODIMP
HTMLObjectElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
{
HandleFocusBlurPlugin(this, aVisitor.mEvent);
return NS_OK;
--- a/dom/html/HTMLSelectElement.cpp
+++ b/dom/html/HTMLSelectElement.cpp
@@ -1482,17 +1482,17 @@ HTMLSelectElement::IsAttributeMapped(con
nsMapRuleToAttributesFunc
HTMLSelectElement::GetAttributeMappingFunction() const
{
return &MapAttributesIntoRule;
}
bool
-HTMLSelectElement::IsDisabledForEvents(uint32_t aMessage)
+HTMLSelectElement::IsDisabledForEvents(EventMessage aMessage)
{
nsIFormControlFrame* formControlFrame = GetFormControlFrame(false);
nsIFrame* formFrame = nullptr;
if (formControlFrame) {
formFrame = do_QueryFrame(formControlFrame);
}
return IsElementDisabledForEvents(aMessage, formFrame);
}
--- a/dom/html/HTMLSelectElement.h
+++ b/dom/html/HTMLSelectElement.h
@@ -286,17 +286,17 @@ public:
virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override;
// Overriden nsIFormControl methods
NS_IMETHOD_(uint32_t) GetType() const override { return NS_FORM_SELECT; }
NS_IMETHOD Reset() override;
NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission) override;
NS_IMETHOD SaveState() override;
virtual bool RestoreState(nsPresState* aState) override;
- virtual bool IsDisabledForEvents(uint32_t aMessage) override;
+ virtual bool IsDisabledForEvents(EventMessage aMessage) override;
virtual void FieldSetDisabledChanged(bool aNotify) override;
EventStates IntrinsicState() const override;
/**
* To be called when stuff is added under a child of the select--but *before*
* they are actually added.
--- a/dom/html/HTMLTextAreaElement.cpp
+++ b/dom/html/HTMLTextAreaElement.cpp
@@ -464,17 +464,17 @@ HTMLTextAreaElement::IsAttributeMapped(c
nsMapRuleToAttributesFunc
HTMLTextAreaElement::GetAttributeMappingFunction() const
{
return &MapAttributesIntoRule;
}
bool
-HTMLTextAreaElement::IsDisabledForEvents(uint32_t aMessage)
+HTMLTextAreaElement::IsDisabledForEvents(EventMessage aMessage)
{
nsIFormControlFrame* formControlFrame = GetFormControlFrame(false);
nsIFrame* formFrame = do_QueryFrame(formControlFrame);
return IsElementDisabledForEvents(aMessage, formFrame);
}
nsresult
HTMLTextAreaElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
--- a/dom/html/HTMLTextAreaElement.h
+++ b/dom/html/HTMLTextAreaElement.h
@@ -70,17 +70,17 @@ public:
NS_IMETHOD SetUserInput(const nsAString& aInput) override;
// nsIFormControl
NS_IMETHOD_(uint32_t) GetType() const override { return NS_FORM_TEXTAREA; }
NS_IMETHOD Reset() override;
NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission) override;
NS_IMETHOD SaveState() override;
virtual bool RestoreState(nsPresState* aState) override;
- virtual bool IsDisabledForEvents(uint32_t aMessage) override;
+ virtual bool IsDisabledForEvents(EventMessage aMessage) override;
virtual void FieldSetDisabledChanged(bool aNotify) override;
virtual EventStates IntrinsicState() const override;
// nsITextControlElemet
NS_IMETHOD SetValueChanged(bool aValueChanged) override;
NS_IMETHOD_(bool) IsSingleLineTextControl() const override;
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -2264,16 +2264,18 @@ nsGenericHTMLFormElement::PreHandleEvent
}
case NS_BLUR_CONTENT:
{
nsIFormControlFrame* formControlFrame = GetFormControlFrame(true);
if (formControlFrame)
formControlFrame->SetFocus(false, false);
break;
}
+ default:
+ break;
}
}
return nsGenericHTMLElement::PreHandleEvent(aVisitor);
}
/* virtual */
bool
@@ -2449,18 +2451,18 @@ nsGenericHTMLFormElement::FormIdUpdated(
NS_ASSERTION(element->IsHTMLElement(), "aData should be an HTML element");
element->UpdateFormOwner(false, aNewElement);
return true;
}
bool
-nsGenericHTMLFormElement::IsElementDisabledForEvents(uint32_t aMessage,
- nsIFrame* aFrame)
+nsGenericHTMLFormElement::IsElementDisabledForEvents(EventMessage aMessage,
+ nsIFrame* aFrame)
{
bool disabled = IsDisabled();
if (!disabled && aFrame) {
const nsStyleUserInterface* uiStyle = aFrame->StyleUserInterface();
disabled = uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE ||
uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED;
}
--- a/dom/html/nsGenericHTMLElement.h
+++ b/dom/html/nsGenericHTMLElement.h
@@ -2,16 +2,17 @@
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef nsGenericHTMLElement_h___
#define nsGenericHTMLElement_h___
#include "mozilla/Attributes.h"
+#include "mozilla/EventForwards.h"
#include "nsMappedAttributeElement.h"
#include "nsIDOMHTMLElement.h"
#include "nsNameSpaceManager.h" // for kNameSpaceID_None
#include "nsIFormControl.h"
#include "nsGkAtoms.h"
#include "nsContentCreatorFunctions.h"
#include "mozilla/ErrorResult.h"
#include "nsIDOMHTMLMenuElement.h"
@@ -1403,17 +1404,18 @@ protected:
* This method is a a callback for IDTargetObserver (from nsIDocument).
* It will be called each time the element associated with the id in @form
* changes.
*/
static bool FormIdUpdated(Element* aOldElement, Element* aNewElement,
void* aData);
// Returns true if the event should not be handled from PreHandleEvent
- bool IsElementDisabledForEvents(uint32_t aMessage, nsIFrame* aFrame);
+ bool IsElementDisabledForEvents(mozilla::EventMessage aMessage,
+ nsIFrame* aFrame);
// The focusability state of this form control. eUnfocusable means that it
// shouldn't be focused at all, eInactiveWindow means it's in an inactive
// window, eActiveWindow means it's in an active window.
enum FocusTristate {
eUnfocusable,
eInactiveWindow,
eActiveWindow
--- a/dom/html/nsIFormControl.h
+++ b/dom/html/nsIFormControl.h
@@ -1,17 +1,19 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef nsIFormControl_h___
#define nsIFormControl_h___
+#include "mozilla/EventForwards.h"
#include "nsISupports.h"
+
class nsIDOMHTMLFormElement;
class nsPresState;
class nsFormSubmission;
namespace mozilla {
namespace dom {
class Element;
class HTMLFieldSetElement;
@@ -190,17 +192,17 @@ public:
inline bool IsSubmittableControl() const;
/**
* Returns whether this form control can have draggable children.
* @return whether this form control can have draggable children.
*/
inline bool AllowDraggableChildren() const;
- virtual bool IsDisabledForEvents(uint32_t aMessage)
+ virtual bool IsDisabledForEvents(mozilla::EventMessage aMessage)
{
return false;
}
protected:
/**
* Returns whether mType corresponds to a single line text control type.
* @param aExcludePassword to have NS_FORM_INPUT_PASSWORD ignored.
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -1086,18 +1086,16 @@ interface nsIDOMWindowUtils : nsISupport
nsIQueryContentEventResult sendQueryContentEvent(
in unsigned long aType,
in unsigned long aOffset,
in unsigned long aLength,
in long aX,
in long aY,
[optional] in unsigned long aAdditionalFlags);
- // NOTE: following values are same as NS_QUERY_* in BasicEvents.h
-
/**
* QUERY_SELECTED_TEXT queries the first selection range's information.
*
* @param aOffset Not used.
* @param aLength Not used.
* @param aX Not used.
* @param aY Not used.
*
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -60,16 +60,17 @@ using mozilla::CSSToScreenScale from "Un
using mozilla::CommandInt from "mozilla/EventForwards.h";
using mozilla::Modifiers from "mozilla/EventForwards.h";
using mozilla::layers::GeckoContentController::APZStateChange from "mozilla/layers/GeckoContentController.h";
using mozilla::WritingMode from "mozilla/WritingModes.h";
using mozilla::layers::TouchBehaviorFlags from "mozilla/layers/APZUtils.h";
using nsIWidget::TouchPointerState from "nsIWidget.h";
using struct LookAndFeelInt from "mozilla/widget/WidgetMessageUtils.h";
using struct mozilla::OwningSerializedStructuredCloneBuffer from "ipc/IPCMessageUtils.h";
+using mozilla::EventMessage from "mozilla/EventForwards.h";
using nsEventStatus from "mozilla/EventForwards.h";
namespace mozilla {
namespace dom {
struct NativeKeyBinding
{
CommandInt[] singleLineCommands;
@@ -271,17 +272,17 @@ parent:
/**
* OnEventNeedingAckHandled() is called after a child process dispatches a
* composition event or a selection event which is sent from the parent
* process.
*
* message The message value of the handled event.
*/
- prio(urgent) async OnEventNeedingAckHandled(uint32_t message);
+ prio(urgent) async OnEventNeedingAckHandled(EventMessage message);
/**
* Tells chrome to start plugin IME. If this results in a string getting
* committed, the result is in aCommitted (otherwise aCommitted is empty).
*
* aKeyboardEvent The event with which plugin IME is to be started
* panelX and panelY Location in screen coordinates of the IME input panel
* (should be just under the plugin)
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -2105,17 +2105,17 @@ TabParent::RecvNotifyIMEPositionChange(c
widget->GetIMEUpdatePreference();
if (updatePreference.WantPositionChanged()) {
mContentCache.MaybeNotifyIME(widget, aIMENotification);
}
return true;
}
bool
-TabParent::RecvOnEventNeedingAckHandled(const uint32_t& aMessage)
+TabParent::RecvOnEventNeedingAckHandled(const EventMessage& aMessage)
{
// This is called when the child process receives WidgetCompositionEvent or
// WidgetSelectionEvent.
nsCOMPtr<nsIWidget> widget = GetWidget();
if (!widget) {
return true;
}
@@ -2886,18 +2886,18 @@ TabParent::InjectTouchEvent(const nsAStr
int32_t* aYs,
uint32_t* aRxs,
uint32_t* aRys,
float* aRotationAngles,
float* aForces,
uint32_t aCount,
int32_t aModifiers)
{
- uint32_t msg;
- nsContentUtils::GetEventIdAndAtom(aType, eTouchEventClass, &msg);
+ EventMessage msg;
+ nsContentUtils::GetEventMessageAndAtom(aType, eTouchEventClass, &msg);
if (msg != NS_TOUCH_START && msg != NS_TOUCH_MOVE &&
msg != NS_TOUCH_END && msg != NS_TOUCH_CANCEL) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIWidget> widget = GetWidget();
if (!widget) {
return NS_ERROR_FAILURE;
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -174,17 +174,17 @@ public:
const widget::IMENotification& aEventMessage) override;
virtual bool RecvNotifyIMESelection(const ContentCache& aContentCache,
const widget::IMENotification& aEventMessage) override;
virtual bool RecvUpdateContentCache(const ContentCache& aContentCache) override;
virtual bool RecvNotifyIMEMouseButtonEvent(const widget::IMENotification& aEventMessage,
bool* aConsumedByIME) override;
virtual bool RecvNotifyIMEPositionChange(const ContentCache& aContentCache,
const widget::IMENotification& aEventMessage) override;
- virtual bool RecvOnEventNeedingAckHandled(const uint32_t& aMessage) override;
+ virtual bool RecvOnEventNeedingAckHandled(const EventMessage& aMessage) override;
virtual bool RecvEndIMEComposition(const bool& aCancel,
bool* aNoCompositionEvent,
nsString* aComposition) override;
virtual bool RecvStartPluginIME(const WidgetKeyboardEvent& aKeyboardEvent,
const int32_t& aPanelX,
const int32_t& aPanelY,
nsString* aCommitted) override;
virtual bool RecvSetPluginFocused(const bool& aFocused) override;
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -2132,16 +2132,18 @@ nsEventStatus nsPluginInstanceOwner::Pro
pPluginEvent = &pluginEvent;
break;
case NS_BLUR_CONTENT:
pluginEvent.event = WM_KILLFOCUS;
pluginEvent.wParam = 0;
pluginEvent.lParam = 0;
pPluginEvent = &pluginEvent;
break;
+ default:
+ break;
}
}
if (pPluginEvent && !pPluginEvent->event) {
// Don't send null events to plugins.
NS_WARNING("nsPluginFrame ProcessEvent: trying to send null event to plugin.");
return rv;
}
@@ -2166,16 +2168,18 @@ nsEventStatus nsPluginInstanceOwner::Pro
case eMouseEventClass:
{
switch (anEvent.mMessage)
{
case NS_MOUSE_CLICK:
case NS_MOUSE_DOUBLECLICK:
// Button up/down events sent instead.
return rv;
+ default:
+ break;
}
// Get reference point relative to plugin origin.
const nsPresContext* presContext = mPluginFrame->PresContext();
nsPoint appPoint =
nsLayoutUtils::GetEventCoordinatesRelativeTo(&anEvent, mPluginFrame) -
mPluginFrame->GetContentRectRelativeToSelf().TopLeft();
nsIntPoint pluginPoint(presContext->AppUnitsToDevPixels(appPoint.x),
@@ -2258,16 +2262,18 @@ nsEventStatus nsPluginInstanceOwner::Pro
event.button = 1;
break;
}
// information lost:
event.subwindow = None;
event.same_screen = True;
}
break;
+ default:
+ break;
}
}
break;
//XXX case eMouseScrollEventClass: not received.
case eKeyboardEventClass:
if (anEvent.mPluginEvent)
@@ -2289,16 +2295,18 @@ nsEventStatus nsPluginInstanceOwner::Pro
event.type = XKeyPress;
break;
case NS_KEY_PRESS:
event.type = XKeyPress;
break;
case NS_KEY_UP:
event.type = KeyRelease;
break;
+ default:
+ break;
}
#endif
// Information that could be obtained from pluginEvent but we may not
// want to promise to provide:
event.subwindow = None;
event.x = 0;
event.y = 0;
@@ -2312,30 +2320,31 @@ nsEventStatus nsPluginInstanceOwner::Pro
// DOMKeyCodeToGdkKeyCode(keyEvent.keyCode) and
// gdk_keymap_get_entries_for_keyval will be useful, but the
// mappings will not be unique.
NS_WARNING("Synthesized key event not sent to plugin");
}
break;
default:
- switch (anEvent.mMessage)
- {
+ switch (anEvent.mMessage) {
case NS_FOCUS_CONTENT:
case NS_BLUR_CONTENT:
{
XFocusChangeEvent &event = pluginEvent.xfocus;
event.type =
anEvent.mMessage == NS_FOCUS_CONTENT ? FocusIn : FocusOut;
// information lost:
event.mode = -1;
event.detail = NotifyDetailNone;
}
break;
- }
+ default:
+ break;
+ }
}
if (!pluginEvent.type) {
return rv;
}
// Fill in (useless) generic event information.
XAnyEvent& event = pluginEvent.xany;
@@ -2366,16 +2375,18 @@ nsEventStatus nsPluginInstanceOwner::Pro
case eMouseEventClass:
{
switch (anEvent.mMessage)
{
case NS_MOUSE_CLICK:
case NS_MOUSE_DOUBLECLICK:
// Button up/down events sent instead.
return rv;
+ default:
+ break;
}
// Get reference point relative to plugin origin.
const nsPresContext* presContext = mPluginFrame->PresContext();
nsPoint appPoint =
nsLayoutUtils::GetEventCoordinatesRelativeTo(&anEvent, mPluginFrame) -
mPluginFrame->GetContentRectRelativeToSelf().TopLeft();
nsIntPoint pluginPoint(presContext->AppUnitsToDevPixels(appPoint.x),
@@ -2407,16 +2418,18 @@ nsEventStatus nsPluginInstanceOwner::Pro
event.inSize = sizeof(ANPEvent);
event.eventType = kMouse_ANPEventType;
event.data.mouse.action = kUp_ANPMouseAction;
event.data.mouse.x = pluginPoint.x;
event.data.mouse.y = pluginPoint.y;
mInstance->HandleEvent(&event, nullptr, NS_PLUGIN_CALL_SAFE_TO_REENTER_GECKO);
}
break;
+ default:
+ break;
}
}
break;
case eKeyboardEventClass:
{
const WidgetKeyboardEvent& keyEvent = *anEvent.AsKeyboardEvent();
LOG("Firing eKeyboardEventClass %d %d\n",
--- a/dom/smil/TimeEvent.cpp
+++ b/dom/smil/TimeEvent.cpp
@@ -12,17 +12,17 @@
namespace mozilla {
namespace dom {
TimeEvent::TimeEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
InternalSMILTimeEvent* aEvent)
: Event(aOwner, aPresContext,
- aEvent ? aEvent : new InternalSMILTimeEvent(false, 0))
+ aEvent ? aEvent : new InternalSMILTimeEvent(false, NS_EVENT_NULL))
, mDetail(mEvent->AsSMILTimeEvent()->detail)
{
if (aEvent) {
mEventIsInternal = false;
} else {
mEventIsInternal = true;
}
--- a/dom/smil/nsSMILTimedElement.cpp
+++ b/dom/smil/nsSMILTimedElement.cpp
@@ -77,22 +77,25 @@ nsSMILTimedElement::InstanceTimeComparat
// Helper class: AsyncTimeEventRunner
namespace
{
class AsyncTimeEventRunner : public nsRunnable
{
protected:
nsRefPtr<nsIContent> mTarget;
- uint32_t mMsg;
+ EventMessage mMsg;
int32_t mDetail;
public:
- AsyncTimeEventRunner(nsIContent* aTarget, uint32_t aMsg, int32_t aDetail)
- : mTarget(aTarget), mMsg(aMsg), mDetail(aDetail)
+ AsyncTimeEventRunner(nsIContent* aTarget, EventMessage aMsg,
+ int32_t aDetail)
+ : mTarget(aTarget)
+ , mMsg(aMsg)
+ , mDetail(aDetail)
{
}
NS_IMETHOD Run()
{
InternalSMILTimeEvent event(true, mMsg);
event.detail = mDetail;
@@ -2360,17 +2363,17 @@ nsSMILTimedElement::NotifyChangedInterva
for (uint32_t i = 0; i < times.Length(); ++i) {
times[i]->HandleChangedInterval(container, aBeginObjectChanged,
aEndObjectChanged);
}
}
void
-nsSMILTimedElement::FireTimeEventAsync(uint32_t aMsg, int32_t aDetail)
+nsSMILTimedElement::FireTimeEventAsync(EventMessage aMsg, int32_t aDetail)
{
if (!mAnimationElement)
return;
nsCOMPtr<nsIRunnable> event =
new AsyncTimeEventRunner(mAnimationElement, aMsg, aDetail);
NS_DispatchToMainThread(event);
}
--- a/dom/smil/nsSMILTimedElement.h
+++ b/dom/smil/nsSMILTimedElement.h
@@ -2,16 +2,17 @@
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef NS_SMILTIMEDELEMENT_H_
#define NS_SMILTIMEDELEMENT_H_
+#include "mozilla/EventForwards.h"
#include "mozilla/Move.h"
#include "nsSMILInterval.h"
#include "nsSMILInstanceTime.h"
#include "nsSMILMilestone.h"
#include "nsSMILTimeValueSpec.h"
#include "nsSMILRepeatCount.h"
#include "nsSMILTypes.h"
#include "nsTArray.h"
@@ -534,17 +535,18 @@ protected:
// a consistent state to receive callbacks, and
// (ii) after calling these methods we must assume that the state of the
// element may have changed.
void NotifyNewInterval();
void NotifyChangedInterval(nsSMILInterval* aInterval,
bool aBeginObjectChanged,
bool aEndObjectChanged);
- void FireTimeEventAsync(uint32_t aMsg, int32_t aDetail);
+ void FireTimeEventAsync(mozilla::EventMessage aMsg,
+ int32_t aDetail);
const nsSMILInstanceTime* GetEffectiveBeginInstance() const;
const nsSMILInterval* GetPreviousInterval() const;
bool HasPlayed() const { return !mOldIntervals.IsEmpty(); }
bool HasClientInFillRange() const;
bool EndHasEventConditions() const;
bool AreEndTimesDependentOn(
const nsSMILInstanceTime* aBase) const;
--- a/editor/libeditor/nsEditorEventListener.cpp
+++ b/editor/libeditor/nsEditorEventListener.cpp
@@ -464,16 +464,18 @@ nsEditorEventListener::HandleEvent(nsIDO
return HandleText(aEvent);
// compositionstart
case NS_COMPOSITION_START:
return HandleStartComposition(aEvent);
// compositionend
case NS_COMPOSITION_END:
HandleEndComposition(aEvent);
return NS_OK;
+ default:
+ break;
}
nsAutoString eventType;
aEvent->GetType(eventType);
// We should accept "focus" and "blur" event even if it's synthesized with
// wrong interface for compatibility with older Gecko.
if (eventType.EqualsLiteral("focus")) {
return Focus(aEvent);
--- a/editor/libeditor/nsPlaintextEditor.cpp
+++ b/editor/libeditor/nsPlaintextEditor.cpp
@@ -1163,31 +1163,36 @@ nsPlaintextEditor::CanCutOrCopy(Password
if (aPasswordFieldAllowed == ePasswordFieldNotAllowed &&
IsPasswordEditor())
return false;
return !selection->Collapsed();
}
bool
-nsPlaintextEditor::FireClipboardEvent(int32_t aType, int32_t aSelectionType, bool* aActionTaken)
+nsPlaintextEditor::FireClipboardEvent(EventMessage aEventMessage,
+ int32_t aSelectionType,
+ bool* aActionTaken)
{
- if (aType == NS_PASTE)
+ if (aEventMessage == NS_PASTE) {
ForceCompositionEnd();
+ }
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
NS_ENSURE_TRUE(presShell, false);
nsRefPtr<Selection> selection = GetSelection();
if (!selection) {
return false;
}
- if (!nsCopySupport::FireClipboardEvent(aType, aSelectionType, presShell, selection, aActionTaken))
+ if (!nsCopySupport::FireClipboardEvent(aEventMessage, aSelectionType,
+ presShell, selection, aActionTaken)) {
return false;
+ }
// If the event handler caused the editor to be destroyed, return false.
// Otherwise return true to indicate that the event was not cancelled.
return !mDidPreDestroy;
}
NS_IMETHODIMP nsPlaintextEditor::Cut()
{
--- a/editor/libeditor/nsPlaintextEditor.h
+++ b/editor/libeditor/nsPlaintextEditor.h
@@ -202,17 +202,19 @@ protected:
/* small utility routine to test the eEditorReadonly bit */
bool IsModifiable();
enum PasswordFieldAllowed {
ePasswordFieldAllowed,
ePasswordFieldNotAllowed
};
bool CanCutOrCopy(PasswordFieldAllowed aPasswordFieldAllowed);
- bool FireClipboardEvent(int32_t aType, int32_t aSelectionType, bool* aActionTaken = nullptr);
+ bool FireClipboardEvent(mozilla::EventMessage aEventMessage,
+ int32_t aSelectionType,
+ bool* aActionTaken = nullptr);
bool UpdateMetaCharset(nsIDOMDocument* aDocument,
const nsACString& aCharacterSet);
// Data members
protected:
nsCOMPtr<nsIEditRules> mRules;
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -842,16 +842,18 @@ APZCTreeManager::UpdateWheelTransaction(
case NS_MOUSE_BUTTON_UP:
case NS_MOUSE_BUTTON_DOWN:
case NS_MOUSE_DOUBLECLICK:
case NS_MOUSE_CLICK:
case NS_CONTEXTMENU:
case NS_DRAGDROP_DROP:
txn->EndTransaction();
return;
+ default:
+ break;
}
}
nsEventStatus
APZCTreeManager::ProcessEvent(WidgetInputEvent& aEvent,
ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId)
{
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -482,17 +482,17 @@ APZCCallbackHelper::DispatchWidgetEvent(
nsEventStatus status = nsEventStatus_eConsumeNoDefault;
if (aEvent.widget) {
aEvent.widget->DispatchEvent(&aEvent, status);
}
return status;
}
nsEventStatus
-APZCCallbackHelper::DispatchSynthesizedMouseEvent(uint32_t aMsg,
+APZCCallbackHelper::DispatchSynthesizedMouseEvent(EventMessage aMsg,
uint64_t aTime,
const LayoutDevicePoint& aRefPoint,
Modifiers aModifiers,
nsIWidget* aWidget)
{
MOZ_ASSERT(aMsg == NS_MOUSE_MOVE || aMsg == NS_MOUSE_BUTTON_DOWN ||
aMsg == NS_MOUSE_BUTTON_UP || aMsg == NS_MOUSE_MOZLONGTAP);
--- a/gfx/layers/apz/util/APZCCallbackHelper.h
+++ b/gfx/layers/apz/util/APZCCallbackHelper.h
@@ -114,17 +114,17 @@ public:
/* Dispatch a widget event via the widget stored in the event, if any.
* In a child process, allows the TabParent event-capture mechanism to
* intercept the event. */
static nsEventStatus DispatchWidgetEvent(WidgetGUIEvent& aEvent);
/* Synthesize a mouse event with the given parameters, and dispatch it
* via the given widget. */
- static nsEventStatus DispatchSynthesizedMouseEvent(uint32_t aMsg,
+ static nsEventStatus DispatchSynthesizedMouseEvent(EventMessage aMsg,
uint64_t aTime,
const LayoutDevicePoint& aRefPoint,
Modifiers aModifiers,
nsIWidget* aWidget);
/* Dispatch a mouse event with the given parameters.
* Return whether or not any listeners have called preventDefault on the event. */
static bool DispatchMouseEvent(const nsCOMPtr<nsIPresShell>& aPresShell,
--- a/layout/base/gtest/TestAccessibleCaretEventHub.cpp
+++ b/layout/base/gtest/TestAccessibleCaretEventHub.cpp
@@ -106,17 +106,18 @@ class AccessibleCaretEventHubTester : pu
{
public:
explicit AccessibleCaretEventHubTester()
{
DefaultValue<nsresult>::Set(NS_OK);
EXPECT_EQ(mHub->GetState(), MockAccessibleCaretEventHub::NoActionState());
}
- static UniquePtr<WidgetEvent> CreateMouseEvent(uint32_t aMessage, nscoord aX,
+ static UniquePtr<WidgetEvent> CreateMouseEvent(EventMessage aMessage,
+ nscoord aX,
nscoord aY)
{
auto event = MakeUnique<WidgetMouseEvent>(true, aMessage, nullptr,
WidgetMouseEvent::eReal);
event->button = WidgetMouseEvent::eLeftButton;
event->refPoint = LayoutDeviceIntPoint(aX, aY);
@@ -138,17 +139,18 @@ public:
return CreateMouseEvent(NS_MOUSE_BUTTON_UP, aX, aY);
}
static UniquePtr<WidgetEvent> CreateLongTapEvent(nscoord aX, nscoord aY)
{
return CreateMouseEvent(NS_MOUSE_MOZLONGTAP, aX, aY);
}
- static UniquePtr<WidgetEvent> CreateTouchEvent(uint32_t aMessage, nscoord aX,
+ static UniquePtr<WidgetEvent> CreateTouchEvent(EventMessage aMessage,
+ nscoord aX,
nscoord aY)
{
auto event = MakeUnique<WidgetTouchEvent>(true, aMessage, nullptr);
int32_t identifier = 0;
LayoutDeviceIntPoint point(aX, aY);
nsIntPoint radius(19, 19);
float rotationAngle = 0;
float force = 1;
@@ -170,17 +172,17 @@ public:
return CreateTouchEvent(NS_TOUCH_MOVE, aX, aY);
}
static UniquePtr<WidgetEvent> CreateTouchReleaseEvent(nscoord aX, nscoord aY)
{
return CreateTouchEvent(NS_TOUCH_END, aX, aY);
}
- static UniquePtr<WidgetEvent> CreateWheelEvent(uint32_t aMessage)
+ static UniquePtr<WidgetEvent> CreateWheelEvent(EventMessage aMessage)
{
auto event = MakeUnique<WidgetWheelEvent>(true, aMessage, nullptr);
return Move(event);
}
void HandleEventAndCheckState(UniquePtr<WidgetEvent> aEvent,
MockAccessibleCaretEventHub::State* aExpectedState,
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -6366,16 +6366,18 @@ PresShell::UpdateActivePointerState(Widg
}
break;
case NS_MOUSE_EXIT_WIDGET:
// In this case we have to remove information about disappeared mouse pointers
if (WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent()) {
gActivePointersIds->Remove(mouseEvent->pointerId);
}
break;
+ default:
+ break;
}
}
nsIContent*
PresShell::GetCurrentEventContent()
{
if (mCurrentEventContent &&
mCurrentEventContent->GetCrossShadowCurrentDoc() != mDocument) {
@@ -6648,17 +6650,17 @@ FlushThrottledStyles(nsIDocument *aDocum
static nsresult
DispatchPointerFromMouseOrTouch(PresShell* aShell,
nsIFrame* aFrame,
WidgetGUIEvent* aEvent,
bool aDontRetargetEvents,
nsEventStatus* aStatus,
nsIContent** aTargetContent)
{
- uint32_t pointerMessage = 0;
+ EventMessage pointerMessage = NS_EVENT_NULL;
if (aEvent->mClass == eMouseEventClass) {
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
// if it is not mouse then it is likely will come as touch event
if (!mouseEvent->convertToPointer) {
return NS_OK;
}
int16_t button = mouseEvent->button;
switch (mouseEvent->mMessage) {
@@ -6833,17 +6835,17 @@ PresShell::DispatchBeforeKeyboardEventIn
size_t& aChainIndex,
bool& aDefaultPrevented)
{
size_t length = aChain.Length();
if (!CanDispatchEvent(&aEvent) || !length) {
return;
}
- uint32_t message =
+ EventMessage message =
(aEvent.mMessage == NS_KEY_DOWN) ? NS_KEY_BEFORE_DOWN : NS_KEY_BEFORE_UP;
nsCOMPtr<EventTarget> eventTarget;
// Dispatch before events from the outermost element.
for (int32_t i = length - 1; i >= 0; i--) {
eventTarget = do_QueryInterface(aChain[i]->OwnerDoc()->GetWindow());
if (!eventTarget || !CanDispatchEvent(&aEvent)) {
return;
}
@@ -6867,17 +6869,17 @@ PresShell::DispatchAfterKeyboardEventInt
bool aEmbeddedCancelled,
size_t aStartOffset)
{
size_t length = aChain.Length();
if (!CanDispatchEvent(&aEvent) || !length) {
return;
}
- uint32_t message =
+ EventMessage message =
(aEvent.mMessage == NS_KEY_DOWN) ? NS_KEY_AFTER_DOWN : NS_KEY_AFTER_UP;
bool embeddedCancelled = aEmbeddedCancelled;
nsCOMPtr<EventTarget> eventTarget;
// Dispatch after events from the innermost element.
for (uint32_t i = aStartOffset; i < length; i++) {
eventTarget = do_QueryInterface(aChain[i]->OwnerDoc()->GetWindow());
if (!eventTarget || !CanDispatchEvent(&aEvent)) {
return;
@@ -7524,16 +7526,18 @@ PresShell::HandleEvent(nsIFrame* aFrame,
shell = static_cast<PresShell*>(
contentFrame->PresContext()->PresShell());
if (shell) {
break;
}
}
break;
}
+ default:
+ break;
}
// Check if we have an active EventStateManager which isn't the
// EventStateManager of the current PresContext.
// If that is the case, and mouse is over some ancestor document,
// forward event handling to the active document.
// This way content can get mouse events even when
// mouse is over the chrome or outside the window.
@@ -7879,28 +7883,32 @@ PresShell::HandleEventInternal(WidgetEve
}
break;
}
case NS_MOUSE_BUTTON_DOWN:
case NS_MOUSE_BUTTON_UP:
isHandlingUserInput = true;
break;
- case NS_DRAGDROP_DROP:
+ case NS_DRAGDROP_DROP: {
nsCOMPtr<nsIDragSession> session = nsContentUtils::GetDragSession();
if (session) {
bool onlyChromeDrop = false;
session->GetOnlyChromeDrop(&onlyChromeDrop);
if (onlyChromeDrop) {
aEvent->mFlags.mOnlyChromeDispatch = true;
}
}
break;
}
+ default:
+ break;
+ }
+
if (!mTouchManager.PreHandleEvent(aEvent, aStatus,
touchIsNew, isHandlingUserInput,
mCurrentEventContent)) {
return NS_OK;
}
}
if (aEvent->mMessage == NS_CONTEXTMENU) {
@@ -7982,16 +7990,18 @@ PresShell::HandleEventInternal(WidgetEve
}
case NS_MOUSE_BUTTON_UP:
// reset the capturing content now that the mouse button is up
SetCapturingContent(nullptr, 0);
break;
case NS_MOUSE_MOVE:
nsIPresShell::AllowMouseCapture(false);
break;
+ default:
+ break;
}
}
return rv;
}
void
nsIPresShell::DispatchGotOrLostPointerCaptureEvent(bool aIsGotCapture,
uint32_t aPointerId,
--- a/layout/generic/nsFrameSetFrame.cpp
+++ b/layout/generic/nsFrameSetFrame.cpp
@@ -655,16 +655,18 @@ nsresult nsHTMLFramesetFrame::HandleEven
case NS_MOUSE_MOVE:
MouseDrag(aPresContext, aEvent);
break;
case NS_MOUSE_BUTTON_UP:
if (aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
EndMouseDrag(aPresContext);
}
break;
+ default:
+ break;
}
*aEventStatus = nsEventStatus_eConsumeNoDefault;
} else {
*aEventStatus = nsEventStatus_eIgnore;
}
return NS_OK;
}
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -1715,17 +1715,18 @@ nsFrameSelection::TakeFocus(nsIContent*
{
int32_t offset;
nsINode *cellparent = GetCellParent(aNewFocus);
if (mCellParent && cellparent && cellparent != mCellParent) //switch to cell selection mode
{
#ifdef DEBUG_TABLE_SELECTION
printf(" * TakeFocus - moving into new cell\n");
#endif
- WidgetMouseEvent event(false, 0, nullptr, WidgetMouseEvent::eReal);
+ WidgetMouseEvent event(false, NS_EVENT_NULL, nullptr,
+ WidgetMouseEvent::eReal);
// Start selecting in the cell we were in before
nsINode* parent = ParentOffset(mCellParent, &offset);
if (parent)
HandleTableSelection(parent, offset,
nsISelectionPrivate::TABLESELECTION_CELL, &event);
// Find the parent of this new cell and extend selection to it
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -231,17 +231,17 @@ CSSAnimation::QueueEvents()
if (computedTiming.mPhase == ComputedTiming::AnimationPhase_Before) {
mPreviousPhaseOrIteration = PREVIOUS_PHASE_BEFORE;
} else if (computedTiming.mPhase == ComputedTiming::AnimationPhase_Active) {
mPreviousPhaseOrIteration = computedTiming.mCurrentIteration;
} else if (computedTiming.mPhase == ComputedTiming::AnimationPhase_After) {
mPreviousPhaseOrIteration = PREVIOUS_PHASE_AFTER;
}
- uint32_t message;
+ EventMessage message;
if (!wasActive && isActive) {
message = NS_ANIMATION_START;
} else if (wasActive && !isActive) {
message = NS_ANIMATION_END;
} else if (wasActive && isActive && !isSameIteration) {
message = NS_ANIMATION_ITERATION;
} else if (skippedActivePhase) {
--- a/layout/style/nsAnimationManager.h
+++ b/layout/style/nsAnimationManager.h
@@ -2,16 +2,17 @@
/* 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/. */
#ifndef nsAnimationManager_h_
#define nsAnimationManager_h_
#include "mozilla/Attributes.h"
#include "mozilla/ContentEvents.h"
+#include "mozilla/EventForwards.h"
#include "AnimationCommon.h"
#include "nsCSSPseudoElements.h"
#include "mozilla/dom/Animation.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/TimeStamp.h"
class nsIGlobalObject;
class nsStyleContext;
@@ -25,17 +26,17 @@ class Promise;
} /* namespace dom */
struct AnimationEventInfo {
nsRefPtr<mozilla::dom::Element> mElement;
mozilla::InternalAnimationEvent mEvent;
AnimationEventInfo(mozilla::dom::Element *aElement,
const nsSubstring& aAnimationName,
- uint32_t aMessage,
+ EventMessage aMessage,
const mozilla::StickyTimeDuration& aElapsedTime,
nsCSSPseudoElements::Type aPseudoType)
: mElement(aElement), mEvent(true, aMessage)
{
// XXX Looks like nobody initialize WidgetEvent::time
mEvent.animationName = aAnimationName;
mEvent.elapsedTime = aElapsedTime.ToSeconds();
mEvent.pseudoElement = AnimationCollection::PseudoTypeAsString(aPseudoType);
--- a/layout/xul/nsButtonBoxFrame.cpp
+++ b/layout/xul/nsButtonBoxFrame.cpp
@@ -168,16 +168,19 @@ nsButtonBoxFrame::HandleEvent(nsPresCont
case NS_MOUSE_CLICK: {
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
if (mouseEvent->IsLeftClickEvent()) {
MouseClicked(aPresContext, mouseEvent);
}
break;
}
+
+ default:
+ break;
}
return nsBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
}
void
nsButtonBoxFrame::Blurred()
{
--- a/layout/xul/nsImageBoxFrame.cpp
+++ b/layout/xul/nsImageBoxFrame.cpp
@@ -58,24 +58,24 @@
using namespace mozilla;
using namespace mozilla::gfx;
using namespace mozilla::image;
using namespace mozilla::layers;
class nsImageBoxFrameEvent : public nsRunnable
{
public:
- nsImageBoxFrameEvent(nsIContent *content, uint32_t message)
+ nsImageBoxFrameEvent(nsIContent *content, EventMessage message)
: mContent(content), mMessage(message) {}
NS_IMETHOD Run() override;
private:
nsCOMPtr<nsIContent> mContent;
- uint32_t mMessage;
+ EventMessage mMessage;
};
NS_IMETHODIMP
nsImageBoxFrameEvent::Run()
{
nsIPresShell *pres_shell = mContent->OwnerDoc()->GetShell();
if (!pres_shell) {
return NS_OK;
@@ -98,17 +98,17 @@ nsImageBoxFrameEvent::Run()
// onload handler once handled. This is needed since the image library
// can't decide if it wants to call it's observer methods
// synchronously or asynchronously. If an image is loaded from the
// cache the notifications come back synchronously, but if the image
// is loaded from the netswork the notifications come back
// asynchronously.
void
-FireImageDOMEvent(nsIContent* aContent, uint32_t aMessage)
+FireImageDOMEvent(nsIContent* aContent, EventMessage aMessage)
{
NS_ASSERTION(aMessage == NS_LOAD || aMessage == NS_LOAD_ERROR,
"invalid message");
nsCOMPtr<nsIRunnable> event = new nsImageBoxFrameEvent(aContent, aMessage);
if (NS_FAILED(NS_DispatchToCurrentThread(event)))
NS_WARNING("failed to dispatch image event");
}
--- a/layout/xul/nsResizerFrame.cpp
+++ b/layout/xul/nsResizerFrame.cpp
@@ -305,16 +305,19 @@ nsResizerFrame::HandleEvent(nsPresContex
if (menuPopupFrame)
break; // Don't restore original sizing for menupopup frames until
// we handle screen constraints here. (Bug 357725)
RestoreOriginalSize(contentToResize);
}
}
break;
+
+ default:
+ break;
}
if (!doDefault)
*aEventStatus = nsEventStatus_eConsumeNoDefault;
if (doDefault && weakFrame.IsAlive())
return nsTitleBarFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
--- a/layout/xul/nsScrollBoxFrame.cpp
+++ b/layout/xul/nsScrollBoxFrame.cpp
@@ -106,16 +106,19 @@ nsAutoRepeatBoxFrame::HandleEvent(nsPres
case NS_MOUSE_CLICK: {
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
if (mouseEvent->IsLeftClickEvent()) {
// skip button frame handling to prevent click handling
return nsBoxFrame::HandleEvent(aPresContext, mouseEvent, aEventStatus);
}
break;
}
+
+ default:
+ break;
}
return nsButtonBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
}
NS_IMETHODIMP
nsAutoRepeatBoxFrame::HandlePress(nsPresContext* aPresContext,
WidgetGUIEvent* aEvent,
--- a/layout/xul/nsScrollbarButtonFrame.cpp
+++ b/layout/xul/nsScrollbarButtonFrame.cpp
@@ -68,16 +68,18 @@ nsScrollbarButtonFrame::HandleEvent(nsPr
break;
case NS_MOUSE_MOVE: {
nsPoint cursor =
nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this);
nsRect frameRect(nsPoint(0, 0), GetSize());
mCursorOnThis = frameRect.Contains(cursor);
break;
}
+ default:
+ break;
}
return nsButtonBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
}
bool
nsScrollbarButtonFrame::HandleButtonPress(nsPresContext* aPresContext,
WidgetGUIEvent* aEvent,
--- a/layout/xul/nsSliderFrame.cpp
+++ b/layout/xul/nsSliderFrame.cpp
@@ -542,16 +542,19 @@ nsSliderFrame::HandleEvent(nsPresContext
case NS_TOUCH_END:
case NS_MOUSE_BUTTON_UP:
if (ShouldScrollForEvent(aEvent)) {
StopDrag();
//we MUST call nsFrame HandleEvent for mouse ups to maintain the selection state and capture state.
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
}
+
+ default:
+ break;
}
//return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
return NS_OK;
} else if (ShouldScrollToClickForEvent(aEvent)) {
nsPoint eventPoint;
if (!GetEventPoint(aEvent, eventPoint)) {
return NS_OK;
--- a/layout/xul/nsSplitterFrame.cpp
+++ b/layout/xul/nsSplitterFrame.cpp
@@ -386,23 +386,26 @@ nsSplitterFrame::HandleEvent(nsPresConte
return NS_OK;
}
nsWeakFrame weakFrame(this);
nsRefPtr<nsSplitterFrameInner> kungFuDeathGrip(mInner);
switch (aEvent->mMessage) {
case NS_MOUSE_MOVE:
mInner->MouseDrag(aPresContext, aEvent);
- break;
+ break;
case NS_MOUSE_BUTTON_UP:
if (aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
mInner->MouseUp(aPresContext, aEvent);
}
- break;
+ break;
+
+ default:
+ break;
}
NS_ENSURE_STATE(weakFrame.IsAlive());
return nsBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
}
void
nsSplitterFrameInner::MouseUp(nsPresContext* aPresContext,
--- a/layout/xul/nsTitleBarFrame.cpp
+++ b/layout/xul/nsTitleBarFrame.cpp
@@ -149,16 +149,19 @@ nsTitleBarFrame::HandleEvent(nsPresConte
case NS_MOUSE_CLICK: {
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
if (mouseEvent->IsLeftClickEvent()) {
MouseClicked(aPresContext, mouseEvent);
}
break;
}
+
+ default:
+ break;
}
if ( doDefault )
return nsBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
else
return NS_OK;
}
--- a/widget/BasicEvents.h
+++ b/widget/BasicEvents.h
@@ -166,17 +166,19 @@ struct EventFlags : public BaseEventFlag
/******************************************************************************
* mozilla::WidgetEvent
******************************************************************************/
class WidgetEvent
{
protected:
- WidgetEvent(bool aIsTrusted, uint32_t aMessage, EventClassID aEventClassID)
+ WidgetEvent(bool aIsTrusted,
+ EventMessage aMessage,
+ EventClassID aEventClassID)
: mClass(aEventClassID)
, mMessage(aMessage)
, refPoint(0, 0)
, lastRefPoint(0, 0)
, time(0)
, timeStamp(TimeStamp::Now())
, userType(nullptr)
{
@@ -188,17 +190,17 @@ protected:
}
WidgetEvent()
{
MOZ_COUNT_CTOR(WidgetEvent);
}
public:
- WidgetEvent(bool aIsTrusted, uint32_t aMessage)
+ WidgetEvent(bool aIsTrusted, EventMessage aMessage)
: mClass(eBasicEventClass)
, mMessage(aMessage)
, refPoint(0, 0)
, lastRefPoint(0, 0)
, time(0)
, timeStamp(TimeStamp::Now())
, userType(nullptr)
{
@@ -226,18 +228,17 @@ public:
"Duplicate() must be overridden by sub class");
WidgetEvent* result = new WidgetEvent(false, mMessage);
result->AssignEventData(*this, true);
result->mFlags = mFlags;
return result;
}
EventClassID mClass;
- // See GUI MESSAGES,
- uint32_t mMessage;
+ EventMessage mMessage;
// Relative to the widget of the event, or if there is no widget then it is
// in screen coordinates. Not modified by layout code.
LayoutDeviceIntPoint refPoint;
// The previous refPoint, if known, used to calculate mouse movement deltas.
LayoutDeviceIntPoint lastRefPoint;
// Elapsed time, in milliseconds, from a platform-specific zero time
// to the time the message was created
uint64_t time;
@@ -386,33 +387,33 @@ public:
/******************************************************************************
* mozilla::WidgetGUIEvent
******************************************************************************/
class WidgetGUIEvent : public WidgetEvent
{
protected:
- WidgetGUIEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget,
+ WidgetGUIEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget,
EventClassID aEventClassID)
: WidgetEvent(aIsTrusted, aMessage, aEventClassID)
, widget(aWidget)
{
}
WidgetGUIEvent()
{
}
public:
virtual WidgetGUIEvent* AsGUIEvent() override { return this; }
- WidgetGUIEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) :
- WidgetEvent(aIsTrusted, aMessage, eGUIEventClass),
- widget(aWidget)
+ WidgetGUIEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget)
+ : WidgetEvent(aIsTrusted, aMessage, eGUIEventClass)
+ , widget(aWidget)
{
}
virtual WidgetEvent* Duplicate() const override
{
MOZ_ASSERT(mClass == eGUIEventClass,
"Duplicate() must be overridden by sub class");
// Not copying widget, it is a weak reference.
@@ -550,31 +551,31 @@ typedef uint16_t Modifiers;
/******************************************************************************
* mozilla::WidgetInputEvent
******************************************************************************/
class WidgetInputEvent : public WidgetGUIEvent
{
protected:
- WidgetInputEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget,
+ WidgetInputEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget,
EventClassID aEventClassID)
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, aEventClassID)
, modifiers(0)
{
}
WidgetInputEvent()
{
}
public:
virtual WidgetInputEvent* AsInputEvent() override { return this; }
- WidgetInputEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget)
+ WidgetInputEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget)
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eInputEventClass)
, modifiers(0)
{
}
virtual WidgetEvent* Duplicate() const override
{
MOZ_ASSERT(mClass == eInputEventClass,
@@ -718,41 +719,41 @@ class InternalUIEvent : public WidgetGUI
{
protected:
InternalUIEvent()
: detail(0)
, mCausedByUntrustedEvent(false)
{
}
- InternalUIEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget,
+ InternalUIEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget,
EventClassID aEventClassID)
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, aEventClassID)
, detail(0)
, mCausedByUntrustedEvent(false)
{
}
- InternalUIEvent(bool aIsTrusted, uint32_t aMessage,
+ InternalUIEvent(bool aIsTrusted, EventMessage aMessage,
EventClassID aEventClassID)
: WidgetGUIEvent(aIsTrusted, aMessage, nullptr, aEventClassID)
, detail(0)
, mCausedByUntrustedEvent(false)
{
}
public:
virtual InternalUIEvent* AsUIEvent() override { return this; }
/**
* If the UIEvent is caused by another event (e.g., click event),
* aEventCausesThisEvent should be the event. If there is no such event,
* this should be nullptr.
*/
- InternalUIEvent(bool aIsTrusted, uint32_t aMessage,
+ InternalUIEvent(bool aIsTrusted, EventMessage aMessage,
const WidgetEvent* aEventCausesThisEvent)
: WidgetGUIEvent(aIsTrusted, aMessage, nullptr, eUIEventClass)
, detail(0)
, mCausedByUntrustedEvent(
aEventCausesThisEvent && !aEventCausesThisEvent->mFlags.mIsTrusted)
{
}
--- a/widget/ContentCache.cpp
+++ b/widget/ContentCache.cpp
@@ -19,17 +19,17 @@ using namespace widget;
static const char*
GetBoolName(bool aBool)
{
return aBool ? "true" : "false";
}
static const char*
-GetEventMessageName(uint32_t aMessage)
+GetEventMessageName(EventMessage aMessage)
{
switch (aMessage) {
case NS_COMPOSITION_START:
return "NS_COMPOSITION_START";
case NS_COMPOSITION_END:
return "NS_COMPOSITION_END";
case NS_COMPOSITION_UPDATE:
return "NS_COMPOSITION_UPDATE";
@@ -671,16 +671,18 @@ ContentCacheInParent::HandleQueryContent
"aEvent={ mMessage=NS_QUERY_EDITOR_RECT }, aWidget=0x%p)",
this, aWidget));
aEvent.mReply.mRect = mEditorRect;
MOZ_LOG(sContentCacheLog, LogLevel::Info,
("ContentCacheInParent: 0x%p HandleQueryContentEvent(), "
"Succeeded, aEvent={ mReply={ mRect=%s } }",
this, GetRectText(aEvent.mReply.mRect).get()));
break;
+ default:
+ break;
}
aEvent.mSucceeded = true;
return true;
}
bool
ContentCacheInParent::GetTextRect(uint32_t aOffset,
LayoutDeviceIntRect& aTextRect) const
@@ -910,17 +912,17 @@ ContentCacheInParent::OnSelectionEvent(
GetBoolName(aSelectionEvent.mUseNativeLineBreak), mPendingEventsNeedingAck,
GetBoolName(mIsComposing)));
mPendingEventsNeedingAck++;
}
void
ContentCacheInParent::OnEventNeedingAckHandled(nsIWidget* aWidget,
- uint32_t aMessage)
+ EventMessage aMessage)
{
// This is called when the child process receives WidgetCompositionEvent or
// WidgetSelectionEvent.
MOZ_LOG(sContentCacheLog, LogLevel::Info,
("ContentCacheInParent: 0x%p OnEventNeedingAckHandled(aWidget=0x%p, "
"aMessage=%s), mPendingEventsNeedingAck=%u",
this, aWidget, GetEventMessageName(aMessage), mPendingEventsNeedingAck));
--- a/widget/ContentCache.h
+++ b/widget/ContentCache.h
@@ -317,17 +317,17 @@ public:
/**
* OnEventNeedingAckHandled() should be called after the child process
* handles a sent event which needs acknowledging.
*
* WARNING: This may send notifications to IME. That might cause destroying
* TabParent or aWidget. Therefore, the caller must not destroy
* this instance during a call of this method.
*/
- void OnEventNeedingAckHandled(nsIWidget* aWidget, uint32_t aMessage);
+ void OnEventNeedingAckHandled(nsIWidget* aWidget, EventMessage aMessage);
/**
* RequestToCommitComposition() requests to commit or cancel composition to
* the widget. If it's handled synchronously, this returns the number of
* composition events after that.
*
* @param aWidget The widget to be requested to commit or cancel
* the composition.
--- a/widget/ContentEvents.h
+++ b/widget/ContentEvents.h
@@ -33,17 +33,17 @@ public:
enum orientType
{
vertical = 0,
horizontal = 1,
both = 2
};
- InternalScrollPortEvent(bool aIsTrusted, uint32_t aMessage,
+ InternalScrollPortEvent(bool aIsTrusted, EventMessage aMessage,
nsIWidget* aWidget)
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eScrollPortEventClass)
, orient(vertical)
{
}
virtual WidgetEvent* Duplicate() const override
{
@@ -75,17 +75,17 @@ public:
class InternalScrollAreaEvent : public WidgetGUIEvent
{
public:
virtual InternalScrollAreaEvent* AsScrollAreaEvent() override
{
return this;
}
- InternalScrollAreaEvent(bool aIsTrusted, uint32_t aMessage,
+ InternalScrollAreaEvent(bool aIsTrusted, EventMessage aMessage,
nsIWidget* aWidget)
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eScrollAreaEventClass)
{
}
virtual WidgetEvent* Duplicate() const override
{
MOZ_ASSERT(mClass == eScrollAreaEventClass,
@@ -116,17 +116,17 @@ public:
* originator is a weak pointer (does not hold a strong reference).
******************************************************************************/
class InternalFormEvent : public WidgetEvent
{
public:
virtual InternalFormEvent* AsFormEvent() override { return this; }
- InternalFormEvent(bool aIsTrusted, uint32_t aMessage)
+ InternalFormEvent(bool aIsTrusted, EventMessage aMessage)
: WidgetEvent(aIsTrusted, aMessage, eFormEventClass)
, originator(nullptr)
{
}
virtual WidgetEvent* Duplicate() const override
{
MOZ_ASSERT(mClass == eFormEventClass,
@@ -154,17 +154,17 @@ public:
class InternalClipboardEvent : public WidgetEvent
{
public:
virtual InternalClipboardEvent* AsClipboardEvent() override
{
return this;
}
- InternalClipboardEvent(bool aIsTrusted, uint32_t aMessage)
+ InternalClipboardEvent(bool aIsTrusted, EventMessage aMessage)
: WidgetEvent(aIsTrusted, aMessage, eClipboardEventClass)
{
}
virtual WidgetEvent* Duplicate() const override
{
MOZ_ASSERT(mClass == eClipboardEventClass,
"Duplicate() must be overridden by sub class");
@@ -190,17 +190,17 @@ public:
* mozilla::InternalFocusEvent
******************************************************************************/
class InternalFocusEvent : public InternalUIEvent
{
public:
virtual InternalFocusEvent* AsFocusEvent() override { return this; }
- InternalFocusEvent(bool aIsTrusted, uint32_t aMessage)
+ InternalFocusEvent(bool aIsTrusted, EventMessage aMessage)
: InternalUIEvent(aIsTrusted, aMessage, eFocusEventClass)
, fromRaise(false)
, isRefocus(false)
{
}
virtual WidgetEvent* Duplicate() const override
{
@@ -235,17 +235,17 @@ public:
class InternalTransitionEvent : public WidgetEvent
{
public:
virtual InternalTransitionEvent* AsTransitionEvent() override
{
return this;
}
- InternalTransitionEvent(bool aIsTrusted, uint32_t aMessage)
+ InternalTransitionEvent(bool aIsTrusted, EventMessage aMessage)
: WidgetEvent(aIsTrusted, aMessage, eTransitionEventClass)
, elapsedTime(0.0)
{
mFlags.mCancelable = false;
}
virtual WidgetEvent* Duplicate() const override
{
@@ -280,17 +280,17 @@ public:
class InternalAnimationEvent : public WidgetEvent
{
public:
virtual InternalAnimationEvent* AsAnimationEvent() override
{
return this;
}
- InternalAnimationEvent(bool aIsTrusted, uint32_t aMessage)
+ InternalAnimationEvent(bool aIsTrusted, EventMessage aMessage)
: WidgetEvent(aIsTrusted, aMessage, eAnimationEventClass)
, elapsedTime(0.0)
{
mFlags.mCancelable = false;
}
virtual WidgetEvent* Duplicate() const override
{
@@ -322,17 +322,17 @@ public:
* mozilla::InternalSVGZoomEvent
******************************************************************************/
class InternalSVGZoomEvent : public WidgetGUIEvent
{
public:
virtual InternalSVGZoomEvent* AsSVGZoomEvent() override { return this; }
- InternalSVGZoomEvent(bool aIsTrusted, uint32_t aMessage)
+ InternalSVGZoomEvent(bool aIsTrusted, EventMessage aMessage)
: WidgetGUIEvent(aIsTrusted, aMessage, nullptr, eSVGZoomEventClass)
{
mFlags.mCancelable = false;
}
virtual WidgetEvent* Duplicate() const override
{
MOZ_ASSERT(mClass == eSVGZoomEventClass,
@@ -358,17 +358,17 @@ public:
class InternalSMILTimeEvent : public InternalUIEvent
{
public:
virtual InternalSMILTimeEvent* AsSMILTimeEvent() override
{
return this;
}
- InternalSMILTimeEvent(bool aIsTrusted, uint32_t aMessage)
+ InternalSMILTimeEvent(bool aIsTrusted, EventMessage aMessage)
: InternalUIEvent(aIsTrusted, aMessage, eSMILTimeEventClass)
{
mFlags.mBubbles = false;
mFlags.mCancelable = false;
}
virtual WidgetEvent* Duplicate() const override
{
--- a/widget/EventForwards.h
+++ b/widget/EventForwards.h
@@ -23,35 +23,37 @@ enum nsEventStatus
// The event is consumed, don't do default processing
nsEventStatus_eConsumeNoDefault,
// The event is consumed, but do default processing
nsEventStatus_eConsumeDoDefault,
// Value is not for use, only for serialization
nsEventStatus_eSentinel
};
+namespace mozilla {
+
/**
* Event messages
*/
-enum
+typedef uint16_t EventMessageType;
+
+enum EventMessage : EventMessageType
{
#define NS_EVENT_MESSAGE(aMessage, aValue) aMessage = aValue,
#include "mozilla/EventMessageList.h"
#undef NS_EVENT_MESSAGE
// For preventing bustage due to "," after the last item.
eEventMessage_MaxValue
};
-namespace mozilla {
-
/**
* Event class IDs
*/
typedef uint8_t EventClassIDType;
enum EventClassID : EventClassIDType
{
--- a/widget/IMEData.h
+++ b/widget/IMEData.h
@@ -413,17 +413,17 @@ struct IMENotification final
case NOTIFY_IME_OF_SELECTION_CHANGE:
mSelectionChangeData.mString = new nsString();
mSelectionChangeData.Clear();
break;
case NOTIFY_IME_OF_TEXT_CHANGE:
mTextChangeData.Clear();
break;
case NOTIFY_IME_OF_MOUSE_BUTTON_EVENT:
- mMouseButtonEventData.mEventMessage = 0;
+ mMouseButtonEventData.mEventMessage = NS_EVENT_NULL;
mMouseButtonEventData.mOffset = UINT32_MAX;
mMouseButtonEventData.mCursorPos.Set(nsIntPoint(0, 0));
mMouseButtonEventData.mCharRect.Set(nsIntRect(0, 0, 0, 0));
mMouseButtonEventData.mButton = -1;
mMouseButtonEventData.mButtons = 0;
mMouseButtonEventData.mModifiers = 0;
default:
break;
@@ -726,18 +726,18 @@ struct IMENotification final
mRemovedEndOffset = aRemovedEndOffset;
mAddedEndOffset = aAddedEndOffset;
mCausedByComposition = aCausedByComposition;
}
};
struct MouseButtonEventData
{
- // The value of WidgetEvent::message
- uint32_t mEventMessage;
+ // The value of WidgetEvent::mMessage
+ EventMessage mEventMessage;
// Character offset from the start of the focused editor under the cursor
uint32_t mOffset;
// Cursor position in pixels relative to the widget
Point mCursorPos;
// Character rect in pixels under the cursor relative to the widget
Rect mCharRect;
// The value of WidgetMouseEventBase::button and buttons
int16_t mButton;
--- a/widget/InputData.cpp
+++ b/widget/InputData.cpp
@@ -76,37 +76,37 @@ MultiTouchInput::MultiTouchInput(const W
}
WidgetTouchEvent
MultiTouchInput::ToWidgetTouchEvent(nsIWidget* aWidget) const
{
MOZ_ASSERT(NS_IsMainThread(),
"Can only convert To WidgetTouchEvent on main thread");
- uint32_t touchType = NS_EVENT_NULL;
+ EventMessage touchEventMessage = NS_EVENT_NULL;
switch (mType) {
case MULTITOUCH_START:
- touchType = NS_TOUCH_START;
+ touchEventMessage = NS_TOUCH_START;
break;
case MULTITOUCH_MOVE:
- touchType = NS_TOUCH_MOVE;
+ touchEventMessage = NS_TOUCH_MOVE;
break;
case MULTITOUCH_END:
- touchType = NS_TOUCH_END;
+ touchEventMessage = NS_TOUCH_END;
break;
case MULTITOUCH_CANCEL:
- touchType = NS_TOUCH_CANCEL;
+ touchEventMessage = NS_TOUCH_CANCEL;
break;
default:
MOZ_ASSERT_UNREACHABLE("Did not assign a type to WidgetTouchEvent in MultiTouchInput");
break;
}
- WidgetTouchEvent event(true, touchType, aWidget);
- if (touchType == NS_EVENT_NULL) {
+ WidgetTouchEvent event(true, touchEventMessage, aWidget);
+ if (touchEventMessage == NS_EVENT_NULL) {
return event;
}
event.modifiers = this->modifiers;
event.time = this->mTime;
event.timeStamp = this->mTimeStamp;
for (size_t i = 0; i < mTouches.Length(); i++) {
@@ -117,46 +117,46 @@ MultiTouchInput::ToWidgetTouchEvent(nsIW
}
WidgetMouseEvent
MultiTouchInput::ToWidgetMouseEvent(nsIWidget* aWidget) const
{
MOZ_ASSERT(NS_IsMainThread(),
"Can only convert To WidgetMouseEvent on main thread");
- uint32_t mouseEventType = NS_EVENT_NULL;
+ EventMessage mouseEventMessage = NS_EVENT_NULL;
switch (mType) {
case MultiTouchInput::MULTITOUCH_START:
- mouseEventType = NS_MOUSE_BUTTON_DOWN;
+ mouseEventMessage = NS_MOUSE_BUTTON_DOWN;
break;
case MultiTouchInput::MULTITOUCH_MOVE:
- mouseEventType = NS_MOUSE_MOVE;
+ mouseEventMessage = NS_MOUSE_MOVE;
break;
case MultiTouchInput::MULTITOUCH_CANCEL:
case MultiTouchInput::MULTITOUCH_END:
- mouseEventType = NS_MOUSE_BUTTON_UP;
+ mouseEventMessage = NS_MOUSE_BUTTON_UP;
break;
default:
MOZ_ASSERT_UNREACHABLE("Did not assign a type to WidgetMouseEvent");
break;
}
- WidgetMouseEvent event(true, mouseEventType, aWidget,
+ WidgetMouseEvent event(true, mouseEventMessage, aWidget,
WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal);
const SingleTouchData& firstTouch = mTouches[0];
event.refPoint.x = firstTouch.mScreenPoint.x;
event.refPoint.y = firstTouch.mScreenPoint.y;
event.time = mTime;
event.button = WidgetMouseEvent::eLeftButton;
event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
event.modifiers = modifiers;
- if (mouseEventType != NS_MOUSE_MOVE) {
+ if (mouseEventMessage != NS_MOUSE_MOVE) {
event.clickCount = 1;
}
return event;
}
int32_t
MultiTouchInput::IndexOfTouch(int32_t aTouchIdentifier)
--- a/widget/MiscEvents.h
+++ b/widget/MiscEvents.h
@@ -22,17 +22,17 @@ namespace mozilla {
class WidgetContentCommandEvent : public WidgetGUIEvent
{
public:
virtual WidgetContentCommandEvent* AsContentCommandEvent() override
{
return this;
}
- WidgetContentCommandEvent(bool aIsTrusted, uint32_t aMessage,
+ WidgetContentCommandEvent(bool aIsTrusted, EventMessage aMessage,
nsIWidget* aWidget,
bool aOnlyEnabledCheck = false)
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eContentCommandEventClass)
, mOnlyEnabledCheck(aOnlyEnabledCheck)
, mSucceeded(false)
, mIsEnabled(false)
{
}
@@ -140,17 +140,17 @@ public:
* This event delivers only a native event to focused plugin.
******************************************************************************/
class WidgetPluginEvent : public WidgetGUIEvent
{
public:
virtual WidgetPluginEvent* AsPluginEvent() override { return this; }
- WidgetPluginEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget)
+ WidgetPluginEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget)
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, ePluginEventClass)
, retargetToFocusedDocument(false)
{
}
virtual WidgetEvent* Duplicate() const override
{
// NOTE: PluginEvent has to be dispatched to nsIFrame::HandleEvent().
--- a/widget/MouseEvents.h
+++ b/widget/MouseEvents.h
@@ -72,18 +72,18 @@ private:
friend class dom::PBrowserParent;
friend class dom::PBrowserChild;
protected:
WidgetMouseEventBase()
{
}
- WidgetMouseEventBase(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget,
- EventClassID aEventClassID)
+ WidgetMouseEventBase(bool aIsTrusted, EventMessage aMessage,
+ nsIWidget* aWidget, EventClassID aEventClassID)
: WidgetInputEvent(aIsTrusted, aMessage, aWidget, aEventClassID)
, button(0)
, buttons(0)
, pressure(0)
, hitCluster(false)
, inputSource(nsIDOMMouseEvent::MOZ_SOURCE_MOUSE)
{
}
@@ -188,17 +188,17 @@ public:
eTopLevel
};
protected:
WidgetMouseEvent()
{
}
- WidgetMouseEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget,
+ WidgetMouseEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget,
EventClassID aEventClassID, reasonType aReason)
: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, aEventClassID)
, acceptActivation(false)
, ignoreRootScrollFrame(false)
, reason(aReason)
, context(eNormal)
, exit(eChild)
, clickCount(0)
@@ -212,17 +212,17 @@ protected:
default:
break;
}
}
public:
virtual WidgetMouseEvent* AsMouseEvent() override { return this; }
- WidgetMouseEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget,
+ WidgetMouseEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget,
reasonType aReason, contextType aContext = eNormal) :
WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, eMouseEventClass),
acceptActivation(false), ignoreRootScrollFrame(false),
reason(aReason), context(aContext), exit(eChild), clickCount(0)
{
switch (aMessage) {
case NS_MOUSEENTER:
case NS_MOUSELEAVE:
@@ -311,17 +311,17 @@ private:
friend class mozilla::dom::PBrowserChild;
protected:
WidgetDragEvent()
{
}
public:
virtual WidgetDragEvent* AsDragEvent() override { return this; }
- WidgetDragEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget)
+ WidgetDragEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget)
: WidgetMouseEvent(aIsTrusted, aMessage, aWidget, eDragEventClass, eReal)
, userCancelled(false)
, mDefaultPreventedOnContent(false)
{
mFlags.mCancelable =
(aMessage != NS_DRAGDROP_EXIT &&
aMessage != NS_DRAGDROP_LEAVE &&
aMessage != NS_DRAGDROP_END);
@@ -374,17 +374,17 @@ private:
}
public:
virtual WidgetMouseScrollEvent* AsMouseScrollEvent() override
{
return this;
}
- WidgetMouseScrollEvent(bool aIsTrusted, uint32_t aMessage,
+ WidgetMouseScrollEvent(bool aIsTrusted, EventMessage aMessage,
nsIWidget* aWidget)
: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget,
eMouseScrollEventClass)
, delta(0)
, isHorizontal(false)
{
}
@@ -434,17 +434,17 @@ private:
WidgetWheelEvent()
{
}
public:
virtual WidgetWheelEvent* AsWheelEvent() override { return this; }
- WidgetWheelEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget)
+ WidgetWheelEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget)
: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, eWheelEventClass)
, deltaX(0.0)
, deltaY(0.0)
, deltaZ(0.0)
, deltaMode(nsIDOMWheelEvent::DOM_DELTA_PIXEL)
, customizedByUserPrefs(false)
, isMomentum(false)
, mIsNoLineOrPageDelta(false)
@@ -582,17 +582,17 @@ class WidgetPointerEvent : public Widget
WidgetPointerEvent()
{
}
public:
virtual WidgetPointerEvent* AsPointerEvent() override { return this; }
- WidgetPointerEvent(bool aIsTrusted, uint32_t aMsg, nsIWidget* w)
+ WidgetPointerEvent(bool aIsTrusted, EventMessage aMsg, nsIWidget* w)
: WidgetMouseEvent(aIsTrusted, aMsg, w, ePointerEventClass, eReal)
, width(0)
, height(0)
, isPrimary(true)
{
UpdateFlags();
}
--- a/widget/TextEventDispatcher.cpp
+++ b/widget/TextEventDispatcher.cpp
@@ -263,18 +263,18 @@ TextEventDispatcher::CommitComposition(n
}
if (aStatus == nsEventStatus_eConsumeNoDefault) {
return NS_OK;
}
// End current composition and make this free for other IMEs.
mIsComposing = false;
- uint32_t message = aCommitString ? NS_COMPOSITION_COMMIT :
- NS_COMPOSITION_COMMIT_AS_IS;
+ EventMessage message = aCommitString ? NS_COMPOSITION_COMMIT :
+ NS_COMPOSITION_COMMIT_AS_IS;
WidgetCompositionEvent compositionCommitEvent(true, message, widget);
InitEvent(compositionCommitEvent);
if (message == NS_COMPOSITION_COMMIT) {
compositionCommitEvent.mData = *aCommitString;
}
rv = DispatchEvent(widget, compositionCommitEvent, aStatus);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@@ -297,28 +297,28 @@ TextEventDispatcher::NotifyIME(const IME
if (rv == NS_ERROR_NOT_AVAILABLE) {
return NS_ERROR_NOT_IMPLEMENTED;
}
return rv;
}
bool
TextEventDispatcher::DispatchKeyboardEvent(
- uint32_t aMessage,
+ EventMessage aMessage,
const WidgetKeyboardEvent& aKeyboardEvent,
nsEventStatus& aStatus,
DispatchTo aDispatchTo)
{
return DispatchKeyboardEventInternal(aMessage, aKeyboardEvent, aStatus,
aDispatchTo);
}
bool
TextEventDispatcher::DispatchKeyboardEventInternal(
- uint32_t aMessage,
+ EventMessage aMessage,
const WidgetKeyboardEvent& aKeyboardEvent,
nsEventStatus& aStatus,
DispatchTo aDispatchTo,
uint32_t aIndexOfKeypress)
{
MOZ_ASSERT(aMessage == NS_KEY_DOWN || aMessage == NS_KEY_UP ||
aMessage == NS_KEY_PRESS, "Invalid aMessage value");
nsresult rv = GetState();
--- a/widget/TextEventDispatcher.h
+++ b/widget/TextEventDispatcher.h
@@ -210,17 +210,17 @@ public:
* @param aStatus If dispatching event should be marked as consumed,
* set nsEventStatus_eConsumeNoDefault. Otherwise,
* set nsEventStatus_eIgnore. After dispatching
* a event and it's consumed this returns
* nsEventStatus_eConsumeNoDefault.
* @param aDispatchTo See comments of DispatchTo.
* @return true if an event is dispatched. Otherwise, false.
*/
- bool DispatchKeyboardEvent(uint32_t aMessage,
+ bool DispatchKeyboardEvent(EventMessage aMessage,
const WidgetKeyboardEvent& aKeyboardEvent,
nsEventStatus& aStatus,
DispatchTo aDispatchTo = eDispatchToParentProcess);
/**
* MaybeDispatchKeypressEvents() maybe dispatches a keypress event which is
* generated from aKeydownEvent.
*
@@ -349,17 +349,17 @@ private:
* aKeyboard.mKeyNameIndex isn't
* KEY_NAME_INDEX_USE_STRING. Otherwise, i.e.,
* when an NS_KEY_PRESS event causes inputting
* text, this must be between 0 and
* mKeyValue.Length() - 1 since keypress events
* sending only one character per event.
* @return true if an event is dispatched. Otherwise, false.
*/
- bool DispatchKeyboardEventInternal(uint32_t aMessage,
+ bool DispatchKeyboardEventInternal(EventMessage aMessage,
const WidgetKeyboardEvent& aKeyboardEvent,
nsEventStatus& aStatus,
DispatchTo aDispatchTo =
eDispatchToParentProcess,
uint32_t aIndexOfKeypress = 0);
};
} // namespace widget
--- a/widget/TextEvents.h
+++ b/widget/TextEvents.h
@@ -82,17 +82,18 @@ private:
protected:
WidgetKeyboardEvent()
{
}
public:
virtual WidgetKeyboardEvent* AsKeyboardEvent() override { return this; }
- WidgetKeyboardEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget,
+ WidgetKeyboardEvent(bool aIsTrusted, EventMessage aMessage,
+ nsIWidget* aWidget,
EventClassID aEventClassID = eKeyboardEventClass)
: WidgetInputEvent(aIsTrusted, aMessage, aWidget, aEventClassID)
, keyCode(0)
, charCode(0)
, location(nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD)
, isChar(false)
, mIsRepeat(false)
, mIsComposing(false)
@@ -301,19 +302,20 @@ public:
// default actions of keydown/keyup event is prevented.
Nullable<bool> mEmbeddedCancelled;
virtual InternalBeforeAfterKeyboardEvent* AsBeforeAfterKeyboardEvent() override
{
return this;
}
- InternalBeforeAfterKeyboardEvent(bool aIsTrusted, uint32_t aMessage,
+ InternalBeforeAfterKeyboardEvent(bool aIsTrusted, EventMessage aMessage,
nsIWidget* aWidget)
- : WidgetKeyboardEvent(aIsTrusted, aMessage, aWidget, eBeforeAfterKeyboardEventClass)
+ : WidgetKeyboardEvent(aIsTrusted, aMessage, aWidget,
+ eBeforeAfterKeyboardEventClass)
{
}
virtual WidgetEvent* Duplicate() const override
{
MOZ_ASSERT(mClass == eBeforeAfterKeyboardEventClass,
"Duplicate() must be overridden by sub class");
// Not copying widget, it is a weak reference.
@@ -355,17 +357,17 @@ private:
}
public:
virtual WidgetCompositionEvent* AsCompositionEvent() override
{
return this;
}
- WidgetCompositionEvent(bool aIsTrusted, uint32_t aMessage,
+ WidgetCompositionEvent(bool aIsTrusted, EventMessage aMessage,
nsIWidget* aWidget)
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eCompositionEventClass)
{
// XXX compositionstart is cancelable in draft of DOM3 Events.
// However, it doesn't make sense for us, we cannot cancel composition
// when we send compositionstart event.
mFlags.mCancelable = false;
}
@@ -455,17 +457,17 @@ private:
}
public:
virtual WidgetQueryContentEvent* AsQueryContentEvent() override
{
return this;
}
- WidgetQueryContentEvent(bool aIsTrusted, uint32_t aMessage,
+ WidgetQueryContentEvent(bool aIsTrusted, EventMessage aMessage,
nsIWidget* aWidget)
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eQueryContentEventClass)
, mSucceeded(false)
, mUseNativeLineBreak(true)
, mWithFontRanges(false)
{
}
@@ -631,17 +633,18 @@ private:
}
public:
virtual WidgetSelectionEvent* AsSelectionEvent() override
{
return this;
}
- WidgetSelectionEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget)
+ WidgetSelectionEvent(bool aIsTrusted, EventMessage aMessage,
+ nsIWidget* aWidget)
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eSelectionEventClass)
, mOffset(0)
, mLength(0)
, mReversed(false)
, mExpandToClusterBoundary(true)
, mSucceeded(false)
, mUseNativeLineBreak(true)
{
@@ -683,17 +686,17 @@ private:
}
public:
virtual InternalEditorInputEvent* AsEditorInputEvent() override
{
return this;
}
- InternalEditorInputEvent(bool aIsTrusted, uint32_t aMessage,
+ InternalEditorInputEvent(bool aIsTrusted, EventMessage aMessage,
nsIWidget* aWidget)
: InternalUIEvent(aIsTrusted, aMessage, aWidget, eEditorInputEventClass)
, mIsComposing(false)
{
if (!aIsTrusted) {
mFlags.mBubbles = false;
mFlags.mCancelable = false;
return;
--- a/widget/TouchEvents.h
+++ b/widget/TouchEvents.h
@@ -31,17 +31,17 @@ namespace mozilla {
class WidgetGestureNotifyEvent : public WidgetGUIEvent
{
public:
virtual WidgetGestureNotifyEvent* AsGestureNotifyEvent() override
{
return this;
}
- WidgetGestureNotifyEvent(bool aIsTrusted, uint32_t aMessage,
+ WidgetGestureNotifyEvent(bool aIsTrusted, EventMessage aMessage,
nsIWidget *aWidget)
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eGestureNotifyEventClass)
, panDirection(ePanNone)
, displayPanFeedback(false)
{
}
virtual WidgetEvent* Duplicate() const override
@@ -89,17 +89,17 @@ public:
class WidgetSimpleGestureEvent : public WidgetMouseEventBase
{
public:
virtual WidgetSimpleGestureEvent* AsSimpleGestureEvent() override
{
return this;
}
- WidgetSimpleGestureEvent(bool aIsTrusted, uint32_t aMessage,
+ WidgetSimpleGestureEvent(bool aIsTrusted, EventMessage aMessage,
nsIWidget* aWidget)
: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget,
eSimpleGestureEventClass)
, allowedDirections(0)
, direction(0)
, delta(0.0)
, clickCount(0)
{
@@ -172,17 +172,17 @@ public:
modifiers = aOther.modifiers;
time = aOther.time;
timeStamp = aOther.timeStamp;
touches.AppendElements(aOther.touches);
mFlags.mCancelable = mMessage != NS_TOUCH_CANCEL;
MOZ_COUNT_CTOR(WidgetTouchEvent);
}
- WidgetTouchEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget)
+ WidgetTouchEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget)
: WidgetInputEvent(aIsTrusted, aMessage, aWidget, eTouchEventClass)
{
MOZ_COUNT_CTOR(WidgetTouchEvent);
mFlags.mCancelable = mMessage != NS_TOUCH_CANCEL;
}
virtual ~WidgetTouchEvent()
{
--- a/widget/android/AndroidJavaWrappers.cpp
+++ b/widget/android/AndroidJavaWrappers.cpp
@@ -684,17 +684,17 @@ AndroidGeckoEvent::ApzEventStatus()
WidgetTouchEvent
AndroidGeckoEvent::MakeTouchEvent(nsIWidget* widget)
{
if (Type() == APZ_INPUT_EVENT) {
return mApzInput.ToWidgetTouchEvent(widget);
}
- int type = NS_EVENT_NULL;
+ EventMessage type = NS_EVENT_NULL;
int startIndex = 0;
int endIndex = Count();
switch (Action()) {
case AndroidMotionEvent::ACTION_HOVER_ENTER: {
if (ToolTypes()[0] == AndroidMotionEvent::TOOL_TYPE_MOUSE) {
break;
}
@@ -825,17 +825,17 @@ AndroidGeckoEvent::MakeMultiTouchInput(n
}
return event;
}
WidgetMouseEvent
AndroidGeckoEvent::MakeMouseEvent(nsIWidget* widget)
{
- uint32_t msg = NS_EVENT_NULL;
+ EventMessage msg = NS_EVENT_NULL;
if (Points().Length() > 0) {
switch (Action()) {
case AndroidMotionEvent::ACTION_HOVER_MOVE:
msg = NS_MOUSE_MOVE;
break;
case AndroidMotionEvent::ACTION_HOVER_ENTER:
msg = NS_MOUSE_ENTER_WIDGET;
break;
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1113,17 +1113,17 @@ bool nsWindow::OnMultitouchEvent(Android
}
void
nsWindow::OnNativeGestureEvent(AndroidGeckoEvent *ae)
{
LayoutDeviceIntPoint pt(ae->Points()[0].x,
ae->Points()[0].y);
double delta = ae->X();
- int msg = 0;
+ EventMessage msg = NS_EVENT_NULL;
switch (ae->Action()) {
case AndroidMotionEvent::ACTION_MAGNIFY_START:
msg = NS_SIMPLE_GESTURE_MAGNIFY_START;
mStartDist = delta;
mLastDist = delta;
break;
case AndroidMotionEvent::ACTION_MAGNIFY:
@@ -1572,17 +1572,17 @@ nsWindow::HandleSpecialKey(AndroidGeckoE
}
}
void
nsWindow::OnKeyEvent(AndroidGeckoEvent *ae)
{
nsRefPtr<nsWindow> kungFuDeathGrip(this);
RemoveIMEComposition();
- uint32_t msg;
+ EventMessage msg;
switch (ae->Action()) {
case AKEY_EVENT_ACTION_DOWN:
msg = NS_KEY_DOWN;
break;
case AKEY_EVENT_ACTION_UP:
msg = NS_KEY_UP;
break;
case AKEY_EVENT_ACTION_MULTIPLE:
--- a/widget/cocoa/TextInputHandler.mm
+++ b/widget/cocoa/TextInputHandler.mm
@@ -2001,17 +2001,17 @@ TextInputHandler::DispatchKeyEventForFla
this, aNativeEvent, GetNativeKeyEventType(aNativeEvent),
GetKeyNameForNativeKeyCode([aNativeEvent keyCode]), [aNativeEvent keyCode],
TrueOrFalse(aDispatchKeyDown), TrueOrFalse(IsIMEComposing())));
if ([aNativeEvent type] != NSFlagsChanged || IsIMEComposing()) {
return;
}
- uint32_t message = aDispatchKeyDown ? NS_KEY_DOWN : NS_KEY_UP;
+ EventMessage message = aDispatchKeyDown ? NS_KEY_DOWN : NS_KEY_UP;
// Fire a key event.
WidgetKeyboardEvent keyEvent(true, message, mWidget);
InitKeyEvent(aNativeEvent, keyEvent);
// Attach a plugin event, in case keyEvent gets dispatched to a plugin. Only
// one field is needed -- the type. The other fields can be constructed as
// the need arises. But Gecko doesn't have anything equivalent to the
@@ -2735,17 +2735,17 @@ IMEInputHandler::DispatchCompositionComm
TrueOrFalse(Destroyed())));
if (NS_WARN_IF(Destroyed())) {
return false;
}
nsRefPtr<IMEInputHandler> kungFuDeathGrip(this);
- uint32_t message =
+ EventMessage message =
aCommitString ? NS_COMPOSITION_COMMIT : NS_COMPOSITION_COMMIT_AS_IS;
WidgetCompositionEvent compositionCommitEvent(true, message, mWidget);
compositionCommitEvent.time = PR_IntervalNow();
if (aCommitString) {
compositionCommitEvent.mData = *aCommitString;
}
return DispatchEvent(compositionCommitEvent);
}
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -257,17 +257,17 @@ typedef NSInteger NSEventGestureAxis;
// these are sent to the first responder when the window key status changes
- (void)viewsWindowDidBecomeKey;
- (void)viewsWindowDidResignKey;
// Stop NSView hierarchy being changed during [ChildView drawRect:]
- (void)delayedTearDown;
-- (void)sendFocusEvent:(uint32_t)eventType;
+- (void)sendFocusEvent:(mozilla::EventMessage)eventMessage;
- (void)handleMouseMoved:(NSEvent*)aEvent;
- (void)sendMouseEnterOrExitEvent:(NSEvent*)aEvent
enter:(BOOL)aEnter
type:(mozilla::WidgetMouseEvent::exitType)aType;
- (void)updateGLContext;
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -3281,23 +3281,23 @@ NSEvent* gLastDragMouseDownEvent = nil;
return YES;
}
- (BOOL)isOpaque
{
return [[self window] isOpaque];
}
-- (void)sendFocusEvent:(uint32_t)eventType
+- (void)sendFocusEvent:(EventMessage)eventMessage
{
if (!mGeckoChild)
return;
nsEventStatus status = nsEventStatus_eIgnore;
- WidgetGUIEvent focusGuiEvent(true, eventType, mGeckoChild);
+ WidgetGUIEvent focusGuiEvent(true, eventMessage, mGeckoChild);
focusGuiEvent.time = PR_IntervalNow();
mGeckoChild->DispatchEvent(&focusGuiEvent, status);
}
// We accept key and mouse events, so don't keep passing them up the chain. Allow
// this to be a 'focused' widget for event dispatch.
- (BOOL)acceptsFirstResponder
{
@@ -3986,17 +3986,17 @@ NSEvent* gLastDragMouseDownEvent = nil;
[self smartMagnifyWithEvent: anEvent];
return;
}
nsAutoRetainCocoaObject kungFuDeathGrip(self);
float deltaZ = [anEvent deltaZ];
- uint32_t msg;
+ EventMessage msg;
switch (mGestureState) {
case eGestureState_StartGesture:
msg = NS_SIMPLE_GESTURE_MAGNIFY_START;
mGestureState = eGestureState_MagnifyGesture;
break;
case eGestureState_MagnifyGesture:
msg = NS_SIMPLE_GESTURE_MAGNIFY_UPDATE;
@@ -4053,17 +4053,17 @@ NSEvent* gLastDragMouseDownEvent = nil;
if (!anEvent || !mGeckoChild)
return;
nsAutoRetainCocoaObject kungFuDeathGrip(self);
float rotation = [anEvent rotation];
- uint32_t msg;
+ EventMessage msg;
switch (mGestureState) {
case eGestureState_StartGesture:
msg = NS_SIMPLE_GESTURE_ROTATE_START;
mGestureState = eGestureState_RotateGesture;
break;
case eGestureState_RotateGesture:
msg = NS_SIMPLE_GESTURE_ROTATE_UPDATE;
@@ -4167,17 +4167,17 @@ NSEvent* gLastDragMouseDownEvent = nil;
return nsCocoaFeatures::OnLionOrLater() &&
!nsCocoaFeatures::OnMountainLionOrLater() &&
[anEvent type] == NSEventTypeGesture &&
[anEvent subtype] == 0x16;
}
#ifdef __LP64__
- (bool)sendSwipeEvent:(NSEvent*)aEvent
- withKind:(uint32_t)aMsg
+ withKind:(EventMessage)aMsg
allowedDirections:(uint32_t*)aAllowedDirections
direction:(uint32_t)aDirection
delta:(double)aDelta
{
if (!mGeckoChild)
return false;
WidgetSimpleGestureEvent geckoEvent(true, aMsg, mGeckoChild);
@@ -4568,17 +4568,17 @@ NSEvent* gLastDragMouseDownEvent = nil;
type:(WidgetMouseEvent::exitType)aType
{
if (!mGeckoChild)
return;
NSPoint windowEventLocation = nsCocoaUtils::EventLocationForWindow(aEvent, [self window]);
NSPoint localEventLocation = [self convertPoint:windowEventLocation fromView:nil];
- uint32_t msg = aEnter ? NS_MOUSE_ENTER_WIDGET : NS_MOUSE_EXIT_WIDGET;
+ EventMessage msg = aEnter ? NS_MOUSE_ENTER_WIDGET : NS_MOUSE_EXIT_WIDGET;
WidgetMouseEvent event(true, msg, mGeckoChild, WidgetMouseEvent::eReal);
event.refPoint = LayoutDeviceIntPoint::FromUntyped(
mGeckoChild->CocoaPointsToDevPixels(localEventLocation));
event.exit = aType;
nsEventStatus status; // ignored
mGeckoChild->DispatchEvent(&event, status);
@@ -4812,25 +4812,28 @@ NewCGSRegionFromRegion(const nsIntRegion
}
static int32_t RoundUp(double aDouble)
{
return aDouble < 0 ? static_cast<int32_t>(floor(aDouble)) :
static_cast<int32_t>(ceil(aDouble));
}
-- (void)sendWheelStartOrStop:(uint32_t)msg forEvent:(NSEvent *)theEvent
+- (void)sendWheelStartOrStop:(EventMessage)msg forEvent:(NSEvent *)theEvent
{
WidgetWheelEvent wheelEvent(true, msg, mGeckoChild);
[self convertCocoaMouseWheelEvent:theEvent toGeckoEvent:&wheelEvent];
mExpectingWheelStop = (msg == NS_WHEEL_START);
mGeckoChild->DispatchAPZAwareEvent(wheelEvent.AsInputEvent());
}
-- (void)sendWheelCondition:(BOOL)condition first:(uint32_t)first second:(uint32_t)second forEvent:(NSEvent *)theEvent
+- (void)sendWheelCondition:(BOOL)condition
+ first:(EventMessage)first
+ second:(EventMessage)second
+ forEvent:(NSEvent *)theEvent
{
if (mExpectingWheelStop == condition) {
[self sendWheelStartOrStop:first forEvent:theEvent];
}
[self sendWheelStartOrStop:second forEvent:theEvent];
}
- (void)scrollWheel:(NSEvent*)theEvent
@@ -5648,17 +5651,17 @@ static int32_t RoundUp(double aDouble)
- (APZCTreeManager*)apzctm
{
return mGeckoChild ? mGeckoChild->APZCTM() : nullptr;
}
// This is a utility function used by NSView drag event methods
// to send events. It contains all of the logic needed for Gecko
// dragging to work. Returns the appropriate cocoa drag operation code.
-- (NSDragOperation)doDragAction:(uint32_t)aMessage sender:(id)aSender
+- (NSDragOperation)doDragAction:(EventMessage)aMessage sender:(id)aSender
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
if (!mGeckoChild)
return NSDragOperationNone;
MOZ_LOG(sCocoaLog, LogLevel::Info, ("ChildView doDragAction: entered\n"));
@@ -5752,16 +5755,18 @@ static int32_t RoundUp(double aDouble)
if (!sourceNode) {
// We're leaving a window while doing a drag that was
// initiated in a different app. End the drag session,
// since we're done with it for now (until the user
// drags back into mozilla).
mDragService->EndDragSession(false);
}
}
+ default:
+ break;
}
}
return NSDragOperationGeneric;
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NSDragOperationNone);
}
--- a/widget/gonk/nsAppShell.cpp
+++ b/widget/gonk/nsAppShell.cpp
@@ -237,17 +237,17 @@ private:
static bool IsControlChar(char16_t aChar)
{
return (aChar < ' ' || aChar == 0x7F);
}
void DispatchKeyDownEvent();
void DispatchKeyUpEvent();
- nsEventStatus DispatchKeyEventInternal(uint32_t aEventMessage);
+ nsEventStatus DispatchKeyEventInternal(EventMessage aEventMessage);
};
KeyEventDispatcher::KeyEventDispatcher(const UserInputData& aData,
KeyCharacterMap* aKeyCharMap)
: mData(aData)
, mKeyCharMap(aKeyCharMap)
, mChar(0)
, mUnmodifiedChar(0)
@@ -289,17 +289,17 @@ KeyEventDispatcher::PrintableKeyValue()
{
if (mDOMKeyNameIndex != KEY_NAME_INDEX_USE_STRING) {
return 0;
}
return mChar ? mChar : mUnmodifiedChar;
}
nsEventStatus
-KeyEventDispatcher::DispatchKeyEventInternal(uint32_t aEventMessage)
+KeyEventDispatcher::DispatchKeyEventInternal(EventMessage aEventMessage)
{
WidgetKeyboardEvent event(true, aEventMessage, nullptr);
if (aEventMessage == NS_KEY_PRESS) {
// XXX If the charCode is not a printable character, the charCode
// should be computed without Ctrl/Alt/Meta modifiers.
event.charCode = static_cast<uint32_t>(mChar);
}
if (!event.charCode) {
--- a/widget/gtk/IMContextWrapper.cpp
+++ b/widget/gtk/IMContextWrapper.cpp
@@ -1434,18 +1434,18 @@ IMContextWrapper::DispatchCompositionCom
nsCOMPtr<nsIWidget> kungFuDeathGrip(mLastFocusedWindow);
if (!DispatchCompositionStart(aContext)) {
return false;
}
}
nsRefPtr<nsWindow> lastFocusedWindow(mLastFocusedWindow);
- uint32_t message = aCommitString ? NS_COMPOSITION_COMMIT :
- NS_COMPOSITION_COMMIT_AS_IS;
+ EventMessage message = aCommitString ? NS_COMPOSITION_COMMIT :
+ NS_COMPOSITION_COMMIT_AS_IS;
mCompositionState = eCompositionState_NotComposing;
mCompositionStart = UINT32_MAX;
mCompositionTargetRange.Clear();
mDispatchedCompositionString.Truncate();
WidgetCompositionEvent compositionCommitEvent(true, message,
mLastFocusedWindow);
InitEvent(compositionCommitEvent);
--- a/widget/gtk/nsDragService.cpp
+++ b/widget/gtk/nsDragService.cpp
@@ -2047,14 +2047,14 @@ gboolean
nsDragService::DispatchDropEvent()
{
// We need to check IsDestroyed here because the nsRefPtr
// only protects this from being deleted, it does NOT protect
// against nsView::~nsView() calling Destroy() on it, bug 378273.
if (mTargetWindow->IsDestroyed())
return FALSE;
- uint32_t msg = mCanDrop ? NS_DRAGDROP_DROP : NS_DRAGDROP_EXIT;
+ EventMessage msg = mCanDrop ? NS_DRAGDROP_DROP : NS_DRAGDROP_EXIT;
mTargetWindow->DispatchDragEvent(msg, mTargetWindowPoint, mTargetTime);
return mCanDrop;
}
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -2892,17 +2892,17 @@ nsWindow::DispatchCommandEvent(nsIAtom*
{
nsEventStatus status;
WidgetCommandEvent event(true, nsGkAtoms::onAppCommand, aCommand, this);
DispatchEvent(&event, status);
return TRUE;
}
bool
-nsWindow::DispatchContentCommandEvent(int32_t aMsg)
+nsWindow::DispatchContentCommandEvent(EventMessage aMsg)
{
nsEventStatus status;
WidgetContentCommandEvent event(true, aMsg, this);
DispatchEvent(&event, status);
return TRUE;
}
static bool
@@ -3321,17 +3321,17 @@ nsWindow::ThemeChanged()
win->ThemeChanged();
}
children = children->next;
}
}
void
-nsWindow::DispatchDragEvent(uint32_t aMsg, const nsIntPoint& aRefPoint,
+nsWindow::DispatchDragEvent(EventMessage aMsg, const nsIntPoint& aRefPoint,
guint aTime)
{
WidgetDragEvent event(true, aMsg, this);
if (aMsg == NS_DRAGDROP_OVER) {
InitDragEvent(event);
}
--- a/widget/gtk/nsWindow.h
+++ b/widget/gtk/nsWindow.h
@@ -254,17 +254,17 @@ public:
MozContainer* GetMozContainer() { return mContainer; }
// GetMozContainerWidget returns the MozContainer even for undestroyed
// descendant windows
GtkWidget* GetMozContainerWidget();
GdkWindow* GetGdkWindow() { return mGdkWindow; }
bool IsDestroyed() { return mIsDestroyed; }
- void DispatchDragEvent(uint32_t aMsg,
+ void DispatchDragEvent(mozilla::EventMessage aMsg,
const nsIntPoint& aRefPoint,
guint aTime);
static void UpdateDragStatus (GdkDragContext *aDragContext,
nsIDragService *aDragService);
// If this dispatched the keydown event actually, this returns TRUE,
// otherwise, FALSE.
bool DispatchKeyDownEvent(GdkEventKey *aEvent,
bool *aIsCancelled);
@@ -364,17 +364,17 @@ private:
GtkWidget *GetToplevelWidget();
nsWindow *GetContainerWindow();
void SetUrgencyHint(GtkWidget *top_window, bool state);
void *SetupPluginPort(void);
void SetDefaultIcon(void);
void InitButtonEvent(mozilla::WidgetMouseEvent& aEvent,
GdkEventButton* aGdkEvent);
bool DispatchCommandEvent(nsIAtom* aCommand);
- bool DispatchContentCommandEvent(int32_t aMsg);
+ bool DispatchContentCommandEvent(mozilla::EventMessage aMsg);
bool CheckForRollup(gdouble aMouseX, gdouble aMouseY,
bool aIsWheel, bool aAlwaysRollup);
bool GetDragInfo(mozilla::WidgetMouseEvent* aMouseEvent,
GdkWindow** aWindow, gint* aButton,
gint* aRootX, gint* aRootY);
void ClearCachedResources();
GtkWidget *mShell;
--- a/widget/nsBaseDragService.cpp
+++ b/widget/nsBaseDragService.cpp
@@ -398,17 +398,17 @@ NS_IMETHODIMP
nsBaseDragService::FireDragEventAtSource(uint32_t aMsg)
{
if (mSourceNode && !mSuppressLevel) {
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mSourceDocument);
if (doc) {
nsCOMPtr<nsIPresShell> presShell = doc->GetShell();
if (presShell) {
nsEventStatus status = nsEventStatus_eIgnore;
- WidgetDragEvent event(true, aMsg, nullptr);
+ WidgetDragEvent event(true, static_cast<EventMessage>(aMsg), nullptr);
event.inputSource = mInputSource;
if (aMsg == NS_DRAGDROP_END) {
event.refPoint.x = mEndDragPoint.x;
event.refPoint.y = mEndDragPoint.y;
event.userCancelled = mUserCancelled;
}
nsCOMPtr<nsIContent> content = do_QueryInterface(mSourceNode);
--- a/widget/nsGUIEventIPC.h
+++ b/widget/nsGUIEventIPC.h
@@ -14,16 +14,35 @@
#include "mozilla/MouseEvents.h"
#include "mozilla/TextEvents.h"
#include "mozilla/TouchEvents.h"
namespace IPC
{
template<>
+struct ParamTraits<mozilla::EventMessage>
+{
+ typedef mozilla::EventMessage paramType;
+
+ static void Write(Message* aMsg, const paramType& aParam)
+ {
+ WriteParam(aMsg, static_cast<const mozilla::EventMessageType&>(aParam));
+ }
+
+ static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
+ {
+ mozilla::EventMessageType eventMessage = 0;
+ bool ret = ReadParam(aMsg, aIter, &eventMessage);
+ *aResult = static_cast<paramType>(eventMessage);
+ return ret;
+ }
+};
+
+template<>
struct ParamTraits<mozilla::BaseEventFlags>
{
typedef mozilla::BaseEventFlags paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
aMsg->WriteBytes(&aParam, sizeof(aParam));
}
--- a/widget/windows/IMMHandler.cpp
+++ b/widget/windows/IMMHandler.cpp
@@ -1519,17 +1519,17 @@ IMMHandler::HandleEndComposition(nsWindo
aWindow, aCommitString,
aCommitString ? NS_ConvertUTF16toUTF8(*aCommitString).get() : ""));
if (mNativeCaretIsCreated) {
::DestroyCaret();
mNativeCaretIsCreated = false;
}
- uint32_t message =
+ EventMessage message =
aCommitString ? NS_COMPOSITION_COMMIT : NS_COMPOSITION_COMMIT_AS_IS;
WidgetCompositionEvent compositionCommitEvent(true, message, aWindow);
nsIntPoint point(0, 0);
aWindow->InitEvent(compositionCommitEvent, &point);
if (aCommitString) {
compositionCommitEvent.mData = *aCommitString;
}
aWindow->DispatchWindowEvent(&compositionCommitEvent);
--- a/widget/windows/KeyboardLayout.cpp
+++ b/widget/windows/KeyboardLayout.cpp
@@ -1318,17 +1318,17 @@ NativeKey::HandleAppCommandMessage() con
return true;
}
}
// Dispatch a command event or a content command event if the command is
// supported.
if (!consumed) {
uint32_t appCommand = GET_APPCOMMAND_LPARAM(mMsg.lParam);
- uint32_t contentCommandMessage = NS_EVENT_NULL;
+ EventMessage contentCommandMessage = NS_EVENT_NULL;
switch (appCommand) {
case APPCOMMAND_BROWSER_BACKWARD:
case APPCOMMAND_BROWSER_FORWARD:
case APPCOMMAND_BROWSER_REFRESH:
case APPCOMMAND_BROWSER_STOP:
case APPCOMMAND_BROWSER_SEARCH:
case APPCOMMAND_BROWSER_FAVORITES:
case APPCOMMAND_BROWSER_HOME:
--- a/widget/windows/WinUtils.cpp
+++ b/widget/windows/WinUtils.cpp
@@ -937,23 +937,23 @@ WinUtils::GetMouseInputSource()
inputSource = (lParamExtraInfo & TABLET_INK_TOUCH) ?
nsIDOMMouseEvent::MOZ_SOURCE_TOUCH : nsIDOMMouseEvent::MOZ_SOURCE_PEN;
}
return static_cast<uint16_t>(inputSource);
}
/* static */
bool
-WinUtils::GetIsMouseFromTouch(uint32_t aEventType)
+WinUtils::GetIsMouseFromTouch(EventMessage aEventMessage)
{
const uint32_t MOZ_T_I_SIGNATURE = TABLET_INK_TOUCH | TABLET_INK_SIGNATURE;
const uint32_t MOZ_T_I_CHECK_TCH = TABLET_INK_TOUCH | TABLET_INK_CHECK;
- return ((aEventType == NS_MOUSE_MOVE ||
- aEventType == NS_MOUSE_BUTTON_DOWN ||
- aEventType == NS_MOUSE_BUTTON_UP) &&
+ return ((aEventMessage == NS_MOUSE_MOVE ||
+ aEventMessage == NS_MOUSE_BUTTON_DOWN ||
+ aEventMessage == NS_MOUSE_BUTTON_UP) &&
(GetMessageExtraInfo() & MOZ_T_I_SIGNATURE) == MOZ_T_I_CHECK_TCH);
}
/* static */
MSG
WinUtils::InitMSG(UINT aMessage, WPARAM wParam, LPARAM lParam, HWND aWnd)
{
MSG msg;
--- a/widget/windows/WinUtils.h
+++ b/widget/windows/WinUtils.h
@@ -30,16 +30,17 @@
#include "nsIFaviconService.h"
#endif
#include "nsIDownloader.h"
#include "nsIURI.h"
#include "nsIWidget.h"
#include "nsIThread.h"
#include "mozilla/Attributes.h"
+#include "mozilla/EventForwards.h"
/**
* NS_INLINE_DECL_IUNKNOWN_REFCOUNTING should be used for defining and
* implementing AddRef() and Release() of IUnknown interface.
* This depends on xpcom/glue/nsISupportsImpl.h.
*/
#define NS_INLINE_DECL_IUNKNOWN_REFCOUNTING(_class) \
@@ -303,17 +304,17 @@ public:
/**
* GetMouseInputSource() returns a pointing device information. The value is
* one of nsIDOMMouseEvent::MOZ_SOURCE_*. This method MUST be called during
* mouse message handling.
*/
static uint16_t GetMouseInputSource();
- static bool GetIsMouseFromTouch(uint32_t aEventType);
+ static bool GetIsMouseFromTouch(EventMessage aEventType);
/**
* SHCreateItemFromParsingName() calls native SHCreateItemFromParsingName()
* API which is available on Vista and up.
*/
static HRESULT SHCreateItemFromParsingName(PCWSTR pszPath, IBindCtx *pbc,
REFIID riid, void **ppv);
--- a/widget/windows/nsNativeDragTarget.cpp
+++ b/widget/windows/nsNativeDragTarget.cpp
@@ -147,20 +147,21 @@ nsNativeDragTarget::GetGeckoDragAction(D
inline
bool
IsKeyDown(char key)
{
return GetKeyState(key) < 0;
}
void
-nsNativeDragTarget::DispatchDragDropEvent(uint32_t aEventType, POINTL aPT)
+nsNativeDragTarget::DispatchDragDropEvent(EventMessage aEventMessage,
+ const POINTL& aPT)
{
nsEventStatus status;
- WidgetDragEvent event(true, aEventType, mWidget);
+ WidgetDragEvent event(true, aEventMessage, mWidget);
nsWindow * win = static_cast<nsWindow *>(mWidget);
win->InitEvent(event);
POINT cpos;
cpos.x = aPT.x;
cpos.y = aPT.y;
@@ -177,17 +178,17 @@ nsNativeDragTarget::DispatchDragDropEven
modifierKeyState.InitInputEvent(event);
event.inputSource = static_cast<nsBaseDragService*>(mDragService)->GetInputSource();
mWidget->DispatchEvent(&event, status);
}
void
-nsNativeDragTarget::ProcessDrag(uint32_t aEventType,
+nsNativeDragTarget::ProcessDrag(EventMessage aEventMessage,
DWORD grfKeyState,
POINTL ptl,
DWORD* pdwEffect)
{
// Before dispatching the event make sure we have the correct drop action set
uint32_t geckoAction;
GetGeckoDragAction(grfKeyState, pdwEffect, &geckoAction);
@@ -196,17 +197,17 @@ nsNativeDragTarget::ProcessDrag(uint32_t
mDragService->GetCurrentSession(getter_AddRefs(currSession));
if (!currSession) {
return;
}
currSession->SetDragAction(geckoAction);
// Dispatch the event into Gecko
- DispatchDragDropEvent(aEventType, ptl);
+ DispatchDragDropEvent(aEventMessage, ptl);
// If TakeChildProcessDragAction returns something other than
// DRAGDROP_ACTION_UNINITIALIZED, it means that the last event was sent
// to the child process and this event is also being sent to the child
// process. In this case, use the last event's action instead.
nsDragService* dragService = static_cast<nsDragService *>(mDragService);
currSession->GetDragAction(&geckoAction);
@@ -223,17 +224,17 @@ nsNativeDragTarget::ProcessDrag(uint32_t
}
else if (nsIDragService::DRAGDROP_ACTION_MOVE & geckoAction) {
*pdwEffect = DROPEFFECT_MOVE;
}
else {
*pdwEffect = DROPEFFECT_NONE;
}
- if (aEventType != NS_DRAGDROP_DROP) {
+ if (aEventMessage != NS_DRAGDROP_DROP) {
// Get the cached drag effect from the drag service, the data member should
// have been set by whoever handled the WidgetGUIEvent or nsIDOMEvent on
// drags.
bool canDrop;
currSession->GetCanDrop(&canDrop);
if (!canDrop) {
*pdwEffect = DROPEFFECT_NONE;
}
--- a/widget/windows/nsNativeDragTarget.h
+++ b/widget/windows/nsNativeDragTarget.h
@@ -11,16 +11,17 @@
#include <shlobj.h>
#ifndef IDropTargetHelper
#include <shobjidl.h> // Vista drag image interfaces
#undef LogSeverity // SetupAPI.h #defines this as DWORD
#endif
#include "mozilla/Attributes.h"
+#include "mozilla/EventForwards.h"
class nsIDragService;
class nsIWidget;
/*
* nsNativeDragTarget implements the IDropTarget interface and gets most of its
* behavior from the associated adapter (m_dragDrop).
*/
@@ -66,19 +67,20 @@ public:
* Cancel the current drag session, if any.
*/
void DragCancel();
protected:
void GetGeckoDragAction(DWORD grfKeyState, LPDWORD pdwEffect,
uint32_t * aGeckoAction);
- void ProcessDrag(uint32_t aEventType, DWORD grfKeyState,
+ void ProcessDrag(mozilla::EventMessage aEventMessage, DWORD grfKeyState,
POINTL pt, DWORD* pdwEffect);
- void DispatchDragDropEvent(uint32_t aType, POINTL pt);
+ void DispatchDragDropEvent(mozilla::EventMessage aEventMessage,
+ const POINTL& aPT);
void AddLinkSupportIfCanBeGenerated(LPDATAOBJECT aIDataSource);
// Native Stuff
ULONG m_cRef; // reference count
HWND mHWnd;
DWORD mEffectsAllowed;
DWORD mEffectsPreferred;
bool mTookOwnRef;
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -3876,17 +3876,17 @@ NS_IMETHODIMP nsWindow::DispatchEvent(Wi
// the window can be destroyed during processing of seemingly innocuous events like, say,
// mousedowns due to the magic of scripting. mousedowns will return nsEventStatus_eIgnore,
// which causes problems with the deleted window. therefore:
if (mOnDestroyCalled)
aStatus = nsEventStatus_eConsumeNoDefault;
return NS_OK;
}
-bool nsWindow::DispatchStandardEvent(uint32_t aMsg)
+bool nsWindow::DispatchStandardEvent(EventMessage aMsg)
{
WidgetGUIEvent event(true, aMsg, this);
InitEvent(event);
bool result = DispatchWindowEvent(&event);
return result;
}
@@ -3986,29 +3986,30 @@ bool nsWindow::DispatchPluginEvent(UINT
WinUtils::InitMSG(aMessage, aWParam, aLParam, mWnd));
if (aDispatchPendingEvents && !Destroyed()) {
DispatchPendingEvents();
}
return ret;
}
// Deal with all sort of mouse event
-bool nsWindow::DispatchMouseEvent(uint32_t aEventType, WPARAM wParam,
- LPARAM lParam, bool aIsContextMenuKey,
- int16_t aButton, uint16_t aInputSource)
+bool
+nsWindow::DispatchMouseEvent(EventMessage aEventMessage, WPARAM wParam,
+ LPARAM lParam, bool aIsContextMenuKey,
+ int16_t aButton, uint16_t aInputSource)
{
bool result = false;
UserActivity();
if (!mWidgetListener) {
return result;
}
- if (mTouchWindow && WinUtils::GetIsMouseFromTouch(aEventType)) {
+ if (mTouchWindow && WinUtils::GetIsMouseFromTouch(aEventMessage)) {
// If mTouchWindow is true, then we must have APZ enabled and be
// feeding it raw touch events. In that case we don't need to
// send touch-generated mouse events to content.
MOZ_ASSERT(mAPZC);
return result;
}
// Since it is unclear whether a user will use the digitizer,
@@ -4016,17 +4017,17 @@ bool nsWindow::DispatchMouseEvent(uint32
if (nsIDOMMouseEvent::MOZ_SOURCE_PEN == aInputSource
// Messages should be only at topLevel window.
&& nsWindowType::eWindowType_toplevel == mWindowType
// Currently this scheme is used only when pointer events is enabled.
&& gfxPrefs::PointerEventsEnabled()) {
InkCollector::sInkCollector->SetTarget(mWnd);
}
- switch (aEventType) {
+ switch (aEventMessage) {
case NS_MOUSE_BUTTON_DOWN:
CaptureMouse(true);
break;
// NS_MOUSE_MOVE and NS_MOUSE_EXIT_WIDGET are here because we need to make sure capture flag
// isn't left on after a drag where we wouldn't see a button up message (see bug 324131).
case NS_MOUSE_BUTTON_UP:
case NS_MOUSE_MOVE:
@@ -4039,20 +4040,20 @@ bool nsWindow::DispatchMouseEvent(uint32
break;
} // switch
nsIntPoint eventPoint;
eventPoint.x = GET_X_LPARAM(lParam);
eventPoint.y = GET_Y_LPARAM(lParam);
- WidgetMouseEvent event(true, aEventType, this, WidgetMouseEvent::eReal,
+ WidgetMouseEvent event(true, aEventMessage, this, WidgetMouseEvent::eReal,
aIsContextMenuKey ? WidgetMouseEvent::eContextMenuKey :
WidgetMouseEvent::eNormal);
- if (aEventType == NS_CONTEXTMENU && aIsContextMenuKey) {
+ if (aEventMessage == NS_CONTEXTMENU && aIsContextMenuKey) {
nsIntPoint zero(0, 0);
InitEvent(event, &zero);
} else {
InitEvent(event, &eventPoint);
}
ModifierKeyState modifierKeyState;
modifierKeyState.InitInputEvent(event);
@@ -4060,18 +4061,17 @@ bool nsWindow::DispatchMouseEvent(uint32
event.inputSource = aInputSource;
// If we get here the mouse events must be from non-touch sources, so
// convert it to pointer events as well
event.convertToPointer = true;
nsIntPoint mpScreen = eventPoint + WidgetToScreenOffsetUntyped();
// Suppress mouse moves caused by widget creation
- if (aEventType == NS_MOUSE_MOVE)
- {
+ if (aEventMessage == NS_MOUSE_MOVE) {
if ((sLastMouseMovePoint.x == mpScreen.x) && (sLastMouseMovePoint.y == mpScreen.y))
return result;
sLastMouseMovePoint.x = mpScreen.x;
sLastMouseMovePoint.y = mpScreen.y;
}
bool insideMovementThreshold = (DeprecatedAbs(sLastMousePoint.x - eventPoint.x) < (short)::GetSystemMetrics(SM_CXDOUBLECLK)) &&
(DeprecatedAbs(sLastMousePoint.y - eventPoint.y) < (short)::GetSystemMetrics(SM_CYDOUBLECLK));
@@ -4091,58 +4091,64 @@ bool nsWindow::DispatchMouseEvent(uint32
eventButton = 0;
break;
}
// Doubleclicks are used to set the click count, then changed to mousedowns
// We're going to time double-clicks from mouse *up* to next mouse *down*
LONG curMsgTime = ::GetMessageTime();
- if (aEventType == NS_MOUSE_DOUBLECLICK) {
- event.mMessage = NS_MOUSE_BUTTON_DOWN;
- event.button = aButton;
- sLastClickCount = 2;
- sLastMouseDownTime = curMsgTime;
- }
- else if (aEventType == NS_MOUSE_BUTTON_UP) {
- // remember when this happened for the next mouse down
- sLastMousePoint.x = eventPoint.x;
- sLastMousePoint.y = eventPoint.y;
- sLastMouseButton = eventButton;
- }
- else if (aEventType == NS_MOUSE_BUTTON_DOWN) {
- // now look to see if we want to convert this to a double- or triple-click
- if (((curMsgTime - sLastMouseDownTime) < (LONG)::GetDoubleClickTime()) && insideMovementThreshold &&
- eventButton == sLastMouseButton) {
- sLastClickCount ++;
- } else {
- // reset the click count, to count *this* click
- sLastClickCount = 1;
- }
- // Set last Click time on MouseDown only
- sLastMouseDownTime = curMsgTime;
- }
- else if (aEventType == NS_MOUSE_MOVE && !insideMovementThreshold) {
- sLastClickCount = 0;
- }
- else if (aEventType == NS_MOUSE_EXIT_WIDGET) {
- event.exit = IsTopLevelMouseExit(mWnd) ?
- WidgetMouseEvent::eTopLevel : WidgetMouseEvent::eChild;
+ switch (aEventMessage) {
+ case NS_MOUSE_DOUBLECLICK:
+ event.mMessage = NS_MOUSE_BUTTON_DOWN;
+ event.button = aButton;
+ sLastClickCount = 2;
+ sLastMouseDownTime = curMsgTime;
+ break;
+ case NS_MOUSE_BUTTON_UP:
+ // remember when this happened for the next mouse down
+ sLastMousePoint.x = eventPoint.x;
+ sLastMousePoint.y = eventPoint.y;
+ sLastMouseButton = eventButton;
+ break;
+ case NS_MOUSE_BUTTON_DOWN:
+ // now look to see if we want to convert this to a double- or triple-click
+ if (((curMsgTime - sLastMouseDownTime) < (LONG)::GetDoubleClickTime()) &&
+ insideMovementThreshold &&
+ eventButton == sLastMouseButton) {
+ sLastClickCount ++;
+ } else {
+ // reset the click count, to count *this* click
+ sLastClickCount = 1;
+ }
+ // Set last Click time on MouseDown only
+ sLastMouseDownTime = curMsgTime;
+ break;
+ case NS_MOUSE_MOVE:
+ if (!insideMovementThreshold) {
+ sLastClickCount = 0;
+ }
+ break;
+ case NS_MOUSE_EXIT_WIDGET:
+ event.exit = IsTopLevelMouseExit(mWnd) ?
+ WidgetMouseEvent::eTopLevel : WidgetMouseEvent::eChild;
+ break;
+ default:
+ break;
}
event.clickCount = sLastClickCount;
#ifdef NS_DEBUG_XX
MOZ_LOG(gWindowsLog, LogLevel::Info,
("Msg Time: %d Click Count: %d\n", curMsgTime, event.clickCount));
#endif
NPEvent pluginEvent;
- switch (aEventType)
- {
+ switch (aEventMessage) {
case NS_MOUSE_BUTTON_DOWN:
switch (aButton) {
case WidgetMouseEvent::eLeftButton:
pluginEvent.event = WM_LBUTTONDOWN;
break;
case WidgetMouseEvent::eMiddleButton:
pluginEvent.event = WM_MBUTTONDOWN;
break;
@@ -4198,17 +4204,17 @@ bool nsWindow::DispatchMouseEvent(uint32
pluginEvent.lParam = lParam;
event.mPluginEvent.Copy(pluginEvent);
// call the event callback
if (mWidgetListener) {
if (nsToolkit::gMouseTrailer)
nsToolkit::gMouseTrailer->Disable();
- if (aEventType == NS_MOUSE_MOVE) {
+ if (aEventMessage == NS_MOUSE_MOVE) {
if (nsToolkit::gMouseTrailer && !sIsInMouseCapture) {
nsToolkit::gMouseTrailer->SetMouseTrailerWindow(mWnd);
}
nsIntRect rect;
GetBounds(rect);
rect.x = 0;
rect.y = 0;
@@ -4224,17 +4230,17 @@ bool nsWindow::DispatchMouseEvent(uint32
if (!mInDtor) {
LPARAM pos = sCurrentWindow->lParamToClient(lParamToScreen(lParam));
sCurrentWindow->DispatchMouseEvent(NS_MOUSE_ENTER_WIDGET, wParam, pos, false,
WidgetMouseEvent::eLeftButton,
aInputSource);
}
}
}
- } else if (aEventType == NS_MOUSE_EXIT_WIDGET) {
+ } else if (aEventMessage == NS_MOUSE_EXIT_WIDGET) {
if (sCurrentWindow == this) {
sCurrentWindow = nullptr;
}
}
result = ConvertStatus(DispatchInputEvent(&event));
if (nsToolkit::gMouseTrailer)
@@ -6456,17 +6462,17 @@ bool nsWindow::OnGesture(WPARAM wParam,
}
mGesture.CloseGestureInfoHandle((HGESTUREINFO)lParam);
return true;
}
// Other gestures translate into simple gesture events:
- WidgetSimpleGestureEvent event(true, 0, this);
+ WidgetSimpleGestureEvent event(true, NS_EVENT_NULL, this);
if ( !mGesture.ProcessGestureMessage(mWnd, wParam, lParam, event) ) {
return false; // fall through to DefWndProc
}
// Polish up and send off the new event
ModifierKeyState modifierKeyState;
modifierKeyState.InitInputEvent(event);
event.button = 0;
--- a/widget/windows/nsWindow.h
+++ b/widget/windows/nsWindow.h
@@ -203,21 +203,25 @@ public:
virtual void UpdateWindowDraggingRegion(const nsIntRegion& aRegion) override;
virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) override;
virtual uint32_t GetMaxTouchPoints() const override;
/**
* Event helpers
*/
- virtual bool DispatchMouseEvent(uint32_t aEventType, WPARAM wParam,
- LPARAM lParam,
- bool aIsContextMenuKey = false,
- int16_t aButton = mozilla::WidgetMouseEvent::eLeftButton,
- uint16_t aInputSource = nsIDOMMouseEvent::MOZ_SOURCE_MOUSE);
+ virtual bool DispatchMouseEvent(
+ mozilla::EventMessage aEventMessage,
+ WPARAM wParam,
+ LPARAM lParam,
+ bool aIsContextMenuKey = false,
+ int16_t aButton =
+ mozilla::WidgetMouseEvent::eLeftButton,
+ uint16_t aInputSource =
+ nsIDOMMouseEvent::MOZ_SOURCE_MOUSE);
virtual bool DispatchWindowEvent(mozilla::WidgetGUIEvent* aEvent,
nsEventStatus& aStatus);
void DispatchPendingEvents();
bool DispatchPluginEvent(UINT aMessage,
WPARAM aWParam,
LPARAM aLParam,
bool aDispatchPendingEvents);
@@ -353,17 +357,17 @@ protected:
return mWindowType == eWindowType_popup;
}
/**
* Event processing helpers
*/
void DispatchFocusToTopLevelWindow(bool aIsActivate);
- bool DispatchStandardEvent(uint32_t aMsg);
+ bool DispatchStandardEvent(mozilla::EventMessage aMsg);
void RelayMouseEvent(UINT aMsg, WPARAM wParam, LPARAM lParam);
virtual bool ProcessMessage(UINT msg, WPARAM &wParam,
LPARAM &lParam, LRESULT *aRetValue);
bool ExternalHandlerProcessMessage(
UINT aMessage, WPARAM& aWParam,
LPARAM& aLParam, MSGResult& aResult);
bool ProcessMessageForPlugin(const MSG &aMsg,
MSGResult& aResult);