From ce9ff392ecc174339a58abcfeae3991ddb09cb27 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Sun, 16 Dec 2012 10:26:03 +0900 Subject: [PATCH] Bug 813445 part.4 Remove NS_EVENT_FLAG_STOP_DISPATCH and NS_EVENT_FLAG_STOP_DISPATCH_IMMEDIATELY r=smaug --- content/events/src/nsDOMEvent.cpp | 8 ++++---- content/events/src/nsDOMUIEvent.cpp | 9 ++------- content/events/src/nsEventDispatcher.cpp | 16 ++++++++-------- content/events/src/nsEventListenerManager.cpp | 2 +- content/events/src/nsEventListenerManager.h | 2 +- content/events/src/nsEventStateManager.cpp | 8 ++++---- content/events/src/nsIMEStateManager.cpp | 3 +-- content/html/content/src/nsHTMLFormElement.cpp | 2 +- widget/nsGUIEvent.h | 10 +++++++--- 9 files changed, 29 insertions(+), 31 deletions(-) diff --git a/content/events/src/nsDOMEvent.cpp b/content/events/src/nsDOMEvent.cpp index e75873f065f..c9e1b06d345 100644 --- a/content/events/src/nsDOMEvent.cpp +++ b/content/events/src/nsDOMEvent.cpp @@ -361,15 +361,15 @@ nsDOMEvent::GetTimeStamp(uint64_t* aTimeStamp) NS_IMETHODIMP nsDOMEvent::StopPropagation() { - mEvent->flags |= NS_EVENT_FLAG_STOP_DISPATCH; + mEvent->mFlags.mPropagationStopped = true; return NS_OK; } NS_IMETHODIMP nsDOMEvent::StopImmediatePropagation() { - mEvent->flags |= - (NS_EVENT_FLAG_STOP_DISPATCH_IMMEDIATELY | NS_EVENT_FLAG_STOP_DISPATCH); + mEvent->mFlags.mPropagationStopped = true; + mEvent->mFlags.mImmediatePropagationStopped = true; return NS_OK; } @@ -813,7 +813,7 @@ nsDOMEvent::SetTarget(nsIDOMEventTarget* aTarget) NS_IMETHODIMP_(bool) nsDOMEvent::IsDispatchStopped() { - return !!(mEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH); + return mEvent->mFlags.mPropagationStopped; } NS_IMETHODIMP_(nsEvent*) diff --git a/content/events/src/nsDOMUIEvent.cpp b/content/events/src/nsDOMUIEvent.cpp index 02189970c43..2e37c88afe4 100644 --- a/content/events/src/nsDOMUIEvent.cpp +++ b/content/events/src/nsDOMUIEvent.cpp @@ -292,19 +292,14 @@ NS_IMETHODIMP nsDOMUIEvent::GetCancelBubble(bool* aCancelBubble) { NS_ENSURE_ARG_POINTER(aCancelBubble); - *aCancelBubble = - (mEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH) ? true : false; + *aCancelBubble = mEvent->mFlags.mPropagationStopped; return NS_OK; } NS_IMETHODIMP nsDOMUIEvent::SetCancelBubble(bool aCancelBubble) { - if (aCancelBubble) { - mEvent->flags |= NS_EVENT_FLAG_STOP_DISPATCH; - } else { - mEvent->flags &= ~NS_EVENT_FLAG_STOP_DISPATCH; - } + mEvent->mFlags.mPropagationStopped = aCancelBubble; return NS_OK; } diff --git a/content/events/src/nsEventDispatcher.cpp b/content/events/src/nsEventDispatcher.cpp index cb997fe2849..0a4233f8557 100644 --- a/content/events/src/nsEventDispatcher.cpp +++ b/content/events/src/nsEventDispatcher.cpp @@ -164,7 +164,7 @@ public: if (WantsWillHandleEvent()) { mTarget->WillHandleEvent(aVisitor); } - if (aVisitor.mEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH) { + if (aVisitor.mEvent->mFlags.mPropagationStopped) { return NS_OK; } if (!mManager) { @@ -279,7 +279,7 @@ nsEventTargetChainItem::HandleEventTargetChain(nsEventChainPostVisitor& aVisitor while (item->mChild) { if ((!(aVisitor.mEvent->flags & NS_EVENT_FLAG_NO_CONTENT_DISPATCH) || item->ForceContentDispatch()) && - !(aVisitor.mEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH)) { + !aVisitor.mEvent->mFlags.mPropagationStopped) { item->HandleEvent(aVisitor, aFlags & NS_EVENT_CAPTURE_MASK, aMayHaveNewListenerManagers || createdELMs != nsEventListenerManager::sCreatedCount, @@ -304,7 +304,7 @@ nsEventTargetChainItem::HandleEventTargetChain(nsEventChainPostVisitor& aVisitor // Target aVisitor.mEvent->mFlags.mInBubblingPhase = true; - if (!(aVisitor.mEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH) && + if (!aVisitor.mEvent->mFlags.mPropagationStopped && (!(aVisitor.mEvent->flags & NS_EVENT_FLAG_NO_CONTENT_DISPATCH) || item->ForceContentDispatch())) { // FIXME Should use aFlags & NS_EVENT_BUBBLE_MASK because capture phase @@ -333,7 +333,7 @@ nsEventTargetChainItem::HandleEventTargetChain(nsEventChainPostVisitor& aVisitor if (aVisitor.mEvent->mFlags.mBubbles || newTarget) { if ((!(aVisitor.mEvent->flags & NS_EVENT_FLAG_NO_CONTENT_DISPATCH) || item->ForceContentDispatch()) && - !(aVisitor.mEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH)) { + !aVisitor.mEvent->mFlags.mPropagationStopped) { item->HandleEvent(aVisitor, aFlags & NS_EVENT_BUBBLE_MASK, createdELMs != nsEventListenerManager::sCreatedCount, aPusher); @@ -349,8 +349,8 @@ nsEventTargetChainItem::HandleEventTargetChain(nsEventChainPostVisitor& aVisitor if (!(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT)) { // Dispatch to the system event group. Make sure to clear the // STOP_DISPATCH flag since this resets for each event group. - aVisitor.mEvent->flags &= - ~(NS_EVENT_FLAG_STOP_DISPATCH | NS_EVENT_FLAG_STOP_DISPATCH_IMMEDIATELY); + aVisitor.mEvent->mFlags.mPropagationStopped = false; + aVisitor.mEvent->mFlags.mImmediatePropagationStopped = false; // Setting back the original target of the event. aVisitor.mEvent->target = aVisitor.mEvent->originalTarget; @@ -372,8 +372,8 @@ nsEventTargetChainItem::HandleEventTargetChain(nsEventChainPostVisitor& aVisitor // After dispatch, clear all the propagation flags so that // system group listeners don't affect to the event. - aVisitor.mEvent->flags &= - ~(NS_EVENT_FLAG_STOP_DISPATCH | NS_EVENT_FLAG_STOP_DISPATCH_IMMEDIATELY); + aVisitor.mEvent->mFlags.mPropagationStopped = false; + aVisitor.mEvent->mFlags.mImmediatePropagationStopped = false; } return NS_OK; diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp index 4dc2ca0b7f5..aa8084a389a 100644 --- a/content/events/src/nsEventListenerManager.cpp +++ b/content/events/src/nsEventListenerManager.cpp @@ -945,7 +945,7 @@ nsEventListenerManager::HandleEventInternal(nsPresContext* aPresContext, nsAutoPopupStatePusher popupStatePusher(nsDOMEvent::GetEventPopupControlState(aEvent)); bool hasListener = false; while (iter.HasMore()) { - if (aEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH_IMMEDIATELY) { + if (aEvent->mFlags.mImmediatePropagationStopped) { break; } nsListenerStruct* ls = &iter.GetNext(); diff --git a/content/events/src/nsEventListenerManager.h b/content/events/src/nsEventListenerManager.h index 0d418ff6fe6..3ce7bdc699b 100644 --- a/content/events/src/nsEventListenerManager.h +++ b/content/events/src/nsEventListenerManager.h @@ -129,7 +129,7 @@ public: nsEventStatus* aEventStatus, nsCxPusher* aPusher) { - if (mListeners.IsEmpty() || aEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH) { + if (mListeners.IsEmpty() || aEvent->mFlags.mPropagationStopped) { return; } diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index 682667535c2..b3a220d26f9 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -1237,7 +1237,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext, // Will not be handled locally, remote the event if (GetCrossProcessTarget()->SendTextEvent(*textEvent)) { // Cancel local dispatching - aEvent->flags |= NS_EVENT_FLAG_STOP_DISPATCH; + aEvent->mFlags.mPropagationStopped = true; } } } @@ -1264,7 +1264,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext, // Will not be handled locally, remote the event if (GetCrossProcessTarget()->SendCompositionEvent(*compositionEvent)) { // Cancel local dispatching - aEvent->flags |= NS_EVENT_FLAG_STOP_DISPATCH; + aEvent->mFlags.mPropagationStopped = true; } } } @@ -2155,7 +2155,7 @@ nsEventStateManager::GenerateDragGesture(nsPresContext* aPresContext, targetContent, selection); if (dragStarted) { sActiveESM = nullptr; - aEvent->flags |= NS_EVENT_FLAG_STOP_DISPATCH; + aEvent->mFlags.mPropagationStopped = true; } } @@ -4178,7 +4178,7 @@ nsEventStateManager::GenerateMouseEnterExit(nsGUIEvent* aEvent) } else if (aEvent->refPoint == sSynthCenteringPoint) { // This is the "synthetic native" event we dispatched to re-center the // pointer. Cancel it so we don't expose the centering move to content. - aEvent->flags |= NS_EVENT_FLAG_STOP_DISPATCH; + aEvent->mFlags.mPropagationStopped = true; // Clear sSynthCenteringPoint so we don't cancel other events // targeted at the center. sSynthCenteringPoint = kInvalidRefPoint; diff --git a/content/events/src/nsIMEStateManager.cpp b/content/events/src/nsIMEStateManager.cpp index 8174e704f5c..69a957ab6c3 100644 --- a/content/events/src/nsIMEStateManager.cpp +++ b/content/events/src/nsIMEStateManager.cpp @@ -549,8 +549,7 @@ nsIMEStateManager::DispatchCompositionEvent(nsINode* aEventTargetNode, { MOZ_ASSERT(aEvent->eventStructType == NS_COMPOSITION_EVENT || aEvent->eventStructType == NS_TEXT_EVENT); - if (!aEvent->mFlags.mIsTrusted || - (aEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH) != 0) { + if (!aEvent->mFlags.mIsTrusted || aEvent->mFlags.mPropagationStopped) { return; } diff --git a/content/html/content/src/nsHTMLFormElement.cpp b/content/html/content/src/nsHTMLFormElement.cpp index c4bab665c63..13fa082e9d1 100644 --- a/content/html/content/src/nsHTMLFormElement.cpp +++ b/content/html/content/src/nsHTMLFormElement.cpp @@ -584,7 +584,7 @@ nsHTMLFormElement::WillHandleEvent(nsEventChainPostVisitor& aVisitor) aVisitor.mEvent->message == NS_FORM_RESET) && aVisitor.mEvent->mFlags.mInBubblingPhase && aVisitor.mEvent->originalTarget != static_cast(this)) { - aVisitor.mEvent->flags |= NS_EVENT_FLAG_STOP_DISPATCH; + aVisitor.mEvent->mFlags.mPropagationStopped = true; } return NS_OK; } diff --git a/widget/nsGUIEvent.h b/widget/nsGUIEvent.h index 03d295e5f29..cde46004348 100644 --- a/widget/nsGUIEvent.h +++ b/widget/nsGUIEvent.h @@ -111,7 +111,6 @@ enum nsEventStructType { #define NS_EVENT_FLAG_NONE 0x0000 #define NS_EVENT_FLAG_BUBBLE 0x0002 #define NS_EVENT_FLAG_CAPTURE 0x0004 -#define NS_EVENT_FLAG_STOP_DISPATCH 0x0008 #define NS_EVENT_FLAG_NO_DEFAULT 0x0010 #define NS_PRIV_EVENT_FLAG_SCRIPT 0x0080 #define NS_EVENT_FLAG_NO_CONTENT_DISPATCH 0x0100 @@ -139,8 +138,6 @@ enum nsEventStructType { #define NS_EVENT_RETARGET_TO_NON_NATIVE_ANONYMOUS 0x40000 -#define NS_EVENT_FLAG_STOP_DISPATCH_IMMEDIATELY 0x80000 - #define NS_EVENT_FLAG_DONT_FORWARD_CROSS_PROCESS 0x100000 #define NS_EVENT_CAPTURE_MASK (~(NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_NO_CONTENT_DISPATCH)) @@ -526,6 +523,13 @@ public: // If mBubbles is true, the event can bubble. Otherwise, cannot be handled // in bubbling phase. bool mBubbles : 1; + // If mPropagationStopped is true, nsDOMEvent::StopPropagation() or + // nsDOMEvent::StopImmediatePropagation() has been called. + bool mPropagationStopped : 1; + // If mImmediatePropagationStopped is true, + // nsDOMEvent::StopImmediatePropagation() has been called. + // Note that mPropagationStopped must be true when this is true. + bool mImmediatePropagationStopped : 1; // If the event is being handled in target phase, returns true. bool InTargetPhase() const