Bug 983049 part.2 Rename nsEventChainPreVisitor to mozilla::EventChainPreVisitor r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 18 Mar 2014 13:48:19 +0900
changeset 174005 91778ceb580b76e4c1deb7bce53f4783781a004b
parent 174004 5c626ba48ddf81b32e98118361c2f9b1102dbda5
child 174006 d3964cfadc3c6b169d821eec7be2bdf2347431b3
push id41165
push usermasayuki@d-toybox.com
push dateTue, 18 Mar 2014 04:48:26 +0000
treeherdermozilla-inbound@735beb5ce026 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs983049
milestone31.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 983049 part.2 Rename nsEventChainPreVisitor to mozilla::EventChainPreVisitor r=smaug
content/base/public/Element.h
content/base/public/nsIContent.h
content/base/src/Attr.cpp
content/base/src/Attr.h
content/base/src/Element.cpp
content/base/src/FragmentOrElement.cpp
content/base/src/nsDocument.cpp
content/base/src/nsDocument.h
content/base/src/nsGenConImageContent.cpp
content/base/src/nsINode.cpp
content/base/src/nsInProcessTabChildGlobal.cpp
content/base/src/nsInProcessTabChildGlobal.h
content/html/content/src/HTMLAnchorElement.cpp
content/html/content/src/HTMLAnchorElement.h
content/html/content/src/HTMLAreaElement.cpp
content/html/content/src/HTMLAreaElement.h
content/html/content/src/HTMLButtonElement.cpp
content/html/content/src/HTMLButtonElement.h
content/html/content/src/HTMLFieldSetElement.cpp
content/html/content/src/HTMLFieldSetElement.h
content/html/content/src/HTMLFormElement.cpp
content/html/content/src/HTMLFormElement.h
content/html/content/src/HTMLImageElement.cpp
content/html/content/src/HTMLImageElement.h
content/html/content/src/HTMLInputElement.cpp
content/html/content/src/HTMLInputElement.h
content/html/content/src/HTMLLinkElement.cpp
content/html/content/src/HTMLLinkElement.h
content/html/content/src/HTMLMenuItemElement.cpp
content/html/content/src/HTMLMenuItemElement.h
content/html/content/src/HTMLOptGroupElement.cpp
content/html/content/src/HTMLOptGroupElement.h
content/html/content/src/HTMLSelectElement.cpp
content/html/content/src/HTMLSelectElement.h
content/html/content/src/HTMLTextAreaElement.cpp
content/html/content/src/HTMLTextAreaElement.h
content/html/content/src/nsGenericHTMLElement.cpp
content/html/content/src/nsGenericHTMLElement.h
content/mathml/content/src/nsMathMLElement.cpp
content/mathml/content/src/nsMathMLElement.h
content/svg/content/src/SVGAElement.cpp
content/svg/content/src/SVGAElement.h
content/svg/content/src/SVGSVGElement.cpp
content/svg/content/src/SVGSVGElement.h
content/xul/content/src/nsXULElement.cpp
content/xul/content/src/nsXULElement.h
dom/base/nsGlobalWindow.cpp
dom/base/nsWindowRoot.cpp
dom/base/nsWindowRoot.h
dom/devicestorage/nsDeviceStorage.cpp
dom/events/nsDOMEventTargetHelper.cpp
dom/events/nsEventDispatcher.cpp
dom/events/nsEventDispatcher.h
dom/file/ArchiveRequest.cpp
dom/file/ArchiveRequest.h
dom/file/FileRequest.cpp
dom/file/FileRequest.h
dom/file/LockedFile.cpp
dom/file/LockedFile.h
dom/indexedDB/IDBRequest.cpp
dom/indexedDB/IDBRequest.h
dom/indexedDB/IDBTransaction.cpp
dom/indexedDB/IDBTransaction.h
dom/interfaces/events/nsIDOMEventTarget.idl
dom/ipc/TabChild.h
dom/workers/MessagePort.cpp
dom/workers/MessagePort.h
dom/workers/SharedWorker.cpp
dom/workers/SharedWorker.h
widget/BasicEvents.h
--- a/content/base/public/Element.h
+++ b/content/base/public/Element.h
@@ -97,16 +97,17 @@ enum {
 };
 
 #undef ELEMENT_FLAG_BIT
 
 // Make sure we have space for our bits
 ASSERT_NODE_FLAGS_SPACE(ELEMENT_TYPE_SPECIFIC_BITS_OFFSET);
 
 namespace mozilla {
+class EventChainPreVisitor;
 class EventChainVisitor;
 class EventListenerManager;
 
 namespace dom {
 
 class Link;
 class UndoManager;
 class DOMRect;
@@ -1107,17 +1108,17 @@ protected:
    * @return true if we can handle the link event, false otherwise
    */
   bool CheckHandleEventForLinksPrecondition(EventChainVisitor& aVisitor,
                                             nsIURI** aURI) const;
 
   /**
    * Handle status bar updates before they can be cancelled.
    */
-  nsresult PreHandleEventForLinks(nsEventChainPreVisitor& aVisitor);
+  nsresult PreHandleEventForLinks(EventChainPreVisitor& aVisitor);
 
   /**
    * Handle default actions for link event if the event isn't consumed yet.
    */
   nsresult PostHandleEventForLinks(nsEventChainPostVisitor& aVisitor);
 
   /**
    * Get the target of this link element. Consumers should established that
--- a/content/base/public/nsIContent.h
+++ b/content/base/public/nsIContent.h
@@ -16,16 +16,17 @@ class nsIURI;
 class nsRuleWalker;
 class nsAttrValue;
 class nsAttrName;
 class nsTextFragment;
 class nsIFrame;
 class nsXBLBinding;
 
 namespace mozilla {
+class EventChainPreVisitor;
 namespace dom {
 class ShadowRoot;
 struct CustomElementData;
 } // namespace dom
 namespace widget {
 struct IMEState;
 } // namespace widget
 } // namespace mozilla
@@ -908,17 +909,18 @@ public:
         }
       }
     }
   }
 
   // Overloaded from nsINode
   virtual already_AddRefed<nsIURI> GetBaseURI() const MOZ_OVERRIDE;
 
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(
+                     mozilla::EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
 
   virtual bool IsPurple() = 0;
   virtual void RemovePurple() = 0;
 
   virtual bool OwnedOnlyByTheDOMTree() { return false; }
 protected:
   /**
    * Hook for implementing GetID.  This is guaranteed to only be
--- a/content/base/src/Attr.cpp
+++ b/content/base/src/Attr.cpp
@@ -356,17 +356,17 @@ Attr::InsertChildAt(nsIContent* aKid, ui
 }
 
 void
 Attr::RemoveChildAt(uint32_t aIndex, bool aNotify)
 {
 }
 
 nsresult
-Attr::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+Attr::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   aVisitor.mCanHandle = true;
   return NS_OK;
 }
 
 void
 Attr::Initialize()
 {
--- a/content/base/src/Attr.h
+++ b/content/base/src/Attr.h
@@ -18,16 +18,17 @@
 #include "nsString.h"
 #include "nsCOMPtr.h"
 #include "nsINodeInfo.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsStubMutationObserver.h"
 #include "nsIDocument.h"
 
 namespace mozilla {
+class EventChainPreVisitor;
 namespace dom {
 
 // Attribute helper class used to wrap up an attribute with a dom
 // object that implements nsIDOMAttr and nsIDOMNode
 class Attr MOZ_FINAL : public nsIAttribute,
                        public nsIDOMAttr
 {
 public:
@@ -46,17 +47,17 @@ public:
                                       ErrorResult& aError) MOZ_OVERRIDE;
   virtual void GetNodeValueInternal(nsAString& aNodeValue) MOZ_OVERRIDE;
   virtual void SetNodeValueInternal(const nsAString& aNodeValue,
                                     ErrorResult& aError) MOZ_OVERRIDE;
 
   // nsIDOMAttr interface
   NS_DECL_NSIDOMATTR
 
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
 
   // nsIAttribute interface
   void SetMap(nsDOMAttributeMap *aMap) MOZ_OVERRIDE;
   Element *GetElement() const;
   nsresult SetOwnerDocument(nsIDocument* aDocument) MOZ_OVERRIDE;
 
   // nsINode interface
   virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE;
--- a/content/base/src/Element.cpp
+++ b/content/base/src/Element.cpp
@@ -2330,17 +2330,17 @@ Element::CheckHandleEventForLinksPrecond
     return false;
   }
 
   // Make sure we actually are a link
   return IsLink(aURI);
 }
 
 nsresult
-Element::PreHandleEventForLinks(nsEventChainPreVisitor& aVisitor)
+Element::PreHandleEventForLinks(EventChainPreVisitor& aVisitor)
 {
   // Optimisation: return early if this event doesn't interest us.
   // IMPORTANT: this switch and the switch below it must be kept in sync!
   switch (aVisitor.mEvent->message) {
   case NS_MOUSE_ENTER_SYNTH:
   case NS_FOCUS_CONTENT:
   case NS_MOUSE_EXIT_SYNTH:
   case NS_BLUR_CONTENT:
--- a/content/base/src/FragmentOrElement.cpp
+++ b/content/base/src/FragmentOrElement.cpp
@@ -698,17 +698,17 @@ FindChromeAccessOnlySubtreeOwner(nsICont
       chromeAccessOnly = aContent->IsRootOfChromeAccessOnlySubtree();
       aContent = aContent->GetParent();
     }
   }
   return aContent;
 }
 
 nsresult
-nsIContent::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+nsIContent::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   //FIXME! Document how this event retargeting works, Bug 329124.
   aVisitor.mCanHandle = true;
   aVisitor.mMayHaveListenerManager = HasListenerManager();
 
   // Don't propagate mouseover and mouseout events when mouse is moving
   // inside chrome access only content.
   bool isAnonForEvents = IsRootOfChromeAccessOnlySubtree();
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -7631,17 +7631,17 @@ nsDocument::GetOrCreateListenerManager()
 
 EventListenerManager*
 nsDocument::GetExistingListenerManager() const
 {
   return mListenerManager;
 }
 
 nsresult
-nsDocument::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+nsDocument::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   aVisitor.mCanHandle = true;
    // FIXME! This is a hack to make middle mouse paste working also in Editor.
    // Bug 329119
   aVisitor.mForceContentDispatch = true;
 
   // Load events must not propagate to |window| object, see bug 335251.
   if (aVisitor.mEvent->message != NS_LOAD) {
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -93,16 +93,17 @@ class nsHTMLCSSStyleSheet;
 class nsDOMNavigationTiming;
 class nsWindowSizes;
 class nsHtml5TreeOpExecutor;
 class nsDocumentOnStack;
 class nsPointerLockPermissionRequest;
 class nsISecurityConsoleMessage;
 
 namespace mozilla {
+class EventChainPreVisitor;
 namespace dom {
 class UndoManager;
 class LifecycleCallbacks;
 class CallbackFunction;
 }
 }
 
 /**
@@ -897,17 +898,18 @@ public:
 
   // nsIDOMXMLDocument
   NS_DECL_NSIDOMXMLDOCUMENT
 
   // nsIDOMDocumentXBL
   NS_DECL_NSIDOMDOCUMENTXBL
 
   // nsIDOMEventTarget
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(
+                     mozilla::EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
   virtual mozilla::EventListenerManager*
     GetOrCreateListenerManager() MOZ_OVERRIDE;
   virtual mozilla::EventListenerManager*
     GetExistingListenerManager() const MOZ_OVERRIDE;
 
   // nsIScriptObjectPrincipal
   virtual nsIPrincipal* GetPrincipal() MOZ_OVERRIDE;
 
--- a/content/base/src/nsGenConImageContent.cpp
+++ b/content/base/src/nsGenConImageContent.cpp
@@ -13,16 +13,18 @@
 #include "nsContentCreatorFunctions.h"
 #include "nsXMLElement.h"
 #include "nsImageLoadingContent.h"
 #include "imgIRequest.h"
 #include "nsEventStates.h"
 #include "nsEventDispatcher.h"
 #include "mozilla/BasicEvents.h"
 
+using namespace mozilla;
+
 class nsGenConImageContent MOZ_FINAL : public nsXMLElement,
                                        public nsImageLoadingContent
 {
 public:
   nsGenConImageContent(already_AddRefed<nsINodeInfo>& aNodeInfo)
     : nsXMLElement(aNodeInfo)
   {
     // nsImageLoadingContent starts out broken, so we start out
@@ -38,17 +40,17 @@ public:
 
   // nsIContent overrides
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               bool aCompileEventHandlers);
   virtual void UnbindFromTree(bool aDeep, bool aNullParent);
   virtual nsEventStates IntrinsicState() const;
 
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+  virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor)
   {
     MOZ_ASSERT(IsInNativeAnonymousSubtree());
     if (aVisitor.mEvent->message == NS_LOAD ||
         aVisitor.mEvent->message == NS_LOAD_ERROR) {
       // Don't propagate the events to the parent.
       return NS_OK;
     }
     return nsXMLElement::PreHandleEvent(aVisitor);
--- a/content/base/src/nsINode.cpp
+++ b/content/base/src/nsINode.cpp
@@ -1128,17 +1128,17 @@ nsINode::RemoveEventListener(const nsASt
     elm->RemoveEventListener(aType, aListener, aUseCapture);
   }
   return NS_OK;
 }
 
 NS_IMPL_REMOVE_SYSTEM_EVENT_LISTENER(nsINode)
 
 nsresult
-nsINode::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+nsINode::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   // This is only here so that we can use the NS_DECL_NSIDOMTARGET macro
   NS_ABORT();
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 nsresult
 nsINode::DispatchEvent(nsIDOMEvent *aEvent, bool* aRetVal)
--- a/content/base/src/nsInProcessTabChildGlobal.cpp
+++ b/content/base/src/nsInProcessTabChildGlobal.cpp
@@ -19,21 +19,22 @@
 #include "xpcpublic.h"
 #include "nsIMozBrowserFrame.h"
 #include "nsDOMClassInfoID.h"
 #include "mozilla/dom/StructuredCloneUtils.h"
 #include "js/StructuredClone.h"
 
 using mozilla::dom::StructuredCloneData;
 using mozilla::dom::StructuredCloneClosure;
+using namespace mozilla;
 
 bool
 nsInProcessTabChildGlobal::DoSendBlockingMessage(JSContext* aCx,
                                                  const nsAString& aMessage,
-                                                 const mozilla::dom::StructuredCloneData& aData,
+                                                 const dom::StructuredCloneData& aData,
                                                  JS::Handle<JSObject *> aCpows,
                                                  nsIPrincipal* aPrincipal,
                                                  InfallibleTArray<nsString>* aJSONRetVal,
                                                  bool aIsSync)
 {
   nsTArray<nsCOMPtr<nsIRunnable> > asyncMessages;
   asyncMessages.SwapElements(mASyncMessages);
   uint32_t len = asyncMessages.Length();
@@ -133,17 +134,17 @@ nsInProcessTabChildGlobal::Init()
 #ifdef DEBUG
   nsresult rv =
 #endif
   InitTabChildGlobal();
   NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
                    "Couldn't initialize nsInProcessTabChildGlobal");
   mMessageManager = new nsFrameMessageManager(this,
                                               nullptr,
-                                              mozilla::dom::ipc::MM_CHILD);
+                                              dom::ipc::MM_CHILD);
   return NS_OK;
 }
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED_2(nsInProcessTabChildGlobal,
                                      nsDOMEventTargetHelper,
                                      mMessageManager,
                                      mGlobal)
 
@@ -244,17 +245,17 @@ nsInProcessTabChildGlobal::DelayedDiscon
 
 NS_IMETHODIMP_(nsIContent *)
 nsInProcessTabChildGlobal::GetOwnerContent()
 {
   return mOwner;
 }
 
 nsresult
-nsInProcessTabChildGlobal::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+nsInProcessTabChildGlobal::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   aVisitor.mCanHandle = true;
 
   if (mIsBrowserOrAppFrame &&
       (!mOwner || !nsContentUtils::IsInChromeDocshell(mOwner->OwnerDoc()))) {
     if (mOwner) {
       nsPIDOMWindow* innerWindow = mOwner->OwnerDoc()->GetInnerWindow();
       if (innerWindow) {
--- a/content/base/src/nsInProcessTabChildGlobal.h
+++ b/content/base/src/nsInProcessTabChildGlobal.h
@@ -18,16 +18,20 @@
 #include "nsIDocShell.h"
 #include "nsIDOMElement.h"
 #include "nsCOMArray.h"
 #include "nsIRunnable.h"
 #include "nsIGlobalObject.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsWeakReference.h"
 
+namespace mozilla {
+class EventChainPreVisitor;
+} // namespace mozilla
+
 class nsInProcessTabChildGlobal : public nsDOMEventTargetHelper,
                                   public nsFrameScriptExecutor,
                                   public nsIInProcessContentFrameMessageManager,
                                   public nsIGlobalObject,
                                   public nsIScriptObjectPrincipal,
                                   public nsSupportsWeakReference,
                                   public mozilla::dom::ipc::MessageManagerCallback
 {
@@ -91,17 +95,18 @@ public:
                                       InfallibleTArray<nsString>* aJSONRetVal,
                                       bool aIsSync) MOZ_OVERRIDE;
   virtual bool DoSendAsyncMessage(JSContext* aCx,
                                   const nsAString& aMessage,
                                   const mozilla::dom::StructuredCloneData& aData,
                                   JS::Handle<JSObject *> aCpows,
                                   nsIPrincipal* aPrincipal) MOZ_OVERRIDE;
 
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(
+                     mozilla::EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
   NS_IMETHOD AddEventListener(const nsAString& aType,
                               nsIDOMEventListener* aListener,
                               bool aUseCapture)
   {
     // By default add listeners only for trusted events!
     return nsDOMEventTargetHelper::AddEventListener(aType, aListener,
                                                     aUseCapture, false, 2);
   }
--- a/content/html/content/src/HTMLAnchorElement.cpp
+++ b/content/html/content/src/HTMLAnchorElement.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/HTMLAnchorElement.h"
 
 #include "mozilla/dom/HTMLAnchorElementBinding.h"
 #include "mozilla/MemoryReporting.h"
 #include "nsCOMPtr.h"
 #include "nsContentUtils.h"
+#include "nsEventDispatcher.h"
 #include "nsGkAtoms.h"
 #include "nsHTMLDNSPrefetch.h"
 #include "nsIDocument.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
 #include "nsIURI.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Anchor)
@@ -239,17 +240,17 @@ HTMLAnchorElement::IsHTMLFocusable(bool 
   }
 
   *aIsFocusable = true;
 
   return false;
 }
 
 nsresult
-HTMLAnchorElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+HTMLAnchorElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   return PreHandleEventForAnchors(aVisitor);
 }
 
 nsresult
 HTMLAnchorElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
 {
   return PostHandleEventForAnchors(aVisitor);
--- a/content/html/content/src/HTMLAnchorElement.h
+++ b/content/html/content/src/HTMLAnchorElement.h
@@ -9,16 +9,17 @@
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/Link.h"
 #include "nsGenericHTMLElement.h"
 #include "nsIDOMHTMLAnchorElement.h"
 #include "nsDOMTokenList.h"
 
 namespace mozilla {
+class EventChainPreVisitor;
 namespace dom {
 
 class HTMLAnchorElement MOZ_FINAL : public nsGenericHTMLElement,
                                     public nsIDOMHTMLAnchorElement,
                                     public Link
 {
 public:
   using Element::GetText;
@@ -49,17 +50,17 @@ public:
 
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               bool aCompileEventHandlers) MOZ_OVERRIDE;
   virtual void UnbindFromTree(bool aDeep = true,
                               bool aNullParent = true) MOZ_OVERRIDE;
   virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex) MOZ_OVERRIDE;
 
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
   virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
   virtual bool IsLink(nsIURI** aURI) const MOZ_OVERRIDE;
   virtual void GetLinkTarget(nsAString& aTarget) MOZ_OVERRIDE;
   virtual already_AddRefed<nsIURI> GetHrefURI() const MOZ_OVERRIDE;
 
   nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
                    const nsAString& aValue, bool aNotify)
   {
--- a/content/html/content/src/HTMLAreaElement.cpp
+++ b/content/html/content/src/HTMLAreaElement.cpp
@@ -4,16 +4,17 @@
  * 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/. */
 
 #include "mozilla/dom/HTMLAreaElement.h"
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/HTMLAreaElementBinding.h"
 #include "mozilla/MemoryReporting.h"
+#include "nsEventDispatcher.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Area)
 
 namespace mozilla {
 namespace dom {
 
 HTMLAreaElement::HTMLAreaElement(already_AddRefed<nsINodeInfo>& aNodeInfo)
   : nsGenericHTMLElement(aNodeInfo)
@@ -87,17 +88,17 @@ HTMLAreaElement::GetTarget(nsAString& aV
 
 NS_IMETHODIMP
 HTMLAreaElement::SetTarget(const nsAString& aValue)
 {
   return SetAttr(kNameSpaceID_None, nsGkAtoms::target, aValue, true);
 }
 
 nsresult
-HTMLAreaElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+HTMLAreaElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   return PreHandleEventForAnchors(aVisitor);
 }
 
 nsresult
 HTMLAreaElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
 {
   return PostHandleEventForAnchors(aVisitor);
--- a/content/html/content/src/HTMLAreaElement.h
+++ b/content/html/content/src/HTMLAreaElement.h
@@ -13,16 +13,17 @@
 #include "nsGkAtoms.h"
 #include "nsDOMTokenList.h"
 #include "nsIDOMHTMLAreaElement.h"
 #include "nsIURL.h"
 
 class nsIDocument;
 
 namespace mozilla {
+class EventChainPreVisitor;
 namespace dom {
 
 class HTMLAreaElement MOZ_FINAL : public nsGenericHTMLElement,
                                   public nsIDOMHTMLAreaElement,
                                   public Link
 {
 public:
   HTMLAreaElement(already_AddRefed<nsINodeInfo>& aNodeInfo);
@@ -38,17 +39,17 @@ public:
   // DOM memory reporter participant
   NS_DECL_SIZEOF_EXCLUDING_THIS
 
   virtual int32_t TabIndexDefault() MOZ_OVERRIDE;
 
   // nsIDOMHTMLAreaElement
   NS_DECL_NSIDOMHTMLAREAELEMENT
 
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
   virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
   virtual bool IsLink(nsIURI** aURI) const MOZ_OVERRIDE;
   virtual void GetLinkTarget(nsAString& aTarget) MOZ_OVERRIDE;
   virtual already_AddRefed<nsIURI> GetHrefURI() const MOZ_OVERRIDE;
 
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               bool aCompileEventHandlers) MOZ_OVERRIDE;
--- a/content/html/content/src/HTMLButtonElement.cpp
+++ b/content/html/content/src/HTMLButtonElement.cpp
@@ -182,17 +182,17 @@ HTMLButtonElement::IsDisabledForEvents(u
   nsIFrame* formFrame = nullptr;
   if (formControlFrame) {
     formFrame = do_QueryFrame(formControlFrame);
   }
   return IsElementDisabledForEvents(aMessage, formFrame);
 }
 
 nsresult
-HTMLButtonElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+HTMLButtonElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   aVisitor.mCanHandle = false;
   if (IsDisabledForEvents(aVisitor.mEvent->message)) {
     return NS_OK;
   }
 
   // Track whether we're in the outermost Dispatch invocation that will
   // cause activation of the input.  That is, if we're a click event, or a
--- a/content/html/content/src/HTMLButtonElement.h
+++ b/content/html/content/src/HTMLButtonElement.h
@@ -7,16 +7,17 @@
 #define mozilla_dom_HTMLButtonElement_h
 
 #include "mozilla/Attributes.h"
 #include "nsGenericHTMLElement.h"
 #include "nsIDOMHTMLButtonElement.h"
 #include "nsIConstraintValidation.h"
 
 namespace mozilla {
+class EventChainPreVisitor;
 namespace dom {
 
 class HTMLButtonElement MOZ_FINAL : public nsGenericHTMLFormElementWithState,
                                     public nsIDOMHTMLButtonElement,
                                     public nsIConstraintValidation
 {
 public:
   using nsIConstraintValidation::GetValidationMessage;
@@ -42,17 +43,17 @@ public:
   NS_IMETHOD_(uint32_t) GetType() const { return mType; }
   NS_IMETHOD Reset() MOZ_OVERRIDE;
   NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission) MOZ_OVERRIDE;
   NS_IMETHOD SaveState() MOZ_OVERRIDE;
   bool RestoreState(nsPresState* aState) MOZ_OVERRIDE;
   virtual bool IsDisabledForEvents(uint32_t aMessage) MOZ_OVERRIDE;
 
   // nsIDOMEventTarget
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
   virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
 
   // nsINode
   virtual nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const MOZ_OVERRIDE;
   virtual JSObject* WrapNode(JSContext* aCx,
                              JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   // nsIContent
--- a/content/html/content/src/HTMLFieldSetElement.cpp
+++ b/content/html/content/src/HTMLFieldSetElement.cpp
@@ -62,17 +62,17 @@ NS_IMPL_NSICONSTRAINTVALIDATION(HTMLFiel
 bool
 HTMLFieldSetElement::IsDisabledForEvents(uint32_t aMessage)
 {
   return IsElementDisabledForEvents(aMessage, nullptr);
 }
 
 // nsIContent
 nsresult
-HTMLFieldSetElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+HTMLFieldSetElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   // Do not process any DOM events if the element is disabled.
   aVisitor.mCanHandle = false;
   if (IsDisabledForEvents(aVisitor.mEvent->message)) {
     return NS_OK;
   }
 
   return nsGenericHTMLFormElement::PreHandleEvent(aVisitor);
--- a/content/html/content/src/HTMLFieldSetElement.h
+++ b/content/html/content/src/HTMLFieldSetElement.h
@@ -9,16 +9,17 @@
 #include "mozilla/Attributes.h"
 #include "nsGenericHTMLElement.h"
 #include "nsIDOMHTMLFieldSetElement.h"
 #include "nsIConstraintValidation.h"
 #include "mozilla/dom/HTMLFormElement.h"
 #include "mozilla/dom/ValidityState.h"
 
 namespace mozilla {
+class EventChainPreVisitor;
 namespace dom {
 
 class HTMLFieldSetElement MOZ_FINAL : public nsGenericHTMLFormElement,
                                       public nsIDOMHTMLFieldSetElement,
                                       public nsIConstraintValidation
 {
 public:
   using nsGenericHTMLFormElement::GetForm;
@@ -33,17 +34,17 @@ public:
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIDOMHTMLFieldSetElement
   NS_DECL_NSIDOMHTMLFIELDSETELEMENT
 
   // nsIContent
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
   virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
                                 const nsAttrValue* aValue, bool aNotify) MOZ_OVERRIDE;
 
   virtual nsresult InsertChildAt(nsIContent* aChild, uint32_t aIndex,
                                      bool aNotify) MOZ_OVERRIDE;
   virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) MOZ_OVERRIDE;
 
   // nsIFormControl
--- a/content/html/content/src/HTMLFormElement.cpp
+++ b/content/html/content/src/HTMLFormElement.cpp
@@ -477,17 +477,17 @@ HTMLFormElement::UnbindFromTree(bool aDe
 
   if (oldDocument) {
     oldDocument->RemovedForm();
   }
   ForgetCurrentSubmission();
 }
 
 nsresult
-HTMLFormElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+HTMLFormElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   aVisitor.mWantsWillHandleEvent = true;
   if (aVisitor.mEvent->originalTarget == static_cast<nsIContent*>(this)) {
     uint32_t msg = aVisitor.mEvent->message;
     if (msg == NS_FORM_SUBMIT) {
       if (mGeneratingSubmit) {
         aVisitor.mCanHandle = false;
         return NS_OK;
--- a/content/html/content/src/HTMLFormElement.h
+++ b/content/html/content/src/HTMLFormElement.h
@@ -22,16 +22,17 @@
 #include "nsRefPtrHashtable.h"
 #include "nsDataHashtable.h"
 #include "jsfriendapi.h" // For js::ExpandoAndGeneration
 
 class nsIMutableArray;
 class nsIURI;
 
 namespace mozilla {
+class EventChainPreVisitor;
 namespace dom {
 class HTMLFormControlsCollection;
 class HTMLImageElement;
 
 class HTMLFormElement MOZ_FINAL : public nsGenericHTMLElement,
                                   public nsIDOMHTMLFormElement,
                                   public nsIWebProgressListener,
                                   public nsIForm,
@@ -84,17 +85,17 @@ public:
 
   virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
 
   // nsIContent
   virtual bool ParseAttribute(int32_t aNamespaceID,
                                 nsIAtom* aAttribute,
                                 const nsAString& aValue,
                                 nsAttrValue& aResult) MOZ_OVERRIDE;
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
   virtual nsresult WillHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
   virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
 
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               bool aCompileEventHandlers) MOZ_OVERRIDE;
   virtual void UnbindFromTree(bool aDeep = true,
                               bool aNullParent = true) MOZ_OVERRIDE;
--- a/content/html/content/src/HTMLImageElement.cpp
+++ b/content/html/content/src/HTMLImageElement.cpp
@@ -336,17 +336,17 @@ HTMLImageElement::AfterSetAttr(int32_t a
   }
 
   return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName,
                                             aValue, aNotify);
 }
 
 
 nsresult
-HTMLImageElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+HTMLImageElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   // If we are a map and get a mouse click, don't let it be handled by
   // the Generic Element as this could cause a click event to fire
   // twice, once by the image frame for the map and once by the Anchor
   // element. (bug 39723)
   WidgetMouseEvent* mouseEvent = aVisitor.mEvent->AsMouseEvent();
   if (mouseEvent && mouseEvent->IsLeftClickEvent()) {
     bool isMap = false;
--- a/content/html/content/src/HTMLImageElement.h
+++ b/content/html/content/src/HTMLImageElement.h
@@ -9,16 +9,17 @@
 #include "mozilla/Attributes.h"
 #include "nsGenericHTMLElement.h"
 #include "nsImageLoadingContent.h"
 #include "nsIDOMHTMLImageElement.h"
 #include "imgRequestProxy.h"
 #include "Units.h"
 
 namespace mozilla {
+class EventChainPreVisitor;
 namespace dom {
 
 class HTMLImageElement MOZ_FINAL : public nsGenericHTMLElement,
                                    public nsImageLoadingContent,
                                    public nsIDOMHTMLImageElement
 {
 public:
   explicit HTMLImageElement(already_AddRefed<nsINodeInfo>& aNodeInfo);
@@ -46,17 +47,17 @@ public:
                                 nsIAtom* aAttribute,
                                 const nsAString& aValue,
                                 nsAttrValue& aResult) MOZ_OVERRIDE;
   virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
                                               int32_t aModType) const MOZ_OVERRIDE;
   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const MOZ_OVERRIDE;
   virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const MOZ_OVERRIDE;
 
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
 
   bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex) MOZ_OVERRIDE;
 
   // SetAttr override.  C++ is stupid, so have to override both
   // overloaded methods.
   nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
                    const nsAString& aValue, bool aNotify)
   {
--- a/content/html/content/src/HTMLInputElement.cpp
+++ b/content/html/content/src/HTMLInputElement.cpp
@@ -3217,17 +3217,18 @@ HTMLInputElement::SelectAll(nsPresContex
   nsIFormControlFrame* formControlFrame = GetFormControlFrame(true);
 
   if (formControlFrame) {
     formControlFrame->SetFormProperty(nsGkAtoms::select, EmptyString());
   }
 }
 
 bool
-HTMLInputElement::NeedToInitializeEditorForEvent(nsEventChainPreVisitor& aVisitor) const
+HTMLInputElement::NeedToInitializeEditorForEvent(
+                    EventChainPreVisitor& aVisitor) const
 {
   // We only need to initialize the editor for single line input controls because they
   // are lazily initialized.  We don't need to initialize the control for
   // certain types of events, because we know that those events are safe to be
   // handled without the editor being initialized.  These events include:
   // mousein/move/out, and DOM mutation events.
   if (!IsSingleLineTextControl(false) ||
       aVisitor.mEvent->eventStructType == NS_MUTATION_EVENT) {
@@ -3248,17 +3249,17 @@ HTMLInputElement::NeedToInitializeEditor
 
 bool
 HTMLInputElement::IsDisabledForEvents(uint32_t aMessage)
 {
   return IsElementDisabledForEvents(aMessage, GetPrimaryFrame());
 }
 
 nsresult
-HTMLInputElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+HTMLInputElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   // Do not process any DOM events if the element is disabled
   aVisitor.mCanHandle = false;
   if (IsDisabledForEvents(aVisitor.mEvent->message)) {
     return NS_OK;
   }
 
   // Initialize the editor if needed.
--- a/content/html/content/src/HTMLInputElement.h
+++ b/content/html/content/src/HTMLInputElement.h
@@ -24,16 +24,19 @@
 
 class nsDOMFileList;
 class nsIRadioGroupContainer;
 class nsIRadioGroupVisitor;
 class nsIRadioVisitor;
 class nsTextEditorState;
 
 namespace mozilla {
+
+class EventChainPreVisitor;
+
 namespace dom {
 
 class Date;
 class DirPickerFileListBuilderTask;
 
 class UploadLastDir MOZ_FINAL : public nsIObserver, public nsSupportsWeakReference {
 public:
   NS_DECL_ISUPPORTS
@@ -143,17 +146,17 @@ public:
                                 nsIAtom* aAttribute,
                                 const nsAString& aValue,
                                 nsAttrValue& aResult) MOZ_OVERRIDE;
   virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
                                               int32_t aModType) const MOZ_OVERRIDE;
   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const MOZ_OVERRIDE;
   virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const MOZ_OVERRIDE;
 
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
   virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
   void PostHandleEventForRangeThumb(nsEventChainPostVisitor& aVisitor);
   void StartRangeThumbDrag(WidgetGUIEvent* aEvent);
   void FinishRangeThumbDrag(WidgetGUIEvent* aEvent = nullptr);
   void CancelRangeThumbDrag(bool aIsForUserEvent = true);
   void SetValueOfRangeForUserEvent(Decimal aValue);
 
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
@@ -886,17 +889,17 @@ protected:
    * Called after calling one of the SetFiles() functions.
    */
   void AfterSetFiles(bool aSetValueChanged);
 
   /**
    * Determine whether the editor needs to be initialized explicitly for
    * a particular event.
    */
-  bool NeedToInitializeEditorForEvent(nsEventChainPreVisitor& aVisitor) const;
+  bool NeedToInitializeEditorForEvent(EventChainPreVisitor& aVisitor) const;
 
   /**
    * Get the value mode of the element, depending of the type.
    */
   ValueModeType GetValueMode() const;
 
   /**
    * Get the mutable state of the element.
--- a/content/html/content/src/HTMLLinkElement.cpp
+++ b/content/html/content/src/HTMLLinkElement.cpp
@@ -6,16 +6,17 @@
 
 #include "mozilla/dom/HTMLLinkElement.h"
 
 #include "mozilla/AsyncEventDispatcher.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/HTMLLinkElementBinding.h"
 #include "mozilla/MemoryReporting.h"
 #include "nsContentUtils.h"
+#include "nsEventDispatcher.h"
 #include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
 #include "nsDOMTokenList.h"
 #include "nsIDocument.h"
 #include "nsIDOMEvent.h"
 #include "nsIDOMStyleSheet.h"
 #include "nsIStyleSheet.h"
 #include "nsIStyleSheetLinkingElement.h"
@@ -297,17 +298,17 @@ HTMLLinkElement::UnsetAttr(int32_t aName
   if (aAttribute == nsGkAtoms::href && kNameSpaceID_None == aNameSpaceID) {
     Link::ResetLinkState(!!aNotify, false);
   }
 
   return rv;
 }
 
 nsresult
-HTMLLinkElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+HTMLLinkElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   return PreHandleEventForAnchors(aVisitor);
 }
 
 nsresult
 HTMLLinkElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
 {
   return PostHandleEventForAnchors(aVisitor);
--- a/content/html/content/src/HTMLLinkElement.h
+++ b/content/html/content/src/HTMLLinkElement.h
@@ -8,16 +8,17 @@
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/Link.h"
 #include "nsGenericHTMLElement.h"
 #include "nsIDOMHTMLLinkElement.h"
 #include "nsStyleLinkElement.h"
 
 namespace mozilla {
+class EventChainPreVisitor;
 namespace dom {
 
 class HTMLLinkElement MOZ_FINAL : public nsGenericHTMLElement,
                                   public nsIDOMHTMLLinkElement,
                                   public nsStyleLinkElement,
                                   public Link
 {
 public:
@@ -36,17 +37,17 @@ public:
 
   // DOM memory reporter participant
   NS_DECL_SIZEOF_EXCLUDING_THIS
 
   void LinkAdded();
   void LinkRemoved();
 
   // nsIDOMEventTarget
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
   virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
 
   // nsINode
   virtual nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const MOZ_OVERRIDE;
   virtual JSObject* WrapNode(JSContext* aCx,
                              JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   // nsIContent
--- a/content/html/content/src/HTMLMenuItemElement.cpp
+++ b/content/html/content/src/HTMLMenuItemElement.cpp
@@ -246,17 +246,17 @@ HTMLMenuItemElement::SetChecked(bool aCh
   } else {
     mCheckedDirty = true;
   }
 
   return NS_OK;
 }
 
 nsresult
-HTMLMenuItemElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+HTMLMenuItemElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   if (aVisitor.mEvent->message == NS_MOUSE_CLICK) {
 
     bool originalCheckedValue = false;
     switch (mType) {
       case CMD_TYPE_CHECKBOX:
         originalCheckedValue = mChecked;
         SetChecked(!originalCheckedValue);
--- a/content/html/content/src/HTMLMenuItemElement.h
+++ b/content/html/content/src/HTMLMenuItemElement.h
@@ -6,16 +6,19 @@
 #ifndef mozilla_dom_HTMLMenuItemElement_h
 #define mozilla_dom_HTMLMenuItemElement_h
 
 #include "mozilla/Attributes.h"
 #include "nsIDOMHTMLMenuItemElement.h"
 #include "nsGenericHTMLElement.h"
 
 namespace mozilla {
+
+class EventChainPreVisitor;
+
 namespace dom {
 
 class Visitor;
 
 class HTMLMenuItemElement MOZ_FINAL : public nsGenericHTMLElement,
                                       public nsIDOMHTMLMenuItemElement
 {
 public:
@@ -28,17 +31,17 @@ public:
   NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLMenuItemElement, menuitem)
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIDOMHTMLMenuItemElement
   NS_DECL_NSIDOMHTMLMENUITEMELEMENT
 
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
   virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
 
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               bool aCompileEventHandlers) MOZ_OVERRIDE;
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                                 nsIAtom* aAttribute,
--- a/content/html/content/src/HTMLOptGroupElement.cpp
+++ b/content/html/content/src/HTMLOptGroupElement.cpp
@@ -43,17 +43,17 @@ NS_IMPL_ISUPPORTS_INHERITED1(HTMLOptGrou
 NS_IMPL_ELEMENT_CLONE(HTMLOptGroupElement)
 
 
 NS_IMPL_BOOL_ATTR(HTMLOptGroupElement, Disabled, disabled)
 NS_IMPL_STRING_ATTR(HTMLOptGroupElement, Label, label)
 
 
 nsresult
-HTMLOptGroupElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+HTMLOptGroupElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   aVisitor.mCanHandle = false;
   // Do not process any DOM events if the element is disabled
   // XXXsmaug This is not the right thing to do. But what is?
   if (HasAttr(kNameSpaceID_None, nsGkAtoms::disabled)) {
     return NS_OK;
   }
 
--- a/content/html/content/src/HTMLOptGroupElement.h
+++ b/content/html/content/src/HTMLOptGroupElement.h
@@ -6,16 +6,17 @@
 #ifndef mozilla_dom_HTMLOptGroupElement_h
 #define mozilla_dom_HTMLOptGroupElement_h
 
 #include "mozilla/Attributes.h"
 #include "nsIDOMHTMLOptGroupElement.h"
 #include "nsGenericHTMLElement.h"
 
 namespace mozilla {
+class EventChainPreVisitor;
 namespace dom {
 
 class HTMLOptGroupElement MOZ_FINAL : public nsGenericHTMLElement,
                                       public nsIDOMHTMLOptGroupElement
 {
 public:
   HTMLOptGroupElement(already_AddRefed<nsINodeInfo>& aNodeInfo);
   virtual ~HTMLOptGroupElement();
@@ -29,17 +30,17 @@ public:
   NS_DECL_NSIDOMHTMLOPTGROUPELEMENT
 
   // nsINode
   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
                                  bool aNotify) MOZ_OVERRIDE;
   virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) MOZ_OVERRIDE;
 
   // nsIContent
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
 
   virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
  
   virtual nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const MOZ_OVERRIDE;
 
   virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
                                 const nsAttrValue* aValue, bool aNotify) MOZ_OVERRIDE;
 
--- a/content/html/content/src/HTMLSelectElement.cpp
+++ b/content/html/content/src/HTMLSelectElement.cpp
@@ -1473,17 +1473,17 @@ HTMLSelectElement::IsDisabledForEvents(u
   nsIFrame* formFrame = nullptr;
   if (formControlFrame) {
     formFrame = do_QueryFrame(formControlFrame);
   }
   return IsElementDisabledForEvents(aMessage, formFrame);
 }
 
 nsresult
-HTMLSelectElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+HTMLSelectElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   aVisitor.mCanHandle = false;
   if (IsDisabledForEvents(aVisitor.mEvent->message)) {
     return NS_OK;
   }
 
   return nsGenericHTMLFormElementWithState::PreHandleEvent(aVisitor);
 }
--- a/content/html/content/src/HTMLSelectElement.h
+++ b/content/html/content/src/HTMLSelectElement.h
@@ -20,16 +20,19 @@
 
 class nsContentList;
 class nsIDOMHTMLOptionElement;
 class nsIHTMLCollection;
 class nsISelectControlFrame;
 class nsPresState;
 
 namespace mozilla {
+
+class EventChainPreVisitor;
+
 namespace dom {
 
 class HTMLSelectElement;
 
 #define NS_SELECT_STATE_IID                        \
 { /* 4db54c7c-d159-455f-9d8e-f60ee466dbf3 */       \
   0x4db54c7c,                                      \
   0xd159,                                          \
@@ -254,17 +257,17 @@ public:
   using nsINode::Remove;
 
 
   // nsINode
   virtual JSObject* WrapNode(JSContext* aCx,
                              JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   // nsIContent
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
   virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
 
   virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable, int32_t* aTabIndex) MOZ_OVERRIDE;
   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
                                  bool aNotify) MOZ_OVERRIDE;
   virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) MOZ_OVERRIDE;
 
   // Overriden nsIFormControl methods
--- a/content/html/content/src/HTMLTextAreaElement.cpp
+++ b/content/html/content/src/HTMLTextAreaElement.cpp
@@ -449,17 +449,17 @@ HTMLTextAreaElement::IsDisabledForEvents
   nsIFrame* formFrame = nullptr;
   if (formControlFrame) {
     formFrame = do_QueryFrame(formControlFrame);
   }
   return IsElementDisabledForEvents(aMessage, formFrame);
 }
 
 nsresult
-HTMLTextAreaElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+HTMLTextAreaElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   aVisitor.mCanHandle = false;
   if (IsDisabledForEvents(aVisitor.mEvent->message)) {
     return NS_OK;
   }
 
   // Don't dispatch a second select event if we are already handling
   // one.
--- a/content/html/content/src/HTMLTextAreaElement.h
+++ b/content/html/content/src/HTMLTextAreaElement.h
@@ -24,16 +24,19 @@
 
 class nsFormSubmission;
 class nsIControllers;
 class nsIDocument;
 class nsPresContext;
 class nsPresState;
 
 namespace mozilla {
+
+class EventChainPreVisitor;
+
 namespace dom {
 
 class HTMLTextAreaElement MOZ_FINAL : public nsGenericHTMLFormElementWithState,
                                       public nsIDOMHTMLTextAreaElement,
                                       public nsITextControlElement,
                                       public nsIDOMNSEditableElement,
                                       public nsStubMutationObserver,
                                       public nsIConstraintValidation
@@ -108,17 +111,17 @@ public:
                                 nsIAtom* aAttribute,
                                 const nsAString& aValue,
                                 nsAttrValue& aResult) MOZ_OVERRIDE;
   virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const MOZ_OVERRIDE;
   virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
                                               int32_t aModType) const MOZ_OVERRIDE;
   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const MOZ_OVERRIDE;
 
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
   virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
 
   virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex) MOZ_OVERRIDE;
 
   virtual void DoneAddingChildren(bool aHaveNotified) MOZ_OVERRIDE;
   virtual bool IsDoneAddingChildren() MOZ_OVERRIDE;
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -713,17 +713,17 @@ nsGenericHTMLElement::CheckHandleEventFo
   //link farther up, do nothing.
   nsCOMPtr<nsIContent> target = aVisitor.mPresContext->EventStateManager()->
     GetEventTargetContent(aVisitor.mEvent);
 
   return !target || !target->IsHTML(nsGkAtoms::area) || IsHTML(nsGkAtoms::area);
 }
 
 nsresult
-nsGenericHTMLElement::PreHandleEventForAnchors(nsEventChainPreVisitor& aVisitor)
+nsGenericHTMLElement::PreHandleEventForAnchors(EventChainPreVisitor& aVisitor)
 {
   nsresult rv = nsGenericHTMLElementBase::PreHandleEvent(aVisitor);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (!CheckHandleEventForAnchorsPreconditions(aVisitor)) {
     return NS_OK;
   }
 
@@ -2280,17 +2280,17 @@ nsGenericHTMLFormElement::AfterSetAttr(i
     }
   }
 
   return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName,
                                             aValue, aNotify);
 }
 
 nsresult
-nsGenericHTMLFormElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+nsGenericHTMLFormElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   if (aVisitor.mEvent->mFlags.mIsTrusted) {
     switch (aVisitor.mEvent->message) {
       case NS_FOCUS_CONTENT:
       {
         // Check to see if focus has bubbled up from a form control's
         // child textfield or button.  If that's the case, don't focus
         // this parent file control -- leave focus on the child.
--- a/content/html/content/src/nsGenericHTMLElement.h
+++ b/content/html/content/src/nsGenericHTMLElement.h
@@ -35,16 +35,17 @@ class nsILayoutHistoryState;
 class nsIEditor;
 struct nsRect;
 struct nsSize;
 class nsIDOMHTMLMenuElement;
 class nsIDOMHTMLCollection;
 class nsDOMSettableTokenList;
 
 namespace mozilla {
+class EventChainPreVisitor;
 class EventChainVisitor;
 class EventListenerManager;
 namespace dom {
 class HTMLFormElement;
 class HTMLPropertiesCollection;
 class HTMLMenuElement;
 }
 }
@@ -586,17 +587,17 @@ public:
                                 bool aIsTrustedEvent) MOZ_OVERRIDE;
 
   /**
    * Check if an event for an anchor can be handled
    * @return true if the event can be handled, false otherwise
    */
   bool CheckHandleEventForAnchorsPreconditions(
          mozilla::EventChainVisitor& aVisitor);
-  nsresult PreHandleEventForAnchors(nsEventChainPreVisitor& aVisitor);
+  nsresult PreHandleEventForAnchors(mozilla::EventChainPreVisitor& aVisitor);
   nsresult PostHandleEventForAnchors(nsEventChainPostVisitor& aVisitor);
   bool IsHTMLLink(nsIURI** aURI) const;
 
   // HTML element methods
   void Compact() { mAttrsAndChildren.Compact(); }
 
   virtual void UpdateEditableState(bool aNotify) MOZ_OVERRIDE;
 
@@ -1323,17 +1324,18 @@ public:
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               bool aCompileEventHandlers) MOZ_OVERRIDE;
   virtual void UnbindFromTree(bool aDeep = true,
                               bool aNullParent = true) MOZ_OVERRIDE;
   virtual IMEState GetDesiredIMEState() MOZ_OVERRIDE;
   virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
 
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(
+                     mozilla::EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
 
   virtual bool IsDisabled() const MOZ_OVERRIDE;
 
   /**
    * This callback is called by a fieldest on all its elements whenever its
    * disabled attribute is changed so the element knows its disabled state
    * might have changed.
    *
--- a/content/mathml/content/src/nsMathMLElement.cpp
+++ b/content/mathml/content/src/nsMathMLElement.cpp
@@ -16,16 +16,17 @@
 #include "nsIDocument.h"
 #include "nsEventStates.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
 #include "mozAutoDocUpdate.h"
 #include "nsIScriptError.h"
 #include "nsContentUtils.h"
 #include "nsIURI.h"
+#include "nsEventDispatcher.h"
 
 #include "mozilla/dom/ElementBinding.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 //----------------------------------------------------------------------
 // nsISupports methods:
@@ -892,17 +893,17 @@ nsMathMLElement::MapMathMLAttributesInto
           break;
         }
       }
     }
   }
 }
 
 nsresult
-nsMathMLElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+nsMathMLElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   nsresult rv = Element::PreHandleEvent(aVisitor);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return PreHandleEventForLinks(aVisitor);
 }
 
 nsresult
--- a/content/mathml/content/src/nsMathMLElement.h
+++ b/content/mathml/content/src/nsMathMLElement.h
@@ -12,16 +12,20 @@
 #include "nsIDOMElement.h"
 #include "Link.h"
 #include "mozilla/dom/DOMRect.h"
 
 class nsCSSValue;
 
 typedef nsMappedAttributeElement nsMathMLElementBase;
 
+namespace mozilla {
+class EventChainPreVisitor;
+} // namespace mozilla
+
 /*
  * The base class for MathML elements.
  */
 class nsMathMLElement MOZ_FINAL : public nsMathMLElementBase,
                                   public nsIDOMElement,
                                   public mozilla::dom::Link
 {
 public:
@@ -63,17 +67,18 @@ public:
   static bool ParseNumericValue(const nsString& aString,
                                 nsCSSValue&     aCSSValue,
                                 uint32_t        aFlags,
                                 nsIDocument*    aDocument);
 
   static void MapMathMLAttributesInto(const nsMappedAttributes* aAttributes, 
                                       nsRuleData* aRuleData);
   
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(
+                     mozilla::EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
   virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
   nsresult Clone(nsINodeInfo*, nsINode**) const MOZ_OVERRIDE;
   virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
   virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE;
 
   // Set during reflow as necessary. Does a style change notification,
   // aNotify must be true.
   void SetIncrementScriptLevel(bool aIncrementScriptLevel, bool aNotify);
--- a/content/svg/content/src/SVGAElement.cpp
+++ b/content/svg/content/src/SVGAElement.cpp
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/SVGAElement.h"
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/SVGAElementBinding.h"
 #include "nsCOMPtr.h"
 #include "nsContentUtils.h"
+#include "nsEventDispatcher.h"
 #include "nsGkAtoms.h"
 #include "nsSVGString.h"
 #include "nsIURI.h"
 
 NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(A)
 
 namespace mozilla {
 namespace dom {
@@ -71,17 +72,17 @@ SVGAElement::Href()
 {
   return mStringAttributes[HREF].ToDOMAnimatedString(this);
 }
 
 //----------------------------------------------------------------------
 // nsINode methods
 
 nsresult
-SVGAElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+SVGAElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   nsresult rv = Element::PreHandleEvent(aVisitor);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return PreHandleEventForLinks(aVisitor);
 }
 
 nsresult
--- a/content/svg/content/src/SVGAElement.h
+++ b/content/svg/content/src/SVGAElement.h
@@ -9,16 +9,19 @@
 #include "Link.h"
 #include "nsSVGString.h"
 #include "mozilla/dom/SVGGraphicsElement.h"
 
 nsresult NS_NewSVGAElement(nsIContent **aResult,
                            already_AddRefed<nsINodeInfo>&& aNodeInfo);
 
 namespace mozilla {
+
+class EventChainPreVisitor;
+
 namespace dom {
 
 typedef SVGGraphicsElement SVGAElementBase;
 
 class SVGAElement MOZ_FINAL : public SVGAElementBase,
                               public Link
 {
 protected:
@@ -28,17 +31,17 @@ protected:
   virtual JSObject* WrapNode(JSContext *cx,
                              JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGAElement, SVGAElementBase)
 
   // nsINode interface methods
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
   virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
 
   // nsIContent
   virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent,
                               nsIContent *aBindingParent,
                               bool aCompileEventHandlers) MOZ_OVERRIDE;
   virtual void UnbindFromTree(bool aDeep = true,
--- a/content/svg/content/src/SVGSVGElement.cpp
+++ b/content/svg/content/src/SVGSVGElement.cpp
@@ -584,17 +584,17 @@ SVGSVGElement::IsAttributeMapped(const n
   return FindAttributeDependence(name, map) ||
     SVGSVGElementBase::IsAttributeMapped(name);
 }
 
 //----------------------------------------------------------------------
 // nsIContent methods:
 
 nsresult
-SVGSVGElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+SVGSVGElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   if (aVisitor.mEvent->message == NS_SVG_LOAD) {
     if (mTimedDocumentRoot) {
       mTimedDocumentRoot->Begin();
       // Set 'resample needed' flag, so that if any script calls a DOM method
       // that requires up-to-date animations before our first sample callback,
       // we'll force a synchronous sample.
       AnimationNeedsResample();
--- a/content/svg/content/src/SVGSVGElement.h
+++ b/content/svg/content/src/SVGSVGElement.h
@@ -23,19 +23,20 @@ nsresult NS_NewSVGSVGElement(nsIContent 
 
 class nsIDOMSVGNumber;
 class nsSMILTimeContainer;
 class nsSVGOuterSVGFrame;
 class nsSVGInnerSVGFrame;
 class nsSVGImageFrame;
 
 namespace mozilla {
+class AutoSVGRenderingState;
 class DOMSVGAnimatedPreserveAspectRatio;
+class EventChainPreVisitor;
 class SVGFragmentIdentifier;
-class AutoSVGRenderingState;
 
 namespace dom {
 class SVGAngle;
 class SVGAnimatedRect;
 class SVGMatrix;
 class SVGTransform;
 class SVGViewElement;
 class SVGIRect;
@@ -122,17 +123,17 @@ public:
    */
   const SVGPoint& GetPreviousTranslate() { return mPreviousTranslate; }
   float GetPreviousScale() { return mPreviousScale; }
 
   nsSMILTimeContainer* GetTimedDocumentRoot();
 
   // nsIContent interface
   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const MOZ_OVERRIDE;
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
 
   virtual bool IsEventAttributeName(nsIAtom* aName) MOZ_OVERRIDE;
 
   // nsSVGElement specializations:
   virtual gfxMatrix PrependLocalTransformsTo(const gfxMatrix &aMatrix,
                       TransformTypes aWhich = eAllTransforms) const MOZ_OVERRIDE;
   virtual bool HasValidDimensions() const MOZ_OVERRIDE;
 
--- a/content/xul/content/src/nsXULElement.cpp
+++ b/content/xul/content/src/nsXULElement.cpp
@@ -1134,17 +1134,17 @@ nsXULElement::List(FILE* out, int32_t aI
     }
     prefix.Append(' ');
 
     nsStyledElement::List(out, aIndent, prefix);
 }
 #endif
 
 nsresult
-nsXULElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+nsXULElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
     aVisitor.mForceContentDispatch = true; //FIXME! Bug 329119
     nsIAtom* tag = Tag();
     if (IsRootOfNativeAnonymousSubtree() &&
         (tag == nsGkAtoms::scrollbar || tag == nsGkAtoms::scrollcorner) &&
         (aVisitor.mEvent->message == NS_MOUSE_CLICK ||
          aVisitor.mEvent->message == NS_MOUSE_DOUBLECLICK ||
          aVisitor.mEvent->message == NS_XUL_COMMAND ||
--- a/content/xul/content/src/nsXULElement.h
+++ b/content/xul/content/src/nsXULElement.h
@@ -44,16 +44,17 @@ class nsXULPrototypeDocument;
 
 class nsIObjectInputStream;
 class nsIObjectOutputStream;
 class nsIOffThreadScriptReceiver;
 class nsXULPrototypeNode;
 typedef nsTArray<nsRefPtr<nsXULPrototypeNode> > nsPrototypeArray;
 
 namespace mozilla {
+class EventChainPreVisitor;
 class EventListenerManager;
 namespace css {
 class StyleRule;
 }
 }
 
 ////////////////////////////////////////////////////////////////////////
 
@@ -369,17 +370,18 @@ public:
     NS_IMPL_FROMCONTENT(nsXULElement, kNameSpaceID_XUL)
 
     // nsISupports
     NS_DECL_ISUPPORTS_INHERITED
     NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsXULElement,
                                                        mozilla::dom::Element)
 
     // nsINode
-    virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
+    virtual nsresult PreHandleEvent(
+                       mozilla::EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
 
     // nsIContent
     virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                                 nsIContent* aBindingParent,
                                 bool aCompileEventHandlers) MOZ_OVERRIDE;
     virtual void UnbindFromTree(bool aDeep, bool aNullParent) MOZ_OVERRIDE;
     virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) MOZ_OVERRIDE;
     virtual void DestroyContent() MOZ_OVERRIDE;
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -2958,17 +2958,17 @@ nsGlobalWindow::WillHandleEvent(nsEventC
 
 JSContext*
 nsGlobalWindow::GetJSContextForEventHandlers()
 {
   return nullptr;
 }
 
 nsresult
-nsGlobalWindow::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+nsGlobalWindow::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   NS_PRECONDITION(IsInnerWindow(), "PreHandleEvent is used on outer window!?");
   static uint32_t count = 0;
   uint32_t msg = aVisitor.mEvent->message;
 
   aVisitor.mCanHandle = true;
   aVisitor.mForceContentDispatch = true; //FIXME! Bug 329119
   if ((msg == NS_MOUSE_MOVE) && gEntropyCollector) {
--- a/dom/base/nsWindowRoot.cpp
+++ b/dom/base/nsWindowRoot.cpp
@@ -163,17 +163,17 @@ nsWindowRoot::GetExistingListenerManager
 nsIScriptContext*
 nsWindowRoot::GetContextForEventHandlers(nsresult* aRv)
 {
   *aRv = NS_OK;
   return nullptr;
 }
 
 nsresult
-nsWindowRoot::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+nsWindowRoot::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   aVisitor.mCanHandle = true;
   aVisitor.mForceContentDispatch = true; //FIXME! Bug 329119
   // To keep mWindow alive
   aVisitor.mItemData = static_cast<nsISupports *>(mWindow);
   aVisitor.mParentTarget = mParent;
   return NS_OK;
 }
--- a/dom/base/nsWindowRoot.h
+++ b/dom/base/nsWindowRoot.h
@@ -5,19 +5,22 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsWindowRoot_h__
 #define nsWindowRoot_h__
 
 class nsPIDOMWindow;
 class nsIDOMEventListener;
 class nsIDOMEvent;
-class nsEventChainPreVisitor;
 class nsEventChainPostVisitor;
 
+namespace mozilla {
+class EventChainPreVisitor;
+} // namespace mozilla
+
 #include "mozilla/Attributes.h"
 #include "mozilla/EventListenerManager.h"
 #include "nsIDOMEventTarget.h"
 #include "nsPIWindowRoot.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsAutoPtr.h"
 
 class nsWindowRoot : public nsPIWindowRoot
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -52,16 +52,17 @@
 #include "nsCExternalHandlerService.h"
 #include "nsIPermissionManager.h"
 #include "nsIStringBundle.h"
 #include "nsIDocument.h"
 #include "nsPrintfCString.h"
 #include <algorithm>
 #include "private/pprio.h"
 #include "nsContentPermissionHelper.h"
+#include "nsEventDispatcher.h"
 
 #include "mozilla/dom/DeviceStorageBinding.h"
 
 // Microsoft's API Name hackery sucks
 #undef CreateEvent
 
 #ifdef MOZ_WIDGET_GONK
 #include "nsIVolume.h"
@@ -4270,17 +4271,17 @@ nsDOMDeviceStorage::GetTargetForDOMEvent
 
 EventTarget *
 nsDOMDeviceStorage::GetTargetForEventTargetChain()
 {
   return nsDOMEventTargetHelper::GetTargetForEventTargetChain();
 }
 
 nsresult
-nsDOMDeviceStorage::PreHandleEvent(nsEventChainPreVisitor & aVisitor)
+nsDOMDeviceStorage::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   return nsDOMEventTargetHelper::PreHandleEvent(aVisitor);
 }
 
 nsresult
 nsDOMDeviceStorage::WillHandleEvent(nsEventChainPostVisitor & aVisitor)
 {
   return nsDOMEventTargetHelper::WillHandleEvent(aVisitor);
--- a/dom/events/nsDOMEventTargetHelper.cpp
+++ b/dom/events/nsDOMEventTargetHelper.cpp
@@ -292,17 +292,17 @@ nsDOMEventTargetHelper::GetEventHandler(
   if (handler) {
     *aValue = JS::ObjectValue(*handler->Callable());
   } else {
     *aValue = JS::NullValue();
   }
 }
 
 nsresult
-nsDOMEventTargetHelper::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+nsDOMEventTargetHelper::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   aVisitor.mCanHandle = true;
   aVisitor.mParentTarget = nullptr;
   return NS_OK;
 }
 
 nsresult
 nsDOMEventTargetHelper::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
--- a/dom/events/nsEventDispatcher.cpp
+++ b/dom/events/nsEventDispatcher.cpp
@@ -159,17 +159,17 @@ public:
                                      nsEventChainPostVisitor& aVisitor,
                                      nsDispatchingCallback* aCallback,
                                      ELMCreationDetector& aCd);
 
   /**
    * Resets aVisitor object and calls PreHandleEvent.
    * Copies mItemFlags and mItemData to the current nsEventTargetChainItem.
    */
-  void PreHandleEvent(nsEventChainPreVisitor& aVisitor);
+  void PreHandleEvent(EventChainPreVisitor& aVisitor);
 
   /**
    * If the current item in the event target chain has an event listener
    * manager, this method calls EventListenerManager::HandleEvent().
    */
   void HandleEvent(nsEventChainPostVisitor& aVisitor,
                    ELMCreationDetector& aCd)
   {
@@ -214,17 +214,17 @@ public:
 
 nsEventTargetChainItem::nsEventTargetChainItem(EventTarget* aTarget)
 : mTarget(aTarget), mFlags(0), mItemFlags(0)
 {
   MOZ_ASSERT(!aTarget || mTarget == aTarget->GetTargetForEventTargetChain());
 }
 
 void
-nsEventTargetChainItem::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+nsEventTargetChainItem::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   aVisitor.Reset();
   unused << mTarget->PreHandleEvent(aVisitor);
   SetForceContentDispatch(aVisitor.mForceContentDispatch);
   SetWantsWillHandleEvent(aVisitor.mWantsWillHandleEvent);
   SetMayHaveListenerManager(aVisitor.mMayHaveListenerManager);
   mItemFlags = aVisitor.mItemFlags;
   mItemData = aVisitor.mItemData;
@@ -510,18 +510,18 @@ nsEventDispatcher::Dispatch(nsISupports*
   nsCOMPtr<nsIContent> content = do_QueryInterface(aEvent->originalTarget);
   bool isInAnon = (content && content->IsInAnonymousSubtree());
 
   aEvent->mFlags.mIsBeingDispatched = true;
 
   // Create visitor object and start event dispatching.
   // PreHandleEvent for the original target.
   nsEventStatus status = aEventStatus ? *aEventStatus : nsEventStatus_eIgnore;
-  nsEventChainPreVisitor preVisitor(aPresContext, aEvent, aDOMEvent, status,
-                                    isInAnon);
+  EventChainPreVisitor preVisitor(aPresContext, aEvent, aDOMEvent, status,
+                                  isInAnon);
   targetEtci->PreHandleEvent(preVisitor);
 
   if (!preVisitor.mCanHandle && preVisitor.mAutomaticChromeDispatch && content) {
     // Event target couldn't handle the event. Try to propagate to chrome.
     nsEventTargetChainItem::DestroyLast(chain, targetEtci);
     targetEtci = EventTargetChainItemForChromeTarget(chain, content);
     NS_ENSURE_STATE(targetEtci);
     MOZ_ASSERT(&chain[0] == targetEtci);
--- a/dom/events/nsEventDispatcher.h
+++ b/dom/events/nsEventDispatcher.h
@@ -26,17 +26,17 @@ class EventTarget;
 } // namespace dom
 
 /**
  * About event dispatching:
  * When either nsEventDispatcher::Dispatch or
  * nsEventDispatcher::DispatchDOMEvent is called an event target chain is
  * created. nsEventDispatcher creates the chain by calling PreHandleEvent 
  * on each event target and the creation continues until either the mCanHandle
- * member of the nsEventChainPreVisitor object is false or the mParentTarget
+ * member of the EventChainPreVisitor object is false or the mParentTarget
  * does not point to a new target. The event target chain is created in the
  * heap.
  *
  * If the event needs retargeting, mEventTargetAtParent must be set in
  * PreHandleEvent.
  *
  * The capture, target and bubble phases of the event dispatch are handled
  * by iterating through the event target chain. Iteration happens twice,
@@ -100,34 +100,39 @@ public:
    *
    * @note This data is different for each item in the event target chain.
    *       It is up to the Pre/PostHandleEvent implementation to decide how to
    *       use this.
    */
   nsCOMPtr<nsISupports> mItemData;
 };
 
-} // namespace mozilla
-
-class nsEventChainPreVisitor : public mozilla::EventChainVisitor
+class EventChainPreVisitor : public EventChainVisitor
 {
 public:
-  nsEventChainPreVisitor(nsPresContext* aPresContext,
-                         mozilla::WidgetEvent* aEvent,
-                         nsIDOMEvent* aDOMEvent,
-                         nsEventStatus aEventStatus,
-                         bool aIsInAnon)
-  : mozilla::EventChainVisitor(aPresContext, aEvent, aDOMEvent, aEventStatus),
-    mCanHandle(true), mAutomaticChromeDispatch(true),
-    mForceContentDispatch(false), mRelatedTargetIsInAnon(false),
-    mOriginalTargetIsInAnon(aIsInAnon), mWantsWillHandleEvent(false),
-    mMayHaveListenerManager(true), mParentTarget(nullptr),
-    mEventTargetAtParent(nullptr) {}
+  EventChainPreVisitor(nsPresContext* aPresContext,
+                       WidgetEvent* aEvent,
+                       nsIDOMEvent* aDOMEvent,
+                       nsEventStatus aEventStatus,
+                       bool aIsInAnon)
+    : EventChainVisitor(aPresContext, aEvent, aDOMEvent, aEventStatus)
+    , mCanHandle(true)
+    , mAutomaticChromeDispatch(true)
+    , mForceContentDispatch(false)
+    , mRelatedTargetIsInAnon(false)
+    , mOriginalTargetIsInAnon(aIsInAnon)
+    , mWantsWillHandleEvent(false)
+    , mMayHaveListenerManager(true)
+    , mParentTarget(nullptr)
+    , mEventTargetAtParent(nullptr)
+  {
+  }
 
-  void Reset() {
+  void Reset()
+  {
     mItemFlags = 0;
     mItemData = nullptr;
     mCanHandle = true;
     mAutomaticChromeDispatch = true;
     mForceContentDispatch = false;
     mWantsWillHandleEvent = false;
     mMayHaveListenerManager = true;
     mParentTarget = nullptr;
@@ -177,25 +182,27 @@ public:
    * If it is known that the current target doesn't have a listener manager
    * when PreHandleEvent is called, set this to false.
    */
   bool                  mMayHaveListenerManager;
 
   /**
    * Parent item in the event target chain.
    */
-  mozilla::dom::EventTarget* mParentTarget;
+  dom::EventTarget* mParentTarget;
 
   /**
    * If the event needs to be retargeted, this is the event target,
    * which should be used when the event is handled at mParentTarget.
    */
-  mozilla::dom::EventTarget* mEventTargetAtParent;
+  dom::EventTarget* mEventTargetAtParent;
 };
 
+} // namespace mozilla
+
 class nsEventChainPostVisitor : public mozilla::EventChainVisitor
 {
 public:
   nsEventChainPostVisitor(mozilla::EventChainVisitor& aOther)
   : mozilla::EventChainVisitor(aOther.mPresContext, aOther.mEvent,
                                aOther.mDOMEvent, aOther.mEventStatus)
   {
   }
--- a/dom/file/ArchiveRequest.cpp
+++ b/dom/file/ArchiveRequest.cpp
@@ -6,16 +6,18 @@
 
 #include "ArchiveRequest.h"
 
 #include "mozilla/dom/ArchiveRequestBinding.h"
 #include "nsContentUtils.h"
 #include "nsCxPusher.h"
 #include "nsEventDispatcher.h"
 
+using namespace mozilla;
+
 USING_FILE_NAMESPACE
 
 /**
  * Class used to make asynchronous the ArchiveRequest.
  */
 class ArchiveRequestEvent : public nsRunnable
 {
 public:
@@ -61,17 +63,17 @@ ArchiveRequest::ArchiveRequest(nsPIDOMWi
 }
 
 ArchiveRequest::~ArchiveRequest()
 {
   MOZ_COUNT_DTOR(ArchiveRequest);
 }
 
 nsresult
-ArchiveRequest::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+ArchiveRequest::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   aVisitor.mCanHandle = true;
   aVisitor.mParentTarget = nullptr;
   return NS_OK;
 }
 
 /* virtual */ JSObject*
 ArchiveRequest::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
--- a/dom/file/ArchiveRequest.h
+++ b/dom/file/ArchiveRequest.h
@@ -8,16 +8,19 @@
 #define mozilla_dom_file_domarchiverequest_h__
 
 #include "mozilla/Attributes.h"
 #include "ArchiveReader.h"
 #include "DOMRequest.h"
 
 #include "FileCommon.h"
 
+namespace mozilla {
+class EventChainPreVisitor;
+} // namespace mozilla
 
 BEGIN_FILE_NAMESPACE
 
 /**
  * This is the ArchiveRequest that handles any operation
  * related to ArchiveReader
  */
 class ArchiveRequest : public mozilla::dom::DOMRequest
@@ -31,17 +34,17 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ArchiveRequest, DOMRequest)
 
   ArchiveRequest(nsPIDOMWindow* aWindow,
                  ArchiveReader* aReader);
 
   // nsIDOMEventTarget
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
 
 public:
   // This is called by the DOMArchiveRequestEvent
   void Run();
 
   // Set the types for this request
   void OpGetFilenames();
   void OpGetFile(const nsAString& aFilename);
--- a/dom/file/FileRequest.cpp
+++ b/dom/file/FileRequest.cpp
@@ -10,16 +10,18 @@
 #include "nsCxPusher.h"
 #include "nsEventDispatcher.h"
 #include "nsError.h"
 #include "nsIDOMProgressEvent.h"
 #include "nsDOMClassInfoID.h"
 #include "FileHelper.h"
 #include "LockedFile.h"
 
+using namespace mozilla;
+
 USING_FILE_NAMESPACE
 
 FileRequest::FileRequest(nsPIDOMWindow* aWindow)
   : DOMRequest(aWindow), mWrapAsDOMRequest(false)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 }
 
@@ -38,17 +40,17 @@ FileRequest::Create(nsPIDOMWindow* aOwne
   nsRefPtr<FileRequest> request = new FileRequest(aOwner);
   request->mLockedFile = aLockedFile;
   request->mWrapAsDOMRequest = aWrapAsDOMRequest;
 
   return request.forget();
 }
 
 nsresult
-FileRequest::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+FileRequest::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   aVisitor.mCanHandle = true;
   aVisitor.mParentTarget = mLockedFile;
   return NS_OK;
 }
 
--- a/dom/file/FileRequest.h
+++ b/dom/file/FileRequest.h
@@ -9,16 +9,20 @@
 
 #include "mozilla/Attributes.h"
 #include "FileCommon.h"
 
 #include "DOMRequest.h"
 
 class nsIDOMLockedFile;
 
+namespace mozilla {
+class EventChainPreVisitor;
+} // namespace mozilla
+
 BEGIN_FILE_NAMESPACE
 
 class FileHelper;
 class LockedFile;
 
 class FileRequest : public mozilla::dom::DOMRequest
 {
 public:
@@ -26,17 +30,17 @@ public:
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FileRequest, DOMRequest)
 
   static already_AddRefed<FileRequest>
   Create(nsPIDOMWindow* aOwner, LockedFile* aLockedFile,
          bool aWrapAsDOMRequest);
 
   // nsIDOMEventTarget
   virtual nsresult
-  PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
 
   void
   OnProgress(uint64_t aProgress, uint64_t aProgressMax)
   {
     FireProgressEvent(aProgress, aProgressMax);
   }
 
   nsresult
--- a/dom/file/LockedFile.cpp
+++ b/dom/file/LockedFile.cpp
@@ -336,17 +336,17 @@ NS_IMPL_RELEASE_INHERITED(LockedFile, ns
 
 DOMCI_DATA(LockedFile, LockedFile)
 
 NS_IMPL_EVENT_HANDLER(LockedFile, complete)
 NS_IMPL_EVENT_HANDLER(LockedFile, abort)
 NS_IMPL_EVENT_HANDLER(LockedFile, error)
 
 nsresult
-LockedFile::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+LockedFile::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   aVisitor.mCanHandle = true;
   aVisitor.mParentTarget = mFileHandle;
   return NS_OK;
 }
 
--- a/dom/file/LockedFile.h
+++ b/dom/file/LockedFile.h
@@ -12,16 +12,20 @@
 #include "mozilla/dom/FileModeBinding.h"
 #include "nsIDOMLockedFile.h"
 #include "nsIRunnable.h"
 
 #include "nsDOMEventTargetHelper.h"
 
 class nsIInputStream;
 
+namespace mozilla {
+class EventChainPreVisitor;
+} // namespace mozilla
+
 BEGIN_FILE_NAMESPACE
 
 class FileHandle;
 class FileRequest;
 class MetadataHelper;
 
 class LockedFile : public nsDOMEventTargetHelper,
                    public nsIDOMLockedFile,
@@ -55,17 +59,17 @@ public:
 
   static already_AddRefed<LockedFile>
   Create(FileHandle* aFileHandle,
          FileMode aMode,
          RequestMode aRequestMode = NORMAL);
 
   // nsIDOMEventTarget
   virtual nsresult
-  PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
 
   nsresult
   CreateParallelStream(nsISupports** aStream);
 
   nsresult
   GetOrCreateStream(nsISupports** aStream);
 
   bool
--- a/dom/indexedDB/IDBRequest.cpp
+++ b/dom/indexedDB/IDBRequest.cpp
@@ -381,17 +381,17 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IDBRequest)
 NS_INTERFACE_MAP_END_INHERITING(IDBWrapperCache)
 
 NS_IMPL_ADDREF_INHERITED(IDBRequest, IDBWrapperCache)
 NS_IMPL_RELEASE_INHERITED(IDBRequest, IDBWrapperCache)
 
 nsresult
-IDBRequest::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+IDBRequest::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   aVisitor.mCanHandle = true;
   aVisitor.mParentTarget = mTransaction;
   return NS_OK;
 }
 
--- a/dom/indexedDB/IDBRequest.h
+++ b/dom/indexedDB/IDBRequest.h
@@ -18,16 +18,17 @@
 #include "nsWrapperCache.h"
 
 #include "mozilla/dom/indexedDB/IDBWrapperCache.h"
 
 class nsIScriptContext;
 class nsPIDOMWindow;
 
 namespace mozilla {
+class EventChainPreVisitor;
 namespace dom {
 class OwningIDBObjectStoreOrIDBIndexOrIDBCursor;
 class ErrorEventInit;
 }
 }
 
 BEGIN_INDEXEDDB_NAMESPACE
 
@@ -56,17 +57,17 @@ public:
                                       IDBTransaction* aTransaction);
 
   static
   already_AddRefed<IDBRequest> Create(IDBIndex* aSource,
                                       IDBDatabase* aDatabase,
                                       IDBTransaction* aTransaction);
 
   // nsIDOMEventTarget
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
 
   void GetSource(Nullable<OwningIDBObjectStoreOrIDBIndexOrIDBCursor>& aSource) const;
 
   void Reset();
 
   nsresult NotifyHelperCompleted(HelperBase* aHelper);
   void NotifyHelperSentResultsToChildProcess(nsresult aRv);
 
--- a/dom/indexedDB/IDBTransaction.cpp
+++ b/dom/indexedDB/IDBTransaction.cpp
@@ -31,16 +31,17 @@
 #include "ProfilerHelpers.h"
 #include "ReportInternalError.h"
 #include "TransactionThreadPool.h"
 
 #include "ipc/IndexedDBChild.h"
 
 #define SAVEPOINT_NAME "savepoint"
 
+using namespace mozilla;
 using namespace mozilla::dom;
 USING_INDEXEDDB_NAMESPACE
 using mozilla::dom::quota::QuotaManager;
 using mozilla::ErrorResult;
 
 namespace {
 
 NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
@@ -717,17 +718,17 @@ IDBTransaction::ObjectStore(const nsAStr
     aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
     return nullptr;
   }
 
   return objectStore.forget();
 }
 
 nsresult
-IDBTransaction::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+IDBTransaction::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   aVisitor.mCanHandle = true;
   aVisitor.mParentTarget = mDatabase;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 IDBTransaction::Run()
--- a/dom/indexedDB/IDBTransaction.h
+++ b/dom/indexedDB/IDBTransaction.h
@@ -25,16 +25,20 @@
 #include "mozilla/dom/IDBTransactionBinding.h"
 #include "mozilla/dom/indexedDB/IDBDatabase.h"
 #include "mozilla/dom/indexedDB/IDBWrapperCache.h"
 #include "mozilla/dom/indexedDB/FileInfo.h"
 
 class nsIThread;
 class nsPIDOMWindow;
 
+namespace mozilla {
+class EventChainPreVisitor;
+} // namespace mozilla
+
 BEGIN_INDEXEDDB_NAMESPACE
 
 class AsyncConnectionHelper;
 class CommitHelper;
 class IDBRequest;
 class IndexedDBDatabaseChild;
 class IndexedDBTransactionChild;
 class IndexedDBTransactionParent;
@@ -93,17 +97,17 @@ public:
          Mode aMode,
          bool aDispatchDelayed)
   {
     return CreateInternal(aDatabase, aObjectStoreNames, aMode, aDispatchDelayed,
                           false);
   }
 
   // nsIDOMEventTarget
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
 
   void OnNewRequest();
   void OnRequestFinished();
   void OnRequestDisconnected();
 
   void RemoveObjectStore(const nsAString& aName);
 
   void SetTransactionListener(IDBTransactionListener* aListener);
--- a/dom/interfaces/events/nsIDOMEventTarget.idl
+++ b/dom/interfaces/events/nsIDOMEventTarget.idl
@@ -8,41 +8,41 @@
 %{C++
 #include "mozilla/EventForwards.h"
 #include "mozilla/dom/Nullable.h"
 #include "js/TypeDecls.h"
 
 using mozilla::dom::Nullable;
 
 namespace mozilla {
+class EventChainPreVisitor;
 class EventListenerManager;
 namespace dom {
 class EventTarget;
 } // namespace dom
 } // namespace mozilla
 
 class nsPresContext;
-class nsEventChainPreVisitor;
 class nsEventChainPostVisitor;
 %}
 
 /**
  * The nsIDOMEventTarget interface is the interface implemented by all
  * event targets in the Document Object Model.
  *
  * For more information on this interface please see 
  * http://www.w3.org/TR/DOM-Level-2-Events/
  */
 
-[ref] native nsEventChainPreVisitorRef(nsEventChainPreVisitor);
 [ref] native nsEventChainPostVisitorRef(nsEventChainPostVisitor);
 [ptr] native WidgetEventPtr(mozilla::WidgetEvent);
 [ptr] native nsPresContextPtr(nsPresContext);
 [ptr] native nsEventStatusPtr(nsEventStatus);
 [ptr] native JSContextPtr(JSContext);
+[ref] native EventChainPreVisitorRef(mozilla::EventChainPreVisitor);
 [ptr] native EventListenerManagerPtr(mozilla::EventListenerManager);
 [ptr] native EventTargetPtr(mozilla::dom::EventTarget);
 
 interface nsIScriptContext;
 interface nsIDOMEventListener;
 interface nsIDOMEvent;
 
 [scriptable, builtinclass, uuid(b128448c-7b53-4769-92cb-cd6eafee676c)]
@@ -206,33 +206,33 @@ interface nsIDOMEventTarget : nsISupport
    * Usually |this| is returned, but for example global object returns
    * the inner object.
    */
    [notxpcom, nostdcall] EventTargetPtr GetTargetForEventTargetChain();
 
   /**
    * Called before the capture phase of the event flow.
    * This is used to create the event target chain and implementations
-   * should set the necessary members of nsEventChainPreVisitor.
+   * should set the necessary members of EventChainPreVisitor.
    * At least aVisitor.mCanHandle must be set,
    * usually also aVisitor.mParentTarget if mCanHandle is PR_TRUE.
    * First one tells that this object can handle the aVisitor.mEvent event and
    * the latter one is the possible parent object for the event target chain.
    * @see nsEventDispatcher.h for more documentation about aVisitor.
    *
    * @param aVisitor the visitor object which is used to create the
    *                 event target chain for event dispatching.
    *
    * @note Only nsEventDispatcher should call this method.
    */
   [noscript, nostdcall]
-  void PreHandleEvent(in nsEventChainPreVisitorRef aVisitor);
+  void PreHandleEvent(in EventChainPreVisitorRef aVisitor);
 
   /**
-   * If nsEventChainPreVisitor.mWantsWillHandleEvent is set PR_TRUE,
+   * If EventChainPreVisitor.mWantsWillHandleEvent is set PR_TRUE,
    * called just before possible event handlers on this object will be called.
    */
   [noscript, nostdcall]
   void WillHandleEvent(in nsEventChainPostVisitorRef aVisitor);
 
   /**
    * Called after the bubble phase of the system event group.
    * The default handling of the event should happen here.
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -113,17 +113,17 @@ public:
   {
     return nsDOMEventTargetHelper::AddEventListener(aType, aListener,
                                                     aUseCapture,
                                                     aWantsUntrusted,
                                                     optional_argc);
   }
 
   nsresult
-  PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+  PreHandleEvent(EventChainPreVisitor& aVisitor)
   {
     aVisitor.mForceContentDispatch = true;
     return NS_OK;
   }
 
   virtual JSContext* GetJSContextForEventHandlers() MOZ_OVERRIDE;
   virtual nsIPrincipal* GetPrincipal() MOZ_OVERRIDE;
   virtual JSObject* GetGlobalJSObject() MOZ_OVERRIDE;
--- a/dom/workers/MessagePort.cpp
+++ b/dom/workers/MessagePort.cpp
@@ -12,16 +12,17 @@
 #include "SharedWorker.h"
 #include "WorkerPrivate.h"
 #include "WorkerRunnable.h"
 
 using mozilla::dom::EventHandlerNonNull;
 using mozilla::dom::MessagePortBase;
 using mozilla::dom::Optional;
 using mozilla::dom::Sequence;
+using namespace mozilla;
 
 USING_WORKERS_NAMESPACE
 
 namespace {
 
 class DelayedEventRunnable MOZ_FINAL : public WorkerRunnable
 {
   nsRefPtr<MessagePort> mMessagePort;
@@ -239,17 +240,17 @@ JSObject*
 MessagePort::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   AssertCorrectThread();
 
   return MessagePortBinding::Wrap(aCx, aScope, this);
 }
 
 nsresult
-MessagePort::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+MessagePort::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   AssertCorrectThread();
 
   nsIDOMEvent*& event = aVisitor.mDOMEvent;
 
   if (event) {
     bool preventDispatch = false;
 
--- a/dom/workers/MessagePort.h
+++ b/dom/workers/MessagePort.h
@@ -10,16 +10,20 @@
 
 #include "nsDOMEventTargetHelper.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/MessagePort.h"
 
 class nsIDOMEvent;
 class nsPIDOMWindow;
 
+namespace mozilla {
+class EventChainPreVisitor;
+} // namespace mozilla
+
 BEGIN_WORKERS_NAMESPACE
 
 class SharedWorker;
 class WorkerPrivate;
 
 class MessagePort MOZ_FINAL : public mozilla::dom::MessagePortBase
 {
   friend class SharedWorker;
@@ -74,17 +78,17 @@ public:
   {
     return !mSharedWorker && !mWorkerPrivate;
   }
 
   virtual JSObject*
   WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   virtual nsresult
-  PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
 
 #ifdef DEBUG
   void
   AssertCorrectThread() const;
 #else
   void
   AssertCorrectThread() const { }
 #endif
--- a/dom/workers/SharedWorker.cpp
+++ b/dom/workers/SharedWorker.cpp
@@ -15,16 +15,17 @@
 #include "nsIDOMEvent.h"
 
 #include "MessagePort.h"
 #include "RuntimeService.h"
 #include "WorkerPrivate.h"
 
 using mozilla::dom::Optional;
 using mozilla::dom::Sequence;
+using namespace mozilla;
 
 USING_WORKERS_NAMESPACE
 
 SharedWorker::SharedWorker(nsPIDOMWindow* aWindow,
                            WorkerPrivate* aWorkerPrivate)
 : nsDOMEventTargetHelper(aWindow), mWorkerPrivate(aWorkerPrivate),
   mSuspended(false)
 {
@@ -193,17 +194,17 @@ JSObject*
 SharedWorker::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   AssertIsOnMainThread();
 
   return SharedWorkerBinding::Wrap(aCx, aScope, this);
 }
 
 nsresult
-SharedWorker::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
+SharedWorker::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   AssertIsOnMainThread();
 
   nsIDOMEvent*& event = aVisitor.mDOMEvent;
 
   if (IsSuspended() && event) {
     QueueEvent(event);
 
--- a/dom/workers/SharedWorker.h
+++ b/dom/workers/SharedWorker.h
@@ -10,16 +10,20 @@
 
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/workers/bindings/MessagePort.h"
 #include "nsDOMEventTargetHelper.h"
 
 class nsIDOMEvent;
 class nsPIDOMWindow;
 
+namespace mozilla {
+class EventChainPreVisitor;
+} // namespace mozilla
+
 BEGIN_WORKERS_NAMESPACE
 
 class MessagePort;
 class RuntimeService;
 class WorkerPrivate;
 
 class SharedWorker MOZ_FINAL : public nsDOMEventTargetHelper
 {
@@ -72,17 +76,17 @@ public:
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SharedWorker, nsDOMEventTargetHelper)
 
   IMPL_EVENT_HANDLER(error)
 
   virtual JSObject*
   WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   virtual nsresult
-  PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
+  PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
 
   WorkerPrivate*
   GetWorkerPrivate() const
   {
     return mWorkerPrivate;
   }
 
 private:
--- a/widget/BasicEvents.h
+++ b/widget/BasicEvents.h
@@ -541,17 +541,17 @@ public:
   // native anonymous subtree, the event target is set to originalTarget.
   bool    mRetargetToNonNativeAnonymous : 1;
   // If mNoCrossProcessBoundaryForwarding is true, the event is not allowed to
   // cross process boundary.
   bool    mNoCrossProcessBoundaryForwarding : 1;
   // If mNoContentDispatch is true, the event is never dispatched to the
   // event handlers which are added to the contents, onfoo attributes and
   // properties.  Note that this flag is ignored when
-  // nsEventChainPreVisitor::mForceContentDispatch is set true.  For exapmle,
+  // EventChainPreVisitor::mForceContentDispatch is set true.  For exapmle,
   // window and document object sets it true.  Therefore, web applications
   // can handle the event if they add event listeners to the window or the
   // document.
   bool    mNoContentDispatch : 1;
   // If mOnlyChromeDispatch is true, the event is dispatched to only chrome.
   bool    mOnlyChromeDispatch : 1;
 
   // If the event is being handled in target phase, returns true.