Bug 610305: decom nsEventStateManager r=smaug
☠☠ backed out by be6f4759e827 ☠ ☠
authorDavid Zbarsky <dzbarsky@gmail.com>
Wed, 20 Apr 2011 21:42:33 +0200
changeset 68385 c1a7c1bc1aebf0c45092426dfc317b9105238a5b
parent 68384 4230d1472963c66fb480e598463b7958ebffa32b
child 68386 be6f4759e82736e21e24e46d22701e7d90a71f91
push id19618
push usermlamouri@mozilla.com
push dateThu, 21 Apr 2011 08:13:26 +0000
treeherdermozilla-central@7cdcae5dee49 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs610305
milestone6.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 610305: decom nsEventStateManager r=smaug
accessible/src/base/AccEvent.cpp
accessible/src/base/nsAccessibilityService.cpp
accessible/src/base/nsAccessible.cpp
accessible/src/base/nsCoreUtils.cpp
accessible/src/base/nsCoreUtils.h
accessible/src/base/nsDocAccessible.cpp
accessible/src/html/nsHTMLLinkAccessible.cpp
accessible/src/xul/nsXULMenuAccessible.cpp
content/base/public/nsIContent.h
content/base/src/Link.cpp
content/base/src/nsDocument.cpp
content/base/src/nsGenConImageContent.cpp
content/base/src/nsGenericElement.cpp
content/base/src/nsImageLoadingContent.cpp
content/base/src/nsObjectLoadingContent.cpp
content/events/public/Makefile.in
content/events/public/nsIEventStateManager.h
content/events/src/Makefile.in
content/events/src/nsDOMDragEvent.cpp
content/events/src/nsDOMEvent.cpp
content/events/src/nsDOMMouseEvent.cpp
content/events/src/nsDOMMouseScrollEvent.cpp
content/events/src/nsDOMUIEvent.cpp
content/events/src/nsEventListenerManager.cpp
content/events/src/nsEventStateManager.cpp
content/events/src/nsEventStateManager.h
content/html/content/src/nsGenericHTMLElement.cpp
content/html/content/src/nsHTMLAnchorElement.cpp
content/html/content/src/nsHTMLAreaElement.cpp
content/html/content/src/nsHTMLButtonElement.cpp
content/html/content/src/nsHTMLFormElement.cpp
content/html/content/src/nsHTMLInputElement.cpp
content/html/content/src/nsHTMLLabelElement.cpp
content/html/content/src/nsHTMLLegendElement.cpp
content/html/content/src/nsHTMLOptGroupElement.cpp
content/html/content/src/nsHTMLOptionElement.cpp
content/html/content/src/nsHTMLOutputElement.cpp
content/html/content/src/nsHTMLSelectElement.cpp
content/html/content/src/nsHTMLTextAreaElement.cpp
content/html/content/src/nsRadioVisitor.cpp
content/html/document/src/nsHTMLDocument.cpp
content/mathml/content/src/nsMathMLElement.cpp
content/xtf/src/nsXTFElementWrapper.cpp
content/xul/content/src/nsXULElement.cpp
content/xul/content/src/nsXULPopupListener.cpp
docshell/base/nsDocShell.cpp
dom/base/nsDOMWindowUtils.cpp
dom/base/nsFocusManager.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsWindowRoot.cpp
editor/libeditor/base/nsEditorEventListener.cpp
editor/libeditor/html/nsHTMLEditor.cpp
embedding/components/find/src/nsWebBrowserFind.cpp
extensions/spellcheck/src/mozInlineSpellChecker.cpp
layout/base/nsCSSFrameConstructor.cpp
layout/base/nsDocumentViewer.cpp
layout/base/nsPresContext.h
layout/base/nsPresShell.cpp
layout/forms/nsButtonFrameRenderer.cpp
layout/forms/nsFileControlFrame.cpp
layout/forms/nsFormControlFrame.cpp
layout/forms/nsListControlFrame.cpp
layout/forms/nsTextControlFrame.cpp
layout/generic/nsContainerFrame.cpp
layout/generic/nsFrame.cpp
layout/generic/nsImageFrame.cpp
layout/inspector/src/inDOMUtils.cpp
layout/inspector/src/inDOMUtils.h
layout/inspector/src/inLayoutUtils.cpp
layout/inspector/src/inLayoutUtils.h
layout/printing/nsPrintPreviewListener.cpp
layout/style/nsCSSRuleProcessor.cpp
layout/style/nsHTMLStyleSheet.cpp
layout/style/nsIStyleRuleProcessor.h
layout/style/nsStyleSet.cpp
layout/xul/base/src/nsBoxFrame.cpp
layout/xul/base/src/nsButtonBoxFrame.cpp
layout/xul/base/src/nsMenuBarListener.cpp
layout/xul/base/src/nsMenuPopupFrame.cpp
layout/xul/base/src/nsTextBoxFrame.cpp
layout/xul/base/src/nsXULLabelFrame.cpp
layout/xul/base/src/tree/src/nsTreeContentView.cpp
toolkit/components/places/History.cpp
toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
widget/src/cocoa/nsNativeThemeCocoa.mm
widget/src/qt/nsNativeThemeQt.cpp
widget/src/windows/nsNativeThemeWin.cpp
widget/src/xpwidgets/nsBaseDragService.cpp
widget/src/xpwidgets/nsNativeTheme.cpp
widget/src/xpwidgets/nsNativeTheme.h
--- a/accessible/src/base/AccEvent.cpp
+++ b/accessible/src/base/AccEvent.cpp
@@ -45,17 +45,17 @@
 #include "nsDocAccessible.h"
 #include "nsIAccessibleText.h"
 #ifdef MOZ_XUL
 #include "nsXULTreeAccessible.h"
 #endif
 #include "nsAccEvent.h"
 
 #include "nsIDOMDocument.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStateManager.h"
 #include "nsIServiceManager.h"
 #ifdef MOZ_XUL
 #include "nsIDOMXULMultSelectCntrlEl.h"
 #endif
 
 ////////////////////////////////////////////////////////////////////////////////
 // AccEvent
 ////////////////////////////////////////////////////////////////////////////////
@@ -198,17 +198,17 @@ AccEvent::CaptureIsFromUserInput(EIsFrom
     return;
 
   nsIPresShell *presShell = nsCoreUtils::GetPresShellFor(targetNode);
   if (!presShell) {
     NS_NOTREACHED("Threre should always be an pres shell for an event");
     return;
   }
 
-  nsIEventStateManager *esm = presShell->GetPresContext()->EventStateManager();
+  nsEventStateManager *esm = presShell->GetPresContext()->EventStateManager();
   if (!esm) {
     NS_NOTREACHED("There should always be an ESM for an event");
     return;
   }
 
   mIsFromUserInput = esm->IsHandlingUserInputExternal();
 }
 
--- a/accessible/src/base/nsAccessibilityService.cpp
+++ b/accessible/src/base/nsAccessibilityService.cpp
@@ -70,17 +70,17 @@
 #include "nsIObserverService.h"
 #include "nsIPluginInstance.h"
 #include "nsISupportsUtils.h"
 #include "nsObjectFrame.h"
 #include "nsOuterDocAccessible.h"
 #include "nsRootAccessibleWrap.h"
 #include "nsTextFragment.h"
 #include "mozilla/Services.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 
 #ifdef MOZ_XUL
 #include "nsXULAlertAccessible.h"
 #include "nsXULColorPickerAccessible.h"
 #include "nsXULComboboxAccessible.h"
 #include "nsXULFormControlAccessible.h"
 #include "nsXULListboxAccessibleWrap.h"
 #include "nsXULMenuAccessibleWrap.h"
--- a/accessible/src/base/nsAccessible.cpp
+++ b/accessible/src/base/nsAccessible.cpp
@@ -94,17 +94,17 @@
 #include "nsIURI.h"
 #include "nsArrayUtils.h"
 #include "nsIMutableArray.h"
 #include "nsIObserverService.h"
 #include "nsIServiceManager.h"
 #include "nsWhitespaceTokenizer.h"
 #include "nsAttrName.h"
 #include "nsNetUtil.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 
 #ifdef NS_DEBUG
 #include "nsIDOMCharacterData.h"
 #endif
 
 #include "mozilla/unused.h"
 
 
--- a/accessible/src/base/nsCoreUtils.cpp
+++ b/accessible/src/base/nsCoreUtils.cpp
@@ -55,17 +55,17 @@
 #include "nsIDOMWindowInternal.h"
 #include "nsIDOMXULElement.h"
 #include "nsIDocShell.h"
 #include "nsIContentViewer.h"
 #include "nsIEventListenerManager.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
 #include "nsIScrollableFrame.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStateManager.h"
 #include "nsISelection2.h"
 #include "nsISelectionController.h"
 #include "nsPIDOMWindow.h"
 #include "nsGUIEvent.h"
 #include "nsIView.h"
 
 #include "nsContentCID.h"
 #include "nsComponentManagerUtils.h"
@@ -201,39 +201,37 @@ nsCoreUtils::DispatchMouseEvent(PRUint32
 PRUint32
 nsCoreUtils::GetAccessKeyFor(nsIContent *aContent)
 {
   if (!aContent)
     return 0;
 
   // Accesskeys are registered by @accesskey attribute only. At first check
   // whether it is presented on the given element to avoid the slow
-  // nsIEventStateManager::GetRegisteredAccessKey() method.
+  // nsEventStateManager::GetRegisteredAccessKey() method.
   if (!aContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::accesskey))
     return 0;
 
   nsCOMPtr<nsIDocument> doc = aContent->GetOwnerDoc();
   if (!doc)
     return 0;
 
   nsCOMPtr<nsIPresShell> presShell = doc->GetShell();
   if (!presShell)
     return 0;
 
   nsPresContext *presContext = presShell->GetPresContext();
   if (!presContext)
     return 0;
 
-  nsIEventStateManager *esm = presContext->EventStateManager();
+  nsEventStateManager *esm = presContext->EventStateManager();
   if (!esm)
     return 0;
 
-  PRUint32 key = 0;
-  esm->GetRegisteredAccessKey(aContent, &key);
-  return key;
+  return esm->GetRegisteredAccessKey(aContent);
 }
 
 nsIContent *
 nsCoreUtils::GetDOMElementFor(nsIContent *aContent)
 {
   if (aContent->IsElement())
     return aContent;
 
--- a/accessible/src/base/nsCoreUtils.h
+++ b/accessible/src/base/nsCoreUtils.h
@@ -105,17 +105,17 @@ public:
    */
   static void DispatchMouseEvent(PRUint32 aEventType, PRInt32 aX, PRInt32 aY,
                                  nsIContent *aContent, nsIFrame *aFrame,
                                  nsIPresShell *aPresShell,
                                  nsIWidget *aRootWidget);
 
   /**
    * Return an accesskey registered on the given element by
-   * nsIEventStateManager or 0 if there is no registered accesskey.
+   * nsEventStateManager or 0 if there is no registered accesskey.
    *
    * @param aContent - the given element.
    */
   static PRUint32 GetAccessKeyFor(nsIContent *aContent);
 
   /**
    * Return DOM element related with the given node, i.e.
    * a) itself if it is DOM element
--- a/accessible/src/base/nsDocAccessible.cpp
+++ b/accessible/src/base/nsDocAccessible.cpp
@@ -56,17 +56,17 @@
 #include "nsIDOMDocumentType.h"
 #include "nsIDOMNSDocument.h"
 #include "nsIDOMNSHTMLDocument.h"
 #include "nsIDOMXULDocument.h"
 #include "nsIDOMMutationEvent.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMXULPopupElement.h"
 #include "nsIEditingSession.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStateManager.h"
 #include "nsIFrame.h"
 #include "nsHTMLSelectAccessible.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsINameSpaceManager.h"
 #include "nsIPresShell.h"
 #include "nsIServiceManager.h"
 #include "nsIViewManager.h"
 #include "nsIScrollableFrame.h"
--- a/accessible/src/html/nsHTMLLinkAccessible.cpp
+++ b/accessible/src/html/nsHTMLLinkAccessible.cpp
@@ -37,17 +37,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsHTMLLinkAccessible.h"
 
 #include "States.h"
 #include "nsCoreUtils.h"
 
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsHTMLLinkAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 nsHTMLLinkAccessible::
   nsHTMLLinkAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
   nsHyperTextAccessibleWrap(aContent, aShell)
--- a/accessible/src/xul/nsXULMenuAccessible.cpp
+++ b/accessible/src/xul/nsXULMenuAccessible.cpp
@@ -396,17 +396,17 @@ nsXULMenuitemAccessible::GetKeyboardShor
 {
   aAccessKey.Truncate();
   if (IsDefunct())
     return NS_ERROR_FAILURE;
 
   static PRInt32 gMenuAccesskeyModifier = -1;  // magic value of -1 indicates unitialized state
 
   // We do not use nsCoreUtils::GetAccesskeyFor() because accesskeys for
-  // menu are't registered by nsIEventStateManager.
+  // menu are't registered by nsEventStateManager.
   nsAutoString accesskey;
   mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::accesskey,
                     accesskey);
   if (accesskey.IsEmpty())
     return NS_OK;
 
   nsAccessible* parentAcc = GetParent();
   if (parentAcc) {
--- a/content/base/public/nsIContent.h
+++ b/content/base/public/nsIContent.h
@@ -784,17 +784,17 @@ public:
   virtual PRBool IsDoneAddingChildren()
   {
     return PR_TRUE;
   }
 
   /**
    * Method to get the _intrinsic_ content state of this content node.  This is
    * the state that is independent of the node's presentation.  To get the full
-   * content state, use nsIEventStateManager.  Also see nsIEventStateManager
+   * content state, use nsEventStateManager.  Also see nsEventStateManager
    * for the possible bits that could be set here.
    */
   virtual nsEventStates IntrinsicState() const;
 
   /**
    * Get the ID of this content node (the atom corresponding to the
    * value of the null-namespace attribute whose name is given by
    * GetIDAttributeName().  This may be null if there is no ID.
--- a/content/base/src/Link.cpp
+++ b/content/base/src/Link.cpp
@@ -34,17 +34,17 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "Link.h"
 
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 #include "nsIURL.h"
 
 #include "nsContentUtils.h"
 #include "nsEscape.h"
 #include "nsGkAtoms.h"
 #include "nsString.h"
 #include "mozAutoDocUpdate.h"
 
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -54,17 +54,16 @@
 #include "plstr.h"
 #include "prprf.h"
 
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsDocument.h"
 #include "nsUnicharUtils.h"
 #include "nsIPrivateDOMEvent.h"
-#include "nsIEventStateManager.h"
 #include "nsContentList.h"
 #include "nsIObserver.h"
 #include "nsIBaseWindow.h"
 #include "mozilla/css/Loader.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIScriptRuntime.h"
 #include "nsCOMArray.h"
--- a/content/base/src/nsGenConImageContent.cpp
+++ b/content/base/src/nsGenConImageContent.cpp
@@ -41,17 +41,17 @@
  * in CSS can have an nsIImageLoadingContent but use an
  * imgIRequest that's already been loaded from the style system.
  */
 
 #include "nsContentCreatorFunctions.h"
 #include "nsXMLElement.h"
 #include "nsImageLoadingContent.h"
 #include "imgIRequest.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 
 class nsGenConImageContent : public nsXMLElement,
                              public nsImageLoadingContent
 {
 public:
   nsGenConImageContent(already_AddRefed<nsINodeInfo> aNodeInfo)
     : nsXMLElement(aNodeInfo)
   {
--- a/content/base/src/nsGenericElement.cpp
+++ b/content/base/src/nsGenericElement.cpp
@@ -61,17 +61,17 @@
 #include "nsNetUtil.h"
 #include "nsIFrame.h"
 #include "nsIAnonymousContentCreator.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
 #include "nsStyleConsts.h"
 #include "nsString.h"
 #include "nsUnicharUtils.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStateManager.h"
 #include "nsIDOMEvent.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsDOMCID.h"
 #include "nsIServiceManager.h"
 #include "nsIDOMCSSStyleDeclaration.h"
 #include "nsDOMCSSAttrDeclaration.h"
 #include "nsINameSpaceManager.h"
 #include "nsContentList.h"
@@ -105,17 +105,16 @@
 #endif
 #include "nsLayoutUtils.h"
 #include "nsGkAtoms.h"
 #include "nsContentUtils.h"
 #include "nsIJSContextStack.h"
 
 #include "nsIServiceManager.h"
 #include "nsIDOMEventListener.h"
-#include "nsEventStateManager.h"
 #include "nsIWebNavigation.h"
 #include "nsIBaseWindow.h"
 
 #include "jsapi.h"
 
 #include "nsNodeInfoManager.h"
 #include "nsICategoryManager.h"
 #include "nsIDOMNSFeatureFactory.h"
@@ -5374,20 +5373,18 @@ nsGenericElement::PostHandleEventForLink
           nsIFocusManager* fm = nsFocusManager::GetFocusManager();
           if (fm) {
             aVisitor.mEvent->flags |= NS_EVENT_FLAG_PREVENT_ANCHOR_ACTIONS;
             nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(this);
             fm->SetFocus(elem, nsIFocusManager::FLAG_BYMOUSE |
                                nsIFocusManager::FLAG_NOSCROLL);
           }
 
-          nsIEventStateManager* esm =
-            aVisitor.mPresContext->EventStateManager();
           nsEventStateManager::SetActiveManager(
-            static_cast<nsEventStateManager*>(esm), this);
+            aVisitor.mPresContext->EventStateManager(), this);
         }
       }
     }
     break;
 
   case NS_MOUSE_CLICK:
     if (NS_IS_MOUSE_LEFT_CLICK(aVisitor.mEvent)) {
       nsInputEvent* inputEvent = static_cast<nsInputEvent*>(aVisitor.mEvent);
--- a/content/base/src/nsImageLoadingContent.cpp
+++ b/content/base/src/nsImageLoadingContent.cpp
@@ -57,17 +57,17 @@
 #include "nsILoadGroup.h"
 #include "imgIContainer.h"
 #include "imgILoader.h"
 #include "nsThreadUtils.h"
 #include "nsNetUtil.h"
 #include "nsPLDOMEvent.h"
 
 #include "nsIPresShell.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 #include "nsGUIEvent.h"
 
 #include "nsIChannel.h"
 #include "nsIStreamListener.h"
 
 #include "nsIFrame.h"
 #include "nsIDOMNode.h"
 
--- a/content/base/src/nsObjectLoadingContent.cpp
+++ b/content/base/src/nsObjectLoadingContent.cpp
@@ -48,17 +48,17 @@
 #include "nsEventDispatcher.h"
 #include "nsIContent.h"
 #include "nsIDocShell.h"
 #include "nsIDocument.h"
 #include "nsIDOMDataContainerEvent.h"
 #include "nsIDOMDocumentEvent.h"
 #include "nsIDOMEventTarget.h"
 #include "nsIExternalProtocolHandler.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 #include "nsIObjectFrame.h"
 #include "nsIPluginDocument.h"
 #include "nsIPluginHost.h"
 #include "nsIPluginInstance.h"
 #include "nsIPresShell.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptSecurityManager.h"
--- a/content/events/public/Makefile.in
+++ b/content/events/public/Makefile.in
@@ -43,17 +43,16 @@ VPATH		= @srcdir@
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= content
 XPIDL_MODULE	= content_events
 
 EXPORTS		= \
 		nsMutationEvent.h \
 		nsIEventListenerManager.h \
-		nsIEventStateManager.h \
 		nsIPrivateDOMEvent.h \
 		nsIPrivateTextEvent.h \
 		nsIPrivateTextRange.h \
 		nsPLDOMEvent.h \
 		nsEventDispatcher.h \
 		nsPIDOMEventTarget.h \
 		nsEventStates.h \
 		$(NULL)
deleted file mode 100644
--- a/content/events/public/nsIEventStateManager.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef nsIEventStateManager_h__
-#define nsIEventStateManager_h__
-
-#include "nsEvent.h"
-#include "nsISupports.h"
-#include "nsEventStates.h"
-
-class nsIContent;
-class nsIDocument;
-class nsPresContext;
-class nsIDOMEvent;
-class nsIFrame;
-class nsIView;
-class nsIWidget;
-class imgIContainer;
-
-/*
- * Event state manager interface.
- */
-#define NS_IEVENTSTATEMANAGER_IID \
-{0x69ab5b16, 0x6690, 0x42fc, \
-  { 0xa9, 0xe5, 0xa3, 0xb4, 0xf8, 0x0f, 0xcb, 0xa6 } }
-
-#define NS_EVENT_NEEDS_FRAME(event) (!NS_IS_ACTIVATION_EVENT(event))
-
-class nsIEventStateManager : public nsISupports {
-
-public:
-  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IEVENTSTATEMANAGER_IID)
-
-  NS_IMETHOD Init() = 0;
-
-  NS_IMETHOD PreHandleEvent(nsPresContext* aPresContext, 
-                            nsEvent *aEvent, 
-                            nsIFrame* aTargetFrame,
-                            nsEventStatus* aStatus,
-                            nsIView* aView) = 0;
-
-  NS_IMETHOD PostHandleEvent(nsPresContext* aPresContext, 
-                             nsEvent *aEvent, 
-                             nsIFrame* aTargetFrame,
-                             nsEventStatus* aStatus,
-                             nsIView* aView) = 0;
-
-  NS_IMETHOD SetPresContext(nsPresContext* aPresContext) = 0;
-  NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame) = 0;
-
-  NS_IMETHOD GetEventTarget(nsIFrame **aFrame) = 0;
-  NS_IMETHOD GetEventTargetContent(nsEvent* aEvent, nsIContent** aContent) = 0;
-
-  /**
-   * Returns the content state of aContent.
-   * @param aContent      The control whose state is requested.
-   * @param aFollowLabels Whether to reflect a label's content state on its
-   *                      associated control. If aFollowLabels is true and
-   *                      aContent is a control which has a label that has the 
-   *                      hover or active content state set, GetContentState
-   *                      will pretend that those states are also set on aContent.
-   * @return              The content state.
-   */
-  virtual nsEventStates GetContentState(nsIContent *aContent,
-                                        PRBool aFollowLabels = PR_FALSE) = 0;
-
-  /**
-   * Notify that the given NS_EVENT_STATE_* bit has changed for this content.
-   * @param aContent Content which has changed states.  This may be null to
-   *                 indicate that nothing is in this state anymore.
-   * @param aState   One of NS_EVENT_STATE_ACTIVE, NS_EVENT_STATE_HOVER,
-   *                 NS_EVENT_STATE_DRAGOVER, NS_EVENT_STATE_URLTARGET.  Don't
-   *                 pass anything else!  Passing in a state object that has
-   *                 more than one of those states set is not supported.
-   * @return  Whether the content was able to change all states. Returns PR_FALSE
-   *                  if a resulting DOM event causes the content node passed in
-   *                  to not change states. Note, the frame for the content may
-   *                  change as a result of the content state change, because of
-   *                  frame reconstructions that may occur, but this does not
-   *                  affect the return value.
-   */
-  virtual PRBool SetContentState(nsIContent *aContent, nsEventStates aState) = 0;
-
-  NS_IMETHOD ContentRemoved(nsIDocument* aDocument, nsIContent* aContent) = 0;
-  NS_IMETHOD EventStatusOK(nsGUIEvent* aEvent, PRBool *aOK) = 0;
-
-  // Access Key Registration
-
-  /**
-   * Register accesskey on the given element. When accesskey is activated then
-   * the element will be notified via nsIContent::PerformAccesskey() method.
-   *
-   * @param  aContent  the given element
-   * @param  aKey      accesskey
-   */
-  NS_IMETHOD RegisterAccessKey(nsIContent* aContent, PRUint32 aKey) = 0;
-
-  /**
-   * Unregister accesskey for the given element.
-   *
-   * @param  aContent  the given element
-   * @param  aKey      accesskey
-   */
-  NS_IMETHOD UnregisterAccessKey(nsIContent* aContent, PRUint32 aKey) = 0;
-
-  /**
-   * Get accesskey registered on the given element or 0 if there is none.
-   *
-   * @param  aContent  the given element
-   * @param  aKey      registered accesskey
-   * @return           NS_OK
-   */
-  NS_IMETHOD GetRegisteredAccessKey(nsIContent* aContent, PRUint32* aKey) = 0;
-
-  NS_IMETHOD SetCursor(PRInt32 aCursor, imgIContainer* aContainer,
-                       PRBool aHaveHotspot, float aHotspotX, float aHotspotY,
-                       nsIWidget* aWidget, PRBool aLockCursor) = 0;
-
-  NS_IMETHOD NotifyDestroyPresContext(nsPresContext* aPresContext) = 0;
-  
-  /**
-   * Returns true if the current code is being executed as a result of user input.
-   * This includes timers or anything else that is initiated from user input.
-   * However, mouse hover events are not counted as user input, nor are
-   * page load events. If this method is called from asynchronously executed code,
-   * such as during layout reflows, it will return false.
-   */
-  NS_IMETHOD_(PRBool) IsHandlingUserInputExternal() = 0;
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsIEventStateManager, NS_IEVENTSTATEMANAGER_IID)
-
-#endif // nsIEventStateManager_h__
--- a/content/events/src/Makefile.in
+++ b/content/events/src/Makefile.in
@@ -41,16 +41,20 @@ srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= content
 LIBRARY_NAME	= gkconevents_s
 LIBXUL_LIBRARY  = 1
 
+EXPORTS		= \
+		nsEventStateManager.h \
+		$(NULL)
+		
 CPPSRCS		= \
 		nsEventListenerManager.cpp \
 		nsEventStateManager.cpp \
 		nsDOMEvent.cpp \
 		nsDOMDataContainerEvent.cpp \
 		nsDOMUIEvent.cpp \
 		nsDOMKeyboardEvent.cpp \
 		nsDOMTextEvent.cpp \
--- a/content/events/src/nsDOMDragEvent.cpp
+++ b/content/events/src/nsDOMDragEvent.cpp
@@ -34,17 +34,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsDOMDragEvent.h"
 #include "nsIServiceManager.h"
 #include "nsGUIEvent.h"
 #include "nsContentUtils.h"
-#include "nsIEventStateManager.h"
 #include "nsDOMDataTransfer.h"
 #include "nsIDragService.h"
 
 nsDOMDragEvent::nsDOMDragEvent(nsPresContext* aPresContext,
                                nsInputEvent* aEvent)
   : nsDOMMouseEvent(aPresContext, aEvent ? aEvent :
                     new nsDragEvent(PR_FALSE, 0, nsnull))
 {
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -311,18 +311,17 @@ nsDOMEvent::GetCurrentTarget(nsIDOMEvent
 // Get the actual event target node (may have been retargeted for mouse events)
 //
 already_AddRefed<nsIContent>
 nsDOMEvent::GetTargetFromFrame()
 {
   if (!mPresContext) { return nsnull; }
 
   // Get the target frame (have to get the ESM first)
-  nsIFrame* targetFrame = nsnull;
-  mPresContext->EventStateManager()->GetEventTarget(&targetFrame);
+  nsIFrame* targetFrame = mPresContext->EventStateManager()->GetEventTarget();
   if (!targetFrame) { return nsnull; }
 
   // get the real content
   nsCOMPtr<nsIContent> realEventContent;
   targetFrame->GetContentForEvent(mPresContext, mEvent, getter_AddRefs(realEventContent));
   return realEventContent.forget();
 }
 
--- a/content/events/src/nsDOMMouseEvent.cpp
+++ b/content/events/src/nsDOMMouseEvent.cpp
@@ -35,17 +35,16 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsDOMMouseEvent.h"
 #include "nsGUIEvent.h"
 #include "nsIContent.h"
-#include "nsIEventStateManager.h"
 #include "nsContentUtils.h"
 
 nsDOMMouseEvent::nsDOMMouseEvent(nsPresContext* aPresContext,
                                  nsInputEvent* aEvent)
   : nsDOMUIEvent(aPresContext, aEvent ? aEvent :
                  new nsMouseEvent(PR_FALSE, 0, nsnull,
                                   nsMouseEvent::eReal))
 {
--- a/content/events/src/nsDOMMouseScrollEvent.cpp
+++ b/content/events/src/nsDOMMouseScrollEvent.cpp
@@ -33,17 +33,16 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsDOMMouseScrollEvent.h"
 #include "nsGUIEvent.h"
 #include "nsIContent.h"
-#include "nsIEventStateManager.h"
 #include "nsContentUtils.h"
 
 nsDOMMouseScrollEvent::nsDOMMouseScrollEvent(nsPresContext* aPresContext,
                                              nsInputEvent* aEvent)
   : nsDOMMouseEvent(aPresContext, aEvent ? aEvent :
                                   new nsMouseScrollEvent(PR_FALSE, 0, nsnull))
 {
   if (aEvent) {
--- a/content/events/src/nsDOMUIEvent.cpp
+++ b/content/events/src/nsDOMUIEvent.cpp
@@ -42,17 +42,17 @@
 #include "nsCOMPtr.h"
 #include "nsDOMUIEvent.h"
 #include "nsIPresShell.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIDOMWindowInternal.h"
 #include "nsIDOMNode.h"
 #include "nsIContent.h"
 #include "nsContentUtils.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStateManager.h"
 #include "nsIFrame.h"
 #include "nsLayoutUtils.h"
 #include "nsIScrollableFrame.h"
 
 nsDOMUIEvent::nsDOMUIEvent(nsPresContext* aPresContext, nsGUIEvent* aEvent)
   : nsDOMEvent(aPresContext, aEvent ?
                static_cast<nsEvent *>(aEvent) :
                static_cast<nsEvent *>(new nsUIEvent(PR_FALSE, 0, 0)))
@@ -253,17 +253,17 @@ nsDOMUIEvent::GetWhich(PRUint32* aWhich)
 
 NS_IMETHODIMP
 nsDOMUIEvent::GetRangeParent(nsIDOMNode** aRangeParent)
 {
   NS_ENSURE_ARG_POINTER(aRangeParent);
   nsIFrame* targetFrame = nsnull;
 
   if (mPresContext) {
-    mPresContext->EventStateManager()->GetEventTarget(&targetFrame);
+    targetFrame = mPresContext->EventStateManager()->GetEventTarget();
   }
 
   *aRangeParent = nsnull;
 
   if (targetFrame) {
     nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(mEvent,
                                                               targetFrame);
     nsCOMPtr<nsIContent> parent = targetFrame->GetContentOffsetsFromPoint(pt).content;
@@ -281,17 +281,17 @@ nsDOMUIEvent::GetRangeParent(nsIDOMNode*
 
 NS_IMETHODIMP
 nsDOMUIEvent::GetRangeOffset(PRInt32* aRangeOffset)
 {
   NS_ENSURE_ARG_POINTER(aRangeOffset);
   nsIFrame* targetFrame = nsnull;
 
   if (mPresContext) {
-    mPresContext->EventStateManager()->GetEventTarget(&targetFrame);
+    targetFrame = mPresContext->EventStateManager()->GetEventTarget();
   }
 
   if (targetFrame) {
     nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(mEvent,
                                                               targetFrame);
     *aRangeOffset = targetFrame->GetContentOffsetsFromPoint(pt).offset;
     return NS_OK;
   }
@@ -329,18 +329,17 @@ nsDOMUIEvent::GetLayerPoint()
        mEvent->eventStructType != NS_MOZTOUCH_EVENT &&
        mEvent->eventStructType != NS_DRAG_EVENT &&
        mEvent->eventStructType != NS_SIMPLE_GESTURE_EVENT) ||
       !mPresContext ||
       mEventIsInternal) {
     return mLayerPoint;
   }
   // XXX I'm not really sure this is correct; it's my best shot, though
-  nsIFrame* targetFrame;
-  mPresContext->EventStateManager()->GetEventTarget(&targetFrame);
+  nsIFrame* targetFrame = mPresContext->EventStateManager()->GetEventTarget();
   if (!targetFrame)
     return mLayerPoint;
   nsIFrame* layer = nsLayoutUtils::GetClosestLayer(targetFrame);
   nsPoint pt(nsLayoutUtils::GetEventCoordinatesRelativeTo(mEvent, layer));
   return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(pt.x),
                     nsPresContext::AppUnitsToIntCSSPixels(pt.y));
 }
 
--- a/content/events/src/nsEventListenerManager.cpp
+++ b/content/events/src/nsEventListenerManager.cpp
@@ -51,17 +51,16 @@
 #include "nsIDOMLoadListener.h"
 #include "nsIDOMTextListener.h"
 #include "nsIDOMCompositionListener.h"
 #include "nsIDOMUIListener.h"
 #include "nsITextControlFrame.h"
 #ifdef MOZ_SVG
 #include "nsGkAtoms.h"
 #endif // MOZ_SVG
-#include "nsIEventStateManager.h"
 #include "nsPIDOMWindow.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsIJSEventListener.h"
 #include "prmem.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptRuntime.h"
 #include "nsLayoutUtils.h"
 #include "nsINameSpaceManager.h"
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -806,17 +806,17 @@ nsEventStateManager::UpdateUserActivityT
   if (gUserInteractionTimer) {
     gUserInteractionTimer->InitWithCallback(gUserInteractionTimerCallback,
                                             NS_USER_INTERACTION_INTERVAL,
                                             nsITimer::TYPE_ONE_SHOT);
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP
+nsresult
 nsEventStateManager::Init()
 {
   nsCOMPtr<nsIObserverService> observerService =
     mozilla::services::GetObserverService();
   if (!observerService)
     return NS_ERROR_FAILURE;
 
   observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE);
@@ -991,18 +991,17 @@ nsEventStateManager::Observe(nsISupports
   }
 
   return NS_OK;
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsEventStateManager)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsEventStateManager)
-   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIEventStateManager)
-   NS_INTERFACE_MAP_ENTRY(nsIEventStateManager)
+   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver)
    NS_INTERFACE_MAP_ENTRY(nsIObserver)
    NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsEventStateManager)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsEventStateManager)
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsEventStateManager)
@@ -1042,18 +1041,17 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ns
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDragOverContent);
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mURLTargetContent);
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFirstMouseOverEventElement);
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFirstMouseOutEventElement);
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDocument);
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMARRAY(mAccessKeys);
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
-
-NS_IMETHODIMP
+nsresult
 nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
                                     nsEvent *aEvent,
                                     nsIFrame* aTargetFrame,
                                     nsEventStatus* aStatus,
                                     nsIView* aView)
 {
   NS_ENSURE_ARG_POINTER(aStatus);
   NS_ENSURE_ARG(aPresContext);
@@ -2813,17 +2811,17 @@ NodeAllowsClickThrough(nsINode* aNode)
       }
     }
     aNode = nsContentUtils::GetCrossDocParentNode(aNode);
   }
   return true;
 }
 #endif
 
-NS_IMETHODIMP
+nsresult
 nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
                                      nsEvent *aEvent,
                                      nsIFrame* aTargetFrame,
                                      nsEventStatus* aStatus,
                                      nsIView* aView)
 {
   NS_ENSURE_ARG(aPresContext);
   NS_ENSURE_ARG_POINTER(aStatus);
@@ -2988,18 +2986,17 @@ nsEventStateManager::PostHandleEvent(nsP
       SetActiveManager(this, activeContent);
     }
     break;
   case NS_MOUSE_BUTTON_UP:
     {
       ClearGlobalActiveContent(this);
       if (IsMouseEventReal(aEvent)) {
         if (!mCurrentTarget) {
-          nsIFrame* targ;
-          GetEventTarget(&targ);
+          GetEventTarget();
         }
         if (mCurrentTarget) {
           ret = CheckForAndDispatchClick(presContext, (nsMouseEvent*)aEvent,
                                          aStatus);
         }
       }
 
       nsIPresShell *shell = presContext->GetPresShell();
@@ -3351,38 +3348,34 @@ nsEventStateManager::IsTargetCrossProces
   // Check to see if there is a focused, editable content in chrome,
   // in that case, do not forward IME events to content
   nsIContent *focusedContent = GetFocusedContent();
   if (focusedContent && focusedContent->IsEditable())
     return PR_FALSE;
   return TabParent::GetIMETabParent() != nsnull;
 }
 
-NS_IMETHODIMP
+void
 nsEventStateManager::NotifyDestroyPresContext(nsPresContext* aPresContext)
 {
   nsIMEStateManager::OnDestroyPresContext(aPresContext);
-  return NS_OK;
 }
 
-NS_IMETHODIMP
+void
 nsEventStateManager::SetPresContext(nsPresContext* aPresContext)
 {
   mPresContext = aPresContext;
-  return NS_OK;
 }
 
-NS_IMETHODIMP
+void
 nsEventStateManager::ClearFrameRefs(nsIFrame* aFrame)
 {
   if (aFrame && aFrame == mCurrentTarget) {
     mCurrentTargetContent = aFrame->GetContent();
   }
-
-  return NS_OK;
 }
 
 void
 nsEventStateManager::UpdateCursor(nsPresContext* aPresContext,
                                   nsEvent* aEvent, nsIFrame* aTargetFrame,
                                   nsEventStatus* aStatus)
 {
   PRInt32 cursor = NS_STYLE_CURSOR_DEFAULT;
@@ -3431,17 +3424,17 @@ nsEventStateManager::UpdateCursor(nsPres
               aTargetFrame->GetNearestWidget(), PR_FALSE);
   }
 
   if (mLockCursor || NS_STYLE_CURSOR_AUTO != cursor) {
     *aStatus = nsEventStatus_eConsumeDoDefault;
   }
 }
 
-NS_IMETHODIMP
+nsresult
 nsEventStateManager::SetCursor(PRInt32 aCursor, imgIContainer* aContainer,
                                PRBool aHaveHotspot,
                                float aHotspotX, float aHotspotY,
                                nsIWidget* aWidget, PRBool aLockCursor)
 {
   EnsureDocument(mPresContext);
   NS_ENSURE_TRUE(mDocument, NS_ERROR_FAILURE);
   sMouseOverDocument = mDocument.get();
@@ -3693,18 +3686,17 @@ nsEventStateManager::NotifyMouseOut(nsGU
     if (subdocFrame) {
       nsCOMPtr<nsIDocShell> docshell;
       subdocFrame->GetDocShell(getter_AddRefs(docshell));
       if (docshell) {
         nsRefPtr<nsPresContext> presContext;
         docshell->GetPresContext(getter_AddRefs(presContext));
 
         if (presContext) {
-          nsEventStateManager* kidESM =
-            static_cast<nsEventStateManager*>(presContext->EventStateManager());
+          nsEventStateManager* kidESM = presContext->EventStateManager();
           // Not moving into any element in this subdocument
           kidESM->NotifyMouseOut(aEvent, nsnull);
         }
       }
     }
   }
   // That could have caused DOM events which could wreak havoc. Reverify
   // things and be careful.
@@ -3752,19 +3744,17 @@ nsEventStateManager::NotifyMouseOver(nsG
   // content associated with our subdocument.
   EnsureDocument(mPresContext);
   nsIDocument *parentDoc = mDocument->GetParentDocument();
   if (parentDoc) {
     nsIContent *docContent = parentDoc->FindContentForSubDocument(mDocument);
     if (docContent) {
       nsIPresShell *parentShell = parentDoc->GetShell();
       if (parentShell) {
-        nsEventStateManager* parentESM =
-          static_cast<nsEventStateManager*>
-                     (parentShell->GetPresContext()->EventStateManager());
+        nsEventStateManager* parentESM = parentShell->GetPresContext()->EventStateManager();
         parentESM->NotifyMouseOver(aEvent, docContent);
       }
     }
   }
   // Firing the DOM event in the parent document could cause all kinds
   // of havoc.  Reverify and take care.
   if (mLastMouseOverElement == aContent)
     return;
@@ -3799,18 +3789,17 @@ nsEventStateManager::GenerateMouseEnterE
 
   // Hold onto old target content through the event and reset after.
   nsCOMPtr<nsIContent> targetBeforeEvent = mCurrentTargetContent;
 
   switch(aEvent->message) {
   case NS_MOUSE_MOVE:
     {
       // Get the target content target (mousemove target == mouseover target)
-      nsCOMPtr<nsIContent> targetElement;
-      GetEventTargetContent(aEvent, getter_AddRefs(targetElement));
+      nsCOMPtr<nsIContent> targetElement = GetEventTargetContent(aEvent);
       if (!targetElement) {
         // We're always over the document root, even if we're only
         // over dead space in a page (whose frame is not associated with
         // any content) or in print preview dead space
         targetElement = mDocument->GetRootElement();
       }
       if (targetElement) {
         NotifyMouseOver(aEvent, targetElement);
@@ -4088,18 +4077,17 @@ nsEventStateManager::CheckForAndDispatch
     event.isMeta = aEvent->isMeta;
     event.time = aEvent->time;
     event.flags |= flags;
     event.button = aEvent->button;
     event.inputSource = aEvent->inputSource;
 
     nsCOMPtr<nsIPresShell> presShell = mPresContext->GetPresShell();
     if (presShell) {
-      nsCOMPtr<nsIContent> mouseContent;
-      GetEventTargetContent(aEvent, getter_AddRefs(mouseContent));
+      nsCOMPtr<nsIContent> mouseContent = GetEventTargetContent(aEvent);
 
       ret = presShell->HandleEventWithTarget(&event, mCurrentTarget,
                                              mouseContent, aStatus);
       if (NS_SUCCEEDED(ret) && aEvent->clickCount == 2) {
         //fire double click
         nsMouseEvent event2(NS_IS_TRUSTED_EVENT(aEvent), NS_MOUSE_DOUBLECLICK,
                             aEvent->widget, nsMouseEvent::eReal);
         event2.refPoint = aEvent->refPoint;
@@ -4115,71 +4103,66 @@ nsEventStateManager::CheckForAndDispatch
         ret = presShell->HandleEventWithTarget(&event2, mCurrentTarget,
                                                mouseContent, aStatus);
       }
     }
   }
   return ret;
 }
 
-NS_IMETHODIMP
-nsEventStateManager::GetEventTarget(nsIFrame **aFrame)
+nsIFrame*
+nsEventStateManager::GetEventTarget()
 {
   nsIPresShell *shell;
   if (mCurrentTarget ||
       !mPresContext ||
       !(shell = mPresContext->GetPresShell())) {
-    *aFrame = mCurrentTarget;
-    return NS_OK;
+    return mCurrentTarget;
   }
 
   if (mCurrentTargetContent) {
     mCurrentTarget = mPresContext->GetPrimaryFrameFor(mCurrentTargetContent);
     if (mCurrentTarget) {
-      *aFrame = mCurrentTarget;
-      return NS_OK;
+      return mCurrentTarget;
     }
   }
 
   nsIFrame* frame = shell->GetEventTargetFrame();
-  *aFrame = mCurrentTarget = frame;
-  return NS_OK;
+  return (mCurrentTarget = frame);
 }
 
-NS_IMETHODIMP
-nsEventStateManager::GetEventTargetContent(nsEvent* aEvent,
-                                           nsIContent** aContent)
+already_AddRefed<nsIContent>
+nsEventStateManager::GetEventTargetContent(nsEvent* aEvent)
 {
   if (aEvent &&
       (aEvent->message == NS_FOCUS_CONTENT ||
        aEvent->message == NS_BLUR_CONTENT)) {
-    NS_IF_ADDREF(*aContent = GetFocusedContent());
-    return NS_OK;
+    nsCOMPtr<nsIContent> content = GetFocusedContent();
+    return content.forget();
   }
 
   if (mCurrentTargetContent) {
-    *aContent = mCurrentTargetContent;
-    NS_IF_ADDREF(*aContent);
-    return NS_OK;
+    nsCOMPtr<nsIContent> content = mCurrentTargetContent;
+    return content.forget();
   }
 
-  *aContent = nsnull;
+  nsIContent *content = nsnull;
 
   nsIPresShell *presShell = mPresContext->GetPresShell();
   if (presShell) {
-    *aContent = presShell->GetEventTargetContent(aEvent).get();
+    content = presShell->GetEventTargetContent(aEvent).get();
   }
 
   // Some events here may set mCurrentTarget but not set the corresponding
   // event target in the PresShell.
-  if (!*aContent && mCurrentTarget) {
-    mCurrentTarget->GetContentForEvent(mPresContext, aEvent, aContent);
+  if (!content && mCurrentTarget) {
+    mCurrentTarget->GetContentForEvent(mPresContext, aEvent, &content);
   }
 
-  return NS_OK;
+  return content;
 }
 
 static already_AddRefed<nsIContent>
 GetLabelTarget(nsIContent* aLabel)
 {
   nsCOMPtr<nsIDOMHTMLLabelElement> label = do_QueryInterface(aLabel);
   if (!label)
     return nsnull;
@@ -4414,17 +4397,17 @@ nsEventStateManager::SetContentState(nsI
         }
       }
     }
   }
 
   return PR_TRUE;
 }
 
-NS_IMETHODIMP
+void
 nsEventStateManager::ContentRemoved(nsIDocument* aDocument, nsIContent* aContent)
 {
   // inform the focus manager that the content is being removed. If this
   // content is focused, the focus will be removed without firing events.
   nsFocusManager* fm = nsFocusManager::GetFocusManager();
   if (fm)
     fm->ContentRemoved(aDocument, aContent);
 
@@ -4447,69 +4430,54 @@ nsEventStateManager::ContentRemoved(nsID
     mDragOverContent = nsnull;
   }
 
   if (mLastMouseOverElement &&
       nsContentUtils::ContentIsDescendantOf(mLastMouseOverElement, aContent)) {
     // See bug 292146 for why we want to null this out
     mLastMouseOverElement = nsnull;
   }
-
-  return NS_OK;
 }
 
-NS_IMETHODIMP
-nsEventStateManager::EventStatusOK(nsGUIEvent* aEvent, PRBool *aOK)
+PRBool
+nsEventStateManager::EventStatusOK(nsGUIEvent* aEvent)
 {
-  *aOK = PR_TRUE;
-  if (aEvent->message == NS_MOUSE_BUTTON_DOWN &&
-      static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton) {
-    if (!sNormalLMouseEventInProcess) {
-      *aOK = PR_FALSE;
-    }
-  }
-  return NS_OK;
+  return !(aEvent->message == NS_MOUSE_BUTTON_DOWN &&
+      static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton  && 
+      !sNormalLMouseEventInProcess);
 }
 
 //-------------------------------------------
 // Access Key Registration
 //-------------------------------------------
-NS_IMETHODIMP
+void
 nsEventStateManager::RegisterAccessKey(nsIContent* aContent, PRUint32 aKey)
 {
   if (aContent && mAccessKeys.IndexOf(aContent) == -1)
     mAccessKeys.AppendObject(aContent);
-
-  return NS_OK;
 }
 
-NS_IMETHODIMP
+void
 nsEventStateManager::UnregisterAccessKey(nsIContent* aContent, PRUint32 aKey)
 {
   if (aContent)
     mAccessKeys.RemoveObject(aContent);
-
-  return NS_OK;
 }
 
-NS_IMETHODIMP
-nsEventStateManager::GetRegisteredAccessKey(nsIContent* aContent,
-                                            PRUint32* aKey)
+PRUint32
+nsEventStateManager::GetRegisteredAccessKey(nsIContent* aContent)
 {
   NS_ENSURE_ARG(aContent);
-  NS_ENSURE_ARG_POINTER(aKey);
-  *aKey = 0;
 
   if (mAccessKeys.IndexOf(aContent) == -1)
-    return NS_OK;
+    return 0;
 
   nsAutoString accessKey;
   aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::accesskey, accessKey);
-  *aKey = accessKey.First();
-  return NS_OK;
+  return accessKey.First();
 }
 
 void
 nsEventStateManager::EnsureDocument(nsPresContext* aPresContext)
 {
   if (!mDocument)
     mDocument = aPresContext->Document();
 }
--- a/content/events/src/nsEventStateManager.h
+++ b/content/events/src/nsEventStateManager.h
@@ -34,33 +34,33 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsEventStateManager_h__
 #define nsEventStateManager_h__
 
-#include "nsIEventStateManager.h"
 #include "nsEvent.h"
 #include "nsGUIEvent.h"
 #include "nsIContent.h"
 #include "nsIObserver.h"
 #include "nsWeakReference.h"
 #include "nsHashtable.h"
 #include "nsITimer.h"
 #include "nsCOMPtr.h"
 #include "nsIDocument.h"
 #include "nsCOMArray.h"
 #include "nsIFrame.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIMarkupDocumentViewer.h"
 #include "nsIScrollableFrame.h"
 #include "nsFocusManager.h"
 #include "nsIDocument.h"
+#include "nsEventStates.h"
 
 class nsIPresShell;
 class nsIDocShell;
 class nsIDocShellTreeNode;
 class nsIDocShellTreeItem;
 class imgIContainer;
 class nsDOMDataTransfer;
 
@@ -70,101 +70,149 @@ class TabParent;
 }
 }
 
 /*
  * Event listener manager
  */
 
 class nsEventStateManager : public nsSupportsWeakReference,
-                            public nsIEventStateManager,
                             public nsIObserver
 {
   friend class nsMouseWheelTransaction;
 public:
   nsEventStateManager();
   virtual ~nsEventStateManager();
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_NSIOBSERVER
 
-  NS_IMETHOD Init();
+  nsresult Init();
   nsresult Shutdown();
 
   /* The PreHandleEvent method is called before event dispatch to either
    * the DOM or frames.  Any processing which must not be prevented or
    * cancelled should occur here.  Any processing which is intended to
    * be conditional based on either DOM or frame processing should occur in
    * PostHandleEvent.  Any centralized event processing which must occur before
    * DOM or frame event handling should occur here as well.
    */
-  NS_IMETHOD PreHandleEvent(nsPresContext* aPresContext,
-                         nsEvent *aEvent,
-                         nsIFrame* aTargetFrame,
-                         nsEventStatus* aStatus,
-                         nsIView* aView);
+  nsresult PreHandleEvent(nsPresContext* aPresContext,
+                          nsEvent *aEvent,
+                          nsIFrame* aTargetFrame,
+                          nsEventStatus* aStatus,
+                          nsIView* aView);
 
   /* The PostHandleEvent method should contain all system processing which
    * should occur conditionally based on DOM or frame processing.  It should
    * also contain any centralized event processing which must occur after
    * DOM and frame processing.
    */
-  NS_IMETHOD PostHandleEvent(nsPresContext* aPresContext,
-                             nsEvent *aEvent,
-                             nsIFrame* aTargetFrame,
-                             nsEventStatus* aStatus,
-                             nsIView* aView);
+  nsresult PostHandleEvent(nsPresContext* aPresContext,
+                           nsEvent *aEvent,
+                           nsIFrame* aTargetFrame,
+                           nsEventStatus* aStatus,
+                           nsIView* aView);
+
+  void NotifyDestroyPresContext(nsPresContext* aPresContext);
+  void SetPresContext(nsPresContext* aPresContext);
+  void ClearFrameRefs(nsIFrame* aFrame);
 
-  NS_IMETHOD NotifyDestroyPresContext(nsPresContext* aPresContext);
-  NS_IMETHOD SetPresContext(nsPresContext* aPresContext);
-  NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame);
+  nsIFrame* GetEventTarget();
+  already_AddRefed<nsIContent> GetEventTargetContent(nsEvent* aEvent);
 
-  NS_IMETHOD GetEventTarget(nsIFrame **aFrame);
-  NS_IMETHOD GetEventTargetContent(nsEvent* aEvent, nsIContent** aContent);
-
+  /**
+   * Returns the content state of aContent.
+   * @param aContent      The control whose state is requested.
+   * @param aFollowLabels Whether to reflect a label's content state on its
+   *                      associated control. If aFollowLabels is true and
+   *                      aContent is a control which has a label that has the 
+   *                      hover or active content state set, GetContentState
+   *                      will pretend that those states are also set on aContent.
+   * @return              The content state.
+   */
   virtual nsEventStates GetContentState(nsIContent *aContent,
                                         PRBool aFollowLabels = PR_FALSE);
-  virtual PRBool SetContentState(nsIContent *aContent, nsEventStates aState);
-  NS_IMETHOD ContentRemoved(nsIDocument* aDocument, nsIContent* aContent);
-  NS_IMETHOD EventStatusOK(nsGUIEvent* aEvent, PRBool *aOK);
+
+  /**
+   * Notify that the given NS_EVENT_STATE_* bit has changed for this content.
+   * @param aContent Content which has changed states
+   * @param aState   Corresponding state flags such as NS_EVENT_STATE_FOCUS
+   * @return  Whether the content was able to change all states. Returns PR_FALSE
+   *                  if a resulting DOM event causes the content node passed in
+   *                  to not change states. Note, the frame for the content may
+   *                  change as a result of the content state change, because of
+   *                  frame reconstructions that may occur, but this does not
+   *                  affect the return value.
+   */
+  PRBool SetContentState(nsIContent *aContent, nsEventStates aState);
+  void ContentRemoved(nsIDocument* aDocument, nsIContent* aContent);
+  PRBool EventStatusOK(nsGUIEvent* aEvent);
 
-  // Access Key Registration
-  NS_IMETHOD RegisterAccessKey(nsIContent* aContent, PRUint32 aKey);
-  NS_IMETHOD UnregisterAccessKey(nsIContent* aContent, PRUint32 aKey);
-  NS_IMETHOD GetRegisteredAccessKey(nsIContent* aContent, PRUint32* aKey);
+  /**
+   * Register accesskey on the given element. When accesskey is activated then
+   * the element will be notified via nsIContent::PerformAccesskey() method.
+   *
+   * @param  aContent  the given element
+   * @param  aKey      accesskey
+   */
+  void RegisterAccessKey(nsIContent* aContent, PRUint32 aKey);
 
-  NS_IMETHOD SetCursor(PRInt32 aCursor, imgIContainer* aContainer,
-                       PRBool aHaveHotspot, float aHotspotX, float aHotspotY,
-                       nsIWidget* aWidget, PRBool aLockCursor);
+  /**
+   * Unregister accesskey for the given element.
+   *
+   * @param  aContent  the given element
+   * @param  aKey      accesskey
+   */
+  void UnregisterAccessKey(nsIContent* aContent, PRUint32 aKey);
+
+  /**
+   * Get accesskey registered on the given element or 0 if there is none.
+   *
+   * @param  aContent  the given element
+   * @return           registered accesskey
+   */
+  PRUint32 GetRegisteredAccessKey(nsIContent* aContent);
+
+  nsresult SetCursor(PRInt32 aCursor, imgIContainer* aContainer,
+                     PRBool aHaveHotspot, float aHotspotX, float aHotspotY,
+                     nsIWidget* aWidget, PRBool aLockCursor); 
 
   static void StartHandlingUserInput()
   {
     ++sUserInputEventDepth;
   }
 
   static void StopHandlingUserInput()
   {
     --sUserInputEventDepth;
   }
 
   static PRBool IsHandlingUserInput()
   {
     return sUserInputEventDepth > 0;
   }
 
+  /**
+   * Returns true if the current code is being executed as a result of user input.
+   * This includes timers or anything else that is initiated from user input.
+   * However, mouse hover events are not counted as user input, nor are
+   * page load events. If this method is called from asynchronously executed code,
+   * such as during layout reflows, it will return false.
+   */
   NS_IMETHOD_(PRBool) IsHandlingUserInputExternal() { return IsHandlingUserInput(); }
   
   nsPresContext* GetPresContext() { return mPresContext; }
 
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsEventStateManager,
-                                           nsIEventStateManager)
+                                           nsIObserver)
 
   static nsIDocument* sMouseOverDocument;
 
-  static nsIEventStateManager* GetActiveEventStateManager() { return sActiveESM; }
+  static nsEventStateManager* GetActiveEventStateManager() { return sActiveESM; }
 
   // Sets aNewESM to be the active event state manager, and
   // if aContent is non-null, marks the object as active.
   static void SetActiveManager(nsEventStateManager* aNewESM,
                                nsIContent* aContent);
 protected:
   void UpdateCursor(nsPresContext* aPresContext, nsEvent* aEvent, nsIFrame* aTargetFrame, nsEventStatus* aStatus);
   /**
@@ -484,9 +532,11 @@ protected:
   PRBool mResetFMMouseDownState;
 
 private:
   // Hide so that this class can only be stack-allocated
   static void* operator new(size_t /*size*/) CPP_THROW_NEW { return nsnull; }
   static void operator delete(void* /*memory*/) {}
 };
 
+#define NS_EVENT_NEEDS_FRAME(event) (!NS_IS_ACTIVATION_EVENT(event))
+
 #endif // nsEventStateManager_h__
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -81,17 +81,17 @@
 #include "nsPresState.h"
 #include "nsILayoutHistoryState.h"
 
 #include "nsHTMLParts.h"
 #include "nsContentUtils.h"
 #include "nsString.h"
 #include "nsUnicharUtils.h"
 #include "nsGkAtoms.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStateManager.h"
 #include "nsIDOMEvent.h"
 #include "nsIDOMNSEvent.h"
 #include "nsDOMCSSDeclaration.h"
 #include "nsITextControlFrame.h"
 #include "nsIForm.h"
 #include "nsIFormControl.h"
 #include "nsIDOMHTMLFormElement.h"
 #include "nsHTMLFormElement.h"
@@ -1051,19 +1051,18 @@ nsGenericHTMLElement::CheckHandleEventFo
     // events) don't have one.
     // XXX: ideally, shouldn't we be able to do what we need without one?
     return PR_FALSE; 
   }
 
   //Need to check if we hit an imagemap area and if so see if we're handling
   //the event on that map or on a link farther up the tree.  If we're on a
   //link farther up, do nothing.
-  nsCOMPtr<nsIContent> target;
-  aVisitor.mPresContext->EventStateManager()->
-    GetEventTargetContent(aVisitor.mEvent, getter_AddRefs(target));
+  nsCOMPtr<nsIContent> target = aVisitor.mPresContext->EventStateManager()->
+    GetEventTargetContent(aVisitor.mEvent);
 
   return !target || !IsArea(target) || IsArea(this);
 }
 
 nsresult
 nsGenericHTMLElement::PreHandleEventForAnchors(nsEventChainPreVisitor& aVisitor)
 {
   nsresult rv = nsGenericHTMLElementBase::PreHandleEvent(aVisitor);
@@ -3348,17 +3347,17 @@ nsGenericHTMLElement::RegUnRegAccessKey(
   if (accessKey.IsEmpty()) {
     return;
   }
 
   // We have an access key, so get the ESM from the pres context.
   nsPresContext *presContext = GetPresContext();
 
   if (presContext) {
-    nsIEventStateManager *esm = presContext->EventStateManager();
+    nsEventStateManager *esm = presContext->EventStateManager();
 
     // Register or unregister as appropriate.
     if (aDoReg) {
       esm->RegisterAccessKey(this, (PRUint32)accessKey.First());
     } else {
       esm->UnregisterAccessKey(this, (PRUint32)accessKey.First());
     }
   }
--- a/content/html/content/src/nsHTMLAnchorElement.cpp
+++ b/content/html/content/src/nsHTMLAnchorElement.cpp
@@ -42,17 +42,16 @@
 #include "nsUnicharUtils.h"
 #include "nsIDOMHTMLAnchorElement.h"
 #include "nsGenericHTMLElement.h"
 #include "nsILink.h"
 #include "nsGkAtoms.h"
 #include "nsIPresShell.h"
 #include "nsIDocument.h"
 #include "nsPresContext.h"
-#include "nsIEventStateManager.h"
 
 #include "nsHTMLDNSPrefetch.h"
 
 #include "Link.h"
 using namespace mozilla::dom;
 
 class nsHTMLAnchorElement : public nsGenericHTMLElement,
                             public nsIDOMHTMLAnchorElement,
--- a/content/html/content/src/nsHTMLAreaElement.cpp
+++ b/content/html/content/src/nsHTMLAreaElement.cpp
@@ -36,17 +36,16 @@
  *
  * ***** END LICENSE BLOCK ***** */
 #include "nsIDOMHTMLAreaElement.h"
 #include "nsIDOMEventTarget.h"
 #include "nsGenericHTMLElement.h"
 #include "nsILink.h"
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
-#include "nsIEventStateManager.h"
 #include "nsIURL.h"
 #include "nsNetUtil.h"
 #include "nsReadableUtils.h"
 #include "nsIDocument.h"
 
 #include "Link.h"
 using namespace mozilla::dom;
 
--- a/content/html/content/src/nsHTMLButtonElement.cpp
+++ b/content/html/content/src/nsHTMLButtonElement.cpp
@@ -45,17 +45,16 @@
 #include "nsIFormControl.h"
 #include "nsIForm.h"
 #include "nsFormSubmission.h"
 #include "nsFormSubmissionConstants.h"
 #include "nsIURL.h"
 #include "nsEventStateManager.h"
 #include "nsIFrame.h"
 #include "nsIFormControlFrame.h"
-#include "nsIEventStateManager.h"
 #include "nsIDOMEvent.h"
 #include "nsIDOMNSEvent.h"
 #include "nsIDocument.h"
 #include "nsGUIEvent.h"
 #include "nsUnicharUtils.h"
 #include "nsLayoutUtils.h"
 #include "nsEventDispatcher.h"
 #include "nsPresState.h"
@@ -372,17 +371,17 @@ nsHTMLButtonElement::PostHandleEvent(nsE
         break;// NS_KEY_PRESS
 
       case NS_MOUSE_BUTTON_DOWN:
         {
           if (aVisitor.mEvent->eventStructType == NS_MOUSE_EVENT) {
             if (static_cast<nsMouseEvent*>(aVisitor.mEvent)->button ==
                   nsMouseEvent::eLeftButton) {
               if (NS_IS_TRUSTED_EVENT(aVisitor.mEvent)) {
-                nsIEventStateManager* esm =
+                nsEventStateManager* esm =
                   aVisitor.mPresContext->EventStateManager();
                 nsEventStateManager::SetActiveManager(
                   static_cast<nsEventStateManager*>(esm), this);
               }
               nsIFocusManager* fm = nsFocusManager::GetFocusManager();
               if (fm)
                 fm->SetFocus(this, nsIFocusManager::FLAG_BYMOUSE |
                                    nsIFocusManager::FLAG_NOSCROLL);
--- a/content/html/content/src/nsHTMLFormElement.cpp
+++ b/content/html/content/src/nsHTMLFormElement.cpp
@@ -76,17 +76,16 @@
 #include "nsLayoutUtils.h"
 
 #include "nsEventDispatcher.h"
 
 #include "mozAutoDocUpdate.h"
 #include "nsIHTMLCollection.h"
 
 #include "nsIConstraintValidation.h"
-#include "nsIEventStateManager.h"
 
 #include "nsIDOMHTMLButtonElement.h"
 
 using namespace mozilla::dom;
 
 static const int NS_FORM_CONTROL_LIST_HASHTABLE_SIZE = 16;
 
 static const PRUint8 NS_FORM_AUTOCOMPLETE_ON  = 1;
--- a/content/html/content/src/nsHTMLInputElement.cpp
+++ b/content/html/content/src/nsHTMLInputElement.cpp
@@ -58,17 +58,17 @@
 #include "nsIForm.h"
 #include "nsFormSubmission.h"
 #include "nsFormSubmissionConstants.h"
 #include "nsIDocument.h"
 #include "nsIPresShell.h"
 #include "nsIFormControlFrame.h"
 #include "nsITextControlFrame.h"
 #include "nsIFrame.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 #include "nsIServiceManager.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsDOMError.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsIEditor.h"
 #include "nsGUIEvent.h"
 #include "nsIIOService.h"
 
--- a/content/html/content/src/nsHTMLLabelElement.cpp
+++ b/content/html/content/src/nsHTMLLabelElement.cpp
@@ -42,17 +42,16 @@
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsPresContext.h"
 #include "nsIFormControl.h"
 #include "nsIForm.h"
 #include "nsIDOMDocument.h"
 #include "nsIDocument.h"
 #include "nsGUIEvent.h"
-#include "nsIEventStateManager.h"
 #include "nsEventDispatcher.h"
 #include "nsPIDOMWindow.h"
 #include "nsFocusManager.h"
 
 class nsHTMLLabelElement : public nsGenericHTMLFormElement,
                            public nsIDOMHTMLLabelElement
 {
 public:
--- a/content/html/content/src/nsHTMLLegendElement.cpp
+++ b/content/html/content/src/nsHTMLLegendElement.cpp
@@ -37,17 +37,16 @@
  * ***** END LICENSE BLOCK ***** */
 #include "nsHTMLLegendElement.h"
 #include "nsIDOMHTMLFormElement.h"
 #include "nsIDOMEventTarget.h"
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsIForm.h"
 #include "nsIFormControl.h"
-#include "nsIEventStateManager.h"
 #include "nsIDocument.h"
 #include "nsPIDOMWindow.h"
 #include "nsFocusManager.h"
 #include "nsIFrame.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Legend)
 
 
--- a/content/html/content/src/nsHTMLOptGroupElement.cpp
+++ b/content/html/content/src/nsHTMLOptGroupElement.cpp
@@ -36,17 +36,17 @@
  * ***** END LICENSE BLOCK ***** */
 #include "nsIDOMHTMLOptGroupElement.h"
 #include "nsIDOMEventTarget.h"
 #include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsIFrame.h"
 #include "nsIFormControlFrame.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 #include "nsIDocument.h"
 
 #include "nsEventDispatcher.h"
 #include "nsHTMLSelectElement.h"
 
 /**
  * The implementation of &lt;optgroup&gt;
  */
--- a/content/html/content/src/nsHTMLOptionElement.cpp
+++ b/content/html/content/src/nsHTMLOptionElement.cpp
@@ -54,17 +54,17 @@
 
 // Notify/query select frame for selected state
 #include "nsIFormControlFrame.h"
 #include "nsIDocument.h"
 #include "nsIFrame.h"
 #include "nsIDOMHTMLSelectElement.h"
 #include "nsNodeInfoManager.h"
 #include "nsCOMPtr.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsContentCreatorFunctions.h"
 #include "mozAutoDocUpdate.h"
 
 using namespace mozilla::dom;
 
 /**
--- a/content/html/content/src/nsHTMLOutputElement.cpp
+++ b/content/html/content/src/nsHTMLOutputElement.cpp
@@ -36,17 +36,17 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsIDOMHTMLOutputElement.h"
 #include "nsGenericHTMLElement.h"
 #include "nsFormSubmission.h"
 #include "nsDOMSettableTokenList.h"
 #include "nsStubMutationObserver.h"
 #include "nsIConstraintValidation.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 #include "mozAutoDocUpdate.h"
 #include "nsHTMLFormElement.h"
 
 
 class nsHTMLOutputElement : public nsGenericHTMLFormElement,
                             public nsIDOMHTMLOutputElement,
                             public nsStubMutationObserver,
                             public nsIConstraintValidation
--- a/content/html/content/src/nsHTMLSelectElement.cpp
+++ b/content/html/content/src/nsHTMLSelectElement.cpp
@@ -47,17 +47,17 @@
 #include "nsMappedAttributes.h"
 #include "nsIForm.h"
 #include "nsFormSubmission.h"
 #include "nsIFormProcessor.h"
 #include "nsContentCreatorFunctions.h"
 
 #include "nsIDOMHTMLOptGroupElement.h"
 #include "nsHTMLOptionElement.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 #include "nsGUIEvent.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsIBoxObject.h"
 #include "nsIDOMNSDocument.h"
 #include "nsIDOMDocumentEvent.h"
 
 // Notify/query select frame for selectedIndex
 #include "nsIDocument.h"
--- a/content/html/content/src/nsHTMLTextAreaElement.cpp
+++ b/content/html/content/src/nsHTMLTextAreaElement.cpp
@@ -53,17 +53,17 @@
 #include "nsIDOMEventTarget.h"
 #include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsPresContext.h"
 #include "nsMappedAttributes.h"
 #include "nsIFormControlFrame.h"
 #include "nsITextControlFrame.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 #include "nsLinebreakConverter.h"
 #include "nsIDocument.h"
 #include "nsIFrame.h"
 #include "nsIFormControlFrame.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsGUIEvent.h"
 #include "nsLinebreakConverter.h"
 #include "nsPresState.h"
--- a/content/html/content/src/nsRadioVisitor.cpp
+++ b/content/html/content/src/nsRadioVisitor.cpp
@@ -33,17 +33,17 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsRadioVisitor.h"
 #include "nsAutoPtr.h"
 #include "nsHTMLInputElement.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 #include "nsIDocument.h"
 #include "nsIConstraintValidation.h"
 
 
 NS_IMPL_ISUPPORTS1(nsRadioVisitor, nsIRadioVisitor)
 
 PRBool
 nsRadioSetCheckedChangedVisitor::Visit(nsIFormControl* aRadio)
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -119,17 +119,16 @@
 #include "nsIJSContextStack.h"
 #include "nsIDocumentViewer.h"
 #include "nsIWyciwygChannel.h"
 #include "nsIScriptElement.h"
 #include "nsIScriptError.h"
 #include "nsIMutableArray.h"
 #include "nsArrayUtils.h"
 #include "nsIEffectiveTLDService.h"
-#include "nsIEventStateManager.h"
 
 #include "nsIPrompt.h"
 //AHMED 12-2
 #include "nsBidiUtils.h"
 
 #include "nsIEditingSession.h"
 #include "nsIEditor.h"
 #include "nsNodeInfoManager.h"
--- a/content/mathml/content/src/nsMathMLElement.cpp
+++ b/content/mathml/content/src/nsMathMLElement.cpp
@@ -42,17 +42,17 @@
 #include "nsDOMClassInfoID.h" // for eDOMClassInfo_MathElement_id.
 #include "nsGkAtoms.h"
 #include "nsCRT.h"
 #include "nsRuleData.h"
 #include "nsCSSValue.h"
 #include "nsMappedAttributes.h"
 #include "nsStyleConsts.h"
 #include "nsIDocument.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
 #include "nsDOMClassInfoID.h"
 #include "mozAutoDocUpdate.h"
 
 //----------------------------------------------------------------------
 // nsISupports methods:
 
--- a/content/xtf/src/nsXTFElementWrapper.cpp
+++ b/content/xtf/src/nsXTFElementWrapper.cpp
@@ -43,17 +43,17 @@
 #include "nsXTFInterfaceAggregator.h"
 #include "nsIClassInfo.h"
 #include "nsPIDOMWindow.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIDocument.h"
 #include "nsGkAtoms.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStateManager.h"
 #include "nsIEventListenerManager.h"
 #include "nsIDOMEvent.h"
 #include "nsGUIEvent.h"
 #include "nsContentUtils.h"
 #include "nsIXTFService.h"
 #include "nsIDOMAttr.h"
 #include "nsIAttribute.h"
 #include "nsDOMAttributeMap.h"
@@ -969,17 +969,17 @@ nsXTFElementWrapper::RegUnregAccessKey(P
   nsIPresShell *presShell = doc->GetShell();
   if (!presShell)
     return;
 
   nsPresContext *presContext = presShell->GetPresContext();
   if (!presContext)
     return;
 
-  nsIEventStateManager *esm = presContext->EventStateManager();
+  nsEventStateManager *esm = presContext->EventStateManager();
   if (!esm)
     return;
 
   // Register or unregister as appropriate.
   nsCOMPtr<nsIDOMAttr> accesskeyNode;
   GetXTFElement()->GetAccesskeyNode(getter_AddRefs(accesskeyNode));
   if (!accesskeyNode)
     return;
--- a/content/xul/content/src/nsXULElement.cpp
+++ b/content/xul/content/src/nsXULElement.cpp
@@ -78,17 +78,17 @@
 #include "nsIDOMEventTarget.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMXULCommandDispatcher.h"
 #include "nsIDOMXULElement.h"
 #include "nsIDOMElementCSSInlineStyle.h"
 #include "nsIDOMXULSelectCntrlItemEl.h"
 #include "nsIDocument.h"
 #include "nsIEventListenerManager.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStateManager.h"
 #include "nsFocusManager.h"
 #include "nsIFastLoadService.h"
 #include "nsHTMLStyleSheet.h"
 #include "nsINameSpaceManager.h"
 #include "nsIObjectInputStream.h"
 #include "nsIObjectOutputStream.h"
 #include "nsIPresShell.h"
 #include "nsIPrincipal.h"
--- a/content/xul/content/src/nsXULPopupListener.cpp
+++ b/content/xul/content/src/nsXULPopupListener.cpp
@@ -69,17 +69,16 @@
 #include "nsLayoutUtils.h"
 #include "nsFrameManager.h"
 #include "nsHTMLReflowState.h"
 #include "nsIObjectLoadingContent.h"
 
 // for event firing in context menus
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
-#include "nsIEventStateManager.h"
 #include "nsFocusManager.h"
 #include "nsPIDOMWindow.h"
 #include "nsIViewManager.h"
 #include "nsDOMError.h"
 #include "nsIMenuFrame.h"
 
 // on win32 and os/2, context menus come up on mouse up. On other platforms,
 // they appear on mouse down. Certain bits of code care about this difference.
@@ -296,17 +295,17 @@ nsXULPopupListener::FireFocusOnTargetCon
         fm->SetFocus(element, nsIFocusManager::FLAG_BYMOUSE |
                               nsIFocusManager::FLAG_NOSCROLL);
       } else if (!suppressBlur) {
         nsPIDOMWindow *window = doc->GetWindow();
         fm->ClearFocus(window);
       }
     }
 
-    nsIEventStateManager *esm = context->EventStateManager();
+    nsEventStateManager *esm = context->EventStateManager();
     nsCOMPtr<nsIContent> focusableContent = do_QueryInterface(element);
     esm->SetContentState(focusableContent, NS_EVENT_STATE_ACTIVE);
   }
   return rv;
 }
 #endif
 
 // ClosePopup
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -196,17 +196,17 @@
 #include "prmem.h"
 
 #include "nsISelectionDisplay.h"
 
 #include "nsIGlobalHistory2.h"
 #include "nsIGlobalHistory3.h"
 
 #ifdef DEBUG_DOCSHELL_FOCUS
-#include "nsIEventStateManager.h"
+#include "nsEventStateManager.h"
 #endif
 
 #include "nsIFrame.h"
 
 // for embedding
 #include "nsIWebBrowserChromeFocus.h"
 
 #if NS_PRINT_PREVIEW
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -41,17 +41,16 @@
 #include "nsDOMError.h"
 #include "nsIDOMNSEvent.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsDOMWindowUtils.h"
 #include "nsQueryContentEventResult.h"
 #include "nsGlobalWindow.h"
 #include "nsIDocument.h"
 #include "nsFocusManager.h"
-#include "nsIEventStateManager.h"
 #include "nsEventStateManager.h"
 #include "nsFrameManager.h"
 #include "nsRefreshDriver.h"
 
 #include "nsIScrollableFrame.h"
 
 #include "nsContentUtils.h"
 #include "nsLayoutUtils.h"
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -63,17 +63,17 @@
 #include "nsIDocShellTreeItem.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsLayoutUtils.h"
 #include "nsIPresShell.h"
 #include "nsIContentViewer.h"
 #include "nsFrameTraversal.h"
 #include "nsObjectFrame.h"
 #include "nsEventDispatcher.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStateManager.h"
 #include "nsIMEStateManager.h"
 #include "nsIWebNavigation.h"
 #include "nsCaret.h"
 #include "nsWidgetsCID.h"
 #include "nsILookAndFeel.h"
 #include "nsIWidget.h"
 #include "nsIBaseWindow.h"
 #include "nsIViewManager.h"
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -121,17 +121,17 @@
 #include "nsIDOMPopStateEvent.h"
 #include "nsIDOMOfflineResourceList.h"
 #include "nsIDOMGeoGeolocation.h"
 #include "nsIDOMDesktopNotification.h"
 #include "nsPIDOMStorage.h"
 #include "nsDOMString.h"
 #include "nsIEmbeddingSiteWindow2.h"
 #include "nsThreadUtils.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStateManager.h"
 #include "nsIHttpProtocolHandler.h"
 #include "nsIJSContextStack.h"
 #include "nsIJSRuntimeService.h"
 #include "nsIMarkupDocumentViewer.h"
 #include "nsIPrefBranch.h"
 #include "nsIPresShell.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsIProgrammingLanguage.h"
--- a/dom/base/nsWindowRoot.cpp
+++ b/dom/base/nsWindowRoot.cpp
@@ -42,17 +42,16 @@
 #include "nsPIDOMWindow.h"
 #include "nsIDOMWindow.h"
 #include "nsIDOMDocument.h"
 #include "nsIDocument.h"
 #include "nsIEventListenerManager.h"
 #include "nsPresContext.h"
 #include "nsLayoutCID.h"
 #include "nsContentCID.h"
-#include "nsIEventStateManager.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsIDOMWindowInternal.h"
 #include "nsString.h"
 #include "nsEventDispatcher.h"
 #include "nsIProgrammingLanguage.h"
 #include "nsGUIEvent.h"
 #include "nsGlobalWindow.h"
 #include "nsFocusManager.h"
--- a/editor/libeditor/base/nsEditorEventListener.cpp
+++ b/editor/libeditor/base/nsEditorEventListener.cpp
@@ -66,17 +66,16 @@
 #include "nsIClipboard.h"
 #include "nsIDragService.h"
 #include "nsIDragSession.h"
 #include "nsIContent.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIDOMNSRange.h"
 #include "nsEditorUtils.h"
 #include "nsIDOMEventTarget.h"
-#include "nsIEventStateManager.h"
 #include "nsISelectionPrivate.h"
 #include "nsIDOMDragEvent.h"
 #include "nsIFocusManager.h"
 #include "nsIDOMWindow.h"
 #include "nsContentUtils.h"
 
 class nsAutoEditorKeypressOperation {
 public:
--- a/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/editor/libeditor/html/nsHTMLEditor.cpp
@@ -93,17 +93,16 @@
 // Misc
 #include "TextEditorTest.h"
 #include "nsEditorUtils.h"
 #include "nsWSRunObject.h"
 #include "nsGkAtoms.h"
 
 #include "nsIFrame.h"
 #include "nsIParserService.h"
-#include "nsIEventStateManager.h"
 
 // Some utilities to handle annoying overloading of "A" tag for link and named anchor
 static char hrefText[] = "href";
 static char anchorTxt[] = "anchor";
 static char namedanchorText[] = "namedanchor";
 
 nsIRangeUtils* nsHTMLEditor::sRangeHelper;
 
--- a/embedding/components/find/src/nsWebBrowserFind.cpp
+++ b/embedding/components/find/src/nsWebBrowserFind.cpp
@@ -51,17 +51,16 @@
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsPIDOMWindow.h"
 #include "nsIURI.h"
 #include "nsIDocShell.h"
 #include "nsIEnumerator.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
-#include "nsIEventStateManager.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsISelectionController.h"
 #include "nsISelection.h"
 #include "nsIFrame.h"
 #include "nsITextControlFrame.h"
 #include "nsReadableUtils.h"
 #include "nsIDOMHTMLElement.h"
--- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ -90,17 +90,16 @@
 #include "nsISelection2.h"
 #include "nsISelectionController.h"
 #include "nsIServiceManager.h"
 #include "nsITextServicesFilter.h"
 #include "nsString.h"
 #include "nsThreadUtils.h"
 #include "nsUnicharUtils.h"
 #include "nsIContent.h"
-#include "nsIEventStateManager.h"
 #include "nsIEventListenerManager.h"
 #include "nsGUIEvent.h"
 
 // Set to spew messages to the console about what is happening.
 //#define DEBUG_INLINESPELL
 
 // the number of milliseconds that we will take at once to do spellchecking
 #define INLINESPELL_CHECK_TIMEOUT 50
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -61,17 +61,17 @@
 #include "nsIDOMHTMLDocument.h"
 #include "nsIDOMHTMLTableColElement.h"
 #include "nsIDOMHTMLTableCaptionElem.h"
 #include "nsHTMLParts.h"
 #include "nsIPresShell.h"
 #include "nsUnicharUtils.h"
 #include "nsStyleSet.h"
 #include "nsIViewManager.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 #include "nsStyleConsts.h"
 #include "nsTableOuterFrame.h"
 #include "nsIDOMXULElement.h"
 #include "nsHTMLContainerFrame.h"
 #include "nsINameSpaceManager.h"
 #include "nsIDOMHTMLSelectElement.h"
 #include "nsIDOMHTMLLegendElement.h"
 #include "nsIComboboxControlFrame.h"
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -53,17 +53,16 @@
 #include "mozilla/FunctionTimer.h"
 #include "nsIDocumentViewerPrint.h"
 #include "nsIDOMDocumentEvent.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsIDOMBeforeUnloadEvent.h"
 #include "nsIDocument.h"
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
-#include "nsIEventStateManager.h"
 #include "nsStyleSet.h"
 #include "nsIStyleSheet.h"
 #include "nsCSSStyleSheet.h"
 #include "nsIFrame.h"
 #include "nsSubDocumentFrame.h"
 
 #include "nsILinkHandler.h"
 #include "nsIDOMDocument.h"
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -84,17 +84,17 @@ struct nsRect;
 class imgIRequest;
 
 class nsFontMetrics;
 class nsIFrame;
 class nsFrameManager;
 class nsILinkHandler;
 class nsStyleContext;
 class nsIAtom;
-class nsIEventStateManager;
+class nsEventStateManager;
 class nsIURI;
 class nsILookAndFeel;
 class nsICSSPseudoComparator;
 class nsIAtom;
 struct nsStyleBackground;
 struct nsStyleBorder;
 class nsIRunnable;
 class gfxUserFontSet;
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -113,16 +113,17 @@
 #include "nsIDOMXMLDocument.h"
 #include "nsIParser.h"
 #include "nsParserCIID.h"
 #include "nsFrameSelection.h"
 #include "nsIDOMNSHTMLTextAreaElement.h"
 #include "nsViewsCID.h"
 #include "nsPresArena.h"
 #include "nsFrameManager.h"
+#include "nsEventStateManager.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsILayoutHistoryState.h"
 #include "nsILineIterator.h" // for ScrollContentIntoView
 #include "nsWeakPtr.h"
 #include "pldhash.h"
 #include "nsIObserverService.h"
 #include "nsIObserver.h"
@@ -3772,17 +3773,17 @@ PresShell::GetReferenceRenderingContext(
 nsresult
 PresShell::GoToAnchor(const nsAString& aAnchorName, PRBool aScroll)
 {
   if (!mDocument) {
     return NS_ERROR_FAILURE;
   }
   
   // Hold a reference to the ESM in case event dispatch tears us down.
-  nsCOMPtr<nsIEventStateManager> esm = mPresContext->EventStateManager();
+  nsRefPtr<nsEventStateManager> esm = mPresContext->EventStateManager();
 
   if (aAnchorName.IsEmpty()) {
     NS_ASSERTION(!aScroll, "can't scroll to empty anchor name");
     esm->SetContentState(nsnull, NS_EVENT_STATE_URLTARGET);
     return NS_OK;
   }
 
   nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryInterface(mDocument);
@@ -6503,17 +6504,17 @@ PresShell::HandleEvent(nsIView         *
     // EventStateManager of the current PresContext.
     // If that is the case, and mouse is over some ancestor document,
     // forward event handling to the active document.
     // This way content can get mouse events even when
     // mouse is over the chrome or outside the window.
     //
     // Note, currently for backwards compatibility we don't forward mouse events
     // to the active document when mouse is over some subdocument.
-    nsIEventStateManager* activeESM =
+    nsEventStateManager* activeESM =
       nsEventStateManager::GetActiveEventStateManager();
     if (activeESM && NS_IS_MOUSE_EVENT(aEvent) &&
         activeESM != shell->GetPresContext()->EventStateManager() &&
         static_cast<nsEventStateManager*>(activeESM)->GetPresContext()) {
       nsIPresShell* activeShell =
         static_cast<nsEventStateManager*>(activeESM)->GetPresContext()->GetPresShell();
       if (activeShell &&
           nsContentUtils::ContentIsCrossDocDescendantOf(activeShell->GetDocument(),
@@ -6789,17 +6790,17 @@ PresShell::HandleEventInternal(nsEvent* 
       // Ensure this is set in case a11y was activated before any
       // nsPresShells existed to observe "a11y-init-or-shutdown" topic
       gIsAccessibilityActive = PR_TRUE;
       return NS_OK;
     }
   }
 #endif
 
-  nsCOMPtr<nsIEventStateManager> manager = mPresContext->EventStateManager();
+  nsRefPtr<nsEventStateManager> manager = mPresContext->EventStateManager();
   nsresult rv = NS_OK;
 
   if (!NS_EVENT_NEEDS_FRAME(aEvent) || GetCurrentEventFrame()) {
     PRBool isHandlingUserInput = PR_FALSE;
 
     if (NS_IS_TRUSTED_EVENT(aEvent)) {
       switch (aEvent->message) {
       case NS_MOUSE_BUTTON_DOWN:
--- a/layout/forms/nsButtonFrameRenderer.cpp
+++ b/layout/forms/nsButtonFrameRenderer.cpp
@@ -39,17 +39,17 @@
 #include "nsPresContext.h"
 #include "nsGkAtoms.h"
 #include "nsCSSPseudoElements.h"
 #include "nsINameSpaceManager.h"
 #include "nsStyleSet.h"
 #include "nsDisplayList.h"
 #include "nsITheme.h"
 #include "nsThemeConstants.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 
 #define ACTIVE   "active"
 #define HOVER    "hover"
 #define FOCUS    "focus"
 
 nsButtonFrameRenderer::nsButtonFrameRenderer()
 {
   MOZ_COUNT_CTOR(nsButtonFrameRenderer);
--- a/layout/forms/nsFileControlFrame.cpp
+++ b/layout/forms/nsFileControlFrame.cpp
@@ -86,17 +86,17 @@
 #include "nsIVariant.h"
 #include "mozilla/Services.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsHTMLInputElement.h"
 #include "nsICapturePicker.h"
 #include "nsIFileURL.h"
 #include "nsDOMFile.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 
 namespace dom = mozilla::dom;
 
 #define SYNC_TEXT 0x1
 #define SYNC_BUTTON 0x2
 
 nsIFrame*
 NS_NewFileControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
--- a/layout/forms/nsFormControlFrame.cpp
+++ b/layout/forms/nsFormControlFrame.cpp
@@ -33,17 +33,17 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsFormControlFrame.h"
 #include "nsGkAtoms.h"
 #include "nsIDOMHTMLInputElement.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStateManager.h"
 #include "nsILookAndFeel.h"
 
 //#define FCF_NOISY
 
 const PRInt32 kSizeNotSet = -1;
 
 nsFormControlFrame::nsFormControlFrame(nsStyleContext* aContext) :
   nsLeafFrame(aContext)
@@ -123,22 +123,23 @@ nsFormControlFrame::RegUnRegAccessKey(ns
   
   NS_ASSERTION(presContext, "aPresContext is NULL in RegUnRegAccessKey!");
 
   nsAutoString accessKey;
 
   nsIContent* content = aFrame->GetContent();
   content->GetAttr(kNameSpaceID_None, nsGkAtoms::accesskey, accessKey);
   if (!accessKey.IsEmpty()) {
-    nsIEventStateManager *stateManager = presContext->EventStateManager();
+    nsEventStateManager *stateManager = presContext->EventStateManager();
     if (aDoReg) {
-      return stateManager->RegisterAccessKey(content, (PRUint32)accessKey.First());
+      stateManager->RegisterAccessKey(content, (PRUint32)accessKey.First());
     } else {
-      return stateManager->UnregisterAccessKey(content, (PRUint32)accessKey.First());
+      stateManager->UnregisterAccessKey(content, (PRUint32)accessKey.First());
     }
+    return NS_OK;
   }
   return NS_ERROR_FAILURE;
 }
 
 void 
 nsFormControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
 {
 }
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -54,17 +54,17 @@
 #include "nsComboboxControlFrame.h"
 #include "nsIViewManager.h"
 #include "nsIDOMHTMLOptGroupElement.h"
 #include "nsWidgetsCID.h"
 #include "nsIPresShell.h"
 #include "nsHTMLParts.h"
 #include "nsIDOMEventTarget.h"
 #include "nsEventDispatcher.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStateManager.h"
 #include "nsIEventListenerManager.h"
 #include "nsIDOMKeyEvent.h"
 #include "nsIDOMMouseEvent.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIComponentManager.h"
 #include "nsILookAndFeel.h"
@@ -82,17 +82,16 @@
 #include "nsIPrivateDOMEvent.h"
 #include "nsCSSRendering.h"
 #include "nsITheme.h"
 #include "nsIDOMMouseListener.h"
 #include "nsIDOMMouseMotionListener.h"
 #include "nsIDOMKeyListener.h"
 #include "nsLayoutUtils.h"
 #include "nsDisplayList.h"
-#include "nsIEventStateManager.h"
 
 // Constants
 const nscoord kMaxDropDownRows          = 20; // This matches the setting for 4.x browsers
 const PRInt32 kNothingSelected          = -1;
 
 // Static members
 nsListControlFrame * nsListControlFrame::mFocused = nsnull;
 nsString * nsListControlFrame::sIncrementalString = nsnull;
@@ -2067,19 +2066,18 @@ nsListControlFrame::GetIndexFromDOMEvent
     // If we're not capturing, then ignore movement in the border
     nsPoint pt = nsLayoutUtils::GetDOMEventCoordinatesRelativeTo(aMouseEvent, this);
     nsRect borderInnerEdge = GetScrollPortRect();
     if (!borderInnerEdge.Contains(pt)) {
       return NS_ERROR_FAILURE;
     }
   }
 
-  nsCOMPtr<nsIContent> content;
-  PresContext()->EventStateManager()->
-    GetEventTargetContent(nsnull, getter_AddRefs(content));
+  nsCOMPtr<nsIContent> content = PresContext()->EventStateManager()->
+    GetEventTargetContent(nsnull);
 
   nsCOMPtr<nsIContent> optionContent = GetOptionFromContent(content);
   if (optionContent) {
     aCurIndex = GetIndexFromContent(optionContent);
     return NS_OK;
   }
 
   PRInt32 numOptions = GetNumberOfOptions();
--- a/layout/forms/nsTextControlFrame.cpp
+++ b/layout/forms/nsTextControlFrame.cpp
@@ -87,17 +87,16 @@
 #include "nsIStyleSheet.h"//observe documents to send onchangenotifications
 #include "nsIStyleRule.h"//observe documents to send onchangenotifications
 #include "nsIDOMEventListener.h"//observe documents to send onchangenotifications
 #include "nsGUIEvent.h"
 #include "nsIDOMEventGroup.h"
 #include "nsIDOM3EventTarget.h"
 #include "nsIDOMNSEvent.h"
 #include "nsIDOMNSUIEvent.h"
-#include "nsIEventStateManager.h"
 
 #include "nsIDOMFocusListener.h" //onchange events
 #include "nsIDOMCharacterData.h" //for selection setting helper func
 #include "nsIDOMNodeList.h" //for selection setting helper func
 #include "nsIDOMRange.h" //for selection setting helper func
 #include "nsPIDOMWindow.h" //needed for notify selection changed to update the menus ect.
 #ifdef ACCESSIBILITY
 #include "nsAccessibilityService.h"
--- a/layout/generic/nsContainerFrame.cpp
+++ b/layout/generic/nsContainerFrame.cpp
@@ -61,17 +61,16 @@
 #include "nsGfxCIID.h"
 #include "nsIServiceManager.h"
 #include "nsCSSRendering.h"
 #include "nsTransform2D.h"
 #include "nsRegion.h"
 #include "nsLayoutErrors.h"
 #include "nsDisplayList.h"
 #include "nsContentErrors.h"
-#include "nsIEventStateManager.h"
 #include "nsListControlFrame.h"
 #include "nsIBaseWindow.h"
 #include "nsThemeConstants.h"
 #include "nsCSSFrameConstructor.h"
 #include "nsThemeConstants.h"
 #include "mozilla/dom/Element.h"
 
 #ifdef NS_DEBUG
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -2071,19 +2071,17 @@ nsFrame::HandlePress(nsPresContext* aPre
   NS_ENSURE_ARG_POINTER(aEventStatus);
   if (nsEventStatus_eConsumeNoDefault == *aEventStatus) {
     return NS_OK;
   }
 
   //We often get out of sync state issues with mousedown events that
   //get interrupted by alerts/dialogs.
   //Check with the ESM to see if we should process this one
-  PRBool eventOK;
-  aPresContext->EventStateManager()->EventStatusOK(aEvent, &eventOK);
-  if (!eventOK) 
+  if (!aPresContext->EventStateManager()->EventStatusOK(aEvent)) 
     return NS_OK;
 
   nsresult rv;
   nsIPresShell *shell = aPresContext->GetPresShell();
   if (!shell)
     return NS_ERROR_FAILURE;
 
   // if we are in Navigator and the click is in a draggable node, we don't want
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -83,25 +83,24 @@
 #include "nsIDOMNode.h"
 #include "nsGUIEvent.h"
 #include "nsLayoutUtils.h"
 #include "nsDisplayList.h"
 
 #include "imgIContainer.h"
 #include "imgILoader.h"
 
-#include "nsContentPolicyUtils.h"
 #include "nsCSSFrameConstructor.h"
 #include "nsIPrefBranch2.h"
 #include "nsIPrefService.h"
 #include "nsIDOMRange.h"
 
 #include "nsIContentPolicy.h"
 #include "nsContentPolicyUtils.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 #include "nsLayoutErrors.h"
 #include "nsBidiUtils.h"
 #include "nsBidiPresUtils.h"
 
 #include "gfxRect.h"
 
 // sizes (pixels) for image icon, padding and border frame
 #define ICON_SIZE        (16)
--- a/layout/inspector/src/inDOMUtils.cpp
+++ b/layout/inspector/src/inDOMUtils.cpp
@@ -52,16 +52,17 @@
 #include "nsICSSStyleRuleDOMWrapper.h"
 #include "nsIDOMWindowInternal.h"
 #include "nsXBLBinding.h"
 #include "nsXBLPrototypeBinding.h"
 #include "nsIDOMElement.h"
 #include "nsIMutableArray.h"
 #include "nsBindingManager.h"
 #include "nsComputedDOMStyle.h"
+#include "nsEventStateManager.h"
 
 ///////////////////////////////////////////////////////////////////////////////
 
 inDOMUtils::inDOMUtils()
 {
 }
 
 inDOMUtils::~inDOMUtils()
@@ -231,17 +232,17 @@ inDOMUtils::GetBindingURLs(nsIDOMElement
   return NS_OK;
 }
 
 NS_IMETHODIMP
 inDOMUtils::SetContentState(nsIDOMElement *aElement, nsEventStates::InternalType aState)
 {
   NS_ENSURE_ARG_POINTER(aElement);
   
-  nsCOMPtr<nsIEventStateManager> esm = inLayoutUtils::GetEventStateManagerFor(aElement);
+  nsRefPtr<nsEventStateManager> esm = inLayoutUtils::GetEventStateManagerFor(aElement);
   if (esm) {
     nsCOMPtr<nsIContent> content;
     content = do_QueryInterface(aElement);
   
     return esm->SetContentState(content, nsEventStates(aState));
   }
   
   return NS_ERROR_FAILURE;
@@ -249,17 +250,17 @@ inDOMUtils::SetContentState(nsIDOMElemen
 
 NS_IMETHODIMP
 inDOMUtils::GetContentState(nsIDOMElement *aElement, nsEventStates::InternalType* aState)
 {
   *aState = 0;
 
   NS_ENSURE_ARG_POINTER(aElement);
 
-  nsCOMPtr<nsIEventStateManager> esm = inLayoutUtils::GetEventStateManagerFor(aElement);
+  nsRefPtr<nsEventStateManager> esm = inLayoutUtils::GetEventStateManagerFor(aElement);
   if (esm) {
     nsCOMPtr<nsIContent> content;
     content = do_QueryInterface(aElement);
     // NOTE: if this method is removed,
     // please remove GetInternalValue from nsEventStates
     *aState = esm->GetContentState(content).GetInternalValue();
     return NS_OK;
   }
--- a/layout/inspector/src/inDOMUtils.h
+++ b/layout/inspector/src/inDOMUtils.h
@@ -35,21 +35,21 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef __inDOMUtils_h__
 #define __inDOMUtils_h__
 
 #include "inIDOMUtils.h"
 
-#include "nsIEventStateManager.h"
 #include "nsISupportsArray.h"
 
 class nsRuleNode;
 class nsStyleContext;
+class nsIContent;
 
 class inDOMUtils : public inIDOMUtils
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_INIDOMUTILS
 
   inDOMUtils();
--- a/layout/inspector/src/inLayoutUtils.cpp
+++ b/layout/inspector/src/inLayoutUtils.cpp
@@ -85,17 +85,17 @@ inLayoutUtils::GetPresShellFor(nsISuppor
 /*static*/
 nsIFrame*
 inLayoutUtils::GetFrameFor(nsIDOMElement* aElement)
 {
   nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
   return content->GetPrimaryFrame();
 }
 
-nsIEventStateManager*
+nsEventStateManager*
 inLayoutUtils::GetEventStateManagerFor(nsIDOMElement *aElement)
 {
   NS_PRECONDITION(aElement, "Passing in a null element is bad");
 
   nsCOMPtr<nsIDOMDocument> domDoc;
   aElement->GetOwnerDocument(getter_AddRefs(domDoc));
   nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
 
--- a/layout/inspector/src/inLayoutUtils.h
+++ b/layout/inspector/src/inLayoutUtils.h
@@ -38,27 +38,27 @@
 #ifndef __inLayoutUtils_h__
 #define __inLayoutUtils_h__
 
 class nsBindingManager;
 class nsIDOMDocument;
 class nsIDOMElement;
 class nsIDOMNode;
 class nsIDOMWindowInternal;
-class nsIEventStateManager;
+class nsEventStateManager;
 class nsIFrame;
 class nsIPresShell;
 class nsISupports;
 
 class inLayoutUtils
 {
 public:
   static nsIDOMWindowInternal* GetWindowFor(nsIDOMNode* aNode);
   static nsIDOMWindowInternal* GetWindowFor(nsIDOMDocument* aDoc);
   static nsIPresShell* GetPresShellFor(nsISupports* aThing);
   static nsIFrame* GetFrameFor(nsIDOMElement* aElement);
-  static nsIEventStateManager* GetEventStateManagerFor(nsIDOMElement *aElement);
+  static nsEventStateManager* GetEventStateManagerFor(nsIDOMElement *aElement);
   static nsBindingManager* GetBindingManagerFor(nsIDOMNode* aNode);
   static nsIDOMDocument* GetSubDocumentFor(nsIDOMNode* aNode);
   static nsIDOMNode* GetContainerFor(nsIDOMDocument* aDoc);
 };
 
 #endif // __inLayoutUtils_h__
--- a/layout/printing/nsPrintPreviewListener.cpp
+++ b/layout/printing/nsPrintPreviewListener.cpp
@@ -42,17 +42,16 @@
 #include "nsIDOMWindow.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMKeyEvent.h"
 #include "nsIDOMNSEvent.h"
 #include "nsIDocument.h"
 #include "nsIDocShell.h"
 #include "nsPresContext.h"
-#include "nsIEventStateManager.h"
 #include "nsFocusManager.h"
 #include "nsLiteralString.h"
 
 NS_IMPL_ISUPPORTS1(nsPrintPreviewListener, nsIDOMEventListener)
 
 
 //
 // nsPrintPreviewListener ctor
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -57,17 +57,17 @@
 #include "pldhash.h"
 #include "nsHashtable.h"
 #include "nsICSSPseudoComparator.h"
 #include "nsCSSRuleProcessor.h"
 #include "mozilla/css/StyleRule.h"
 #include "mozilla/css/GroupRule.h"
 #include "nsIDocument.h"
 #include "nsPresContext.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStateManager.h"
 #include "nsGkAtoms.h"
 #include "nsString.h"
 #include "nsUnicharUtils.h"
 #include "nsDOMError.h"
 #include "nsRuleWalker.h"
 #include "nsCSSPseudoClasses.h"
 #include "nsCSSPseudoElements.h"
 #include "nsIContent.h"
--- a/layout/style/nsHTMLStyleSheet.cpp
+++ b/layout/style/nsHTMLStyleSheet.cpp
@@ -54,17 +54,17 @@
 #include "nsIAtom.h"
 #include "nsIURL.h"
 #include "nsMappedAttributes.h"
 #include "nsILink.h"
 #include "nsIFrame.h"
 #include "nsStyleContext.h"
 #include "nsGkAtoms.h"
 #include "nsPresContext.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 #include "nsIDocument.h"
 #include "nsIPresShell.h"
 #include "nsStyleConsts.h"
 #include "nsIHTMLDocument.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsCSSAnonBoxes.h"
 #include "nsRuleWalker.h"
 #include "nsRuleData.h"
--- a/layout/style/nsIStyleRuleProcessor.h
+++ b/layout/style/nsIStyleRuleProcessor.h
@@ -119,17 +119,17 @@ public:
     HasDocumentStateDependentStyle(StateRuleProcessorData* aData) = 0;
 
   /**
    * Return how (as described by nsRestyleHint) style can depend on a
    * change of the given content state on the given content node.  This
    * test is used for optimization only, and may err on the side of
    * reporting more dependencies than really exist.
    *
-   * Event states are defined in nsIEventStateManager.h.
+   * Event states are defined in nsEventStates.h.
    */
   virtual nsRestyleHint
     HasStateDependentStyle(StateRuleProcessorData* aData) = 0;
 
   /**
    * This method will be called twice for every attribute change.
    * During the first call, aData->mAttrHasChanged will be false and
    * the attribute change will not have happened yet.  During the
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -57,17 +57,17 @@
 #include "nsIContent.h"
 #include "nsIFrame.h"
 #include "nsContentUtils.h"
 #include "nsRuleProcessorData.h"
 #include "nsTransitionManager.h"
 #ifdef MOZ_CSS_ANIMATIONS
 #include "nsAnimationManager.h"
 #endif
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 #include "mozilla/dom/Element.h"
 
 using namespace mozilla::dom;
 
 NS_IMPL_ISUPPORTS1(nsEmptyStyleRule, nsIStyleRule)
 
 /* virtual */ void
 nsEmptyStyleRule::MapRuleInfoInto(nsRuleData* aRuleData)
--- a/layout/xul/base/src/nsBoxFrame.cpp
+++ b/layout/xul/base/src/nsBoxFrame.cpp
@@ -80,22 +80,21 @@
 #include "nsIServiceManager.h"
 #include "nsIBoxLayout.h"
 #include "nsSprocketLayout.h"
 #include "nsIDocument.h"
 #include "nsIScrollableFrame.h"
 #include "nsWidgetsCID.h"
 #include "nsCSSAnonBoxes.h"
 #include "nsHTMLContainerFrame.h"
-#include "nsIEventStateManager.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMElement.h"
 #include "nsITheme.h"
 #include "nsTransform2D.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStateManager.h"
 #include "nsEventDispatcher.h"
 #include "nsIDOMEvent.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsContentUtils.h"
 #include "nsDisplayList.h"
 
 // Needed for Print Preview
 #include "nsIDocument.h"
@@ -1925,27 +1924,25 @@ nsBoxFrame::RegUnregAccessKey(PRBool aDo
   nsAutoString accessKey;
   mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::accesskey, accessKey);
 
   if (accessKey.IsEmpty())
     return NS_OK;
 
   // With a valid PresContext we can get the ESM 
   // and register the access key
-  nsIEventStateManager *esm = PresContext()->EventStateManager();
-
-  nsresult rv;
+  nsEventStateManager *esm = PresContext()->EventStateManager();
 
   PRUint32 key = accessKey.First();
   if (aDoReg)
-    rv = esm->RegisterAccessKey(mContent, key);
+    esm->RegisterAccessKey(mContent, key);
   else
-    rv = esm->UnregisterAccessKey(mContent, key);
+    esm->UnregisterAccessKey(mContent, key);
 
-  return rv;
+  return NS_OK;
 }
 
 PRBool
 nsBoxFrame::SupportsOrdinalsInChildren()
 {
   return PR_TRUE;
 }
 
--- a/layout/xul/base/src/nsButtonBoxFrame.cpp
+++ b/layout/xul/base/src/nsButtonBoxFrame.cpp
@@ -43,17 +43,17 @@
 #include "nsIDOMDocument.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMXULButtonElement.h"
 #include "nsGkAtoms.h"
 #include "nsINameSpaceManager.h"
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsGUIEvent.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStateManager.h"
 #include "nsIDOMElement.h"
 #include "nsDisplayList.h"
 #include "nsContentUtils.h"
 
 //
 // NS_NewXULButtonFrame
 //
 // Creates a new Button frame and returns it
@@ -87,17 +87,17 @@ nsButtonBoxFrame::HandleEvent(nsPresCont
     return NS_OK;
   }
 
   switch (aEvent->message) {
     case NS_KEY_DOWN:
       if (NS_KEY_EVENT == aEvent->eventStructType) {
         nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent;
         if (NS_VK_SPACE == keyEvent->keyCode) {
-          nsIEventStateManager *esm = aPresContext->EventStateManager();
+          nsEventStateManager *esm = aPresContext->EventStateManager();
           // :hover:active state
           esm->SetContentState(mContent, NS_EVENT_STATE_HOVER);
           esm->SetContentState(mContent, NS_EVENT_STATE_ACTIVE);
         }
       }
       break;
 
 // On mac, Return fires the defualt button, not the focused one.
@@ -116,17 +116,17 @@ nsButtonBoxFrame::HandleEvent(nsPresCont
       break;
 #endif
 
     case NS_KEY_UP:
       if (NS_KEY_EVENT == aEvent->eventStructType) {
         nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent;
         if (NS_VK_SPACE == keyEvent->keyCode) {
           // only activate on keyup if we're already in the :hover:active state
-          nsIEventStateManager *esm = aPresContext->EventStateManager();
+          nsEventStateManager *esm = aPresContext->EventStateManager();
           nsEventStates buttonState = esm->GetContentState(mContent);
           if (buttonState.HasAllStates(NS_EVENT_STATE_ACTIVE |
                                        NS_EVENT_STATE_HOVER)) {
             // return to normal state
             esm->SetContentState(nsnull, NS_EVENT_STATE_ACTIVE);
             esm->SetContentState(nsnull, NS_EVENT_STATE_HOVER);
             MouseClicked(aPresContext, aEvent);
           }
--- a/layout/xul/base/src/nsMenuBarListener.cpp
+++ b/layout/xul/base/src/nsMenuBarListener.cpp
@@ -52,18 +52,16 @@
 #include "nsIServiceManager.h"
 #include "nsWidgetsCID.h"
 #include "nsCOMPtr.h"
 #include "nsIDOMKeyEvent.h"
 #include "nsIContent.h"
 #include "nsIDOMNode.h"
 #include "nsIDOMElement.h"
 
-#include "nsIEventStateManager.h"
-
 #include "nsContentUtils.h"
 
 /*
  * nsMenuBarListener implementation
  */
 
 NS_IMPL_ADDREF(nsMenuBarListener)
 NS_IMPL_RELEASE(nsMenuBarListener)
--- a/layout/xul/base/src/nsMenuPopupFrame.cpp
+++ b/layout/xul/base/src/nsMenuPopupFrame.cpp
@@ -68,17 +68,17 @@
 #include "nsGUIEvent.h"
 #include "nsIRootBox.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsReadableUtils.h"
 #include "nsUnicharUtils.h"
 #include "nsLayoutUtils.h"
 #include "nsContentUtils.h"
 #include "nsCSSFrameConstructor.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStateManager.h"
 #include "nsIBoxLayout.h"
 #include "nsIPopupBoxObject.h"
 #include "nsPIWindowRoot.h"
 #include "nsIReflowCallback.h"
 #include "nsBindingManager.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIBaseWindow.h"
 #include "nsISound.h"
@@ -828,17 +828,17 @@ nsMenuPopupFrame::HidePopup(PRBool aDese
   viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
   viewManager->ResizeView(view, nsRect(0, 0, 0, 0));
 
   FireDOMEvent(NS_LITERAL_STRING("DOMMenuInactive"), mContent);
 
   // XXX, bug 137033, In Windows, if mouse is outside the window when the menupopup closes, no
   // mouse_enter/mouse_exit event will be fired to clear current hover state, we should clear it manually.
   // This code may not the best solution, but we can leave it here until we find the better approach.
-  nsIEventStateManager *esm = PresContext()->EventStateManager();
+  nsEventStateManager *esm = PresContext()->EventStateManager();
 
   nsEventStates state = esm->GetContentState(mContent);
 
   if (state.HasState(NS_EVENT_STATE_HOVER))
     esm->SetContentState(nsnull, NS_EVENT_STATE_HOVER);
 
   nsMenuFrame* menuFrame = GetParentMenu();
   if (menuFrame) {
--- a/layout/xul/base/src/nsTextBoxFrame.cpp
+++ b/layout/xul/base/src/nsTextBoxFrame.cpp
@@ -57,17 +57,17 @@
 #include "nsBoxLayoutState.h"
 #include "nsMenuBarListener.h"
 #include "nsXPIDLString.h"
 #include "nsIServiceManager.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMXULLabelElement.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStateManager.h"
 #include "nsITheme.h"
 #include "nsUnicharUtils.h"
 #include "nsContentUtils.h"
 #include "nsDisplayList.h"
 #include "nsCSSRendering.h"
 #include "nsIReflowCallback.h"
 #include "nsBoxFrame.h"
 
@@ -1146,22 +1146,20 @@ nsTextBoxFrame::RegUnregAccessKey(PRBool
 
     // see if we even have an access key
     nsAutoString accessKey;
     mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::accesskey, accessKey);
 
     if (accessKey.IsEmpty())
         return NS_OK;
 
-    nsresult rv;
-
     // With a valid PresContext we can get the ESM 
     // and (un)register the access key
-    nsIEventStateManager *esm = PresContext()->EventStateManager();
+    nsEventStateManager *esm = PresContext()->EventStateManager();
 
     PRUint32 key = accessKey.First();
     if (aDoReg)
-        rv = esm->RegisterAccessKey(mContent, key);
+        esm->RegisterAccessKey(mContent, key);
     else
-        rv = esm->UnregisterAccessKey(mContent, key);
+        esm->UnregisterAccessKey(mContent, key);
 
-    return rv;
+    return NS_OK;
 }
--- a/layout/xul/base/src/nsXULLabelFrame.cpp
+++ b/layout/xul/base/src/nsXULLabelFrame.cpp
@@ -35,17 +35,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 /* derived class of nsBlockFrame used for xul:label elements */
 
 #include "nsXULLabelFrame.h"
 #include "nsHTMLParts.h"
 #include "nsINameSpaceManager.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStateManager.h"
 
 nsIFrame*
 NS_NewXULLabelFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
 {
   nsXULLabelFrame* it = new (aPresShell) nsXULLabelFrame(aContext);
   
   if (it)
     it->SetFlags(NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT);
@@ -75,26 +75,25 @@ nsXULLabelFrame::RegUnregAccessKey(PRBoo
   nsAutoString accessKey;
   mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::accesskey, accessKey);
 
   if (accessKey.IsEmpty())
     return NS_OK;
 
   // With a valid PresContext we can get the ESM 
   // and register the access key
-  nsIEventStateManager *esm = PresContext()->EventStateManager();
-  nsresult rv;
+  nsEventStateManager *esm = PresContext()->EventStateManager();
 
   PRUint32 key = accessKey.First();
   if (aDoReg)
-    rv = esm->RegisterAccessKey(mContent, key);
+    esm->RegisterAccessKey(mContent, key);
   else
-    rv = esm->UnregisterAccessKey(mContent, key);
+    esm->UnregisterAccessKey(mContent, key);
 
-  return rv;
+  return NS_OK;
 }
 
 /////////////////////////////////////////////////////////////////////////////
 // nsIFrame
 
 NS_IMETHODIMP
 nsXULLabelFrame::Init(nsIContent*      aContent,
                       nsIFrame*        aParent,
--- a/layout/xul/base/src/tree/src/nsTreeContentView.cpp
+++ b/layout/xul/base/src/tree/src/nsTreeContentView.cpp
@@ -37,17 +37,17 @@
 
 #include "nsINameSpaceManager.h"
 #include "nsGkAtoms.h"
 #include "nsIBoxObject.h"
 #include "nsTreeUtils.h"
 #include "nsTreeContentView.h"
 #include "nsChildIterator.h"
 #include "nsIDOMClassInfo.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 #include "nsINodeInfo.h"
 #include "nsIXULSortService.h"
 #include "nsContentUtils.h"
 #include "nsTreeBodyFrame.h"
 #include "mozilla/dom/Element.h"
 
 namespace dom = mozilla::dom;
 
--- a/toolkit/components/places/History.cpp
+++ b/toolkit/components/places/History.cpp
@@ -46,17 +46,16 @@
 #include "nsNavBookmarks.h"
 #include "Helpers.h"
 #include "PlaceInfo.h"
 #include "VisitInfo.h"
 
 #include "mozilla/storage.h"
 #include "mozilla/dom/Link.h"
 #include "nsDocShellCID.h"
-#include "nsIEventStateManager.h"
 #include "mozilla/Services.h"
 #include "nsThreadUtils.h"
 #include "nsNetUtil.h"
 #include "nsIXPConnect.h"
 
 // Initial size for the cache holding visited status observers.
 #define VISIT_OBSERVERS_INITIAL_CACHE_SIZE 128
 
--- a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
+++ b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
@@ -64,17 +64,16 @@
 #include "nsIContent.h"
 #include "nsIFrame.h"
 #include "nsFrameTraversal.h"
 #include "nsIDOMDocument.h"
 #include "nsIImageDocument.h"
 #include "nsIDOMHTMLDocument.h"
 #include "nsIDOMNSHTMLDocument.h"
 #include "nsIDOMHTMLElement.h"
-#include "nsIEventStateManager.h"
 #include "nsIDocument.h"
 #include "nsISelection.h"
 #include "nsILink.h"
 #include "nsTextFragment.h"
 #include "nsIDOMNSEditableElement.h"
 #include "nsIDOMNSHTMLElement.h"
 #include "nsIEditor.h"
 
--- a/widget/src/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/src/cocoa/nsNativeThemeCocoa.mm
@@ -47,17 +47,17 @@
 #include "nsSize.h"
 #include "nsThemeConstants.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsIFrame.h"
 #include "nsIAtom.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 #include "nsINameSpaceManager.h"
 #include "nsPresContext.h"
 #include "nsILookAndFeel.h"
 #include "nsWidgetAtoms.h"
 #include "nsToolkit.h"
 #include "nsCocoaWindow.h"
 #include "nsNativeThemeColors.h"
 #include "nsIScrollableFrame.h"
--- a/widget/src/qt/nsNativeThemeQt.cpp
+++ b/widget/src/qt/nsNativeThemeQt.cpp
@@ -56,17 +56,16 @@
 #include "nsPresContext.h"
 
 #include "nsRect.h"
 #include "nsSize.h"
 #include "nsTransform2D.h"
 #include "nsThemeConstants.h"
 #include "nsILookAndFeel.h"
 #include "nsIServiceManager.h"
-#include "nsIEventStateManager.h"
 #include "nsIDOMHTMLInputElement.h"
 #include <malloc.h>
 
 
 #include "gfxASurface.h"
 #include "gfxContext.h"
 #include "gfxQtPlatform.h"
 #include "gfxQPainterSurface.h"
--- a/widget/src/windows/nsNativeThemeWin.cpp
+++ b/widget/src/windows/nsNativeThemeWin.cpp
@@ -46,17 +46,17 @@
 #include "nsSize.h"
 #include "nsTransform2D.h"
 #include "nsThemeConstants.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsIFrame.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStates.h"
 #include "nsINameSpaceManager.h"
 #include "nsILookAndFeel.h"
 #include "nsIDOMHTMLInputElement.h"
 #include "nsIMenuFrame.h"
 #include "nsWidgetAtoms.h"
 #include <malloc.h>
 #include "nsWindow.h"
 #include "nsIComboboxControlFrame.h"
--- a/widget/src/xpwidgets/nsBaseDragService.cpp
+++ b/widget/src/xpwidgets/nsBaseDragService.cpp
@@ -54,17 +54,16 @@
 #include "nsIPresShell.h"
 #include "nsIViewManager.h"
 #include "nsIDOMNode.h"
 #include "nsIDOMDragEvent.h"
 #include "nsISelection.h"
 #include "nsISelectionPrivate.h"
 #include "nsPresContext.h"
 #include "nsIDOMDataTransfer.h"
-#include "nsIEventStateManager.h"
 #include "nsICanvasElementExternal.h"
 #include "nsIImageLoadingContent.h"
 #include "imgIContainer.h"
 #include "imgIRequest.h"
 #include "nsIViewObserver.h"
 #include "nsRegion.h"
 #include "nsGUIEvent.h"
 #include "nsIPrefService.h"
--- a/widget/src/xpwidgets/nsNativeTheme.cpp
+++ b/widget/src/xpwidgets/nsNativeTheme.cpp
@@ -38,17 +38,17 @@
 
 #include "nsNativeTheme.h"
 #include "nsIWidget.h"
 #include "nsIDocument.h"
 #include "nsIContent.h"
 #include "nsIFrame.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
-#include "nsIEventStateManager.h"
+#include "nsEventStateManager.h"
 #include "nsString.h"
 #include "nsINameSpaceManager.h"
 #include "nsIDOMHTMLInputElement.h"
 #include "nsILookAndFeel.h"
 #include "nsThemeConstants.h"
 #include "nsIComponentManager.h"
 #include "nsPIDOMWindow.h"
 
@@ -86,17 +86,17 @@ nsNativeTheme::GetContentState(nsIFrame*
 
   if (!aFrame->GetContent())
     return nsEventStates();
 
   nsIPresShell *shell = GetPresShell(aFrame);
   if (!shell)
     return nsEventStates();
 
-  nsIEventStateManager* esm = shell->GetPresContext()->EventStateManager();
+  nsEventStateManager* esm = shell->GetPresContext()->EventStateManager();
   nsEventStates flags = esm->GetContentState(aFrame->GetContent(), PR_TRUE);
   
   if (isXULCheckboxRadio && aWidgetType == NS_THEME_RADIO) {
     if (IsFocused(aFrame))
       flags |= NS_EVENT_STATE_FOCUS;
   }
 
   // On Windows and Mac, only draw focus rings if they should be shown. This
--- a/widget/src/xpwidgets/nsNativeTheme.h
+++ b/widget/src/xpwidgets/nsNativeTheme.h
@@ -71,17 +71,17 @@ class nsNativeTheme : public nsITimerCal
   enum TreeSortDirection {
     eTreeSortDirection_Descending,
     eTreeSortDirection_Natural,
     eTreeSortDirection_Ascending
   };
 
   nsNativeTheme();
 
-  // Returns the content state (hover, focus, etc), see nsIEventStateManager.h
+  // Returns the content state (hover, focus, etc), see nsEventStateManager.h
   nsEventStates GetContentState(nsIFrame* aFrame, PRUint8 aWidgetType);
 
   // Returns whether the widget is already styled by content
   // Normally called from ThemeSupportsWidget to turn off native theming
   // for elements that are already styled.
   PRBool IsWidgetStyled(nsPresContext* aPresContext, nsIFrame* aFrame,
                         PRUint8 aWidgetType);