diff --git a/dom/base/ImportManager.cpp b/dom/base/ImportManager.cpp index 1f4d376b37b5..d0e514b59161 100644 --- a/dom/base/ImportManager.cpp +++ b/dom/base/ImportManager.cpp @@ -6,7 +6,6 @@ #include "ImportManager.h" -#include "mozilla/dom/ScriptLoader.h" #include "mozilla/EventListenerManager.h" #include "HTMLLinkElement.h" #include "nsContentPolicyUtils.h" @@ -19,6 +18,7 @@ #include "nsIDOMEvent.h" #include "nsIPrincipal.h" #include "nsIScriptObjectPrincipal.h" +#include "nsScriptLoader.h" #include "nsNetUtil.h" //----------------------------------------------------------------------------- @@ -156,7 +156,7 @@ ImportLoader::Updater::UpdateMainReferrer(uint32_t aNewIdx) // Our nearest predecessor has changed. So let's add the ScriptLoader to the // new one if there is any. And remove it from the old one. RefPtr manager = mLoader->Manager(); - ScriptLoader* loader = mLoader->mDocument->ScriptLoader(); + nsScriptLoader* loader = mLoader->mDocument->ScriptLoader(); ImportLoader*& pred = mLoader->mBlockingPredecessor; ImportLoader* newPred = manager->GetNearestPredecessor(newMainReferrer); if (pred) { @@ -339,7 +339,7 @@ ImportLoader::DispatchEventIfFinished(nsINode* aNode) } void -ImportLoader::AddBlockedScriptLoader(ScriptLoader* aScriptLoader) +ImportLoader::AddBlockedScriptLoader(nsScriptLoader* aScriptLoader) { if (mBlockedScriptLoaders.Contains(aScriptLoader)) { return; @@ -352,7 +352,7 @@ ImportLoader::AddBlockedScriptLoader(ScriptLoader* aScriptLoader) } bool -ImportLoader::RemoveBlockedScriptLoader(ScriptLoader* aScriptLoader) +ImportLoader::RemoveBlockedScriptLoader(nsScriptLoader* aScriptLoader) { aScriptLoader->RemoveParserBlockingScriptExecutionBlocker(); return mBlockedScriptLoaders.RemoveElement(aScriptLoader); diff --git a/dom/base/ImportManager.h b/dom/base/ImportManager.h index ccc00125ae58..258d4691cf7f 100644 --- a/dom/base/ImportManager.h +++ b/dom/base/ImportManager.h @@ -45,8 +45,8 @@ #include "nsIStreamListener.h" #include "nsIWeakReferenceUtils.h" #include "nsRefPtrHashtable.h" +#include "nsScriptLoader.h" #include "nsURIHashKey.h" -#include "mozilla/dom/ScriptLoader.h" class nsIDocument; class nsIPrincipal; @@ -184,8 +184,8 @@ public: // and wait for that to run its scripts. We keep track of all the // ScriptRunners that are waiting for this import. NOTE: updating // the main referrer might change this list. - void AddBlockedScriptLoader(ScriptLoader* aScriptLoader); - bool RemoveBlockedScriptLoader(ScriptLoader* aScriptLoader); + void AddBlockedScriptLoader(nsScriptLoader* aScriptLoader); + bool RemoveBlockedScriptLoader(nsScriptLoader* aScriptLoader); void SetBlockingPredecessor(ImportLoader* aLoader); private: @@ -230,7 +230,7 @@ private: // List of pending ScriptLoaders that are waiting for this import // to finish. - nsTArray> mBlockedScriptLoaders; + nsTArray> mBlockedScriptLoaders; // There is always exactly one referrer link that is flagged as // the main referrer the primary link. This is the one that is diff --git a/dom/base/Location.cpp b/dom/base/Location.cpp index f437250f20d3..6a269fe631e4 100644 --- a/dom/base/Location.cpp +++ b/dom/base/Location.cpp @@ -32,9 +32,9 @@ #include "mozilla/Likely.h" #include "nsCycleCollectionParticipant.h" #include "NullPrincipal.h" +#include "ScriptSettings.h" #include "mozilla/Unused.h" #include "mozilla/dom/LocationBinding.h" -#include "mozilla/dom/ScriptSettings.h" namespace mozilla { namespace dom { diff --git a/dom/script/ScriptSettings.cpp b/dom/base/ScriptSettings.cpp similarity index 100% rename from dom/script/ScriptSettings.cpp rename to dom/base/ScriptSettings.cpp diff --git a/dom/script/ScriptSettings.h b/dom/base/ScriptSettings.h similarity index 100% rename from dom/script/ScriptSettings.h rename to dom/base/ScriptSettings.h diff --git a/dom/base/moz.build b/dom/base/moz.build index 4b4f0063f49d..cc41636b3fbe 100644 --- a/dom/base/moz.build +++ b/dom/base/moz.build @@ -27,6 +27,7 @@ XPIDL_SOURCES += [ 'nsIObjectLoadingContent.idl', 'nsIRemoteWindowContext.idl', 'nsIScriptChannel.idl', + 'nsIScriptLoaderObserver.idl', 'nsISelection.idl', 'nsISelectionController.idl', 'nsISelectionDisplay.idl', @@ -91,6 +92,7 @@ EXPORTS += [ 'nsINode.h', 'nsINodeList.h', 'nsIScriptContext.h', + 'nsIScriptElement.h', 'nsIScriptGlobalObject.h', 'nsIScriptNameSpaceManager.h', 'nsIScriptObjectPrincipal.h', @@ -111,6 +113,7 @@ EXPORTS += [ 'nsRange.h', 'nsReferencedElement.h', 'nsSandboxFlags.h', + 'nsScriptLoader.h', 'nsStructuredCloneContainer.h', 'nsStubAnimationObserver.h', 'nsStubDocumentObserver.h', @@ -195,6 +198,7 @@ EXPORTS.mozilla.dom += [ 'ResponsiveImageSelector.h', 'SameProcessMessageQueue.h', 'ScreenOrientation.h', + 'ScriptSettings.h', 'ShadowRoot.h', 'StructuredCloneHolder.h', 'StructuredCloneTags.h', @@ -311,6 +315,8 @@ UNIFIED_SOURCES += [ 'nsRange.cpp', 'nsReferencedElement.cpp', 'nsScreen.cpp', + 'nsScriptElement.cpp', + 'nsScriptLoader.cpp', 'nsScriptNameSpaceManager.cpp', 'nsStructuredCloneContainer.cpp', 'nsStubAnimationObserver.cpp', @@ -337,6 +343,7 @@ UNIFIED_SOURCES += [ 'ResponsiveImageSelector.cpp', 'SameProcessMessageQueue.cpp', 'ScreenOrientation.cpp', + 'ScriptSettings.cpp', 'ShadowRoot.cpp', 'StructuredCloneHolder.cpp', 'StyleSheetList.cpp', diff --git a/dom/base/nsContentPermissionHelper.cpp b/dom/base/nsContentPermissionHelper.cpp index 535262a3f437..49b58aebed10 100644 --- a/dom/base/nsContentPermissionHelper.cpp +++ b/dom/base/nsContentPermissionHelper.cpp @@ -32,6 +32,7 @@ #include "nsIDocument.h" #include "nsIDOMEvent.h" #include "nsWeakPtr.h" +#include "ScriptSettings.h" using mozilla::Unused; // using namespace mozilla::dom; diff --git a/dom/base/nsContentSink.cpp b/dom/base/nsContentSink.cpp index 0c94aec06920..762b49ab8883 100644 --- a/dom/base/nsContentSink.cpp +++ b/dom/base/nsContentSink.cpp @@ -10,6 +10,7 @@ */ #include "nsContentSink.h" +#include "nsScriptLoader.h" #include "nsIDocument.h" #include "nsIDOMDocument.h" #include "mozilla/css/Loader.h" @@ -48,7 +49,6 @@ #include "nsHTMLDNSPrefetch.h" #include "nsIObserverService.h" #include "mozilla/Preferences.h" -#include "mozilla/dom/ScriptLoader.h" #include "nsParserConstants.h" #include "nsSandboxFlags.h" diff --git a/dom/base/nsContentSink.h b/dom/base/nsContentSink.h index ae5c5e92eab7..af211ae462a2 100644 --- a/dom/base/nsContentSink.h +++ b/dom/base/nsContentSink.h @@ -36,16 +36,13 @@ class nsIAtom; class nsIChannel; class nsIContent; class nsNodeInfoManager; +class nsScriptLoader; class nsIApplicationCache; namespace mozilla { namespace css { class Loader; } // namespace css - -namespace dom { -class ScriptLoader; -} // namespace dom } // namespace mozilla #ifdef DEBUG @@ -279,7 +276,7 @@ protected: nsCOMPtr mDocShell; RefPtr mCSSLoader; RefPtr mNodeInfoManager; - RefPtr mScriptLoader; + RefPtr mScriptLoader; // back off timer notification after count int32_t mBackoffCount; diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index af9ea0adbdf5..7068149e2f48 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -2026,7 +2026,7 @@ nsDocument::Init() mScopeObject = do_GetWeakReference(global); MOZ_ASSERT(mScopeObject); - mScriptLoader = new dom::ScriptLoader(this); + mScriptLoader = new nsScriptLoader(this); mozilla::HoldJSObjects(this); @@ -5011,7 +5011,7 @@ nsDocument::GetWindowInternal() const return win; } -ScriptLoader* +nsScriptLoader* nsDocument::ScriptLoader() { return mScriptLoader; diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h index 8a1663e4c78b..c3efcef6f1a4 100644 --- a/dom/base/nsDocument.h +++ b/dom/base/nsDocument.h @@ -31,6 +31,7 @@ #include "nsJSThingHashtable.h" #include "nsIScriptObjectPrincipal.h" #include "nsIURI.h" +#include "nsScriptLoader.h" #include "nsIRadioGroupContainer.h" #include "nsILayoutHistoryState.h" #include "nsIRequest.h" @@ -59,7 +60,6 @@ #include "mozilla/MemoryReporting.h" #include "mozilla/PendingAnimationTracker.h" #include "mozilla/dom/DOMImplementation.h" -#include "mozilla/dom/ScriptLoader.h" #include "mozilla/dom/StyleSheetList.h" #include "nsDataHashtable.h" #include "mozilla/TimeStamp.h" @@ -742,7 +742,7 @@ public: /** * Get the script loader for this document */ - virtual mozilla::dom::ScriptLoader* ScriptLoader() override; + virtual nsScriptLoader* ScriptLoader() override; /** * Add/Remove an element to the document's id and name hashes @@ -1492,7 +1492,7 @@ public: RefPtr mListenerManager; RefPtr mDOMStyleSheets; RefPtr mStyleSheetSetList; - RefPtr mScriptLoader; + RefPtr mScriptLoader; nsDocHeaderData* mHeaderData; /* mIdentifierMap works as follows for IDs: * 1) Attribute changes affect the table immediately (removing and adding diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager.cpp index 6ef8a12bd90b..ae3c54f3f322 100644 --- a/dom/base/nsFrameMessageManager.cpp +++ b/dom/base/nsFrameMessageManager.cpp @@ -18,7 +18,7 @@ #include "nsJSUtils.h" #include "nsJSPrincipals.h" #include "nsNetUtil.h" -#include "mozilla/dom/ScriptLoader.h" +#include "nsScriptLoader.h" #include "nsFrameLoader.h" #include "nsIInputStream.h" #include "nsIXULRuntime.h" @@ -1640,9 +1640,9 @@ nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript( if (NS_FAILED(NS_ReadInputStreamToString(input, buffer, avail))) { return; } - ScriptLoader::ConvertToUTF16(channel, (uint8_t*)buffer.get(), avail, - EmptyString(), nullptr, - dataStringBuf, dataStringLength); + nsScriptLoader::ConvertToUTF16(channel, (uint8_t*)buffer.get(), avail, + EmptyString(), nullptr, + dataStringBuf, dataStringLength); } JS::SourceBufferHolder srcBuf(dataStringBuf, dataStringLength, diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 20d71578cace..d9fc5f615495 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -64,7 +64,7 @@ #include "nsReadableUtils.h" #include "nsDOMClassInfo.h" #include "nsJSEnvironment.h" -#include "mozilla/dom/ScriptSettings.h" +#include "ScriptSettings.h" #include "mozilla/Preferences.h" #include "mozilla/Likely.h" #include "mozilla/Sprintf.h" diff --git a/dom/base/nsIDocument.h b/dom/base/nsIDocument.h index 930943082cbe..5b4955952fd2 100644 --- a/dom/base/nsIDocument.h +++ b/dom/base/nsIDocument.h @@ -92,6 +92,7 @@ class nsIVariant; class nsViewManager; class nsPresContext; class nsRange; +class nsScriptLoader; class nsSMILAnimationController; class nsSVGElement; class nsTextNode; @@ -153,7 +154,6 @@ class NodeIterator; enum class OrientationType : uint8_t; class ProcessingInstruction; class Promise; -class ScriptLoader; class StyleSheetList; class SVGDocument; class SVGSVGElement; @@ -1368,7 +1368,7 @@ public: /** * Get the script loader for this document */ - virtual mozilla::dom::ScriptLoader* ScriptLoader() = 0; + virtual nsScriptLoader* ScriptLoader() = 0; /** * Add/Remove an element to the document's id and name hashes diff --git a/dom/script/nsIScriptElement.h b/dom/base/nsIScriptElement.h similarity index 100% rename from dom/script/nsIScriptElement.h rename to dom/base/nsIScriptElement.h diff --git a/dom/script/nsIScriptLoaderObserver.idl b/dom/base/nsIScriptLoaderObserver.idl similarity index 100% rename from dom/script/nsIScriptLoaderObserver.idl rename to dom/base/nsIScriptLoaderObserver.idl diff --git a/dom/base/nsInProcessTabChildGlobal.cpp b/dom/base/nsInProcessTabChildGlobal.cpp index 302e6eaef1fd..ca2f4be6f9cd 100644 --- a/dom/base/nsInProcessTabChildGlobal.cpp +++ b/dom/base/nsInProcessTabChildGlobal.cpp @@ -11,13 +11,13 @@ #include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsComponentManagerUtils.h" +#include "nsScriptLoader.h" #include "nsFrameLoader.h" #include "xpcpublic.h" #include "nsIMozBrowserFrame.h" #include "nsDOMClassInfoID.h" #include "mozilla/EventDispatcher.h" #include "mozilla/dom/SameProcessMessageQueue.h" -#include "mozilla/dom/ScriptLoader.h" using namespace mozilla; using namespace mozilla::dom; diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index 606f76859314..8946d75a9833 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -37,6 +37,7 @@ #include "nsXPCOMCIDInternal.h" #include "nsIXULRuntime.h" #include "nsTextFormatter.h" +#include "ScriptSettings.h" #ifdef XP_WIN #include #define getpid _getpid @@ -59,7 +60,6 @@ #include "mozilla/dom/DOMException.h" #include "mozilla/dom/DOMExceptionBinding.h" #include "mozilla/dom/ErrorEvent.h" -#include "mozilla/dom/ScriptSettings.h" #include "nsAXPCNativeCallContext.h" #include "mozilla/CycleCollectedJSRuntime.h" #include "mozilla/SystemGroup.h" diff --git a/dom/script/ScriptElement.cpp b/dom/base/nsScriptElement.cpp similarity index 64% rename from dom/script/ScriptElement.cpp rename to dom/base/nsScriptElement.cpp index 0cb17dcb0656..ebeb18f81cb2 100644 --- a/dom/script/ScriptElement.cpp +++ b/dom/base/nsScriptElement.cpp @@ -4,13 +4,13 @@ * 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 "ScriptElement.h" -#include "ScriptLoader.h" +#include "nsScriptElement.h" #include "mozilla/BasicEvents.h" #include "mozilla/EventDispatcher.h" #include "mozilla/dom/Element.h" #include "nsContentUtils.h" #include "nsPresContext.h" +#include "nsScriptLoader.h" #include "nsIParser.h" #include "nsGkAtoms.h" #include "nsContentSink.h" @@ -19,11 +19,11 @@ using namespace mozilla; using namespace mozilla::dom; NS_IMETHODIMP -ScriptElement::ScriptAvailable(nsresult aResult, - nsIScriptElement *aElement, - bool aIsInline, - nsIURI *aURI, - int32_t aLineNo) +nsScriptElement::ScriptAvailable(nsresult aResult, + nsIScriptElement *aElement, + bool aIsInline, + nsIURI *aURI, + int32_t aLineNo) { if (!aIsInline && NS_FAILED(aResult)) { nsCOMPtr parser = do_QueryReferent(mCreatorParser); @@ -40,7 +40,7 @@ ScriptElement::ScriptAvailable(nsresult aResult, } /* virtual */ nsresult -ScriptElement::FireErrorEvent() +nsScriptElement::FireErrorEvent() { nsCOMPtr cont = do_QueryInterface((nsIScriptElement*) this); @@ -53,9 +53,9 @@ ScriptElement::FireErrorEvent() } NS_IMETHODIMP -ScriptElement::ScriptEvaluated(nsresult aResult, - nsIScriptElement *aElement, - bool aIsInline) +nsScriptElement::ScriptEvaluated(nsresult aResult, + nsIScriptElement *aElement, + bool aIsInline) { nsresult rv = NS_OK; if (!aIsInline) { @@ -78,44 +78,44 @@ ScriptElement::ScriptEvaluated(nsresult aResult, } void -ScriptElement::CharacterDataChanged(nsIDocument *aDocument, - nsIContent* aContent, - CharacterDataChangeInfo* aInfo) +nsScriptElement::CharacterDataChanged(nsIDocument *aDocument, + nsIContent* aContent, + CharacterDataChangeInfo* aInfo) { MaybeProcessScript(); } void -ScriptElement::AttributeChanged(nsIDocument* aDocument, - Element* aElement, - int32_t aNameSpaceID, - nsIAtom* aAttribute, - int32_t aModType, - const nsAttrValue* aOldValue) +nsScriptElement::AttributeChanged(nsIDocument* aDocument, + Element* aElement, + int32_t aNameSpaceID, + nsIAtom* aAttribute, + int32_t aModType, + const nsAttrValue* aOldValue) { MaybeProcessScript(); } void -ScriptElement::ContentAppended(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aFirstNewContent, - int32_t aNewIndexInContainer) +nsScriptElement::ContentAppended(nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aFirstNewContent, + int32_t aNewIndexInContainer) { MaybeProcessScript(); } void -ScriptElement::ContentInserted(nsIDocument *aDocument, - nsIContent* aContainer, - nsIContent* aChild, - int32_t aIndexInContainer) +nsScriptElement::ContentInserted(nsIDocument *aDocument, + nsIContent* aContainer, + nsIContent* aChild, + int32_t aIndexInContainer) { MaybeProcessScript(); } bool -ScriptElement::MaybeProcessScript() +nsScriptElement::MaybeProcessScript() { nsCOMPtr cont = do_QueryInterface((nsIScriptElement*) this); @@ -145,6 +145,6 @@ ScriptElement::MaybeProcessScript() } } - RefPtr loader = ownerDoc->ScriptLoader(); + RefPtr loader = ownerDoc->ScriptLoader(); return loader->ProcessScriptElement(this); } diff --git a/dom/script/ScriptElement.h b/dom/base/nsScriptElement.h similarity index 78% rename from dom/script/ScriptElement.h rename to dom/base/nsScriptElement.h index 0babda674af1..4a2a584ac2e7 100644 --- a/dom/script/ScriptElement.h +++ b/dom/base/nsScriptElement.h @@ -4,25 +4,22 @@ * 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_ScriptElement_h -#define mozilla_dom_ScriptElement_h +#ifndef nsScriptElement_h +#define nsScriptElement_h #include "mozilla/Attributes.h" #include "nsIScriptLoaderObserver.h" #include "nsIScriptElement.h" #include "nsStubMutationObserver.h" -namespace mozilla { -namespace dom { - /** * Baseclass useful for script elements (such as and * ). Currently the class assumes that only the 'src' * attribute and the children of the class affect what script to execute. */ -class ScriptElement : public nsIScriptElement, - public nsStubMutationObserver +class nsScriptElement : public nsIScriptElement, + public nsStubMutationObserver { public: // nsIScriptLoaderObserver @@ -34,7 +31,7 @@ public: NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED - explicit ScriptElement(FromParser aFromParser) + explicit nsScriptElement(mozilla::dom::FromParser aFromParser) : nsIScriptElement(aFromParser) { } @@ -52,7 +49,4 @@ protected: virtual bool MaybeProcessScript() override; }; -} // dom namespace -} // mozilla namespace - -#endif // mozilla_dom_ScriptElement_h +#endif // nsScriptElement_h diff --git a/dom/script/ScriptLoader.cpp b/dom/base/nsScriptLoader.cpp similarity index 86% rename from dom/script/ScriptLoader.cpp rename to dom/base/nsScriptLoader.cpp index f90c30bd021f..5a5ebf5802a0 100644 --- a/dom/script/ScriptLoader.cpp +++ b/dom/base/nsScriptLoader.cpp @@ -8,7 +8,7 @@ * A class that handles loading and evaluation of