summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-06-30 11:32:07 +0000
committerMoonchild <moonchild@palemoon.org>2020-06-30 11:51:11 +0000
commitc45b7ee3a985b2b4862fb182cdb34f644f737048 (patch)
tree53da33f85383ce934145da45b1ad4963b8e94f35
parentc7330b5eb48cdd69b06e5f55643ea4c94303381f (diff)
downloaduxp-c45b7ee3a985b2b4862fb182cdb34f644f737048.tar.gz
Issue #1603 - Part 1: Reorganize ScriptLoader/ScriptElement
- Moves scripting parts of DOM into 'dom/script' - Renames nsScript{Loader/Element} to Script{Loader/Element} - Adjusts all callers
-rw-r--r--dom/base/ImportManager.cpp8
-rw-r--r--dom/base/ImportManager.h8
-rw-r--r--dom/base/Location.cpp2
-rwxr-xr-xdom/base/moz.build7
-rw-r--r--dom/base/nsContentPermissionHelper.cpp3
-rw-r--r--dom/base/nsContentSink.cpp2
-rw-r--r--dom/base/nsContentSink.h7
-rw-r--r--dom/base/nsDocument.cpp4
-rw-r--r--dom/base/nsDocument.h6
-rw-r--r--dom/base/nsFrameMessageManager.cpp8
-rw-r--r--dom/base/nsGlobalWindow.cpp2
-rw-r--r--dom/base/nsIDocument.h4
-rw-r--r--dom/base/nsInProcessTabChildGlobal.cpp2
-rw-r--r--dom/base/nsJSEnvironment.cpp2
-rwxr-xr-xdom/console/Console.cpp2
-rw-r--r--dom/events/DOMEventTargetHelper.cpp2
-rw-r--r--dom/html/HTMLScriptElement.cpp2
-rw-r--r--dom/html/HTMLScriptElement.h7
-rw-r--r--dom/html/nsGenericHTMLElement.cpp2
-rw-r--r--dom/html/nsHTMLContentSink.cpp2
-rw-r--r--dom/messagechannel/MessagePort.cpp2
-rw-r--r--dom/moz.build1
-rw-r--r--dom/script/ScriptElement.cpp (renamed from dom/base/nsScriptElement.cpp)60
-rw-r--r--dom/script/ScriptElement.h (renamed from dom/base/nsScriptElement.h)18
-rw-r--r--dom/script/ScriptLoader.cpp (renamed from dom/base/nsScriptLoader.cpp)574
-rw-r--r--dom/script/ScriptLoader.h (renamed from dom/base/nsScriptLoader.h)190
-rw-r--r--dom/script/ScriptSettings.cpp (renamed from dom/base/ScriptSettings.cpp)0
-rw-r--r--dom/script/ScriptSettings.h (renamed from dom/base/ScriptSettings.h)0
-rw-r--r--dom/script/moz.build33
-rw-r--r--dom/script/nsIScriptElement.h (renamed from dom/base/nsIScriptElement.h)0
-rw-r--r--dom/script/nsIScriptLoaderObserver.idl (renamed from dom/base/nsIScriptLoaderObserver.idl)0
-rw-r--r--dom/svg/SVGScriptElement.cpp4
-rw-r--r--dom/svg/SVGScriptElement.h6
-rw-r--r--dom/workers/ScriptLoader.cpp20
-rw-r--r--dom/workers/ServiceWorkerManager.cpp2
-rw-r--r--dom/workers/ServiceWorkerScriptCache.cpp14
-rw-r--r--dom/worklet/Worklet.cpp8
-rw-r--r--dom/xml/nsXMLContentSink.cpp2
-rw-r--r--dom/xml/nsXMLFragmentContentSink.cpp2
-rw-r--r--dom/xslt/xslt/txMozillaXMLOutput.cpp8
-rw-r--r--dom/xul/XULDocument.cpp8
-rw-r--r--dom/xul/XULDocument.h2
-rw-r--r--dom/xul/nsXULContentSink.cpp2
-rw-r--r--js/xpconnect/loader/mozJSSubScriptLoader.cpp12
-rw-r--r--js/xpconnect/src/XPCJSContext.cpp6
-rw-r--r--parser/html/nsHtml5DocumentBuilder.cpp2
-rw-r--r--parser/html/nsHtml5OplessBuilder.cpp2
-rw-r--r--parser/html/nsHtml5TreeOpExecutor.cpp2
-rw-r--r--parser/html/nsParserUtils.cpp4
-rw-r--r--parser/htmlparser/nsParser.cpp2
50 files changed, 554 insertions, 514 deletions
diff --git a/dom/base/ImportManager.cpp b/dom/base/ImportManager.cpp
index d0e514b591..1f4d376b37 100644
--- a/dom/base/ImportManager.cpp
+++ b/dom/base/ImportManager.cpp
@@ -6,6 +6,7 @@
#include "ImportManager.h"
+#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/EventListenerManager.h"
#include "HTMLLinkElement.h"
#include "nsContentPolicyUtils.h"
@@ -18,7 +19,6 @@
#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<ImportManager> manager = mLoader->Manager();
- nsScriptLoader* loader = mLoader->mDocument->ScriptLoader();
+ ScriptLoader* 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(nsScriptLoader* aScriptLoader)
+ImportLoader::AddBlockedScriptLoader(ScriptLoader* aScriptLoader)
{
if (mBlockedScriptLoaders.Contains(aScriptLoader)) {
return;
@@ -352,7 +352,7 @@ ImportLoader::AddBlockedScriptLoader(nsScriptLoader* aScriptLoader)
}
bool
-ImportLoader::RemoveBlockedScriptLoader(nsScriptLoader* aScriptLoader)
+ImportLoader::RemoveBlockedScriptLoader(ScriptLoader* aScriptLoader)
{
aScriptLoader->RemoveParserBlockingScriptExecutionBlocker();
return mBlockedScriptLoaders.RemoveElement(aScriptLoader);
diff --git a/dom/base/ImportManager.h b/dom/base/ImportManager.h
index 258d4691cf..ccc00125ae 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(nsScriptLoader* aScriptLoader);
- bool RemoveBlockedScriptLoader(nsScriptLoader* aScriptLoader);
+ void AddBlockedScriptLoader(ScriptLoader* aScriptLoader);
+ bool RemoveBlockedScriptLoader(ScriptLoader* aScriptLoader);
void SetBlockingPredecessor(ImportLoader* aLoader);
private:
@@ -230,7 +230,7 @@ private:
// List of pending ScriptLoaders that are waiting for this import
// to finish.
- nsTArray<RefPtr<nsScriptLoader>> mBlockedScriptLoaders;
+ nsTArray<RefPtr<ScriptLoader>> 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 1483c32f9d..308e9a4ff6 100644
--- a/dom/base/Location.cpp
+++ b/dom/base/Location.cpp
@@ -32,9 +32,9 @@
#include "mozilla/Likely.h"
#include "nsCycleCollectionParticipant.h"
#include "nsNullPrincipal.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/base/moz.build b/dom/base/moz.build
index cedaa0e49d..ded203c505 100755
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -26,7 +26,6 @@ XPIDL_SOURCES += [
'nsIObjectLoadingContent.idl',
'nsIRemoteWindowContext.idl',
'nsIScriptChannel.idl',
- 'nsIScriptLoaderObserver.idl',
'nsISelection.idl',
'nsISelectionController.idl',
'nsISelectionDisplay.idl',
@@ -97,7 +96,6 @@ EXPORTS += [
'nsINode.h',
'nsINodeList.h',
'nsIScriptContext.h',
- 'nsIScriptElement.h',
'nsIScriptGlobalObject.h',
'nsIScriptNameSpaceManager.h',
'nsIScriptObjectPrincipal.h',
@@ -118,7 +116,6 @@ EXPORTS += [
'nsRange.h',
'nsReferencedElement.h',
'nsSandboxFlags.h',
- 'nsScriptLoader.h',
'nsStructuredCloneContainer.h',
'nsStubAnimationObserver.h',
'nsStubDocumentObserver.h',
@@ -210,7 +207,6 @@ EXPORTS.mozilla.dom += [
'ResponsiveImageSelector.h',
'SameProcessMessageQueue.h',
'ScreenOrientation.h',
- 'ScriptSettings.h',
'ShadowRoot.h',
'SimpleTreeIterator.h',
'StructuredCloneHolder.h',
@@ -331,8 +327,6 @@ SOURCES += [
'nsRange.cpp',
'nsReferencedElement.cpp',
'nsScreen.cpp',
- 'nsScriptElement.cpp',
- 'nsScriptLoader.cpp',
'nsScriptNameSpaceManager.cpp',
'nsStructuredCloneContainer.cpp',
'nsStubAnimationObserver.cpp',
@@ -359,7 +353,6 @@ 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 c57fc6233b..eaaec2a412 100644
--- a/dom/base/nsContentPermissionHelper.cpp
+++ b/dom/base/nsContentPermissionHelper.cpp
@@ -29,9 +29,8 @@
#include "nsIDocument.h"
#include "nsIDOMEvent.h"
#include "nsWeakPtr.h"
-#include "ScriptSettings.h"
-using mozilla::Unused; // <snicker>
+using mozilla::Unused;
using namespace mozilla::dom;
using namespace mozilla;
diff --git a/dom/base/nsContentSink.cpp b/dom/base/nsContentSink.cpp
index 490f0ec17c..1e6465a1bf 100644
--- a/dom/base/nsContentSink.cpp
+++ b/dom/base/nsContentSink.cpp
@@ -10,7 +10,6 @@
*/
#include "nsContentSink.h"
-#include "nsScriptLoader.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "mozilla/css/Loader.h"
@@ -49,6 +48,7 @@
#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 b1a7588740..2d914a8d7b 100644
--- a/dom/base/nsContentSink.h
+++ b/dom/base/nsContentSink.h
@@ -36,13 +36,16 @@ 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
@@ -273,7 +276,7 @@ protected:
nsCOMPtr<nsIDocShell> mDocShell;
RefPtr<mozilla::css::Loader> mCSSLoader;
RefPtr<nsNodeInfoManager> mNodeInfoManager;
- RefPtr<nsScriptLoader> mScriptLoader;
+ RefPtr<mozilla::dom::ScriptLoader> mScriptLoader;
// back off timer notification after count
int32_t mBackoffCount;
diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp
index 40bfa97e2a..dc4b23f2ce 100644
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -1834,7 +1834,7 @@ nsDocument::Init()
mScopeObject = do_GetWeakReference(global);
MOZ_ASSERT(mScopeObject);
- mScriptLoader = new nsScriptLoader(this);
+ mScriptLoader = new dom::ScriptLoader(this);
mozilla::HoldJSObjects(this);
@@ -4623,7 +4623,7 @@ nsDocument::GetWindowInternal() const
return win;
}
-nsScriptLoader*
+ScriptLoader*
nsDocument::ScriptLoader()
{
return mScriptLoader;
diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h
index 9d7b0aafd1..502ba0f133 100644
--- a/dom/base/nsDocument.h
+++ b/dom/base/nsDocument.h
@@ -32,7 +32,6 @@
#include "nsJSThingHashtable.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsIURI.h"
-#include "nsScriptLoader.h"
#include "nsIRadioGroupContainer.h"
#include "nsILayoutHistoryState.h"
#include "nsIRequest.h"
@@ -61,6 +60,7 @@
#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"
@@ -491,7 +491,7 @@ public:
/**
* Get the script loader for this document
*/
- virtual nsScriptLoader* ScriptLoader() override;
+ virtual mozilla::dom::ScriptLoader* ScriptLoader() override;
/**
* Add/Remove an element to the document's id and name hashes
@@ -1205,7 +1205,7 @@ protected:
public:
RefPtr<mozilla::EventListenerManager> mListenerManager;
RefPtr<nsDOMStyleSheetSetList> mStyleSheetSetList;
- RefPtr<nsScriptLoader> mScriptLoader;
+ RefPtr<mozilla::dom::ScriptLoader> mScriptLoader;
nsDocHeaderData* mHeaderData;
nsClassHashtable<nsStringHashKey, nsRadioGroupStruct> mRadioGroups;
diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager.cpp
index bba4232aa8..331931f19d 100644
--- a/dom/base/nsFrameMessageManager.cpp
+++ b/dom/base/nsFrameMessageManager.cpp
@@ -19,7 +19,6 @@
#include "nsJSUtils.h"
#include "nsJSPrincipals.h"
#include "nsNetUtil.h"
-#include "nsScriptLoader.h"
#include "nsFrameLoader.h"
#include "nsIXULRuntime.h"
#include "nsIScriptError.h"
@@ -38,6 +37,7 @@
#include "mozilla/dom/PermissionMessageUtils.h"
#include "mozilla/dom/ProcessGlobal.h"
#include "mozilla/dom/SameProcessMessageQueue.h"
+#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/ipc/BlobChild.h"
#include "mozilla/dom/ipc/BlobParent.h"
@@ -1786,9 +1786,9 @@ nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
if (NS_FAILED(NS_ReadInputStreamToString(input, buffer, avail))) {
return;
}
- nsScriptLoader::ConvertToUTF16(channel, (uint8_t*)buffer.get(), avail,
- EmptyString(), nullptr,
- dataStringBuf, dataStringLength);
+ ScriptLoader::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 69643762c5..acd596a442 100644
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -62,7 +62,7 @@
#include "nsReadableUtils.h"
#include "nsDOMClassInfo.h"
#include "nsJSEnvironment.h"
-#include "ScriptSettings.h"
+#include "mozilla/dom/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 d88db84237..33aac3a3d6 100644
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -93,7 +93,6 @@ class nsIVariant;
class nsViewManager;
class nsPresContext;
class nsRange;
-class nsScriptLoader;
class nsSMILAnimationController;
class nsTextNode;
class nsWindowSizes;
@@ -153,6 +152,7 @@ enum class OrientationType : uint32_t;
class ProcessingInstruction;
class Promise;
class Selection;
+class ScriptLoader;
class StyleSheetList;
class SVGDocument;
class SVGSVGElement;
@@ -1278,7 +1278,7 @@ public:
/**
* Get the script loader for this document
*/
- virtual nsScriptLoader* ScriptLoader() = 0;
+ virtual mozilla::dom::ScriptLoader* ScriptLoader() = 0;
/**
* Add/Remove an element to the document's id and name hashes
diff --git a/dom/base/nsInProcessTabChildGlobal.cpp b/dom/base/nsInProcessTabChildGlobal.cpp
index 9885b41a83..4cc3c9ce99 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 efea3ee401..605b1917fd 100644
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -37,7 +37,6 @@
#include "nsXPCOMCIDInternal.h"
#include "nsIXULRuntime.h"
#include "nsTextFormatter.h"
-#include "ScriptSettings.h"
#include "xpcpublic.h"
@@ -55,6 +54,7 @@
#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/CycleCollectedJSContext.h"
#include "mozilla/Telemetry.h"
diff --git a/dom/console/Console.cpp b/dom/console/Console.cpp
index b174172e01..119a259fe0 100755
--- a/dom/console/Console.cpp
+++ b/dom/console/Console.cpp
@@ -12,6 +12,7 @@
#include "mozilla/dom/File.h"
#include "mozilla/dom/FunctionBinding.h"
#include "mozilla/dom/Performance.h"
+#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/StructuredCloneHolder.h"
#include "mozilla/dom/ToJSValue.h"
#include "mozilla/dom/WorkletGlobalScope.h"
@@ -22,7 +23,6 @@
#include "nsGlobalWindow.h"
#include "nsJSUtils.h"
#include "nsNetUtil.h"
-#include "ScriptSettings.h"
#include "WorkerPrivate.h"
#include "WorkerRunnable.h"
#include "WorkerScope.h"
diff --git a/dom/events/DOMEventTargetHelper.cpp b/dom/events/DOMEventTargetHelper.cpp
index f534f119c7..3d162b01ec 100644
--- a/dom/events/DOMEventTargetHelper.cpp
+++ b/dom/events/DOMEventTargetHelper.cpp
@@ -8,7 +8,7 @@
#include "nsIDocument.h"
#include "mozilla/Sprintf.h"
#include "nsGlobalWindow.h"
-#include "ScriptSettings.h"
+#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventListenerManager.h"
diff --git a/dom/html/HTMLScriptElement.cpp b/dom/html/HTMLScriptElement.cpp
index a1bea94d97..5b727280f5 100644
--- a/dom/html/HTMLScriptElement.cpp
+++ b/dom/html/HTMLScriptElement.cpp
@@ -37,7 +37,7 @@ HTMLScriptElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
HTMLScriptElement::HTMLScriptElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
FromParser aFromParser)
: nsGenericHTMLElement(aNodeInfo)
- , nsScriptElement(aFromParser)
+ , ScriptElement(aFromParser)
{
AddMutationObserver(this);
}
diff --git a/dom/html/HTMLScriptElement.h b/dom/html/HTMLScriptElement.h
index bd446fa97d..6edeb98322 100644
--- a/dom/html/HTMLScriptElement.h
+++ b/dom/html/HTMLScriptElement.h
@@ -8,16 +8,16 @@
#define mozilla_dom_HTMLScriptElement_h
#include "nsIDOMHTMLScriptElement.h"
-#include "nsScriptElement.h"
#include "nsGenericHTMLElement.h"
#include "mozilla/Attributes.h"
+#include "mozilla/dom/ScriptElement.h"
namespace mozilla {
namespace dom {
class HTMLScriptElement final : public nsGenericHTMLElement,
public nsIDOMHTMLScriptElement,
- public nsScriptElement
+ public ScriptElement
{
public:
using Element::GetText;
@@ -98,7 +98,8 @@ protected:
virtual ~HTMLScriptElement();
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
- // nsScriptElement
+
+ // ScriptElement
virtual bool HasScriptContent() override;
};
diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp
index 17dba6da98..b52e61ce6e 100644
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -48,7 +48,6 @@
#include "nsIDocShell.h"
#include "nsNameSpaceManager.h"
#include "nsError.h"
-#include "nsScriptLoader.h"
#include "nsRuleData.h"
#include "nsIPrincipal.h"
#include "nsContainerFrame.h"
@@ -92,6 +91,7 @@
#include "mozilla/dom/FromParser.h"
#include "mozilla/dom/Link.h"
#include "mozilla/BloomFilter.h"
+#include "mozilla/dom/ScriptLoader.h"
#include "nsVariant.h"
#include "nsDOMTokenList.h"
diff --git a/dom/html/nsHTMLContentSink.cpp b/dom/html/nsHTMLContentSink.cpp
index eb22b772f9..f7e380f407 100644
--- a/dom/html/nsHTMLContentSink.cpp
+++ b/dom/html/nsHTMLContentSink.cpp
@@ -20,10 +20,10 @@
#include "nsIHTMLContentSink.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
-#include "nsScriptLoader.h"
#include "nsIURI.h"
#include "nsIContentViewer.h"
#include "mozilla/dom/NodeInfo.h"
+#include "mozilla/dom/ScriptLoader.h"
#include "nsToken.h"
#include "nsIAppShell.h"
#include "nsCRT.h"
diff --git a/dom/messagechannel/MessagePort.cpp b/dom/messagechannel/MessagePort.cpp
index 56204da995..fcbe36a723 100644
--- a/dom/messagechannel/MessagePort.cpp
+++ b/dom/messagechannel/MessagePort.cpp
@@ -16,6 +16,7 @@
#include "mozilla/dom/MessagePortBinding.h"
#include "mozilla/dom/MessagePortChild.h"
#include "mozilla/dom/PMessagePort.h"
+#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/StructuredCloneTags.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerScope.h"
@@ -28,7 +29,6 @@
#include "nsContentUtils.h"
#include "nsGlobalWindow.h"
#include "nsPresContext.h"
-#include "ScriptSettings.h"
#include "SharedMessagePortMessage.h"
#include "nsIBFCacheEntry.h"
diff --git a/dom/moz.build b/dom/moz.build
index 8a958982f3..7888ccd69f 100644
--- a/dom/moz.build
+++ b/dom/moz.build
@@ -100,6 +100,7 @@ DIRS += [
'performance',
'xhr',
'worklet',
+ 'script',
]
if CONFIG['OS_ARCH'] == 'WINNT':
diff --git a/dom/base/nsScriptElement.cpp b/dom/script/ScriptElement.cpp
index ebeb18f81c..0cb17dcb06 100644
--- a/dom/base/nsScriptElement.cpp
+++ b/dom/script/ScriptElement.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 "nsScriptElement.h"
+#include "ScriptElement.h"
+#include "ScriptLoader.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
-nsScriptElement::ScriptAvailable(nsresult aResult,
- nsIScriptElement *aElement,
- bool aIsInline,
- nsIURI *aURI,
- int32_t aLineNo)
+ScriptElement::ScriptAvailable(nsresult aResult,
+ nsIScriptElement *aElement,
+ bool aIsInline,
+ nsIURI *aURI,
+ int32_t aLineNo)
{
if (!aIsInline && NS_FAILED(aResult)) {
nsCOMPtr<nsIParser> parser = do_QueryReferent(mCreatorParser);
@@ -40,7 +40,7 @@ nsScriptElement::ScriptAvailable(nsresult aResult,
}
/* virtual */ nsresult
-nsScriptElement::FireErrorEvent()
+ScriptElement::FireErrorEvent()
{
nsCOMPtr<nsIContent> cont =
do_QueryInterface((nsIScriptElement*) this);
@@ -53,9 +53,9 @@ nsScriptElement::FireErrorEvent()
}
NS_IMETHODIMP
-nsScriptElement::ScriptEvaluated(nsresult aResult,
- nsIScriptElement *aElement,
- bool aIsInline)
+ScriptElement::ScriptEvaluated(nsresult aResult,
+ nsIScriptElement *aElement,
+ bool aIsInline)
{
nsresult rv = NS_OK;
if (!aIsInline) {
@@ -78,44 +78,44 @@ nsScriptElement::ScriptEvaluated(nsresult aResult,
}
void
-nsScriptElement::CharacterDataChanged(nsIDocument *aDocument,
- nsIContent* aContent,
- CharacterDataChangeInfo* aInfo)
+ScriptElement::CharacterDataChanged(nsIDocument *aDocument,
+ nsIContent* aContent,
+ CharacterDataChangeInfo* aInfo)
{
MaybeProcessScript();
}
void
-nsScriptElement::AttributeChanged(nsIDocument* aDocument,
- Element* aElement,
- int32_t aNameSpaceID,
- nsIAtom* aAttribute,
- int32_t aModType,
- const nsAttrValue* aOldValue)
+ScriptElement::AttributeChanged(nsIDocument* aDocument,
+ Element* aElement,
+ int32_t aNameSpaceID,
+ nsIAtom* aAttribute,
+ int32_t aModType,
+ const nsAttrValue* aOldValue)
{
MaybeProcessScript();
}
void
-nsScriptElement::ContentAppended(nsIDocument* aDocument,
- nsIContent* aContainer,
- nsIContent* aFirstNewContent,
- int32_t aNewIndexInContainer)
+ScriptElement::ContentAppended(nsIDocument* aDocument,
+ nsIContent* aContainer,
+ nsIContent* aFirstNewContent,
+ int32_t aNewIndexInContainer)
{
MaybeProcessScript();
}
void
-nsScriptElement::ContentInserted(nsIDocument *aDocument,
- nsIContent* aContainer,
- nsIContent* aChild,
- int32_t aIndexInContainer)
+ScriptElement::ContentInserted(nsIDocument *aDocument,
+ nsIContent* aContainer,
+ nsIContent* aChild,
+ int32_t aIndexInContainer)
{
MaybeProcessScript();
}
bool
-nsScriptElement::MaybeProcessScript()
+ScriptElement::MaybeProcessScript()
{
nsCOMPtr<nsIContent> cont =
do_QueryInterface((nsIScriptElement*) this);
@@ -145,6 +145,6 @@ nsScriptElement::MaybeProcessScript()
}
}
- RefPtr<nsScriptLoader> loader = ownerDoc->ScriptLoader();
+ RefPtr<ScriptLoader> loader = ownerDoc->ScriptLoader();
return loader->ProcessScriptElement(this);
}
diff --git a/dom/base/nsScriptElement.h b/dom/script/ScriptElement.h
index 4a2a584ac2..0babda674a 100644
--- a/dom/base/nsScriptElement.h
+++ b/dom/script/ScriptElement.h
@@ -4,22 +4,25 @@
* 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 nsScriptElement_h
-#define nsScriptElement_h
+#ifndef mozilla_dom_ScriptElement_h
+#define mozilla_dom_ScriptElement_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 <xhtml:script> and
* <svg:script>). Currently the class assumes that only the 'src'
* attribute and the children of the class affect what script to execute.
*/
-class nsScriptElement : public nsIScriptElement,
- public nsStubMutationObserver
+class ScriptElement : public nsIScriptElement,
+ public nsStubMutationObserver
{
public:
// nsIScriptLoaderObserver
@@ -31,7 +34,7 @@ public:
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
- explicit nsScriptElement(mozilla::dom::FromParser aFromParser)
+ explicit ScriptElement(FromParser aFromParser)
: nsIScriptElement(aFromParser)
{
}
@@ -49,4 +52,7 @@ protected:
virtual bool MaybeProcessScript() override;
};
-#endif // nsScriptElement_h
+} // dom namespace
+} // mozilla namespace
+
+#endif // mozilla_dom_ScriptElement_h
diff --git a/dom/base/nsScriptLoader.cpp b/dom/script/ScriptLoader.cpp
index 25482fe7b6..b5c8053e88 100644
--- a/dom/base/nsScriptLoader.cpp
+++ b/dom/script/ScriptLoader.cpp
@@ -8,7 +8,7 @@
* A class that handles loading and evaluation of <script> elements.
*/
-#include "nsScriptLoader.h"
+#include "ScriptLoader.h"
#include "prsystem.h"
#include "jsapi.h"
@@ -58,19 +58,19 @@
#include "mozilla/Unused.h"
#include "nsIScriptError.h"
-using namespace mozilla;
-using namespace mozilla::dom;
-
using JS::SourceBufferHolder;
+namespace mozilla {
+namespace dom {
+
static LazyLogModule gCspPRLog("CSP");
void
-ImplCycleCollectionUnlink(nsScriptLoadRequestList& aField);
+ImplCycleCollectionUnlink(ScriptLoadRequestList& aField);
void
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
- nsScriptLoadRequestList& aField,
+ ScriptLoadRequestList& aField,
const char* aName,
uint32_t aFlags = 0);
@@ -78,23 +78,23 @@ ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
// nsScriptLoadRequest
//////////////////////////////////////////////////////////////
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsScriptLoadRequest)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ScriptLoadRequest)
NS_INTERFACE_MAP_END
-NS_IMPL_CYCLE_COLLECTING_ADDREF(nsScriptLoadRequest)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(nsScriptLoadRequest)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(ScriptLoadRequest)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(ScriptLoadRequest)
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsScriptLoadRequest)
+NS_IMPL_CYCLE_COLLECTION_CLASS(ScriptLoadRequest)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsScriptLoadRequest)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ScriptLoadRequest)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mElement)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsScriptLoadRequest)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(ScriptLoadRequest)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-nsScriptLoadRequest::~nsScriptLoadRequest()
+ScriptLoadRequest::~ScriptLoadRequest()
{
js_free(mScriptTextBuf);
@@ -107,21 +107,21 @@ nsScriptLoadRequest::~nsScriptLoadRequest()
}
void
-nsScriptLoadRequest::SetReady()
+ScriptLoadRequest::SetReady()
{
MOZ_ASSERT(mProgress != Progress::Ready);
mProgress = Progress::Ready;
}
void
-nsScriptLoadRequest::Cancel()
+ScriptLoadRequest::Cancel()
{
MaybeCancelOffThreadScript();
mIsCanceled = true;
}
void
-nsScriptLoadRequest::MaybeCancelOffThreadScript()
+ScriptLoadRequest::MaybeCancelOffThreadScript()
{
MOZ_ASSERT(NS_IsMainThread());
@@ -135,29 +135,29 @@ nsScriptLoadRequest::MaybeCancelOffThreadScript()
}
//////////////////////////////////////////////////////////////
-// nsModuleLoadRequest
+// ModuleLoadRequest
//////////////////////////////////////////////////////////////
// A load request for a module, created for every top level module script and
-// every module import. Load request can share an nsModuleScript if there are
+// every module import. Load request can share a ModuleScript if there are
// multiple imports of the same module.
-class nsModuleLoadRequest final : public nsScriptLoadRequest
+class ModuleLoadRequest final : public ScriptLoadRequest
{
- ~nsModuleLoadRequest() {}
+ ~ModuleLoadRequest() {}
- nsModuleLoadRequest(const nsModuleLoadRequest& aOther) = delete;
- nsModuleLoadRequest(nsModuleLoadRequest&& aOther) = delete;
+ ModuleLoadRequest(const ModuleLoadRequest& aOther) = delete;
+ ModuleLoadRequest(ModuleLoadRequest&& aOther) = delete;
public:
NS_DECL_ISUPPORTS_INHERITED
- NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsModuleLoadRequest, nsScriptLoadRequest)
+ NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ModuleLoadRequest, ScriptLoadRequest)
- nsModuleLoadRequest(nsIScriptElement* aElement,
- uint32_t aVersion,
- CORSMode aCORSMode,
- const SRIMetadata& aIntegrity,
- nsScriptLoader* aLoader);
+ ModuleLoadRequest(nsIScriptElement* aElement,
+ uint32_t aVersion,
+ CORSMode aCORSMode,
+ const SRIMetadata& aIntegrity,
+ ScriptLoader* aLoader);
bool IsTopLevel() const {
return mIsTopLevel;
@@ -178,15 +178,15 @@ public:
// Pointer to the script loader, used to trigger actions when the module load
// finishes.
- RefPtr<nsScriptLoader> mLoader;
+ RefPtr<ScriptLoader> mLoader;
// The importing module, or nullptr for top level module scripts. Used to
// implement the ancestor list checked when fetching module dependencies.
- RefPtr<nsModuleLoadRequest> mParent;
+ RefPtr<ModuleLoadRequest> mParent;
// Set to a module script object after a successful load or nullptr on
// failure.
- RefPtr<nsModuleScript> mModuleScript;
+ RefPtr<ModuleScript> mModuleScript;
// A promise that is completed on successful load of this module and all of
// its dependencies, indicating that the module is ready for instantiation and
@@ -194,48 +194,48 @@ public:
MozPromiseHolder<GenericPromise> mReady;
// Array of imported modules.
- nsTArray<RefPtr<nsModuleLoadRequest>> mImports;
+ nsTArray<RefPtr<ModuleLoadRequest>> mImports;
};
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsModuleLoadRequest)
-NS_INTERFACE_MAP_END_INHERITING(nsScriptLoadRequest)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ModuleLoadRequest)
+NS_INTERFACE_MAP_END_INHERITING(ScriptLoadRequest)
-NS_IMPL_CYCLE_COLLECTION_INHERITED(nsModuleLoadRequest, nsScriptLoadRequest,
+NS_IMPL_CYCLE_COLLECTION_INHERITED(ModuleLoadRequest, ScriptLoadRequest,
mBaseURL,
mLoader,
mParent,
mModuleScript,
mImports)
-NS_IMPL_ADDREF_INHERITED(nsModuleLoadRequest, nsScriptLoadRequest)
-NS_IMPL_RELEASE_INHERITED(nsModuleLoadRequest, nsScriptLoadRequest)
-
-nsModuleLoadRequest::nsModuleLoadRequest(nsIScriptElement* aElement,
- uint32_t aVersion,
- CORSMode aCORSMode,
- const SRIMetadata &aIntegrity,
- nsScriptLoader* aLoader)
- : nsScriptLoadRequest(nsScriptKind::Module,
- aElement,
- aVersion,
- aCORSMode,
- aIntegrity),
+NS_IMPL_ADDREF_INHERITED(ModuleLoadRequest, ScriptLoadRequest)
+NS_IMPL_RELEASE_INHERITED(ModuleLoadRequest, ScriptLoadRequest)
+
+ModuleLoadRequest::ModuleLoadRequest(nsIScriptElement* aElement,
+ uint32_t aVersion,
+ CORSMode aCORSMode,
+ const SRIMetadata &aIntegrity,
+ ScriptLoader* aLoader)
+ : ScriptLoadRequest(ScriptKind::Module,
+ aElement,
+ aVersion,
+ aCORSMode,
+ aIntegrity),
mIsTopLevel(true),
mLoader(aLoader)
{}
-inline nsModuleLoadRequest*
-nsScriptLoadRequest::AsModuleRequest()
+inline ModuleLoadRequest*
+ScriptLoadRequest::AsModuleRequest()
{
MOZ_ASSERT(IsModuleRequest());
- return static_cast<nsModuleLoadRequest*>(this);
+ return static_cast<ModuleLoadRequest*>(this);
}
-void nsModuleLoadRequest::Cancel()
+void ModuleLoadRequest::Cancel()
{
- nsScriptLoadRequest::Cancel();
+ ScriptLoadRequest::Cancel();
mModuleScript = nullptr;
- mProgress = nsScriptLoadRequest::Progress::Ready;
+ mProgress = ScriptLoadRequest::Progress::Ready;
for (size_t i = 0; i < mImports.Length(); i++) {
mImports[i]->Cancel();
}
@@ -243,7 +243,7 @@ void nsModuleLoadRequest::Cancel()
}
void
-nsModuleLoadRequest::SetReady()
+ModuleLoadRequest::SetReady()
{
#ifdef DEBUG
for (size_t i = 0; i < mImports.Length(); i++) {
@@ -251,12 +251,12 @@ nsModuleLoadRequest::SetReady()
}
#endif
- nsScriptLoadRequest::SetReady();
+ ScriptLoadRequest::SetReady();
mReady.ResolveIfExists(true, __func__);
}
void
-nsModuleLoadRequest::ModuleLoaded()
+ModuleLoadRequest::ModuleLoaded()
{
// A module that was found to be marked as fetching in the module map has now
// been loaded.
@@ -266,7 +266,7 @@ nsModuleLoadRequest::ModuleLoaded()
}
void
-nsModuleLoadRequest::DependenciesLoaded()
+ModuleLoadRequest::DependenciesLoaded()
{
// The module and all of its dependencies have been successfully fetched and
// compiled.
@@ -283,7 +283,7 @@ nsModuleLoadRequest::DependenciesLoaded()
}
void
-nsModuleLoadRequest::LoadFailed()
+ModuleLoadRequest::LoadFailed()
{
Cancel();
mLoader->ProcessLoadedModuleTree(this);
@@ -292,12 +292,12 @@ nsModuleLoadRequest::LoadFailed()
}
//////////////////////////////////////////////////////////////
-// nsModuleScript
+// ModuleScript
//////////////////////////////////////////////////////////////
// A single module script. May be used to satisfy multiple load requests.
-class nsModuleScript final : public nsISupports
+class ModuleScript final : public nsISupports
{
enum InstantiationState {
Uninstantiated,
@@ -305,23 +305,23 @@ class nsModuleScript final : public nsISupports
Errored
};
- RefPtr<nsScriptLoader> mLoader;
+ RefPtr<ScriptLoader> mLoader;
nsCOMPtr<nsIURI> mBaseURL;
JS::Heap<JSObject*> mModuleRecord;
JS::Heap<JS::Value> mException;
InstantiationState mInstantiationState;
- ~nsModuleScript();
+ ~ModuleScript();
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
- NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsModuleScript)
+ NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ModuleScript)
- nsModuleScript(nsScriptLoader* aLoader,
- nsIURI* aBaseURL,
- JS::Handle<JSObject*> aModuleRecord);
+ ModuleScript(ScriptLoader* aLoader,
+ nsIURI* aBaseURL,
+ JS::Handle<JSObject*> aModuleRecord);
- nsScriptLoader* Loader() const { return mLoader; }
+ ScriptLoader* Loader() const { return mLoader; }
JSObject* ModuleRecord() const { return mModuleRecord; }
JS::Value Exception() const { return mException; }
nsIURI* BaseURL() const { return mBaseURL; }
@@ -340,31 +340,31 @@ public:
void UnlinkModuleRecord();
};
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsModuleScript)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ModuleScript)
NS_INTERFACE_MAP_END
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsModuleScript)
+NS_IMPL_CYCLE_COLLECTION_CLASS(ModuleScript)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsModuleScript)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ModuleScript)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mLoader)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mBaseURL)
tmp->UnlinkModuleRecord();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsModuleScript)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(ModuleScript)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLoader)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsModuleScript)
+NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(ModuleScript)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mModuleRecord)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mException)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
-NS_IMPL_CYCLE_COLLECTING_ADDREF(nsModuleScript)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(nsModuleScript)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(ModuleScript)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(ModuleScript)
-nsModuleScript::nsModuleScript(nsScriptLoader *aLoader, nsIURI* aBaseURL,
- JS::Handle<JSObject*> aModuleRecord)
+ModuleScript::ModuleScript(ScriptLoader *aLoader, nsIURI* aBaseURL,
+ JS::Handle<JSObject*> aModuleRecord)
: mLoader(aLoader),
mBaseURL(aBaseURL),
mModuleRecord(aModuleRecord),
@@ -382,7 +382,7 @@ nsModuleScript::nsModuleScript(nsScriptLoader *aLoader, nsIURI* aBaseURL,
}
void
-nsModuleScript::UnlinkModuleRecord()
+ModuleScript::UnlinkModuleRecord()
{
// Remove module's back reference to this object request if present.
if (mModuleRecord) {
@@ -394,7 +394,7 @@ nsModuleScript::UnlinkModuleRecord()
mException.setUndefined();
}
-nsModuleScript::~nsModuleScript()
+ModuleScript::~ModuleScript()
{
if (mModuleRecord) {
// The object may be destroyed without being unlinked first.
@@ -404,7 +404,7 @@ nsModuleScript::~nsModuleScript()
}
void
-nsModuleScript::SetInstantiationResult(JS::Handle<JS::Value> aMaybeException)
+ModuleScript::SetInstantiationResult(JS::Handle<JS::Value> aMaybeException)
{
MOZ_ASSERT(mInstantiationState == Uninstantiated);
MOZ_ASSERT(mModuleRecord);
@@ -421,19 +421,19 @@ nsModuleScript::SetInstantiationResult(JS::Handle<JS::Value> aMaybeException)
//////////////////////////////////////////////////////////////
-// nsScriptLoadRequestList
+// ScriptLoadRequestList
//////////////////////////////////////////////////////////////
-nsScriptLoadRequestList::~nsScriptLoadRequestList()
+ScriptLoadRequestList::~ScriptLoadRequestList()
{
Clear();
}
void
-nsScriptLoadRequestList::Clear()
+ScriptLoadRequestList::Clear()
{
while (!isEmpty()) {
- RefPtr<nsScriptLoadRequest> first = StealFirst();
+ RefPtr<ScriptLoadRequest> first = StealFirst();
first->Cancel();
// And just let it go out of scope and die.
}
@@ -441,9 +441,9 @@ nsScriptLoadRequestList::Clear()
#ifdef DEBUG
bool
-nsScriptLoadRequestList::Contains(nsScriptLoadRequest* aElem) const
+ScriptLoadRequestList::Contains(ScriptLoadRequest* aElem) const
{
- for (const nsScriptLoadRequest* req = getFirst();
+ for (const ScriptLoadRequest* req = getFirst();
req; req = req->getNext()) {
if (req == aElem) {
return true;
@@ -455,20 +455,20 @@ nsScriptLoadRequestList::Contains(nsScriptLoadRequest* aElem) const
#endif // DEBUG
inline void
-ImplCycleCollectionUnlink(nsScriptLoadRequestList& aField)
+ImplCycleCollectionUnlink(ScriptLoadRequestList& aField)
{
while (!aField.isEmpty()) {
- RefPtr<nsScriptLoadRequest> first = aField.StealFirst();
+ RefPtr<ScriptLoadRequest> first = aField.StealFirst();
}
}
inline void
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
- nsScriptLoadRequestList& aField,
+ ScriptLoadRequestList& aField,
const char* aName,
uint32_t aFlags)
{
- for (nsScriptLoadRequest* request = aField.getFirst();
+ for (ScriptLoadRequest* request = aField.getFirst();
request; request = request->getNext())
{
CycleCollectionNoteChild(aCallback, request, aName, aFlags);
@@ -476,18 +476,18 @@ ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
}
//////////////////////////////////////////////////////////////
-// nsScriptLoader::PreloadInfo
+// ScriptLoader::PreloadInfo
//////////////////////////////////////////////////////////////
inline void
-ImplCycleCollectionUnlink(nsScriptLoader::PreloadInfo& aField)
+ImplCycleCollectionUnlink(ScriptLoader::PreloadInfo& aField)
{
ImplCycleCollectionUnlink(aField.mRequest);
}
inline void
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
- nsScriptLoader::PreloadInfo& aField,
+ ScriptLoader::PreloadInfo& aField,
const char* aName,
uint32_t aFlags = 0)
{
@@ -495,13 +495,13 @@ ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
}
//////////////////////////////////////////////////////////////
-// nsScriptLoader
+// ScriptLoader
//////////////////////////////////////////////////////////////
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsScriptLoader)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ScriptLoader)
NS_INTERFACE_MAP_END
-NS_IMPL_CYCLE_COLLECTION(nsScriptLoader,
+NS_IMPL_CYCLE_COLLECTION(ScriptLoader,
mNonAsyncExternalScriptInsertedRequests,
mLoadingAsyncRequests,
mLoadedAsyncRequests,
@@ -512,10 +512,10 @@ NS_IMPL_CYCLE_COLLECTION(nsScriptLoader,
mPendingChildLoaders,
mFetchedModules)
-NS_IMPL_CYCLE_COLLECTING_ADDREF(nsScriptLoader)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(nsScriptLoader)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(ScriptLoader)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(ScriptLoader)
-nsScriptLoader::nsScriptLoader(nsIDocument *aDocument)
+ScriptLoader::ScriptLoader(nsIDocument *aDocument)
: mDocument(aDocument),
mParserBlockingBlockerCount(0),
mBlockerCount(0),
@@ -528,7 +528,7 @@ nsScriptLoader::nsScriptLoader(nsIDocument *aDocument)
{
}
-nsScriptLoader::~nsScriptLoader()
+ScriptLoader::~ScriptLoader()
{
mObservers.Clear();
@@ -536,27 +536,27 @@ nsScriptLoader::~nsScriptLoader()
mParserBlockingRequest->FireScriptAvailable(NS_ERROR_ABORT);
}
- for (nsScriptLoadRequest* req = mXSLTRequests.getFirst(); req;
+ for (ScriptLoadRequest* req = mXSLTRequests.getFirst(); req;
req = req->getNext()) {
req->FireScriptAvailable(NS_ERROR_ABORT);
}
- for (nsScriptLoadRequest* req = mDeferRequests.getFirst(); req;
+ for (ScriptLoadRequest* req = mDeferRequests.getFirst(); req;
req = req->getNext()) {
req->FireScriptAvailable(NS_ERROR_ABORT);
}
- for (nsScriptLoadRequest* req = mLoadingAsyncRequests.getFirst(); req;
+ for (ScriptLoadRequest* req = mLoadingAsyncRequests.getFirst(); req;
req = req->getNext()) {
req->FireScriptAvailable(NS_ERROR_ABORT);
}
- for (nsScriptLoadRequest* req = mLoadedAsyncRequests.getFirst(); req;
+ for (ScriptLoadRequest* req = mLoadedAsyncRequests.getFirst(); req;
req = req->getNext()) {
req->FireScriptAvailable(NS_ERROR_ABORT);
}
- for(nsScriptLoadRequest* req = mNonAsyncExternalScriptInsertedRequests.getFirst();
+ for(ScriptLoadRequest* req = mNonAsyncExternalScriptInsertedRequests.getFirst();
req;
req = req->getNext()) {
req->FireScriptAvailable(NS_ERROR_ABORT);
@@ -623,11 +623,11 @@ IsScriptEventHandler(nsIContent* aScriptElement)
}
nsresult
-nsScriptLoader::CheckContentPolicy(nsIDocument* aDocument,
- nsISupports *aContext,
- nsIURI *aURI,
- const nsAString &aType,
- bool aIsPreLoad)
+ScriptLoader::CheckContentPolicy(nsIDocument* aDocument,
+ nsISupports *aContext,
+ nsIURI *aURI,
+ const nsAString &aType,
+ bool aIsPreLoad)
{
nsContentPolicyType contentPolicyType = aIsPreLoad
? nsIContentPolicy::TYPE_INTERNAL_SCRIPT_PRELOAD
@@ -654,7 +654,7 @@ nsScriptLoader::CheckContentPolicy(nsIDocument* aDocument,
}
bool
-nsScriptLoader::ModuleScriptsEnabled()
+ScriptLoader::ModuleScriptsEnabled()
{
static bool sEnabledForContent = false;
static bool sCachedPref = false;
@@ -667,7 +667,7 @@ nsScriptLoader::ModuleScriptsEnabled()
}
bool
-nsScriptLoader::ModuleMapContainsModule(nsModuleLoadRequest *aRequest) const
+ScriptLoader::ModuleMapContainsModule(ModuleLoadRequest *aRequest) const
{
// Returns whether we have fetched, or are currently fetching, a module script
// for the request's URL.
@@ -676,7 +676,7 @@ nsScriptLoader::ModuleMapContainsModule(nsModuleLoadRequest *aRequest) const
}
bool
-nsScriptLoader::IsFetchingModule(nsModuleLoadRequest *aRequest) const
+ScriptLoader::IsFetchingModule(ModuleLoadRequest *aRequest) const
{
bool fetching = mFetchingModules.Contains(aRequest->mURI);
MOZ_ASSERT_IF(fetching, !mFetchedModules.Contains(aRequest->mURI));
@@ -684,7 +684,7 @@ nsScriptLoader::IsFetchingModule(nsModuleLoadRequest *aRequest) const
}
void
-nsScriptLoader::SetModuleFetchStarted(nsModuleLoadRequest *aRequest)
+ScriptLoader::SetModuleFetchStarted(ModuleLoadRequest *aRequest)
{
// Update the module map to indicate that a module is currently being fetched.
@@ -694,8 +694,8 @@ nsScriptLoader::SetModuleFetchStarted(nsModuleLoadRequest *aRequest)
}
void
-nsScriptLoader::SetModuleFetchFinishedAndResumeWaitingRequests(nsModuleLoadRequest *aRequest,
- nsresult aResult)
+ScriptLoader::SetModuleFetchFinishedAndResumeWaitingRequests(ModuleLoadRequest *aRequest,
+ nsresult aResult)
{
// Update module map with the result of fetching a single module script. The
// module script pointer is nullptr on error.
@@ -706,7 +706,7 @@ nsScriptLoader::SetModuleFetchFinishedAndResumeWaitingRequests(nsModuleLoadReque
MOZ_ALWAYS_TRUE(mFetchingModules.Get(aRequest->mURI, getter_AddRefs(promise)));
mFetchingModules.Remove(aRequest->mURI);
- RefPtr<nsModuleScript> ms(aRequest->mModuleScript);
+ RefPtr<ModuleScript> ms(aRequest->mModuleScript);
MOZ_ASSERT(NS_SUCCEEDED(aResult) == (ms != nullptr));
mFetchedModules.Put(aRequest->mURI, ms);
@@ -720,7 +720,7 @@ nsScriptLoader::SetModuleFetchFinishedAndResumeWaitingRequests(nsModuleLoadReque
}
RefPtr<GenericPromise>
-nsScriptLoader::WaitForModuleFetch(nsModuleLoadRequest *aRequest)
+ScriptLoader::WaitForModuleFetch(ModuleLoadRequest *aRequest)
{
MOZ_ASSERT(ModuleMapContainsModule(aRequest));
@@ -733,7 +733,7 @@ nsScriptLoader::WaitForModuleFetch(nsModuleLoadRequest *aRequest)
return promise;
}
- RefPtr<nsModuleScript> ms;
+ RefPtr<ModuleScript> ms;
MOZ_ALWAYS_TRUE(mFetchedModules.Get(aRequest->mURI, getter_AddRefs(ms)));
if (!ms) {
return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
@@ -742,17 +742,17 @@ nsScriptLoader::WaitForModuleFetch(nsModuleLoadRequest *aRequest)
return GenericPromise::CreateAndResolve(true, __func__);
}
-nsModuleScript*
-nsScriptLoader::GetFetchedModule(nsIURI* aURL) const
+ModuleScript*
+ScriptLoader::GetFetchedModule(nsIURI* aURL) const
{
bool found;
- nsModuleScript* ms = mFetchedModules.GetWeak(aURL, &found);
+ ModuleScript* ms = mFetchedModules.GetWeak(aURL, &found);
MOZ_ASSERT(found);
return ms;
}
nsresult
-nsScriptLoader::ProcessFetchedModuleSource(nsModuleLoadRequest* aRequest)
+ScriptLoader::ProcessFetchedModuleSource(ModuleLoadRequest* aRequest)
{
MOZ_ASSERT(!aRequest->mModuleScript);
@@ -771,7 +771,7 @@ nsScriptLoader::ProcessFetchedModuleSource(nsModuleLoadRequest* aRequest)
}
nsresult
-nsScriptLoader::CreateModuleScript(nsModuleLoadRequest* aRequest)
+ScriptLoader::CreateModuleScript(ModuleLoadRequest* aRequest)
{
MOZ_ASSERT(!aRequest->mModuleScript);
MOZ_ASSERT(aRequest->mBaseURL);
@@ -825,7 +825,7 @@ nsScriptLoader::CreateModuleScript(nsModuleLoadRequest* aRequest)
MOZ_ASSERT(NS_SUCCEEDED(rv) == (module != nullptr));
if (module) {
aRequest->mModuleScript =
- new nsModuleScript(this, aRequest->mBaseURL, module);
+ new ModuleScript(this, aRequest->mBaseURL, module);
}
}
@@ -835,7 +835,7 @@ nsScriptLoader::CreateModuleScript(nsModuleLoadRequest* aRequest)
}
static bool
-ThrowTypeError(JSContext* aCx, nsModuleScript* aScript,
+ThrowTypeError(JSContext* aCx, ModuleScript* aScript,
const nsString& aMessage)
{
JS::Rooted<JSObject*> module(aCx, aScript->ModuleRecord());
@@ -862,7 +862,7 @@ ThrowTypeError(JSContext* aCx, nsModuleScript* aScript,
}
static bool
-HandleResolveFailure(JSContext* aCx, nsModuleScript* aScript,
+HandleResolveFailure(JSContext* aCx, ModuleScript* aScript,
const nsAString& aSpecifier)
{
// TODO: How can we get the line number of the failed import?
@@ -874,7 +874,7 @@ HandleResolveFailure(JSContext* aCx, nsModuleScript* aScript,
}
static bool
-HandleModuleNotFound(JSContext* aCx, nsModuleScript* aScript,
+HandleModuleNotFound(JSContext* aCx, ModuleScript* aScript,
const nsAString& aSpecifier)
{
// TODO: How can we get the line number of the failed import?
@@ -886,7 +886,7 @@ HandleModuleNotFound(JSContext* aCx, nsModuleScript* aScript,
}
static already_AddRefed<nsIURI>
-ResolveModuleSpecifier(nsModuleScript* aScript,
+ResolveModuleSpecifier(ModuleScript* aScript,
const nsAString& aSpecifier)
{
// The following module specifiers are allowed by the spec:
@@ -921,7 +921,7 @@ ResolveModuleSpecifier(nsModuleScript* aScript,
}
static nsresult
-RequestedModuleIsInAncestorList(nsModuleLoadRequest* aRequest, nsIURI* aURL, bool* aResult)
+RequestedModuleIsInAncestorList(ModuleLoadRequest* aRequest, nsIURI* aURL, bool* aResult)
{
const size_t ImportDepthLimit = 100;
@@ -947,9 +947,9 @@ RequestedModuleIsInAncestorList(nsModuleLoadRequest* aRequest, nsIURI* aURL, boo
}
static nsresult
-ResolveRequestedModules(nsModuleLoadRequest* aRequest, nsCOMArray<nsIURI> &aUrls)
+ResolveRequestedModules(ModuleLoadRequest* aRequest, nsCOMArray<nsIURI> &aUrls)
{
- nsModuleScript* ms = aRequest->mModuleScript;
+ ModuleScript* ms = aRequest->mModuleScript;
AutoJSAPI jsapi;
if (!jsapi.Init(ms->ModuleRecord())) {
@@ -977,7 +977,7 @@ ResolveRequestedModules(nsModuleLoadRequest* aRequest, nsCOMArray<nsIURI> &aUrls
}
// Let url be the result of resolving a module specifier given module script and requested.
- nsModuleScript* ms = aRequest->mModuleScript;
+ ModuleScript* ms = aRequest->mModuleScript;
nsCOMPtr<nsIURI> uri = ResolveModuleSpecifier(ms, specifier);
if (!uri) {
HandleResolveFailure(cx, ms, specifier);
@@ -996,11 +996,11 @@ ResolveRequestedModules(nsModuleLoadRequest* aRequest, nsCOMArray<nsIURI> &aUrls
}
void
-nsScriptLoader::StartFetchingModuleDependencies(nsModuleLoadRequest* aRequest)
+ScriptLoader::StartFetchingModuleDependencies(ModuleLoadRequest* aRequest)
{
MOZ_ASSERT(aRequest->mModuleScript);
MOZ_ASSERT(!aRequest->IsReadyToRun());
- aRequest->mProgress = nsModuleLoadRequest::Progress::FetchingImports;
+ aRequest->mProgress = ModuleLoadRequest::Progress::FetchingImports;
nsCOMArray<nsIURI> urls;
nsresult rv = ResolveRequestedModules(aRequest, urls);
@@ -1028,19 +1028,19 @@ nsScriptLoader::StartFetchingModuleDependencies(nsModuleLoadRequest* aRequest)
RefPtr<GenericPromise::AllPromiseType> allReady =
GenericPromise::All(AbstractThread::GetCurrent(), importsReady);
allReady->Then(AbstractThread::GetCurrent(), __func__, aRequest,
- &nsModuleLoadRequest::DependenciesLoaded,
- &nsModuleLoadRequest::LoadFailed);
+ &ModuleLoadRequest::DependenciesLoaded,
+ &ModuleLoadRequest::LoadFailed);
}
RefPtr<GenericPromise>
-nsScriptLoader::StartFetchingModuleAndDependencies(nsModuleLoadRequest* aRequest,
- nsIURI* aURI)
+ScriptLoader::StartFetchingModuleAndDependencies(ModuleLoadRequest* aRequest,
+ nsIURI* aURI)
{
MOZ_ASSERT(aURI);
- RefPtr<nsModuleLoadRequest> childRequest =
- new nsModuleLoadRequest(aRequest->mElement, aRequest->mJSVersion,
- aRequest->mCORSMode, aRequest->mIntegrity, this);
+ RefPtr<ModuleLoadRequest> childRequest =
+ new ModuleLoadRequest(aRequest->mElement, aRequest->mJSVersion,
+ aRequest->mCORSMode, aRequest->mIntegrity, this);
childRequest->mIsTopLevel = false;
childRequest->mURI = aURI;
@@ -1070,7 +1070,7 @@ HostResolveImportedModule(JSContext* aCx, unsigned argc, JS::Value* vp)
// Let referencing module script be referencingModule.[[HostDefined]].
JS::Value value = JS::GetModuleHostDefinedField(module);
- auto script = static_cast<nsModuleScript*>(value.toPrivate());
+ auto script = static_cast<ModuleScript*>(value.toPrivate());
MOZ_ASSERT(script->ModuleRecord() == module);
// Let url be the result of resolving a module specifier given referencing
@@ -1089,7 +1089,7 @@ HostResolveImportedModule(JSContext* aCx, unsigned argc, JS::Value* vp)
// Let resolved module script be the value of the entry in module map whose
// key is url. If no such entry exists, throw a TypeError exception and abort
// these steps.
- nsModuleScript* ms = script->Loader()->GetFetchedModule(uri);
+ ModuleScript* ms = script->Loader()->GetFetchedModule(uri);
if (!ms) {
return HandleModuleNotFound(aCx, script, string);
}
@@ -1123,7 +1123,7 @@ EnsureModuleResolveHook(JSContext* aCx)
}
void
-nsScriptLoader::ProcessLoadedModuleTree(nsModuleLoadRequest* aRequest)
+ScriptLoader::ProcessLoadedModuleTree(ModuleLoadRequest* aRequest)
{
if (aRequest->IsTopLevel()) {
MaybeMoveToLoadedList(aRequest);
@@ -1136,13 +1136,13 @@ nsScriptLoader::ProcessLoadedModuleTree(nsModuleLoadRequest* aRequest)
}
bool
-nsScriptLoader::InstantiateModuleTree(nsModuleLoadRequest* aRequest)
+ScriptLoader::InstantiateModuleTree(ModuleLoadRequest* aRequest)
{
// Perform eager instantiation of the loaded module tree.
MOZ_ASSERT(aRequest);
- nsModuleScript* ms = aRequest->mModuleScript;
+ ModuleScript* ms = aRequest->mModuleScript;
MOZ_ASSERT(ms);
if (!ms || !ms->ModuleRecord()) {
return false;
@@ -1171,14 +1171,14 @@ nsScriptLoader::InstantiateModuleTree(nsModuleLoadRequest* aRequest)
// Mark this module and any uninstantiated dependencies found via depth-first
// search as instantiated and record any error.
- mozilla::Vector<nsModuleLoadRequest*, 1> requests;
+ mozilla::Vector<ModuleLoadRequest*, 1> requests;
if (!requests.append(aRequest)) {
return false;
}
while (!requests.empty()) {
- nsModuleLoadRequest* request = requests.popCopy();
- nsModuleScript* ms = request->mModuleScript;
+ ModuleLoadRequest* request = requests.popCopy();
+ ModuleScript* ms = request->mModuleScript;
if (!ms->IsUninstantiated()) {
continue;
}
@@ -1198,8 +1198,8 @@ nsScriptLoader::InstantiateModuleTree(nsModuleLoadRequest* aRequest)
}
nsresult
-nsScriptLoader::StartLoad(nsScriptLoadRequest *aRequest, const nsAString &aType,
- bool aScriptFromHead)
+ScriptLoader::StartLoad(ScriptLoadRequest *aRequest, const nsAString &aType,
+ bool aScriptFromHead)
{
MOZ_ASSERT(aRequest->IsLoading());
NS_ENSURE_TRUE(mDocument, NS_ERROR_NULL_POINTER);
@@ -1212,12 +1212,12 @@ nsScriptLoader::StartLoad(nsScriptLoadRequest *aRequest, const nsAString &aType,
if (aRequest->IsModuleRequest()) {
// Check whether the module has been fetched or is currently being fetched,
// and if so wait for it.
- nsModuleLoadRequest* request = aRequest->AsModuleRequest();
+ ModuleLoadRequest* request = aRequest->AsModuleRequest();
if (ModuleMapContainsModule(request)) {
WaitForModuleFetch(request)
->Then(AbstractThread::GetCurrent(), __func__, request,
- &nsModuleLoadRequest::ModuleLoaded,
- &nsModuleLoadRequest::LoadFailed);
+ &ModuleLoadRequest::ModuleLoaded,
+ &ModuleLoadRequest::LoadFailed);
return NS_OK;
}
@@ -1330,8 +1330,8 @@ nsScriptLoader::StartLoad(nsScriptLoadRequest *aRequest, const nsAString &aType,
mReporter);
}
- RefPtr<nsScriptLoadHandler> handler =
- new nsScriptLoadHandler(this, aRequest, sriDataVerifier.forget());
+ RefPtr<ScriptLoadHandler> handler =
+ new ScriptLoadHandler(this, aRequest, sriDataVerifier.forget());
nsCOMPtr<nsIIncrementalStreamLoader> loader;
rv = NS_NewIncrementalStreamLoader(getter_AddRefs(loader), handler);
@@ -1341,22 +1341,22 @@ nsScriptLoader::StartLoad(nsScriptLoadRequest *aRequest, const nsAString &aType,
}
bool
-nsScriptLoader::PreloadURIComparator::Equals(const PreloadInfo &aPi,
- nsIURI * const &aURI) const
+ScriptLoader::PreloadURIComparator::Equals(const PreloadInfo &aPi,
+ nsIURI * const &aURI) const
{
bool same;
return NS_SUCCEEDED(aPi.mRequest->mURI->Equals(aURI, &same)) &&
same;
}
-class nsScriptRequestProcessor : public Runnable
+class ScriptRequestProcessor : public Runnable
{
private:
- RefPtr<nsScriptLoader> mLoader;
- RefPtr<nsScriptLoadRequest> mRequest;
+ RefPtr<ScriptLoader> mLoader;
+ RefPtr<ScriptLoadRequest> mRequest;
public:
- nsScriptRequestProcessor(nsScriptLoader* aLoader,
- nsScriptLoadRequest* aRequest)
+ ScriptRequestProcessor(ScriptLoader* aLoader,
+ ScriptLoadRequest* aRequest)
: mLoader(aLoader)
, mRequest(aRequest)
{}
@@ -1428,24 +1428,23 @@ CSPAllowsInlineScript(nsIScriptElement *aElement, nsIDocument *aDocument)
return allowInlineScript;
}
-nsScriptLoadRequest*
-nsScriptLoader::CreateLoadRequest(nsScriptKind aKind,
- nsIScriptElement* aElement,
- uint32_t aVersion, CORSMode aCORSMode,
- const SRIMetadata &aIntegrity)
+ScriptLoadRequest*
+ScriptLoader::CreateLoadRequest(ScriptKind aKind,
+ nsIScriptElement* aElement,
+ uint32_t aVersion, CORSMode aCORSMode,
+ const SRIMetadata &aIntegrity)
{
- if (aKind == nsScriptKind::Classic) {
- return new nsScriptLoadRequest(aKind, aElement, aVersion, aCORSMode,
- aIntegrity);
+ if (aKind == ScriptKind::Classic) {
+ return new ScriptLoadRequest(aKind, aElement, aVersion, aCORSMode,
+ aIntegrity);
}
- MOZ_ASSERT(aKind == nsScriptKind::Module);
- return new nsModuleLoadRequest(aElement, aVersion, aCORSMode, aIntegrity,
- this);
+ MOZ_ASSERT(aKind == ScriptKind::Module);
+ return new ModuleLoadRequest(aElement, aVersion, aCORSMode, aIntegrity, this);
}
bool
-nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
+ScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
{
// We need a document to evaluate scripts.
NS_ENSURE_TRUE(mDocument, false);
@@ -1471,10 +1470,10 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
nsAutoString type;
bool hasType = aElement->GetScriptType(type);
- nsScriptKind scriptKind = nsScriptKind::Classic;
+ ScriptKind scriptKind = ScriptKind::Classic;
if (!type.IsEmpty()) {
if (ModuleScriptsEnabled() && type.LowerCaseEqualsASCII("module")) {
- scriptKind = nsScriptKind::Module;
+ scriptKind = ScriptKind::Module;
} else {
NS_ENSURE_TRUE(ParseTypeAttribute(type, &version), false);
}
@@ -1498,7 +1497,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
// "The nomodule attribute must not be specified on module scripts (and will
// be ignored if it is)."
if (ModuleScriptsEnabled() &&
- scriptKind == nsScriptKind::Classic &&
+ scriptKind == ScriptKind::Classic &&
scriptContent->IsHTMLElement() &&
scriptContent->HasAttr(kNameSpaceID_None, nsGkAtoms::nomodule)) {
return false;
@@ -1506,7 +1505,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
// Step 15. and later in the HTML5 spec
nsresult rv = NS_OK;
- RefPtr<nsScriptLoadRequest> request;
+ RefPtr<ScriptLoadRequest> request;
if (aElement->GetScriptExternal()) {
// external script
nsCOMPtr<nsIURI> scriptURI = aElement->GetScriptURI();
@@ -1562,7 +1561,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
integrity);
if (!integrity.IsEmpty()) {
MOZ_LOG(SRILogHelper::GetSriLog(), mozilla::LogLevel::Debug,
- ("nsScriptLoader::ProcessScriptElement, integrity=%s",
+ ("ScriptLoader::ProcessScriptElement, integrity=%s",
NS_ConvertUTF16toUTF8(integrity).get()));
nsAutoCString sourceUri;
if (mDocument->GetDocumentURI()) {
@@ -1704,7 +1703,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
request->mLineNo = aElement->GetScriptLineNumber();
if (request->IsModuleRequest()) {
- nsModuleLoadRequest* modReq = request->AsModuleRequest();
+ ModuleLoadRequest* modReq = request->AsModuleRequest();
modReq->mBaseURL = mDocument->GetDocBaseURI();
rv = CreateModuleScript(modReq);
NS_ENSURE_SUCCESS(rv, false);
@@ -1716,7 +1715,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
}
return false;
}
- request->mProgress = nsScriptLoadRequest::Progress::Ready;
+ request->mProgress = ScriptLoadRequest::Progress::Ready;
if (aElement->GetParserCreated() == FROM_PARSER_XSLT &&
(!ReadyToExecuteParserBlockingScripts() || !mXSLTRequests.isEmpty())) {
// Need to maintain order for XSLT-inserted scripts
@@ -1728,7 +1727,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
if (aElement->GetParserCreated() == NOT_FROM_PARSER) {
NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
"A script-inserted script is inserted without an update batch?");
- nsContentUtils::AddScriptRunner(new nsScriptRequestProcessor(this,
+ nsContentUtils::AddScriptRunner(new ScriptRequestProcessor(this,
request));
return false;
}
@@ -1758,13 +1757,13 @@ namespace {
class NotifyOffThreadScriptLoadCompletedRunnable : public Runnable
{
- RefPtr<nsScriptLoadRequest> mRequest;
- RefPtr<nsScriptLoader> mLoader;
+ RefPtr<ScriptLoadRequest> mRequest;
+ RefPtr<ScriptLoader> mLoader;
void *mToken;
public:
- NotifyOffThreadScriptLoadCompletedRunnable(nsScriptLoadRequest* aRequest,
- nsScriptLoader* aLoader)
+ NotifyOffThreadScriptLoadCompletedRunnable(ScriptLoadRequest* aRequest,
+ ScriptLoader* aLoader)
: mRequest(aRequest), mLoader(aLoader), mToken(nullptr)
{}
@@ -1781,16 +1780,16 @@ public:
} /* anonymous namespace */
nsresult
-nsScriptLoader::ProcessOffThreadRequest(nsScriptLoadRequest* aRequest)
+ScriptLoader::ProcessOffThreadRequest(ScriptLoadRequest* aRequest)
{
- MOZ_ASSERT(aRequest->mProgress == nsScriptLoadRequest::Progress::Compiling);
+ MOZ_ASSERT(aRequest->mProgress == ScriptLoadRequest::Progress::Compiling);
MOZ_ASSERT(!aRequest->mWasCompiledOMT);
aRequest->mWasCompiledOMT = true;
if (aRequest->IsModuleRequest()) {
MOZ_ASSERT(aRequest->mOffThreadToken);
- nsModuleLoadRequest* request = aRequest->AsModuleRequest();
+ ModuleLoadRequest* request = aRequest->AsModuleRequest();
nsresult rv = ProcessFetchedModuleSource(request);
if (NS_FAILED(rv)) {
request->LoadFailed();
@@ -1837,8 +1836,8 @@ NotifyOffThreadScriptLoadCompletedRunnable::Run()
// We want these to be dropped on the main thread, once we return from this
// function.
- RefPtr<nsScriptLoadRequest> request = mRequest.forget();
- RefPtr<nsScriptLoader> loader = mLoader.forget();
+ RefPtr<ScriptLoadRequest> request = mRequest.forget();
+ RefPtr<ScriptLoader> loader = mLoader.forget();
request->mOffThreadToken = mToken;
nsresult rv = loader->ProcessOffThreadRequest(request);
@@ -1856,7 +1855,7 @@ OffThreadScriptLoaderCallback(void *aToken, void *aCallbackData)
}
nsresult
-nsScriptLoader::AttemptAsyncScriptCompile(nsScriptLoadRequest* aRequest)
+ScriptLoader::AttemptAsyncScriptCompile(ScriptLoadRequest* aRequest)
{
MOZ_ASSERT_IF(!aRequest->IsModuleRequest(), aRequest->IsReadyToRun());
MOZ_ASSERT(!aRequest->mWasCompiledOMT);
@@ -1909,14 +1908,14 @@ nsScriptLoader::AttemptAsyncScriptCompile(nsScriptLoadRequest* aRequest)
}
mDocument->BlockOnload();
- aRequest->mProgress = nsScriptLoadRequest::Progress::Compiling;
+ aRequest->mProgress = ScriptLoadRequest::Progress::Compiling;
Unused << runnable.forget();
return NS_OK;
}
nsresult
-nsScriptLoader::CompileOffThreadOrProcessRequest(nsScriptLoadRequest* aRequest)
+ScriptLoader::CompileOffThreadOrProcessRequest(ScriptLoadRequest* aRequest)
{
NS_ASSERTION(nsContentUtils::IsSafeToRunScript(),
"Processing requests when running scripts is unsafe.");
@@ -1934,7 +1933,7 @@ nsScriptLoader::CompileOffThreadOrProcessRequest(nsScriptLoadRequest* aRequest)
}
SourceBufferHolder
-nsScriptLoader::GetScriptSource(nsScriptLoadRequest* aRequest, nsAutoString& inlineData)
+ScriptLoader::GetScriptSource(ScriptLoadRequest* aRequest, nsAutoString& inlineData)
{
// Return a SourceBufferHolder object holding the script's source text.
// |inlineData| is used to hold the text for inline objects.
@@ -1955,7 +1954,7 @@ nsScriptLoader::GetScriptSource(nsScriptLoadRequest* aRequest, nsAutoString& inl
}
nsresult
-nsScriptLoader::ProcessRequest(nsScriptLoadRequest* aRequest)
+ScriptLoader::ProcessRequest(ScriptLoadRequest* aRequest)
{
NS_ASSERTION(nsContentUtils::IsSafeToRunScript(),
"Processing requests when running scripts is unsafe.");
@@ -2055,8 +2054,8 @@ nsScriptLoader::ProcessRequest(nsScriptLoadRequest* aRequest)
}
void
-nsScriptLoader::FireScriptAvailable(nsresult aResult,
- nsScriptLoadRequest* aRequest)
+ScriptLoader::FireScriptAvailable(nsresult aResult,
+ ScriptLoadRequest* aRequest)
{
for (int32_t i = 0; i < mObservers.Count(); i++) {
nsCOMPtr<nsIScriptLoaderObserver> obs = mObservers[i];
@@ -2069,8 +2068,8 @@ nsScriptLoader::FireScriptAvailable(nsresult aResult,
}
void
-nsScriptLoader::FireScriptEvaluated(nsresult aResult,
- nsScriptLoadRequest* aRequest)
+ScriptLoader::FireScriptEvaluated(nsresult aResult,
+ ScriptLoadRequest* aRequest)
{
for (int32_t i = 0; i < mObservers.Count(); i++) {
nsCOMPtr<nsIScriptLoaderObserver> obs = mObservers[i];
@@ -2082,7 +2081,7 @@ nsScriptLoader::FireScriptEvaluated(nsresult aResult,
}
already_AddRefed<nsIScriptGlobalObject>
-nsScriptLoader::GetScriptGlobalObject()
+ScriptLoader::GetScriptGlobalObject()
{
nsCOMPtr<nsIDocument> master = mDocument->MasterDocument();
nsPIDOMWindowInner *pwin = master->GetInnerWindow();
@@ -2103,10 +2102,10 @@ nsScriptLoader::GetScriptGlobalObject()
}
nsresult
-nsScriptLoader::FillCompileOptionsForRequest(const AutoJSAPI&jsapi,
- nsScriptLoadRequest* aRequest,
- JS::Handle<JSObject*> aScopeChain,
- JS::CompileOptions* aOptions)
+ScriptLoader::FillCompileOptionsForRequest(const AutoJSAPI&jsapi,
+ ScriptLoadRequest* aRequest,
+ JS::Handle<JSObject*> aScopeChain,
+ JS::CompileOptions* aOptions)
{
// It's very important to use aRequest->mURI, not the final URI of the channel
// aRequest ended up getting script data from, as the script filename.
@@ -2150,7 +2149,7 @@ nsScriptLoader::FillCompileOptionsForRequest(const AutoJSAPI&jsapi,
}
nsresult
-nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest)
+ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest)
{
// We need a document to evaluate scripts.
if (!mDocument) {
@@ -2211,10 +2210,10 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest)
}
if (aRequest->IsModuleRequest()) {
- nsModuleLoadRequest* request = aRequest->AsModuleRequest();
+ ModuleLoadRequest* request = aRequest->AsModuleRequest();
MOZ_ASSERT(request->mModuleScript);
MOZ_ASSERT(!request->mOffThreadToken);
- nsModuleScript* ms = request->mModuleScript;
+ ModuleScript* ms = request->mModuleScript;
MOZ_ASSERT(!ms->IsUninstantiated());
if (ms->InstantiationFailed()) {
JS::Rooted<JS::Value> exception(aes.cx(), ms->Exception());
@@ -2243,7 +2242,7 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest)
}
void
-nsScriptLoader::ProcessPendingRequestsAsync()
+ScriptLoader::ProcessPendingRequestsAsync()
{
if (mParserBlockingRequest ||
!mXSLTRequests.isEmpty() ||
@@ -2252,14 +2251,14 @@ nsScriptLoader::ProcessPendingRequestsAsync()
!mDeferRequests.isEmpty() ||
!mPendingChildLoaders.IsEmpty()) {
NS_DispatchToCurrentThread(NewRunnableMethod(this,
- &nsScriptLoader::ProcessPendingRequests));
+ &ScriptLoader::ProcessPendingRequests));
}
}
void
-nsScriptLoader::ProcessPendingRequests()
+ScriptLoader::ProcessPendingRequests()
{
- RefPtr<nsScriptLoadRequest> request;
+ RefPtr<ScriptLoadRequest> request;
if (mParserBlockingRequest &&
mParserBlockingRequest->IsReadyToRun() &&
@@ -2311,7 +2310,7 @@ nsScriptLoader::ProcessPendingRequests()
while (!mPendingChildLoaders.IsEmpty() &&
ReadyToExecuteParserBlockingScripts()) {
- RefPtr<nsScriptLoader> child = mPendingChildLoaders[0];
+ RefPtr<ScriptLoader> child = mPendingChildLoaders[0];
mPendingChildLoaders.RemoveElementAt(0);
child->RemoveParserBlockingScriptExecutionBlocker();
}
@@ -2337,7 +2336,7 @@ nsScriptLoader::ProcessPendingRequests()
}
bool
-nsScriptLoader::ReadyToExecuteParserBlockingScripts()
+ScriptLoader::ReadyToExecuteParserBlockingScripts()
{
// Make sure the SelfReadyToExecuteParserBlockingScripts check is first, so
// that we don't block twice on an ancestor.
@@ -2346,7 +2345,7 @@ nsScriptLoader::ReadyToExecuteParserBlockingScripts()
}
for (nsIDocument* doc = mDocument; doc; doc = doc->GetParentDocument()) {
- nsScriptLoader* ancestor = doc->ScriptLoader();
+ ScriptLoader* ancestor = doc->ScriptLoader();
if (!ancestor->SelfReadyToExecuteParserBlockingScripts() &&
ancestor->AddPendingChildLoader(this)) {
AddParserBlockingScriptExecutionBlocker();
@@ -2394,10 +2393,10 @@ nsScriptLoader::ReadyToExecuteParserBlockingScripts()
}
/* static */ nsresult
-nsScriptLoader::ConvertToUTF16(nsIChannel* aChannel, const uint8_t* aData,
- uint32_t aLength, const nsAString& aHintCharset,
- nsIDocument* aDocument,
- char16_t*& aBufOut, size_t& aLengthOut)
+ScriptLoader::ConvertToUTF16(nsIChannel* aChannel, const uint8_t* aData,
+ uint32_t aLength, const nsAString& aHintCharset,
+ nsIDocument* aDocument,
+ char16_t*& aBufOut, size_t& aLengthOut)
{
if (!aLength) {
aBufOut = nullptr;
@@ -2474,14 +2473,14 @@ nsScriptLoader::ConvertToUTF16(nsIChannel* aChannel, const uint8_t* aData,
}
nsresult
-nsScriptLoader::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
- nsISupports* aContext,
- nsresult aChannelStatus,
- nsresult aSRIStatus,
- mozilla::Vector<char16_t> &aString,
- mozilla::dom::SRICheckDataVerifier* aSRIDataVerifier)
-{
- nsScriptLoadRequest* request = static_cast<nsScriptLoadRequest*>(aContext);
+ScriptLoader::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
+ nsISupports* aContext,
+ nsresult aChannelStatus,
+ nsresult aSRIStatus,
+ mozilla::Vector<char16_t> &aString,
+ mozilla::dom::SRICheckDataVerifier* aSRIDataVerifier)
+{
+ ScriptLoadRequest* request = static_cast<ScriptLoadRequest*>(aContext);
NS_ASSERTION(request, "null request in stream complete handler");
NS_ENSURE_TRUE(request, NS_ERROR_FAILURE);
@@ -2511,7 +2510,7 @@ nsScriptLoader::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
if (loadInfo->GetEnforceSRI()) {
MOZ_LOG(SRILogHelper::GetSriLog(), mozilla::LogLevel::Debug,
- ("nsScriptLoader::OnStreamComplete, required SRI not found"));
+ ("ScriptLoader::OnStreamComplete, required SRI not found"));
nsCOMPtr<nsIContentSecurityPolicy> csp;
loadInfo->LoadingPrincipal()->GetCsp(getter_AddRefs(csp));
nsAutoCString violationURISpec;
@@ -2544,29 +2543,29 @@ nsScriptLoader::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
MOZ_ASSERT_IF(request->IsModuleRequest(),
request->AsModuleRequest()->IsTopLevel());
if (request->isInList()) {
- RefPtr<nsScriptLoadRequest> req = mDeferRequests.Steal(request);
+ RefPtr<ScriptLoadRequest> req = mDeferRequests.Steal(request);
FireScriptAvailable(rv, req);
}
} else if (request->mIsAsync) {
MOZ_ASSERT_IF(request->IsModuleRequest(),
request->AsModuleRequest()->IsTopLevel());
if (request->isInList()) {
- RefPtr<nsScriptLoadRequest> req = mLoadingAsyncRequests.Steal(request);
+ RefPtr<ScriptLoadRequest> req = mLoadingAsyncRequests.Steal(request);
FireScriptAvailable(rv, req);
}
} else if (request->mIsNonAsyncScriptInserted) {
if (request->isInList()) {
- RefPtr<nsScriptLoadRequest> req =
+ RefPtr<ScriptLoadRequest> req =
mNonAsyncExternalScriptInsertedRequests.Steal(request);
FireScriptAvailable(rv, req);
}
} else if (request->mIsXSLT) {
if (request->isInList()) {
- RefPtr<nsScriptLoadRequest> req = mXSLTRequests.Steal(request);
+ RefPtr<ScriptLoadRequest> req = mXSLTRequests.Steal(request);
FireScriptAvailable(rv, req);
}
} else if (request->IsModuleRequest()) {
- nsModuleLoadRequest* modReq = request->AsModuleRequest();
+ ModuleLoadRequest* modReq = request->AsModuleRequest();
MOZ_ASSERT(!modReq->IsTopLevel());
MOZ_ASSERT(!modReq->isInList());
modReq->Cancel();
@@ -2597,19 +2596,19 @@ nsScriptLoader::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
}
void
-nsScriptLoader::UnblockParser(nsScriptLoadRequest* aParserBlockingRequest)
+ScriptLoader::UnblockParser(ScriptLoadRequest* aParserBlockingRequest)
{
aParserBlockingRequest->mElement->UnblockParser();
}
void
-nsScriptLoader::ContinueParserAsync(nsScriptLoadRequest* aParserBlockingRequest)
+ScriptLoader::ContinueParserAsync(ScriptLoadRequest* aParserBlockingRequest)
{
aParserBlockingRequest->mElement->ContinueParserAsync();
}
uint32_t
-nsScriptLoader::NumberOfProcessors()
+ScriptLoader::NumberOfProcessors()
{
if (mNumberOfProcessors > 0)
return mNumberOfProcessors;
@@ -2621,7 +2620,7 @@ nsScriptLoader::NumberOfProcessors()
}
void
-nsScriptLoader::MaybeMoveToLoadedList(nsScriptLoadRequest* aRequest)
+ScriptLoader::MaybeMoveToLoadedList(ScriptLoadRequest* aRequest)
{
MOZ_ASSERT(aRequest->IsReadyToRun());
@@ -2631,17 +2630,17 @@ nsScriptLoader::MaybeMoveToLoadedList(nsScriptLoadRequest* aRequest)
if (aRequest->mIsAsync) {
MOZ_ASSERT(aRequest->isInList());
if (aRequest->isInList()) {
- RefPtr<nsScriptLoadRequest> req = mLoadingAsyncRequests.Steal(aRequest);
+ RefPtr<ScriptLoadRequest> req = mLoadingAsyncRequests.Steal(aRequest);
mLoadedAsyncRequests.AppendElement(req);
}
}
}
nsresult
-nsScriptLoader::PrepareLoadedRequest(nsScriptLoadRequest* aRequest,
- nsIIncrementalStreamLoader* aLoader,
- nsresult aStatus,
- mozilla::Vector<char16_t> &aString)
+ScriptLoader::PrepareLoadedRequest(ScriptLoadRequest* aRequest,
+ nsIIncrementalStreamLoader* aLoader,
+ nsresult aStatus,
+ mozilla::Vector<char16_t> &aString)
{
if (NS_FAILED(aStatus)) {
return aStatus;
@@ -2713,7 +2712,7 @@ nsScriptLoader::PrepareLoadedRequest(nsScriptLoadRequest* aRequest,
"aRequest should be pending!");
if (aRequest->IsModuleRequest()) {
- nsModuleLoadRequest* request = aRequest->AsModuleRequest();
+ ModuleLoadRequest* request = aRequest->AsModuleRequest();
// When loading a module, only responses with a JavaScript MIME type are
// acceptable.
@@ -2744,7 +2743,7 @@ nsScriptLoader::PrepareLoadedRequest(nsScriptLoadRequest* aRequest,
MOZ_ASSERT(!aRequest->IsModuleRequest());
nsresult rv = AttemptAsyncScriptCompile(aRequest);
if (rv == NS_OK) {
- MOZ_ASSERT(aRequest->mProgress == nsScriptLoadRequest::Progress::Compiling,
+ MOZ_ASSERT(aRequest->mProgress == ScriptLoadRequest::Progress::Compiling,
"Request should be off-thread compiling now.");
return NS_OK;
}
@@ -2763,7 +2762,7 @@ nsScriptLoader::PrepareLoadedRequest(nsScriptLoadRequest* aRequest,
}
void
-nsScriptLoader::ParsingComplete(bool aTerminated)
+ScriptLoader::ParsingComplete(bool aTerminated)
{
if (mDeferEnabled) {
// Have to check because we apparently get ParsingComplete
@@ -2789,12 +2788,12 @@ nsScriptLoader::ParsingComplete(bool aTerminated)
}
void
-nsScriptLoader::PreloadURI(nsIURI *aURI, const nsAString &aCharset,
- const nsAString &aType,
- const nsAString &aCrossOrigin,
- const nsAString& aIntegrity,
- bool aScriptFromHead,
- const mozilla::net::ReferrerPolicy aReferrerPolicy)
+ScriptLoader::PreloadURI(nsIURI *aURI, const nsAString &aCharset,
+ const nsAString &aType,
+ const nsAString &aCrossOrigin,
+ const nsAString& aIntegrity,
+ bool aScriptFromHead,
+ const mozilla::net::ReferrerPolicy aReferrerPolicy)
{
NS_ENSURE_TRUE_VOID(mDocument);
// Check to see if scripts has been turned off.
@@ -2810,7 +2809,7 @@ nsScriptLoader::PreloadURI(nsIURI *aURI, const nsAString &aCharset,
SRIMetadata sriMetadata;
if (!aIntegrity.IsEmpty()) {
MOZ_LOG(SRILogHelper::GetSriLog(), mozilla::LogLevel::Debug,
- ("nsScriptLoader::PreloadURI, integrity=%s",
+ ("ScriptLoader::PreloadURI, integrity=%s",
NS_ConvertUTF16toUTF8(aIntegrity).get()));
nsAutoCString sourceUri;
if (mDocument->GetDocumentURI()) {
@@ -2819,8 +2818,8 @@ nsScriptLoader::PreloadURI(nsIURI *aURI, const nsAString &aCharset,
SRICheck::IntegrityMetadata(aIntegrity, sourceUri, mReporter, &sriMetadata);
}
- RefPtr<nsScriptLoadRequest> request =
- CreateLoadRequest(nsScriptKind::Classic, nullptr, 0,
+ RefPtr<ScriptLoadRequest> request =
+ CreateLoadRequest(ScriptKind::Classic, nullptr, 0,
Element::StringToCORSMode(aCrossOrigin), sriMetadata);
request->mURI = aURI;
request->mIsInline = false;
@@ -2837,7 +2836,7 @@ nsScriptLoader::PreloadURI(nsIURI *aURI, const nsAString &aCharset,
}
void
-nsScriptLoader::AddDeferRequest(nsScriptLoadRequest* aRequest)
+ScriptLoader::AddDeferRequest(ScriptLoadRequest* aRequest)
{
aRequest->mIsDefer = true;
mDeferRequests.AppendElement(aRequest);
@@ -2850,7 +2849,7 @@ nsScriptLoader::AddDeferRequest(nsScriptLoadRequest* aRequest)
}
bool
-nsScriptLoader::MaybeRemovedDeferRequests()
+ScriptLoader::MaybeRemovedDeferRequests()
{
if (mDeferRequests.isEmpty() && mDocument &&
mBlockingDOMContentLoaded) {
@@ -2862,12 +2861,12 @@ nsScriptLoader::MaybeRemovedDeferRequests()
}
//////////////////////////////////////////////////////////////
-// nsScriptLoadHandler
+// ScriptLoadHandler
//////////////////////////////////////////////////////////////
-nsScriptLoadHandler::nsScriptLoadHandler(nsScriptLoader *aScriptLoader,
- nsScriptLoadRequest *aRequest,
- mozilla::dom::SRICheckDataVerifier *aSRIDataVerifier)
+ScriptLoadHandler::ScriptLoadHandler(ScriptLoader *aScriptLoader,
+ ScriptLoadRequest *aRequest,
+ mozilla::dom::SRICheckDataVerifier *aSRIDataVerifier)
: mScriptLoader(aScriptLoader),
mRequest(aRequest),
mSRIDataVerifier(aSRIDataVerifier),
@@ -2876,17 +2875,17 @@ nsScriptLoadHandler::nsScriptLoadHandler(nsScriptLoader *aScriptLoader,
mBuffer()
{}
-nsScriptLoadHandler::~nsScriptLoadHandler()
+ScriptLoadHandler::~ScriptLoadHandler()
{}
-NS_IMPL_ISUPPORTS(nsScriptLoadHandler, nsIIncrementalStreamLoaderObserver)
+NS_IMPL_ISUPPORTS(ScriptLoadHandler, nsIIncrementalStreamLoaderObserver)
NS_IMETHODIMP
-nsScriptLoadHandler::OnIncrementalData(nsIIncrementalStreamLoader* aLoader,
- nsISupports* aContext,
- uint32_t aDataLength,
- const uint8_t* aData,
- uint32_t *aConsumedLength)
+ScriptLoadHandler::OnIncrementalData(nsIIncrementalStreamLoader* aLoader,
+ nsISupports* aContext,
+ uint32_t aDataLength,
+ const uint8_t* aData,
+ uint32_t *aConsumedLength)
{
if (mRequest->IsCanceled()) {
// If request cancelled, ignore any incoming data.
@@ -2916,9 +2915,9 @@ nsScriptLoadHandler::OnIncrementalData(nsIIncrementalStreamLoader* aLoader,
}
nsresult
-nsScriptLoadHandler::TryDecodeRawData(const uint8_t* aData,
- uint32_t aDataLength,
- bool aEndOfStream)
+ScriptLoadHandler::TryDecodeRawData(const uint8_t* aData,
+ uint32_t aDataLength,
+ bool aEndOfStream)
{
int32_t srcLen = aDataLength;
const char* src = reinterpret_cast<const char *>(aData);
@@ -2938,9 +2937,9 @@ nsScriptLoadHandler::TryDecodeRawData(const uint8_t* aData,
}
rv = mDecoder->Convert(src,
- &srcLen,
- mBuffer.begin() + haveRead,
- &dstLen);
+ &srcLen,
+ mBuffer.begin() + haveRead,
+ &dstLen);
NS_ENSURE_SUCCESS(rv, rv);
@@ -2952,10 +2951,10 @@ nsScriptLoadHandler::TryDecodeRawData(const uint8_t* aData,
}
bool
-nsScriptLoadHandler::EnsureDecoder(nsIIncrementalStreamLoader *aLoader,
- const uint8_t* aData,
- uint32_t aDataLength,
- bool aEndOfStream)
+ScriptLoadHandler::EnsureDecoder(nsIIncrementalStreamLoader *aLoader,
+ const uint8_t* aData,
+ uint32_t aDataLength,
+ bool aEndOfStream)
{
// Check if decoder has already been created.
if (mDecoder) {
@@ -3005,9 +3004,9 @@ nsScriptLoadHandler::EnsureDecoder(nsIIncrementalStreamLoader *aLoader,
if (!mRequest->IsPreload()) {
mRequest->mElement->GetScriptCharset(hintCharset);
} else {
- nsTArray<nsScriptLoader::PreloadInfo>::index_type i =
+ nsTArray<ScriptLoader::PreloadInfo>::index_type i =
mScriptLoader->mPreloads.IndexOf(mRequest, 0,
- nsScriptLoader::PreloadRequestComparator());
+ ScriptLoader::PreloadRequestComparator());
NS_ASSERTION(i != mScriptLoader->mPreloads.NoIndex,
"Incorrect preload bookkeeping");
@@ -3036,11 +3035,11 @@ nsScriptLoadHandler::EnsureDecoder(nsIIncrementalStreamLoader *aLoader,
}
NS_IMETHODIMP
-nsScriptLoadHandler::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
- nsISupports* aContext,
- nsresult aStatus,
- uint32_t aDataLength,
- const uint8_t* aData)
+ScriptLoadHandler::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
+ nsISupports* aContext,
+ nsresult aStatus,
+ uint32_t aDataLength,
+ const uint8_t* aData)
{
if (!mRequest->IsCanceled()) {
DebugOnly<bool> encoderSet =
@@ -3059,3 +3058,6 @@ nsScriptLoadHandler::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
return mScriptLoader->OnStreamComplete(aLoader, mRequest, aStatus, mSRIStatus,
mBuffer, mSRIDataVerifier);
}
+
+} // dom namespace
+} // mozilla namespace \ No newline at end of file
diff --git a/dom/base/nsScriptLoader.h b/dom/script/ScriptLoader.h
index a00239be5f..6fe76eca88 100644
--- a/dom/base/nsScriptLoader.h
+++ b/dom/script/ScriptLoader.h
@@ -8,8 +8,8 @@
* A class that handles loading and evaluation of <script> elements.
*/
-#ifndef __nsScriptLoader_h__
-#define __nsScriptLoader_h__
+#ifndef mozilla_dom_ScriptLoader_h
+#define mozilla_dom_ScriptLoader_h
#include "nsCOMPtr.h"
#include "nsRefPtrHashtable.h"
@@ -30,9 +30,6 @@
#include "mozilla/net/ReferrerPolicy.h"
#include "mozilla/Vector.h"
-class nsModuleLoadRequest;
-class nsModuleScript;
-class nsScriptLoadRequestList;
class nsIURI;
namespace JS {
@@ -41,37 +38,39 @@ namespace JS {
namespace mozilla {
namespace dom {
+
class AutoJSAPI;
-} // namespace dom
-} // namespace mozilla
+class ModuleLoadRequest;
+class ModuleScript;
+class ScriptLoadRequestList;
//////////////////////////////////////////////////////////////
// Per-request data structure
//////////////////////////////////////////////////////////////
-enum class nsScriptKind {
+enum class ScriptKind {
Classic,
Module
};
-class nsScriptLoadRequest : public nsISupports,
- private mozilla::LinkedListElement<nsScriptLoadRequest>
+class ScriptLoadRequest : public nsISupports,
+ private mozilla::LinkedListElement<ScriptLoadRequest>
{
- typedef LinkedListElement<nsScriptLoadRequest> super;
+ typedef LinkedListElement<ScriptLoadRequest> super;
- // Allow LinkedListElement<nsScriptLoadRequest> to cast us to itself as needed.
- friend class mozilla::LinkedListElement<nsScriptLoadRequest>;
- friend class nsScriptLoadRequestList;
+ // Allow LinkedListElement<ScriptLoadRequest> to cast us to itself as needed.
+ friend class mozilla::LinkedListElement<ScriptLoadRequest>;
+ friend class ScriptLoadRequestList;
protected:
- virtual ~nsScriptLoadRequest();
+ virtual ~ScriptLoadRequest();
public:
- nsScriptLoadRequest(nsScriptKind aKind,
- nsIScriptElement* aElement,
- uint32_t aVersion,
- mozilla::CORSMode aCORSMode,
- const mozilla::dom::SRIMetadata &aIntegrity)
+ ScriptLoadRequest(ScriptKind aKind,
+ nsIScriptElement* aElement,
+ uint32_t aVersion,
+ mozilla::CORSMode aCORSMode,
+ const mozilla::dom::SRIMetadata &aIntegrity)
: mKind(aKind),
mElement(aElement),
mProgress(Progress::Loading),
@@ -95,14 +94,14 @@ public:
}
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
- NS_DECL_CYCLE_COLLECTION_CLASS(nsScriptLoadRequest)
+ NS_DECL_CYCLE_COLLECTION_CLASS(ScriptLoadRequest)
bool IsModuleRequest() const
{
- return mKind == nsScriptKind::Module;
+ return mKind == ScriptKind::Module;
}
- nsModuleLoadRequest* AsModuleRequest();
+ ModuleLoadRequest* AsModuleRequest();
void FireScriptAvailable(nsresult aResult)
{
@@ -154,7 +153,7 @@ public:
using super::getNext;
using super::isInList;
- const nsScriptKind mKind;
+ const ScriptKind mKind;
nsCOMPtr<nsIScriptElement> mElement;
Progress mProgress; // Are we still waiting for a load to complete?
bool mIsInline; // Is the script inline or loaded?
@@ -179,23 +178,23 @@ public:
mozilla::net::ReferrerPolicy mReferrerPolicy;
};
-class nsScriptLoadRequestList : private mozilla::LinkedList<nsScriptLoadRequest>
+class ScriptLoadRequestList : private mozilla::LinkedList<ScriptLoadRequest>
{
- typedef mozilla::LinkedList<nsScriptLoadRequest> super;
+ typedef mozilla::LinkedList<ScriptLoadRequest> super;
public:
- ~nsScriptLoadRequestList();
+ ~ScriptLoadRequestList();
void Clear();
#ifdef DEBUG
- bool Contains(nsScriptLoadRequest* aElem) const;
+ bool Contains(ScriptLoadRequest* aElem) const;
#endif // DEBUG
using super::getFirst;
using super::isEmpty;
- void AppendElement(nsScriptLoadRequest* aElem)
+ void AppendElement(ScriptLoadRequest* aElem)
{
MOZ_ASSERT(!aElem->isInList());
NS_ADDREF(aElem);
@@ -203,20 +202,20 @@ public:
}
MOZ_MUST_USE
- already_AddRefed<nsScriptLoadRequest> Steal(nsScriptLoadRequest* aElem)
+ already_AddRefed<ScriptLoadRequest> Steal(ScriptLoadRequest* aElem)
{
aElem->removeFrom(*this);
return dont_AddRef(aElem);
}
MOZ_MUST_USE
- already_AddRefed<nsScriptLoadRequest> StealFirst()
+ already_AddRefed<ScriptLoadRequest> StealFirst()
{
MOZ_ASSERT(!isEmpty());
return Steal(getFirst());
}
- void Remove(nsScriptLoadRequest* aElem)
+ void Remove(ScriptLoadRequest* aElem)
{
aElem->removeFrom(*this);
NS_RELEASE(aElem);
@@ -227,12 +226,12 @@ public:
// Script loader implementation
//////////////////////////////////////////////////////////////
-class nsScriptLoader final : public nsISupports
+class ScriptLoader final : public nsISupports
{
class MOZ_STACK_CLASS AutoCurrentScriptUpdater
{
public:
- AutoCurrentScriptUpdater(nsScriptLoader* aScriptLoader,
+ AutoCurrentScriptUpdater(ScriptLoader* aScriptLoader,
nsIScriptElement* aCurrentScript)
: mOldScript(aScriptLoader->mCurrentScript)
, mScriptLoader(aScriptLoader)
@@ -245,19 +244,19 @@ class nsScriptLoader final : public nsISupports
}
private:
nsCOMPtr<nsIScriptElement> mOldScript;
- nsScriptLoader* mScriptLoader;
+ ScriptLoader* mScriptLoader;
};
- friend class nsModuleLoadRequest;
- friend class nsScriptRequestProcessor;
- friend class nsScriptLoadHandler;
+ friend class ModuleLoadRequest;
+ friend class ScriptRequestProcessor;
+ friend class ScriptLoadHandler;
friend class AutoCurrentScriptUpdater;
public:
- explicit nsScriptLoader(nsIDocument* aDocument);
+ explicit ScriptLoader(nsIDocument* aDocument);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
- NS_DECL_CYCLE_COLLECTION_CLASS(nsScriptLoader)
+ NS_DECL_CYCLE_COLLECTION_CLASS(ScriptLoader)
/**
* The loader maintains a weak reference to the document with
@@ -395,7 +394,7 @@ public:
/**
* Handle the completion of a stream. This is called by the
- * nsScriptLoadHandler object which observes the IncrementalStreamLoader
+ * ScriptLoadHandler object which observes the IncrementalStreamLoader
* loading the script.
*/
nsresult OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
@@ -463,17 +462,17 @@ public:
* Process a request that was deferred so that the script could be compiled
* off thread.
*/
- nsresult ProcessOffThreadRequest(nsScriptLoadRequest *aRequest);
+ nsresult ProcessOffThreadRequest(ScriptLoadRequest *aRequest);
- bool AddPendingChildLoader(nsScriptLoader* aChild) {
+ bool AddPendingChildLoader(ScriptLoader* aChild) {
return mPendingChildLoaders.AppendElement(aChild) != nullptr;
}
private:
- virtual ~nsScriptLoader();
+ virtual ~ScriptLoader();
- nsScriptLoadRequest* CreateLoadRequest(
- nsScriptKind aKind,
+ ScriptLoadRequest* CreateLoadRequest(
+ ScriptKind aKind,
nsIScriptElement* aElement,
uint32_t aVersion,
mozilla::CORSMode aCORSMode,
@@ -482,12 +481,12 @@ private:
/**
* Unblocks the creator parser of the parser-blocking scripts.
*/
- void UnblockParser(nsScriptLoadRequest* aParserBlockingRequest);
+ void UnblockParser(ScriptLoadRequest* aParserBlockingRequest);
/**
* Asynchronously resumes the creator parser of the parser-blocking scripts.
*/
- void ContinueParserAsync(nsScriptLoadRequest* aParserBlockingRequest);
+ void ContinueParserAsync(ScriptLoadRequest* aParserBlockingRequest);
/**
@@ -502,7 +501,7 @@ private:
/**
* Start a load for aRequest's URI.
*/
- nsresult StartLoad(nsScriptLoadRequest *aRequest, const nsAString &aType,
+ nsresult StartLoad(ScriptLoadRequest *aRequest, const nsAString &aType,
bool aScriptFromHead);
/**
@@ -539,83 +538,83 @@ private:
return mEnabled && !mBlockerCount;
}
- nsresult AttemptAsyncScriptCompile(nsScriptLoadRequest* aRequest);
- nsresult ProcessRequest(nsScriptLoadRequest* aRequest);
- nsresult CompileOffThreadOrProcessRequest(nsScriptLoadRequest* aRequest);
+ nsresult AttemptAsyncScriptCompile(ScriptLoadRequest* aRequest);
+ nsresult ProcessRequest(ScriptLoadRequest* aRequest);
+ nsresult CompileOffThreadOrProcessRequest(ScriptLoadRequest* aRequest);
void FireScriptAvailable(nsresult aResult,
- nsScriptLoadRequest* aRequest);
+ ScriptLoadRequest* aRequest);
void FireScriptEvaluated(nsresult aResult,
- nsScriptLoadRequest* aRequest);
- nsresult EvaluateScript(nsScriptLoadRequest* aRequest);
+ ScriptLoadRequest* aRequest);
+ nsresult EvaluateScript(ScriptLoadRequest* aRequest);
already_AddRefed<nsIScriptGlobalObject> GetScriptGlobalObject();
nsresult FillCompileOptionsForRequest(const mozilla::dom::AutoJSAPI& jsapi,
- nsScriptLoadRequest* aRequest,
+ ScriptLoadRequest* aRequest,
JS::Handle<JSObject*> aScopeChain,
JS::CompileOptions* aOptions);
uint32_t NumberOfProcessors();
- nsresult PrepareLoadedRequest(nsScriptLoadRequest* aRequest,
+ nsresult PrepareLoadedRequest(ScriptLoadRequest* aRequest,
nsIIncrementalStreamLoader* aLoader,
nsresult aStatus,
mozilla::Vector<char16_t> &aString);
- void AddDeferRequest(nsScriptLoadRequest* aRequest);
+ void AddDeferRequest(ScriptLoadRequest* aRequest);
bool MaybeRemovedDeferRequests();
- void MaybeMoveToLoadedList(nsScriptLoadRequest* aRequest);
+ void MaybeMoveToLoadedList(ScriptLoadRequest* aRequest);
- JS::SourceBufferHolder GetScriptSource(nsScriptLoadRequest* aRequest,
+ JS::SourceBufferHolder GetScriptSource(ScriptLoadRequest* aRequest,
nsAutoString& inlineData);
bool ModuleScriptsEnabled();
- void SetModuleFetchStarted(nsModuleLoadRequest *aRequest);
- void SetModuleFetchFinishedAndResumeWaitingRequests(nsModuleLoadRequest *aRequest,
+ void SetModuleFetchStarted(ModuleLoadRequest *aRequest);
+ void SetModuleFetchFinishedAndResumeWaitingRequests(ModuleLoadRequest *aRequest,
nsresult aResult);
- bool IsFetchingModule(nsModuleLoadRequest *aRequest) const;
+ bool IsFetchingModule(ModuleLoadRequest *aRequest) const;
- bool ModuleMapContainsModule(nsModuleLoadRequest *aRequest) const;
- RefPtr<mozilla::GenericPromise> WaitForModuleFetch(nsModuleLoadRequest *aRequest);
- nsModuleScript* GetFetchedModule(nsIURI* aURL) const;
+ bool ModuleMapContainsModule(ModuleLoadRequest *aRequest) const;
+ RefPtr<mozilla::GenericPromise> WaitForModuleFetch(ModuleLoadRequest *aRequest);
+ ModuleScript* GetFetchedModule(nsIURI* aURL) const;
friend bool
HostResolveImportedModule(JSContext* aCx, unsigned argc, JS::Value* vp);
- nsresult CreateModuleScript(nsModuleLoadRequest* aRequest);
- nsresult ProcessFetchedModuleSource(nsModuleLoadRequest* aRequest);
- void ProcessLoadedModuleTree(nsModuleLoadRequest* aRequest);
- bool InstantiateModuleTree(nsModuleLoadRequest* aRequest);
- void StartFetchingModuleDependencies(nsModuleLoadRequest* aRequest);
+ nsresult CreateModuleScript(ModuleLoadRequest* aRequest);
+ nsresult ProcessFetchedModuleSource(ModuleLoadRequest* aRequest);
+ void ProcessLoadedModuleTree(ModuleLoadRequest* aRequest);
+ bool InstantiateModuleTree(ModuleLoadRequest* aRequest);
+ void StartFetchingModuleDependencies(ModuleLoadRequest* aRequest);
RefPtr<mozilla::GenericPromise>
- StartFetchingModuleAndDependencies(nsModuleLoadRequest* aRequest, nsIURI* aURI);
+ StartFetchingModuleAndDependencies(ModuleLoadRequest* aRequest, nsIURI* aURI);
nsIDocument* mDocument; // [WEAK]
nsCOMArray<nsIScriptLoaderObserver> mObservers;
- nsScriptLoadRequestList mNonAsyncExternalScriptInsertedRequests;
+ ScriptLoadRequestList mNonAsyncExternalScriptInsertedRequests;
// mLoadingAsyncRequests holds async requests while they're loading; when they
// have been loaded they are moved to mLoadedAsyncRequests.
- nsScriptLoadRequestList mLoadingAsyncRequests;
- nsScriptLoadRequestList mLoadedAsyncRequests;
- nsScriptLoadRequestList mDeferRequests;
- nsScriptLoadRequestList mXSLTRequests;
- RefPtr<nsScriptLoadRequest> mParserBlockingRequest;
+ ScriptLoadRequestList mLoadingAsyncRequests;
+ ScriptLoadRequestList mLoadedAsyncRequests;
+ ScriptLoadRequestList mDeferRequests;
+ ScriptLoadRequestList mXSLTRequests;
+ RefPtr<ScriptLoadRequest> mParserBlockingRequest;
// In mRequests, the additional information here is stored by the element.
struct PreloadInfo {
- RefPtr<nsScriptLoadRequest> mRequest;
+ RefPtr<ScriptLoadRequest> mRequest;
nsString mCharset;
};
- friend void ImplCycleCollectionUnlink(nsScriptLoader::PreloadInfo& aField);
+ friend void ImplCycleCollectionUnlink(ScriptLoader::PreloadInfo& aField);
friend void ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
- nsScriptLoader::PreloadInfo& aField,
+ ScriptLoader::PreloadInfo& aField,
const char* aName, uint32_t aFlags);
struct PreloadRequestComparator {
- bool Equals(const PreloadInfo &aPi, nsScriptLoadRequest * const &aRequest)
+ bool Equals(const PreloadInfo &aPi, ScriptLoadRequest * const &aRequest)
const
{
return aRequest == aPi.mRequest;
@@ -628,7 +627,7 @@ private:
nsCOMPtr<nsIScriptElement> mCurrentScript;
nsCOMPtr<nsIScriptElement> mCurrentParserInsertedScript;
- nsTArray< RefPtr<nsScriptLoader> > mPendingChildLoaders;
+ nsTArray< RefPtr<ScriptLoader> > mPendingChildLoaders;
uint32_t mParserBlockingBlockerCount;
uint32_t mBlockerCount;
uint32_t mNumberOfProcessors;
@@ -639,23 +638,23 @@ private:
// Module map
nsRefPtrHashtable<nsURIHashKey, mozilla::GenericPromise::Private> mFetchingModules;
- nsRefPtrHashtable<nsURIHashKey, nsModuleScript> mFetchedModules;
+ nsRefPtrHashtable<nsURIHashKey, ModuleScript> mFetchedModules;
nsCOMPtr<nsIConsoleReportCollector> mReporter;
};
-class nsScriptLoadHandler final : public nsIIncrementalStreamLoaderObserver
+class ScriptLoadHandler final : public nsIIncrementalStreamLoaderObserver
{
public:
- explicit nsScriptLoadHandler(nsScriptLoader* aScriptLoader,
- nsScriptLoadRequest *aRequest,
- mozilla::dom::SRICheckDataVerifier *aSRIDataVerifier);
+ explicit ScriptLoadHandler(ScriptLoader* aScriptLoader,
+ ScriptLoadRequest *aRequest,
+ mozilla::dom::SRICheckDataVerifier *aSRIDataVerifier);
NS_DECL_ISUPPORTS
NS_DECL_NSIINCREMENTALSTREAMLOADEROBSERVER
private:
- virtual ~nsScriptLoadHandler();
+ virtual ~ScriptLoadHandler();
/*
* Try to decode some raw data.
@@ -673,10 +672,10 @@ private:
bool aEndOfStream);
// ScriptLoader which will handle the parsed script.
- RefPtr<nsScriptLoader> mScriptLoader;
+ RefPtr<ScriptLoader> mScriptLoader;
- // The nsScriptLoadRequest for this load.
- RefPtr<nsScriptLoadRequest> mRequest;
+ // The ScriptLoadRequest for this load.
+ RefPtr<ScriptLoadRequest> mRequest;
// SRI data verifier.
nsAutoPtr<mozilla::dom::SRICheckDataVerifier> mSRIDataVerifier;
@@ -711,7 +710,10 @@ public:
}
bool mWasEnabled;
- RefPtr<nsScriptLoader> mLoader;
+ RefPtr<ScriptLoader> mLoader;
};
-#endif //__nsScriptLoader_h__
+} // namespace dom
+} // namespace mozilla
+
+#endif //mozilla_dom_ScriptLoader_h
diff --git a/dom/base/ScriptSettings.cpp b/dom/script/ScriptSettings.cpp
index 92ab221c95..92ab221c95 100644
--- a/dom/base/ScriptSettings.cpp
+++ b/dom/script/ScriptSettings.cpp
diff --git a/dom/base/ScriptSettings.h b/dom/script/ScriptSettings.h
index 05e62f55e2..05e62f55e2 100644
--- a/dom/base/ScriptSettings.h
+++ b/dom/script/ScriptSettings.h
diff --git a/dom/script/moz.build b/dom/script/moz.build
new file mode 100644
index 0000000000..063d154265
--- /dev/null
+++ b/dom/script/moz.build
@@ -0,0 +1,33 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# 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/.
+
+XPIDL_SOURCES += [
+ 'nsIScriptLoaderObserver.idl',
+]
+
+XPIDL_MODULE = 'dom'
+
+EXPORTS += ['nsIScriptElement.h']
+
+EXPORTS.mozilla.dom += [
+ 'ScriptElement.h',
+ 'ScriptLoader.h',
+ 'ScriptSettings.h',
+]
+
+SOURCES += [
+ 'ScriptElement.cpp',
+ 'ScriptLoader.cpp',
+ 'ScriptSettings.cpp',
+]
+
+LOCAL_INCLUDES += [
+ '/dom/base',
+ '/dom/workers',
+]
+
+include('/ipc/chromium/chromium-config.mozbuild')
+
+FINAL_LIBRARY = 'xul'
diff --git a/dom/base/nsIScriptElement.h b/dom/script/nsIScriptElement.h
index 470d51c948..470d51c948 100644
--- a/dom/base/nsIScriptElement.h
+++ b/dom/script/nsIScriptElement.h
diff --git a/dom/base/nsIScriptLoaderObserver.idl b/dom/script/nsIScriptLoaderObserver.idl
index ed71965255..ed71965255 100644
--- a/dom/base/nsIScriptLoaderObserver.idl
+++ b/dom/script/nsIScriptLoaderObserver.idl
diff --git a/dom/svg/SVGScriptElement.cpp b/dom/svg/SVGScriptElement.cpp
index 0cc827b9fd..7adce2f46b 100644
--- a/dom/svg/SVGScriptElement.cpp
+++ b/dom/svg/SVGScriptElement.cpp
@@ -42,7 +42,7 @@ NS_IMPL_ISUPPORTS_INHERITED(SVGScriptElement, SVGScriptElementBase,
SVGScriptElement::SVGScriptElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
FromParser aFromParser)
: SVGScriptElementBase(aNodeInfo)
- , nsScriptElement(aFromParser)
+ , ScriptElement(aFromParser)
{
AddMutationObserver(this);
}
@@ -168,7 +168,7 @@ SVGScriptElement::FreezeUriAsyncDefer()
}
//----------------------------------------------------------------------
-// nsScriptElement methods
+// ScriptElement methods
bool
SVGScriptElement::HasScriptContent()
diff --git a/dom/svg/SVGScriptElement.h b/dom/svg/SVGScriptElement.h
index d3a233b728..79a3de70da 100644
--- a/dom/svg/SVGScriptElement.h
+++ b/dom/svg/SVGScriptElement.h
@@ -10,7 +10,7 @@
#include "nsSVGElement.h"
#include "nsCOMPtr.h"
#include "nsSVGString.h"
-#include "nsScriptElement.h"
+#include "mozilla/dom/ScriptElement.h"
class nsIDocument;
@@ -24,7 +24,7 @@ namespace dom {
typedef nsSVGElement SVGScriptElementBase;
class SVGScriptElement final : public SVGScriptElementBase,
- public nsScriptElement
+ public ScriptElement
{
protected:
friend nsresult (::NS_NewSVGScriptElement(nsIContent **aResult,
@@ -47,7 +47,7 @@ public:
virtual void FreezeUriAsyncDefer() override;
virtual CORSMode GetCORSMode() const override;
- // nsScriptElement
+ // ScriptElement
virtual bool HasScriptContent() override;
// nsIContent specializations:
diff --git a/dom/workers/ScriptLoader.cpp b/dom/workers/ScriptLoader.cpp
index 56b18441e5..bcec94dcb4 100644
--- a/dom/workers/ScriptLoader.cpp
+++ b/dom/workers/ScriptLoader.cpp
@@ -34,7 +34,6 @@
#include "nsIPipe.h"
#include "nsIOutputStream.h"
#include "nsPrintfCString.h"
-#include "nsScriptLoader.h"
#include "nsString.h"
#include "nsStreamUtils.h"
#include "nsTArray.h"
@@ -58,6 +57,7 @@
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/PromiseNativeHandler.h"
#include "mozilla/dom/Response.h"
+#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/SRILogHelper.h"
#include "mozilla/UniquePtr.h"
@@ -1075,14 +1075,14 @@ private:
// May be null.
nsIDocument* parentDoc = mWorkerPrivate->GetDocument();
- // Use the regular nsScriptLoader for this grunt work! Should be just fine
+ // Use the regular ScriptLoader for this grunt work! Should be just fine
// because we're running on the main thread.
// Unlike <script> tags, Worker scripts are always decoded as UTF-8,
// per spec. So we explicitly pass in the charset hint.
- rv = nsScriptLoader::ConvertToUTF16(aLoadInfo.mChannel, aString, aStringLen,
- NS_LITERAL_STRING("UTF-8"), parentDoc,
- aLoadInfo.mScriptTextBuf,
- aLoadInfo.mScriptTextLength);
+ rv = ScriptLoader::ConvertToUTF16(aLoadInfo.mChannel, aString, aStringLen,
+ NS_LITERAL_STRING("UTF-8"), parentDoc,
+ aLoadInfo.mScriptTextBuf,
+ aLoadInfo.mScriptTextLength);
if (NS_FAILED(rv)) {
return rv;
}
@@ -1289,10 +1289,10 @@ private:
MOZ_ASSERT(!loadInfo.mScriptTextBuf);
nsresult rv =
- nsScriptLoader::ConvertToUTF16(nullptr, aString, aStringLen,
- NS_LITERAL_STRING("UTF-8"), parentDoc,
- loadInfo.mScriptTextBuf,
- loadInfo.mScriptTextLength);
+ ScriptLoader::ConvertToUTF16(nullptr, aString, aStringLen,
+ NS_LITERAL_STRING("UTF-8"), parentDoc,
+ loadInfo.mScriptTextBuf,
+ loadInfo.mScriptTextLength);
if (NS_SUCCEEDED(rv) && IsMainWorkerScript()) {
nsCOMPtr<nsIURI> finalURI;
rv = NS_NewURI(getter_AddRefs(finalURI), loadInfo.mFullURL, nullptr, nullptr);
diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp
index a8f191f2e6..306ef6b235 100644
--- a/dom/workers/ServiceWorkerManager.cpp
+++ b/dom/workers/ServiceWorkerManager.cpp
@@ -22,7 +22,6 @@
#include "nsITimer.h"
#include "nsIUploadChannel2.h"
#include "nsPIDOMWindow.h"
-#include "nsScriptLoader.h"
#include "nsServiceManagerUtils.h"
#include "nsDebug.h"
#include "nsISupportsPrimitives.h"
@@ -44,6 +43,7 @@
#include "mozilla/dom/PromiseNativeHandler.h"
#include "mozilla/dom/Request.h"
#include "mozilla/dom/RootedDictionary.h"
+#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/dom/TypedArray.h"
#include "mozilla/ipc/BackgroundChild.h"
#include "mozilla/ipc/PBackgroundChild.h"
diff --git a/dom/workers/ServiceWorkerScriptCache.cpp b/dom/workers/ServiceWorkerScriptCache.cpp
index f44bb673c8..707b689e8a 100644
--- a/dom/workers/ServiceWorkerScriptCache.cpp
+++ b/dom/workers/ServiceWorkerScriptCache.cpp
@@ -11,6 +11,7 @@
#include "mozilla/dom/cache/Cache.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/PromiseWorkerProxy.h"
+#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/ipc/BackgroundUtils.h"
#include "mozilla/ipc/PBackgroundSharedTypes.h"
#include "nsICacheInfoChannel.h"
@@ -23,7 +24,6 @@
#include "nsIScriptError.h"
#include "nsContentUtils.h"
#include "nsNetUtil.h"
-#include "nsScriptLoader.h"
#include "ServiceWorkerManager.h"
#include "Workers.h"
#include "nsStringStream.h"
@@ -801,9 +801,9 @@ CompareNetwork::OnStreamComplete(nsIStreamLoader* aLoader, nsISupports* aContext
char16_t* buffer = nullptr;
size_t len = 0;
- rv = nsScriptLoader::ConvertToUTF16(httpChannel, aString, aLen,
- NS_LITERAL_STRING("UTF-8"), nullptr,
- buffer, len);
+ rv = ScriptLoader::ConvertToUTF16(httpChannel, aString, aLen,
+ NS_LITERAL_STRING("UTF-8"), nullptr,
+ buffer, len);
if (NS_WARN_IF(NS_FAILED(rv))) {
mManager->NetworkFinished(rv);
return rv;
@@ -855,9 +855,9 @@ CompareCache::OnStreamComplete(nsIStreamLoader* aLoader, nsISupports* aContext,
char16_t* buffer = nullptr;
size_t len = 0;
- nsresult rv = nsScriptLoader::ConvertToUTF16(nullptr, aString, aLen,
- NS_LITERAL_STRING("UTF-8"),
- nullptr, buffer, len);
+ nsresult rv = ScriptLoader::ConvertToUTF16(nullptr, aString, aLen,
+ NS_LITERAL_STRING("UTF-8"),
+ nullptr, buffer, len);
if (NS_WARN_IF(NS_FAILED(rv))) {
mManager->CacheFinished(rv, false);
return rv;
diff --git a/dom/worklet/Worklet.cpp b/dom/worklet/Worklet.cpp
index 19a877ea8f..1b71916abf 100644
--- a/dom/worklet/Worklet.cpp
+++ b/dom/worklet/Worklet.cpp
@@ -12,11 +12,11 @@
#include "mozilla/dom/PromiseNativeHandler.h"
#include "mozilla/dom/RegisterWorkletBindings.h"
#include "mozilla/dom/Response.h"
+#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/dom/ScriptSettings.h"
#include "nsIInputStreamPump.h"
#include "nsIThreadRetargetableRequest.h"
#include "nsNetUtil.h"
-#include "nsScriptLoader.h"
#include "xpcprivate.h"
namespace mozilla {
@@ -171,9 +171,9 @@ public:
char16_t* scriptTextBuf;
size_t scriptTextLength;
nsresult rv =
- nsScriptLoader::ConvertToUTF16(nullptr, aString, aStringLen,
- NS_LITERAL_STRING("UTF-8"), nullptr,
- scriptTextBuf, scriptTextLength);
+ ScriptLoader::ConvertToUTF16(nullptr, aString, aStringLen,
+ NS_LITERAL_STRING("UTF-8"), nullptr,
+ scriptTextBuf, scriptTextLength);
if (NS_WARN_IF(NS_FAILED(rv))) {
RejectPromises(rv);
return NS_OK;
diff --git a/dom/xml/nsXMLContentSink.cpp b/dom/xml/nsXMLContentSink.cpp
index 7c9d308fd6..daf1dbf271 100644
--- a/dom/xml/nsXMLContentSink.cpp
+++ b/dom/xml/nsXMLContentSink.cpp
@@ -35,7 +35,6 @@
#include "nsRect.h"
#include "nsIWebNavigation.h"
#include "nsIScriptElement.h"
-#include "nsScriptLoader.h"
#include "nsStyleLinkElement.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
@@ -62,6 +61,7 @@
#include "mozilla/dom/Element.h"
#include "mozilla/dom/HTMLTemplateElement.h"
#include "mozilla/dom/ProcessingInstruction.h"
+#include "mozilla/dom/ScriptLoader.h"
using namespace mozilla;
using namespace mozilla::dom;
diff --git a/dom/xml/nsXMLFragmentContentSink.cpp b/dom/xml/nsXMLFragmentContentSink.cpp
index 7fa815c84a..7d9f869879 100644
--- a/dom/xml/nsXMLFragmentContentSink.cpp
+++ b/dom/xml/nsXMLFragmentContentSink.cpp
@@ -24,10 +24,10 @@
#include "nsTArray.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIDocShell.h"
-#include "nsScriptLoader.h"
#include "mozilla/css/Loader.h"
#include "mozilla/dom/DocumentFragment.h"
#include "mozilla/dom/ProcessingInstruction.h"
+#include "mozilla/dom/ScriptLoader.h"
using namespace mozilla::dom;
diff --git a/dom/xslt/xslt/txMozillaXMLOutput.cpp b/dom/xslt/xslt/txMozillaXMLOutput.cpp
index 069413d976..704d8ac110 100644
--- a/dom/xslt/xslt/txMozillaXMLOutput.cpp
+++ b/dom/xslt/xslt/txMozillaXMLOutput.cpp
@@ -7,7 +7,6 @@
#include "nsIDocument.h"
#include "nsIDocShell.h"
-#include "nsScriptLoader.h"
#include "nsIDOMDocument.h"
#include "nsIDOMDocumentType.h"
#include "nsIScriptElement.h"
@@ -31,6 +30,7 @@
#include "mozilla/css/Loader.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/EncodingUtils.h"
+#include "mozilla/dom/ScriptLoader.h"
#include "nsContentUtils.h"
#include "txXMLUtils.h"
#include "nsContentSink.h"
@@ -230,7 +230,7 @@ txMozillaXMLOutput::endDocument(nsresult aResult)
MOZ_ASSERT(mDocument->GetReadyStateEnum() ==
nsIDocument::READYSTATE_LOADING, "Bad readyState");
mDocument->SetReadyStateInternal(nsIDocument::READYSTATE_INTERACTIVE);
- nsScriptLoader* loader = mDocument->ScriptLoader();
+ ScriptLoader* loader = mDocument->ScriptLoader();
if (loader) {
loader->ParsingComplete(false);
}
@@ -416,7 +416,7 @@ txMozillaXMLOutput::startDocument()
}
if (mCreatingNewDocument) {
- nsScriptLoader* loader = mDocument->ScriptLoader();
+ ScriptLoader* loader = mDocument->ScriptLoader();
if (loader) {
loader->BeginDeferringScripts();
}
@@ -857,7 +857,7 @@ txMozillaXMLOutput::createResultDocument(const nsSubstring& aName, int32_t aNsID
}
// Set up script loader of the result document.
- nsScriptLoader *loader = mDocument->ScriptLoader();
+ ScriptLoader *loader = mDocument->ScriptLoader();
if (mNotifier) {
loader->AddObserver(mNotifier);
}
diff --git a/dom/xul/XULDocument.cpp b/dom/xul/XULDocument.cpp
index d3b94920a3..c5ec9a208a 100644
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -3325,10 +3325,10 @@ XULDocument::OnStreamComplete(nsIStreamLoader* aLoader,
!mOffThreadCompileStringBuf),
"XULDocument can't load multiple scripts at once");
- rv = nsScriptLoader::ConvertToUTF16(channel, string, stringLen,
- EmptyString(), this,
- mOffThreadCompileStringBuf,
- mOffThreadCompileStringLength);
+ rv = ScriptLoader::ConvertToUTF16(channel, string, stringLen,
+ EmptyString(), this,
+ mOffThreadCompileStringBuf,
+ mOffThreadCompileStringLength);
if (NS_SUCCEEDED(rv)) {
// Attempt to give ownership of the buffer to the JS engine. If
// we hit offthread compilation, however, we will have to take it
diff --git a/dom/xul/XULDocument.h b/dom/xul/XULDocument.h
index a5ed497049..5c4dad42eb 100644
--- a/dom/xul/XULDocument.h
+++ b/dom/xul/XULDocument.h
@@ -21,13 +21,13 @@
#include "nsCOMArray.h"
#include "nsIURI.h"
#include "nsIXULDocument.h"
-#include "nsScriptLoader.h"
#include "nsIStreamListener.h"
#include "nsIStreamLoader.h"
#include "nsICSSLoaderObserver.h"
#include "nsIXULStore.h"
#include "mozilla/Attributes.h"
+#include "mozilla/dom/ScriptLoader.h"
#include "js/TracingAPI.h"
#include "js/TypeDecls.h"
diff --git a/dom/xul/nsXULContentSink.cpp b/dom/xul/nsXULContentSink.cpp
index edeee87280..94560e70db 100644
--- a/dom/xul/nsXULContentSink.cpp
+++ b/dom/xul/nsXULContentSink.cpp
@@ -881,7 +881,7 @@ XULContentSinkImpl::OpenScript(const char16_t** aAttributes,
isJavaScript = false;
}
} else if (key.EqualsLiteral("language")) {
- // Language is deprecated, and the impl in nsScriptLoader ignores the
+ // Language is deprecated, and the impl in ScriptLoader ignores the
// various version strings anyway. So we make no attempt to support
// languages other than JS for language=
nsAutoString lang(aAttributes[1]);
diff --git a/js/xpconnect/loader/mozJSSubScriptLoader.cpp b/js/xpconnect/loader/mozJSSubScriptLoader.cpp
index f23e5833a0..baf7a93920 100644
--- a/js/xpconnect/loader/mozJSSubScriptLoader.cpp
+++ b/js/xpconnect/loader/mozJSSubScriptLoader.cpp
@@ -15,7 +15,6 @@
#include "nsNetCID.h"
#include "nsNetUtil.h"
#include "nsIFileURL.h"
-#include "nsScriptLoader.h"
#include "nsIScriptSecurityManager.h"
#include "nsThreadUtils.h"
@@ -26,6 +25,7 @@
#include "jswrapper.h"
#include "mozilla/dom/Promise.h"
+#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/dom/ToJSValue.h"
#include "mozilla/HoldDropJSObjects.h"
#include "mozilla/scache/StartupCache.h"
@@ -139,8 +139,8 @@ PrepareScript(nsIURI* uri,
size_t scriptLength = 0;
nsresult rv =
- nsScriptLoader::ConvertToUTF16(nullptr, reinterpret_cast<const uint8_t*>(buf), len,
- charset, nullptr, scriptBuf, scriptLength);
+ ScriptLoader::ConvertToUTF16(nullptr, reinterpret_cast<const uint8_t*>(buf), len,
+ charset, nullptr, scriptBuf, scriptLength);
JS::SourceBufferHolder srcBuf(scriptBuf, scriptLength,
JS::SourceBufferHolder::GiveOwnership);
@@ -826,9 +826,9 @@ ScriptPrecompiler::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
// Convert data to char16_t* and prepare to call CompileOffThread.
nsAutoString hintCharset;
nsresult rv =
- nsScriptLoader::ConvertToUTF16(mChannel, aString, aLength,
- hintCharset, nullptr,
- mScriptBuf, mScriptLength);
+ ScriptLoader::ConvertToUTF16(mChannel, aString, aLength,
+ hintCharset, nullptr,
+ mScriptBuf, mScriptLength);
NS_ENSURE_SUCCESS(rv, NS_OK);
diff --git a/js/xpconnect/src/XPCJSContext.cpp b/js/xpconnect/src/XPCJSContext.cpp
index bde949a960..511bc8a98f 100644
--- a/js/xpconnect/src/XPCJSContext.cpp
+++ b/js/xpconnect/src/XPCJSContext.cpp
@@ -35,13 +35,13 @@
#include "nsCCUncollectableMarker.h"
#include "nsCycleCollectionNoteRootCallback.h"
#include "nsCycleCollector.h"
-#include "nsScriptLoader.h"
#include "jsapi.h"
#include "jsprf.h"
#include "js/MemoryMetrics.h"
#include "mozilla/dom/GeneratedAtomList.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/Element.h"
+#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/dom/WindowBinding.h"
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
#include "mozilla/Atomics.h"
@@ -3035,8 +3035,8 @@ ReadSourceFromFilename(JSContext* cx, const char* filename, char16_t** src, size
ptr += bytesRead;
}
- rv = nsScriptLoader::ConvertToUTF16(scriptChannel, buf.get(), rawLen, EmptyString(),
- nullptr, *src, *len);
+ rv = ScriptLoader::ConvertToUTF16(scriptChannel, buf.get(), rawLen, EmptyString(),
+ nullptr, *src, *len);
NS_ENSURE_SUCCESS(rv, rv);
if (!*src)
diff --git a/parser/html/nsHtml5DocumentBuilder.cpp b/parser/html/nsHtml5DocumentBuilder.cpp
index ba8a333c49..aff199a45d 100644
--- a/parser/html/nsHtml5DocumentBuilder.cpp
+++ b/parser/html/nsHtml5DocumentBuilder.cpp
@@ -8,8 +8,8 @@
#include "nsIStyleSheetLinkingElement.h"
#include "nsStyleLinkElement.h"
-#include "nsScriptLoader.h"
#include "nsIHTMLDocument.h"
+#include "mozilla/dom/ScriptLoader.h"
NS_IMPL_CYCLE_COLLECTION_INHERITED(nsHtml5DocumentBuilder, nsContentSink,
mOwnedElements)
diff --git a/parser/html/nsHtml5OplessBuilder.cpp b/parser/html/nsHtml5OplessBuilder.cpp
index ac1c03f106..65b97ffc72 100644
--- a/parser/html/nsHtml5OplessBuilder.cpp
+++ b/parser/html/nsHtml5OplessBuilder.cpp
@@ -6,8 +6,8 @@
#include "nsHtml5OplessBuilder.h"
-#include "nsScriptLoader.h"
#include "mozilla/css/Loader.h"
+#include "mozilla/dom/ScriptLoader.h"
#include "nsIDocShell.h"
#include "nsIHTMLDocument.h"
diff --git a/parser/html/nsHtml5TreeOpExecutor.cpp b/parser/html/nsHtml5TreeOpExecutor.cpp
index 95f177376d..3ed634d0c3 100644
--- a/parser/html/nsHtml5TreeOpExecutor.cpp
+++ b/parser/html/nsHtml5TreeOpExecutor.cpp
@@ -7,10 +7,10 @@
#include "mozilla/DebugOnly.h"
#include "mozilla/Likely.h"
#include "mozilla/dom/nsCSPService.h"
+#include "mozilla/dom/ScriptLoader.h"
#include "nsError.h"
#include "nsHtml5TreeOpExecutor.h"
-#include "nsScriptLoader.h"
#include "nsIContentViewer.h"
#include "nsIContentSecurityPolicy.h"
#include "nsIDocShellTreeItem.h"
diff --git a/parser/html/nsParserUtils.cpp b/parser/html/nsParserUtils.cpp
index 9e0bb8c9e2..2085cd1495 100644
--- a/parser/html/nsParserUtils.cpp
+++ b/parser/html/nsParserUtils.cpp
@@ -9,7 +9,6 @@
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsXPIDLString.h"
-#include "nsScriptLoader.h"
#include "nsEscape.h"
#include "nsIParser.h"
#include "nsIDTD.h"
@@ -36,6 +35,7 @@
#include "nsTreeSanitizer.h"
#include "nsHtml5Module.h"
#include "mozilla/dom/DocumentFragment.h"
+#include "mozilla/dom/ScriptLoader.h"
#include "nsNullPrincipal.h"
#define XHTML_DIV_TAG "div xmlns=\"http://www.w3.org/1999/xhtml\""
@@ -148,7 +148,7 @@ nsParserUtils::ParseFragment(const nsAString& aFragment,
nsAutoScriptBlockerSuppressNodeRemoved autoBlocker;
// stop scripts
- RefPtr<nsScriptLoader> loader;
+ RefPtr<ScriptLoader> loader;
bool scripts_enabled = false;
if (document) {
loader = document->ScriptLoader();
diff --git a/parser/htmlparser/nsParser.cpp b/parser/htmlparser/nsParser.cpp
index dd140c5531..d1e521750a 100644
--- a/parser/htmlparser/nsParser.cpp
+++ b/parser/htmlparser/nsParser.cpp
@@ -28,7 +28,6 @@
#include "nsIFragmentContentSink.h"
#include "nsStreamUtils.h"
#include "nsHTMLTokenizer.h"
-#include "nsScriptLoader.h"
#include "nsDataHashtable.h"
#include "nsXPCOMCIDInternal.h"
#include "nsMimeTypes.h"
@@ -41,6 +40,7 @@
#include "nsIHTMLContentSink.h"
#include "mozilla/dom/EncodingUtils.h"
+#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/BinarySearch.h"
using namespace mozilla;