Skip to content

Commit

Permalink
Bug 1362119 - part 1 - Moving dom/base/Script{Loader,Element}.* in do…
Browse files Browse the repository at this point in the history
…m/script, r=ehsan

This patch does these things:

1. it moves nsScriptElement, nsScriptLoader, ScriptSettings, nsIScriptElement
   and nsIScriptLoaderObserver in dom/script
2. it renames nsScriptElement to mozilla::dom::ScriptElement
3. it renames nsScriptLaoder to mozilla::dom::ScriptLoader

--HG--
rename : dom/base/nsScriptElement.cpp => dom/script/ScriptElement.cpp
rename : dom/base/nsScriptElement.h => dom/script/ScriptElement.h
rename : dom/base/nsScriptLoader.cpp => dom/script/ScriptLoader.cpp
rename : dom/base/nsScriptLoader.h => dom/script/ScriptLoader.h
rename : dom/base/ScriptSettings.cpp => dom/script/ScriptSettings.cpp
rename : dom/base/ScriptSettings.h => dom/script/ScriptSettings.h
rename : dom/base/nsIScriptElement.h => dom/script/nsIScriptElement.h
rename : dom/base/nsIScriptLoaderObserver.idl => dom/script/nsIScriptLoaderObserver.idl
  • Loading branch information
bakulf committed May 8, 2017
1 parent b302544 commit 1981f67
Show file tree
Hide file tree
Showing 53 changed files with 598 additions and 551 deletions.
8 changes: 4 additions & 4 deletions dom/base/ImportManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "ImportManager.h"

#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/EventListenerManager.h"
#include "HTMLLinkElement.h"
#include "nsContentPolicyUtils.h"
Expand All @@ -18,7 +19,6 @@
#include "nsIDOMEvent.h"
#include "nsIPrincipal.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsScriptLoader.h"
#include "nsNetUtil.h"

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -339,7 +339,7 @@ ImportLoader::DispatchEventIfFinished(nsINode* aNode)
}

void
ImportLoader::AddBlockedScriptLoader(nsScriptLoader* aScriptLoader)
ImportLoader::AddBlockedScriptLoader(ScriptLoader* aScriptLoader)
{
if (mBlockedScriptLoaders.Contains(aScriptLoader)) {
return;
Expand All @@ -352,7 +352,7 @@ ImportLoader::AddBlockedScriptLoader(nsScriptLoader* aScriptLoader)
}

bool
ImportLoader::RemoveBlockedScriptLoader(nsScriptLoader* aScriptLoader)
ImportLoader::RemoveBlockedScriptLoader(ScriptLoader* aScriptLoader)
{
aScriptLoader->RemoveParserBlockingScriptExecutionBlocker();
return mBlockedScriptLoaders.RemoveElement(aScriptLoader);
Expand Down
8 changes: 4 additions & 4 deletions dom/base/ImportManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -184,8 +184,8 @@ class ImportLoader final : public nsIStreamListener
// 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:
Expand Down Expand Up @@ -230,7 +230,7 @@ class ImportLoader final : public nsIStreamListener

// 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
Expand Down
2 changes: 1 addition & 1 deletion dom/base/Location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
#include "mozilla/Likely.h"
#include "nsCycleCollectionParticipant.h"
#include "NullPrincipal.h"
#include "ScriptSettings.h"
#include "mozilla/Unused.h"
#include "mozilla/dom/LocationBinding.h"
#include "mozilla/dom/ScriptSettings.h"

namespace mozilla {
namespace dom {
Expand Down
7 changes: 0 additions & 7 deletions dom/base/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ XPIDL_SOURCES += [
'nsIObjectLoadingContent.idl',
'nsIRemoteWindowContext.idl',
'nsIScriptChannel.idl',
'nsIScriptLoaderObserver.idl',
'nsISelection.idl',
'nsISelectionController.idl',
'nsISelectionDisplay.idl',
Expand Down Expand Up @@ -92,7 +91,6 @@ EXPORTS += [
'nsINode.h',
'nsINodeList.h',
'nsIScriptContext.h',
'nsIScriptElement.h',
'nsIScriptGlobalObject.h',
'nsIScriptNameSpaceManager.h',
'nsIScriptObjectPrincipal.h',
Expand All @@ -113,7 +111,6 @@ EXPORTS += [
'nsRange.h',
'nsReferencedElement.h',
'nsSandboxFlags.h',
'nsScriptLoader.h',
'nsStructuredCloneContainer.h',
'nsStubAnimationObserver.h',
'nsStubDocumentObserver.h',
Expand Down Expand Up @@ -198,7 +195,6 @@ EXPORTS.mozilla.dom += [
'ResponsiveImageSelector.h',
'SameProcessMessageQueue.h',
'ScreenOrientation.h',
'ScriptSettings.h',
'ShadowRoot.h',
'StructuredCloneHolder.h',
'StructuredCloneTags.h',
Expand Down Expand Up @@ -315,8 +311,6 @@ UNIFIED_SOURCES += [
'nsRange.cpp',
'nsReferencedElement.cpp',
'nsScreen.cpp',
'nsScriptElement.cpp',
'nsScriptLoader.cpp',
'nsScriptNameSpaceManager.cpp',
'nsStructuredCloneContainer.cpp',
'nsStubAnimationObserver.cpp',
Expand All @@ -343,7 +337,6 @@ UNIFIED_SOURCES += [
'ResponsiveImageSelector.cpp',
'SameProcessMessageQueue.cpp',
'ScreenOrientation.cpp',
'ScriptSettings.cpp',
'ShadowRoot.cpp',
'StructuredCloneHolder.cpp',
'StyleSheetList.cpp',
Expand Down
1 change: 0 additions & 1 deletion dom/base/nsContentPermissionHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "nsIDocument.h"
#include "nsIDOMEvent.h"
#include "nsWeakPtr.h"
#include "ScriptSettings.h"

using mozilla::Unused; // <snicker>
using namespace mozilla::dom;
Expand Down
2 changes: 1 addition & 1 deletion dom/base/nsContentSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*/

#include "nsContentSink.h"
#include "nsScriptLoader.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "mozilla/css/Loader.h"
Expand Down Expand Up @@ -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"

Expand Down
7 changes: 5 additions & 2 deletions dom/base/nsContentSink.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -276,7 +279,7 @@ class nsContentSink : public nsICSSLoaderObserver,
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;
Expand Down
4 changes: 2 additions & 2 deletions dom/base/nsDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2026,7 +2026,7 @@ nsDocument::Init()
mScopeObject = do_GetWeakReference(global);
MOZ_ASSERT(mScopeObject);

mScriptLoader = new nsScriptLoader(this);
mScriptLoader = new dom::ScriptLoader(this);

mozilla::HoldJSObjects(this);

Expand Down Expand Up @@ -5011,7 +5011,7 @@ nsDocument::GetWindowInternal() const
return win;
}

nsScriptLoader*
ScriptLoader*
nsDocument::ScriptLoader()
{
return mScriptLoader;
Expand Down
6 changes: 3 additions & 3 deletions dom/base/nsDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "nsJSThingHashtable.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsIURI.h"
#include "nsScriptLoader.h"
#include "nsIRadioGroupContainer.h"
#include "nsILayoutHistoryState.h"
#include "nsIRequest.h"
Expand Down Expand Up @@ -60,6 +59,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"
Expand Down Expand Up @@ -742,7 +742,7 @@ class nsDocument : public nsIDocument,
/**
* 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
Expand Down Expand Up @@ -1492,7 +1492,7 @@ class nsDocument : public nsIDocument,
RefPtr<mozilla::EventListenerManager> mListenerManager;
RefPtr<mozilla::dom::StyleSheetList> mDOMStyleSheets;
RefPtr<nsDOMStyleSheetSetList> mStyleSheetSetList;
RefPtr<nsScriptLoader> mScriptLoader;
RefPtr<mozilla::dom::ScriptLoader> mScriptLoader;
nsDocHeaderData* mHeaderData;
/* mIdentifierMap works as follows for IDs:
* 1) Attribute changes affect the table immediately (removing and adding
Expand Down
8 changes: 4 additions & 4 deletions dom/base/nsFrameMessageManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "nsJSUtils.h"
#include "nsJSPrincipals.h"
#include "nsNetUtil.h"
#include "nsScriptLoader.h"
#include "mozilla/dom/ScriptLoader.h"
#include "nsFrameLoader.h"
#include "nsIInputStream.h"
#include "nsIXULRuntime.h"
Expand Down Expand Up @@ -1640,9 +1640,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,
Expand Down
2 changes: 1 addition & 1 deletion dom/base/nsGlobalWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,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"
Expand Down
4 changes: 2 additions & 2 deletions dom/base/nsIDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ class nsIVariant;
class nsViewManager;
class nsPresContext;
class nsRange;
class nsScriptLoader;
class nsSMILAnimationController;
class nsSVGElement;
class nsTextNode;
Expand Down Expand Up @@ -154,6 +153,7 @@ class NodeIterator;
enum class OrientationType : uint8_t;
class ProcessingInstruction;
class Promise;
class ScriptLoader;
class StyleSheetList;
class SVGDocument;
class SVGSVGElement;
Expand Down Expand Up @@ -1368,7 +1368,7 @@ class nsIDocument : public nsINode,
/**
* 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
Expand Down
2 changes: 1 addition & 1 deletion dom/base/nsInProcessTabChildGlobal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion dom/base/nsJSEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include "nsXPCOMCIDInternal.h"
#include "nsIXULRuntime.h"
#include "nsTextFormatter.h"
#include "ScriptSettings.h"
#ifdef XP_WIN
#include <process.h>
#define getpid _getpid
Expand All @@ -60,6 +59,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/CycleCollectedJSRuntime.h"
#include "mozilla/SystemGroup.h"
Expand Down
6 changes: 3 additions & 3 deletions dom/base/test/test_script_loader_js_cache.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<!-- https://bugzilla.mozilla.org/show_bug.cgi?id=900784 -->
<!-- The JS bytecode cache is not supposed to be observable. To make it
observable, the nsScriptLoader is instrumented to trigger events on the
observable, the ScriptLoader is instrumented to trigger events on the
script tag. These events are followed to reconstruct the code path taken by
the script loader and associate a simple name which is checked in these
test cases.
Expand All @@ -14,7 +14,7 @@
<script src="/resources/testharnessreport.js"></script>
<script type="application/javascript">
// This is the state machine of the trace events produced by the
// nsScriptLoader. This state machine is used to give a name to each
// ScriptLoader. This state machine is used to give a name to each
// code path, such that we can assert each code path with a single word.
var scriptLoaderStateMachine = {
"scriptloader_load_source": {
Expand Down Expand Up @@ -112,7 +112,7 @@
promise_test(async function() {
// Setting dom.expose_test_interfaces pref causes the
// nsScriptLoadRequest to fire event on script tags, with information
// about its internal state. The nsScriptLoader source send events to
// about its internal state. The ScriptLoader source send events to
// trace these and resolve a promise with the path taken by the
// script loader.
//
Expand Down
2 changes: 1 addition & 1 deletion dom/console/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion dom/events/DOMEventTargetHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion dom/html/HTMLScriptElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,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);
}
Expand Down
Loading

0 comments on commit 1981f67

Please sign in to comment.