Bug 1673424 - Fix includes around JS/StructuredClone.h.
authorSimon Giesecke <sgiesecke@mozilla.com>
Mon, 23 Nov 2020 16:06:52 +0000
changeset 558351 c15be3f697413364c3c3078388b494f891002495
parent 558350 267fdd18674019c1c7f579722c8a2c2519c4d24e
child 558352 d55236e0b03ce5d6e7119c8d81bc244490c64c53
push id37978
push usernerli@mozilla.com
push dateTue, 24 Nov 2020 09:22:28 +0000
treeherdermozilla-central@0e1c1a720ca7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1673424
milestone85.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1673424 - Fix includes around JS/StructuredClone.h. Differential Revision: https://phabricator.services.mozilla.com/D94762 Depends on D93568
dom/base/DOMMatrix.cpp
dom/base/DOMMatrix.h
dom/base/DOMPoint.cpp
dom/base/DOMPoint.h
dom/base/DOMQuad.cpp
dom/base/DOMQuad.h
dom/base/DOMRect.cpp
dom/base/DOMRect.h
dom/base/StructuredCloneHolder.cpp
dom/base/StructuredCloneHolder.h
dom/canvas/ImageData.cpp
dom/canvas/ImageData.h
dom/crypto/CryptoKey.cpp
dom/crypto/CryptoKey.h
dom/crypto/KeyAlgorithmProxy.cpp
dom/crypto/KeyAlgorithmProxy.h
dom/crypto/WebCryptoCommon.h
dom/indexedDB/IndexedDatabase.cpp
dom/indexedDB/IndexedDatabase.h
dom/media/webrtc/RTCCertificate.cpp
dom/media/webrtc/RTCCertificate.h
dom/url/URLSearchParams.cpp
dom/url/URLSearchParams.h
intl/l10n/FluentBundle.cpp
--- a/dom/base/DOMMatrix.cpp
+++ b/dom/base/DOMMatrix.cpp
@@ -1,31 +1,44 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/DOMMatrix.h"
 
-#include "mozilla/dom/BindingUtils.h"
+#include <cmath>
+#include <cstdint>
+#include <new>
+#include "ErrorList.h"
+#include "js/Conversions.h"
+#include "js/Equality.h"
+#include "js/StructuredClone.h"
+#include "js/Value.h"
+#include "mozilla/Casting.h"
+#include "mozilla/ErrorResult.h"
+#include "mozilla/FloatingPoint.h"
+#include "mozilla/MacroForEach.h"
+#include "mozilla/RefPtr.h"
+#include "mozilla/ServoCSSParser.h"
+#include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/DOMMatrixBinding.h"
 #include "mozilla/dom/DOMPoint.h"
 #include "mozilla/dom/DOMPointBinding.h"
-#include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/ToJSValue.h"
-#include "mozilla/ServoCSSParser.h"
-#include "nsGlobalWindowInner.h"
-#include "nsStyleTransformMatrix.h"
-#include "nsGlobalWindowInner.h"
-
-#include <math.h>
-
-#include "js/Conversions.h"  // JS::NumberToString
-#include "js/Equality.h"     // JS::SameValueZero
+#include "mozilla/gfx/BasePoint.h"
+#include "mozilla/gfx/BasePoint4D.h"
+#include "mozilla/gfx/Point.h"
+#include "nsIGlobalObject.h"
+#include "nsPIDOMWindow.h"
+#include "nsString.h"
+#include "nsStringFlags.h"
+#include "nsTArray.h"
+#include "nsTLiteralString.h"
 
 namespace mozilla::dom {
 
 template <typename T>
 static void SetDataInMatrix(DOMMatrixReadOnly* aMatrix, const T* aData,
                             int aLength, ErrorResult& aRv);
 
 static const double radPerDegree = 2.0 * M_PI / 360.0;
--- a/dom/base/DOMMatrix.h
+++ b/dom/base/DOMMatrix.h
@@ -2,36 +2,46 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_DOM_DOMMATRIX_H_
 #define MOZILLA_DOM_DOMMATRIX_H_
 
-#include "js/StructuredClone.h"
-#include "nsWrapperCache.h"
-#include "nsISupports.h"
-#include "nsCycleCollectionParticipant.h"
-#include "mozilla/Attributes.h"
-#include "mozilla/ErrorResult.h"
+#include <cstring>
+#include <utility>
+#include "js/RootingAPI.h"
+#include "mozilla/AlreadyAddRefed.h"
+#include "mozilla/Assertions.h"
 #include "mozilla/UniquePtr.h"
+#include "mozilla/dom/TypedArray.h"
+#include "mozilla/gfx/Matrix.h"
 #include "nsCOMPtr.h"
-#include "mozilla/dom/BindingDeclarations.h"
-#include "mozilla/dom/TypedArray.h"
-#include "mozilla/gfx/Matrix.h"  // for Matrix4x4Double
+#include "nsCycleCollectionParticipant.h"
+#include "nsISupports.h"
+#include "nsStringFwd.h"
+#include "nsWrapperCache.h"
 
+class JSObject;
 class nsIGlobalObject;
+struct JSContext;
+struct JSStructuredCloneReader;
+struct JSStructuredCloneWriter;
 
 namespace mozilla {
+class ErrorResult;
+
 namespace dom {
 
 class GlobalObject;
 class DOMMatrix;
 class DOMPoint;
+template <typename T>
+class Optional;
 class UTF8StringOrUnrestrictedDoubleSequenceOrDOMMatrixReadOnly;
 struct DOMPointInit;
 struct DOMMatrixInit;
 struct DOMMatrix2DInit;
 
 class DOMMatrixReadOnly : public nsWrapperCache {
  public:
   explicit DOMMatrixReadOnly(nsISupports* aParent)
--- a/dom/base/DOMPoint.cpp
+++ b/dom/base/DOMPoint.cpp
@@ -1,18 +1,26 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/DOMPoint.h"
 
+#include <cstdint>
+#include "js/StructuredClone.h"
+#include "mozilla/Casting.h"
+#include "mozilla/ErrorResult.h"
+#include "mozilla/MacroForEach.h"
+#include "mozilla/RefPtr.h"
+#include "mozilla/dom/BindingDeclarations.h"
+#include "mozilla/dom/DOMMatrix.h"
 #include "mozilla/dom/DOMPointBinding.h"
-#include "mozilla/dom/BindingDeclarations.h"
+#include "nsIGlobalObject.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMPointReadOnly, mParent)
 
 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DOMPointReadOnly, AddRef)
 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DOMPointReadOnly, Release)
--- a/dom/base/DOMPoint.h
+++ b/dom/base/DOMPoint.h
@@ -2,30 +2,33 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_DOMPOINT_H_
 #define MOZILLA_DOMPOINT_H_
 
-#include "js/StructuredClone.h"
-#include "DOMMatrix.h"
-#include "nsWrapperCache.h"
-#include "nsIGlobalObject.h"
-#include "nsISupports.h"
+#include "js/RootingAPI.h"
+#include "mozilla/AlreadyAddRefed.h"
+#include "mozilla/Assertions.h"
+#include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
-#include "mozilla/Attributes.h"
-#include "mozilla/ErrorResult.h"
-#include "nsCOMPtr.h"
-#include "mozilla/dom/BindingDeclarations.h"
+#include "nsISupports.h"
+#include "nsWrapperCache.h"
 
+class JSObject;
 class nsIGlobalObject;
+struct JSContext;
+struct JSStructuredCloneReader;
+struct JSStructuredCloneWriter;
 
 namespace mozilla {
+class ErrorResult;
+
 namespace dom {
 
 class GlobalObject;
 class DOMPoint;
 struct DOMPointInit;
 struct DOMMatrixInit;
 
 class DOMPointReadOnly : public nsWrapperCache {
--- a/dom/base/DOMQuad.cpp
+++ b/dom/base/DOMQuad.cpp
@@ -1,21 +1,27 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/DOMQuad.h"
 
+#include <algorithm>
+#include "mozilla/FloatingPoint.h"
+#include "mozilla/MacroForEach.h"
+#include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/DOMPoint.h"
 #include "mozilla/dom/DOMQuadBinding.h"
 #include "mozilla/dom/DOMRect.h"
 #include "mozilla/dom/DOMRectBinding.h"
-#include "mozilla/FloatingPoint.h"
+#include "mozilla/gfx/BasePoint.h"
+#include "mozilla/gfx/MatrixFwd.h"
+#include "nsIGlobalObject.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::gfx;
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMQuad, mParent, mPoints[0], mPoints[1],
                                       mPoints[2], mPoints[3])
 
--- a/dom/base/DOMQuad.h
+++ b/dom/base/DOMQuad.h
@@ -2,34 +2,39 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_DOMQUAD_H_
 #define MOZILLA_DOMQUAD_H_
 
-#include "js/StructuredClone.h"
-#include "nsWrapperCache.h"
-#include "nsISupports.h"
-#include "nsCycleCollectionParticipant.h"
-#include "mozilla/Attributes.h"
+#include <cstdint>
+#include "Units.h"
+#include "js/RootingAPI.h"
+#include "mozilla/AlreadyAddRefed.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/RefPtr.h"
 #include "nsCOMPtr.h"
-#include "nsIGlobalObject.h"
-#include "mozilla/dom/BindingDeclarations.h"
-#include "mozilla/ErrorResult.h"
-#include "Units.h"
+#include "nsCycleCollectionParticipant.h"
+#include "nsISupports.h"
+#include "nsWrapperCache.h"
 
+class JSObject;
 class nsIGlobalObject;
+struct JSContext;
+struct JSStructuredCloneReader;
+struct JSStructuredCloneWriter;
 
 namespace mozilla {
 namespace dom {
 
 class DOMRectReadOnly;
 class DOMPoint;
+class GlobalObject;
 struct DOMPointInit;
 struct DOMQuadInit;
 struct DOMRectInit;
 
 class DOMQuad final : public nsWrapperCache {
   ~DOMQuad();
 
  public:
--- a/dom/base/DOMRect.cpp
+++ b/dom/base/DOMRect.cpp
@@ -1,19 +1,26 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/DOMRect.h"
 
-#include "nsPresContext.h"
+#include <cmath>
+#include "js/StructuredClone.h"
+#include "mozilla/AppUnits.h"
+#include "mozilla/Casting.h"
+#include "mozilla/MacroForEach.h"
+#include "mozilla/dom/BindingDeclarations.h"
+#include "mozilla/dom/DOMRectBinding.h"
 #include "mozilla/dom/DOMRectListBinding.h"
-#include "mozilla/dom/DOMRectBinding.h"
+#include "nsIGlobalObject.h"
+#include "nsRect.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMRectReadOnly, mParent)
 NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMRectReadOnly)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMRectReadOnly)
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMRectReadOnly)
--- a/dom/base/DOMRect.h
+++ b/dom/base/DOMRect.h
@@ -2,32 +2,42 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_DOMRECT_H_
 #define MOZILLA_DOMRECT_H_
 
-#include "js/StructuredClone.h"
-#include "nsTArray.h"
+#include <algorithm>
+#include <cstdint>
+#include <new>
+#include <utility>
+#include "js/RootingAPI.h"
+#include "mozilla/AlreadyAddRefed.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/FloatingPoint.h"
+#include "mozilla/RefPtr.h"
 #include "nsCOMPtr.h"
-#include "nsWrapperCache.h"
 #include "nsCycleCollectionParticipant.h"
-#include "mozilla/Attributes.h"
-#include "mozilla/dom/BindingDeclarations.h"
-#include "mozilla/ErrorResult.h"
-#include "mozilla/FloatingPoint.h"
+#include "nsISupports.h"
+#include "nsTArray.h"
+#include "nsWrapperCache.h"
 
+class JSObject;
+class nsIGlobalObject;
+struct JSContext;
+struct JSStructuredCloneReader;
+struct JSStructuredCloneWriter;
 struct nsRect;
-class nsIGlobalObject;
 
 namespace mozilla {
 namespace dom {
 
+class GlobalObject;
 struct DOMRectInit;
 
 class DOMRectReadOnly : public nsISupports, public nsWrapperCache {
  protected:
   virtual ~DOMRectReadOnly() = default;
 
  public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
--- a/dom/base/StructuredCloneHolder.cpp
+++ b/dom/base/StructuredCloneHolder.cpp
@@ -1,53 +1,82 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "StructuredCloneHolder.h"
+#include "mozilla/dom/StructuredCloneHolder.h"
 
-#include "ImageContainer.h"
+#include <new>
+#include "ErrorList.h"
+#include "MainThreadUtils.h"
+#include "js/CallArgs.h"
+#include "js/Value.h"
+#include "js/WasmModule.h"
+#include "js/Wrapper.h"
+#include "jsapi.h"
+#include "mozilla/AlreadyAddRefed.h"
 #include "mozilla/AutoRestore.h"
+#include "mozilla/ErrorResult.h"
+#include "mozilla/OwningNonNull.h"
+#include "mozilla/RefPtr.h"
+#include "mozilla/ScopeExit.h"
+#include "mozilla/StaticPrefs_dom.h"
+#include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/BindingUtils.h"
+#include "mozilla/dom/Blob.h"
 #include "mozilla/dom/BlobBinding.h"
+#include "mozilla/dom/BlobImpl.h"
 #include "mozilla/dom/BrowsingContext.h"
-#include "mozilla/dom/BrowsingContextBinding.h"
 #include "mozilla/dom/ClonedErrorHolder.h"
 #include "mozilla/dom/ClonedErrorHolderBinding.h"
-#include "mozilla/dom/StructuredCloneBlob.h"
+#include "mozilla/dom/DirectoryBinding.h"
+#include "mozilla/dom/DOMJSClass.h"
+#include "mozilla/dom/DOMTypes.h"
+#include "mozilla/dom/Directory.h"
 #include "mozilla/dom/DocGroup.h"
-#include "mozilla/dom/Directory.h"
-#include "mozilla/dom/DirectoryBinding.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/FileList.h"
 #include "mozilla/dom/FileListBinding.h"
 #include "mozilla/dom/FormData.h"
+#include "mozilla/dom/FormDataBinding.h"
 #include "mozilla/dom/ImageBitmap.h"
 #include "mozilla/dom/ImageBitmapBinding.h"
 #include "mozilla/dom/JSExecutionManager.h"
 #include "mozilla/dom/MessagePort.h"
 #include "mozilla/dom/MessagePortBinding.h"
 #include "mozilla/dom/OffscreenCanvas.h"
 #include "mozilla/dom/OffscreenCanvasBinding.h"
-#include "mozilla/dom/PMessagePort.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/StructuredCloneBlob.h"
 #include "mozilla/dom/StructuredCloneHolderBinding.h"
 #include "mozilla/dom/StructuredCloneTags.h"
 #include "mozilla/dom/ToJSValue.h"
 #include "mozilla/dom/WebIDLSerializable.h"
+#include "mozilla/dom/WorkerCommon.h"
 #include "mozilla/dom/WorkerPrivate.h"
+#include "mozilla/fallible.h"
 #include "mozilla/gfx/2D.h"
-#include "mozilla/ipc/BackgroundChild.h"
-#include "mozilla/ipc/BackgroundUtils.h"
-#include "mozilla/ipc/PBackgroundSharedTypes.h"
-#include "MultipartBlobImpl.h"
-#include "nsQueryObject.h"
+#include "nsContentUtils.h"
+#include "nsDebug.h"
+#include "nsError.h"
+#include "nsID.h"
+#include "nsIEventTarget.h"
+#include "nsIFile.h"
+#include "nsIGlobalObject.h"
+#include "nsIInputStream.h"
+#include "nsIPrincipal.h"
+#include "nsISupports.h"
+#include "nsJSPrincipals.h"
+#include "nsPIDOMWindow.h"
+#include "nsString.h"
+#include "nsThreadUtils.h"
+#include "nsXPCOM.h"
+#include "xpcpublic.h"
 
 using namespace mozilla::ipc;
 
 namespace mozilla::dom {
 
 namespace {
 
 JSObject* StructuredCloneCallbacksRead(
--- a/dom/base/StructuredCloneHolder.h
+++ b/dom/base/StructuredCloneHolder.h
@@ -2,45 +2,63 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_StructuredCloneHolder_h
 #define mozilla_dom_StructuredCloneHolder_h
 
+#include <cstddef>
+#include <cstdint>
 #include <utility>
-
+#include "js/RootingAPI.h"
 #include "js/StructuredClone.h"
-#include "js/WasmModule.h"
-#include "jsapi.h"
+#include "js/TypeDecls.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
 #include "mozilla/MemoryReporting.h"
+#include "mozilla/RefPtr.h"
 #include "mozilla/UniquePtr.h"
-#include "mozilla/dom/BindingDeclarations.h"
+#include "nsCOMPtr.h"
+#include "nsString.h"
 #include "nsTArray.h"
 
-#ifdef DEBUG
-#  include "nsIThread.h"
-#endif
-
+class nsIEventTarget;
 class nsIGlobalObject;
 class nsIInputStream;
+struct JSStructuredCloneReader;
+struct JSStructuredCloneWriter;
+
+namespace JS {
+class Value;
+struct WasmModule;
+}  // namespace JS
 
 namespace mozilla {
 class ErrorResult;
+template <class T>
+class OwningNonNull;
+
 namespace layers {
 class Image;
 }
 
 namespace gfx {
 class DataSourceSurface;
 }
 
 namespace dom {
 
+class BlobImpl;
+class MessagePort;
+class MessagePortIdentifier;
+template <typename T>
+class Sequence;
+
 class StructuredCloneHolderBase {
  public:
   typedef JS::StructuredCloneScope StructuredCloneScope;
 
   StructuredCloneHolderBase(
       StructuredCloneScope aScope = StructuredCloneScope::SameProcess);
   virtual ~StructuredCloneHolderBase();
 
--- a/dom/canvas/ImageData.cpp
+++ b/dom/canvas/ImageData.cpp
@@ -1,21 +1,28 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 et tw=78: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/ImageData.h"
 
+#include "ErrorList.h"
+#include "js/StructuredClone.h"
+#include "js/Value.h"
+#include "jsapi.h"
+#include "jsfriendapi.h"
 #include "mozilla/CheckedInt.h"
+#include "mozilla/ErrorResult.h"
 #include "mozilla/HoldDropJSObjects.h"
+#include "mozilla/RefPtr.h"
+#include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/ImageDataBinding.h"
-
-#include "jsapi.h"
+#include "nsCycleCollectionNoteChild.h"
 
 namespace mozilla::dom {
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(ImageData)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(ImageData)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(ImageData)
 
--- a/dom/canvas/ImageData.h
+++ b/dom/canvas/ImageData.h
@@ -5,30 +5,37 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_ImageData_h
 #define mozilla_dom_ImageData_h
 
 #include <cstdint>
 #include <utility>
 #include "js/RootingAPI.h"
-#include "js/StructuredClone.h"
 #include "mozilla/AlreadyAddRefed.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/dom/TypedArray.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsISupports.h"
 
+class JSObject;
 class nsIGlobalObject;
+struct JSContext;
+struct JSStructuredCloneReader;
+struct JSStructuredCloneWriter;
 
 namespace mozilla {
 class ErrorResult;
 
 namespace dom {
 
+class GlobalObject;
+template <typename T>
+class Optional;
+
 class ImageData final : public nsISupports {
   ~ImageData() { DropData(); }
 
  public:
   ImageData(uint32_t aWidth, uint32_t aHeight, JSObject& aData)
       : mWidth(aWidth), mHeight(aHeight), mData(&aData) {
     HoldData();
   }
--- a/dom/crypto/CryptoKey.cpp
+++ b/dom/crypto/CryptoKey.cpp
@@ -1,23 +1,52 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "CryptoKey.h"
+#include "mozilla/dom/CryptoKey.h"
 
-#include "cryptohi.h"
+#include <cstddef>
+#include <cstring>
+#include <memory>
+#include <new>
+#include <utility>
+#include "blapit.h"
+#include "certt.h"
+#include "js/StructuredClone.h"
+#include "js/TypeDecls.h"
+#include "keyhi.h"
 #include "mozilla/ArrayUtils.h"
+#include "mozilla/ErrorResult.h"
+#include "mozilla/MacroForEach.h"
+#include "mozilla/dom/KeyAlgorithmBinding.h"
 #include "mozilla/dom/RootedDictionary.h"
 #include "mozilla/dom/SubtleCryptoBinding.h"
 #include "mozilla/dom/ToJSValue.h"
+#include "mozilla/dom/WebCryptoCommon.h"
+#include "nsDebug.h"
+#include "nsError.h"
+#include "nsLiteralString.h"
 #include "nsNSSComponent.h"
+#include "nsStringFlags.h"
+#include "nsTArray.h"
 #include "pk11pub.h"
+#include "pkcs11t.h"
+#include "plarena.h"
+#include "prtypes.h"
+#include "secasn1.h"
+#include "secasn1t.h"
+#include "seccomon.h"
+#include "secdert.h"
+#include "secitem.h"
+#include "secmodt.h"
+#include "secoid.h"
+#include "secoidt.h"
 
 namespace mozilla::dom {
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CryptoKey, mGlobal)
 NS_IMPL_CYCLE_COLLECTING_ADDREF(CryptoKey)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(CryptoKey)
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CryptoKey)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
--- a/dom/crypto/CryptoKey.h
+++ b/dom/crypto/CryptoKey.h
@@ -2,33 +2,46 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_CryptoKey_h
 #define mozilla_dom_CryptoKey_h
 
-#include "nsCycleCollectionParticipant.h"
-#include "nsWrapperCache.h"
-#include "nsIGlobalObject.h"
-#include "pk11pub.h"
-#include "keyhi.h"
+#include <cstdint>
+#include "ErrorList.h"
 #include "ScopedNSSTypes.h"
-#include "mozilla/ErrorResult.h"
+#include "js/RootingAPI.h"
+#include "keythi.h"
+#include "mozilla/AlreadyAddRefed.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/RefPtr.h"
+#include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/CryptoBuffer.h"
 #include "mozilla/dom/KeyAlgorithmProxy.h"
-#include "js/StructuredClone.h"
-#include "js/TypeDecls.h"
+#include "nsCycleCollectionParticipant.h"
+#include "nsIGlobalObject.h"
+#include "nsISupports.h"
+#include "nsStringFwd.h"
+#include "nsTArrayForwardDeclare.h"
+#include "nsWrapperCache.h"
 
 #define CRYPTOKEY_SC_VERSION 0x00000001
 
+class JSObject;
 class nsIGlobalObject;
+struct JSContext;
+struct JSStructuredCloneReader;
+struct JSStructuredCloneWriter;
 
 namespace mozilla {
+
+class ErrorResult;
+
 namespace dom {
 
 /*
 
 The internal structure of keys is dictated by the need for cloning.
 We store everything besides the key data itself in a 32-bit bitmask,
 with the following structure (byte-aligned for simplicity, in order
 from least to most significant):
--- a/dom/crypto/KeyAlgorithmProxy.cpp
+++ b/dom/crypto/KeyAlgorithmProxy.cpp
@@ -1,15 +1,18 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/KeyAlgorithmProxy.h"
+
+#include "js/StructuredClone.h"
+#include "mozilla/Assertions.h"
 #include "mozilla/dom/StructuredCloneHolder.h"
 #include "mozilla/dom/WebCryptoCommon.h"
 
 namespace mozilla::dom {
 
 bool KeyAlgorithmProxy::WriteStructuredClone(
     JSStructuredCloneWriter* aWriter) const {
   if (!StructuredCloneHolder::WriteString(aWriter, mName) ||
--- a/dom/crypto/KeyAlgorithmProxy.h
+++ b/dom/crypto/KeyAlgorithmProxy.h
@@ -2,20 +2,31 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_KeyAlgorithmProxy_h
 #define mozilla_dom_KeyAlgorithmProxy_h
 
-#include "pk11pub.h"
-#include "js/StructuredClone.h"
+#include <cstdint>
+#include <utility>
+#include "js/RootingAPI.h"
+#include "mozilla/dom/CryptoBuffer.h"
 #include "mozilla/dom/KeyAlgorithmBinding.h"
+#include "mozilla/dom/TypedArray.h"
 #include "mozilla/dom/WebCryptoCommon.h"
+#include "nsLiteralString.h"
+#include "nsStringFwd.h"
+#include "pkcs11t.h"
+
+class JSObject;
+struct JSContext;
+struct JSStructuredCloneReader;
+struct JSStructuredCloneWriter;
 
 #define KEY_ALGORITHM_SC_VERSION 0x00000001
 
 namespace mozilla {
 namespace dom {
 
 // A heap-safe variant of RsaHashedKeyAlgorithm
 // The only difference is that it uses CryptoBuffer instead of Uint8Array
--- a/dom/crypto/WebCryptoCommon.h
+++ b/dom/crypto/WebCryptoCommon.h
@@ -2,22 +2,39 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_WebCryptoCommon_h
 #define mozilla_dom_WebCryptoCommon_h
 
+// XXX Several of these dependencies could be removed by moving implementations
+// to the cpp file.
+
+#include <cstdint>
+#include <cstring>
 #include "js/StructuredClone.h"
 #include "mozilla/ArrayUtils.h"
+#include "mozilla/Assertions.h"
 #include "mozilla/dom/CryptoBuffer.h"
+#include "mozilla/fallible.h"
 #include "nsContentUtils.h"
-#include "nsString.h"
-#include "pk11pub.h"
+#include "nsLiteralString.h"
+#include "nsStringFwd.h"
+#include "pkcs11t.h"
+#include "plarena.h"
+#include "secasn1t.h"
+#include "seccomon.h"
+#include "secitem.h"
+#include "secoid.h"
+#include "secoidt.h"
+
+struct JSStructuredCloneReader;
+struct JSStructuredCloneWriter;
 
 // WebCrypto algorithm names
 #define WEBCRYPTO_ALG_AES_CBC "AES-CBC"
 #define WEBCRYPTO_ALG_AES_CTR "AES-CTR"
 #define WEBCRYPTO_ALG_AES_GCM "AES-GCM"
 #define WEBCRYPTO_ALG_AES_KW "AES-KW"
 #define WEBCRYPTO_ALG_SHA1 "SHA-1"
 #define WEBCRYPTO_ALG_SHA256 "SHA-256"
--- a/dom/indexedDB/IndexedDatabase.cpp
+++ b/dom/indexedDB/IndexedDatabase.cpp
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "IndexedDatabase.h"
+#include "mozilla/dom/IndexedDatabase.h"
 #include "IndexedDatabaseInlines.h"
 
 #include "IDBDatabase.h"
 #include "IDBMutableFile.h"
 
 #include "mozilla/dom/FileBlobImpl.h"
 #include "mozilla/dom/StructuredCloneTags.h"
 #include "mozilla/dom/WorkerPrivate.h"
--- a/dom/indexedDB/IndexedDatabase.h
+++ b/dom/indexedDB/IndexedDatabase.h
@@ -19,18 +19,16 @@ namespace mozilla {
 namespace dom {
 
 class Blob;
 class IDBDatabase;
 class IDBMutableFile;
 
 namespace indexedDB {
 
-class SerializedStructuredCloneReadInfo;
-
 struct StructuredCloneFileBase {
   enum FileType {
     eBlob,
     eMutableFile,
     eStructuredClone,
     eWasmBytecode,
     eWasmCompiled,
     eEndGuard
--- a/dom/media/webrtc/RTCCertificate.cpp
+++ b/dom/media/webrtc/RTCCertificate.cpp
@@ -1,29 +1,62 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/RTCCertificate.h"
 
-#include <cmath>
 #include <cstdio>
+#include <cstring>
+#include <memory>
+#include <new>
 #include <utility>
-
+#include "ErrorList.h"
+#include "MainThreadUtils.h"
 #include "cert.h"
-#include "jsapi.h"
-#include "mozilla/Sprintf.h"
+#include "cryptohi.h"
+#include "js/StructuredClone.h"
+#include "js/TypeDecls.h"
+#include "js/Value.h"
+#include "keyhi.h"
+#include "mozilla/ErrorResult.h"
+#include "mozilla/MacroForEach.h"
+#include "mozilla/OwningNonNull.h"
+#include "mozilla/UniquePtr.h"
+#include "mozilla/dom/BindingDeclarations.h"
+#include "mozilla/dom/CryptoBuffer.h"
 #include "mozilla/dom/CryptoKey.h"
+#include "mozilla/dom/KeyAlgorithmBinding.h"
+#include "mozilla/dom/KeyAlgorithmProxy.h"
+#include "mozilla/dom/Promise.h"
 #include "mozilla/dom/RTCCertificateBinding.h"
 #include "mozilla/dom/StructuredCloneHolder.h"
+#include "mozilla/dom/SubtleCryptoBinding.h"
+#include "mozilla/dom/UnionTypes.h"
 #include "mozilla/dom/WebCryptoCommon.h"
 #include "mozilla/dom/WebCryptoTask.h"
+#include "mozilla/fallible.h"
+#include "nsDebug.h"
+#include "nsError.h"
+#include "nsLiteralString.h"
+#include "nsStringFlags.h"
+#include "nsStringFwd.h"
+#include "nsTLiteralString.h"
+#include "pk11pub.h"
+#include "plarena.h"
+#include "secasn1.h"
+#include "secasn1t.h"
+#include "seccomon.h"
+#include "secmodt.h"
+#include "secoid.h"
+#include "secoidt.h"
 #include "transport/dtlsidentity.h"
+#include "xpcpublic.h"
 
 namespace mozilla::dom {
 
 #define RTCCERTIFICATE_SC_VERSION 0x00000001
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(RTCCertificate, mGlobal)
 NS_IMPL_CYCLE_COLLECTING_ADDREF(RTCCertificate)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(RTCCertificate)
--- a/dom/media/webrtc/RTCCertificate.h
+++ b/dom/media/webrtc/RTCCertificate.h
@@ -2,36 +2,49 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_RTCCertificate_h
 #define mozilla_dom_RTCCertificate_h
 
+#include <cstdint>
+#include "ScopedNSSTypes.h"
+#include "certt.h"
+#include "js/RootingAPI.h"
+#include "keythi.h"
+#include "mozilla/AlreadyAddRefed.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/RefPtr.h"
 #include "nsCycleCollectionParticipant.h"
+#include "nsIGlobalObject.h"
+#include "nsISupports.h"
 #include "nsWrapperCache.h"
-#include "nsIGlobalObject.h"
 #include "prtime.h"
 #include "sslt.h"
-#include "ScopedNSSTypes.h"
 
-#include "mozilla/ErrorResult.h"
-#include "mozilla/UniquePtr.h"
-#include "mozilla/RefPtr.h"
-#include "mozilla/dom/CryptoKey.h"
-#include "mozilla/dom/RTCCertificateBinding.h"
-#include "js/StructuredClone.h"
-#include "js/TypeDecls.h"
+class JSObject;
+struct JSContext;
+struct JSStructuredCloneReader;
+struct JSStructuredCloneWriter;
+
+namespace JS {
+class Compartment;
+}
 
 namespace mozilla {
 class DtlsIdentity;
+class ErrorResult;
+
 namespace dom {
 
+class GlobalObject;
 class ObjectOrString;
+class Promise;
 
 class RTCCertificate final : public nsISupports, public nsWrapperCache {
  public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(RTCCertificate)
 
   // WebIDL method that implements RTCPeerConnection.generateCertificate.
   static already_AddRefed<Promise> GenerateCertificate(
--- a/dom/url/URLSearchParams.cpp
+++ b/dom/url/URLSearchParams.cpp
@@ -1,20 +1,42 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "URLSearchParams.h"
+#include "mozilla/dom/URLSearchParams.h"
+
+// XXX encoding_rs.h is not self-contained, this order is required
+#include "mozilla/Encoding.h"
+#include "encoding_rs.h"
+
+#include <new>
+#include <type_traits>
+#include <utility>
+#include "js/StructuredClone.h"
+#include "mozilla/ArrayIterator.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/ErrorResult.h"
+#include "mozilla/MacroForEach.h"
+#include "mozilla/NotNull.h"
+#include "mozilla/dom/BindingDeclarations.h"
+#include "mozilla/dom/Record.h"
 #include "mozilla/dom/StructuredCloneHolder.h"
 #include "mozilla/dom/URLSearchParamsBinding.h"
-#include "mozilla/Encoding.h"
+#include "mozilla/fallible.h"
 #include "nsDOMString.h"
-#include "nsIInputStream.h"
+#include "nsError.h"
+#include "nsIGlobalObject.h"
+#include "nsLiteralString.h"
+#include "nsPrintfCString.h"
+#include "nsString.h"
+#include "nsStringFlags.h"
+#include "nsStringIterator.h"
 #include "nsStringStream.h"
 #include "nsURLHelper.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(URLSearchParams, mParent, mObserver)
 NS_IMPL_CYCLE_COLLECTING_ADDREF(URLSearchParams)
--- a/dom/url/URLSearchParams.h
+++ b/dom/url/URLSearchParams.h
@@ -2,31 +2,45 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_URLSearchParams_h
 #define mozilla_dom_URLSearchParams_h
 
-#include "js/StructuredClone.h"
-#include "mozilla/dom/BindingDeclarations.h"
-#include "mozilla/ErrorResult.h"
+#include <cstdint>
+#include "ErrorList.h"
+#include "js/RootingAPI.h"
+#include "mozilla/AlreadyAddRefed.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/RefPtr.h"
+#include "mozilla/UniquePtr.h"
+#include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
+#include "nsISupports.h"
+#include "nsStringFwd.h"
+#include "nsTArray.h"
 #include "nsWrapperCache.h"
-#include "nsISupports.h"
-#include "nsIInputStream.h"
 
+class JSObject;
 class nsIGlobalObject;
+class nsIInputStream;
+struct JSContext;
+struct JSStructuredCloneReader;
+struct JSStructuredCloneWriter;
 
 namespace mozilla {
+
+class ErrorResult;
 class URLParams;
 
 namespace dom {
 
+class GlobalObject;
 class URLSearchParams;
 class USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString;
 
 class URLSearchParamsObserver : public nsISupports {
  public:
   virtual ~URLSearchParamsObserver() = default;
 
   virtual void URLSearchParamsUpdated(URLSearchParams* aFromThis) = 0;
--- a/intl/l10n/FluentBundle.cpp
+++ b/intl/l10n/FluentBundle.cpp
@@ -2,16 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "FluentBundle.h"
 #include "nsContentUtils.h"
 #include "mozilla/dom/UnionTypes.h"
+#include "nsIInputStream.h"
 #include "nsStringFwd.h"
 #include "nsTArray.h"
 #include "unicode/numberformatter.h"
 #include "unicode/datefmt.h"
 
 using namespace mozilla::dom;
 
 namespace mozilla {