Skip to content

Commit

Permalink
Bug 912956 part.12 All event utils (macros and inline methods) should…
Browse files Browse the repository at this point in the history
… be methods of mozilla::WidgetEvent r=roc
  • Loading branch information
masayuki-nakano committed Sep 24, 2013
1 parent b0da229 commit c28e4ca
Show file tree
Hide file tree
Showing 23 changed files with 408 additions and 219 deletions.
2 changes: 1 addition & 1 deletion content/base/src/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2213,7 +2213,7 @@ Element::PostHandleEventForLinks(nsEventChainPostVisitor& aVisitor)
break;

case NS_MOUSE_CLICK:
if (NS_IS_MOUSE_LEFT_CLICK(aVisitor.mEvent)) {
if (aVisitor.mEvent->IsLeftClickEvent()) {
nsInputEvent* inputEvent = static_cast<nsInputEvent*>(aVisitor.mEvent);
if (inputEvent->IsControl() || inputEvent->IsMeta() ||
inputEvent->IsAlt() ||inputEvent->IsShift()) {
Expand Down
2 changes: 1 addition & 1 deletion content/events/src/nsDOMUIEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ nsDOMUIEvent::ComputeModifierState(const nsAString& aModifiersList)
bool
nsDOMUIEvent::GetModifierStateInternal(const nsAString& aKey)
{
if (!NS_IS_INPUT_EVENT(mEvent)) {
if (!mEvent->IsInputDerivedEvent()) {
MOZ_CRASH("mEvent must be nsInputEvent or derived class");
}
nsInputEvent* inputEvent = static_cast<nsInputEvent*>(mEvent);
Expand Down
9 changes: 4 additions & 5 deletions content/events/src/nsEventStateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ RoundDown(double aDouble)
static inline bool
IsMouseEventReal(nsEvent* aEvent)
{
NS_ABORT_IF_FALSE(NS_IS_MOUSE_EVENT_STRUCT(aEvent), "Not a mouse event");
NS_ABORT_IF_FALSE(aEvent->IsMouseDerivedEvent(), "Not a mouse event");
// Return true if not synthesized.
return static_cast<nsMouseEvent*>(aEvent)->reason == nsMouseEvent::eReal;
}
Expand Down Expand Up @@ -796,16 +796,15 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
if (!mCurrentTarget) return NS_ERROR_NULL_POINTER;
}
#ifdef DEBUG
if (NS_IS_DRAG_EVENT(aEvent) && sIsPointerLocked) {
if (aEvent->HasDragEventMessage() && sIsPointerLocked) {
NS_ASSERTION(sIsPointerLocked,
"sIsPointerLocked is true. Drag events should be suppressed when the pointer is locked.");
}
#endif
// Store last known screenPoint and clientPoint so pointer lock
// can use these values as constants.
if (aEvent->mFlags.mIsTrusted &&
((NS_IS_MOUSE_EVENT_STRUCT(aEvent) &&
IsMouseEventReal(aEvent)) ||
((aEvent->IsMouseDerivedEvent() && IsMouseEventReal(aEvent)) ||
aEvent->eventStructType == NS_WHEEL_EVENT)) {
if (!sIsPointerLocked) {
sLastScreenPoint = nsDOMUIEvent::CalculateScreenPoint(aPresContext, aEvent);
Expand Down Expand Up @@ -976,7 +975,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
WheelPrefs::GetInstance()->ApplyUserPrefsToDelta(wheelEvent);

// If we won't dispatch a DOM event for this event, nothing to do anymore.
if (!NS_IsAllowedToDispatchDOMEvent(wheelEvent)) {
if (!wheelEvent->IsAllowedToDispatchDOMEvent()) {
break;
}

Expand Down
3 changes: 2 additions & 1 deletion content/events/src/nsEventStateManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,8 @@ class nsAutoHandlingUserInputStatePusher
// Click and double-click events need to be handled even for content that
// has no frame. This is required for Web compatibility.
#define NS_EVENT_NEEDS_FRAME(event) \
(!NS_IS_ACTIVATION_EVENT(event) && (event)->message != NS_MOUSE_CLICK && \
(!(event)->HasPluginActivationEventMessage() && \
(event)->message != NS_MOUSE_CLICK && \
(event)->message != NS_MOUSE_DOUBLECLICK)

#endif // nsEventStateManager_h__
4 changes: 2 additions & 2 deletions content/html/content/src/HTMLButtonElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ HTMLButtonElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
// DOMActivate that was dispatched directly, this will be set, but if we're
// a DOMActivate dispatched from click handling, it will not be set.
bool outerActivateEvent =
(NS_IS_MOUSE_LEFT_CLICK(aVisitor.mEvent) ||
(aVisitor.mEvent->IsLeftClickEvent() ||
(aVisitor.mEvent->message == NS_UI_ACTIVATE &&
!mInInternalActivate));

Expand All @@ -224,7 +224,7 @@ HTMLButtonElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
}

if (aVisitor.mEventStatus != nsEventStatus_eConsumeNoDefault &&
NS_IS_MOUSE_LEFT_CLICK(aVisitor.mEvent)) {
aVisitor.mEvent->IsLeftClickEvent()) {
nsUIEvent actEvent(aVisitor.mEvent->mFlags.mIsTrusted, NS_UI_ACTIVATE, 1);

nsCOMPtr<nsIPresShell> shell = aVisitor.mPresContext->GetPresShell();
Expand Down
6 changes: 3 additions & 3 deletions content/html/content/src/HTMLInputElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3010,7 +3010,7 @@ HTMLInputElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
// DOMActivate that was dispatched directly, this will be set, but if we're
// a DOMActivate dispatched from click handling, it will not be set.
bool outerActivateEvent =
(NS_IS_MOUSE_LEFT_CLICK(aVisitor.mEvent) ||
(aVisitor.mEvent->IsLeftClickEvent() ||
(aVisitor.mEvent->message == NS_UI_ACTIVATE && !mInInternalActivate));

if (outerActivateEvent) {
Expand Down Expand Up @@ -3240,7 +3240,7 @@ HTMLInputElement::MaybeInitPickers(nsEventChainPostVisitor& aVisitor)
// - it's the left mouse button.
// We do not prevent non-trusted click because authors can already use
// .click(). However, the pickers will follow the rules of popup-blocking.
if (NS_IS_MOUSE_LEFT_CLICK(aVisitor.mEvent) &&
if (aVisitor.mEvent->IsLeftClickEvent() &&
!aVisitor.mEvent->mFlags.mDefaultPrevented) {
if (mType == NS_FORM_INPUT_FILE) {
return InitFilePicker(FILE_PICKER_FILE);
Expand Down Expand Up @@ -3294,7 +3294,7 @@ HTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
// the click.
if (aVisitor.mEventStatus != nsEventStatus_eConsumeNoDefault &&
!IsSingleLineTextControl(true) &&
NS_IS_MOUSE_LEFT_CLICK(aVisitor.mEvent) &&
aVisitor.mEvent->IsLeftClickEvent() &&
!ShouldPreventDOMActivateDispatch(aVisitor.mEvent->originalTarget)) {
nsUIEvent actEvent(aVisitor.mEvent->mFlags.mIsTrusted, NS_UI_ACTIVATE, 1);

Expand Down
4 changes: 2 additions & 2 deletions content/html/content/src/HTMLLabelElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ nsresult
HTMLLabelElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
{
if (mHandlingEvent ||
(!NS_IS_MOUSE_LEFT_CLICK(aVisitor.mEvent) &&
(!aVisitor.mEvent->IsLeftClickEvent() &&
aVisitor.mEvent->message != NS_MOUSE_BUTTON_DOWN) ||
aVisitor.mEventStatus == nsEventStatus_eConsumeNoDefault ||
!aVisitor.mPresContext ||
Expand Down Expand Up @@ -146,7 +146,7 @@ HTMLLabelElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
break;

case NS_MOUSE_CLICK:
if (NS_IS_MOUSE_LEFT_CLICK(aVisitor.mEvent)) {
if (aVisitor.mEvent->IsLeftClickEvent()) {
const nsMouseEvent* event =
static_cast<const nsMouseEvent*>(aVisitor.mEvent);
LayoutDeviceIntPoint* mouseDownPoint =
Expand Down
2 changes: 1 addition & 1 deletion content/xbl/src/nsXBLPrototypeHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ nsXBLPrototypeHandler::ModifiersMatchMask(nsIDOMUIEvent* aEvent,
bool aIgnoreShiftKey)
{
nsEvent* event = aEvent->GetInternalNSEvent();
NS_ENSURE_TRUE(event && NS_IS_INPUT_EVENT(event), false);
NS_ENSURE_TRUE(event && event->IsInputDerivedEvent(), false);
nsInputEvent* inputEvent = static_cast<nsInputEvent*>(event);

if (mKeyMask & cMetaMask) {
Expand Down
4 changes: 2 additions & 2 deletions dom/base/nsGlobalWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2877,8 +2877,8 @@ nsGlobalWindow::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
// Handle 'active' event.
if (!mIdleObservers.IsEmpty() &&
aVisitor.mEvent->mFlags.mIsTrusted &&
(NS_IS_MOUSE_EVENT(aVisitor.mEvent) ||
NS_IS_DRAG_EVENT(aVisitor.mEvent))) {
(aVisitor.mEvent->HasMouseEventMessage() ||
aVisitor.mEvent->HasDragEventMessage())) {
mAddActiveEventFuzzTime = false;
}

Expand Down
21 changes: 11 additions & 10 deletions layout/base/nsPresShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6017,7 +6017,7 @@ PresShell::HandleEvent(nsIFrame *aFrame,

if (mIsDestroying ||
(sDisableNonTestMouseEvents && !aEvent->mFlags.mIsSynthesizedForTests &&
NS_IS_MOUSE_EVENT(aEvent))) {
aEvent->HasMouseEventMessage())) {
return NS_OK;
}

Expand All @@ -6027,8 +6027,9 @@ PresShell::HandleEvent(nsIFrame *aFrame,
return NS_OK;

nsIContent* capturingContent =
NS_IS_MOUSE_EVENT(aEvent) || aEvent->eventStructType == NS_WHEEL_EVENT ?
GetCapturingContent() : nullptr;
(aEvent->HasMouseEventMessage() ||
aEvent->eventStructType == NS_WHEEL_EVENT ? GetCapturingContent() :
nullptr);

nsCOMPtr<nsIDocument> retargetEventDoc;
if (!aDontRetargetEvents) {
Expand All @@ -6041,7 +6042,7 @@ PresShell::HandleEvent(nsIFrame *aFrame,
// active window. So, the events should be handled on the last focused
// content in the last focused DOM window in same top level window.
// Note, if no DOM window has been focused yet, we can discard the events.
if (NS_IsEventTargetedAtFocusedWindow(aEvent)) {
if (aEvent->IsTargetedAtFocusedWindow()) {
nsCOMPtr<nsPIDOMWindow> window = GetFocusedDOMWindowInOurWindow();
// No DOM window in same top level window has not been focused yet,
// discard the events.
Expand Down Expand Up @@ -6071,7 +6072,7 @@ PresShell::HandleEvent(nsIFrame *aFrame,
nsIFrame* frame = presShell->GetRootFrame();
if (!frame) {
if (aEvent->message == NS_QUERY_TEXT_CONTENT ||
NS_IS_CONTENT_COMMAND_EVENT(aEvent)) {
aEvent->IsContentCommandEvent()) {
return NS_OK;
}

Expand Down Expand Up @@ -6109,7 +6110,7 @@ PresShell::HandleEvent(nsIFrame *aFrame,
frame = GetNearestFrameContainingPresShell(this);
}

bool dispatchUsingCoordinates = NS_IsEventUsingCoordinates(aEvent);
bool dispatchUsingCoordinates = aEvent->IsUsingCoordinates();
if (dispatchUsingCoordinates) {
NS_WARN_IF_FALSE(frame, "Nothing to handle this event!");
if (!frame)
Expand Down Expand Up @@ -6376,7 +6377,7 @@ PresShell::HandleEvent(nsIFrame *aFrame,
// to the active document when mouse is over some subdocument.
nsEventStateManager* activeESM =
nsEventStateManager::GetActiveEventStateManager();
if (activeESM && NS_IS_MOUSE_EVENT(aEvent) &&
if (activeESM && aEvent->HasMouseEventMessage() &&
activeESM != shell->GetPresContext()->EventStateManager() &&
static_cast<nsEventStateManager*>(activeESM)->GetPresContext()) {
nsIPresShell* activeShell =
Expand Down Expand Up @@ -6409,7 +6410,7 @@ PresShell::HandleEvent(nsIFrame *aFrame,
PushCurrentEventInfo(nullptr, nullptr);

// key and IME related events go to the focused frame in this DOM window.
if (NS_IsEventTargetedAtFocusedContent(aEvent)) {
if (aEvent->IsTargetedAtFocusedContent()) {
mCurrentEventContent = nullptr;

nsCOMPtr<nsPIDOMWindow> window =
Expand Down Expand Up @@ -6499,7 +6500,7 @@ PresShell::HandleEvent(nsIFrame *aFrame,
mCurrentEventFrame = nullptr;
return HandleEventInternal(aEvent, aEventStatus);
}
else if (NS_IS_KEY_EVENT(aEvent)) {
else if (aEvent->HasKeyEventMessage()) {
// Keypress events in new blank tabs should not be completely thrown away.
// Retarget them -- the parent chrome shell might make use of them.
return RetargetEventToParent(aEvent, aEventStatus);
Expand Down Expand Up @@ -6872,7 +6873,7 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsEventStatus* aStatus)
if (aEvent->eventStructType == NS_KEY_EVENT) {
nsContentUtils::SetIsHandlingKeyBoardEvent(true);
}
if (NS_IsAllowedToDispatchDOMEvent(aEvent)) {
if (aEvent->IsAllowedToDispatchDOMEvent()) {
nsPresShellEventCB eventCB(this);
if (aEvent->eventStructType == NS_TOUCH_EVENT) {
DispatchTouchEvent(aEvent, aStatus, &eventCB, touchIsNew);
Expand Down
3 changes: 2 additions & 1 deletion layout/generic/nsImageFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,8 @@ nsImageFrame::GetContentForEvent(nsEvent* aEvent,
// XXX We need to make this special check for area element's capturing the
// mouse due to bug 135040. Remove it once that's fixed.
nsIContent* capturingContent =
NS_IS_MOUSE_EVENT(aEvent) ? nsIPresShell::GetCapturingContent() : nullptr;
aEvent->HasMouseEventMessage() ? nsIPresShell::GetCapturingContent() :
nullptr;
if (capturingContent && capturingContent->GetPrimaryFrame() == this) {
*aContent = capturingContent;
NS_IF_ADDREF(*aContent);
Expand Down
2 changes: 1 addition & 1 deletion layout/generic/nsObjectFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1993,7 +1993,7 @@ nsObjectFrame::HandleEvent(nsPresContext* aPresContext,
#endif

if (mInstanceOwner->SendNativeEvents() &&
NS_IS_PLUGIN_EVENT(anEvent)) {
anEvent->IsNativeEventDelivererForPlugin()) {
*anEventStatus = mInstanceOwner->ProcessEvent(*anEvent);
// Due to plugin code reentering Gecko, this frame may be dead at this
// point.
Expand Down
2 changes: 1 addition & 1 deletion layout/xul/base/src/nsButtonBoxFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ nsButtonBoxFrame::HandleEvent(nsPresContext* aPresContext,
break;

case NS_MOUSE_CLICK:
if (NS_IS_MOUSE_LEFT_CLICK(aEvent)) {
if (aEvent->IsLeftClickEvent()) {
MouseClicked(aPresContext, aEvent);
}
break;
Expand Down
2 changes: 1 addition & 1 deletion layout/xul/base/src/nsResizerFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ nsResizerFrame::HandleEvent(nsPresContext* aPresContext,
break;

case NS_MOUSE_CLICK:
if (NS_IS_MOUSE_LEFT_CLICK(aEvent))
if (aEvent->IsLeftClickEvent())
{
MouseClicked(aPresContext, aEvent);
}
Expand Down
2 changes: 1 addition & 1 deletion layout/xul/base/src/nsScrollBoxFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ nsAutoRepeatBoxFrame::HandleEvent(nsPresContext* aPresContext,
break;

case NS_MOUSE_CLICK:
if (NS_IS_MOUSE_LEFT_CLICK(aEvent)) {
if (aEvent->IsLeftClickEvent()) {
// skip button frame handling to prevent click handling
return nsBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
}
Expand Down
2 changes: 1 addition & 1 deletion layout/xul/base/src/nsTitleBarFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ nsTitleBarFrame::HandleEvent(nsPresContext* aPresContext,


case NS_MOUSE_CLICK:
if (NS_IS_MOUSE_LEFT_CLICK(aEvent))
if (aEvent->IsLeftClickEvent())
{
MouseClicked(aPresContext, aEvent);
}
Expand Down
17 changes: 8 additions & 9 deletions view/src/nsViewManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,23 +690,23 @@ nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsView* aView, nsEventStatus* a
{
PROFILER_LABEL("event", "nsViewManager::DispatchEvent");

if ((NS_IS_MOUSE_EVENT(aEvent) &&
if ((aEvent->HasMouseEventMessage() &&
// Ignore mouse events that we synthesize.
static_cast<nsMouseEvent*>(aEvent)->reason == nsMouseEvent::eReal &&
// Ignore mouse exit and enter (we'll get moves if the user
// is really moving the mouse) since we get them when we
// create and destroy widgets.
aEvent->message != NS_MOUSE_EXIT &&
aEvent->message != NS_MOUSE_ENTER) ||
NS_IS_KEY_EVENT(aEvent) ||
NS_IS_IME_EVENT(aEvent) ||
aEvent->HasKeyEventMessage() ||
aEvent->HasIMEEventMessage() ||
aEvent->message == NS_PLUGIN_INPUT_EVENT) {
gLastUserEventTime = PR_IntervalToMicroseconds(PR_IntervalNow());
}

// Find the view whose coordinates system we're in.
nsView* view = aView;
bool dispatchUsingCoordinates = NS_IsEventUsingCoordinates(aEvent);
bool dispatchUsingCoordinates = aEvent->IsUsingCoordinates();
if (dispatchUsingCoordinates) {
// Will dispatch using coordinates. Pretty bogus but it's consistent
// with what presshell does.
Expand All @@ -716,11 +716,10 @@ nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsView* aView, nsEventStatus* a
// If the view has no frame, look for a view that does.
nsIFrame* frame = view->GetFrame();
if (!frame &&
(dispatchUsingCoordinates || NS_IS_KEY_EVENT(aEvent) ||
NS_IS_IME_RELATED_EVENT(aEvent) ||
NS_IS_NON_RETARGETED_PLUGIN_EVENT(aEvent) ||
aEvent->message == NS_PLUGIN_ACTIVATE ||
aEvent->message == NS_PLUGIN_FOCUS ||
(dispatchUsingCoordinates || aEvent->HasKeyEventMessage() ||
aEvent->IsIMERelatedEvent() ||
aEvent->IsNonRetargetedNativeEventDelivererForPlugin() ||
aEvent->HasPluginActivationEventMessage() ||
aEvent->message == NS_PLUGIN_RESOLUTION_CHANGED)) {
while (view && !view->GetFrame()) {
view = view->GetParent();
Expand Down
Loading

0 comments on commit c28e4ca

Please sign in to comment.