Bug 813445 part.3 Remove NS_EVENT_FLAG_CANT_CANCEL and NS_EVENT_FLAG_CANT_BUBBLE r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Sun, 16 Dec 2012 10:26:03 +0900
changeset 125275 70c9aa60b939aa2ac24d46cc0ea54b91fd5be8cd
parent 125274 00e871fde7d259f324d962019b3b35d1d713d3af
child 125276 6361db1cb4dbb1670b71c71ab186a7cfc7bb029c
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs813445
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 813445 part.3 Remove NS_EVENT_FLAG_CANT_CANCEL and NS_EVENT_FLAG_CANT_BUBBLE r=smaug
content/base/src/nsScriptElement.cpp
content/events/public/nsMutationEvent.h
content/events/src/nsDOMCompositionEvent.cpp
content/events/src/nsDOMEvent.cpp
content/events/src/nsEventDispatcher.cpp
content/html/content/src/nsHTMLMenuElement.cpp
content/smil/nsDOMTimeEvent.cpp
content/svg/content/src/nsDOMSVGEvent.cpp
content/svg/content/src/nsDOMSVGZoomEvent.cpp
dom/base/nsFocusManager.cpp
dom/base/nsGlobalWindow.cpp
editor/libeditor/base/nsEditor.cpp
layout/base/nsDocumentViewer.cpp
layout/generic/nsGfxScrollFrame.cpp
layout/xul/base/src/nsImageBoxFrame.cpp
layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
parser/html/nsHtml5SVGLoadDispatcher.cpp
widget/nsGUIEvent.h
--- a/content/base/src/nsScriptElement.cpp
+++ b/content/base/src/nsScriptElement.cpp
@@ -54,20 +54,18 @@ nsScriptElement::ScriptEvaluated(nsresul
       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;
     nsEvent event(true, type);
-    if (type == NS_LOAD) {
-      // Load event doesn't bubble.
-      event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
-    }
+    // Load event doesn't bubble.
+    event.mFlags.mBubbles = (type != NS_LOAD);
 
     nsEventDispatcher::Dispatch(cont, presContext, &event, nullptr, &status);
   }
 
   return rv;
 }
 
 void
--- a/content/events/public/nsMutationEvent.h
+++ b/content/events/public/nsMutationEvent.h
@@ -12,17 +12,17 @@
 
 class nsMutationEvent : public nsEvent
 {
 public:
   nsMutationEvent(bool isTrusted, uint32_t msg)
     : nsEvent(isTrusted, msg, NS_MUTATION_EVENT),
       mAttrChange(0)
   {
-    flags |= NS_EVENT_FLAG_CANT_CANCEL;
+    mFlags.mCancelable = false;
   }
 
   nsCOMPtr<nsIDOMNode> mRelatedNode;
   nsCOMPtr<nsIAtom>    mAttrName;
   nsCOMPtr<nsIAtom>    mPrevAttrValue;
   nsCOMPtr<nsIAtom>    mNewAttrValue;
   unsigned short       mAttrChange;
 };
--- a/content/events/src/nsDOMCompositionEvent.cpp
+++ b/content/events/src/nsDOMCompositionEvent.cpp
@@ -19,17 +19,17 @@ nsDOMCompositionEvent::nsDOMCompositionE
     mEventIsInternal = false;
   } else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
 
     // XXX compositionstart is cancelable in draft of DOM3 Events.
     //     However, it doesn't make sence for us, we cannot cancel composition
     //     when we sends compositionstart event.
-    mEvent->flags |= NS_EVENT_FLAG_CANT_CANCEL;
+    mEvent->mFlags.mCancelable = false;
   }
 
   mData = static_cast<nsCompositionEvent*>(mEvent)->data;
   // TODO: Native event should have locale information.
 }
 
 nsDOMCompositionEvent::~nsDOMCompositionEvent()
 {
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -335,24 +335,24 @@ nsDOMEvent::GetEventPhase(uint16_t* aEve
     *aEventPhase = nsIDOMEvent::NONE;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMEvent::GetBubbles(bool* aBubbles)
 {
-  *aBubbles = !(mEvent->flags & NS_EVENT_FLAG_CANT_BUBBLE);
+  *aBubbles = mEvent->mFlags.mBubbles;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMEvent::GetCancelable(bool* aCancelable)
 {
-  *aCancelable = !(mEvent->flags & NS_EVENT_FLAG_CANT_CANCEL);
+  *aCancelable = mEvent->mFlags.mCancelable;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMEvent::GetTimeStamp(uint64_t* aTimeStamp)
 {
   *aTimeStamp = mEvent->time;
   return NS_OK;
@@ -422,17 +422,17 @@ nsDOMEvent::GetIsTrusted(bool *aIsTruste
 {
   *aIsTrusted = mEvent->mFlags.mIsTrusted;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMEvent::PreventDefault()
 {
-  if (!(mEvent->flags & NS_EVENT_FLAG_CANT_CANCEL)) {
+  if (mEvent->mFlags.mCancelable) {
     mEvent->flags |= NS_EVENT_FLAG_NO_DEFAULT;
 
     // Need to set an extra flag for drag events.
     if (mEvent->eventStructType == NS_DRAG_EVENT && mEvent->mFlags.mIsTrusted) {
       nsCOMPtr<nsINode> node = do_QueryInterface(mEvent->currentTarget);
       if (!node) {
         nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(mEvent->currentTarget);
         if (win) {
@@ -466,27 +466,18 @@ nsDOMEvent::InitEvent(const nsAString& a
     // Ensure the caller is permitted to dispatch trusted DOM events.
     if (!nsContentUtils::IsCallerChrome()) {
       SetTrusted(false);
     }
   }
 
   SetEventType(aEventTypeArg);
 
-  if (aCanBubbleArg) {
-    mEvent->flags &= ~NS_EVENT_FLAG_CANT_BUBBLE;
-  } else {
-    mEvent->flags |= NS_EVENT_FLAG_CANT_BUBBLE;
-  }
-
-  if (aCancelableArg) {
-    mEvent->flags &= ~NS_EVENT_FLAG_CANT_CANCEL;
-  } else {
-    mEvent->flags |= NS_EVENT_FLAG_CANT_CANCEL;
-  }
+  mEvent->mFlags.mBubbles = aCanBubbleArg;
+  mEvent->mFlags.mCancelable = aCancelableArg;
 
   // Clearing the old targets, so that the event is targeted correctly when
   // re-dispatching it.
   mEvent->target = nullptr;
   mEvent->originalTarget = nullptr;
   mCachedType = aEventTypeArg;
   return NS_OK;
 }
--- a/content/events/src/nsEventDispatcher.cpp
+++ b/content/events/src/nsEventDispatcher.cpp
@@ -325,17 +325,17 @@ nsEventTargetChainItem::HandleEventTarge
   while (item) {
     nsIDOMEventTarget* newTarget = item->GetNewTarget();
     if (newTarget) {
       // Item is at anonymous boundary. Need to retarget for the current item
       // and for parent items.
       aVisitor.mEvent->target = newTarget;
     }
 
-    if (!(aVisitor.mEvent->flags & NS_EVENT_FLAG_CANT_BUBBLE) || newTarget) {
+    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)) {
         item->HandleEvent(aVisitor, aFlags & NS_EVENT_BUBBLE_MASK,
                           createdELMs != nsEventListenerManager::sCreatedCount,
                           aPusher);
       }
       if (aFlags & NS_EVENT_FLAG_SYSTEM_EVENT) {
--- a/content/html/content/src/nsHTMLMenuElement.cpp
+++ b/content/html/content/src/nsHTMLMenuElement.cpp
@@ -81,17 +81,18 @@ nsHTMLMenuElement::SendShowEvent()
   NS_ENSURE_TRUE(nsContentUtils::IsCallerChrome(), NS_ERROR_DOM_SECURITY_ERR);
 
   nsCOMPtr<nsIDocument> document = GetCurrentDoc();
   if (!document) {
     return NS_ERROR_FAILURE;
   }
 
   nsEvent event(true, NS_SHOW_EVENT);
-  event.flags |= NS_EVENT_FLAG_CANT_CANCEL | NS_EVENT_FLAG_CANT_BUBBLE;
+  event.mFlags.mBubbles = false;
+  event.mFlags.mCancelable = false;
 
   nsCOMPtr<nsIPresShell> shell = document->GetShell();
   if (!shell) {
     return NS_ERROR_FAILURE;
   }
  
   nsRefPtr<nsPresContext> presContext = shell->GetPresContext();
   nsEventStatus status = nsEventStatus_eIgnore;
--- a/content/smil/nsDOMTimeEvent.cpp
+++ b/content/smil/nsDOMTimeEvent.cpp
@@ -20,18 +20,18 @@ nsDOMTimeEvent::nsDOMTimeEvent(nsPresCon
     mEvent->eventStructType = NS_SMIL_TIME_EVENT;
   }
 
   if (mEvent->eventStructType == NS_SMIL_TIME_EVENT) {
     nsUIEvent* event = static_cast<nsUIEvent*>(mEvent);
     mDetail = event->detail;
   }
 
-  mEvent->flags |= NS_EVENT_FLAG_CANT_BUBBLE |
-                   NS_EVENT_FLAG_CANT_CANCEL;
+  mEvent->mFlags.mBubbles = false;
+  mEvent->mFlags.mCancelable = false;
 
   if (mPresContext) {
     nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
     if (container) {
       nsCOMPtr<nsIDOMWindow> window = do_GetInterface(container);
       if (window) {
         mView = do_QueryInterface(window);
       }
--- a/content/svg/content/src/nsDOMSVGEvent.cpp
+++ b/content/svg/content/src/nsDOMSVGEvent.cpp
@@ -18,20 +18,19 @@ nsDOMSVGEvent::nsDOMSVGEvent(nsPresConte
     mEventIsInternal = false;
   }
   else {
     mEventIsInternal = true;
     mEvent->eventStructType = NS_SVG_EVENT;
     mEvent->time = PR_Now();
   }
 
-  mEvent->flags |= NS_EVENT_FLAG_CANT_CANCEL;
-  if (mEvent->message == NS_SVG_LOAD || mEvent->message == NS_SVG_UNLOAD) {
-    mEvent->flags |= NS_EVENT_FLAG_CANT_BUBBLE;
-  }
+  mEvent->mFlags.mCancelable = false;
+  mEvent->mFlags.mBubbles =
+    (mEvent->message != NS_SVG_LOAD && mEvent->message != NS_SVG_UNLOAD);
 }
 
 //----------------------------------------------------------------------
 // nsISupports methods:
 
 NS_IMPL_ADDREF_INHERITED(nsDOMSVGEvent, nsDOMEvent)
 NS_IMPL_RELEASE_INHERITED(nsDOMSVGEvent, nsDOMEvent)
 
--- a/content/svg/content/src/nsDOMSVGZoomEvent.cpp
+++ b/content/svg/content/src/nsDOMSVGZoomEvent.cpp
@@ -27,17 +27,17 @@ nsDOMSVGZoomEvent::nsDOMSVGZoomEvent(nsP
     mEventIsInternal = false;
   }
   else {
     mEventIsInternal = true;
     mEvent->eventStructType = NS_SVGZOOM_EVENT;
     mEvent->time = PR_Now();
   }
 
-  mEvent->flags |= NS_EVENT_FLAG_CANT_CANCEL;
+  mEvent->mFlags.mCancelable = false;
 
   // We must store the "Previous" and "New" values before this event is
   // dispatched. Reading the values from the root 'svg' element after we've
   // been dispatched is not an option since event handler code may change
   // currentScale and currentTranslate in response to this event.
   nsIPresShell *presShell;
   if (mPresContext && (presShell = mPresContext->GetPresShell())) {
     nsIDocument *doc = presShell->GetDocument();
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -1857,17 +1857,17 @@ public:
                  nsPresContext* aContext, bool aWindowRaised,
                  bool aIsRefocus)
   : mTarget(aTarget), mType(aType), mContext(aContext),
     mWindowRaised(aWindowRaised), mIsRefocus(aIsRefocus) {}
 
   NS_IMETHOD Run()
   {
     nsFocusEvent event(true, mType);
-    event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
+    event.mFlags.mBubbles = false;
     event.fromRaise = mWindowRaised;
     event.isRefocus = mIsRefocus;
     return nsEventDispatcher::Dispatch(mTarget, mContext, &event);
   }
 
   nsCOMPtr<nsISupports>   mTarget;
   uint32_t                mType;
   nsRefPtr<nsPresContext> mContext;
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -2659,17 +2659,17 @@ nsGlobalWindow::PostHandleEvent(nsEventC
 
     if (content && GetParentInternal() &&
         itemType != nsIDocShellTreeItem::typeChrome) {
       // If we're not in chrome, or at a chrome boundary, fire the
       // onload event for the frame element.
 
       nsEventStatus status = nsEventStatus_eIgnore;
       nsEvent event(aVisitor.mEvent->mFlags.mIsTrusted, NS_LOAD);
-      event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
+      event.mFlags.mBubbles = false;
 
       // Most of the time we could get a pres context to pass in here,
       // but not always (i.e. if this window is not shown there won't
       // be a pres context available). Since we're not firing a GUI
       // event we don't need a pres context anyway so we just pass
       // null as the pres context all the time here.
       nsEventDispatcher::Dispatch(content, nullptr, &event, nullptr, &status);
     }
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -1814,17 +1814,17 @@ public:
     }
 
     nsCOMPtr<nsIPresShell> ps = mEditor->GetPresShell();
     if (!ps) {
       return NS_OK;
     }
 
     nsEvent inputEvent(mIsTrusted, NS_FORM_INPUT);
-    inputEvent.flags |= NS_EVENT_FLAG_CANT_CANCEL;
+    inputEvent.mFlags.mCancelable = false;
     inputEvent.time = static_cast<uint64_t>(PR_Now() / 1000);
     nsEventStatus status = nsEventStatus_eIgnore;
     nsresult rv =
       ps->HandleEventWithTarget(&inputEvent, nullptr, mTarget, &status);
     NS_ENSURE_SUCCESS(rv, NS_OK); // print the warning if error
     return NS_OK;
   }
 
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -1003,17 +1003,17 @@ nsDocumentViewer::LoadComplete(nsresult 
   // XXXbz imagelib kills off the document load for a full-page image with
   // NS_ERROR_PARSED_DATA_CACHED if it's in the cache.  So we want to treat
   // that one as a success code; otherwise whether we fire onload for the image
   // will depend on whether it's cached!
   if(window &&
      (NS_SUCCEEDED(aStatus) || aStatus == NS_ERROR_PARSED_DATA_CACHED)) {
     nsEventStatus status = nsEventStatus_eIgnore;
     nsEvent event(true, NS_LOAD);
-    event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
+    event.mFlags.mBubbles = false;
      // XXX Dispatching to |window|, but using |document| as the target.
     event.target = mDocument;
 
     // If the document presentation is being restored, we don't want to fire
     // onload to the document content since that would likely confuse scripts
     // on the page.
 
     nsIDocShell *docShell = window->GetDocShell();
@@ -1284,17 +1284,17 @@ nsDocumentViewer::PageHide(bool aIsUnloa
       // Fail if no window is available...
       NS_WARNING("window not set for document!");
       return NS_ERROR_NULL_POINTER;
     }
 
     // Now, fire an Unload event to the document...
     nsEventStatus status = nsEventStatus_eIgnore;
     nsEvent event(true, NS_PAGE_UNLOAD);
-    event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
+    event.mFlags.mBubbles = false;
     // XXX Dispatching to |window|, but using |document| as the target.
     event.target = mDocument;
 
     // Never permit popups from the unload handler, no matter how we get
     // here.
     nsAutoPopupStatePusher popupStatePusher(openAbused, true);
 
     nsEventDispatcher::Dispatch(window, mPresContext, &event, nullptr, &status);
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -2842,17 +2842,17 @@ nsGfxScrollFrameInner::FireScrollEvent()
   if (mIsRoot) {
     nsIDocument* doc = content->GetCurrentDoc();
     if (doc) {
       nsEventDispatcher::Dispatch(doc, prescontext, &event, nullptr,  &status);
     }
   } else {
     // scroll events fired at elements don't bubble (although scroll events
     // fired at documents do, to the window)
-    event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
+    event.mFlags.mBubbles = false;
     nsEventDispatcher::Dispatch(content, prescontext, &event, nullptr, &status);
   }
 }
 
 void
 nsGfxScrollFrameInner::PostScrollEvent()
 {
   if (mScrollEvent.IsPending())
--- a/layout/xul/base/src/nsImageBoxFrame.cpp
+++ b/layout/xul/base/src/nsImageBoxFrame.cpp
@@ -77,17 +77,17 @@ nsImageBoxFrameEvent::Run()
   nsRefPtr<nsPresContext> pres_context = pres_shell->GetPresContext();
   if (!pres_context) {
     return NS_OK;
   }
 
   nsEventStatus status = nsEventStatus_eIgnore;
   nsEvent event(true, mMessage);
 
-  event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
+  event.mFlags.mBubbles = false;
   nsEventDispatcher::Dispatch(mContent, pres_context, &event, nullptr, &status);
   return NS_OK;
 }
 
 // Fire off an event that'll asynchronously call the image elements
 // 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
--- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
+++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
@@ -4434,17 +4434,17 @@ nsTreeBodyFrame::ScrollEvent::Run()
 
 
 void
 nsTreeBodyFrame::FireScrollEvent()
 {
   mScrollEvent.Forget();
   nsScrollbarEvent event(true, NS_SCROLL_EVENT, nullptr);
   // scroll events fired at elements don't bubble
-  event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
+  event.mFlags.mBubbles = false;
   nsEventDispatcher::Dispatch(GetContent(), PresContext(), &event);
 }
 
 void
 nsTreeBodyFrame::PostScrollEvent()
 {
   if (mScrollEvent.IsPending())
     return;
--- a/parser/html/nsHtml5SVGLoadDispatcher.cpp
+++ b/parser/html/nsHtml5SVGLoadDispatcher.cpp
@@ -15,17 +15,17 @@ nsHtml5SVGLoadDispatcher::nsHtml5SVGLoad
   mDocument->BlockOnload();
 }
 
 NS_IMETHODIMP
 nsHtml5SVGLoadDispatcher::Run()
 {
   nsEvent event(true, NS_SVG_LOAD);
   event.eventStructType = NS_SVG_EVENT;
-  event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
+  event.mFlags.mBubbles = false;
   // Do we care about forcing presshell creation if it hasn't happened yet?
   // That is, should this code flush or something?  Does it really matter?
   // For that matter, do we really want to try getting the prescontext?
   // Does this event ever want one?
   nsRefPtr<nsPresContext> ctx;
   nsCOMPtr<nsIPresShell> shell = mElement->OwnerDoc()->GetShell();
   if (shell) {
     ctx = shell->GetPresContext();
--- a/widget/nsGUIEvent.h
+++ b/widget/nsGUIEvent.h
@@ -108,18 +108,16 @@ enum nsEventStructType {
 // These flags are sort of a mess. They're sort of shared between event
 // listener flags and event flags, but only some of them. You've been
 // warned!
 #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_EVENT_FLAG_CANT_CANCEL         0x0020
-#define NS_EVENT_FLAG_CANT_BUBBLE         0x0040
 #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
@@ -517,16 +515,22 @@ public:
   // If mIsTrusted is true, the event is a trusted event.  Otherwise, it's
   // an untrusted event.
   bool    mIsTrusted : 1;
   // If mInBubblingPhase is true, the event is in bubbling phase or target
   // phase.
   bool    mInBubblingPhase : 1;
   // If mInCapturePhase is true, the event is in capture phase or target phase.
   bool    mInCapturePhase : 1;
+  // If mCancelable is true, the event can be consumed.  I.e., calling
+  // nsDOMEvent::PreventDefault() can prevent the default action.
+  bool    mCancelable : 1;
+  // If mBubbles is true, the event can bubble.  Otherwise, cannot be handled
+  // in bubbling phase.
+  bool    mBubbles : 1;
 
   // If the event is being handled in target phase, returns true.
   bool InTargetPhase() const
   {
     return (mInBubblingPhase && mInCapturePhase);
   }
 
   EventFlags()
@@ -577,16 +581,18 @@ protected:
       refPoint(0, 0),
       lastRefPoint(0, 0),
       time(0),
       flags(NS_EVENT_FLAG_NONE),
       userType(0)
   {
     MOZ_COUNT_CTOR(nsEvent);
     mFlags.mIsTrusted = isTrusted;
+    mFlags.mCancelable = true;
+    mFlags.mBubbles = true;
   }
 
   nsEvent()
   {
     MOZ_COUNT_CTOR(nsEvent);
   }
 
 public:
@@ -596,16 +602,18 @@ public:
       refPoint(0, 0),
       lastRefPoint(0, 0),
       time(0),
       flags(NS_EVENT_FLAG_NONE),
       userType(0)
   {
     MOZ_COUNT_CTOR(nsEvent);
     mFlags.mIsTrusted = isTrusted;
+    mFlags.mCancelable = true;
+    mFlags.mBubbles = true;
   }
 
   ~nsEvent()
   {
     MOZ_COUNT_DTOR(nsEvent);
   }
 
   nsEvent(const nsEvent& aOther)
@@ -907,42 +915,44 @@ protected:
   nsMouseEvent(bool isTrusted, uint32_t msg, nsIWidget *w,
                nsEventStructType structType, reasonType aReason)
     : nsMouseEvent_base(isTrusted, msg, w, structType),
       acceptActivation(false), ignoreRootScrollFrame(false),
       reason(aReason), context(eNormal), exit(eChild), clickCount(0)
   {
     switch (msg) {
       case NS_MOUSE_MOVE:
-        flags |= NS_EVENT_FLAG_CANT_CANCEL;
+        mFlags.mCancelable = false;
         break;
       case NS_MOUSEENTER:
       case NS_MOUSELEAVE:
-        flags |= (NS_EVENT_FLAG_CANT_CANCEL & NS_EVENT_FLAG_CANT_BUBBLE);
+        mFlags.mBubbles = false;
+        mFlags.mCancelable = false;
         break;
       default:
         break;
     }
   }
 
 public:
 
   nsMouseEvent(bool isTrusted, uint32_t msg, nsIWidget *w,
                reasonType aReason, contextType aContext = eNormal)
     : nsMouseEvent_base(isTrusted, msg, w, NS_MOUSE_EVENT),
       acceptActivation(false), ignoreRootScrollFrame(false),
       reason(aReason), context(aContext), exit(eChild), clickCount(0)
   {
     switch (msg) {
       case NS_MOUSE_MOVE:
-        flags |= NS_EVENT_FLAG_CANT_CANCEL;
+        mFlags.mCancelable = false;
         break;
       case NS_MOUSEENTER:
       case NS_MOUSELEAVE:
-        flags |= (NS_EVENT_FLAG_CANT_CANCEL | NS_EVENT_FLAG_CANT_BUBBLE);
+        mFlags.mBubbles = false;
+        mFlags.mCancelable = false;
         break;
       case NS_CONTEXTMENU:
         button = (context == eNormal) ? eRightButton : eLeftButton;
         break;
       default:
         break;
     }
   }
@@ -977,21 +987,20 @@ public:
 
 class nsDragEvent : public nsMouseEvent
 {
 public:
   nsDragEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
     : nsMouseEvent(isTrusted, msg, w, NS_DRAG_EVENT, eReal),
       userCancelled(false)
   {
-    if (msg == NS_DRAGDROP_EXIT_SYNTH ||
-        msg == NS_DRAGDROP_LEAVE_SYNTH ||
-        msg == NS_DRAGDROP_END) {
-      flags |= NS_EVENT_FLAG_CANT_CANCEL;
-    }
+    mFlags.mCancelable =
+      (msg != NS_DRAGDROP_EXIT_SYNTH &&
+       msg != NS_DRAGDROP_LEAVE_SYNTH &&
+       msg != NS_DRAGDROP_END);
   }
 
   nsCOMPtr<nsIDOMDataTransfer> dataTransfer;
   bool userCancelled;
 };
 
 /**
  * Keyboard event
@@ -1204,17 +1213,17 @@ public:
 
 public:
   nsCompositionEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
     : nsGUIEvent(isTrusted, msg, w, NS_COMPOSITION_EVENT)
   {
     // 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.
-    flags |= NS_EVENT_FLAG_CANT_CANCEL;
+    mFlags.mCancelable = false;
   }
 
   nsString data;
 };
 
 /**
  * nsMouseScrollEvent is used for legacy DOM mouse scroll events, i.e.,
  * DOMMouseScroll and MozMousePixelScroll event.  These events are NOT hanbled