diff --git a/mozilla/accessible/src/base/nsRootAccessible.cpp b/mozilla/accessible/src/base/nsRootAccessible.cpp index 751779325da..e55a41f0bbe 100644 --- a/mozilla/accessible/src/base/nsRootAccessible.cpp +++ b/mozilla/accessible/src/base/nsRootAccessible.cpp @@ -43,7 +43,6 @@ #include "nsIAccessibleCaret.h" #include "nsIBaseWindow.h" #include "nsICaret.h" -#include "nsIChromeEventHandler.h" #include "nsIDocShell.h" #include "nsIDocShellTreeItem.h" #include "nsIDocShellTreeNode.h" @@ -264,7 +263,7 @@ nsRootAccessible::GetChromeEventHandler(nsIDOMEventTarget **aChromeTarget) nsCOMPtr domWin; GetWindow(getter_AddRefs(domWin)); nsCOMPtr privateDOMWindow(do_QueryInterface(domWin)); - nsCOMPtr chromeEventHandler; + nsCOMPtr chromeEventHandler; if (privateDOMWindow) { chromeEventHandler = privateDOMWindow->GetChromeEventHandler(); } diff --git a/mozilla/content/base/public/nsContentUtils.h b/mozilla/content/base/public/nsContentUtils.h index 970f21a5d22..c91556bda0e 100644 --- a/mozilla/content/base/public/nsContentUtils.h +++ b/mozilla/content/base/public/nsContentUtils.h @@ -802,13 +802,10 @@ public: * @param aCreateIfNotFound If PR_FALSE, returns a listener manager only if * one already exists. * @param aResult [out] Set to the eventlistener manager for aNode. - * @param aCreated [out] Set to PR_TRUE if a new eventlistener manager was - * created. */ static nsresult GetListenerManager(nsINode *aNode, PRBool aCreateIfNotFound, - nsIEventListenerManager **aResult, - PRBool *aCreated); + nsIEventListenerManager **aResult); /** * Remove the eventlistener manager for aNode. diff --git a/mozilla/content/base/public/nsINode.h b/mozilla/content/base/public/nsINode.h index aacf03c8007..8ed515f4d32 100644 --- a/mozilla/content/base/public/nsINode.h +++ b/mozilla/content/base/public/nsINode.h @@ -38,6 +38,7 @@ #ifndef nsINode_h___ #define nsINode_h___ +#include "nsPIDOMEventTarget.h" #include "nsEvent.h" #include "nsPropertyTable.h" #include "nsTObserverArray.h" @@ -96,11 +97,11 @@ class nsNodeSupportsWeakRefTearoff; // IID for the nsINode interface #define NS_INODE_IID \ -{ 0x0d2a583d, 0x7a99, 0x426b, \ - { 0x89, 0xfa, 0xca, 0x8d, 0x63, 0xbb, 0xd7, 0x3f } } +{ 0x22ab1440, 0xa6ee, 0x4da7, \ + { 0xbc, 0x3b, 0x94, 0x2e, 0x56, 0x0d, 0xdc, 0xe0 } } // hack to make egcs / gcc 2.95.2 happy -class nsINode_base : public nsISupports { +class nsINode_base : public nsPIDOMEventTarget { public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_INODE_IID) }; @@ -442,65 +443,6 @@ public: return mNodeInfo->NodeInfoManager()->DocumentPrincipal(); } - /** - * Called before the capture phase of the event flow. - * This is used to create the event target chain and implementations - * should set the necessary members of nsEventChainPreVisitor. - * At least aVisitor.mCanHandle must be set, - * usually also aVisitor.mParentTarget if mCanHandle is PR_TRUE. - * First one tells that this object can handle the aVisitor.mEvent event and - * the latter one is the possible parent object for the event target chain. - * @see nsEventDispatcher.h for more documentation about aVisitor. - * - * @param aVisitor the visitor object which is used to create the - * event target chain for event dispatching. - * - * @note Only nsEventDispatcher should call this method. - */ - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) = 0; - - /** - * Called after the bubble phase of the system event group. - * The default handling of the event should happen here. - * @param aVisitor the visitor object which is used during post handling. - * - * @see nsEventDispatcher.h for documentation about aVisitor. - * @note Only nsEventDispatcher should call this method. - */ - virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) = 0; - - /** - * Dispatch an event. - * @param aEvent the event that is being dispatched. - * @param aDOMEvent the event that is being dispatched, use if you want to - * dispatch nsIDOMEvent, not only nsEvent. - * @param aPresContext the current presentation context, can be nsnull. - * @param aEventStatus the status returned from the function, can be nsnull. - * - * @note If both aEvent and aDOMEvent are used, aEvent must be the internal - * event of the aDOMEvent. - * - * If aDOMEvent is not nsnull (in which case aEvent can be nsnull) it is used - * for dispatching, otherwise aEvent is used. - * - * @deprecated This method is here just until all the callers outside Gecko - * have been converted to use nsIDOMEventTarget::dispatchEvent. - */ - virtual nsresult DispatchDOMEvent(nsEvent* aEvent, - nsIDOMEvent* aDOMEvent, - nsPresContext* aPresContext, - nsEventStatus* aEventStatus) = 0; - - /** - * Get the event listener manager, the guy you talk to to register for events - * on this node. - * @param aCreateIfNotFound If PR_FALSE, returns a listener manager only if - * one already exists. [IN] - * @param aResult The event listener manager [OUT] - */ - NS_IMETHOD GetListenerManager(PRBool aCreateIfNotFound, - nsIEventListenerManager** aResult); - /** * Get the parent nsIContent for this node. * @return the parent, or null if no parent or the parent is not an nsIContent @@ -609,6 +551,9 @@ public: nsNodeWeakReference* mWeakReference; }; + /** + * Functions for managing flags and slots + */ #ifdef DEBUG nsSlots* DebugGetSlots() { @@ -616,10 +561,34 @@ public: } #endif + PRBool HasFlag(PtrBits aFlag) const + { + return !!(GetFlags() & aFlag); + } + + PtrBits GetFlags() const + { + return NS_UNLIKELY(HasSlots()) ? FlagsAsSlots()->mFlags : mFlagsOrSlots; + } + + void SetFlags(PtrBits aFlagsToSet) + { + NS_ASSERTION(!(aFlagsToSet & (NODE_IS_ANONYMOUS | NODE_MAY_HAVE_FRAME)) || + IsNodeOfType(eCONTENT), + "Flag only permitted on nsIContent nodes"); + PtrBits* flags = HasSlots() ? &FlagsAsSlots()->mFlags : + &mFlagsOrSlots; + *flags |= aFlagsToSet; + } + + void UnsetFlags(PtrBits aFlagsToUnset) + { + PtrBits* flags = HasSlots() ? &FlagsAsSlots()->mFlags : + &mFlagsOrSlots; + *flags &= ~aFlagsToUnset; + } + protected: - /** - * Functions for managing flags and slots - */ // Override this function to create a custom slots class. virtual nsINode::nsSlots* CreateSlots(); @@ -654,33 +623,6 @@ protected: return slots; } - PtrBits GetFlags() const - { - return NS_UNLIKELY(HasSlots()) ? FlagsAsSlots()->mFlags : mFlagsOrSlots; - } - - PRBool HasFlag(PtrBits aFlag) const - { - return !!(GetFlags() & aFlag); - } - - void SetFlags(PtrBits aFlagsToSet) - { - NS_ASSERTION(!(aFlagsToSet & (NODE_IS_ANONYMOUS | NODE_MAY_HAVE_FRAME)) || - IsNodeOfType(eCONTENT), - "Flag only permitted on nsIContent nodes"); - PtrBits* flags = HasSlots() ? &FlagsAsSlots()->mFlags : - &mFlagsOrSlots; - *flags |= aFlagsToSet; - } - - void UnsetFlags(PtrBits aFlagsToUnset) - { - PtrBits* flags = HasSlots() ? &FlagsAsSlots()->mFlags : - &mFlagsOrSlots; - *flags &= ~aFlagsToUnset; - } - nsCOMPtr mNodeInfo; enum { PARENT_BIT_INDOCUMENT = 1 << 0, PARENT_BIT_PARENT_IS_CONTENT = 1 << 1 }; diff --git a/mozilla/content/base/src/nsContentUtils.cpp b/mozilla/content/base/src/nsContentUtils.cpp index 1315803d8fa..10bd19c1a43 100644 --- a/mozilla/content/base/src/nsContentUtils.cpp +++ b/mozilla/content/base/src/nsContentUtils.cpp @@ -2911,12 +2911,14 @@ nsContentUtils::TraverseListenerManager(nsINode *aNode, nsresult nsContentUtils::GetListenerManager(nsINode *aNode, PRBool aCreateIfNotFound, - nsIEventListenerManager **aResult, - PRBool *aCreated) + nsIEventListenerManager **aResult) { *aResult = nsnull; - *aCreated = PR_FALSE; + if (!aCreateIfNotFound && !aNode->HasFlag(NODE_HAS_LISTENERMANAGER)) { + return NS_OK; + } + if (!sEventListenerManagersHash.ops) { // We're already shut down, don't bother creating an event listener // manager. @@ -2957,7 +2959,7 @@ nsContentUtils::GetListenerManager(nsINode *aNode, entry->mListenerManager->SetListenerTarget(aNode); - *aCreated = PR_TRUE; + aNode->SetFlags(NODE_HAS_LISTENERMANAGER); } NS_ADDREF(*aResult = entry->mListenerManager); diff --git a/mozilla/content/base/src/nsDOMAttribute.cpp b/mozilla/content/base/src/nsDOMAttribute.cpp index 1f63528b78e..849ae17189a 100644 --- a/mozilla/content/base/src/nsDOMAttribute.cpp +++ b/mozilla/content/base/src/nsDOMAttribute.cpp @@ -93,6 +93,7 @@ NS_INTERFACE_MAP_BEGIN(nsDOMAttribute) NS_INTERFACE_MAP_ENTRY(nsIDOMNode) NS_INTERFACE_MAP_ENTRY(nsIDOM3Node) NS_INTERFACE_MAP_ENTRY(nsIDOM3Attr) + NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget) NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference, new nsNodeSupportsWeakRefTearoff(this)) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMAttr) @@ -734,6 +735,13 @@ nsDOMAttribute::DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent, return NS_ERROR_NOT_IMPLEMENTED; } +nsresult +nsDOMAttribute::GetListenerManager(PRBool aCreateIfNotFound, + nsIEventListenerManager** aResult) +{ + return nsContentUtils::GetListenerManager(this, aCreateIfNotFound, aResult); +} + nsresult nsDOMAttribute::EnsureChildState(PRBool aSetText, PRBool &aHasChild) const { diff --git a/mozilla/content/base/src/nsDOMAttribute.h b/mozilla/content/base/src/nsDOMAttribute.h index 1eb2dc2ff1e..7c35ba22d65 100644 --- a/mozilla/content/base/src/nsDOMAttribute.h +++ b/mozilla/content/base/src/nsDOMAttribute.h @@ -100,6 +100,8 @@ public: virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent, nsPresContext* aPresContext, nsEventStatus* aEventStatus); + virtual nsresult GetListenerManager(PRBool aCreateIfNotFound, + nsIEventListenerManager** aResult); virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; static void Initialize(); diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index a55016db962..68345a3f9fc 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -908,6 +908,7 @@ NS_INTERFACE_MAP_BEGIN(nsDocument) NS_INTERFACE_MAP_ENTRY(nsIDOM3EventTarget) NS_INTERFACE_MAP_ENTRY(nsIDOMNSEventTarget) NS_INTERFACE_MAP_ENTRY(nsIDOMNode) + NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget) NS_INTERFACE_MAP_ENTRY(nsIDOM3Node) NS_INTERFACE_MAP_ENTRY(nsIDOM3Document) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) diff --git a/mozilla/content/base/src/nsFrameLoader.cpp b/mozilla/content/base/src/nsFrameLoader.cpp index f58a622fd98..88a37419c68 100644 --- a/mozilla/content/base/src/nsFrameLoader.cpp +++ b/mozilla/content/base/src/nsFrameLoader.cpp @@ -53,7 +53,6 @@ #include "nsIDOMWindow.h" #include "nsPIDOMWindow.h" #include "nsIWebNavigation.h" -#include "nsIChromeEventHandler.h" #include "nsIDocShell.h" #include "nsIDocShellTreeItem.h" #include "nsIDocShellTreeNode.h" @@ -65,6 +64,7 @@ #include "nsIScriptGlobalObject.h" #include "nsIScriptSecurityManager.h" #include "nsFrameLoader.h" +#include "nsIDOMEventTarget.h" #include "nsIURI.h" #include "nsIURL.h" @@ -397,7 +397,7 @@ nsFrameLoader::EnsureDocShell() // Make sure all shells have links back to the content element // in the nearest enclosing chrome shell. - nsCOMPtr chromeEventHandler; + nsCOMPtr chromeEventHandler; if (parentType == nsIDocShellTreeItem::typeChrome) { // Our parent shell is a chrome shell. It is therefore our nearest diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.cpp b/mozilla/content/base/src/nsGenericDOMDataNode.cpp index e24c372fdd2..dfb36fd250b 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.cpp +++ b/mozilla/content/base/src/nsGenericDOMDataNode.cpp @@ -90,6 +90,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_INTERFACE_MAP_BEGIN(nsGenericDOMDataNode) NS_INTERFACE_MAP_ENTRY(nsIContent) NS_INTERFACE_MAP_ENTRY(nsINode) + NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget) NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMEventReceiver, nsDOMEventRTTearoff::Create(this)) NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMEventTarget, @@ -702,6 +703,13 @@ nsGenericDOMDataNode::DispatchDOMEvent(nsEvent* aEvent, aPresContext, aEventStatus); } +nsresult +nsGenericDOMDataNode::GetListenerManager(PRBool aCreateIfNotFound, + nsIEventListenerManager** aResult) +{ + return nsContentUtils::GetListenerManager(this, aCreateIfNotFound, aResult); +} + PRUint32 nsGenericDOMDataNode::GetChildCount() const { diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.h b/mozilla/content/base/src/nsGenericDOMDataNode.h index 095036a617b..69d11c1a7fc 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.h +++ b/mozilla/content/base/src/nsGenericDOMDataNode.h @@ -180,6 +180,8 @@ public: virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent, nsPresContext* aPresContext, nsEventStatus* aEventStatus); + virtual nsresult GetListenerManager(PRBool aCreateIfNotFound, + nsIEventListenerManager** aResult); // Implementation for nsIContent virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index 79c96c35d55..13eaa368e56 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -214,25 +214,11 @@ nsINode::UnsetProperty(PRUint16 aCategory, nsIAtom *aPropertyName, aStatus); } -NS_IMETHODIMP -nsINode::GetListenerManager(PRBool aCreateIfNotFound, - nsIEventListenerManager** aResult) +nsresult +nsGenericElement::GetListenerManager(PRBool aCreateIfNotFound, + nsIEventListenerManager** aResult) { - // No need to call nsContentUtils::GetListenerManager if we don't have - // an event listener manager. - if (!aCreateIfNotFound && !HasFlag(NODE_HAS_LISTENERMANAGER)) { - *aResult = nsnull; - return NS_OK; - } - - PRBool created; - nsresult rv = - nsContentUtils::GetListenerManager(this, aCreateIfNotFound, aResult, - &created); - if (NS_SUCCEEDED(rv) && created) { - SetFlags(NODE_HAS_LISTENERMANAGER); - } - return rv; + return nsContentUtils::GetListenerManager(this, aCreateIfNotFound, aResult); } nsINode::nsSlots* @@ -3034,6 +3020,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_INTERFACE_MAP_BEGIN(nsGenericElement) NS_INTERFACE_MAP_ENTRY(nsIContent) NS_INTERFACE_MAP_ENTRY(nsINode) + NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget) NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Node, new nsNode3Tearoff(this)) NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNSElement, new nsNSElementTearoff(this)) NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMEventReceiver, diff --git a/mozilla/content/base/src/nsGenericElement.h b/mozilla/content/base/src/nsGenericElement.h index 0d2b7a27d0f..34af6cc992d 100644 --- a/mozilla/content/base/src/nsGenericElement.h +++ b/mozilla/content/base/src/nsGenericElement.h @@ -394,6 +394,8 @@ public: virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent, nsPresContext* aPresContext, nsEventStatus* aEventStatus); + virtual nsresult GetListenerManager(PRBool aCreateIfNotFound, + nsIEventListenerManager** aResult); // nsIContent interface methods virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, diff --git a/mozilla/content/base/src/nsNodeUtils.cpp b/mozilla/content/base/src/nsNodeUtils.cpp index 0ce3993615a..9d0b33bc256 100755 --- a/mozilla/content/base/src/nsNodeUtils.cpp +++ b/mozilla/content/base/src/nsNodeUtils.cpp @@ -219,9 +219,8 @@ nsNodeUtils::LastRelease(nsINode* aNode, PRBool aDelete) #ifdef DEBUG if (nsContentUtils::IsInitialized()) { nsCOMPtr manager; - PRBool created; nsContentUtils::GetListenerManager(aNode, PR_FALSE, - getter_AddRefs(manager), &created); + getter_AddRefs(manager)); if (!manager) { NS_ERROR("Huh, our bit says we have a listener manager list, " "but there's nothing in the hash!?!!"); diff --git a/mozilla/content/events/public/Makefile.in b/mozilla/content/events/public/Makefile.in index 1a69db3b7d6..7d01e7d8a87 100644 --- a/mozilla/content/events/public/Makefile.in +++ b/mozilla/content/events/public/Makefile.in @@ -54,6 +54,7 @@ EXPORTS = \ nsIPrivateCompositionEvent.h \ nsPLDOMEvent.h \ nsEventDispatcher.h \ + nsPIDOMEventTarget.h \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/mozilla/content/events/public/nsEventDispatcher.h b/mozilla/content/events/public/nsEventDispatcher.h index e90436c65a6..d833c3d0290 100644 --- a/mozilla/content/events/public/nsEventDispatcher.h +++ b/mozilla/content/events/public/nsEventDispatcher.h @@ -44,7 +44,7 @@ class nsIContent; class nsIDocument; class nsPresContext; -class nsIChromeEventHandler; +class nsPIDOMEventTarget; class nsIScriptGlobalObject; class nsEventTargetChainItem; @@ -53,21 +53,20 @@ class nsEventTargetChainItem; * About event dispatching: * When either nsEventDispatcher::Dispatch or * nsEventDispatcher::DispatchDOMEvent is called an event target chain is - * created. nsEventDispatcher creates the chain by calling PreHandleEvent - * (or PreHandleChromeEvent) on each event target and the creation continues - * until either the mCanHandle member of the nsEventChainPreVisitor object is - * PR_FALSE or the mParentTarget does not point to a new target. - * The event target chain is created on the stack. + * created. nsEventDispatcher creates the chain by calling PreHandleEvent + * on each event target and the creation continues until either the mCanHandle + * member of the nsEventChainPreVisitor object is PR_FALSE or the mParentTarget + * does not point to a new target. The event target chain is created in the + * heap. * * If the event needs retargeting, mEventTargetAtParent must be set in - * PreHandleEvent or PreHandleChromeEvent. + * PreHandleEvent. * * The capture, target and bubble phases of the event dispatch are handled * by iterating through the event target chain. Iteration happens twice, * first for the default event group and then for the system event group. * While dispatching the event for the system event group PostHandleEvent - * (or PostHandleChromeEvent) is called right after calling event listener for - * the current event target. + * is called right after calling event listener for the current event target. */ class nsEventChainVisitor { @@ -132,34 +131,25 @@ public: nsIDOMEvent* aDOMEvent, nsEventStatus aEventStatus = nsEventStatus_eIgnore) : nsEventChainVisitor(aPresContext, aEvent, aDOMEvent, aEventStatus), - mCanHandle(PR_TRUE), mParentIsChromeHandler(PR_FALSE), - mForceContentDispatch(PR_FALSE) {} + mCanHandle(PR_TRUE), mForceContentDispatch(PR_FALSE) {} void Reset() { mItemFlags = 0; mItemData = nsnull; mCanHandle = PR_TRUE; - mParentIsChromeHandler = PR_FALSE; mForceContentDispatch = PR_FALSE; mParentTarget = nsnull; mEventTargetAtParent = nsnull; } /** - * Member that must be set in PreHandleEvent or PreHandleChromeEvent by event - * targets. If set to false, indicates that this event target will not be - * handling the event and construction of the event target chain is complete. - * The target that sets mCanHandle to false is NOT included in the event target - * chain. + * Member that must be set in PreHandleEvent by event targets. If set to false, + * indicates that this event target will not be handling the event and + * construction of the event target chain is complete. The target that sets + * mCanHandle to false is NOT included in the event target chain. */ PRPackedBool mCanHandle; - /** - * Member that is set to PR_TRUE in PreHandleEvent or PreHandleChromeEvent if - * and only if mParentTarget is set to a chrome event handler. - */ - PRPackedBool mParentIsChromeHandler; - /** * If mForceContentDispatch is set to PR_TRUE, * content dispatching is not disabled for this event target. @@ -206,7 +196,7 @@ class nsEventDispatcher { public: /** - * aTarget should QI to nsINode, nsPIDOMWindow or nsIChromeEventHandler. + * aTarget should QI to nsPIDOMEventTarget. * If the target of aEvent is set before calling this method, the target of * aEvent is used as the target (unless there is event * retargeting) and the originalTarget of the DOM Event. @@ -220,8 +210,7 @@ public: nsEvent* aEvent, nsIDOMEvent* aDOMEvent = nsnull, nsEventStatus* aEventStatus = nsnull, - nsDispatchingCallback* aCallback = nsnull, - PRBool aTargetIsChromeHandler = PR_FALSE); + nsDispatchingCallback* aCallback = nsnull); /** * Dispatches an event. diff --git a/mozilla/content/events/public/nsPIDOMEventTarget.h b/mozilla/content/events/public/nsPIDOMEventTarget.h new file mode 100644 index 00000000000..81684b4ae09 --- /dev/null +++ b/mozilla/content/events/public/nsPIDOMEventTarget.h @@ -0,0 +1,122 @@ +/* -*- 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 Mozilla.org. + * Portions created by the Initial Developer are Copyright (C) 2006 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Olli Pettay (Original Author) + * + * Alternatively, the contents of this file may be used under the terms of + * either 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 nsPIDOMEventTarget_h_ +#define nsPIDOMEventTarget_h_ + +#include "nsISupports.h" +#include "nsEvent.h" + +class nsIDOMEvent; +class nsPresContext; +class nsEventChainPreVisitor; +class nsEventChainPostVisitor; +class nsIEventListenerManager; + +// 764756cd-8af2-4a25-919d-ca95759a1be1 +#define NS_PIDOMEVENTTARGET_IID \ +{ 0x764756cd, 0x8af2, 0x4a25, \ + { 0x91, 0x9d, 0xca, 0x95, 0x75, 0x9a, 0x1b, 0xe1 } } + +class nsPIDOMEventTarget : public nsISupports +{ +public: + NS_DECLARE_STATIC_IID_ACCESSOR(NS_PIDOMEVENTTARGET_IID) + + /** + * Called before the capture phase of the event flow. + * This is used to create the event target chain and implementations + * should set the necessary members of nsEventChainPreVisitor. + * At least aVisitor.mCanHandle must be set, + * usually also aVisitor.mParentTarget if mCanHandle is PR_TRUE. + * First one tells that this object can handle the aVisitor.mEvent event and + * the latter one is the possible parent object for the event target chain. + * @see nsEventDispatcher.h for more documentation about aVisitor. + * + * @param aVisitor the visitor object which is used to create the + * event target chain for event dispatching. + * + * @note Only nsEventDispatcher should call this method. + */ + virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) = 0; + + /** + * Called after the bubble phase of the system event group. + * The default handling of the event should happen here. + * @param aVisitor the visitor object which is used during post handling. + * + * @see nsEventDispatcher.h for documentation about aVisitor. + * @note Only nsEventDispatcher should call this method. + */ + virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) = 0; + + /** + * Dispatch an event. + * @param aEvent the event that is being dispatched. + * @param aDOMEvent the event that is being dispatched, use if you want to + * dispatch nsIDOMEvent, not only nsEvent. + * @param aPresContext the current presentation context, can be nsnull. + * @param aEventStatus the status returned from the function, can be nsnull. + * + * @note If both aEvent and aDOMEvent are used, aEvent must be the internal + * event of the aDOMEvent. + * + * If aDOMEvent is not nsnull (in which case aEvent can be nsnull) it is used + * for dispatching, otherwise aEvent is used. + * + * @deprecated This method is here just until all the callers outside Gecko + * have been converted to use nsIDOMEventTarget::dispatchEvent. + */ + virtual nsresult DispatchDOMEvent(nsEvent* aEvent, + nsIDOMEvent* aDOMEvent, + nsPresContext* aPresContext, + nsEventStatus* aEventStatus) = 0; + + /** + * Get the event listener manager, the guy you talk to to register for events + * on this node. + * @param aCreateIfNotFound If PR_FALSE, returns a listener manager only if + * one already exists. [IN] + * @param aResult The event listener manager [OUT] + */ + virtual nsresult GetListenerManager(PRBool aCreateIfNotFound, + nsIEventListenerManager** aResult) = 0; +}; + +NS_DEFINE_STATIC_IID_ACCESSOR(nsPIDOMEventTarget, NS_PIDOMEVENTTARGET_IID) + +#endif // !defined(nsPIDOMEventTarget_h_) diff --git a/mozilla/content/events/src/nsEventDispatcher.cpp b/mozilla/content/events/src/nsEventDispatcher.cpp index df5f6d4a9a2..c793d477349 100644 --- a/mozilla/content/events/src/nsEventDispatcher.cpp +++ b/mozilla/content/events/src/nsEventDispatcher.cpp @@ -40,7 +40,7 @@ #include "nsIAtom.h" #include "nsDOMEvent.h" #include "nsINode.h" -#include "nsIChromeEventHandler.h" +#include "nsPIDOMEventTarget.h" #include "nsPresContext.h" #include "nsIPrivateDOMEvent.h" #include "nsIDOMEventReceiver.h" @@ -54,22 +54,13 @@ #include NEW_H #include "nsFixedSizeAllocator.h" -#define NS_TARGET_CHAIN_IS_NODE (1 << 0) -#define NS_TARGET_CHAIN_IS_WINDOW (1 << 1) -#define NS_TARGET_CHAIN_IS_CHROMEHANDLER (1 << 2) - -#define NS_TARGET_CHAIN_FORCE_CONTENT_DISPATCH (1 << 3) - -#define NS_TARGET_CHAIN_TYPE_MASK \ - (NS_TARGET_CHAIN_IS_NODE | NS_TARGET_CHAIN_IS_WINDOW | \ - NS_TARGET_CHAIN_IS_CHROMEHANDLER) +#define NS_TARGET_CHAIN_FORCE_CONTENT_DISPATCH (1 << 0) // nsEventTargetChainItem represents a single item in the event target chain. class nsEventTargetChainItem { private: nsEventTargetChainItem(nsISupports* aTarget, - PRBool aTargetIsChromeHandler, nsEventTargetChainItem* aChild = nsnull); void Destroy(nsFixedSizeAllocator* aAllocator); @@ -77,13 +68,11 @@ private: public: static nsEventTargetChainItem* Create(nsFixedSizeAllocator* aAllocator, nsISupports* aTarget, - PRBool aTargetIsChromeHandler, nsEventTargetChainItem* aChild = nsnull) { void* place = aAllocator->Alloc(sizeof(nsEventTargetChainItem)); return place - ? ::new (place) nsEventTargetChainItem(aTarget, aTargetIsChromeHandler, - aChild) + ? ::new (place) nsEventTargetChainItem(aTarget, aChild) : nsnull; } @@ -97,7 +86,7 @@ public: PRBool IsValid() { - return !!(mFlags & NS_TARGET_CHAIN_TYPE_MASK); + return !!(mTarget); } nsISupports* GetNewTarget() @@ -122,10 +111,10 @@ public: return !!(mFlags & NS_TARGET_CHAIN_FORCE_CONTENT_DISPATCH); } - nsISupports* CurrentTarget(); - - already_AddRefed GetListenerManager( - PRBool aCreateIfNotFound); + nsISupports* CurrentTarget() + { + return mTarget; + } /** * Dispatches event through the event target chain. @@ -138,9 +127,8 @@ public: nsDispatchingCallback* aCallback); /** - * Resets aVisitor object and calls PreHandleEvent - * (or PreHandleChromeEvent). Copies mItemFlags and mItemData to the - * current nsEventTargetChainItem. + * Resets aVisitor object and calls PreHandleEvent. + * Copies mItemFlags and mItemData to the current nsEventTargetChainItem. */ nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor); @@ -152,64 +140,28 @@ public: nsresult HandleEvent(nsEventChainPostVisitor& aVisitor, PRUint32 aFlags); /** - * Copies mItemFlags and mItemData to aVisitor and calls PostHandleEvent - * (or PostHandleChromeEvent). + * Copies mItemFlags and mItemData to aVisitor and calls PostHandleEvent. */ nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor); - union { - nsINode* mNode; - nsPIDOMWindow* mWindow; - nsIChromeEventHandler* mChromeHandler; - }; - nsEventTargetChainItem* mChild; - nsEventTargetChainItem* mParent; - PRUint16 mFlags; - PRUint16 mItemFlags; - nsCOMPtr mItemData; + nsCOMPtr mTarget; + nsEventTargetChainItem* mChild; + nsEventTargetChainItem* mParent; + PRUint16 mFlags; + PRUint16 mItemFlags; + nsCOMPtr mItemData; // Event retargeting must happen whenever mNewTarget is non-null. - nsCOMPtr mNewTarget; + nsCOMPtr mNewTarget; }; nsEventTargetChainItem::nsEventTargetChainItem(nsISupports* aTarget, - PRBool aTargetIsChromeHandler, nsEventTargetChainItem* aChild) -: mNode(nsnull), mChild(aChild), mParent(nsnull), mFlags(0), mItemFlags(0) +: mTarget(do_QueryInterface(aTarget)), mChild(aChild), mParent(nsnull), mFlags(0), mItemFlags(0) { if (mChild) { mChild->mParent = this; } - - // If the target is explicitly marked to be a chrome handler. - if (aTargetIsChromeHandler) { - nsCOMPtr ceh = do_QueryInterface(aTarget); - if (ceh) { - ceh.swap(mChromeHandler); - mFlags |= NS_TARGET_CHAIN_IS_CHROMEHANDLER; - } - } else { - nsCOMPtr node = do_QueryInterface(aTarget); - if (node) { - node.swap(mNode); - mFlags |= NS_TARGET_CHAIN_IS_NODE; - } else { - nsCOMPtr window = - do_QueryInterface(aTarget); - if (window) { - window.swap(mWindow); - mFlags |= NS_TARGET_CHAIN_IS_WINDOW; - } else { - nsCOMPtr ceh = do_QueryInterface(aTarget); - if (ceh) { - ceh.swap(mChromeHandler); - mFlags |= NS_TARGET_CHAIN_IS_CHROMEHANDLER; - } - } - } - } - NS_POSTCONDITION((mFlags & NS_TARGET_CHAIN_TYPE_MASK), - "No event target in event target chain!"); } void @@ -225,119 +177,17 @@ nsEventTargetChainItem::Destroy(nsFixedSizeAllocator* aAllocator) mParent = nsnull; } - switch (mFlags & NS_TARGET_CHAIN_TYPE_MASK) { - case NS_TARGET_CHAIN_IS_NODE: - NS_RELEASE(mNode); - break; - case NS_TARGET_CHAIN_IS_WINDOW: - NS_RELEASE(mWindow); - break; - case NS_TARGET_CHAIN_IS_CHROMEHANDLER: - NS_RELEASE(mChromeHandler); - break; - default: - NS_WARNING("Unknown type in event target chain!!!"); - break; - } -} - -already_AddRefed -nsEventTargetChainItem::GetListenerManager(PRBool aCreateIfNotFound) -{ - nsIEventListenerManager* manager = nsnull; - switch (mFlags & NS_TARGET_CHAIN_TYPE_MASK) { - case NS_TARGET_CHAIN_IS_NODE: - { - mNode->GetListenerManager(aCreateIfNotFound, &manager); - break; - } - case NS_TARGET_CHAIN_IS_WINDOW: - { - nsCOMPtr receiver(do_QueryInterface(mWindow)); - if (receiver) { - receiver->GetListenerManager(aCreateIfNotFound, &manager); - } - break; - } - case NS_TARGET_CHAIN_IS_CHROMEHANDLER: - { - nsCOMPtr receiver(do_QueryInterface(mChromeHandler)); - if (receiver) { - receiver->GetListenerManager(aCreateIfNotFound, &manager); - } - break; - } - default: - { - NS_WARNING("Unknown type in event target chain!!!"); - break; - } - } - - return manager; -} - -nsISupports* -nsEventTargetChainItem::CurrentTarget() -{ - nsCOMPtr eventTarget; - switch (mFlags & NS_TARGET_CHAIN_TYPE_MASK) { - case NS_TARGET_CHAIN_IS_NODE: - { - return mNode; - } - case NS_TARGET_CHAIN_IS_WINDOW: - { - return mWindow; - break; - } - case NS_TARGET_CHAIN_IS_CHROMEHANDLER: - { - return mChromeHandler; - break; - } - default: - { - NS_WARNING("Unknown type in event target chain!!!"); - break; - } - } - - return nsnull; + mTarget = nsnull; } nsresult nsEventTargetChainItem::PreHandleEvent(nsEventChainPreVisitor& aVisitor) { aVisitor.Reset(); - nsresult rv = NS_OK; - switch (mFlags & NS_TARGET_CHAIN_TYPE_MASK) { - case NS_TARGET_CHAIN_IS_NODE: - { - rv = mNode->PreHandleEvent(aVisitor); - break; - } - case NS_TARGET_CHAIN_IS_WINDOW: - { - rv = mWindow->PreHandleEvent(aVisitor); - break; - } - case NS_TARGET_CHAIN_IS_CHROMEHANDLER: - { - rv = mChromeHandler->PreHandleChromeEvent(aVisitor); - break; - } - default: - { - NS_WARNING("Unknown type in event target chain!!!"); - break; - } - } - + nsresult rv = mTarget->PreHandleEvent(aVisitor); SetForceContentDispatch(aVisitor.mForceContentDispatch); mItemFlags = aVisitor.mItemFlags; mItemData = aVisitor.mItemData; - return rv; } @@ -345,8 +195,8 @@ nsresult nsEventTargetChainItem::HandleEvent(nsEventChainPostVisitor& aVisitor, PRUint32 aFlags) { - nsCOMPtr lm = - nsEventTargetChainItem::GetListenerManager(PR_FALSE); + nsCOMPtr lm; + mTarget->GetListenerManager(PR_FALSE, getter_AddRefs(lm)); if (lm) { aVisitor.mEvent->currentTarget = CurrentTarget(); @@ -363,26 +213,7 @@ nsEventTargetChainItem::PostHandleEvent(nsEventChainPostVisitor& aVisitor) { aVisitor.mItemFlags = mItemFlags; aVisitor.mItemData = mItemData; - switch (mFlags & NS_TARGET_CHAIN_TYPE_MASK) { - case NS_TARGET_CHAIN_IS_NODE: - { - return mNode->PostHandleEvent(aVisitor); - } - case NS_TARGET_CHAIN_IS_WINDOW: - { - return mWindow->PostHandleEvent(aVisitor); - } - case NS_TARGET_CHAIN_IS_CHROMEHANDLER: - { - return mChromeHandler->PostHandleChromeEvent(aVisitor); - } - default: - { - NS_WARNING("Unknown type in event target chain!!!"); - break; - } - } - + mTarget->PostHandleEvent(aVisitor); return NS_OK; } @@ -534,8 +365,7 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget, nsEvent* aEvent, nsIDOMEvent* aDOMEvent, nsEventStatus* aEventStatus, - nsDispatchingCallback* aCallback, - PRBool aTargetIsChromeHandler) + nsDispatchingCallback* aCallback) { NS_ASSERTION(aEvent, "Trying to dispatch without nsEvent!"); NS_ENSURE_TRUE(!NS_IS_EVENT_IN_DISPATCH(aEvent), @@ -569,7 +399,7 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget, // Create the event target chain item for the event target. nsEventTargetChainItem* targetEtci = - nsEventTargetChainItem::Create(pool.GetPool(), aTarget, aTargetIsChromeHandler); + nsEventTargetChainItem::Create(pool.GetPool(), aTarget); NS_ENSURE_TRUE(targetEtci, NS_ERROR_OUT_OF_MEMORY); if (!targetEtci->IsValid()) { nsEventTargetChainItem::Destroy(pool.GetPool(), targetEtci); @@ -602,7 +432,6 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget, while (preVisitor.mParentTarget) { nsEventTargetChainItem* parentEtci = nsEventTargetChainItem::Create(pool.GetPool(), preVisitor.mParentTarget, - preVisitor.mParentIsChromeHandler, topEtci); if (!parentEtci) { rv = NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index 3137a4e1e6c..f7936f22093 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -97,7 +97,6 @@ #include "nsIServiceManager.h" #include "nsIScriptSecurityManager.h" -#include "nsIChromeEventHandler.h" #include "nsIFocusController.h" #include "nsIDOMXULElement.h" diff --git a/mozilla/content/html/content/public/nsILink.h b/mozilla/content/html/content/public/nsILink.h index 8368063901f..842b5fbccb5 100644 --- a/mozilla/content/html/content/public/nsILink.h +++ b/mozilla/content/html/content/public/nsILink.h @@ -87,14 +87,14 @@ public: NS_IMETHOD GetHrefURI(nsIURI** aURI) = 0; /** - * Dispatch a LinkAdded event to the nsIChromeEventHandler for this document. + * Dispatch a LinkAdded event to the chrome event handler for this document. * This is used to notify the chrome listeners when restoring a page * presentation. Currently, this only applies to HTML elements. */ NS_IMETHOD LinkAdded() = 0; /** - * Dispatch a LinkRemoved event to the nsIChromeEventHandler for this + * Dispatch a LinkRemoved event to the chrome event handler for this * document. This is used to notify the chrome listeners when saving a page * presentation (since the document is not torn down). Currently, this only * applies to HTML elements. diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index dd73eaec871..1dd7854e6d1 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -3052,7 +3052,6 @@ nsGenericHTMLFrameElement::~nsGenericHTMLFrameElement() NS_INTERFACE_MAP_BEGIN(nsGenericHTMLFrameElement) NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLFrameElement) - NS_INTERFACE_MAP_ENTRY(nsIChromeEventHandler) NS_INTERFACE_MAP_ENTRY(nsIFrameLoaderOwner) NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement) @@ -3201,18 +3200,6 @@ nsGenericHTMLFrameElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, return rv; } -NS_IMETHODIMP -nsGenericHTMLFrameElement::PreHandleChromeEvent(nsEventChainPreVisitor& aVisitor) -{ - return PreHandleEvent(aVisitor); -} - -NS_IMETHODIMP -nsGenericHTMLFrameElement::PostHandleChromeEvent(nsEventChainPostVisitor& aVisitor) -{ - return NS_OK; -} - //---------------------------------------------------------------------- void diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.h b/mozilla/content/html/content/src/nsGenericHTMLElement.h index d3667242513..1fc92f79b69 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.h +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.h @@ -43,7 +43,6 @@ #include "nsINameSpaceManager.h" // for kNameSpaceID_None #include "nsIFormControl.h" #include "nsIDOMNSHTMLFrameElement.h" -#include "nsIChromeEventHandler.h" #include "nsFrameLoader.h" class nsIDOMAttr; @@ -843,8 +842,7 @@ protected: class nsGenericHTMLFrameElement : public nsGenericHTMLElement, public nsIDOMNSHTMLFrameElement, - public nsIFrameLoaderOwner, - public nsIChromeEventHandler + public nsIFrameLoaderOwner { public: nsGenericHTMLFrameElement(nsINodeInfo *aNodeInfo) @@ -859,9 +857,6 @@ public: // nsIDOMNSHTMLFrameElement NS_DECL_NSIDOMNSHTMLFRAMEELEMENT - // nsIChromeEventHandler - NS_DECL_NSICHROMEEVENTHANDLER - // nsIFrameLoaderOwner NS_DECL_NSIFRAMELOADEROWNER diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index 2211c01d323..1b6b5152168 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -433,8 +433,6 @@ nsXULElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) inst = NS_STATIC_CAST(nsIScriptEventHandlerOwner*, new nsXULElement::nsScriptEventHandlerOwnerTearoff(this)); NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY); - } else if (aIID.Equals(NS_GET_IID(nsIChromeEventHandler))) { - inst = NS_STATIC_CAST(nsIChromeEventHandler *, this); } else if (aIID.Equals(NS_GET_IID(nsIDOMElementCSSInlineStyle))) { inst = NS_STATIC_CAST(nsIDOMElementCSSInlineStyle *, new nsXULElementTearoff(this)); @@ -2243,22 +2241,6 @@ nsXULElement::AddPopupListener(nsIAtom* aName) return NS_OK; } -//***************************************************************************** -// nsXULElement::nsIChromeEventHandler -//***************************************************************************** - -NS_IMETHODIMP -nsXULElement::PreHandleChromeEvent(nsEventChainPreVisitor& aVisitor) -{ - return PreHandleEvent(aVisitor); -} - -NS_IMETHODIMP -nsXULElement::PostHandleChromeEvent(nsEventChainPostVisitor& aVisitor) -{ - return NS_OK; -} - //---------------------------------------------------------------------- nsGenericElement::nsAttrInfo diff --git a/mozilla/content/xul/content/src/nsXULElement.h b/mozilla/content/xul/content/src/nsXULElement.h index b0f8d1a4a3b..7fb63b32660 100644 --- a/mozilla/content/xul/content/src/nsXULElement.h +++ b/mozilla/content/xul/content/src/nsXULElement.h @@ -70,7 +70,6 @@ #include "nsIXULPrototypeCache.h" #include "nsIXULTemplateBuilder.h" #include "nsIBoxObject.h" -#include "nsIChromeEventHandler.h" #include "nsIXBLService.h" #include "nsICSSOMFactory.h" #include "nsLayoutCID.h" @@ -440,9 +439,7 @@ public: #define XUL_ELEMENT_LAZY_STATE_OFFSET NODE_TYPE_SPECIFIC_BITS_OFFSET -class nsXULElement : public nsGenericElement, - public nsIDOMXULElement, - public nsIChromeEventHandler +class nsXULElement : public nsGenericElement, public nsIDOMXULElement { public: /** @@ -579,9 +576,6 @@ public: // nsIDOMXULElement NS_DECL_NSIDOMXULELEMENT - // nsIChromeEventHandler - NS_DECL_NSICHROMEEVENTHANDLER - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; nsresult GetStyle(nsIDOMCSSStyleDeclaration** aStyle); diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 087db830c1b..a1a32b22481 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -67,7 +67,7 @@ #include "nsIMarkupDocumentViewer.h" #include "nsXPIDLString.h" #include "nsReadableUtils.h" -#include "nsIChromeEventHandler.h" +#include "nsIDOMEventTarget.h" #include "nsIDOMChromeWindow.h" #include "nsIDOMWindowInternal.h" #include "nsIWebBrowserChrome.h" @@ -1110,10 +1110,12 @@ nsDocShell::GetContentViewer(nsIContentViewer ** aContentViewer) } NS_IMETHODIMP -nsDocShell::SetChromeEventHandler(nsIChromeEventHandler * aChromeEventHandler) +nsDocShell::SetChromeEventHandler(nsIDOMEventTarget* aChromeEventHandler) { + nsCOMPtr piTarget = + do_QueryInterface(aChromeEventHandler); // Weak reference. Don't addref. - mChromeEventHandler = aChromeEventHandler; + mChromeEventHandler = piTarget; NS_ASSERTION(!mScriptGlobal, "SetChromeEventHandler() called after the script global " @@ -1126,12 +1128,11 @@ nsDocShell::SetChromeEventHandler(nsIChromeEventHandler * aChromeEventHandler) } NS_IMETHODIMP -nsDocShell::GetChromeEventHandler(nsIChromeEventHandler ** aChromeEventHandler) +nsDocShell::GetChromeEventHandler(nsIDOMEventTarget** aChromeEventHandler) { NS_ENSURE_ARG_POINTER(aChromeEventHandler); - - *aChromeEventHandler = mChromeEventHandler; - NS_IF_ADDREF(*aChromeEventHandler); + nsCOMPtr target = do_QueryInterface(mChromeEventHandler); + target.swap(*aChromeEventHandler); return NS_OK; } diff --git a/mozilla/docshell/base/nsDocShell.h b/mozilla/docshell/base/nsDocShell.h index d6c0a1c1f06..68fcb0cdb91 100644 --- a/mozilla/docshell/base/nsDocShell.h +++ b/mozilla/docshell/base/nsDocShell.h @@ -104,6 +104,7 @@ #include "nsISecureBrowserUI.h" #include "nsIObserver.h" #include "nsDocShellLoadTypes.h" +#include "nsPIDOMEventTarget.h" class nsIScrollableView; @@ -600,7 +601,7 @@ protected: // For that reasons don't use nsCOMPtr. nsIDocShellTreeOwner * mTreeOwner; // Weak Reference - nsIChromeEventHandler * mChromeEventHandler; //Weak Reference + nsPIDOMEventTarget * mChromeEventHandler; //Weak Reference static nsIURIFixup *sURIFixup; diff --git a/mozilla/docshell/base/nsIDocShell.idl b/mozilla/docshell/base/nsIDocShell.idl index 9f6f67630b6..fa104d4a7a5 100644 --- a/mozilla/docshell/base/nsIDocShell.idl +++ b/mozilla/docshell/base/nsIDocShell.idl @@ -56,7 +56,7 @@ interface nsIURI; interface nsIChannel; interface nsIContentViewer; interface nsIURIContentListener; -interface nsIChromeEventHandler; +interface nsIDOMEventTarget; interface nsIDocShellLoadInfo; interface nsIDocumentCharsetInfo; interface nsIWebNavigation; @@ -68,7 +68,7 @@ interface nsILayoutHistoryState; interface nsISecureBrowserUI; interface nsIDOMStorage; -[scriptable, uuid(539355C0-F5C8-4929-A4AA-CB105E8F9997)] +[scriptable, uuid(fbe2a673-4b8b-46a2-b225-398c52cc05cb)] interface nsIDocShell : nsISupports { /** @@ -213,7 +213,7 @@ interface nsIDocShell : nsISupports * This attribute allows chrome to tie in to handle DOM events that may * be of interest to chrome. */ - attribute nsIChromeEventHandler chromeEventHandler; + attribute nsIDOMEventTarget chromeEventHandler; /** * The document charset info. This is used by a load to determine priorities diff --git a/mozilla/dom/public/base/nsPIDOMWindow.h b/mozilla/dom/public/base/nsPIDOMWindow.h index 81a057fef55..d7e60534e5d 100644 --- a/mozilla/dom/public/base/nsPIDOMWindow.h +++ b/mozilla/dom/public/base/nsPIDOMWindow.h @@ -45,7 +45,7 @@ #include "nsIDOMXULCommandDispatcher.h" #include "nsIDOMElement.h" #include "nsIDOMWindowInternal.h" -#include "nsIChromeEventHandler.h" +#include "nsPIDOMEventTarget.h" #include "nsIDOMDocument.h" #include "nsCOMPtr.h" #include "nsEvent.h" @@ -72,8 +72,8 @@ class nsPresContext; struct nsTimeout; #define NS_PIDOMWINDOW_IID \ -{ 0xbebce53b, 0xa4ec, 0x49e5, \ - { 0x82, 0x8e, 0x23, 0x08, 0x61, 0x2b, 0x41, 0x9b } } +{ 0xbf81c452, 0xbd39, 0x4001, \ + { 0x85, 0xf4, 0x21, 0x79, 0x36, 0xc5, 0x85, 0x7d } } class nsPIDOMWindow : public nsIDOMWindowInternal { @@ -87,7 +87,7 @@ public: virtual nsresult Activate() = 0; virtual nsresult Deactivate() = 0; - nsIChromeEventHandler* GetChromeEventHandler() const + nsPIDOMEventTarget* GetChromeEventHandler() const { return mChromeEventHandler; } @@ -311,55 +311,6 @@ public: virtual PRBool WouldReuseInnerWindow(nsIDocument *aNewDocument) = 0; - /** - * Called before the capture phase of the event flow. - * This is used to create the event target chain and implementations - * should set the necessary members of nsEventChainPreVisitor. - * At least aVisitor.mCanHandle must be set, - * usually also aVisitor.mParentTarget if mCanHandle is PR_TRUE. - * First one tells that this object can handle the aVisitor.mEvent event and - * the latter one is the possible parent object for the event target chain. - * @see nsEventDispatcher.h for more documentation about aVisitor. - * - * @param aVisitor the visitor object which is used to create the - * event target chain for event dispatching. - * - * @note Only nsEventDispatcher should call this method. - */ - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) = 0; - - /** - * Called after the bubble phase of the system event group. - * The default handling of the event should happen here. - * @param aVisitor the visitor object which is used during post handling. - * - * @see nsEventDispatcher.h for documentation about aVisitor. - * @note Only nsEventDispatcher should call this method. - */ - virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) = 0; - - - /** - * Dispatch an event. - * @param aEvent the event that is being dispatched. - * @param aDOMEvent the event that is being dispatched, use if you want to - * dispatch nsIDOMEvent, not only nsEvent. - * @param aPresContext the current presentation context, can be nsnull. - * @param aEventStatus the status returned from the function, can be nsnull. - * - * @note If both aEvent and aDOMEvent are used, aEvent must be the internal - * event of the aDOMEvent. - * - * If aDOMEvent is not nsnull (in which case aEvent can be nsnull) it is used - * for dispatching, otherwise aEvent is used. - * - * @deprecated This method is here just until all the callers outside Gecko - * have been converted to use nsIDOMEventTarget::dispatchEvent. - */ - virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent, - nsPresContext* aPresContext, - nsEventStatus* aEventStatus) = 0; - /** * Get the docshell in this window. */ @@ -427,7 +378,7 @@ protected: // These two variables are special in that they're set to the same // value on both the outer window and the current inner window. Make // sure you keep them in sync! - nsCOMPtr mChromeEventHandler; // strong + nsCOMPtr mChromeEventHandler; // strong nsCOMPtr mDocument; // strong // These members are only used on outer windows. diff --git a/mozilla/dom/public/base/nsPIWindowRoot.h b/mozilla/dom/public/base/nsPIWindowRoot.h index 14af5bbf2c3..890aaf9370f 100644 --- a/mozilla/dom/public/base/nsPIWindowRoot.h +++ b/mozilla/dom/public/base/nsPIWindowRoot.h @@ -41,6 +41,7 @@ #define nsPIWindowRoot_h__ #include "nsISupports.h" +#include "nsPIDOMEventTarget.h" class nsIFocusController; @@ -49,7 +50,7 @@ class nsIFocusController; { 0xc18dee5a, 0xdcf9, 0x4391, \ { 0xa2, 0x0c, 0x58, 0x1e, 0x76, 0x9d, 0x09, 0x5e } } -class nsPIWindowRoot : public nsISupports { +class nsPIWindowRoot : public nsPIDOMEventTarget { public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWINDOWROOT_IID) diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp index c64f82dd2b9..e9ea6ea93f9 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.cpp +++ b/mozilla/dom/src/base/nsGlobalWindow.cpp @@ -681,6 +681,7 @@ NS_INTERFACE_MAP_BEGIN(nsGlobalWindow) NS_INTERFACE_MAP_ENTRY(nsIScriptGlobalObject) NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal) NS_INTERFACE_MAP_ENTRY(nsIDOMEventReceiver) + NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget) NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget) NS_INTERFACE_MAP_ENTRY(nsIDOM3EventTarget) NS_INTERFACE_MAP_ENTRY(nsIDOMNSEventTarget) @@ -1810,7 +1811,9 @@ nsGlobalWindow::SetDocShell(nsIDocShell* aDocShell) // Get our enclosing chrome shell and retrieve its global window impl, so // that we can do some forwarding to the chrome document. - mDocShell->GetChromeEventHandler(getter_AddRefs(mChromeEventHandler)); + nsCOMPtr chromeEventHandler; + mDocShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler)); + mChromeEventHandler = do_QueryInterface(chromeEventHandler); if (!mChromeEventHandler) { // We have no chrome event handler. If we have a parent, // get our chrome event handler from the parent. If @@ -1895,11 +1898,7 @@ nsGlobalWindow::PreHandleEvent(nsEventChainPreVisitor& aVisitor) mIsHandlingResizeEvent = PR_TRUE; } - // Check chrome document capture here. - if (mChromeEventHandler) { - aVisitor.mParentTarget = mChromeEventHandler; - aVisitor.mParentIsChromeHandler = PR_TRUE; - } + aVisitor.mParentTarget = mChromeEventHandler; return NS_OK; } @@ -1910,7 +1909,7 @@ nsGlobalWindow::PostHandleEvent(nsEventChainPostVisitor& aVisitor) /* mChromeEventHandler and mContext go dangling in the middle of this function under some circumstances (events that destroy the window) without this addref. */ - nsCOMPtr kungFuDeathGrip1(mChromeEventHandler); + nsCOMPtr kungFuDeathGrip1(mChromeEventHandler); nsCOMPtr kungFuDeathGrip2(GetContextInternal()); nsGlobalWindow* outer = GetOuterWindowInternal(); @@ -4072,7 +4071,7 @@ nsGlobalWindow::GetWindowRoot(nsIDOMEventTarget **aWindowRoot) return NS_OK; } - nsIChromeEventHandler *chromeHandler = piWin->GetChromeEventHandler(); + nsPIDOMEventTarget *chromeHandler = piWin->GetChromeEventHandler(); if (!chromeHandler) { return NS_OK; } @@ -5623,7 +5622,7 @@ nsGlobalWindow::GetPrivateRoot() // Get the chrome event handler from the doc shell, since we only // want to deal with XUL chrome handlers and not the new kind of // window root handler. - nsCOMPtr chromeEventHandler; + nsCOMPtr chromeEventHandler; docShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler)); nsCOMPtr chromeElement(do_QueryInterface(mChromeEventHandler)); @@ -5721,18 +5720,16 @@ nsGlobalWindow::Deactivate() nsIFocusController* nsGlobalWindow::GetRootFocusController() { - nsIDOMWindowInternal *rootWindow = nsGlobalWindow::GetPrivateRoot(); + nsIDOMWindowInternal* rootWindow = nsGlobalWindow::GetPrivateRoot(); nsCOMPtr fc; - if (rootWindow) { + nsCOMPtr piWin(do_QueryInterface(rootWindow)); + if (piWin) { // Obtain the chrome event handler. - nsCOMPtr piWin(do_QueryInterface(rootWindow)); - nsIChromeEventHandler *chromeHandler = piWin->GetChromeEventHandler(); - if (chromeHandler) { - nsCOMPtr windowRoot(do_QueryInterface(chromeHandler)); - if (windowRoot) { - windowRoot->GetFocusController(getter_AddRefs(fc)); - } + nsPIDOMEventTarget* chromeHandler = piWin->GetChromeEventHandler(); + nsCOMPtr windowRoot(do_QueryInterface(chromeHandler)); + if (windowRoot) { + windowRoot->GetFocusController(getter_AddRefs(fc)); } } diff --git a/mozilla/dom/src/base/nsGlobalWindow.h b/mozilla/dom/src/base/nsGlobalWindow.h index 9fde02452b1..fb585dad740 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.h +++ b/mozilla/dom/src/base/nsGlobalWindow.h @@ -56,7 +56,6 @@ #include "nsDOMWindowList.h" #include "nsIBaseWindow.h" #include "nsIBrowserDOMWindow.h" -#include "nsIChromeEventHandler.h" #include "nsIControllers.h" #include "nsIDocShellTreeOwner.h" #include "nsIDocShellTreeItem.h" @@ -95,6 +94,7 @@ #include "nsIDOMStorage.h" #include "nsIDOMStorageList.h" #include "nsIDOMStorageWindow.h" +#include "nsPIDOMEventTarget.h" #define DEFAULT_HOME_PAGE "www.mozilla.org" #define PREF_BROWSER_STARTUP_HOMEPAGE "browser.startup.homepage" @@ -217,6 +217,7 @@ class nsGlobalWindow : public nsPIDOMWindow, public nsIDOMJSWindow, public nsIScriptObjectPrincipal, public nsIDOMEventReceiver, + public nsPIDOMEventTarget, public nsIDOM3EventTarget, public nsIDOMNSEventTarget, public nsIDOMViewCSS, diff --git a/mozilla/dom/src/base/nsWindowRoot.cpp b/mozilla/dom/src/base/nsWindowRoot.cpp index ebab1f137a6..9e889abd142 100644 --- a/mozilla/dom/src/base/nsWindowRoot.cpp +++ b/mozilla/dom/src/base/nsWindowRoot.cpp @@ -86,7 +86,7 @@ NS_IMPL_CYCLE_COLLECTION_2_AMBIGUOUS(nsWindowRoot, nsIDOMEventReceiver, NS_INTERFACE_MAP_BEGIN(nsWindowRoot) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMEventReceiver) NS_INTERFACE_MAP_ENTRY(nsIDOMEventReceiver) - NS_INTERFACE_MAP_ENTRY(nsIChromeEventHandler) + NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget) NS_INTERFACE_MAP_ENTRY(nsPIWindowRoot) NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget) NS_INTERFACE_MAP_ENTRY(nsIDOM3EventTarget) @@ -114,11 +114,22 @@ nsWindowRoot::DispatchEvent(nsIDOMEvent* aEvt, PRBool *_retval) { nsEventStatus status = nsEventStatus_eIgnore; nsresult rv = nsEventDispatcher::DispatchDOMEvent( - NS_STATIC_CAST(nsIChromeEventHandler*, this), nsnull, aEvt, nsnull, &status); + NS_STATIC_CAST(nsPIDOMEventTarget*, this), nsnull, aEvt, nsnull, &status); *_retval = (status != nsEventStatus_eConsumeNoDefault); return rv; } +nsresult +nsWindowRoot::DispatchDOMEvent(nsEvent* aEvent, + nsIDOMEvent* aDOMEvent, + nsPresContext* aPresContext, + nsEventStatus* aEventStatus) +{ + return nsEventDispatcher::DispatchDOMEvent(NS_STATIC_CAST(nsPIDOMEventTarget*, this), + aEvent, aDOMEvent, + aPresContext, aEventStatus); +} + NS_IMETHODIMP nsWindowRoot::AddGroupedEventListener(const nsAString & aType, nsIDOMEventListener *aListener, PRBool aUseCapture, nsIDOMEventGroup *aEvtGrp) @@ -240,7 +251,7 @@ nsWindowRoot::GetSystemEventGroup(nsIDOMEventGroup **aGroup) NS_IMETHODIMP -nsWindowRoot::PreHandleChromeEvent(nsEventChainPreVisitor& aVisitor) +nsWindowRoot::PreHandleEvent(nsEventChainPreVisitor& aVisitor) { aVisitor.mCanHandle = PR_TRUE; aVisitor.mForceContentDispatch = PR_TRUE; //FIXME! Bug 329119 @@ -250,7 +261,7 @@ nsWindowRoot::PreHandleChromeEvent(nsEventChainPreVisitor& aVisitor) } NS_IMETHODIMP -nsWindowRoot::PostHandleChromeEvent(nsEventChainPostVisitor& aVisitor) +nsWindowRoot::PostHandleEvent(nsEventChainPostVisitor& aVisitor) { return NS_OK; } @@ -280,7 +291,7 @@ nsWindowRoot::SetScriptTypeID(PRUint32 aScriptType) /////////////////////////////////////////////////////////////////////////////////// nsresult -NS_NewWindowRoot(nsIDOMWindow* aWindow, nsIChromeEventHandler** aResult) +NS_NewWindowRoot(nsIDOMWindow* aWindow, nsPIDOMEventTarget** aResult) { *aResult = new nsWindowRoot(aWindow); if (!*aResult) diff --git a/mozilla/dom/src/base/nsWindowRoot.h b/mozilla/dom/src/base/nsWindowRoot.h index 3ce17d9211c..715e28eea42 100644 --- a/mozilla/dom/src/base/nsWindowRoot.h +++ b/mozilla/dom/src/base/nsWindowRoot.h @@ -50,7 +50,6 @@ class nsEventChainPostVisitor; #include "nsIDOMEventReceiver.h" #include "nsIDOM3EventTarget.h" #include "nsIDOMNSEventTarget.h" -#include "nsIChromeEventHandler.h" #include "nsIEventListenerManager.h" #include "nsPIWindowRoot.h" #include "nsIFocusController.h" @@ -60,7 +59,6 @@ class nsEventChainPostVisitor; class nsWindowRoot : public nsIDOMEventReceiver, public nsIDOM3EventTarget, public nsIDOMNSEventTarget, - public nsIChromeEventHandler, public nsPIWindowRoot { public: @@ -71,7 +69,13 @@ public: NS_DECL_NSIDOMEVENTTARGET NS_DECL_NSIDOM3EVENTTARGET NS_DECL_NSIDOMNSEVENTTARGET - NS_DECL_NSICHROMEEVENTHANDLER + + virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor); + virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor); + virtual nsresult DispatchDOMEvent(nsEvent* aEvent, + nsIDOMEvent* aDOMEvent, + nsPresContext* aPresContext, + nsEventStatus* aEventStatus); // nsIDOMEventReceiver NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID); @@ -96,6 +100,6 @@ protected: extern nsresult NS_NewWindowRoot(nsIDOMWindow* aWindow, - nsIChromeEventHandler** aResult); + nsPIDOMEventTarget** aResult); #endif diff --git a/mozilla/embedding/browser/cocoa/src/CHBrowserView.mm b/mozilla/embedding/browser/cocoa/src/CHBrowserView.mm index 1d39ff05876..5c8c5829b58 100644 --- a/mozilla/embedding/browser/cocoa/src/CHBrowserView.mm +++ b/mozilla/embedding/browser/cocoa/src/CHBrowserView.mm @@ -46,7 +46,6 @@ #include "nsIURI.h" #include "nsIDOMWindow.h" #include "nsPIDOMWindow.h" -#include "nsIChromeEventHandler.h" #include "nsIDOMEventReceiver.h" #include "nsIWidget.h" diff --git a/mozilla/embedding/browser/gtk/src/EmbedPrivate.cpp b/mozilla/embedding/browser/gtk/src/EmbedPrivate.cpp index a0426ad186f..370531d333a 100644 --- a/mozilla/embedding/browser/gtk/src/EmbedPrivate.cpp +++ b/mozilla/embedding/browser/gtk/src/EmbedPrivate.cpp @@ -64,7 +64,6 @@ #include "nsIDOMWindow.h" #include "nsPIDOMWindow.h" #include "nsIDOMWindowInternal.h" -#include "nsIChromeEventHandler.h" // For seting scrollbar visibilty #include "nsIDOMBarProp.h" diff --git a/mozilla/embedding/browser/photon/src/EmbedPrivate.cpp b/mozilla/embedding/browser/photon/src/EmbedPrivate.cpp index a0b6cd488e7..c0c11eb4409 100644 --- a/mozilla/embedding/browser/photon/src/EmbedPrivate.cpp +++ b/mozilla/embedding/browser/photon/src/EmbedPrivate.cpp @@ -67,7 +67,6 @@ #include #include #include -#include #include #include #include diff --git a/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp index af85882d0ad..e31c6dc4c81 100644 --- a/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp +++ b/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp @@ -116,10 +116,9 @@ GetEventReceiver ( nsWebBrowser* inBrowser, nsIDOMEventReceiver** outEventRcvr ) NS_ENSURE_TRUE(domWindowPrivate, NS_ERROR_FAILURE); nsPIDOMWindow *rootWindow = domWindowPrivate->GetPrivateRoot(); NS_ENSURE_TRUE(rootWindow, NS_ERROR_FAILURE); - nsIChromeEventHandler *chromeHandler = rootWindow->GetChromeEventHandler(); - NS_ENSURE_TRUE(chromeHandler, NS_ERROR_FAILURE); - - nsCOMPtr rcvr = do_QueryInterface(chromeHandler); + nsCOMPtr rcvr = + do_QueryInterface(rootWindow->GetChromeEventHandler()); + NS_ENSURE_TRUE(rcvr, NS_ERROR_FAILURE); *outEventRcvr = rcvr; NS_IF_ADDREF(*outEventRcvr); diff --git a/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.h b/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.h index 435159cacc8..009ab5e55ce 100644 --- a/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.h +++ b/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.h @@ -52,7 +52,6 @@ #include "nsIWebBrowserChrome.h" #include "nsIDOMMouseListener.h" #include "nsIDOMDocument.h" -#include "nsIChromeEventHandler.h" #include "nsIDOMEventReceiver.h" #include "nsIEmbeddingSiteWindow.h" #include "nsIWebProgressListener.h" diff --git a/mozilla/embedding/components/commandhandler/src/Makefile.in b/mozilla/embedding/components/commandhandler/src/Makefile.in index 98fe17626f0..aeb13f1fe8e 100644 --- a/mozilla/embedding/components/commandhandler/src/Makefile.in +++ b/mozilla/embedding/components/commandhandler/src/Makefile.in @@ -46,6 +46,7 @@ MODULE = commandhandler REQUIRES = string \ xpcom \ dom \ + content \ widget \ necko \ xuldoc \ diff --git a/mozilla/extensions/spatialnavigation/src/nsSpatialNavigationPrivate.h b/mozilla/extensions/spatialnavigation/src/nsSpatialNavigationPrivate.h index fa86921d61c..0400ac49dd6 100755 --- a/mozilla/extensions/spatialnavigation/src/nsSpatialNavigationPrivate.h +++ b/mozilla/extensions/spatialnavigation/src/nsSpatialNavigationPrivate.h @@ -52,7 +52,6 @@ #include "nsIArray.h" #include "nsIBaseWindow.h" #include "nsICategoryManager.h" -#include "nsIChromeEventHandler.h" #include "nsIComponentManager.h" #include "nsIDOM3EventTarget.h" #include "nsIDOMAbstractView.h" diff --git a/mozilla/extensions/spatialnavigation/src/nsSpatialNavigationUtils.cpp b/mozilla/extensions/spatialnavigation/src/nsSpatialNavigationUtils.cpp index f34558d36f1..a21dd40b0e5 100755 --- a/mozilla/extensions/spatialnavigation/src/nsSpatialNavigationUtils.cpp +++ b/mozilla/extensions/spatialnavigation/src/nsSpatialNavigationUtils.cpp @@ -251,7 +251,7 @@ nsresult getEventTargetFromWindow(nsIDOMWindow* aWindow, nsIDOM3EventTarget** aE if (!privateWindow) return NS_ERROR_UNEXPECTED; // assert - nsIChromeEventHandler *chromeEventHandler = privateWindow->GetChromeEventHandler(); + nsPIDOMEventTarget *chromeEventHandler = privateWindow->GetChromeEventHandler(); nsCOMPtr receiver(do_QueryInterface(chromeEventHandler)); if (!receiver) diff --git a/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp b/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp index 994ee2d0c7c..3751d508968 100644 --- a/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp +++ b/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp @@ -52,7 +52,6 @@ #include "nsPIDOMWindow.h" #include "nsIDOMEventTarget.h" #include "nsIDOMNSUIEvent.h" -#include "nsIChromeEventHandler.h" #include "nsIDOMNSEvent.h" #include "nsIPrefBranch.h" #include "nsIPrefBranch2.h" @@ -2377,7 +2376,7 @@ nsTypeAheadFind::GetChromeEventHandler(nsIDOMWindow *aDOMWin, nsIDOMEventTarget **aChromeTarget) { nsCOMPtr privateDOMWindow(do_QueryInterface(aDOMWin)); - nsIChromeEventHandler *chromeEventHandler = nsnull; + nsPIDOMEventTarget* chromeEventHandler = nsnull; if (privateDOMWindow) { chromeEventHandler = privateDOMWindow->GetChromeEventHandler(); } diff --git a/mozilla/layout/base/Makefile.in b/mozilla/layout/base/Makefile.in index 8a9a9515b91..51de490803c 100644 --- a/mozilla/layout/base/Makefile.in +++ b/mozilla/layout/base/Makefile.in @@ -81,7 +81,6 @@ REQUIRES += thebes cairo endif XPIDLSRCS = \ - nsIChromeEventHandler.idl \ nsIStyleSheetService.idl \ $(NULL) diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index 553a7fe5e7e..afdf214f48b 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -86,7 +86,6 @@ #include "nsIPageSequenceFrame.h" #include "nsIURL.h" #include "nsNetUtil.h" -#include "nsIChromeEventHandler.h" #include "nsIContentViewerEdit.h" #include "nsIContentViewerFile.h" #include "nsICSSLoader.h" @@ -2203,7 +2202,7 @@ DocumentViewerImpl::CreateStyleSet(nsIDocument* aDocument, // Append chrome sheets (scrollbars + forms). PRBool shouldOverride = PR_FALSE; nsCOMPtr ds(do_QueryInterface(docShell)); - nsCOMPtr chromeHandler; + nsCOMPtr chromeHandler; nsCOMPtr uri; nsCOMPtr csssheet; diff --git a/mozilla/layout/base/nsIChromeEventHandler.idl b/mozilla/layout/base/nsIChromeEventHandler.idl deleted file mode 100644 index d8681a58f0f..00000000000 --- a/mozilla/layout/base/nsIChromeEventHandler.idl +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: IDL; tab-width: 4; 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 the Mozilla browser. - * - * The Initial Developer of the Original Code is - * Netscape Communications, Inc. - * Portions created by the Initial Developer are Copyright (C) 1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Travis Bogard - * Olli Pettay - * - * 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 ***** */ - -#include "nsISupports.idl" - -%{ C++ -class nsEventChainPreVisitor; -class nsEventChainPostVisitor; -%} - -[ref] native nsEventChainPreVisitorRef(nsEventChainPreVisitor); -[ref] native nsEventChainPostVisitorRef(nsEventChainPostVisitor); - -interface nsIDOMEvent; - -/** - * The nsIChromeEventHandler - */ - -[scriptable, uuid(a54dc626-9648-406b-bc82-b5c51b3767d7)] -interface nsIChromeEventHandler : nsISupports -{ - /** - * Called before the capture phase of the event flow. - * This is used to create the event target chain and implementations - * should set the necessary members of nsEventChainPreVisitor. - * At least aVisitor.mCanHandle must be set, - * usually also aVisitor.mParentTarget if mCanHandle is PR_TRUE. - * First one tells that this object can handle the aVisitor.mEvent event and - * the latter one is the possible parent object for the event target chain. - * @see nsEventDispatcher.h for more documentation about aVisitor. - * - * @param aVisitor the visitor object which is used to create the - * event target chain for event dispatching. - * - * @note Only nsEventDispatcher should call this method. - */ - [noscript] void PreHandleChromeEvent(in nsEventChainPreVisitorRef aVisitor); - - /** - * Called after the bubble phase of the system event group. - * The default handling of the event should happen here. - * @param aVisitor the visitor object which is used during post handling. - * - * @see nsEventDispatcher.h for documentation about aVisitor. - * @note Only nsEventDispatcher should call this method. - */ - [noscript] void PostHandleChromeEvent(in nsEventChainPostVisitorRef aVisitor); -}; diff --git a/mozilla/toolkit/components/remote/Makefile.in b/mozilla/toolkit/components/remote/Makefile.in index 9ac37fed067..e099853b93e 100644 --- a/mozilla/toolkit/components/remote/Makefile.in +++ b/mozilla/toolkit/components/remote/Makefile.in @@ -62,6 +62,7 @@ REQUIRES = \ widget \ gfx \ dom \ + content \ layout \ docshell \ $(NULL) diff --git a/mozilla/toolkit/components/satchel/src/nsFormFillController.cpp b/mozilla/toolkit/components/satchel/src/nsFormFillController.cpp index 9362702a836..4420d8b5bfa 100644 --- a/mozilla/toolkit/components/satchel/src/nsFormFillController.cpp +++ b/mozilla/toolkit/components/satchel/src/nsFormFillController.cpp @@ -52,7 +52,6 @@ #include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestorUtils.h" #include "nsIDocShellTreeItem.h" -#include "nsIChromeEventHandler.h" #include "nsPIDOMWindow.h" #include "nsIWebNavigation.h" #include "nsIContentViewer.h" @@ -905,7 +904,7 @@ nsFormFillController::AddWindowListeners(nsIDOMWindow *aWindow) return; nsCOMPtr privateDOMWindow(do_QueryInterface(aWindow)); - nsIChromeEventHandler* chromeEventHandler = nsnull; + nsPIDOMEventTarget* chromeEventHandler = nsnull; if (privateDOMWindow) chromeEventHandler = privateDOMWindow->GetChromeEventHandler(); @@ -964,7 +963,7 @@ nsFormFillController::RemoveWindowListeners(nsIDOMWindow *aWindow) StopControllingInput(); nsCOMPtr privateDOMWindow(do_QueryInterface(aWindow)); - nsIChromeEventHandler* chromeEventHandler = nsnull; + nsPIDOMEventTarget* chromeEventHandler = nsnull; if (privateDOMWindow) chromeEventHandler = privateDOMWindow->GetChromeEventHandler(); diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index 87f5ce021d0..31bce02e35b 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -778,8 +778,9 @@ PRBool nsWebShellWindow::ExecuteCloseHandler() nsCOMPtr kungFuDeathGrip(this); nsCOMPtr window(do_GetInterface(mDocShell)); + nsCOMPtr eventTarget = do_QueryInterface(window); - if (window) { + if (eventTarget) { nsCOMPtr contentViewer; mDocShell->GetContentViewer(getter_AddRefs(contentViewer)); nsCOMPtr docViewer(do_QueryInterface(contentViewer)); @@ -793,7 +794,7 @@ PRBool nsWebShellWindow::ExecuteCloseHandler() nsMouseEvent::eReal); nsresult rv = - window->DispatchDOMEvent(&event, nsnull, presContext, &status); + eventTarget->DispatchDOMEvent(&event, nsnull, presContext, &status); if (NS_SUCCEEDED(rv) && status == nsEventStatus_eConsumeNoDefault) return PR_TRUE; // else fall through and return PR_FALSE diff --git a/mozilla/xpfe/browser/src/Makefile.in b/mozilla/xpfe/browser/src/Makefile.in index 97a130a36f8..b629aa70562 100644 --- a/mozilla/xpfe/browser/src/Makefile.in +++ b/mozilla/xpfe/browser/src/Makefile.in @@ -57,6 +57,7 @@ REQUIRES = xpcom \ appshell \ appcomps \ dom \ + content \ layout \ js \ uriloader \