Bug 813445 part.7 Remove NS_EVENT_DISPATCHED and NS_EVENT_FLAG_DISPATCHING r=smaug

This commit is contained in:
Masayuki Nakano 2012-12-16 10:26:04 +09:00
parent 0adde071a4
commit f214472f22
4 changed files with 13 additions and 23 deletions

View File

@ -53,7 +53,7 @@ nsDOMDataContainerEvent::SetData(const nsAString& aKey, nsIVariant *aData)
NS_ENSURE_ARG(aData);
// Make sure this event isn't already being dispatched.
NS_ENSURE_STATE(!(NS_IS_EVENT_IN_DISPATCH(mEvent)));
NS_ENSURE_STATE(!mEvent->mFlags.mIsBeingDispatched);
NS_ENSURE_STATE(mData.IsInitialized());
mData.Put(aKey, aData);
return NS_OK;

View File

@ -460,7 +460,7 @@ NS_IMETHODIMP
nsDOMEvent::InitEvent(const nsAString& aEventTypeArg, bool aCanBubbleArg, bool aCancelableArg)
{
// Make sure this event isn't already being dispatched.
NS_ENSURE_TRUE(!NS_IS_EVENT_IN_DISPATCH(mEvent), NS_OK);
NS_ENSURE_TRUE(!mEvent->mFlags.mIsBeingDispatched, NS_OK);
if (mEvent->mFlags.mIsTrusted) {
// Ensure the caller is permitted to dispatch trusted DOM events.

View File

@ -450,7 +450,7 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget,
{
SAMPLE_LABEL("nsEventDispatcher", "Dispatch");
NS_ASSERTION(aEvent, "Trying to dispatch without nsEvent!");
NS_ENSURE_TRUE(!NS_IS_EVENT_IN_DISPATCH(aEvent),
NS_ENSURE_TRUE(!aEvent->mFlags.mIsBeingDispatched,
NS_ERROR_ILLEGAL_VALUE);
NS_ASSERTION(!aTargets || !aEvent->message, "Wrong parameters!");
@ -569,7 +569,7 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget,
nsCOMPtr<nsIContent> content = do_QueryInterface(aEvent->originalTarget);
bool isInAnon = (content && content->IsInAnonymousSubtree());
NS_MARK_EVENT_DISPATCH_STARTED(aEvent);
aEvent->mFlags.mIsBeingDispatched = true;
// Create visitor object and start event dispatching.
// PreHandleEvent for the original target.
@ -645,7 +645,8 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget,
nsEventTargetChainItem::Destroy(pool.GetPool(), targetEtci);
targetEtci = nullptr;
NS_MARK_EVENT_DISPATCH_DONE(aEvent);
aEvent->mFlags.mIsBeingDispatched = false;
aEvent->mFlags.mDispatchedAtLeastOnce = true;
if (!externalDOMEvent && preVisitor.mDOMEvent) {
// An nsDOMEvent was created while dispatching the event.
@ -675,7 +676,7 @@ nsEventDispatcher::DispatchDOMEvent(nsISupports* aTarget,
NS_ENSURE_TRUE(innerEvent, NS_ERROR_ILLEGAL_VALUE);
bool dontResetTrusted = false;
if (innerEvent->flags & NS_EVENT_DISPATCHED) {
if (innerEvent->mFlags.mDispatchedAtLeastOnce) {
innerEvent->target = nullptr;
innerEvent->originalTarget = nullptr;
} else {

View File

@ -114,9 +114,6 @@ enum nsEventStructType {
#define NS_PRIV_EVENT_FLAG_SCRIPT 0x0080
#define NS_EVENT_FLAG_NO_CONTENT_DISPATCH 0x0100
#define NS_EVENT_FLAG_SYSTEM_EVENT 0x0200
// Event has been dispatched at least once
#define NS_EVENT_DISPATCHED 0x0400
#define NS_EVENT_FLAG_DISPATCHING 0x0800
// When an event is synthesized for testing, this flag will be set.
// Note that this is currently used only with mouse events, because this
// flag is not needed on other events now. It could be added to other
@ -538,6 +535,12 @@ public:
// the first <label> element is clicked, that one may set this true.
// Then, the second <label> element won't handle the event.
bool mMultipleActionsPrevented : 1;
// If mIsBeingDispatched is true, the DOM event created from the event is
// dispatching into the DOM tree and not completed.
bool mIsBeingDispatched : 1;
// If mDispatchedAtLeastOnce is true, the event has been dispatched
// as a DOM event and the dispatch has been completed.
bool mDispatchedAtLeastOnce : 1;
// If the event is being handled in target phase, returns true.
bool InTargetPhase() const
@ -1828,20 +1831,6 @@ enum nsDragDropEventStatus {
(NS_IS_PLUGIN_EVENT(evnt) && \
!(static_cast<nsPluginEvent*>(evnt)->retargetToFocusedDocument))
// Mark an event as being dispatching.
#define NS_MARK_EVENT_DISPATCH_STARTED(event) \
(event)->flags |= NS_EVENT_FLAG_DISPATCHING;
#define NS_IS_EVENT_IN_DISPATCH(event) \
(((event)->flags & NS_EVENT_FLAG_DISPATCHING) != 0)
// Mark an event as being done dispatching.
#define NS_MARK_EVENT_DISPATCH_DONE(event) \
NS_ASSERTION(NS_IS_EVENT_IN_DISPATCH(event), \
"Event never got marked for dispatch!"); \
(event)->flags &= ~NS_EVENT_FLAG_DISPATCHING; \
(event)->flags |= NS_EVENT_DISPATCHED;
// Be aware the query content events and the selection events are a part of IME
// processing. So, you shouldn't use NS_IS_IME_EVENT macro directly in most
// cases, you should use NS_IS_IME_RELATED_EVENT instead.