Bug 1678374 - Avoid including jsapi.h from header files. r=jandem

Differential Revision: https://phabricator.services.mozilla.com/D97620

Depends on D97618
This commit is contained in:
Simon Giesecke 2020-11-23 16:12:34 +00:00
parent e9f54e05c6
commit feb7572bff
16 changed files with 46 additions and 35 deletions

View File

@ -7,8 +7,8 @@
#ifndef nsDOMJSUtils_h__
#define nsDOMJSUtils_h__
#include "nsIScriptContext.h"
#include "jsapi.h"
#include "js/TypeDecls.h"
#include "nscore.h"
class nsIJSArgArray;

View File

@ -15,8 +15,8 @@
#include <math.h>
#include <stdint.h>
#include "jsapi.h"
#include "js/Conversions.h"
#include "js/RootingAPI.h"
#include "mozilla/Assertions.h"
#include "mozilla/FloatingPoint.h"
#include "mozilla/dom/BindingCallContext.h"

View File

@ -7,7 +7,6 @@
#ifndef mozilla_dom_BodyExtractor_h
#define mozilla_dom_BodyExtractor_h
#include "jsapi.h"
#include "nsString.h"
class nsIInputStream;

View File

@ -7,7 +7,8 @@
#ifndef mozilla_dom_FetchStreamReader_h
#define mozilla_dom_FetchStreamReader_h
#include "jsapi.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "mozilla/dom/FetchBinding.h"
#include "mozilla/dom/PromiseNativeHandler.h"
#include "nsIAsyncOutputStream.h"

View File

@ -9,9 +9,8 @@
#include "mozilla/dom/indexedDB/IDBResult.h"
#include "js/Array.h" // JS::GetArrayLength
#include "js/RootingAPI.h"
#include "jsapi.h"
#include "js/TypeDecls.h"
#include "nsString.h"
class mozIStorageStatement;

View File

@ -7,7 +7,7 @@
#ifndef mozilla_dom_PushSubscription_h
#define mozilla_dom_PushSubscription_h
#include "jsapi.h"
#include "js/RootingAPI.h"
#include "nsCOMPtr.h"
#include "nsWrapperCache.h"

View File

@ -7,8 +7,9 @@
#ifndef mozilla_dom_ScriptLoadRequest_h
#define mozilla_dom_ScriptLoadRequest_h
#include "jsapi.h"
#include "js/OffThreadScriptCompilation.h"
#include "js/AllocPolicy.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "mozilla/Atomics.h"
#include "mozilla/Assertions.h"
#include "mozilla/CORSMode.h"
@ -26,6 +27,10 @@
class nsICacheInfoChannel;
namespace JS {
class OffThreadToken;
}
namespace mozilla {
namespace dom {
@ -174,7 +179,7 @@ class ScriptLoadRequest
// can be transferred in constant time to the JS engine, not copied in linear
// time.
template <typename Unit>
using ScriptTextBuffer = Vector<Unit, 0, JSMallocAllocPolicy>;
using ScriptTextBuffer = Vector<Unit, 0, js::MallocAllocPolicy>;
// BinAST data isn't transferred to the JS engine, so it doesn't need to use
// the JS allocator.

View File

@ -36,6 +36,8 @@ class nsIURI;
namespace JS {
class CompileOptions;
template <typename UnitT>
class SourceText;

View File

@ -9,9 +9,9 @@
#include <stdint.h>
#include "jsapi.h"
#include "js/ContextOptions.h"
#include "js/GCAPI.h"
#include "js/RealmOptions.h"
#include "mozilla/Maybe.h"
#include "nsString.h"
#include "nsTArray.h"

View File

@ -7,7 +7,7 @@
#ifndef mozilla_dom_workers_WorkerCommon_h
#define mozilla_dom_workers_WorkerCommon_h
#include "jsapi.h"
#include "js/TypeDecls.h"
#include "mozilla/Attributes.h"
#include "mozilla/dom/ServiceWorkerDescriptor.h"

View File

@ -187,6 +187,21 @@ class TempAllocPolicy : public AllocPolicyBase {
}
};
/*
* A replacement for MallocAllocPolicy that allocates in the JS heap and adds no
* extra behaviours.
*
* This is currently used for allocating source buffers for parsing. Since these
* are temporary and will not be freed by GC, the memory is not tracked by the
* usual accounting.
*/
class MallocAllocPolicy : public AllocPolicyBase {
public:
void reportAllocOverflow() const {}
MOZ_MUST_USE bool checkSimulatedOOM() const { return true; }
};
} /* namespace js */
#endif /* js_AllocPolicy_h */

View File

@ -666,21 +666,6 @@ extern JS_PUBLIC_API bool IsProfileTimelineRecordingEnabled();
} // namespace JS
/*
* A replacement for MallocAllocPolicy that allocates in the JS heap and adds no
* extra behaviours.
*
* This is currently used for allocating source buffers for parsing. Since these
* are temporary and will not be freed by GC, the memory is not tracked by the
* usual accounting.
*/
class JS_PUBLIC_API JSMallocAllocPolicy : public js::AllocPolicyBase {
public:
void reportAllocOverflow() const {}
MOZ_MUST_USE bool checkSimulatedOOM() const { return true; }
};
/**
* Set the size of the native stack that should not be exceed. To disable
* stack size checking pass 0.

View File

@ -9,13 +9,18 @@
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/PrecompiledScriptBinding.h"
#include "jsapi.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "nsCOMPtr.h"
#include "nsCycleCollectionParticipant.h"
#include "nsISupports.h"
#include "nsWrapperCache.h"
namespace JS {
class ReadOnlyCompileOptions;
}
namespace mozilla {
namespace dom {
class PrecompiledScript : public nsISupports, public nsWrapperCache {

View File

@ -25,9 +25,10 @@
#include "nsIThread.h"
#include "nsITimer.h"
#include "jsapi.h"
#include "js/CompileOptions.h" // JS::CompileOptions, JS::ReadOnlyCompileOptions
#include "js/GCAnnotations.h"
#include "js/GCAnnotations.h" // for JS_HAZ_NON_GC_POINTER
#include "js/RootingAPI.h" // for Handle, Heap
#include "js/Transcoding.h" // for TranscodeBuffer, TranscodeRange, TranscodeSources
#include "js/TypeDecls.h" // for HandleObject, HandleScript
#include <prio.h>

View File

@ -11,7 +11,8 @@
#include "mozilla/dom/StreamFilterDataEventBinding.h"
#include "mozilla/extensions/StreamFilter.h"
#include "jsapi.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "mozilla/HoldDropJSObjects.h"
#include "mozilla/dom/Event.h"

View File

@ -14,8 +14,6 @@
#include "nsIObserver.h"
#include "nsISupports.h"
#include "jsapi.h"
namespace mozilla {
class Addon;