Bug 911020 - Introduce js/TypeDecls.h, which holds very commonly used type declarations from the JS engine. r=luke.
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 27 Aug 2013 19:59:14 -0700
changeset 145213 9e98958b5e50ca9456adb49750e6480ac7ad201d
parent 145212 85ca556d2bcfee0d3812eaffe9179b7b9acf5cce
child 145214 d6a0066e7081f31e788be79cf8156fe1aa01548c
push id25201
push useremorley@mozilla.com
push dateMon, 02 Sep 2013 13:55:21 +0000
treeherdermozilla-central@66991961691d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs911020
milestone26.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 911020 - Introduce js/TypeDecls.h, which holds very commonly used type declarations from the JS engine. r=luke.
caps/idl/nsIPrincipal.idl
caps/include/nsScriptSecurityManager.h
content/base/public/nsContentUtils.h
content/base/public/nsINode.h
content/base/src/nsFrameMessageManager.h
content/base/src/nsNodeUtils.h
content/canvas/src/WebGLActiveInfo.h
content/events/src/nsDOMEvent.h
content/html/content/public/nsIHTMLCollection.h
content/html/content/src/ValidityState.h
content/media/webaudio/AudioBuffer.h
content/media/webaudio/AudioContext.h
content/media/webaudio/AudioListener.h
content/media/webaudio/AudioParam.h
content/media/webspeech/recognition/SpeechGrammar.h
content/media/webspeech/recognition/SpeechGrammarList.h
content/media/webspeech/recognition/SpeechRecognition.h
content/media/webspeech/recognition/SpeechRecognitionAlternative.h
content/media/webspeech/recognition/SpeechRecognitionResult.h
content/media/webspeech/recognition/SpeechRecognitionResultList.h
content/media/webspeech/synth/SpeechSynthesis.h
content/media/webspeech/synth/SpeechSynthesisUtterance.h
content/media/webspeech/synth/SpeechSynthesisVoice.h
content/xbl/src/nsXBLBinding.h
content/xbl/src/nsXBLPrototypeHandler.h
content/xbl/src/nsXBLSerialize.h
content/xul/document/src/XULDocument.h
docshell/base/nsIDocShell.idl
dom/base/nsIGlobalObject.h
dom/base/nsIScriptGlobalObject.h
dom/base/nsIScriptTimeoutHandler.h
dom/base/nsLocation.h
dom/base/nsPIDOMWindow.h
dom/base/nsPIWindowRoot.h
dom/base/nsPerformance.h
dom/base/nsWrapperCache.h
dom/bindings/BindingDeclarations.h
dom/bindings/Date.h
dom/bindings/ErrorResult.h
dom/bluetooth/BluetoothUtils.h
dom/cellbroadcast/src/CellBroadcast.h
dom/interfaces/base/nsIDOMHistory.idl
dom/interfaces/base/nsIStructuredCloneContainer.idl
dom/interfaces/events/nsIDOMEventTarget.idl
dom/interfaces/json/nsIJSON.idl
dom/ipc/TabParent.h
dom/network/src/TCPServerSocketChild.h
dom/network/src/TCPServerSocketParent.h
dom/network/src/TCPSocketChild.h
dom/network/src/TCPSocketParent.h
dom/plugins/base/nsNPAPIPluginInstance.h
dom/promise/Promise.h
dom/promise/PromiseResolver.h
dom/src/geolocation/nsGeoPosition.h
embedding/components/windowwatcher/src/nsWindowWatcher.h
ipc/testshell/TestShellParent.h
ipc/testshell/XPCShellEnvironment.h
js/public/Anchor.h
js/public/CallArgs.h
js/public/Class.h
js/public/Id.h
js/public/IdForward.h
js/public/OldDebugAPI.h
js/public/ProfilingStack.h
js/public/PropertyKey.h
js/public/RootingAPI.h
js/public/StructuredClone.h
js/public/TypeDecls.h
js/src/TraceLogging.h
js/src/builtin/Intl.h
js/src/builtin/Module.cpp
js/src/frontend/BytecodeCompiler.cpp
js/src/frontend/NameFunctions.h
js/src/gc/Marking.h
js/src/gc/Rooting.h
js/src/jit/IonCaches.h
js/src/jit/IonCode.h
js/src/jit/IonFrames.h
js/src/jit/JSONSpewer.h
js/src/jit/PerfSpewer.h
js/src/jsalloc.h
js/src/jsanalyze.h
js/src/jsapi.h
js/src/jsdate.h
js/src/jsgc.h
js/src/jsinfer.h
js/src/jsnum.h
js/src/jspubtd.h
js/src/jsscript.cpp
js/src/jsscript.h
js/src/jsutil.h
js/src/moz.build
js/src/vm/Debugger.cpp
js/src/vm/Debugger.h
js/src/vm/GlobalObject.cpp
js/src/vm/SPSProfiler.h
js/src/vm/Shape.h
js/src/vm/Stack.h
js/src/vm/String.h
js/src/vm/ThreadPool.h
js/xpconnect/idl/nsIXPConnect.idl
js/xpconnect/idl/xpcIJSModuleLoader.idl
js/xpconnect/idl/xpcexception.idl
netwerk/base/src/ProxyAutoConfig.h
storage/src/mozStoragePrivateHelpers.h
tools/profiler/GeckoProfiler.h
tools/profiler/GeckoProfilerFunc.h
tools/profiler/JSObjectBuilder.h
xpcom/build/nsXULAppAPI.h
xpfe/appshell/public/nsIAppShellService.idl
--- a/caps/idl/nsIPrincipal.idl
+++ b/caps/idl/nsIPrincipal.idl
@@ -3,17 +3,16 @@
  * 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/. */
 
 /* Defines the abstract interface for a principal. */
 
 #include "nsISerializable.idl"
 
 %{C++
-struct JSContext;
 struct JSPrincipals;
 #include "nsCOMPtr.h"
 #include "nsTArray.h"
 %}
 
 interface nsIURI;
 interface nsIContentSecurityPolicy;
 
--- a/caps/include/nsScriptSecurityManager.h
+++ b/caps/include/nsScriptSecurityManager.h
@@ -13,23 +13,20 @@
 #include "nsInterfaceHashtable.h"
 #include "nsHashtable.h"
 #include "nsCOMPtr.h"
 #include "nsIChannelEventSink.h"
 #include "nsIObserver.h"
 #include "pldhash.h"
 #include "plstr.h"
 #include "nsIScriptExternalNameSet.h"
+#include "js/TypeDecls.h"
 
 #include <stdint.h>
 
-namespace JS {
-template <typename T> class Handle;
-template <typename T> class MutableHandle;
-}
 class nsIDocShell;
 class nsString;
 class nsIClassInfo;
 class nsIIOService;
 class nsIStringBundle;
 class nsSystemPrincipal;
 struct ClassPolicy;
 class ClassInfoData;
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -13,16 +13,17 @@
 #if defined(XP_WIN) || defined(XP_OS2)
 #include <float.h>
 #endif
 
 #if defined(SOLARIS)
 #include <ieeefp.h>
 #endif
 
+#include "js/TypeDecls.h"
 #include "js/RootingAPI.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/GuardObjects.h"
 #include "mozilla/TimeStamp.h"
 #include "nsContentListDeclarations.h"
 #include "nsMathUtils.h"
 
 class imgICache;
@@ -87,31 +88,26 @@ class nsNodeInfoManager;
 class nsPIDOMWindow;
 class nsPresContext;
 class nsScriptObjectTracer;
 class nsStringHashKey;
 class nsTextFragment;
 class nsViewportInfo;
 class nsWrapperCache;
 
-struct JSContext;
 struct JSPropertyDescriptor;
 struct JSRuntime;
 struct nsIntMargin;
 
 template<class E> class nsCOMArray;
 template<class E> class nsTArray;
 template<class K, class V> class nsDataHashtable;
 template<class K, class V> class nsRefPtrHashtable;
 template<class T> class nsReadingIterator;
 
-namespace JS {
-class Value;
-} // namespace JS
-
 namespace mozilla {
 class ErrorResult;
 class Selection;
 
 namespace dom {
 class DocumentFragment;
 class Element;
 class EventTarget;
--- a/content/base/public/nsINode.h
+++ b/content/base/public/nsINode.h
@@ -14,16 +14,17 @@
 #include "nsIVariant.h"             // for use in GetUserData()
 #include "nsNodeInfoManager.h"      // for use in NodePrincipal()
 #include "nsPropertyTable.h"        // for typedefs
 #include "nsTObserverArray.h"       // for member
 #include "nsWindowMemoryReporter.h" // for NS_DECL_SIZEOF_EXCLUDING_THIS
 #include "mozilla/ErrorResult.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/dom/EventTarget.h" // for base class
+#include "js/TypeDecls.h"     // for Handle, Value, JSObject, JSContext
 
 // Including 'windows.h' will #define GetClassInfo to something else.
 #ifdef XP_WIN
 #ifdef GetClassInfo
 #undef GetClassInfo
 #endif
 #endif
 
@@ -62,21 +63,16 @@ inline bool IsSpaceCharacter(char aChar)
 }
 class Element;
 class EventHandlerNonNull;
 class OnErrorEventHandlerNonNull;
 template<typename T> class Optional;
 } // namespace dom
 } // namespace mozilla
 
-namespace JS {
-class Value;
-template<typename T> class Handle;
-}
-
 #define NODE_FLAG_BIT(n_) (1U << (WRAPPER_CACHE_FLAGS_BITS_USED + (n_)))
 
 enum {
   // This bit will be set if the node has a listener manager.
   NODE_HAS_LISTENERMANAGER =              NODE_FLAG_BIT(0),
 
   // Whether this node has had any properties set on it
   NODE_HAS_PROPERTIES =                   NODE_FLAG_BIT(1),
--- a/content/base/src/nsFrameMessageManager.h
+++ b/content/base/src/nsFrameMessageManager.h
@@ -103,18 +103,16 @@ protected:
 StructuredCloneData UnpackClonedMessageDataForParent(const ClonedMessageData& aData);
 StructuredCloneData UnpackClonedMessageDataForChild(const ClonedMessageData& aData);
 
 } // namespace ipc
 } // namespace dom
 } // namespace mozilla
 
 class nsAXPCNativeCallContext;
-struct JSContext;
-class JSObject;
 
 struct nsMessageListenerInfo
 {
   // Exactly one of mStrongListener and mWeakListener must be non-null.
   nsCOMPtr<nsIMessageListener> mStrongListener;
   nsWeakPtr mWeakListener;
   nsCOMPtr<nsIAtom> mMessage;
 };
--- a/content/base/src/nsNodeUtils.h
+++ b/content/base/src/nsNodeUtils.h
@@ -3,20 +3,19 @@
  * 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 nsNodeUtils_h___
 #define nsNodeUtils_h___
 
 #include "nsIContent.h"          // for use in inline function (ParentChainChanged)
 #include "nsIMutationObserver.h" // for use in inline function (ParentChainChanged)
+#include "js/TypeDecls.h"
 
 struct CharacterDataChangeInfo;
-struct JSContext;
-class JSObject;
 class nsIVariant;
 class nsIDOMNode;
 class nsIDOMUserDataHandler;
 template<class E> class nsCOMArray;
 class nsCycleCollectionTraversalCallback;
 
 class nsNodeUtils
 {
--- a/content/canvas/src/WebGLActiveInfo.h
+++ b/content/canvas/src/WebGLActiveInfo.h
@@ -4,22 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef WEBGLACTIVEINFO_H_
 #define WEBGLACTIVEINFO_H_
 
 #include "WebGLTypes.h"
 #include "nsISupports.h"
 #include "nsString.h"
-
-struct JSContext;
-class JSObject;
-namespace JS {
-template <typename T> class Handle;
-}
+#include "js/TypeDecls.h"
 
 namespace mozilla {
 
 class WebGLActiveInfo MOZ_FINAL
 {
 public:
     WebGLActiveInfo(WebGLint size, WebGLenum type, const nsACString& name) :
         mSize(size),
--- a/content/events/src/nsDOMEvent.h
+++ b/content/events/src/nsDOMEvent.h
@@ -13,22 +13,21 @@
 #include "nsPIDOMWindow.h"
 #include "nsPoint.h"
 #include "nsGUIEvent.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsAutoPtr.h"
 #include "mozilla/dom/EventBinding.h"
 #include "nsIScriptGlobalObject.h"
 #include "Units.h"
+#include "js/TypeDecls.h"
 
 class nsIContent;
 class nsIDOMEventTarget;
 class nsPresContext;
-struct JSContext;
-class JSObject;
 
 namespace mozilla {
 namespace dom {
 class EventTarget;
 }
 }
 
 // Dummy class so we can cast through it to get from nsISupports to
--- a/content/html/content/public/nsIHTMLCollection.h
+++ b/content/html/content/public/nsIHTMLCollection.h
@@ -3,19 +3,18 @@
  * 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 nsIHTMLCollection_h___
 #define nsIHTMLCollection_h___
 
 #include "nsIDOMHTMLCollection.h"
 #include "nsWrapperCache.h"
+#include "js/TypeDecls.h"
 
-struct JSContext;
-class JSObject;
 class nsINode;
 class nsString;
 template<class> class nsTArray;
 
 namespace mozilla {
 class ErrorResult;
 
 namespace dom {
--- a/content/html/content/src/ValidityState.h
+++ b/content/html/content/src/ValidityState.h
@@ -4,19 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_ValidityState_h
 #define mozilla_dom_ValidityState_h
 
 #include "nsIDOMValidityState.h"
 #include "nsIConstraintValidation.h"
 #include "nsWrapperCache.h"
-
-class JSObject;
-struct JSContext;
+#include "js/TypeDecls.h"
 
 namespace mozilla {
 namespace dom {
 
 class ValidityState MOZ_FINAL : public nsIDOMValidityState,
                                 public nsWrapperCache
 {
 public:
--- a/content/media/webaudio/AudioBuffer.h
+++ b/content/media/webaudio/AudioBuffer.h
@@ -9,19 +9,17 @@
 
 #include "nsWrapperCache.h"
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/Attributes.h"
 #include "EnableWebAudioCheck.h"
 #include "nsAutoPtr.h"
 #include "nsTArray.h"
 #include "AudioContext.h"
-
-struct JSContext;
-class JSObject;
+#include "js/TypeDecls.h"
 
 namespace mozilla {
 
 class ErrorResult;
 class ThreadSharedFloatArrayBufferList;
 
 namespace dom {
 
--- a/content/media/webaudio/AudioContext.h
+++ b/content/media/webaudio/AudioContext.h
@@ -12,25 +12,24 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/TypedArray.h"
 #include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsDOMEventTargetHelper.h"
 #include "nsHashKeys.h"
 #include "nsTHashtable.h"
+#include "js/TypeDecls.h"
 
 // X11 has a #define for CurrentTime. Unbelievable :-(.
 // See content/media/DOMMediaStream.h for more fun!
 #ifdef CurrentTime
 #undef CurrentTime
 #endif
 
-struct JSContext;
-class JSObject;
 class nsPIDOMWindow;
 
 namespace mozilla {
 
 class DOMMediaStream;
 class ErrorResult;
 class MediaStream;
 class MediaStreamGraph;
--- a/content/media/webaudio/AudioListener.h
+++ b/content/media/webaudio/AudioListener.h
@@ -11,18 +11,17 @@
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/Attributes.h"
 #include "EnableWebAudioCheck.h"
 #include "nsAutoPtr.h"
 #include "ThreeDPoint.h"
 #include "AudioContext.h"
 #include "PannerNode.h"
 #include "WebAudioUtils.h"
-
-struct JSContext;
+#include "js/TypeDecls.h"
 
 namespace mozilla {
 
 namespace dom {
 
 class AudioListener MOZ_FINAL : public nsWrapperCache,
                                 public EnableWebAudioCheck
 {
--- a/content/media/webaudio/AudioParam.h
+++ b/content/media/webaudio/AudioParam.h
@@ -10,18 +10,17 @@
 #include "AudioParamTimeline.h"
 #include "nsWrapperCache.h"
 #include "nsCycleCollectionParticipant.h"
 #include "EnableWebAudioCheck.h"
 #include "nsAutoPtr.h"
 #include "AudioNode.h"
 #include "mozilla/dom/TypedArray.h"
 #include "WebAudioUtils.h"
-
-struct JSContext;
+#include "js/TypeDecls.h"
 
 namespace mozilla {
 
 namespace dom {
 
 class AudioParam MOZ_FINAL : public nsWrapperCache,
                              public EnableWebAudioCheck,
                              public AudioParamTimeline
--- a/content/media/webspeech/recognition/SpeechGrammar.h
+++ b/content/media/webspeech/recognition/SpeechGrammar.h
@@ -5,24 +5,23 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #pragma once
 
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsString.h"
 #include "nsWrapperCache.h"
+#include "js/TypeDecls.h"
 
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
 
 #include "EnableWebSpeechRecognitionCheck.h"
 
-struct JSContext;
-
 namespace mozilla {
 namespace dom {
 
 class GlobalObject;
 
 class SpeechGrammar MOZ_FINAL : public nsISupports,
                                 public nsWrapperCache,
                                 public EnableWebSpeechRecognitionCheck
--- a/content/media/webspeech/recognition/SpeechGrammarList.h
+++ b/content/media/webspeech/recognition/SpeechGrammarList.h
@@ -4,25 +4,24 @@
  * 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/. */
 
 #pragma once
 
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
+#include "js/TypeDecls.h"
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/BindingUtils.h"
 
 #include "EnableWebSpeechRecognitionCheck.h"
 #include "SpeechGrammar.h"
 
-struct JSContext;
-
 namespace mozilla {
 namespace dom {
 
 class GlobalObject;
 class SpeechGrammarList MOZ_FINAL : public nsISupports,
                                     public nsWrapperCache,
                                     public EnableWebSpeechRecognitionCheck
 {
--- a/content/media/webspeech/recognition/SpeechRecognition.h
+++ b/content/media/webspeech/recognition/SpeechRecognition.h
@@ -7,16 +7,17 @@
 #pragma once
 
 #include "mozilla/Attributes.h"
 #include "nsCOMPtr.h"
 #include "nsDOMEventTargetHelper.h"
 #include "nsString.h"
 #include "nsWrapperCache.h"
 #include "nsTArray.h"
+#include "js/TypeDecls.h"
 
 #include "nsIDOMNavigatorUserMedia.h"
 #include "nsITimer.h"
 #include "MediaEngine.h"
 #include "MediaStreamGraph.h"
 #include "AudioSegment.h"
 #include "mozilla/WeakPtr.h"
 #include "mozilla/Preferences.h"
@@ -25,17 +26,16 @@
 #include "SpeechGrammarList.h"
 #include "SpeechRecognitionResultList.h"
 #include "SpeechStreamListener.h"
 #include "nsISpeechRecognitionService.h"
 #include "endpointer.h"
 
 #include "mozilla/dom/SpeechRecognitionError.h"
 
-struct JSContext;
 class nsIDOMWindow;
 
 namespace mozilla {
 
 namespace dom {
 
 #define TEST_PREFERENCE_ENABLE "media.webspeech.test.enable"
 #define TEST_PREFERENCE_FAKE_FSM_EVENTS "media.webspeech.test.fake_fsm_events"
--- a/content/media/webspeech/recognition/SpeechRecognitionAlternative.h
+++ b/content/media/webspeech/recognition/SpeechRecognitionAlternative.h
@@ -5,23 +5,22 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #pragma once
 
 #include "nsCycleCollectionParticipant.h"
 #include "nsString.h"
 #include "nsWrapperCache.h"
 #include "nsAutoPtr.h"
+#include "js/TypeDecls.h"
 
 #include "mozilla/Attributes.h"
 
 #include "EnableWebSpeechRecognitionCheck.h"
 
-struct JSContext;
-
 namespace mozilla {
 namespace dom {
 
 class SpeechRecognition;
 
 class SpeechRecognitionAlternative MOZ_FINAL : public nsISupports,
                                                public nsWrapperCache,
                                                public EnableWebSpeechRecognitionCheck
--- a/content/media/webspeech/recognition/SpeechRecognitionResult.h
+++ b/content/media/webspeech/recognition/SpeechRecognitionResult.h
@@ -6,24 +6,23 @@
 
 #pragma once
 
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 #include "nsAutoPtr.h"
 #include "nsTArray.h"
+#include "js/TypeDecls.h"
 
 #include "mozilla/Attributes.h"
 
 #include "EnableWebSpeechRecognitionCheck.h"
 #include "SpeechRecognitionAlternative.h"
 
-struct JSContext;
-
 namespace mozilla {
 namespace dom {
 
 class SpeechRecognitionResult MOZ_FINAL : public nsISupports,
                                           public nsWrapperCache,
                                           public EnableWebSpeechRecognitionCheck
 {
 public:
--- a/content/media/webspeech/recognition/SpeechRecognitionResultList.h
+++ b/content/media/webspeech/recognition/SpeechRecognitionResultList.h
@@ -5,24 +5,23 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #pragma once
 
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 #include "nsAutoPtr.h"
 #include "nsTArray.h"
+#include "js/TypeDecls.h"
 
 #include "mozilla/Attributes.h"
 
 #include "EnableWebSpeechRecognitionCheck.h"
 #include "SpeechRecognitionResult.h"
 
-struct JSContext;
-
 namespace mozilla {
 namespace dom {
 
 class SpeechRecognition;
 
 class SpeechRecognitionResultList MOZ_FINAL : public nsISupports,
                                               public nsWrapperCache,
                                               public EnableWebSpeechRecognitionCheck
--- a/content/media/webspeech/synth/SpeechSynthesis.h
+++ b/content/media/webspeech/synth/SpeechSynthesis.h
@@ -5,22 +5,22 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #pragma once
 
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsWrapperCache.h"
 #include "nsRefPtrHashtable.h"
+#include "js/TypeDecls.h"
 
 #include "EnableSpeechSynthesisCheck.h"
 #include "SpeechSynthesisUtterance.h"
 #include "SpeechSynthesisVoice.h"
 
-struct JSContext;
 class nsIDOMWindow;
 
 namespace mozilla {
 namespace dom {
 
 class nsSpeechTask;
 
 class SpeechSynthesis MOZ_FINAL : public nsISupports,
--- a/content/media/webspeech/synth/SpeechSynthesisUtterance.h
+++ b/content/media/webspeech/synth/SpeechSynthesisUtterance.h
@@ -4,22 +4,21 @@
  * 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/. */
 
 #pragma once
 
 #include "nsCOMPtr.h"
 #include "nsDOMEventTargetHelper.h"
 #include "nsString.h"
+#include "js/TypeDecls.h"
 
 #include "EnableSpeechSynthesisCheck.h"
 #include "nsSpeechTask.h"
 
-struct JSContext;
-
 namespace mozilla {
 namespace dom {
 
 class SpeechSynthesisVoice;
 class SpeechSynthesis;
 class nsSynthVoiceRegistry;
 
 class SpeechSynthesisUtterance MOZ_FINAL : public nsDOMEventTargetHelper,
--- a/content/media/webspeech/synth/SpeechSynthesisVoice.h
+++ b/content/media/webspeech/synth/SpeechSynthesisVoice.h
@@ -4,22 +4,21 @@
  * 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/. */
 
 #pragma once
 
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsWrapperCache.h"
+#include "js/TypeDecls.h"
 
 #include "EnableSpeechSynthesisCheck.h"
 #include "nsISpeechService.h"
 
-struct JSContext;
-
 namespace mozilla {
 namespace dom {
 
 class nsSynthVoiceRegistry;
 class SpeechSynthesis;
 
 class SpeechSynthesisVoice MOZ_FINAL : public nsISupports,
                                        public nsWrapperCache,
--- a/content/xbl/src/nsXBLBinding.h
+++ b/content/xbl/src/nsXBLBinding.h
@@ -10,34 +10,33 @@
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "nsINodeList.h"
 #include "nsIStyleRuleProcessor.h"
 #include "nsClassHashtable.h"
 #include "nsTArray.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsISupportsImpl.h"
+#include "js/TypeDecls.h"
 
 class nsXBLPrototypeBinding;
 class nsIContent;
 class nsIAtom;
 class nsIDocument;
 class nsIScriptContext;
 
 namespace mozilla {
 namespace dom {
 
 class XBLChildrenElement;
 
 }
 }
 
 class nsAnonymousContentList;
-struct JSContext;
-class JSObject;
 
 // *********************************************************************/
 // The XBLBinding class
 
 class nsXBLBinding
 {
 public:
   nsXBLBinding(nsXBLPrototypeBinding* aProtoBinding);
--- a/content/xbl/src/nsXBLPrototypeHandler.h
+++ b/content/xbl/src/nsXBLPrototypeHandler.h
@@ -10,31 +10,27 @@
 #include "nsString.h"
 #include "nsCOMPtr.h"
 #include "nsIController.h"
 #include "nsAutoPtr.h"
 #include "nsXBLEventHandler.h"
 #include "nsIWeakReference.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsCycleCollectionParticipant.h"
+#include "js/TypeDecls.h"
 
-class JSObject;
 class nsIDOMEvent;
 class nsIContent;
 class nsIDOMUIEvent;
 class nsIDOMKeyEvent;
 class nsIDOMMouseEvent;
 class nsIObjectInputStream;
 class nsIObjectOutputStream;
 class nsXBLPrototypeBinding;
 
-namespace JS {
-template <typename T> class MutableHandle;
-}
-
 namespace mozilla {
 namespace dom {
 class EventTarget;
 }
 }
 
 #define NS_HANDLER_TYPE_XBL_JS              (1 << 0)
 #define NS_HANDLER_TYPE_XBL_COMMAND         (1 << 1)
--- a/content/xbl/src/nsXBLSerialize.h
+++ b/content/xbl/src/nsXBLSerialize.h
@@ -4,21 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsXBLSerialize_h__
 #define nsXBLSerialize_h__
 
 #include "nsIObjectInputStream.h"
 #include "nsIObjectOutputStream.h"
 #include "nsINameSpaceManager.h"
-
-namespace JS {
-template <typename T> class Handle;
-template <typename T> class MutableHandle;
-}
+#include "js/TypeDecls.h"
 
 typedef uint8_t XBLBindingSerializeDetails;
 
 // A version number to ensure we don't load cached data in a different
 // file format.
 #define XBLBinding_Serialize_Version 0x00000002
 
 // Set for the first binding in a document
--- a/content/xul/document/src/XULDocument.h
+++ b/content/xul/document/src/XULDocument.h
@@ -20,32 +20,33 @@
 #include "nsIURI.h"
 #include "nsIXULDocument.h"
 #include "nsScriptLoader.h"
 #include "nsIStreamListener.h"
 #include "nsICSSLoaderObserver.h"
 
 #include "mozilla/Attributes.h"
 
+#include "js/TypeDecls.h"
+
 class nsIRDFResource;
 class nsIRDFService;
 class nsPIWindowRoot;
 #if 0 // XXXbe save me, scc (need NSCAP_FORWARD_DECL(nsXULPrototypeScript))
 class nsIObjectInputStream;
 class nsIObjectOutputStream;
 class nsIXULPrototypeScript;
 #else
 #include "nsIObjectInputStream.h"
 #include "nsIObjectOutputStream.h"
 #include "nsXULElement.h"
 #endif
 #include "nsURIHashKey.h"
 #include "nsInterfaceHashtable.h"
 
-class JSObject;
 struct JSTracer;
 struct PRLogModuleInfo;
 
 class nsRefMapEntry : public nsStringHashKey
 {
 public:
   nsRefMapEntry(const nsAString& aKey) :
     nsStringHashKey(&aKey)
--- a/docshell/base/nsIDocShell.idl
+++ b/docshell/base/nsIDocShell.idl
@@ -4,19 +4,19 @@
  * 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 "domstubs.idl"
 #include "nsIDocShellTreeItem.idl"
 #include "nsIAtom.idl"
 
 %{ C++
+#include "js/TypeDecls.h"
 class nsPresContext;
 class nsIPresShell;
-struct JSContext;
 %}
 
 /**
  * The nsIDocShell interface.
  */
 
 [ptr] native nsPresContext(nsPresContext);
 [ptr] native nsIPresShell(nsIPresShell);
--- a/dom/base/nsIGlobalObject.h
+++ b/dom/base/nsIGlobalObject.h
@@ -3,18 +3,17 @@
  * 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 nsIGlobalObject_h__
 #define nsIGlobalObject_h__
 
 #include "nsISupports.h"
 #include "nsIScriptObjectPrincipal.h"
-
-class JSObject;
+#include "js/TypeDecls.h"
 
 #define NS_IGLOBALOBJECT_IID \
 { 0x8503e9a9, 0x530, 0x4b26,  \
 { 0xae, 0x24, 0x18, 0xca, 0x38, 0xe5, 0xed, 0x17 } }
 
 class nsIGlobalObject : public nsIScriptObjectPrincipal
 {
 public:
--- a/dom/base/nsIScriptGlobalObject.h
+++ b/dom/base/nsIScriptGlobalObject.h
@@ -5,21 +5,21 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsIScriptGlobalObject_h__
 #define nsIScriptGlobalObject_h__
 
 #include "nsISupports.h"
 #include "nsEvent.h"
 #include "nsIGlobalObject.h"
+#include "js/TypeDecls.h"
 
 class nsIScriptContext;
 class nsScriptErrorEvent;
 class nsIScriptGlobalObject;
-class JSObject;
 
 // A helper function for nsIScriptGlobalObject implementations to use
 // when handling a script error.  Generally called by the global when a context
 // notifies it of an error via nsIScriptGlobalObject::HandleScriptError.
 // Returns true if HandleDOMEvent was actually called, in which case
 // aStatus will be filled in with the status.
 bool
 NS_HandleScriptError(nsIScriptGlobalObject *aScriptGlobal,
--- a/dom/base/nsIScriptTimeoutHandler.h
+++ b/dom/base/nsIScriptTimeoutHandler.h
@@ -2,20 +2,18 @@
 /* vim: set ts=2 sw=2 et 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 nsIScriptTimeoutHandler_h___
 #define nsIScriptTimeoutHandler_h___
 
 #include "nsTArray.h"
+#include "js/TypeDecls.h"
 
-namespace JS {
-class Value;
-} // namespace JS
 namespace mozilla {
 namespace dom {
 class Function;
 } // namespace dom
 } // namespace mozilla
 
 #define NS_ISCRIPTTIMEOUTHANDLER_IID \
 { 0x53c8e80e, 0xcc78, 0x48bc, \
--- a/dom/base/nsLocation.h
+++ b/dom/base/nsLocation.h
@@ -7,20 +7,20 @@
 #ifndef nsLocation_h__
 #define nsLocation_h__
 
 #include "nsIDOMLocation.h"
 #include "nsString.h"
 #include "nsIWeakReferenceUtils.h"
 #include "nsWrapperCache.h"
 #include "nsCycleCollectionParticipant.h"
+#include "js/TypeDecls.h"
 
 class nsIURI;
 class nsIDocShell;
-struct JSContext;
 class nsIDocShellLoadInfo;
 
 //*****************************************************************************
 // nsLocation: Script "location" object
 //*****************************************************************************
 
 class nsLocation : public nsIDOMLocation
                  , public nsWrapperCache
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -9,39 +9,35 @@
 #define nsPIDOMWindow_h__
 
 #include "nsIDOMWindow.h"
 
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "nsTArray.h"
 #include "mozilla/dom/EventTarget.h"
+#include "js/TypeDecls.h"
 
 #define DOM_WINDOW_DESTROYED_TOPIC "dom-window-destroyed"
 #define DOM_WINDOW_FROZEN_TOPIC "dom-window-frozen"
 #define DOM_WINDOW_THAWED_TOPIC "dom-window-thawed"
 
-class JSObject;
 class nsIArray;
 class nsIContent;
 class nsIDocShell;
 class nsIDocument;
 class nsIIdleObserver;
 class nsIPrincipal;
 class nsIScriptTimeoutHandler;
 class nsIURI;
 class nsPerformance;
 class nsPIWindowRoot;
 class nsXBLPrototypeHandler;
 struct nsTimeout;
 
-namespace JS {
-template<typename> class Handle;
-}
-
 namespace mozilla {
 namespace dom {
 class AudioContext;
 class Element;
 }
 }
 
 // Popup control state enum. The values in this enum must go from most
--- a/dom/base/nsPIWindowRoot.h
+++ b/dom/base/nsPIWindowRoot.h
@@ -8,17 +8,16 @@
 #define nsPIWindowRoot_h__
 
 #include "nsISupports.h"
 #include "mozilla/dom/EventTarget.h"
 
 class nsPIDOMWindow;
 class nsIControllers;
 class nsIController;
-struct JSContext;
 
 #define NS_IWINDOWROOT_IID \
 { 0x3f71f50c, 0xa7e0, 0x43bc, \
  { 0xac, 0x25, 0x4d, 0xbb, 0x88, 0x7b, 0x21, 0x09 } }
 
 class nsPIWindowRoot : public mozilla::dom::EventTarget
 {
 public:
--- a/dom/base/nsPerformance.h
+++ b/dom/base/nsPerformance.h
@@ -7,21 +7,20 @@
 
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "mozilla/Attributes.h"
 #include "nsWrapperCache.h"
 #include "nsDOMNavigationTiming.h"
 #include "nsContentUtils.h"
 #include "nsIDOMWindow.h"
+#include "js/TypeDecls.h"
 
 class nsITimedChannel;
 class nsPerformance;
-class JSObject;
-struct JSContext;
 
 // Script "performance.timing" object
 class nsPerformanceTiming MOZ_FINAL : public nsWrapperCache
 {
 public:
   nsPerformanceTiming(nsPerformance* aPerformance,
                       nsITimedChannel* aChannel);
   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsPerformanceTiming)
--- a/dom/base/nsWrapperCache.h
+++ b/dom/base/nsWrapperCache.h
@@ -8,18 +8,16 @@
 
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/Assertions.h"
 #include "js/Id.h"          // must come before js/RootingAPI.h
 #include "js/Value.h"       // must come before js/RootingAPI.h
 #include "js/RootingAPI.h"
 
 struct JSTracer;
-class JSObject;
-struct JSContext;
 class XPCWrappedNativeScope;
 
 namespace mozilla {
 namespace dom {
 namespace workers {
 
 class DOMBindingBase;
 
--- a/dom/bindings/BindingDeclarations.h
+++ b/dom/bindings/BindingDeclarations.h
@@ -18,18 +18,16 @@
 #include "js/RootingAPI.h"
 #include "mozilla/Maybe.h"
 #include "nsCOMPtr.h"
 #include "nsDOMString.h"
 #include "nsStringBuffer.h"
 #include "nsTArray.h"
 #include "nsAutoPtr.h" // for nsRefPtr member variables
 
-struct JSContext;
-class JSObject;
 class nsWrapperCache;
 
 // nsGlobalWindow implements nsWrapperCache, but doesn't always use it. Don't
 // try to use it without fixing that first.
 class nsGlobalWindow;
 
 namespace mozilla {
 namespace dom {
--- a/dom/bindings/Date.h
+++ b/dom/bindings/Date.h
@@ -4,23 +4,17 @@
  * 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/. */
 
 /* Representation for dates. */
 
 #ifndef mozilla_dom_Date_h
 #define mozilla_dom_Date_h
 
-class JSObject;
-struct JSContext;
-
-namespace JS {
-class Value;
-template<typename> class MutableHandle;
-} // namespace JS
+#include "js/TypeDecls.h"
 
 namespace mozilla {
 namespace dom {
 
 class Date
 {
 public:
   // Not inlining much here to avoid the includes we'd need.
--- a/dom/bindings/ErrorResult.h
+++ b/dom/bindings/ErrorResult.h
@@ -13,18 +13,16 @@
 
 #include <stdarg.h>
 
 #include "js/Value.h"
 #include "nscore.h"
 #include "nsStringGlue.h"
 #include "mozilla/Assertions.h"
 
-struct JSContext;
-
 namespace mozilla {
 
 namespace dom {
 
 enum ErrNum {
 #define MSG_DEF(_name, _argc, _str) \
   _name,
 #include "mozilla/dom/Errors.msg"
--- a/dom/bluetooth/BluetoothUtils.h
+++ b/dom/bluetooth/BluetoothUtils.h
@@ -3,19 +3,17 @@
 /* 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_bluetooth_bluetoothutils_h__
 #define mozilla_dom_bluetooth_bluetoothutils_h__
 
 #include "BluetoothCommon.h"
-
-struct JSContext;
-class JSObject;
+#include "js/TypeDecls.h"
 
 BEGIN_BLUETOOTH_NAMESPACE
 
 class BluetoothNamedValue;
 class BluetoothValue;
 class BluetoothReplyRunnable;
 
 bool
--- a/dom/cellbroadcast/src/CellBroadcast.h
+++ b/dom/cellbroadcast/src/CellBroadcast.h
@@ -5,19 +5,17 @@
 
 #ifndef mozilla_dom_CellBroadcast_h__
 #define mozilla_dom_CellBroadcast_h__
 
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
 #include "nsDOMEventTargetHelper.h"
 #include "nsICellBroadcastProvider.h"
-
-class JSObject;
-struct JSContext;
+#include "js/TypeDecls.h"
 
 class nsPIDOMWindow;
 
 namespace mozilla {
 namespace dom {
 
 class CellBroadcast MOZ_FINAL : public nsDOMEventTargetHelper
 {
--- a/dom/interfaces/base/nsIDOMHistory.idl
+++ b/dom/interfaces/base/nsIDOMHistory.idl
@@ -1,16 +1,12 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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 "domstubs.idl"
 
-%{ C++
-struct JSContext;
-%}
-
 [scriptable, uuid(55226663-fe68-48ba-addf-08e32eaab569)]
 interface nsIDOMHistory : nsISupports
 {
   // Empty interface that exists only for extension backwards compat
 };
--- a/dom/interfaces/base/nsIStructuredCloneContainer.idl
+++ b/dom/interfaces/base/nsIStructuredCloneContainer.idl
@@ -6,17 +6,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
 interface nsIVariant;
 interface nsIDocument;
 
 %{C++
-struct JSContext;
+#include "js/TypeDecls.h"
 %}
 
 /**
  * This interface acts as a container for an object serialized using the
  * structured clone algorithm.
  *
  * You can copy an object into an nsIStructuredCloneContainer using
  * initFromVariant or initFromBase64.  It's an error to initialize an
--- a/dom/interfaces/events/nsIDOMEventTarget.idl
+++ b/dom/interfaces/events/nsIDOMEventTarget.idl
@@ -3,29 +3,29 @@
  * 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 "domstubs.idl"
 
 %{C++
 #include "nsEvent.h"
 #include "mozilla/dom/Nullable.h"
+#include "js/TypeDecls.h"
 
 using mozilla::dom::Nullable;
 
 namespace mozilla {
 namespace dom {
 class EventTarget;
 } // namespace dom
 } // namespace mozilla
 
 class nsPresContext;
 class nsEventChainPreVisitor;
 class nsEventChainPostVisitor;
-struct JSContext;
 class nsEventListenerManager;
 %}
 
 /**
  * The nsIDOMEventTarget interface is the interface implemented by all
  * event targets in the Document Object Model.
  *
  * For more information on this interface please see 
--- a/dom/interfaces/json/nsIJSON.idl
+++ b/dom/interfaces/json/nsIJSON.idl
@@ -8,17 +8,17 @@
 interface nsIInputStream;
 interface nsIOutputStream;
 interface nsIScriptGlobalObject;
 
 [ptr] native JSValPtr(JS::Value);
 [ptr] native JSContext(JSContext);
 
 %{C++
-namespace JS { class Value; }
+#include "js/TypeDecls.h"
 %}
 
 /**
  * Don't use this!  Use JSON.parse and JSON.stringify directly.
  */
 [scriptable, uuid(083aebb0-7790-43b2-ae81-9e404e626236)]
 interface nsIJSON : nsISupports
 {
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -17,20 +17,19 @@
 #include "nsCOMPtr.h"
 #include "nsIAuthPromptProvider.h"
 #include "nsIBrowserDOMWindow.h"
 #include "nsIDialogParamBlock.h"
 #include "nsISecureBrowserUI.h"
 #include "nsITabParent.h"
 #include "nsWeakReference.h"
 #include "Units.h"
+#include "js/TypeDecls.h"
 
 struct gfxMatrix;
-struct JSContext;
-class JSObject;
 class mozIApplication;
 class nsFrameLoader;
 class nsIURI;
 class CpowHolder;
 
 namespace mozilla {
 
 namespace layers {
--- a/dom/network/src/TCPServerSocketChild.h
+++ b/dom/network/src/TCPServerSocketChild.h
@@ -6,18 +6,16 @@
 #include "nsITCPServerSocketChild.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsCOMPtr.h"
 
 #define TCPSERVERSOCKETCHILD_CID \
   { 0x41a77ec8, 0xfd86, 0x409e, { 0xae, 0xa9, 0xaf, 0x2c, 0xa4, 0x07, 0xef, 0x8e } }
 
 class nsITCPServerSocketInternal;
-struct JSContext;
-struct JSObject;
 
 namespace mozilla {
 namespace dom {
 
 class TCPServerSocketChildBase : public nsITCPServerSocketChild {
 public:
   NS_DECL_CYCLE_COLLECTION_CLASS(TCPServerSocketChildBase)
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
--- a/dom/network/src/TCPServerSocketParent.h
+++ b/dom/network/src/TCPServerSocketParent.h
@@ -5,19 +5,16 @@
 #include "mozilla/net/PNeckoParent.h"
 #include "mozilla/net/PTCPServerSocketParent.h"
 #include "nsITCPSocketParent.h"
 #include "nsITCPServerSocketParent.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsCOMPtr.h"
 #include "nsIDOMTCPSocket.h"
 
-struct JSContext;
-struct JSObject;
-
 namespace mozilla {
 namespace dom {
 
 class PBrowserParent;
 
 class TCPServerSocketParent : public mozilla::net::PTCPServerSocketParent
                             , public nsITCPServerSocketParent
 {
--- a/dom/network/src/TCPSocketChild.h
+++ b/dom/network/src/TCPSocketChild.h
@@ -1,23 +1,22 @@
 /* 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/net/PTCPSocketChild.h"
 #include "nsITCPSocketChild.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsCOMPtr.h"
+#include "js/TypeDecls.h"
 
 #define TCPSOCKETCHILD_CID \
   { 0xa589d96f, 0x7e09, 0x4edf, { 0xa0, 0x1a, 0xeb, 0x49, 0x51, 0xf4, 0x2f, 0x37 } }
 
 class nsITCPSocketInternal;
-struct JSContext;
-class JSObject;
 
 namespace mozilla {
 namespace dom {
 
 class TCPSocketChildBase : public nsITCPSocketChild {
 public:
   NS_DECL_CYCLE_COLLECTION_CLASS(TCPSocketChildBase)
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
--- a/dom/network/src/TCPSocketParent.h
+++ b/dom/network/src/TCPSocketParent.h
@@ -2,19 +2,17 @@
  * 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/net/PTCPSocketParent.h"
 #include "nsITCPSocketParent.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsCOMPtr.h"
 #include "nsIDOMTCPSocket.h"
-
-struct JSContext;
-class JSObject;
+#include "js/TypeDecls.h"
 
 #define TCPSOCKETPARENT_CID \
   { 0x4e7246c6, 0xa8b3, 0x426d, { 0x9c, 0x17, 0x76, 0xda, 0xb1, 0xe1, 0xe1, 0x4a } }
 
 namespace mozilla {
 namespace dom {
 
 class PBrowserParent;
--- a/dom/plugins/base/nsNPAPIPluginInstance.h
+++ b/dom/plugins/base/nsNPAPIPluginInstance.h
@@ -11,32 +11,31 @@
 #include "nsPIDOMWindow.h"
 #include "nsITimer.h"
 #include "nsIPluginTagInfo.h"
 #include "nsIURI.h"
 #include "nsIChannel.h"
 #include "nsInterfaceHashtable.h"
 #include "nsHashKeys.h"
 #include <prinrval.h>
+#include "js/TypeDecls.h"
 #ifdef MOZ_WIDGET_ANDROID
 #include "nsAutoPtr.h"
 #include "nsIRunnable.h"
 #include "GLContext.h"
 #include "nsSurfaceTexture.h"
 #include "AndroidBridge.h"
 #include <map>
 class PluginEventRunnable;
 class SharedPluginTexture;
 #endif
 
 #include "mozilla/TimeStamp.h"
 #include "mozilla/PluginLibrary.h"
 
-class JSObject;
-
 class nsPluginStreamListenerPeer; // browser-initiated stream class
 class nsNPAPIPluginStreamListener; // plugin-initiated stream class
 class nsIPluginInstanceOwner;
 class nsIOutputStream;
 class nsPluginInstanceOwner;
 
 #if defined(OS_WIN)
 const NPDrawingModel kDefaultDrawingModel = NPDrawingModelSyncWin;
--- a/dom/promise/Promise.h
+++ b/dom/promise/Promise.h
@@ -10,18 +10,17 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/dom/PromiseBinding.h"
 #include "nsWrapperCache.h"
 #include "nsAutoPtr.h"
 #include "nsPIDOMWindow.h"
-
-struct JSContext;
+#include "js/TypeDecls.h"
 
 namespace mozilla {
 namespace dom {
 
 class PromiseInit;
 class PromiseCallback;
 class AnyCallback;
 class PromiseResolver;
--- a/dom/promise/PromiseResolver.h
+++ b/dom/promise/PromiseResolver.h
@@ -7,18 +7,17 @@
 #ifndef mozilla_dom_PromiseResolver_h
 #define mozilla_dom_PromiseResolver_h
 
 #include "mozilla/dom/Promise.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
-
-struct JSContext;
+#include "js/TypeDecls.h"
 
 namespace mozilla {
 namespace dom {
 
 class PromiseResolver MOZ_FINAL : public nsWrapperCache
 {
   friend class PromiseResolverTask;
   friend class WrapperPromiseCallback;
--- a/dom/src/geolocation/nsGeoPosition.h
+++ b/dom/src/geolocation/nsGeoPosition.h
@@ -9,18 +9,17 @@
 #include "nsAutoPtr.h"
 #include "nsIDOMGeoPositionCoords.h"
 #include "nsIDOMGeoPosition.h"
 #include "nsString.h"
 #include "mozilla/Attributes.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 #include "mozilla/dom/Nullable.h"
-
-struct JSContext;
+#include "js/TypeDecls.h"
 
 ////////////////////////////////////////////////////
 // nsGeoPositionCoords
 ////////////////////////////////////////////////////
 
 /**
  * Simple object that holds a single point in space.
  */
--- a/embedding/components/windowwatcher/src/nsWindowWatcher.h
+++ b/embedding/components/windowwatcher/src/nsWindowWatcher.h
@@ -12,27 +12,26 @@
 
 #include "nsCOMPtr.h"
 #include "mozilla/Mutex.h"
 #include "nsIWindowCreator.h" // for stupid compilers
 #include "nsIWindowWatcher.h"
 #include "nsIPromptFactory.h"
 #include "nsPIWindowWatcher.h"
 #include "nsTArray.h"
+#include "js/TypeDecls.h"
 
 class  nsIURI;
 class  nsIDocShellTreeItem;
 class  nsIDocShellTreeOwner;
 class  nsIWebBrowserChrome;
 class  nsString;
 class  nsWatcherWindowEnumerator;
 class  nsIScriptContext;
 class  nsPromptService;
-struct JSContext;
-class JSObject;
 struct nsWatcherWindowEntry;
 struct SizeSpec;
 
 class nsWindowWatcher :
       public nsIWindowWatcher,
       public nsPIWindowWatcher,
       public nsIPromptFactory
 {
--- a/ipc/testshell/TestShellParent.h
+++ b/ipc/testshell/TestShellParent.h
@@ -6,22 +6,20 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef ipc_testshell_TestShellParent_h
 #define ipc_testshell_TestShellParent_h 1
 
 #include "mozilla/ipc/PTestShellParent.h"
 #include "mozilla/ipc/PTestShellCommandParent.h"
 
+#include "js/TypeDecls.h"
 #include "nsAutoJSValHolder.h"
 #include "nsStringGlue.h"
 
-struct JSContext;
-class JSObject;
-
 namespace mozilla {
 
 namespace ipc {
 
 class TestShellCommandParent;
 
 class TestShellParent : public PTestShellParent
 {
--- a/ipc/testshell/XPCShellEnvironment.h
+++ b/ipc/testshell/XPCShellEnvironment.h
@@ -11,19 +11,18 @@
 #include <stdio.h>
 
 #include "nsAutoJSValHolder.h"
 #include "nsCOMPtr.h"
 #include "nsDebug.h"
 #include "nsStringGlue.h"
 #include "nsJSPrincipals.h"
 #include "nsContentUtils.h"
+#include "js/TypeDecls.h"
 
-struct JSContext;
-class JSObject;
 struct JSPrincipals;
 
 namespace mozilla {
 namespace ipc {
 
 class XPCShellEnvironment
 {
 public:
--- a/js/public/Anchor.h
+++ b/js/public/Anchor.h
@@ -6,22 +6,17 @@
 
 /* JS::Anchor implementation. */
 
 #ifndef js_Anchor_h
 #define js_Anchor_h
 
 #include "mozilla/Attributes.h"
 
-class JSFunction;
-class JSObject;
-class JSScript;
-class JSString;
-
-namespace JS { class Value; }
+#include "js/TypeDecls.h"
 
 namespace JS {
 
 /*
  * Protecting non-Value, non-JSObject *, non-JSString * values from collection
  *
  * Most of the time, the garbage collector's conservative stack scanner works
  * behind the scenes, finding all live values and protecting them from being
--- a/js/public/CallArgs.h
+++ b/js/public/CallArgs.h
@@ -33,19 +33,16 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/TypeTraits.h"
 
 #include "jstypes.h"
 
 #include "js/RootingAPI.h"
 #include "js/Value.h"
 
-struct JSContext;
-class JSObject;
-
 /* Typedef for native functions called by the JS VM. */
 typedef bool
 (* JSNative)(JSContext *cx, unsigned argc, JS::Value *vp);
 
 /* Typedef for native functions that may be called in parallel. */
 typedef js::ParallelResult
 (* JSParallelNative)(js::ForkJoinSlice *slice, unsigned argc, JS::Value *vp);
 
--- a/js/public/Class.h
+++ b/js/public/Class.h
@@ -4,43 +4,31 @@
  * 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/. */
 
 /* JSClass definition and its component types, plus related interfaces. */
 
 #ifndef js_Class_h
 #define js_Class_h
 
-#include "jspubtd.h"
 #include "jstypes.h"
 
 #include "js/CallArgs.h"
 #include "js/Id.h"
+#include "js/TypeDecls.h"
 
 /*
  * A JSClass acts as a vtable for JS objects that allows JSAPI clients to
  * control various aspects of the behavior of an object like property lookup.
  * js::Class is an engine-private extension that allows more control over
  * object behavior and, e.g., allows custom slow layout.
  */
 
 class JSFreeOp;
 
-namespace JS {
-template <typename T> class Handle;
-template <typename T> class MutableHandle;
-class Value;
-
-typedef JS::Handle<JSObject*> HandleObject;
-typedef JS::Handle<jsid> HandleId;
-typedef JS::Handle<JS::Value> HandleValue;
-typedef JS::MutableHandle<JSObject*> MutableHandleObject;
-typedef JS::MutableHandle<JS::Value> MutableHandleValue;
-}
-
 namespace js {
 
 class Class;
 class FreeOp;
 class PropertyId;
 class PropertyName;
 class Shape;
 class SpecialId;
--- a/js/public/Id.h
+++ b/js/public/Id.h
@@ -2,24 +2,34 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * 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 js_Id_h
 #define js_Id_h
 
+// A jsid is an identifier for a property or method of an object which is
+// either a 31-bit signed integer, interned string or object.
+//
+// Also, there is an additional jsid value, JSID_VOID, which does not occur in
+// JS scripts but may be used to indicate the absence of a valid jsid.  A void
+// jsid is not a valid id and only arises as an exceptional API return value,
+// such as in JS_NextProperty. Embeddings must not pass JSID_VOID into JSAPI
+// entry points expecting a jsid and do not need to handle JSID_VOID in hooks
+// receiving a jsid except when explicitly noted in the API contract.
+//
+// A jsid is not implicitly convertible to or from a jsval; JS_ValueToId or
+// JS_IdToValue must be used instead.
+
 #include "jstypes.h"
 
-#include "js/IdForward.h"
+#include "js/TypeDecls.h"
 #include "js/Utility.h"
 
-class JSObject;
-class JSString;
-
 #ifdef JS_USE_JSID_STRUCT_TYPES
 struct jsid
 {
     size_t asBits;
     bool operator==(jsid rhs) const { return asBits == rhs.asBits; }
     bool operator!=(jsid rhs) const { return asBits != rhs.asBits; }
 };
 # define JSID_BITS(id) (id.asBits)
deleted file mode 100644
--- a/js/public/IdForward.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: set ts=8 sts=4 et sw=4 tw=99:
- * 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 js_IdForward_h
-#define js_IdForward_h
-
-#include <stddef.h>
-
-// A jsid is an identifier for a property or method of an object which is
-// either a 31-bit signed integer, interned string or object.
-//
-// Also, there is an additional jsid value, JSID_VOID, which does not occur in
-// JS scripts but may be used to indicate the absence of a valid jsid.  A void
-// jsid is not a valid id and only arises as an exceptional API return value,
-// such as in JS_NextProperty. Embeddings must not pass JSID_VOID into JSAPI
-// entry points expecting a jsid and do not need to handle JSID_VOID in hooks
-// receiving a jsid except when explicitly noted in the API contract.
-//
-// A jsid is not implicitly convertible to or from a jsval; JS_ValueToId or
-// JS_IdToValue must be used instead.
-//
-// In release builds, jsid is defined to be an integral type. This
-// prevents many bugs from being caught at compile time. E.g.:
-//
-//  jsid id = ...
-//  if (id)             // error
-//    ...
-//
-//  size_t n = id;      // error
-//
-// To catch more errors, jsid is given a struct type in C++ debug builds.
-// Struct assignment and (in C++) operator== allow correct code to be mostly
-// oblivious to the change. This feature can be explicitly disabled in debug
-// builds by defining JS_NO_JSVAL_JSID_STRUCT_TYPES.
-//
-// Note: if jsid was always a struct, we could just forward declare it in
-// places where its declaration is needed.  But the fact that it's a typedef in
-// non-debug builds prevents that.  So we have this file, which is morally
-// equivalent to a forward declaration, and should be included by any file that
-// uses jsid but doesn't need its definition.
-
-#if defined(DEBUG) && !defined(JS_NO_JSVAL_JSID_STRUCT_TYPES)
-# define JS_USE_JSID_STRUCT_TYPES
-#endif
-
-#ifdef JS_USE_JSID_STRUCT_TYPES
-struct jsid;
-#else
-typedef ptrdiff_t jsid;
-#endif
-
-#endif /* js_IdForward_h */
--- a/js/public/OldDebugAPI.h
+++ b/js/public/OldDebugAPI.h
@@ -9,17 +9,17 @@
 
 /*
  * JS debugger API.
  */
 
 #include "jsbytecode.h"
 
 #include "js/CallArgs.h"
-#include "js/IdForward.h"
+#include "js/TypeDecls.h"
 
 class JSAtom;
 class JSFreeOp;
 
 namespace js { class StackFrame; }
 
 namespace JS {
 
--- a/js/public/ProfilingStack.h
+++ b/js/public/ProfilingStack.h
@@ -8,17 +8,16 @@
 #define js_ProfilingStack_h
 
 #include "jsbytecode.h"
 #include "jstypes.h"
 
 #include "js/Utility.h"
 
 struct JSRuntime;
-class JSScript;
 
 namespace js {
 
 // A call stack can be specified to the JS engine such that all JS entry/exits
 // to functions push/pop an entry to/from the specified stack.
 //
 // For more detailed information, see vm/SPSProfiler.h.
 //
--- a/js/public/PropertyKey.h
+++ b/js/public/PropertyKey.h
@@ -4,20 +4,19 @@
  * 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/. */
 
 /* JS::PropertyKey implementation. */
 
 #ifndef js_PropertyKey_h
 #define js_PropertyKey_h
 
+#include "js/TypeDecls.h"
 #include "js/Value.h"
 
-struct JSContext;
-
 namespace JS {
 
 class PropertyKey;
 
 namespace detail {
 
 extern JS_PUBLIC_API(bool)
 ToPropertyKeySlow(JSContext *cx, HandleValue v, PropertyKey *key);
--- a/js/public/RootingAPI.h
+++ b/js/public/RootingAPI.h
@@ -7,17 +7,17 @@
 #ifndef js_RootingAPI_h
 #define js_RootingAPI_h
 
 #include "mozilla/GuardObjects.h"
 #include "mozilla/TypeTraits.h"
 
 #include "jspubtd.h"
 
-#include "js/IdForward.h"
+#include "js/TypeDecls.h"
 #include "js/Utility.h"
 
 /*
  * Moving GC Stack Rooting
  *
  * A moving GC may change the physical location of GC allocated things, even
  * when they are rooted, updating all pointers to the thing to refer to its new
  * location. The GC must therefore know about all live pointers to a thing,
@@ -93,17 +93,16 @@
  *     +---> MutableHandle<T>
  *     (via &)
  *
  * All of these types have an implicit conversion to raw pointers.
  */
 
 namespace js {
 
-class Module;
 class ScriptSourceObject;
 
 template <typename T>
 struct GCMethods {};
 
 template <typename T>
 class RootedBase {};
 
@@ -139,19 +138,16 @@ struct Cell;
 } /* namespace gc */
 
 } /* namespace js */
 
 namespace JS {
 
 template <typename T> class Rooted;
 
-template <typename T> class Handle;
-template <typename T> class MutableHandle;
-
 /* This is exposing internal state of the GC for inlining purposes. */
 JS_FRIEND_API(bool) isGCEnabled();
 
 #if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE)
 extern void
 CheckStackRoots(JSContext *cx);
 #endif
 
@@ -462,25 +458,16 @@ class MOZ_NONHEAP_CLASS Handle : public 
     Handle() {}
 
     const T *ptr;
 
     template <typename S>
     void operator=(S v) MOZ_DELETE;
 };
 
-typedef Handle<JSObject*>                   HandleObject;
-typedef Handle<js::Module*>                 HandleModule;
-typedef Handle<js::ScriptSourceObject *>    HandleScriptSource;
-typedef Handle<JSFunction*>                 HandleFunction;
-typedef Handle<JSScript*>                   HandleScript;
-typedef Handle<JSString*>                   HandleString;
-typedef Handle<jsid>                        HandleId;
-typedef Handle<Value>                       HandleValue;
-
 /*
  * Similar to a handle, but the underlying storage can be changed. This is
  * useful for outparams.
  *
  * If you want to add additional methods to MutableHandle for a specific
  * specialization, define a MutableHandleBase<T> specialization containing
  * them.
  */
@@ -522,23 +509,16 @@ class MOZ_STACK_CLASS MutableHandle : pu
     MutableHandle() {}
 
     T *ptr;
 
     template <typename S> void operator=(S v) MOZ_DELETE;
     void operator=(MutableHandle other) MOZ_DELETE;
 };
 
-typedef MutableHandle<JSObject*>   MutableHandleObject;
-typedef MutableHandle<JSFunction*> MutableHandleFunction;
-typedef MutableHandle<JSScript*>   MutableHandleScript;
-typedef MutableHandle<JSString*>   MutableHandleString;
-typedef MutableHandle<jsid>        MutableHandleId;
-typedef MutableHandle<Value>       MutableHandleValue;
-
 #ifdef JSGC_GENERATIONAL
 JS_PUBLIC_API(void) HeapCellPostBarrier(js::gc::Cell **cellp);
 JS_PUBLIC_API(void) HeapCellRelocate(js::gc::Cell **cellp);
 #endif
 
 } /* namespace JS */
 
 namespace js {
@@ -798,18 +778,16 @@ class MOZ_STACK_CLASS Rooted : public js
 
 #if !(defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING))
 // Defined in vm/String.h.
 template <>
 class Rooted<JSStableString *>;
 #endif
 
 typedef Rooted<JSObject*>                   RootedObject;
-typedef Rooted<js::Module*>                 RootedModule;
-typedef Rooted<js::ScriptSourceObject *>    RootedScriptSource;
 typedef Rooted<JSFunction*>                 RootedFunction;
 typedef Rooted<JSScript*>                   RootedScript;
 typedef Rooted<JSString*>                   RootedString;
 typedef Rooted<jsid>                        RootedId;
 typedef Rooted<JS::Value>                   RootedValue;
 
 } /* namespace JS */
 
--- a/js/public/StructuredClone.h
+++ b/js/public/StructuredClone.h
@@ -6,27 +6,22 @@
 
 #ifndef js_StructuredClone_h
 #define js_StructuredClone_h
 
 #include <stdint.h>
 
 #include "jstypes.h"
 
-struct JSContext;
-class JSObject;
+#include "js/TypeDecls.h"
+
 struct JSRuntime;
 struct JSStructuredCloneReader;
 struct JSStructuredCloneWriter;
 
-namespace JS {
-template <typename T> class Handle;
-class Value;
-}
-
 // API for the HTML5 internal structured cloning algorithm.
 
 // Read structured data from the reader r. This hook is used to read a value
 // previously serialized by a call to the WriteStructuredCloneOp hook.
 //
 // tag and data are the pair of uint32_t values from the header. The callback
 // may use the JS_Read* APIs to read any other relevant parts of the object
 // from the reader r. closure is any value passed to the JS_ReadStructuredClone
new file mode 100644
--- /dev/null
+++ b/js/public/TypeDecls.h
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ * vim: set ts=8 sts=4 et sw=4 tw=99:
+ * 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/. */
+
+// This file contains public type declarations that are used *frequently*.  If
+// it doesn't occur at least 10 times in Gecko, it probably shouldn't be in
+// here.
+//
+// It includes only:
+// - forward declarations of structs and classes;
+// - typedefs;
+// - enums (maybe).
+// It does *not* contain any struct or class definitions.
+
+#ifndef js_TypeDecls_h
+#define js_TypeDecls_h
+
+#include <stddef.h>
+#include <stdint.h>
+
+struct JSContext;
+class JSFunction;
+class JSObject;
+class JSScript;
+class JSString;
+
+// In release builds, jsid is defined to be an integral type. This
+// prevents many bugs from being caught at compile time. E.g.:
+//
+//  jsid id = ...
+//  if (id)             // error
+//    ...
+//
+//  size_t n = id;      // error
+//
+// To catch more errors, jsid is given a struct type in C++ debug builds.
+// Struct assignment and (in C++) operator== allow correct code to be mostly
+// oblivious to the change. This feature can be explicitly disabled in debug
+// builds by defining JS_NO_JSVAL_JSID_STRUCT_TYPES.
+//
+#if defined(DEBUG) && !defined(JS_NO_JSVAL_JSID_STRUCT_TYPES)
+# define JS_USE_JSID_STRUCT_TYPES
+#endif
+
+#ifdef JS_USE_JSID_STRUCT_TYPES
+struct jsid;
+#else
+typedef ptrdiff_t jsid;
+#endif
+
+#ifdef WIN32
+typedef wchar_t  jschar;
+#else
+typedef uint16_t jschar;
+#endif
+
+namespace JS {
+
+class Value;
+template <typename T> class Handle;
+template <typename T> class MutableHandle;
+
+typedef Handle<JSFunction*> HandleFunction;
+typedef Handle<jsid>        HandleId;
+typedef Handle<JSObject*>   HandleObject;
+typedef Handle<JSScript*>   HandleScript;
+typedef Handle<JSString*>   HandleString;
+typedef Handle<Value>       HandleValue;
+
+typedef MutableHandle<JSFunction*> MutableHandleFunction;
+typedef MutableHandle<jsid>        MutableHandleId;
+typedef MutableHandle<JSObject*>   MutableHandleObject;
+typedef MutableHandle<JSScript*>   MutableHandleScript;
+typedef MutableHandle<JSString*>   MutableHandleString;
+typedef MutableHandle<Value>       MutableHandleValue;
+
+} // namespace JS
+
+#endif /* js_TypeDecls_h */
--- a/js/src/TraceLogging.h
+++ b/js/src/TraceLogging.h
@@ -5,18 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef TraceLogging_h
 #define TraceLogging_h
 
 #include <stdint.h>
 #include <stdio.h>
 
-class JSScript;
-
 namespace JS {
 class CompileOptions;
 }
 
 namespace js {
 
 class TraceLogging
 {
--- a/js/src/builtin/Intl.h
+++ b/js/src/builtin/Intl.h
@@ -6,32 +6,28 @@
 
 #ifndef builtin_Intl_h
 #define builtin_Intl_h
 
 #include "jsapi.h"
 
 #include "js/RootingAPI.h"
 
-struct JSContext;
-class JSObject;
-
 /*
  * The Intl module specified by standard ECMA-402,
  * ECMAScript Internationalization API Specification.
  */
 
 /**
  * Initializes the Intl Object and its standard built-in properties.
  * Spec: ECMAScript Internationalization API Specification, 8.0, 8.1
  */
 extern JSObject *
 js_InitIntlClass(JSContext *cx, js::HandleObject obj);
 
-
 namespace js {
 
 /*
  * The following functions are for use by self-hosted code.
  */
 
 
 /******************** Collator ********************/
--- a/js/src/builtin/Module.cpp
+++ b/js/src/builtin/Module.cpp
@@ -5,16 +5,20 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "builtin/Module.h"
 
 #include "jsobjinlines.h"
 
 using namespace js;
 
+namespace js {
+typedef Rooted<Module*> RootedModule;
+}
+
 Class Module::class_ = {
     "Module",
     JSCLASS_HAS_RESERVED_SLOTS(2) | JSCLASS_IS_ANONYMOUS,
     JS_PropertyStub,        /* addProperty */
     JS_DeletePropertyStub,  /* delProperty */
     JS_PropertyStub,        /* getProperty */
     JS_StrictPropertyStub,  /* setProperty */
     JS_EnumerateStub,
--- a/js/src/frontend/BytecodeCompiler.cpp
+++ b/js/src/frontend/BytecodeCompiler.cpp
@@ -183,17 +183,17 @@ frontend::CompileScript(ExclusiveContext
         return NULL;
     JS_ASSERT_IF(staticLevel != 0, options.sourcePolicy != CompileOptions::LAZY_SOURCE);
     ScriptSource *ss = cx->new_<ScriptSource>(options.originPrincipals());
     if (!ss)
         return NULL;
     if (options.filename && !ss->setFilename(cx, options.filename))
         return NULL;
 
-    JS::RootedScriptSource sourceObject(cx, ScriptSourceObject::create(cx, ss));
+    RootedScriptSource sourceObject(cx, ScriptSourceObject::create(cx, ss));
     if (!sourceObject)
         return NULL;
 
     SourceCompressionTask mysct(cx);
     SourceCompressionTask *sct = extraSct ? extraSct : &mysct;
 
     switch (options.sourcePolicy) {
       case CompileOptions::SAVE_SOURCE:
@@ -411,17 +411,17 @@ frontend::CompileLazyFunction(JSContext 
                                                   lazy->generatorKind());
     if (!pn)
         return false;
 
     if (!NameFunctions(cx, pn))
         return false;
 
     RootedObject enclosingScope(cx, lazy->enclosingScope());
-    JS::RootedScriptSource sourceObject(cx, lazy->sourceObject());
+    RootedScriptSource sourceObject(cx, lazy->sourceObject());
     JS_ASSERT(sourceObject);
 
     Rooted<JSScript*> script(cx, JSScript::Create(cx, enclosingScope, false,
                                                   options, staticLevel,
                                                   sourceObject, lazy->begin(), lazy->end()));
     if (!script)
         return false;
 
@@ -463,17 +463,17 @@ CompileFunctionBody(JSContext *cx, Mutab
 
     if (!CheckLength(cx, length))
         return false;
     ScriptSource *ss = cx->new_<ScriptSource>(options.originPrincipals());
     if (!ss)
         return false;
     if (options.filename && !ss->setFilename(cx, options.filename))
         return false;
-    JS::RootedScriptSource sourceObject(cx, ScriptSourceObject::create(cx, ss));
+    RootedScriptSource sourceObject(cx, ScriptSourceObject::create(cx, ss));
     if (!sourceObject)
         return false;
     SourceCompressionTask sct(cx);
     JS_ASSERT(options.sourcePolicy != CompileOptions::LAZY_SOURCE);
     if (options.sourcePolicy == CompileOptions::SAVE_SOURCE) {
         if (!ss->setSourceCopy(cx, chars, length, true, &sct))
             return false;
     }
--- a/js/src/frontend/NameFunctions.h
+++ b/js/src/frontend/NameFunctions.h
@@ -2,17 +2,17 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * 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 frontend_NameFunctions_h
 #define frontend_NameFunctions_h
 
-struct JSContext;
+#include "js/TypeDecls.h"
 
 namespace js {
 namespace frontend {
 
 class ParseNode;
 
 bool
 NameFunctions(JSContext *cx, ParseNode *pn);
--- a/js/src/gc/Marking.h
+++ b/js/src/gc/Marking.h
@@ -4,23 +4,17 @@
  * 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 gc_Marking_h
 #define gc_Marking_h
 
 #include "gc/Barrier.h"
 #include "jit/IonCode.h"
-
-extern "C" {
-struct JSContext;
-class JSFunction;
-class JSObject;
-class JSScript;
-}
+#include "js/TypeDecls.h"
 
 class JSAtom;
 class JSLinearString;
 
 namespace js {
 
 class ArgumentsObject;
 class ArrayBufferObject;
--- a/js/src/gc/Rooting.h
+++ b/js/src/gc/Rooting.h
@@ -19,20 +19,22 @@ class Shape;
 namespace types { struct TypeObject; }
 
 // These are internal counterparts to the public types such as HandleObject.
 
 typedef JS::Handle<Shape*>             HandleShape;
 typedef JS::Handle<types::TypeObject*> HandleTypeObject;
 typedef JS::Handle<JSAtom*>            HandleAtom;
 typedef JS::Handle<PropertyName*>      HandlePropertyName;
+typedef JS::Handle<js::ScriptSourceObject*> HandleScriptSource;
 
 typedef JS::MutableHandle<Shape*>      MutableHandleShape;
 typedef JS::MutableHandle<JSAtom*>     MutableHandleAtom;
 
 typedef JS::Rooted<Shape*>             RootedShape;
 typedef JS::Rooted<types::TypeObject*> RootedTypeObject;
 typedef JS::Rooted<JSAtom*>            RootedAtom;
 typedef JS::Rooted<PropertyName*>      RootedPropertyName;
+typedef Rooted<js::ScriptSourceObject*> RootedScriptSource;
 
 } /* namespace js */
 
 #endif /* gc_Rooting_h */
--- a/js/src/jit/IonCaches.h
+++ b/js/src/jit/IonCaches.h
@@ -9,19 +9,16 @@
 
 #ifdef JS_CPU_ARM
 # include "jit/arm/Assembler-arm.h"
 #endif
 #include "jit/IonCode.h"
 #include "jit/Registers.h"
 #include "jit/shared/Assembler-shared.h"
 
-class JSFunction;
-class JSScript;
-
 namespace js {
 
 class LockedJSContext;
 class TypedArrayObject;
 
 namespace jit {
 
 #define IONCACHE_KIND_LIST(_)                                   \
--- a/js/src/jit/IonCode.h
+++ b/js/src/jit/IonCode.h
@@ -14,18 +14,16 @@
 
 #include "gc/Heap.h"
 #include "jit/IonTypes.h"
 
 namespace JSC {
     class ExecutablePool;
 }
 
-class JSScript;
-
 namespace js {
 
 class AsmJSModule;
 
 namespace jit {
 
 // The maximum size of any buffer associated with an assembler or code object.
 // This is chosen to not overflow a signed integer, leaving room for an extra
--- a/js/src/jit/IonFrames.h
+++ b/js/src/jit/IonFrames.h
@@ -15,19 +15,16 @@
 #include "jsfun.h"
 #include "jstypes.h"
 #include "jsutil.h"
 
 #include "jit/IonCode.h"
 #include "jit/IonFrameIterator.h"
 #include "jit/Registers.h"
 
-class JSFunction;
-class JSScript;
-
 namespace js {
 namespace jit {
 
 typedef void * CalleeToken;
 
 enum CalleeTokenTag
 {
     CalleeToken_Function = 0x0, // untagged
--- a/js/src/jit/JSONSpewer.h
+++ b/js/src/jit/JSONSpewer.h
@@ -4,17 +4,17 @@
  * 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 jit_JSONSpewer_h
 #define jit_JSONSpewer_h
 
 #include <stdio.h>
 
-class JSScript;
+#include "js/TypeDecls.h"
 
 namespace js {
 namespace jit {
 
 class MDefinition;
 class MInstruction;
 class MBasicBlock;
 class MIRGraph;
--- a/js/src/jit/PerfSpewer.h
+++ b/js/src/jit/PerfSpewer.h
@@ -6,18 +6,16 @@
 
 #ifndef jit_PerfSpewer_h
 #define jit_PerfSpewer_h
 
 #include <stdio.h>
 
 #include "jit/IonMacroAssembler.h"
 
-class JSScript;
-
 namespace js {
 namespace jit {
 
 class MBasicBlock;
 class MacroAssembler;
 
 #ifdef JS_ION_PERF
 void CheckPerf();
--- a/js/src/jsalloc.h
+++ b/js/src/jsalloc.h
@@ -4,20 +4,19 @@
  * 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/. */
 
 /* JS allocation policies. */
 
 #ifndef jsalloc_h
 #define jsalloc_h
 
+#include "js/TypeDecls.h"
 #include "js/Utility.h"
 
-struct JSContext;
-
 namespace js {
 
 class ContextFriendFields;
 
 /* Policy for using system memory functions and doing no error reporting. */
 class SystemAllocPolicy
 {
   public:
--- a/js/src/jsanalyze.h
+++ b/js/src/jsanalyze.h
@@ -6,18 +6,16 @@
 
 /* Definitions for javascript analysis. */
 
 #ifndef jsanalyze_h
 #define jsanalyze_h
 
 #include "jscompartment.h"
 
-class JSScript;
-
 namespace js {
 namespace analyze {
 
 class LoopAnalysis;
 class SlotValue;
 class SSAValue;
 class SSAUseChain;
 
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -4632,26 +4632,24 @@ using JS::CallArgs;
 using JS::IsAcceptableThis;
 using JS::NativeImpl;
 using JS::CallReceiver;
 using JS::CompileOptions;
 using JS::CallNonGenericMethod;
 
 using JS::Rooted;
 using JS::RootedObject;
-using JS::RootedModule;
 using JS::RootedFunction;
 using JS::RootedScript;
 using JS::RootedString;
 using JS::RootedId;
 using JS::RootedValue;
 
 using JS::Handle;
 using JS::HandleObject;
-using JS::HandleModule;
 using JS::HandleFunction;
 using JS::HandleScript;
 using JS::HandleString;
 using JS::HandleId;
 using JS::HandleValue;
 
 using JS::MutableHandle;
 using JS::MutableHandleObject;
--- a/js/src/jsdate.h
+++ b/js/src/jsdate.h
@@ -9,25 +9,17 @@
  */
 
 #ifndef jsdate_h
 #define jsdate_h
 
 #include "jstypes.h"
 
 #include "js/RootingAPI.h"
-
-extern "C" {
-class JSObject;
-struct JSContext;
-}
-
-namespace JS {
-class Value;
-}
+#include "js/TypeDecls.h"
 
 extern JSObject *
 js_InitDateClass(JSContext *cx, JS::HandleObject obj);
 
 /*
  * These functions provide a C interface to the date/time object
  */
 
--- a/js/src/jsgc.h
+++ b/js/src/jsgc.h
@@ -16,17 +16,16 @@
 #include "jslock.h"
 #include "jsobj.h"
 
 #include "js/GCAPI.h"
 #include "js/Vector.h"
 
 class JSAtom;
 struct JSCompartment;
-class JSFunction;
 class JSFlatString;
 class JSLinearString;
 
 namespace js {
 
 class ArgumentsObject;
 class ArrayBufferObject;
 class ArrayBufferViewObject;
--- a/js/src/jsinfer.h
+++ b/js/src/jsinfer.h
@@ -13,18 +13,16 @@
 
 #include "jsfriendapi.h"
 
 #include "ds/IdValuePair.h"
 #include "ds/LifoAlloc.h"
 #include "gc/Barrier.h"
 #include "js/Utility.h"
 
-class JSScript;
-
 namespace js {
 
 class TypeRepresentation;
 
 class TaggedProto
 {
   public:
     TaggedProto() : proto(NULL) {}
--- a/js/src/jsnum.h
+++ b/js/src/jsnum.h
@@ -37,18 +37,16 @@ js_InitNumberClass(JSContext *cx, js::Ha
 /*
  * String constants for global function names, used in jsapi.c and jsnum.c.
  */
 extern const char js_isNaN_str[];
 extern const char js_isFinite_str[];
 extern const char js_parseFloat_str[];
 extern const char js_parseInt_str[];
 
-class JSString;
-
 /*
  * When base == 10, this function implements ToString() as specified by
  * ECMA-262-5 section 9.8.1; but note that it handles integers specially for
  * performance.  See also js::NumberToCString().
  */
 template <js::AllowGC allowGC>
 extern JSString *
 js_NumberToString(js::ThreadSafeContext *cx, double d);
--- a/js/src/jspubtd.h
+++ b/js/src/jspubtd.h
@@ -10,53 +10,40 @@
 /*
  * JS public API typedefs.
  */
 
 #include "mozilla/PodOperations.h"
 
 #include "jsprototypes.h"
 #include "jstypes.h"
-#include "jsversion.h"  // #include here so it's seen everywhere
 
-#include "js/IdForward.h"
+#include "js/TypeDecls.h"
 
 #if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING) || defined(DEBUG)
 # define JSGC_TRACK_EXACT_ROOTS
 #endif
 
 namespace JS {
 
-/*
- * Allow headers to reference JS::Value without #including the whole jsapi.h.
- * Unfortunately, typedefs (hence jsval) cannot be declared.
- */
-class Value;
-
 class AutoIdVector;
 class CallArgs;
 
 template <typename T>
 class Rooted;
 
 class JS_PUBLIC_API(AutoGCRooter);
 
 class JS_PUBLIC_API(CompileOptions);
 class JS_PUBLIC_API(CompartmentOptions);
 
 struct Zone;
 
 } /* namespace JS */
 
-#ifdef WIN32
-typedef wchar_t   jschar;
-#else
-typedef uint16_t  jschar;
-#endif
-
 /*
  * Run-time version enumeration.  For compile-time version checking, please use
  * the JS_HAS_* macros in jsversion.h, or use MOZJS_MAJOR_VERSION,
  * MOZJS_MINOR_VERSION, MOZJS_PATCH_VERSION, and MOZJS_ALPHA definitions.
  */
 typedef enum JSVersion {
     JSVERSION_ECMA_3  = 148,
     JSVERSION_1_6     = 160,
@@ -145,17 +132,16 @@ typedef enum {
     JSTRACE_TYPE_OBJECT,
     JSTRACE_LAST = JSTRACE_TYPE_OBJECT
 } JSGCTraceKind;
 
 /* Struct typedefs and class forward declarations. */
 typedef struct JSClass                      JSClass;
 typedef struct JSCompartment                JSCompartment;
 typedef struct JSConstDoubleSpec            JSConstDoubleSpec;
-typedef struct JSContext                    JSContext;
 typedef struct JSCrossCompartmentCall       JSCrossCompartmentCall;
 typedef struct JSErrorReport                JSErrorReport;
 typedef struct JSExceptionState             JSExceptionState;
 typedef struct JSFunctionSpec               JSFunctionSpec;
 typedef struct JSIdArray                    JSIdArray;
 typedef struct JSLocaleCallbacks            JSLocaleCallbacks;
 typedef struct JSObjectMap                  JSObjectMap;
 typedef struct JSPrincipals                 JSPrincipals;
@@ -165,21 +151,17 @@ typedef struct JSPropertySpec           
 typedef struct JSRuntime                    JSRuntime;
 typedef struct JSSecurityCallbacks          JSSecurityCallbacks;
 typedef struct JSStructuredCloneCallbacks   JSStructuredCloneCallbacks;
 typedef struct JSStructuredCloneReader      JSStructuredCloneReader;
 typedef struct JSStructuredCloneWriter      JSStructuredCloneWriter;
 typedef struct JSTracer                     JSTracer;
 
 class                                       JSFlatString;
-class                                       JSFunction;
-class                                       JSObject;
-class                                       JSScript;
 class                                       JSStableString;  // long story
-class                                       JSString;
 
 #ifdef JS_THREADSAFE
 typedef struct PRCallOnceType   JSCallOnceType;
 #else
 typedef bool                    JSCallOnceType;
 #endif
 typedef bool                    (*JSInitCallback)(void);
 
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -541,17 +541,17 @@ js::XDRScript(XDRState<mode> *xdr, Handl
         JSVersion version_ = JSVersion(version & JS_BITMASK(16));
         JS_ASSERT((version_ & VersionFlags::MASK) == unsigned(version_));
 
         // staticLevel is set below.
         CompileOptions options(cx);
         options.setVersion(version_)
                .setNoScriptRval(!!(scriptBits & (1 << NoScriptRval)))
                .setSelfHostingMode(!!(scriptBits & (1 << SelfHosted)));
-        JS::RootedScriptSource sourceObject(cx);
+        RootedScriptSource sourceObject(cx);
         if (scriptBits & (1 << OwnSource)) {
             ScriptSource *ss = cx->new_<ScriptSource>(xdr->originPrincipals());
             if (!ss)
                 return false;
             sourceObject = ScriptSourceObject::create(cx, ss);
             if (!sourceObject)
                 return false;
         } else {
@@ -957,17 +957,17 @@ Class ScriptSourceObject::class_ = {
 };
 
 ScriptSourceObject *
 ScriptSourceObject::create(ExclusiveContext *cx, ScriptSource *source)
 {
     RootedObject object(cx, NewObjectWithGivenProto(cx, &class_, NULL, cx->global()));
     if (!object)
         return NULL;
-    JS::RootedScriptSource sourceObject(cx, &object->as<ScriptSourceObject>());
+    RootedScriptSource sourceObject(cx, &object->as<ScriptSourceObject>());
     sourceObject->setSlot(SOURCE_SLOT, PrivateValue(source));
     source->incref();
     return sourceObject;
 }
 
 static const unsigned char emptySource[] = "";
 
 /* Adjust the amount of memory this script source uses for source data,
@@ -1605,17 +1605,17 @@ void
 JSScript::initCompartment(ExclusiveContext *cx)
 {
     compartment_ = cx->compartment_;
 }
 
 JSScript *
 JSScript::Create(ExclusiveContext *cx, HandleObject enclosingScope, bool savedCallerFun,
                  const CompileOptions &options, unsigned staticLevel,
-                 JS::HandleScriptSource sourceObject, uint32_t bufStart, uint32_t bufEnd)
+                 HandleScriptSource sourceObject, uint32_t bufStart, uint32_t bufEnd)
 {
     JS_ASSERT(bufStart <= bufEnd);
 
     RootedScript script(cx, js_NewGCScript(cx));
     if (!script)
         return NULL;
 
     PodZero(script.get());
@@ -2286,17 +2286,17 @@ js::CloneScript(JSContext *cx, HandleObj
     options.setPrincipals(cx->compartment()->principals)
            .setOriginPrincipals(src->originPrincipals())
            .setCompileAndGo(src->compileAndGo)
            .setSelfHostingMode(src->selfHosted)
            .setNoScriptRval(src->noScriptRval)
            .setVersion(src->getVersion());
 
     /* Make sure we clone the script source object with the script */
-    JS::RootedScriptSource sourceObject(cx, ScriptSourceObject::create(cx, src->scriptSource()));
+    RootedScriptSource sourceObject(cx, ScriptSourceObject::create(cx, src->scriptSource()));
     if (!sourceObject)
         return NULL;
 
     RootedScript dst(cx, JSScript::Create(cx, enclosingScope, src->savedCallerFun,
                                           options, src->staticLevel,
                                           sourceObject, src->sourceStart, src->sourceEnd));
     if (!dst) {
         js_free(data);
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -15,16 +15,17 @@
 #include "jsatom.h"
 #ifdef JS_THREADSAFE
 #include "jslock.h"
 #endif
 #include "jsobj.h"
 #include "jsopcode.h"
 
 #include "gc/Barrier.h"
+#include "gc/Rooting.h"
 #include "vm/Shape.h"
 
 namespace js {
 
 namespace jit {
     struct IonScript;
     struct BaselineScript;
     struct IonScriptCounts;
@@ -625,17 +626,17 @@ class JSScript : public js::gc::Cell
     //
     // End of fields.  Start methods.
     //
 
   public:
     static JSScript *Create(js::ExclusiveContext *cx,
                             js::HandleObject enclosingScope, bool savedCallerFun,
                             const JS::CompileOptions &options, unsigned staticLevel,
-                            JS::HandleScriptSource sourceObject, uint32_t sourceStart,
+                            js::HandleScriptSource sourceObject, uint32_t sourceStart,
                             uint32_t sourceEnd);
 
     void initCompartment(js::ExclusiveContext *cx);
 
     // Three ways ways to initialize a JSScript. Callers of partiallyInit()
     // and fullyInitTrivial() are responsible for notifying the debugger after
     // successfully creating any kind (function or other) of new JSScript.
     // However, callers of fullyInitFromEmitter() do not need to do this.
--- a/js/src/jsutil.h
+++ b/js/src/jsutil.h
@@ -15,19 +15,16 @@
 #include "mozilla/GuardObjects.h"
 
 #ifdef USE_ZLIB
 #include <zlib.h>
 #endif
 
 #include "js/Utility.h"
 
-/* Forward declarations. */
-struct JSContext;
-
 static JS_ALWAYS_INLINE void *
 js_memcpy(void *dst_, const void *src_, size_t len)
 {
     char *dst = (char *) dst_;
     const char *src = (const char *) src_;
     JS_ASSERT_IF(dst >= src, (size_t) (dst - src) >= len);
     JS_ASSERT_IF(src >= dst, (size_t) (src - dst) >= len);
 
--- a/js/src/moz.build
+++ b/js/src/moz.build
@@ -63,25 +63,25 @@ EXPORTS.js += [
     '../public/CallNonGenericMethod.h',
     '../public/CharacterEncoding.h',
     '../public/Class.h',
     '../public/Date.h',
     '../public/GCAPI.h',
     '../public/HashTable.h',
     '../public/HeapAPI.h',
     '../public/Id.h',
-    '../public/IdForward.h',
     '../public/LegacyIntTypes.h',
     '../public/MemoryMetrics.h',
     '../public/OldDebugAPI.h',
     '../public/ProfilingStack.h',
     '../public/PropertyKey.h',
     '../public/RequiredDefines.h',
     '../public/RootingAPI.h',
     '../public/StructuredClone.h',
+    '../public/TypeDecls.h',
     '../public/Utility.h',
     '../public/Value.h',
     '../public/Vector.h',
 ]
 
 CPP_SOURCES += [
     'ArgumentsObject.cpp',
     'BinaryData.cpp',
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -2854,17 +2854,17 @@ DebuggerScript_getLineCount(JSContext *c
 }
 
 static bool
 DebuggerScript_getSource(JSContext *cx, unsigned argc, Value *vp)
 {
     THIS_DEBUGSCRIPT_SCRIPT(cx, argc, vp, "(get source)", args, obj, script);
     Debugger *dbg = Debugger::fromChildJSObject(obj);
 
-    JS::RootedScriptSource source(cx, script->sourceObject());
+    RootedScriptSource source(cx, script->sourceObject());
     RootedObject sourceObject(cx, dbg->wrapSource(cx, source));
     if (!sourceObject)
         return false;
 
     args.rval().setObject(*sourceObject);
     return true;
 }
 
@@ -3619,33 +3619,33 @@ Class DebuggerSource_class = {
     NULL,                 /* checkAccess */
     NULL,                 /* call        */
     NULL,                 /* hasInstance */
     NULL,                 /* construct   */
     DebuggerSource_trace
 };
 
 JSObject *
-Debugger::newDebuggerSource(JSContext *cx, JS::HandleScriptSource source)
+Debugger::newDebuggerSource(JSContext *cx, HandleScriptSource source)
 {
     assertSameCompartment(cx, object.get());
 
     JSObject *proto = &object->getReservedSlot(JSSLOT_DEBUG_SOURCE_PROTO).toObject();
     JS_ASSERT(proto);
     JSObject *sourceobj = NewObjectWithGivenProto(cx, &DebuggerSource_class, proto, NULL);
     if (!sourceobj)
         return NULL;
     sourceobj->setReservedSlot(JSSLOT_DEBUGSOURCE_OWNER, ObjectValue(*object));
     sourceobj->setPrivateGCThing(source);
 
     return sourceobj;
 }
 
 JSObject *
-Debugger::wrapSource(JSContext *cx, JS::HandleScriptSource source)
+Debugger::wrapSource(JSContext *cx, HandleScriptSource source)
 {
     assertSameCompartment(cx, object.get());
     JS_ASSERT(cx->compartment() != source->compartment());
     SourceWeakMap::AddPtr p = sources.lookupForAdd(source);
     if (!p) {
         JSObject *sourceobj = newDebuggerSource(cx, source);
         if (!sourceobj)
             return NULL;
@@ -3699,17 +3699,17 @@ DebuggerSource_checkThis(JSContext *cx, 
     return thisobj;
 }
 
 #define THIS_DEBUGSOURCE_REFERENT(cx, argc, vp, fnname, args, obj, sourceObject)    \
     CallArgs args = CallArgsFromVp(argc, vp);                                       \
     RootedObject obj(cx, DebuggerSource_checkThis(cx, args, fnname));               \
     if (!obj)                                                                       \
         return false;                                                               \
-    JS::RootedScriptSource sourceObject(cx, GetSourceReferent(obj));                \
+    RootedScriptSource sourceObject(cx, GetSourceReferent(obj));                    \
     if (!sourceObject)                                                              \
         return false;
 
 static bool
 DebuggerSource_getText(JSContext *cx, unsigned argc, Value *vp)
 {
     THIS_DEBUGSOURCE_REFERENT(cx, argc, vp, "(get text)", args, obj, sourceObject);
 
--- a/js/src/vm/Debugger.h
+++ b/js/src/vm/Debugger.h
@@ -360,17 +360,17 @@ class Debugger : private mozilla::Linked
      * |script|.
      */
     JSObject *newDebuggerScript(JSContext *cx, HandleScript script);
 
     /*
      * Allocate and initialize a Debugger.Source instance whose referent is
      * |source|.
      */
-    JSObject *newDebuggerSource(JSContext *cx, JS::HandleScriptSource source);
+    JSObject *newDebuggerSource(JSContext *cx, js::HandleScriptSource source);
 
     /*
      * Receive a "new script" event from the engine. A new script was compiled
      * or deserialized.
      */
     void fireNewScript(JSContext *cx, HandleScript script);
 
     inline Breakpoint *firstBreakpoint() const;
@@ -523,17 +523,17 @@ class Debugger : private mozilla::Linked
      */
     JSObject *wrapScript(JSContext *cx, HandleScript script);
 
     /*
      * Return the Debugger.Source object for |source|, or create a new one if
      * needed. The context |cx| must be in the debugger compartment; |source|
      * must be a script source object in a debuggee compartment.
      */
-    JSObject *wrapSource(JSContext *cx, JS::HandleScriptSource source);
+    JSObject *wrapSource(JSContext *cx, js::HandleScriptSource source);
 
   private:
     Debugger(const Debugger &) MOZ_DELETE;
     Debugger & operator=(const Debugger &) MOZ_DELETE;
 };
 
 class BreakpointSite {
     friend class Breakpoint;
--- a/js/src/vm/GlobalObject.cpp
+++ b/js/src/vm/GlobalObject.cpp
@@ -227,17 +227,17 @@ GlobalObject::initFunctionAndObjectClass
         jschar *source = InflateString(cx, rawSource, &sourceLen);
         if (!source)
             return NULL;
         ScriptSource *ss = cx->new_<ScriptSource>(/* originPrincipals = */ (JSPrincipals*) NULL);
         if (!ss) {
             js_free(source);
             return NULL;
         }
-        JS::RootedScriptSource sourceObject(cx, ScriptSourceObject::create(cx, ss));
+        RootedScriptSource sourceObject(cx, ScriptSourceObject::create(cx, ss));
         if (!sourceObject)
             return NULL;
         ss->setSource(source, sourceLen);
 
         CompileOptions options(cx);
         options.setNoScriptRval(true)
                .setVersion(JSVERSION_DEFAULT);
 
--- a/js/src/vm/SPSProfiler.h
+++ b/js/src/vm/SPSProfiler.h
@@ -98,18 +98,16 @@
  * As an invariant, if the pc is NULL, then the JIT is currently executing
  * generated code. Otherwise execution is in another JS function or in C++. With
  * this in place, only the top entry of the stack can ever have NULL as its pc.
  * Additionally with this invariant, it is possible to maintain mappings of JIT
  * code to pc which can be accessed safely because they will only be accessed
  * from a signal handler when the JIT code is executing.
  */
 
-class JSFunction;
-
 namespace js {
 
 class ProfileEntry;
 
 typedef HashMap<JSScript*, const char*, DefaultHasher<JSScript*>, SystemAllocPolicy>
         ProfileStringMap;
 
 class SPSEntryMarker;
--- a/js/src/vm/Shape.h
+++ b/js/src/vm/Shape.h
@@ -88,18 +88,16 @@
  * trees are more space-efficient than alternatives.  This was removed in bug
  * 631138; see that bug for the full details.
  *
  * Because many Shapes have similar data, there is actually a secondary type
  * called a BaseShape that holds some of a Shape's data.  Many shapes can share
  * a single BaseShape.
  */
 
-class JSObject;
-
 namespace js {
 
 class Bindings;
 class Nursery;
 class StaticBlockObject;
 
 /* Limit on the number of slotful properties in an object. */
 static const uint32_t SHAPE_INVALID_SLOT = JS_BIT(24) - 1;
--- a/js/src/vm/Stack.h
+++ b/js/src/vm/Stack.h
@@ -13,17 +13,16 @@
 #include "jsscript.h"
 
 #include "jit/IonFrameIterator.h"
 #ifdef CHECK_OSIPOINT_REGISTERS
 #include "jit/Registers.h" // for RegisterDump
 #endif
 #include "js/OldDebugAPI.h"
 
-struct JSContext;
 struct JSCompartment;
 struct JSGenerator;
 
 namespace js {
 
 class StackFrame;
 class FrameRegs;
 
--- a/js/src/vm/String.h
+++ b/js/src/vm/String.h
@@ -20,17 +20,16 @@
 #include "js/CharacterEncoding.h"
 #include "js/RootingAPI.h"
 
 class JSDependentString;
 class JSExtensibleString;
 class JSExternalString;
 class JSInlineString;
 class JSStableString;
-class JSString;
 class JSRope;
 
 namespace js {
 
 class StaticStrings;
 class PropertyName;
 
 /* The buffer length required to contain any unsigned 32-bit integer. */
--- a/js/src/vm/ThreadPool.h
+++ b/js/src/vm/ThreadPool.h
@@ -15,20 +15,18 @@
 #ifdef JS_THREADSAFE
 # include "prcvar.h"
 # include "prlock.h"
 # include "prtypes.h"
 #endif
 
 #include "js/Vector.h"
 
-struct JSContext;
 struct JSRuntime;
 struct JSCompartment;
-class JSScript;
 
 namespace js {
 
 class ThreadPoolWorker;
 
 typedef void (*TaskFun)(void *userdata, uint32_t workerId, uintptr_t stackLimit);
 
 class TaskExecutor
--- a/js/xpconnect/idl/nsIXPConnect.idl
+++ b/js/xpconnect/idl/nsIXPConnect.idl
@@ -15,26 +15,22 @@
 #include "nsIInterfaceInfoManager.idl"
 #include "nsIExceptionService.idl"
 #include "nsIVariant.idl"
 #include "nsIObjectOutputStream.idl"
 #include "nsIObjectInputStream.idl"
 
 %{ C++
 #include "jspubtd.h"
+#include "js/TypeDecls.h"
 #include "xptinfo.h"
 #include "nsAXPCNativeCallContext.h"
 
 struct JSFreeOp;
 
-namespace JS {
-template <typename T> class Handle;
-template <typename T> class MutableHandle;
-}
-
 class nsWrapperCache;
 %}
 
 /***************************************************************************/
 
 // NB: jsval and jsid are declared in nsrootidl.idl
 
 [ptr] native JSContextPtr(JSContext);
--- a/js/xpconnect/idl/xpcIJSModuleLoader.idl
+++ b/js/xpconnect/idl/xpcIJSModuleLoader.idl
@@ -3,17 +3,17 @@
  * 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 "nsISupports.idl"
 
 [ptr] native nsAXPCNativeCallContextPtr(nsAXPCNativeCallContext);
 
 %{C++
-class JSObject;
+#include "js/TypeDecls.h"
 %}
 
 [ptr] native JSObjectPtr(JSObject);
 
 [scriptable, uuid(243d1a31-db9f-47a1-9922-55a1ad5515fb)]
 interface xpcIJSModuleLoader : nsISupports
 {
   /**
--- a/js/xpconnect/idl/xpcexception.idl
+++ b/js/xpconnect/idl/xpcexception.idl
@@ -3,20 +3,17 @@
  * 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 "nsISupports.idl"
 #include "nsIException.idl"
 
 %{ C++
-struct JSContext;
-namespace JS {
-class Value;
-}
+#include "js/TypeDecls.h"
 %}
 
 [ptr] native xpcexJSContextPtr(JSContext);
       native xpcexJSVal(JS::Value);
 
 [scriptable, uuid(cac29630-7bf2-4e22-811b-46855a7d5af0)]
 interface nsIXPCException : nsIException
 {
--- a/netwerk/base/src/ProxyAutoConfig.h
+++ b/netwerk/base/src/ProxyAutoConfig.h
@@ -7,20 +7,17 @@
 #ifndef ProxyAutoConfig_h__
 #define ProxyAutoConfig_h__
 
 #include "nsString.h"
 #include "prio.h"
 #include "nsITimer.h"
 #include "nsAutoPtr.h"
 #include "mozilla/net/DNS.h"
-
-namespace JS {
-class Value;
-}
+#include "js/TypeDecls.h"
 
 namespace mozilla { namespace net {
 
 class JSRuntimeWrapper;
 
 // The ProxyAutoConfig class is meant to be created and run on a
 // non main thread. It synchronously resolves PAC files by blocking that
 // thread and running nested event loops. GetProxyForURI is not re-entrant.
--- a/storage/src/mozStoragePrivateHelpers.h
+++ b/storage/src/mozStoragePrivateHelpers.h
@@ -10,26 +10,23 @@
 /**
  * This file contains convenience methods for mozStorage.
  */
 
 #include "sqlite3.h"
 #include "nsIVariant.h"
 #include "nsError.h"
 #include "nsAutoPtr.h"
+#include "js/TypeDecls.h"
 
 class mozIStorageCompletionCallback;
 class mozIStorageBaseStatement;
 class mozIStorageBindingParams;
 class nsIRunnable;
 
-namespace JS {
-class Value;
-}
-
 namespace mozilla {
 namespace storage {
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Macros
 
 #define ENSURE_INDEX_VALUE(aIndex, aCount) \
   NS_ENSURE_TRUE(aIndex < aCount, NS_ERROR_INVALID_ARG)
--- a/tools/profiler/GeckoProfiler.h
+++ b/tools/profiler/GeckoProfiler.h
@@ -45,28 +45,26 @@
  * 't' - Elapse time since recording started.
  *
  */
 
 #ifndef SAMPLER_H
 #define SAMPLER_H
 
 #include "mozilla/NullPtr.h"
+#include "js/TypeDecls.h"
 
 namespace mozilla {
 class TimeStamp;
 }
 
 #ifndef MOZ_ENABLE_PROFILER_SPS
 
 #include <stdint.h>
 
-struct JSContext;
-class JSObject;
-
 // Insert a RAII in this scope to active a pseudo label. Any samples collected
 // in this scope will contain this annotation. For dynamic strings use
 // PROFILER_LABEL_PRINTF. Arguments must be string literals.
 #define PROFILER_LABEL(name_space, info) do {} while (0)
 
 // Format a dynamic string as a pseudo label. These labels will a considerable
 // storage size in the circular buffer compared to regular labels. This function
 // can be used to annotate custom information such as URL for the resource being
--- a/tools/profiler/GeckoProfilerFunc.h
+++ b/tools/profiler/GeckoProfilerFunc.h
@@ -2,29 +2,27 @@
 /* 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 PROFILER_FUNCS_H
 #define PROFILER_FUNCS_H
 
 #include "mozilla/NullPtr.h"
+#include "js/TypeDecls.h"
 #include <stdint.h>
 
 namespace mozilla {
 class TimeDuration;
 class TimeStamp;
 }
 
 using mozilla::TimeStamp;
 using mozilla::TimeDuration;
 
-struct JSContext;
-class JSObject;
-
 // Returns a handle to pass on exit. This can check that we are popping the
 // correct callstack.
 inline void* mozilla_sampler_call_enter(const char *aInfo, void *aFrameAddress = NULL,
                                         bool aCopy = false, uint32_t line = 0);
 inline void  mozilla_sampler_call_exit(void* handle);
 inline void  mozilla_sampler_add_marker(const char *aInfo);
 
 void mozilla_sampler_start(int aEntries, double aInterval,
--- a/tools/profiler/JSObjectBuilder.h
+++ b/tools/profiler/JSObjectBuilder.h
@@ -2,21 +2,20 @@
 /* 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 JSOBJECTBUILDER_H
 #define JSOBJECTBUILDER_H
 
 #include "JSAObjectBuilder.h"
+#include "js/TypeDecls.h"
 
 class JSCustomObject;
 class JSCustomObjectBuilder;
-struct JSContext;
-class JSObject;
 class nsAString;
 
 /* this is handy wrapper around JSAPI to make it more pleasant to use.
  * We collect the JSAPI errors and so that callers don't need to */
 class JSObjectBuilder : public JSAObjectBuilder
 {
 public:
   // We need to ensure that this object lives on the stack so that GC sees it properly
--- a/xpcom/build/nsXULAppAPI.h
+++ b/xpcom/build/nsXULAppAPI.h
@@ -7,16 +7,17 @@
 #define _nsXULAppAPI_h__
 
 #include "nsID.h"
 #include "xrecore.h"
 #include "nsXPCOM.h"
 #include "nsISupports.h"
 #include "prlog.h"
 #include "nsXREAppData.h"
+#include "js/TypeDecls.h"
 
 #include "mozilla/Assertions.h"
 
 /**
  * A directory service key which provides the platform-correct "application
  * data" directory as follows, where $name and $vendor are as defined above and
  * $vendor is optional:
  *
@@ -421,25 +422,20 @@ XRE_API(nsresult,
 class MessageLoop;
 
 XRE_API(void,
         XRE_ShutdownChildProcess, ())
 
 XRE_API(MessageLoop*,
         XRE_GetIOMessageLoop, ())
 
-struct JSContext;
-class JSString;
-
 XRE_API(bool,
         XRE_SendTestShellCommand, (JSContext* aCx,
                                    JSString* aCommand,
                                    void* aCallback))
-class JSObject;
-
 XRE_API(bool,
         XRE_ShutdownTestShell, ())
 
 XRE_API(void,
         XRE_InstallX11ErrorHandler, ())
 
 #if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
 #define XRE_HAS_DLL_BLOCKLIST
--- a/xpfe/appshell/public/nsIAppShellService.idl
+++ b/xpfe/appshell/public/nsIAppShellService.idl
@@ -9,17 +9,17 @@ interface nsIXULWindow;
 interface nsIWebNavigation;
 interface nsIURI;
 interface nsIDOMWindow;
 interface nsIAppShell;
 
 [ptr] native JSContext(JSContext);
 
 %{C++
-struct JSContext;
+#include "js/TypeDecls.h"
 %}
 
 [scriptable, uuid(5c19ab54-67bf-46d0-ac5b-21abd9050c3b)]
 interface nsIAppShellService : nsISupports
 {
   /**
    * Create a window, which will be initially invisible.
    * @param aParent the parent window.  Can be null.