author | Masayuki Nakano <masayuki@d-toybox.com> |
Mon, 17 Mar 2014 15:56:54 +0900 | |
changeset 173867 | db2c6e0b798efe86895743f5e476bea406e1036a |
parent 173866 | f3f677c84bf2b44c441fa9bfaf16dbcc6a0eec8c |
child 173870 | 28a725269bfa2e32c029fe9c3d4eca20292f6793 |
child 173922 | 73f9b143169e59457eb0ec3bd4c1d4bcc6aec8c5 |
push id | 26427 |
push user | cbook@mozilla.com |
push date | Mon, 17 Mar 2014 11:34:18 +0000 |
treeherder | mozilla-central@db2c6e0b798e [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | smaug |
bugs | 982602 |
milestone | 30.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
|
--- a/content/base/src/Attr.cpp +++ b/content/base/src/Attr.cpp @@ -20,17 +20,16 @@ #include "nsIDOMUserDataHandler.h" #include "nsEventDispatcher.h" #include "nsGkAtoms.h" #include "nsCOMArray.h" #include "nsNameSpaceManager.h" #include "nsNodeUtils.h" #include "nsTextNode.h" #include "mozAutoDocUpdate.h" -#include "nsAsyncDOMEvent.h" #include "nsWrapperCacheInlines.h" nsIAttribute::nsIAttribute(nsDOMAttributeMap* aAttrMap, already_AddRefed<nsINodeInfo>& aNodeInfo, bool aNsAware) : nsINode(aNodeInfo), mAttrMap(aAttrMap), mNsAware(aNsAware) { }
--- a/content/base/src/Element.cpp +++ b/content/base/src/Element.cpp @@ -43,16 +43,17 @@ #include "nsNameSpaceManager.h" #include "nsContentList.h" #include "nsDOMTokenList.h" #include "nsXBLPrototypeBinding.h" #include "nsError.h" #include "nsDOMString.h" #include "nsIScriptSecurityManager.h" #include "nsIDOMMutationEvent.h" +#include "mozilla/AsyncEventDispatcher.h" #include "mozilla/ContentEvents.h" #include "mozilla/EventListenerManager.h" #include "mozilla/InternalMutationEvent.h" #include "mozilla/MouseEvents.h" #include "mozilla/TextEvents.h" #include "nsNodeUtils.h" #include "mozilla/dom/DirectionalityUtils.h" #include "nsDocument.h" @@ -94,17 +95,16 @@ #include "nsContentCreatorFunctions.h" #include "nsIControllers.h" #include "nsView.h" #include "nsViewManager.h" #include "nsIScrollableFrame.h" #include "mozilla/css/StyleRule.h" /* For nsCSSSelectorList */ #include "nsCSSRuleProcessor.h" #include "nsRuleProcessorData.h" -#include "nsAsyncDOMEvent.h" #include "nsTextNode.h" #ifdef MOZ_XUL #include "nsIXULDocument.h" #endif /* MOZ_XUL */ #include "nsCycleCollectionParticipant.h" #include "nsCCUncollectableMarker.h" @@ -1941,17 +1941,17 @@ Element::SetAttrAndNotify(int32_t aNames mutation.mNewAttrValue = do_GetAtom(newValue); } if (!aOldValue.IsEmptyString()) { mutation.mPrevAttrValue = aOldValue.GetAsAtom(); } mutation.mAttrChange = aModType; mozAutoSubtreeModified subtree(OwnerDoc(), this); - (new nsAsyncDOMEvent(this, mutation))->RunDOMEventWhenSafe(); + (new AsyncEventDispatcher(this, mutation))->RunDOMEventWhenSafe(); } return NS_OK; } bool Element::ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute, @@ -2126,17 +2126,17 @@ Element::UnsetAttr(int32_t aNameSpaceID, nsAutoString value; oldValue.ToString(value); if (!value.IsEmpty()) mutation.mPrevAttrValue = do_GetAtom(value); mutation.mAttrChange = nsIDOMMutationEvent::REMOVAL; mozAutoSubtreeModified subtree(OwnerDoc(), this); - (new nsAsyncDOMEvent(this, mutation))->RunDOMEventWhenSafe(); + (new AsyncEventDispatcher(this, mutation))->RunDOMEventWhenSafe(); } return NS_OK; } const nsAttrName* Element::GetAttrNameAt(uint32_t aIndex) const { @@ -2613,22 +2613,22 @@ Element::MozRequestFullScreen() // Note that requests for fullscreen inside a web app's origin are exempt // from this restriction. const char* error = GetFullScreenError(OwnerDoc()); if (error) { nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, NS_LITERAL_CSTRING("DOM"), OwnerDoc(), nsContentUtils::eDOM_PROPERTIES, error); - nsRefPtr<nsAsyncDOMEvent> e = - new nsAsyncDOMEvent(OwnerDoc(), - NS_LITERAL_STRING("mozfullscreenerror"), - true, - false); - e->PostDOMEvent(); + nsRefPtr<AsyncEventDispatcher> asyncDispatcher = + new AsyncEventDispatcher(OwnerDoc(), + NS_LITERAL_STRING("mozfullscreenerror"), + true, + false); + asyncDispatcher->PostDOMEvent(); return; } OwnerDoc()->AsyncRequestFullScreen(this); return; }
--- a/content/base/src/FragmentOrElement.cpp +++ b/content/base/src/FragmentOrElement.cpp @@ -12,16 +12,17 @@ #include "mozilla/ArrayUtils.h" #include "mozilla/Likely.h" #include "mozilla/MemoryReporting.h" #include "mozilla/StaticPtr.h" #include "mozilla/dom/FragmentOrElement.h" +#include "mozilla/AsyncEventDispatcher.h" #include "mozilla/EventListenerManager.h" #include "mozilla/dom/Attr.h" #include "nsDOMAttributeMap.h" #include "nsIAtom.h" #include "nsINodeInfo.h" #include "nsIDocumentInlines.h" #include "nsIDocumentEncoder.h" #include "nsIDOMNodeList.h" @@ -94,17 +95,16 @@ #include "nsContentCreatorFunctions.h" #include "nsIControllers.h" #include "nsView.h" #include "nsViewManager.h" #include "nsIScrollableFrame.h" #include "ChildIterator.h" #include "mozilla/css/StyleRule.h" /* For nsCSSSelectorList */ #include "nsRuleProcessorData.h" -#include "nsAsyncDOMEvent.h" #include "nsTextNode.h" #include "mozilla/dom/NodeListBinding.h" #include "mozilla/dom/UndoManager.h" #ifdef MOZ_XUL #include "nsIXULDocument.h" #endif /* MOZ_XUL */ @@ -1118,17 +1118,17 @@ FragmentOrElement::FireNodeInserted(nsID nsIContent* childContent = aNodes[i]; if (nsContentUtils::HasMutationListeners(childContent, NS_EVENT_BITS_MUTATION_NODEINSERTED, aParent)) { InternalMutationEvent mutation(true, NS_MUTATION_NODEINSERTED); mutation.mRelatedNode = do_QueryInterface(aParent); mozAutoSubtreeModified subtree(aDoc, aParent); - (new nsAsyncDOMEvent(childContent, mutation))->RunDOMEventWhenSafe(); + (new AsyncEventDispatcher(childContent, mutation))->RunDOMEventWhenSafe(); } } } //---------------------------------------------------------------------- // nsISupports implementation
--- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -35,19 +35,19 @@ #include "mozilla/css/Loader.h" #include "mozilla/css/ImageLoader.h" #include "nsDocShell.h" #include "nsIDocShellTreeItem.h" #include "nsCOMArray.h" #include "nsDOMClassInfo.h" #include "nsCxPusher.h" +#include "mozilla/AsyncEventDispatcher.h" #include "mozilla/BasicEvents.h" #include "mozilla/EventListenerManager.h" -#include "nsAsyncDOMEvent.h" #include "nsIDOMNodeFilter.h" #include "nsIDOMStyleSheet.h" #include "mozilla/dom/Attr.h" #include "nsIDOMDOMImplementation.h" #include "nsIDOMDocumentXBL.h" #include "mozilla/dom/Element.h" #include "nsGenericHTMLElement.h" @@ -3976,19 +3976,20 @@ nsDocument::AddStyleSheetToStyleSets(nsI return; \ } \ nsCOMPtr<concreteInterface> ssEvent(do_QueryInterface(event)); \ MOZ_ASSERT(ssEvent); \ ssEvent->initMethod(NS_LITERAL_STRING(type), true, true, \ cssSheet, __VA_ARGS__); \ event->SetTrusted(true); \ event->SetTarget(this); \ - nsRefPtr<nsAsyncDOMEvent> asyncEvent = new nsAsyncDOMEvent(this, event); \ - asyncEvent->mDispatchChromeOnly = true; \ - asyncEvent->PostDOMEvent(); \ + nsRefPtr<AsyncEventDispatcher> asyncDispatcher = \ + new AsyncEventDispatcher(this, event); \ + asyncDispatcher->mDispatchChromeOnly = true; \ + asyncDispatcher->PostDOMEvent(); \ } while (0); void nsDocument::NotifyStyleSheetAdded(nsIStyleSheet* aSheet, bool aDocumentSheet) { NS_DOCUMENT_NOTIFY_OBSERVERS(StyleSheetAdded, (this, aSheet, aDocumentSheet)); if (StyleSheetChangeEventsEnabled()) { @@ -8562,22 +8563,22 @@ nsDocument::UnblockOnload(bool aFireSync } } else if (mIsBeingUsedAsImage) { // To correctly unblock onload for a document that contains an SVG // image, we need to know when all of the SVG document's resources are // done loading, in a way comparable to |window.onload|. We fire this // event to indicate that the SVG should be considered fully loaded. // Because scripting is disabled on SVG-as-image documents, this event // is not accessible to content authors. (See bug 837135.) - nsRefPtr<nsAsyncDOMEvent> e = - new nsAsyncDOMEvent(this, - NS_LITERAL_STRING("MozSVGAsImageDocumentLoad"), - false, - false); - e->PostDOMEvent(); + nsRefPtr<AsyncEventDispatcher> asyncDispatcher = + new AsyncEventDispatcher(this, + NS_LITERAL_STRING("MozSVGAsImageDocumentLoad"), + false, + false); + asyncDispatcher->PostDOMEvent(); } } } class nsUnblockOnloadEvent : public nsRunnable { public: nsUnblockOnloadEvent(nsDocument *doc) : mDoc(doc) {} NS_IMETHOD Run() { @@ -8745,22 +8746,22 @@ NotifyPageHide(nsIDocument* aDocument, v const bool* aPersistedPtr = static_cast<const bool*>(aData); aDocument->OnPageHide(*aPersistedPtr, nullptr); return true; } static void DispatchFullScreenChange(nsIDocument* aTarget) { - nsRefPtr<nsAsyncDOMEvent> e = - new nsAsyncDOMEvent(aTarget, - NS_LITERAL_STRING("mozfullscreenchange"), - true, - false); - e->PostDOMEvent(); + nsRefPtr<AsyncEventDispatcher> asyncDispatcher = + new AsyncEventDispatcher(aTarget, + NS_LITERAL_STRING("mozfullscreenchange"), + true, + false); + asyncDispatcher->PostDOMEvent(); } void nsDocument::OnPageHide(bool aPersisted, EventTarget* aDispatchStartTarget) { // Send out notifications that our <link> elements are detached, // but only if this is not a full unload. @@ -8903,17 +8904,18 @@ nsDocument::MutationEventDispatched(nsIN } } mSubtreeModifiedTargets.Clear(); int32_t realTargetCount = realTargets.Count(); for (int32_t k = 0; k < realTargetCount; ++k) { InternalMutationEvent mutation(true, NS_MUTATION_SUBTREEMODIFIED); - (new nsAsyncDOMEvent(realTargets[k], mutation))->RunDOMEventWhenSafe(); + (new AsyncEventDispatcher(realTargets[k], mutation))-> + RunDOMEventWhenSafe(); } } } void nsDocument::AddStyleRelevantLink(Link* aLink) { NS_ASSERTION(aLink, "Passing in a null link. Expect crashes RSN!"); @@ -9066,21 +9068,20 @@ nsDocument::SetReadyStateInternal(ReadyS break; } } // At the time of loading start, we don't have timing object, record time. if (READYSTATE_LOADING == rs) { mLoadingTimeStamp = mozilla::TimeStamp::Now(); } - nsRefPtr<nsAsyncDOMEvent> plevent = - new nsAsyncDOMEvent(this, NS_LITERAL_STRING("readystatechange"), false, false); - if (plevent) { - plevent->RunDOMEventWhenSafe(); - } + nsRefPtr<AsyncEventDispatcher> asyncDispatcher = + new AsyncEventDispatcher(this, NS_LITERAL_STRING("readystatechange"), + false, false); + asyncDispatcher->RunDOMEventWhenSafe(); } NS_IMETHODIMP nsDocument::GetReadyState(nsAString& aReadyState) { nsIDocument::GetReadyState(aReadyState); return NS_OK; } @@ -10666,22 +10667,22 @@ nsDocument::RestorePreviousFullScreenSta if (fullScreenDoc != doc) { // We've popped so enough off the stack that we've rolled back to // a fullscreen element in a parent document. If this document isn't // approved for fullscreen, or if it's cross origin, dispatch an // event to chrome so it knows to show the authorization/warning UI. if (!nsContentUtils::HaveEqualPrincipals(fullScreenDoc, doc) || (!nsContentUtils::IsSitePermAllow(doc->NodePrincipal(), "fullscreen") && !static_cast<nsDocument*>(doc)->mIsApprovedForFullscreen)) { - nsRefPtr<nsAsyncDOMEvent> e = - new nsAsyncDOMEvent(doc, - NS_LITERAL_STRING("MozEnteredDomFullscreen"), - true, - true); - e->PostDOMEvent(); + nsRefPtr<AsyncEventDispatcher> asyncDispatcher = + new AsyncEventDispatcher(doc, + NS_LITERAL_STRING("MozEnteredDomFullscreen"), + true, + true); + asyncDispatcher->PostDOMEvent(); } } if (!nsContentUtils::HaveEqualPrincipals(doc, fullScreenDoc)) { // The origin which is fullscreen changed. Send a notification to // the root process so that a warning or approval UI can be shown // as necessary. nsAutoString origin; @@ -10755,22 +10756,22 @@ nsDocument::AsyncRequestFullScreen(Eleme } static void LogFullScreenDenied(bool aLogFailure, const char* aMessage, nsIDocument* aDoc) { if (!aLogFailure) { return; } - nsRefPtr<nsAsyncDOMEvent> e = - new nsAsyncDOMEvent(aDoc, - NS_LITERAL_STRING("mozfullscreenerror"), - true, - false); - e->PostDOMEvent(); + nsRefPtr<AsyncEventDispatcher> asyncDispatcher = + new AsyncEventDispatcher(aDoc, + NS_LITERAL_STRING("mozfullscreenerror"), + true, + false); + asyncDispatcher->PostDOMEvent(); nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, NS_LITERAL_CSTRING("DOM"), aDoc, nsContentUtils::eDOM_PROPERTIES, aMessage); } nsresult nsDocument::AddFullscreenApprovedObserver() @@ -11116,22 +11117,22 @@ nsDocument::RequestFullScreen(Element* a // If this document, or a document with the same principal has not // already been approved for fullscreen this fullscreen-session, dispatch // an event so that chrome knows to pop up a warning/approval UI. // Note previousFullscreenDoc=nullptr upon first entry, so we always // take this path on the first time we enter fullscreen in a fullscreen // session. if (!mIsApprovedForFullscreen || !nsContentUtils::HaveEqualPrincipals(previousFullscreenDoc, this)) { - nsRefPtr<nsAsyncDOMEvent> e = - new nsAsyncDOMEvent(this, - NS_LITERAL_STRING("MozEnteredDomFullscreen"), - true, - true); - e->PostDOMEvent(); + nsRefPtr<AsyncEventDispatcher> asyncDispatcher = + new AsyncEventDispatcher(this, + NS_LITERAL_STRING("MozEnteredDomFullscreen"), + true, + true); + asyncDispatcher->PostDOMEvent(); } #ifdef DEBUG // Note assertions must run before SetWindowFullScreen() as that does // synchronous event dispatch which can run script which exits full-screen! NS_ASSERTION(GetFullScreenElement() == aElement, "Full-screen element should be the requested element!"); NS_ASSERTION(IsFullScreenDoc(), "Should be full-screen doc"); @@ -11273,37 +11274,37 @@ nsDocument::IsFullScreenEnabled(bool aCa static void DispatchPointerLockChange(nsIDocument* aTarget) { if (!aTarget) { return; } - nsRefPtr<nsAsyncDOMEvent> e = - new nsAsyncDOMEvent(aTarget, - NS_LITERAL_STRING("mozpointerlockchange"), - true, - false); - e->PostDOMEvent(); + nsRefPtr<AsyncEventDispatcher> asyncDispatcher = + new AsyncEventDispatcher(aTarget, + NS_LITERAL_STRING("mozpointerlockchange"), + true, + false); + asyncDispatcher->PostDOMEvent(); } static void DispatchPointerLockError(nsIDocument* aTarget) { if (!aTarget) { return; } - nsRefPtr<nsAsyncDOMEvent> e = - new nsAsyncDOMEvent(aTarget, - NS_LITERAL_STRING("mozpointerlockerror"), - true, - false); - e->PostDOMEvent(); + nsRefPtr<AsyncEventDispatcher> asyncDispatcher = + new AsyncEventDispatcher(aTarget, + NS_LITERAL_STRING("mozpointerlockerror"), + true, + false); + asyncDispatcher->PostDOMEvent(); } mozilla::StaticRefPtr<nsPointerLockPermissionRequest> gPendingPointerLockRequest; class nsPointerLockPermissionRequest : public nsRunnable, public nsIContentPermissionRequest { public:
--- a/content/base/src/nsFrameLoader.cpp +++ b/content/base/src/nsFrameLoader.cpp @@ -52,17 +52,16 @@ #include "nsIXULWindow.h" #include "nsIEditor.h" #include "nsIMozBrowserFrame.h" #include "nsIPermissionManager.h" #include "nsISHistory.h" #include "nsLayoutUtils.h" #include "nsView.h" -#include "nsAsyncDOMEvent.h" #include "nsIURI.h" #include "nsIURL.h" #include "nsNetUtil.h" #include "nsGkAtoms.h" #include "nsNameSpaceManager.h" @@ -71,16 +70,17 @@ #include "nsIDOMChromeWindow.h" #include "nsInProcessTabChildGlobal.h" #include "Layers.h" #include "AppProcessChecker.h" #include "ContentParent.h" #include "TabParent.h" +#include "mozilla/AsyncEventDispatcher.h" #include "mozilla/GuardObjects.h" #include "mozilla/Preferences.h" #include "mozilla/unused.h" #include "mozilla/dom/Element.h" #include "mozilla/layout/RenderFrameParent.h" #include "nsIAppsService.h" #include "GeckoProfiler.h" @@ -370,22 +370,24 @@ nsFrameLoader::LoadFrame() } return NS_OK; } void nsFrameLoader::FireErrorEvent() { - if (mOwnerContent) { - nsRefPtr<nsAsyncDOMEvent> event = - new nsLoadBlockingAsyncDOMEvent(mOwnerContent, NS_LITERAL_STRING("error"), - false, false); - event->PostDOMEvent(); + if (!mOwnerContent) { + return; } + nsRefPtr<AsyncEventDispatcher > loadBlockingAsyncDispatcher = + new LoadBlockingAsyncEventDispatcher(mOwnerContent, + NS_LITERAL_STRING("error"), + false, false); + loadBlockingAsyncDispatcher->PostDOMEvent(); } NS_IMETHODIMP nsFrameLoader::LoadURI(nsIURI* aURI) { if (!aURI) return NS_ERROR_INVALID_POINTER; NS_ENSURE_STATE(!mDestroyCalled && mOwnerContent);
--- a/content/base/src/nsGenericDOMDataNode.cpp +++ b/content/base/src/nsGenericDOMDataNode.cpp @@ -6,16 +6,17 @@ /* * Base class for DOM Core's nsIDOMComment, nsIDOMDocumentType, nsIDOMText, * nsIDOMCDATASection, and nsIDOMProcessingInstruction nodes. */ #include "mozilla/DebugOnly.h" #include "nsGenericDOMDataNode.h" +#include "mozilla/AsyncEventDispatcher.h" #include "mozilla/MemoryReporting.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/ShadowRoot.h" #include "nsIDocument.h" #include "nsIDOMDocument.h" #include "nsReadableUtils.h" #include "mozilla/InternalMutationEvent.h" #include "nsIURI.h" @@ -27,17 +28,16 @@ #include "nsChangeHint.h" #include "nsEventDispatcher.h" #include "nsCOMArray.h" #include "nsNodeUtils.h" #include "mozilla/dom/DirectionalityUtils.h" #include "nsBindingManager.h" #include "nsCCUncollectableMarker.h" #include "mozAutoDocUpdate.h" -#include "nsAsyncDOMEvent.h" #include "pldhash.h" #include "prprf.h" #include "nsWrapperCacheInlines.h" using namespace mozilla; using namespace mozilla::dom; @@ -382,17 +382,17 @@ nsGenericDOMDataNode::SetTextInternal(ui mutation.mPrevAttrValue = oldValue; if (aLength > 0) { nsAutoString val; mText.AppendTo(val); mutation.mNewAttrValue = do_GetAtom(val); } mozAutoSubtreeModified subtree(OwnerDoc(), this); - (new nsAsyncDOMEvent(this, mutation))->RunDOMEventWhenSafe(); + (new AsyncEventDispatcher(this, mutation))->RunDOMEventWhenSafe(); } } return NS_OK; } //----------------------------------------------------------------------
--- a/content/base/src/nsINode.cpp +++ b/content/base/src/nsINode.cpp @@ -8,26 +8,26 @@ * Base class for all DOM nodes. */ #include "nsINode.h" #include "AccessCheck.h" #include "jsapi.h" #include "mozAutoDocUpdate.h" +#include "mozilla/AsyncEventDispatcher.h" #include "mozilla/CORSMode.h" #include "mozilla/EventListenerManager.h" #include "mozilla/InternalMutationEvent.h" #include "mozilla/Likely.h" #include "mozilla/MemoryReporting.h" #include "mozilla/Telemetry.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/Event.h" #include "mozilla/dom/ShadowRoot.h" -#include "nsAsyncDOMEvent.h" #include "nsAttrValueOrString.h" #include "nsBindingManager.h" #include "nsCCUncollectableMarker.h" #include "nsContentCreatorFunctions.h" #include "nsContentList.h" #include "nsContentUtils.h" #include "nsCycleCollectionParticipant.h" #include "nsDocument.h" @@ -1437,17 +1437,17 @@ nsINode::doInsertChildAt(nsIContent* aKi } if (nsContentUtils::HasMutationListeners(aKid, NS_EVENT_BITS_MUTATION_NODEINSERTED, this)) { InternalMutationEvent mutation(true, NS_MUTATION_NODEINSERTED); mutation.mRelatedNode = do_QueryInterface(this); mozAutoSubtreeModified subtree(OwnerDoc(), this); - (new nsAsyncDOMEvent(aKid, mutation))->RunDOMEventWhenSafe(); + (new AsyncEventDispatcher(aKid, mutation))->RunDOMEventWhenSafe(); } } return NS_OK; } Element* nsINode::GetPreviousElementSibling() const
--- a/content/base/src/nsImageLoadingContent.cpp +++ b/content/base/src/nsImageLoadingContent.cpp @@ -21,17 +21,16 @@ #include "nsContentPolicyUtils.h" #include "nsIURI.h" #include "nsILoadGroup.h" #include "imgIContainer.h" #include "imgLoader.h" #include "imgRequestProxy.h" #include "nsThreadUtils.h" #include "nsNetUtil.h" -#include "nsAsyncDOMEvent.h" #include "nsImageFrame.h" #include "nsIPresShell.h" #include "nsEventStates.h" #include "nsIChannel.h" #include "nsIStreamListener.h" @@ -40,16 +39,17 @@ #include "nsContentUtils.h" #include "nsLayoutUtils.h" #include "nsIContentPolicy.h" #include "nsEventDispatcher.h" #include "nsSVGEffects.h" #include "mozAutoDocUpdate.h" +#include "mozilla/AsyncEventDispatcher.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/ScriptSettings.h" #if defined(XP_WIN) // Undefine LoadImage to prevent naming conflict with Windows. #undef LoadImage #endif @@ -1034,20 +1034,20 @@ nsresult nsImageLoadingContent::FireEvent(const nsAString& aEventType) { // We have to fire the event asynchronously so that we won't go into infinite // loops in cases when onLoad handlers reset the src and the new src is in // cache. nsCOMPtr<nsINode> thisNode = do_QueryInterface(static_cast<nsIImageLoadingContent*>(this)); - nsRefPtr<nsAsyncDOMEvent> event = - new nsLoadBlockingAsyncDOMEvent(thisNode, aEventType, false, false); - event->PostDOMEvent(); - + nsRefPtr<AsyncEventDispatcher> loadBlockingAsyncDispatcher = + new LoadBlockingAsyncEventDispatcher(thisNode, aEventType, false, false); + loadBlockingAsyncDispatcher->PostDOMEvent(); + return NS_OK; } nsRefPtr<imgRequestProxy>& nsImageLoadingContent::PrepareNextRequest() { // If we don't have a usable current request, get rid of any half-baked // request that might be sitting there and make this one current.
--- a/content/html/content/src/HTMLCanvasElement.cpp +++ b/content/html/content/src/HTMLCanvasElement.cpp @@ -13,17 +13,16 @@ #include "mozilla/Base64.h" #include "mozilla/CheckedInt.h" #include "mozilla/dom/CanvasRenderingContext2D.h" #include "mozilla/dom/HTMLCanvasElementBinding.h" #include "mozilla/dom/UnionTypes.h" #include "mozilla/gfx/Rect.h" #include "mozilla/Preferences.h" #include "mozilla/Telemetry.h" -#include "nsAsyncDOMEvent.h" #include "nsAttrValueInlines.h" #include "nsContentUtils.h" #include "nsDisplayList.h" #include "nsDOMFile.h" #include "nsDOMJSUtils.h" #include "nsFrameManager.h" #include "nsIScriptSecurityManager.h" #include "nsITimer.h"
--- a/content/html/content/src/HTMLFormElement.cpp +++ b/content/html/content/src/HTMLFormElement.cpp @@ -1051,24 +1051,24 @@ HTMLFormElement::AssertDocumentOrder( } } #endif void HTMLFormElement::PostPasswordEvent() { // Don't fire another add event if we have a pending add event. - if (mFormPasswordEvent.get()) { + if (mFormPasswordEventDispatcher.get()) { return; } - nsRefPtr<FormPasswordEvent> event = - new FormPasswordEvent(this, NS_LITERAL_STRING("DOMFormHasPassword")); - mFormPasswordEvent = event; - event->PostDOMEvent(); + mFormPasswordEventDispatcher = + new FormPasswordEventDispatcher(this, + NS_LITERAL_STRING("DOMFormHasPassword")); + mFormPasswordEventDispatcher->PostDOMEvent(); } // This function return true if the element, once appended, is the last one in // the array. template<typename ElementType> static bool AddElementToList(nsTArray<ElementType*>& aList, ElementType* aChild, HTMLFormElement* aForm)
--- a/content/html/content/src/HTMLFormElement.h +++ b/content/html/content/src/HTMLFormElement.h @@ -1,31 +1,31 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef mozilla_dom_HTMLFormElement_h #define mozilla_dom_HTMLFormElement_h +#include "mozilla/AsyncEventDispatcher.h" #include "mozilla/Attributes.h" #include "nsCOMPtr.h" #include "nsIForm.h" #include "nsIFormControl.h" #include "nsFormSubmission.h" #include "nsGenericHTMLElement.h" #include "nsIDOMHTMLFormElement.h" #include "nsIWebProgressListener.h" #include "nsIRadioGroupContainer.h" #include "nsIWeakReferenceUtils.h" #include "nsThreadUtils.h" #include "nsInterfaceHashtable.h" #include "nsRefPtrHashtable.h" #include "nsDataHashtable.h" -#include "nsAsyncDOMEvent.h" #include "jsfriendapi.h" // For js::ExpandoAndGeneration class nsIMutableArray; class nsIURI; namespace mozilla { namespace dom { class HTMLFormControlsCollection; @@ -404,34 +404,34 @@ public: js::ExpandoAndGeneration mExpandoAndGeneration; protected: virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE; void PostPasswordEvent(); - void EventHandled() { mFormPasswordEvent = nullptr; } + void EventHandled() { mFormPasswordEventDispatcher = nullptr; } - class FormPasswordEvent : public nsAsyncDOMEvent + class FormPasswordEventDispatcher MOZ_FINAL : public AsyncEventDispatcher { public: - FormPasswordEvent(HTMLFormElement* aEventNode, - const nsAString& aEventType) - : nsAsyncDOMEvent(aEventNode, aEventType, true, true) + FormPasswordEventDispatcher(HTMLFormElement* aEventNode, + const nsAString& aEventType) + : AsyncEventDispatcher(aEventNode, aEventType, true, true) {} NS_IMETHOD Run() MOZ_OVERRIDE { static_cast<HTMLFormElement*>(mEventNode.get())->EventHandled(); - return nsAsyncDOMEvent::Run(); + return AsyncEventDispatcher::Run(); } }; - nsRefPtr<FormPasswordEvent> mFormPasswordEvent; + nsRefPtr<FormPasswordEventDispatcher> mFormPasswordEventDispatcher; class RemoveElementRunnable; friend class RemoveElementRunnable; class RemoveElementRunnable : public nsRunnable { public: RemoveElementRunnable(HTMLFormElement* aForm) : mForm(aForm)
--- a/content/html/content/src/HTMLInputElement.cpp +++ b/content/html/content/src/HTMLInputElement.cpp @@ -1,19 +1,19 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/dom/HTMLInputElement.h" #include "mozilla/ArrayUtils.h" +#include "mozilla/AsyncEventDispatcher.h" #include "mozilla/DebugOnly.h" #include "mozilla/dom/Date.h" -#include "nsAsyncDOMEvent.h" #include "nsAttrValueInlines.h" #include "nsIDOMHTMLInputElement.h" #include "nsITextControlElement.h" #include "nsIDOMNSEditableElement.h" #include "nsIRadioVisitor.h" #include "nsIPhonetic.h" @@ -3571,19 +3571,19 @@ HTMLInputElement::CancelRangeThumbDrag(b // TODO: decide what we should do here - bug 851782. nsAutoString val; ConvertNumberToString(mRangeThumbDragStartValue, val); SetValueInternal(val, true, true); nsRangeFrame* frame = do_QueryFrame(GetPrimaryFrame()); if (frame) { frame->UpdateForValueChange(); } - nsRefPtr<nsAsyncDOMEvent> event = - new nsAsyncDOMEvent(this, NS_LITERAL_STRING("input"), true, false); - event->RunDOMEventWhenSafe(); + nsRefPtr<AsyncEventDispatcher> asyncDispatcher = + new AsyncEventDispatcher(this, NS_LITERAL_STRING("input"), true, false); + asyncDispatcher->RunDOMEventWhenSafe(); } } void HTMLInputElement::SetValueOfRangeForUserEvent(Decimal aValue) { MOZ_ASSERT(aValue.isFinite()); @@ -5072,19 +5072,20 @@ HTMLInputElement::SetSelectionRange(int3 nsITextControlFrame::SelectionDirection dir = nsITextControlFrame::eForward; if (aDirection.WasPassed() && aDirection.Value().EqualsLiteral("backward")) { dir = nsITextControlFrame::eBackward; } aRv = textControlFrame->SetSelectionRange(aSelectionStart, aSelectionEnd, dir); if (!aRv.Failed()) { aRv = textControlFrame->ScrollSelectionIntoView(); - nsRefPtr<nsAsyncDOMEvent> event = - new nsAsyncDOMEvent(this, NS_LITERAL_STRING("select"), true, false); - event->PostDOMEvent(); + nsRefPtr<AsyncEventDispatcher> asyncDispatcher = + new AsyncEventDispatcher(this, NS_LITERAL_STRING("select"), + true, false); + asyncDispatcher->PostDOMEvent(); } } } } NS_IMETHODIMP HTMLInputElement::SetSelectionRange(int32_t aSelectionStart, int32_t aSelectionEnd,
--- a/content/html/content/src/HTMLLinkElement.cpp +++ b/content/html/content/src/HTMLLinkElement.cpp @@ -1,20 +1,20 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/dom/HTMLLinkElement.h" +#include "mozilla/AsyncEventDispatcher.h" #include "mozilla/Attributes.h" #include "mozilla/dom/HTMLLinkElementBinding.h" #include "mozilla/MemoryReporting.h" -#include "nsAsyncDOMEvent.h" #include "nsContentUtils.h" #include "nsGenericHTMLElement.h" #include "nsGkAtoms.h" #include "nsDOMTokenList.h" #include "nsIDocument.h" #include "nsIDOMEvent.h" #include "nsIDOMStyleSheet.h" #include "nsIStyleSheet.h" @@ -221,21 +221,21 @@ HTMLLinkElement::CreateAndDispatchEvent( {&nsGkAtoms::_empty, &nsGkAtoms::stylesheet, nullptr}; if (!nsContentUtils::HasNonEmptyAttr(this, kNameSpaceID_None, nsGkAtoms::rev) && FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::rel, strings, eIgnoreCase) != ATTR_VALUE_NO_MATCH) return; - nsRefPtr<nsAsyncDOMEvent> event = new nsAsyncDOMEvent(this, aEventName, true, - true); + nsRefPtr<AsyncEventDispatcher> asyncDispatcher = + new AsyncEventDispatcher(this, aEventName, true, true); // Always run async in order to avoid running script when the content // sink isn't expecting it. - event->PostDOMEvent(); + asyncDispatcher->PostDOMEvent(); } nsresult HTMLLinkElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix, const nsAString& aValue, bool aNotify) { nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix,
--- a/content/html/content/src/HTMLMetaElement.cpp +++ b/content/html/content/src/HTMLMetaElement.cpp @@ -1,18 +1,18 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "mozilla/AsyncEventDispatcher.h" #include "mozilla/dom/HTMLMetaElement.h" #include "mozilla/dom/HTMLMetaElementBinding.h" +#include "nsContentUtils.h" #include "nsStyleConsts.h" -#include "nsAsyncDOMEvent.h" -#include "nsContentUtils.h" NS_IMPL_NS_NEW_HTML_ELEMENT(Meta) namespace mozilla { namespace dom { HTMLMetaElement::HTMLMetaElement(already_AddRefed<nsINodeInfo>& aNodeInfo) : nsGenericHTMLElement(aNodeInfo) @@ -78,19 +78,19 @@ HTMLMetaElement::UnbindFromTree(bool aDe void HTMLMetaElement::CreateAndDispatchEvent(nsIDocument* aDoc, const nsAString& aEventName) { if (!aDoc) return; - nsRefPtr<nsAsyncDOMEvent> event = new nsAsyncDOMEvent(this, aEventName, true, - true); - event->PostDOMEvent(); + nsRefPtr<AsyncEventDispatcher> asyncDispatcher = + new AsyncEventDispatcher(this, aEventName, true, true); + asyncDispatcher->PostDOMEvent(); } JSObject* HTMLMetaElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aScope) { return HTMLMetaElementBinding::Wrap(aCx, aScope, this); }
--- a/content/html/content/src/HTMLTextAreaElement.cpp +++ b/content/html/content/src/HTMLTextAreaElement.cpp @@ -2,16 +2,17 @@ /* vim: set sw=2 ts=2 et tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/dom/HTMLTextAreaElement.h" #include "mozAutoDocUpdate.h" +#include "mozilla/AsyncEventDispatcher.h" #include "mozilla/Attributes.h" #include "mozilla/dom/HTMLTextAreaElementBinding.h" #include "mozilla/MouseEvents.h" #include "nsAttrValueInlines.h" #include "nsContentCID.h" #include "nsContentCreatorFunctions.h" #include "nsError.h" #include "nsEventDispatcher.h" @@ -882,19 +883,20 @@ HTMLTextAreaElement::SetSelectionRange(u nsITextControlFrame::SelectionDirection dir = nsITextControlFrame::eForward; if (aDirection.WasPassed() && aDirection.Value().EqualsLiteral("backward")) { dir = nsITextControlFrame::eBackward; } rv = textControlFrame->SetSelectionRange(aSelectionStart, aSelectionEnd, dir); if (NS_SUCCEEDED(rv)) { rv = textControlFrame->ScrollSelectionIntoView(); - nsRefPtr<nsAsyncDOMEvent> event = - new nsAsyncDOMEvent(this, NS_LITERAL_STRING("select"), true, false); - event->PostDOMEvent(); + nsRefPtr<AsyncEventDispatcher> asyncDispatcher = + new AsyncEventDispatcher(this, NS_LITERAL_STRING("select"), + true, false); + asyncDispatcher->PostDOMEvent(); } } } if (NS_FAILED(rv)) { aError.Throw(rv); } }
--- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -78,17 +78,16 @@ #include "nsEventDispatcher.h" #include "nsLayoutUtils.h" #include "mozAutoDocUpdate.h" #include "nsHtml5Module.h" #include "nsITextControlElement.h" #include "mozilla/dom/Element.h" #include "HTMLFieldSetElement.h" #include "HTMLMenuElement.h" -#include "nsAsyncDOMEvent.h" #include "nsDOMMutationObserver.h" #include "mozilla/Preferences.h" #include "mozilla/dom/FromParser.h" #include "mozilla/dom/Link.h" #include "mozilla/dom/UndoManager.h" #include "mozilla/BloomFilter.h" #include "HTMLPropertiesCollection.h"
--- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -70,17 +70,16 @@ #include "nsRuleWalker.h" #include "nsIDOMCSSStyleDeclaration.h" #include "nsCSSParser.h" #include "nsIListBoxObject.h" #include "nsContentUtils.h" #include "nsContentList.h" #include "mozilla/InternalMutationEvent.h" #include "mozilla/MouseEvents.h" -#include "nsAsyncDOMEvent.h" #include "nsIDOMMutationEvent.h" #include "nsPIDOMWindow.h" #include "nsJSPrincipals.h" #include "nsDOMAttributeMap.h" #include "nsGkAtoms.h" #include "nsXULContentUtils.h" #include "nsNodeUtils.h" #include "nsFrameLoader.h"
rename from dom/events/nsAsyncDOMEvent.cpp rename to dom/events/AsyncEventDispatcher.cpp --- a/dom/events/nsAsyncDOMEvent.cpp +++ b/dom/events/AsyncEventDispatcher.cpp @@ -1,36 +1,44 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "nsAsyncDOMEvent.h" -#include "nsIDOMEvent.h" -#include "nsContentUtils.h" -#include "nsEventDispatcher.h" +#include "mozilla/AsyncEventDispatcher.h" #include "mozilla/BasicEvents.h" #include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent() #include "mozilla/dom/EventTarget.h" +#include "nsContentUtils.h" +#include "nsEventDispatcher.h" +#include "nsIDOMEvent.h" -using namespace mozilla; -using namespace mozilla::dom; +namespace mozilla { + +using namespace dom; -nsAsyncDOMEvent::nsAsyncDOMEvent(nsINode* aEventNode, WidgetEvent& aEvent) - : mEventNode(aEventNode), mDispatchChromeOnly(false) +/****************************************************************************** + * mozilla::AsyncEventDispatcher + ******************************************************************************/ + +AsyncEventDispatcher::AsyncEventDispatcher(nsINode* aEventNode, + WidgetEvent& aEvent) + : mEventNode(aEventNode) + , mDispatchChromeOnly(false) { MOZ_ASSERT(mEventNode); nsEventDispatcher::CreateEvent(aEventNode, nullptr, &aEvent, EmptyString(), getter_AddRefs(mEvent)); NS_ASSERTION(mEvent, "Should never fail to create an event"); mEvent->DuplicatePrivateData(); mEvent->SetTrusted(aEvent.mFlags.mIsTrusted); } -NS_IMETHODIMP nsAsyncDOMEvent::Run() +NS_IMETHODIMP +AsyncEventDispatcher::Run() { if (mEvent) { if (mDispatchChromeOnly) { MOZ_ASSERT(mEvent->InternalDOMEvent()->IsTrusted()); nsCOMPtr<nsIDocument> ownerDoc = mEventNode->OwnerDoc(); nsPIDOMWindow* window = ownerDoc->GetWindow(); if (!window) { @@ -57,24 +65,32 @@ NS_IMETHODIMP nsAsyncDOMEvent::Run() nsContentUtils::DispatchTrustedEvent(doc, mEventNode, mEventType, mBubbles, false); } } return NS_OK; } -nsresult nsAsyncDOMEvent::PostDOMEvent() +nsresult +AsyncEventDispatcher::PostDOMEvent() { return NS_DispatchToCurrentThread(this); } -void nsAsyncDOMEvent::RunDOMEventWhenSafe() +void +AsyncEventDispatcher::RunDOMEventWhenSafe() { nsContentUtils::AddScriptRunner(this); } -nsLoadBlockingAsyncDOMEvent::~nsLoadBlockingAsyncDOMEvent() +/****************************************************************************** + * mozilla::LoadBlockingAsyncEventDispatcher + ******************************************************************************/ + +LoadBlockingAsyncEventDispatcher::~LoadBlockingAsyncEventDispatcher() { if (mBlockedDoc) { mBlockedDoc->UnblockOnload(true); } } + +} // namespace mozilla
rename from dom/events/nsAsyncDOMEvent.h rename to dom/events/AsyncEventDispatcher.h --- a/dom/events/nsAsyncDOMEvent.h +++ b/dom/events/AsyncEventDispatcher.h @@ -1,76 +1,90 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef nsAsyncDOMEvent_h___ -#define nsAsyncDOMEvent_h___ +#ifndef mozilla_AsyncEventDispatcher_h_ +#define mozilla_AsyncEventDispatcher_h_ #include "mozilla/Attributes.h" #include "nsCOMPtr.h" -#include "nsThreadUtils.h" -#include "nsINode.h" +#include "nsIDocument.h" #include "nsIDOMEvent.h" +#include "nsINode.h" #include "nsString.h" -#include "nsIDocument.h" +#include "nsThreadUtils.h" + +namespace mozilla { /** * Use nsAsyncDOMEvent to fire a DOM event that requires safe a stable DOM. * For example, you may need to fire an event from within layout, but * want to ensure that the event handler doesn't mutate the DOM at * the wrong time, in order to avoid resulting instability. */ -class nsAsyncDOMEvent : public nsRunnable { +class AsyncEventDispatcher : public nsRunnable +{ public: - nsAsyncDOMEvent(nsINode *aEventNode, const nsAString& aEventType, - bool aBubbles, bool aDispatchChromeOnly) - : mEventNode(aEventNode), mEventType(aEventType), - mBubbles(aBubbles), - mDispatchChromeOnly(aDispatchChromeOnly) - { } + AsyncEventDispatcher(nsINode* aEventNode, const nsAString& aEventType, + bool aBubbles, bool aDispatchChromeOnly) + : mEventNode(aEventNode) + , mEventType(aEventType) + , mBubbles(aBubbles) + , mDispatchChromeOnly(aDispatchChromeOnly) + { + } - nsAsyncDOMEvent(nsINode *aEventNode, nsIDOMEvent *aEvent) - : mEventNode(aEventNode), mEvent(aEvent), mDispatchChromeOnly(false) - { } + AsyncEventDispatcher(nsINode* aEventNode, nsIDOMEvent* aEvent) + : mEventNode(aEventNode) + , mEvent(aEvent) + , mDispatchChromeOnly(false) + { + } - nsAsyncDOMEvent(nsINode* aEventNode, mozilla::WidgetEvent& aEvent); + AsyncEventDispatcher(nsINode* aEventNode, WidgetEvent& aEvent); NS_IMETHOD Run() MOZ_OVERRIDE; nsresult PostDOMEvent(); void RunDOMEventWhenSafe(); nsCOMPtr<nsINode> mEventNode; nsCOMPtr<nsIDOMEvent> mEvent; nsString mEventType; bool mBubbles; bool mDispatchChromeOnly; }; -class nsLoadBlockingAsyncDOMEvent : public nsAsyncDOMEvent { +class LoadBlockingAsyncEventDispatcher MOZ_FINAL : public AsyncEventDispatcher +{ public: - nsLoadBlockingAsyncDOMEvent(nsINode *aEventNode, const nsAString& aEventType, - bool aBubbles, bool aDispatchChromeOnly) - : nsAsyncDOMEvent(aEventNode, aEventType, aBubbles, aDispatchChromeOnly), - mBlockedDoc(aEventNode->OwnerDoc()) + LoadBlockingAsyncEventDispatcher(nsINode* aEventNode, + const nsAString& aEventType, + bool aBubbles, bool aDispatchChromeOnly) + : AsyncEventDispatcher(aEventNode, aEventType, + aBubbles, aDispatchChromeOnly) + , mBlockedDoc(aEventNode->OwnerDoc()) { if (mBlockedDoc) { mBlockedDoc->BlockOnload(); } } - nsLoadBlockingAsyncDOMEvent(nsINode *aEventNode, nsIDOMEvent *aEvent) - : nsAsyncDOMEvent(aEventNode, aEvent), - mBlockedDoc(aEventNode->OwnerDoc()) + LoadBlockingAsyncEventDispatcher(nsINode* aEventNode, nsIDOMEvent* aEvent) + : AsyncEventDispatcher(aEventNode, aEvent) + , mBlockedDoc(aEventNode->OwnerDoc()) { if (mBlockedDoc) { mBlockedDoc->BlockOnload(); } } - ~nsLoadBlockingAsyncDOMEvent(); + ~LoadBlockingAsyncEventDispatcher(); +private: nsCOMPtr<nsIDocument> mBlockedDoc; }; -#endif +} // namespace mozilla + +#endif // mozilla_AsyncEventDispatcher_h_
--- a/dom/events/IMEContentObserver.cpp +++ b/dom/events/IMEContentObserver.cpp @@ -1,20 +1,20 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=2 sw=2 et tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "ContentEventHandler.h" #include "IMEContentObserver.h" +#include "mozilla/AsyncEventDispatcher.h" #include "mozilla/IMEStateManager.h" #include "mozilla/dom/Element.h" #include "nsAutoPtr.h" -#include "nsAsyncDOMEvent.h" #include "nsContentUtils.h" #include "nsGkAtoms.h" #include "nsIAtom.h" #include "nsIContent.h" #include "nsIDocument.h" #include "nsIDOMDocument.h" #include "nsIDOMRange.h" #include "nsIFrame.h" @@ -90,18 +90,18 @@ IMEContentObserver::Init(nsIWidget* aWid // The document node is editable, but there are no contents, this document // is not editable. return; } NS_ENSURE_TRUE_VOID(mRootContent); if (IMEStateManager::IsTestingIME()) { nsIDocument* doc = aPresContext->Document(); - (new nsAsyncDOMEvent(doc, NS_LITERAL_STRING("MozIMEFocusIn"), - false, false))->RunDOMEventWhenSafe(); + (new AsyncEventDispatcher(doc, NS_LITERAL_STRING("MozIMEFocusIn"), + false, false))->RunDOMEventWhenSafe(); } aWidget->NotifyIME(IMENotification(NOTIFY_IME_OF_FOCUS)); // NOTIFY_IME_OF_FOCUS might cause recreating IMEContentObserver // instance via IMEStateManager::UpdateIMEState(). So, this // instance might already have been destroyed, check it. if (!mRootContent) { @@ -144,18 +144,18 @@ IMEContentObserver::ObserveEditableNode( void IMEContentObserver::Destroy() { // If CreateTextStateManager failed, mRootContent will be null, // and we should not call NotifyIME(IMENotification(NOTIFY_IME_OF_BLUR)) if (mRootContent) { if (IMEStateManager::IsTestingIME() && mEditableNode) { nsIDocument* doc = mEditableNode->OwnerDoc(); - (new nsAsyncDOMEvent(doc, NS_LITERAL_STRING("MozIMEFocusOut"), - false, false))->RunDOMEventWhenSafe(); + (new AsyncEventDispatcher(doc, NS_LITERAL_STRING("MozIMEFocusOut"), + false, false))->RunDOMEventWhenSafe(); } mWidget->NotifyIME(IMENotification(NOTIFY_IME_OF_BLUR)); } // Even if there are some pending notification, it'll never notify the widget. mWidget = nullptr; if (mUpdatePreference.WantSelectionChange() && mSelection) { nsCOMPtr<nsISelectionPrivate> selPrivate(do_QueryInterface(mSelection)); if (selPrivate) {
--- a/dom/events/moz.build +++ b/dom/events/moz.build @@ -9,28 +9,28 @@ MOCHITEST_CHROME_MANIFESTS += ['test/chr XPIDL_SOURCES += [ 'nsIEventListenerService.idl', ] XPIDL_MODULE = 'content_events' EXPORTS += [ - 'nsAsyncDOMEvent.h', 'nsDOMEventTargetHelper.h', 'nsDOMKeyNameList.h', 'nsEventDispatcher.h', 'nsEventNameList.h', 'nsEventStateManager.h', 'nsEventStates.h', 'nsIJSEventListener.h', 'nsVKList.h', ] EXPORTS.mozilla += [ + 'AsyncEventDispatcher.h', 'EventListenerManager.h', 'IMEStateManager.h', 'InternalMutationEvent.h', ] EXPORTS.mozilla.dom += [ 'AnimationEvent.h', 'BeforeUnloadEvent.h', @@ -62,16 +62,17 @@ EXPORTS.mozilla.dom += [ 'XULCommandEvent.h', ] if CONFIG['MOZ_WEBSPEECH']: EXPORTS.mozilla.dom += ['SpeechRecognitionError.h'] UNIFIED_SOURCES += [ 'AnimationEvent.cpp', + 'AsyncEventDispatcher.cpp', 'BeforeUnloadEvent.cpp', 'ClipboardEvent.cpp', 'CommandEvent.cpp', 'CompositionEvent.cpp', 'ContentEventHandler.cpp', 'DataContainerEvent.cpp', 'DataTransfer.cpp', 'DeviceMotionEvent.cpp', @@ -85,17 +86,16 @@ UNIFIED_SOURCES += [ 'IMEStateManager.cpp', 'KeyboardEvent.cpp', 'MessageEvent.cpp', 'MouseEvent.cpp', 'MouseScrollEvent.cpp', 'MutationEvent.cpp', 'NotifyAudioAvailableEvent.cpp', 'NotifyPaintEvent.cpp', - 'nsAsyncDOMEvent.cpp', 'nsDOMEventTargetHelper.cpp', 'nsEventDispatcher.cpp', 'nsJSEventListener.cpp', 'nsPaintRequest.cpp', 'PointerEvent.cpp', 'ScrollAreaEvent.cpp', 'SimpleGestureEvent.cpp', 'TextComposition.cpp',
--- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -27,21 +27,21 @@ #include "nsListControlFrame.h" #include "nsAutoPtr.h" #include "nsStyleSet.h" #include "nsNodeInfoManager.h" #include "nsContentCreatorFunctions.h" #include "nsLayoutUtils.h" #include "nsDisplayList.h" #include "nsITheme.h" -#include "nsAsyncDOMEvent.h" #include "nsRenderingContext.h" #include "mozilla/Likely.h" #include <algorithm> #include "nsTextNode.h" +#include "mozilla/AsyncEventDispatcher.h" #include "mozilla/LookAndFeel.h" #include "mozilla/MouseEvents.h" #include "mozilla/unused.h" using namespace mozilla; NS_IMETHODIMP nsComboboxControlFrame::RedisplayTextEvent::Run() @@ -1547,18 +1547,18 @@ nsComboboxControlFrame::OnOptionSelected return NS_OK; } void nsComboboxControlFrame::FireValueChangeEvent() { // Fire ValueChange event to indicate data value of combo box has changed nsContentUtils::AddScriptRunner( - new nsAsyncDOMEvent(mContent, NS_LITERAL_STRING("ValueChange"), true, - false)); + new AsyncEventDispatcher(mContent, NS_LITERAL_STRING("ValueChange"), true, + false)); } void nsComboboxControlFrame::OnContentReset() { if (mListControlFrame) { mListControlFrame->OnContentReset(); }
--- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -20,17 +20,16 @@ #include "nsString.h" #include "nsReadableUtils.h" #include "nsStyleContext.h" #include "nsTableOuterFrame.h" #include "nsView.h" #include "nsViewManager.h" #include "nsIScrollableFrame.h" #include "nsPresContext.h" -#include "nsAsyncDOMEvent.h" #include "nsStyleConsts.h" #include "nsIPresShell.h" #include "prlog.h" #include "prprf.h" #include <stdarg.h> #include "nsFrameManager.h" #include "nsLayoutUtils.h" @@ -73,16 +72,17 @@ #include "nsRenderingContext.h" #include "nsAbsoluteContainingBlock.h" #include "StickyScrollContainer.h" #include "nsFontInflationData.h" #include "gfxASurface.h" #include "nsRegion.h" #include "nsIFrameInlines.h" +#include "mozilla/AsyncEventDispatcher.h" #include "mozilla/EventListenerManager.h" #include "mozilla/Preferences.h" #include "mozilla/LookAndFeel.h" #include "mozilla/MouseEvents.h" #include "mozilla/css/ImageLoader.h" #include "mozilla/gfx/Tools.h" #include "nsPrintfCString.h" @@ -2438,20 +2438,20 @@ nsFrame::GetContentForEvent(WidgetEvent* } void nsFrame::FireDOMEvent(const nsAString& aDOMEventName, nsIContent *aContent) { nsIContent* target = aContent ? aContent : mContent; if (target) { - nsRefPtr<nsAsyncDOMEvent> event = - new nsAsyncDOMEvent(target, aDOMEventName, true, false); - if (NS_FAILED(event->PostDOMEvent())) - NS_WARNING("Failed to dispatch nsAsyncDOMEvent"); + nsRefPtr<AsyncEventDispatcher> asyncDispatcher = + new AsyncEventDispatcher(target, aDOMEventName, true, false); + DebugOnly<nsresult> rv = asyncDispatcher->PostDOMEvent(); + NS_ASSERTION(NS_SUCCEEDED(rv), "AsyncEventDispatcher failed to dispatch"); } } nsresult nsFrame::HandleEvent(nsPresContext* aPresContext, WidgetGUIEvent* aEvent, nsEventStatus* aEventStatus) {
--- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -4,27 +4,27 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsPrintEngine.h" #include "nsIStringBundle.h" #include "nsReadableUtils.h" #include "nsCRT.h" +#include "mozilla/AsyncEventDispatcher.h" #include "mozilla/Selection.h" #include "nsIScriptGlobalObject.h" #include "nsPIDOMWindow.h" #include "nsIDocShell.h" #include "nsIFrame.h" #include "nsIURI.h" #include "nsITextToSubURI.h" #include "nsError.h" #include "nsView.h" -#include "nsAsyncDOMEvent.h" #include <algorithm> // Print Options #include "nsIPrintSettings.h" #include "nsIPrintSettingsService.h" #include "nsIPrintOptions.h" #include "nsIPrintSession.h" #include "nsGfxCIID.h" @@ -1853,17 +1853,17 @@ nsPrintEngine::ReflowDocList(nsPrintObje void nsPrintEngine::FirePrintPreviewUpdateEvent() { // Dispatch the event only while in PrintPreview. When printing, there is no // listener bound to this event and therefore no need to dispatch it. if (mIsDoingPrintPreview && !mIsDoingPrinting) { nsCOMPtr<nsIContentViewer> cv = do_QueryInterface(mDocViewerPrint); - (new nsAsyncDOMEvent( + (new AsyncEventDispatcher( cv->GetDocument(), NS_LITERAL_STRING("printPreviewUpdate"), true, true) )->RunDOMEventWhenSafe(); } } nsresult nsPrintEngine::InitPrintDocConstruction(bool aHandleError) {
--- a/layout/xul/tree/nsTreeBodyFrame.cpp +++ b/layout/xul/tree/nsTreeBodyFrame.cpp @@ -1,13 +1,14 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "mozilla/AsyncEventDispatcher.h" #include "mozilla/ContentEvents.h" #include "mozilla/DebugOnly.h" #include "mozilla/MathAlgorithms.h" #include "mozilla/MouseEvents.h" #include "mozilla/Likely.h" #include "nsCOMPtr.h" #include "nsPresContext.h" @@ -18,17 +19,16 @@ #include "nsTreeImageListener.h" #include "nsGkAtoms.h" #include "nsCSSAnonBoxes.h" #include "nsIContent.h" #include "nsStyleContext.h" #include "nsIBoxObject.h" -#include "nsAsyncDOMEvent.h" #include "nsIDOMDataContainerEvent.h" #include "nsIDOMMouseEvent.h" #include "nsIDOMElement.h" #include "nsIDOMNodeList.h" #include "nsIDOMDocument.h" #include "nsIDOMXULElement.h" #include "nsIDocument.h" #include "mozilla/css/StyleRule.h" @@ -4557,21 +4557,19 @@ nsTreeBodyFrame::FireRowCountChangedEven if (!countVariant) return; countVariant->SetAsInt32(aCount); treeEvent->SetData(NS_LITERAL_STRING("count"), countVariant); event->SetTrusted(true); - nsRefPtr<nsAsyncDOMEvent> plevent = new nsAsyncDOMEvent(content, event); - if (!plevent) - return; - - plevent->PostDOMEvent(); + nsRefPtr<AsyncEventDispatcher> asyncDispatcher = + new AsyncEventDispatcher(content, event); + asyncDispatcher->PostDOMEvent(); } void nsTreeBodyFrame::FireInvalidateEvent(int32_t aStartRowIdx, int32_t aEndRowIdx, nsITreeColumn *aStartCol, nsITreeColumn *aEndCol) { nsCOMPtr<nsIContent> content(GetBaseElement()); @@ -4639,19 +4637,19 @@ nsTreeBodyFrame::FireInvalidateEvent(int return; endColVariant->SetAsInt32(endColIdx); treeEvent->SetData(NS_LITERAL_STRING("endcolumn"), endColVariant); } event->SetTrusted(true); - nsRefPtr<nsAsyncDOMEvent> plevent = new nsAsyncDOMEvent(content, event); - if (plevent) - plevent->PostDOMEvent(); + nsRefPtr<AsyncEventDispatcher> asyncDispatcher = + new AsyncEventDispatcher(content, event); + asyncDispatcher->PostDOMEvent(); } #endif class nsOverflowChecker : public nsRunnable { public: nsOverflowChecker(nsTreeBodyFrame* aFrame) : mFrame(aFrame) {} NS_IMETHOD Run() MOZ_OVERRIDE
--- a/layout/xul/tree/nsTreeSelection.cpp +++ b/layout/xul/tree/nsTreeSelection.cpp @@ -1,29 +1,31 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "mozilla/AsyncEventDispatcher.h" #include "nsCOMPtr.h" #include "nsTreeSelection.h" #include "nsIBoxObject.h" #include "nsITreeBoxObject.h" #include "nsITreeView.h" #include "nsString.h" #include "nsIDOMElement.h" #include "nsDOMClassInfoID.h" #include "nsIContent.h" #include "nsNameSpaceManager.h" #include "nsGkAtoms.h" -#include "nsAsyncDOMEvent.h" #include "nsEventDispatcher.h" #include "nsAutoPtr.h" #include "nsComponentManagerUtils.h" +using namespace mozilla; + // A helper class for managing our ranges of selection. struct nsTreeRange { nsTreeSelection* mSelection; nsTreeRange* mPrev; nsTreeRange* mNext; @@ -645,21 +647,22 @@ NS_IMETHODIMP nsTreeSelection::SetCurren boxObject->GetElement(getter_AddRefs(treeElt)); nsCOMPtr<nsINode> treeDOMNode(do_QueryInterface(treeElt)); NS_ENSURE_STATE(treeDOMNode); NS_NAMED_LITERAL_STRING(DOMMenuItemActive, "DOMMenuItemActive"); NS_NAMED_LITERAL_STRING(DOMMenuItemInactive, "DOMMenuItemInactive"); - nsRefPtr<nsAsyncDOMEvent> event = - new nsAsyncDOMEvent(treeDOMNode, - (aIndex != -1 ? DOMMenuItemActive : DOMMenuItemInactive), - true, false); - return event->PostDOMEvent(); + nsRefPtr<AsyncEventDispatcher> asyncDispatcher = + new AsyncEventDispatcher(treeDOMNode, + (aIndex != -1 ? DOMMenuItemActive : + DOMMenuItemInactive), + true, false); + return asyncDispatcher->PostDOMEvent(); } NS_IMETHODIMP nsTreeSelection::GetCurrentColumn(nsITreeColumn** aCurrentColumn) { NS_IF_ADDREF(*aCurrentColumn = mCurrentColumn); return NS_OK; } @@ -833,19 +836,19 @@ nsTreeSelection::FireOnSelectHandler() return NS_ERROR_UNEXPECTED; nsCOMPtr<nsIDOMElement> elt; boxObject->GetElement(getter_AddRefs(elt)); NS_ENSURE_STATE(elt); nsCOMPtr<nsINode> node(do_QueryInterface(elt)); NS_ENSURE_STATE(node); - nsRefPtr<nsAsyncDOMEvent> event = - new nsAsyncDOMEvent(node, NS_LITERAL_STRING("select"), true, false); - event->RunDOMEventWhenSafe(); + nsRefPtr<AsyncEventDispatcher> asyncDispatcher = + new AsyncEventDispatcher(node, NS_LITERAL_STRING("select"), true, false); + asyncDispatcher->RunDOMEventWhenSafe(); return NS_OK; } void nsTreeSelection::SelectCallback(nsITimer *aTimer, void *aClosure) { nsRefPtr<nsTreeSelection> self = static_cast<nsTreeSelection*>(aClosure); if (self) {