Bug 1391803 - Use nsStringFwd.h for forward declaring string classes. r=froydnj
authorEric Rahm <erahm@mozilla.com>
Wed, 16 Aug 2017 16:48:52 -0700
changeset 376425 397cfed5073f34740aed9e20460810316ee8ec25
parent 376424 5e813b0d6a3cc9d1a17bb64efa735b9dbaf5615a
child 376426 d792b3bb3d98254f2ba3ea23d0bfeb3151c99aa5
push id32383
push userkwierso@gmail.com
push dateThu, 24 Aug 2017 01:07:41 +0000
treeherdermozilla-central@d1c70c20e7b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1391803
milestone57.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 1391803 - Use nsStringFwd.h for forward declaring string classes. r=froydnj We should not be declaring forward declarations for nsString classes directly, instead we should use nsStringFwd.h. This will make changing the underlying types easier.
accessible/base/Platform.h
accessible/mac/MacUtils.h
caps/nsScriptSecurityManager.h
docshell/base/nsWebNavigationInfo.h
dom/animation/AnimationPerformanceWarning.h
dom/base/DOMException.h
dom/base/DirectionalityUtils.h
dom/base/DocumentFragment.h
dom/base/nsAttrValue.h
dom/base/nsContentListDeclarations.h
dom/base/nsContentPolicyUtils.h
dom/base/nsCopySupport.h
dom/base/nsIContent.h
dom/base/nsIContentSerializer.h
dom/base/nsIDocument.h
dom/base/nsIGlobalObject.h
dom/base/nsNameSpaceManager.h
dom/base/nsNodeInfoManager.h
dom/base/nsTextFragment.h
dom/console/nsIConsoleReportCollector.h
dom/events/AnimationEvent.h
dom/events/TouchEvent.h
dom/events/TransitionEvent.h
dom/html/nsIFormProcessor.h
dom/html/nsIHTMLCollection.h
dom/html/nsITextControlElement.h
dom/indexedDB/IDBEvents.h
dom/indexedDB/ScriptErrorHelper.h
dom/ipc/nsIContentChild.h
dom/media/DecoderTraits.h
dom/media/fmp4/MP4Decoder.h
dom/media/gmp/GMPUtils.h
dom/media/platforms/omx/OmxPlatformLayer.h
dom/plugins/ipc/PluginLibrary.h
dom/presentation/interfaces/nsIPresentationService.idl
dom/security/test/gtest/TestCSPParser.cpp
dom/smil/nsISMILAttr.h
dom/smil/nsSMILCSSValueType.h
dom/smil/nsSMILTimeValueSpec.h
dom/svg/SVGMotionSMILPathUtils.h
dom/svg/SVGTests.h
dom/workers/ScriptLoader.h
dom/xbl/nsXBLService.h
dom/xslt/base/txCore.h
dom/xslt/nsIDocumentTransformer.h
dom/xul/nsXULElement.h
editor/composer/nsComposerCommands.h
editor/libeditor/CSSEditUtils.h
editor/libeditor/ChangeStyleTransaction.h
editor/libeditor/EditorBase.h
editor/txtsvc/nsISpellChecker.h
editor/txtsvc/nsITextServicesDocument.h
editor/txtsvc/nsTextServicesDocument.h
gfx/src/nsColor.h
gfx/thebes/PrintTarget.h
image/ImageFactory.h
ipc/chromium/src/base/message_pump_libevent.h
ipc/contentproc/plugin-container.cpp
layout/base/RestyleManager.h
layout/base/nsIPresShell.h
layout/base/nsPresContext.h
layout/forms/nsIFormControlFrame.h
layout/forms/nsIListControlFrame.h
layout/generic/nsHTMLCanvasFrame.h
layout/generic/nsVideoFrame.h
layout/inspector/inISearchProcess.idl
layout/style/ImportRule.h
layout/style/nsMediaList.h
layout/style/nsStyleUtil.h
netwerk/base/nsILoadInfo.idl
netwerk/base/nsIURIClassifier.idl
netwerk/cache/nsCacheDevice.h
netwerk/cache2/CacheFileUtils.h
netwerk/protocol/about/nsAboutCacheEntry.h
netwerk/protocol/http/PSpdyPush.h
netwerk/protocol/http/nsHttpAuthCache.h
netwerk/protocol/http/nsIHttpChannelInternal.idl
netwerk/socket/nsISSLSocketControl.idl
netwerk/streamconv/nsStreamConverterService.h
parser/html/nsHtml5ArrayCopy.h
parser/htmlparser/nsIParser.h
rdf/base/nsIRDFXMLSink.idl
rdf/base/rdfutil.h
security/manager/ssl/nsISiteSecurityService.idl
security/manager/ssl/nsNSSCertificate.h
security/manager/ssl/nsNSSCertificateDB.h
toolkit/components/telemetry/ipc/TelemetryIPCAccumulator.h
toolkit/components/windowwatcher/nsDialogParamBlock.h
toolkit/xre/nsAppRunner.h
tools/profiler/gecko/nsIProfiler.idl
tools/profiler/public/ChildProfilerController.h
tools/profiler/tasktracer/GeckoTaskTracer.h
widget/EventForwards.h
widget/cocoa/nsMenuItemX.h
widget/cocoa/nsMenuUtilsX.h
widget/nsTransferable.h
widget/tests/TestChromeMargin.cpp
widget/windows/WinModifierKeyState.h
xpcom/base/ErrorNames.h
xpcom/base/nsrootidl.idl
xpcom/build/nsXPCOM.h
xpcom/string/nsStringFwd.h
--- a/accessible/base/Platform.h
+++ b/accessible/base/Platform.h
@@ -3,18 +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_a11y_Platform_h
 #define mozilla_a11y_Platform_h
 
 #include <stdint.h>
-
-class nsString;
+#include "nsStringFwd.h"
 
 namespace mozilla {
 namespace a11y {
 
 class ProxyAccessible;
 
 enum EPlatformDisabledState {
   ePlatformIsForceEnabled = -1,
--- a/accessible/mac/MacUtils.h
+++ b/accessible/mac/MacUtils.h
@@ -2,18 +2,19 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef _MacUtils_H_
 #define _MacUtils_H_
 
+#include "nsStringFwd.h"
+
 @class NSString;
-class nsString;
 
 namespace mozilla {
 namespace a11y {
 namespace utils {
 
 /**
  * Get a localized string from the string bundle.
  * Return nil if not found.
--- a/caps/nsScriptSecurityManager.h
+++ b/caps/nsScriptSecurityManager.h
@@ -11,22 +11,22 @@
 
 #include "nsIAddonPolicyService.h"
 #include "mozilla/Maybe.h"
 #include "nsIAddonPolicyService.h"
 #include "nsIPrincipal.h"
 #include "nsCOMPtr.h"
 #include "nsIObserver.h"
 #include "nsServiceManagerUtils.h"
+#include "nsStringFwd.h"
 #include "plstr.h"
 #include "js/TypeDecls.h"
 
 #include <stdint.h>
 
-class nsCString;
 class nsIIOService;
 class nsIStringBundle;
 class SystemPrincipal;
 
 namespace mozilla {
 class OriginAttributes;
 } // namespace mozilla
 
--- a/docshell/base/nsWebNavigationInfo.h
+++ b/docshell/base/nsWebNavigationInfo.h
@@ -5,20 +5,19 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsWebNavigationInfo_h__
 #define nsWebNavigationInfo_h__
 
 #include "nsIWebNavigationInfo.h"
 #include "nsCOMPtr.h"
 #include "nsICategoryManager.h"
+#include "nsStringFwd.h"
 #include "mozilla/Attributes.h"
 
-class nsCString;
-
 #define NS_WEBNAVIGATION_INFO_CID \
  { 0xf30bc0a2, 0x958b, 0x4287,{0xbf, 0x62, 0xce, 0x38, 0xba, 0x0c, 0x81, 0x1e}}
 
 class nsWebNavigationInfo final : public nsIWebNavigationInfo
 {
 public:
   nsWebNavigationInfo() {}
 
--- a/dom/animation/AnimationPerformanceWarning.h
+++ b/dom/animation/AnimationPerformanceWarning.h
@@ -5,20 +5,19 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_AnimationPerformanceWarning_h
 #define mozilla_dom_AnimationPerformanceWarning_h
 
 #include <initializer_list>
 
 #include "mozilla/Maybe.h"
+#include "nsStringFwd.h"
 #include "nsTArray.h"
 
-class nsAString;
-
 namespace mozilla {
 
 // Represents the reason why we can't run the CSS property on the compositor.
 struct AnimationPerformanceWarning
 {
   enum class Type : uint8_t {
     ContentTooLarge,
     ContentTooLargeArea,
--- a/dom/base/DOMException.h
+++ b/dom/base/DOMException.h
@@ -21,17 +21,16 @@
 #include "nsID.h"
 #include "nsIDOMDOMException.h"
 #include "nsWrapperCache.h"
 #include "xpcexception.h"
 #include "nsString.h"
 #include "mozilla/dom/BindingDeclarations.h"
 
 class nsIStackFrame;
-class nsString;
 
 nsresult
 NS_GetNameAndMessageForDOMNSResult(nsresult aNSResult, nsACString& aName,
                                    nsACString& aMessage,
                                    uint16_t* aCode = nullptr);
 
 namespace mozilla {
 class ErrorResult;
--- a/dom/base/DirectionalityUtils.h
+++ b/dom/base/DirectionalityUtils.h
@@ -3,19 +3,19 @@
 /* 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 DirectionalityUtils_h___
 #define DirectionalityUtils_h___
 
 #include "nscore.h"
+#include "nsStringFwd.h"
 
 class nsIContent;
-class nsAString;
 class nsAttrValue;
 class nsTextNode;
 
 namespace mozilla {
 namespace dom {
 class Element;
 } // namespace dom
 } // namespace mozilla
--- a/dom/base/DocumentFragment.h
+++ b/dom/base/DocumentFragment.h
@@ -6,19 +6,19 @@
 
 #ifndef mozilla_dom_DocumentFragment_h__
 #define mozilla_dom_DocumentFragment_h__
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/BorrowedAttrInfo.h"
 #include "mozilla/dom/FragmentOrElement.h"
 #include "nsIDOMDocumentFragment.h"
+#include "nsStringFwd.h"
 
 class nsIAtom;
-class nsAString;
 class nsIDocument;
 class nsIContent;
 
 namespace mozilla {
 namespace dom {
 
 class Element;
 
--- a/dom/base/nsAttrValue.h
+++ b/dom/base/nsAttrValue.h
@@ -16,27 +16,27 @@
 
 #include "nscore.h"
 #include "nsStringGlue.h"
 #include "nsStringBuffer.h"
 #include "nsColor.h"
 #include "nsCaseTreatment.h"
 #include "nsMargin.h"
 #include "nsCOMPtr.h"
+#include "nsStringFwd.h"
 #include "SVGAttrValueWrapper.h"
 #include "nsTArrayForwardDeclare.h"
 #include "nsIAtom.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/EnumTypeTraits.h"
 
 // Undefine LoadImage to prevent naming conflict with Windows.
 #undef LoadImage
 
-class nsAString;
 class nsIDocument;
 class nsStyledElement;
 struct MiscContainer;
 
 namespace mozilla {
 class DeclarationBlock;
 namespace css {
 struct URLValue;
--- a/dom/base/nsContentListDeclarations.h
+++ b/dom/base/nsContentListDeclarations.h
@@ -4,24 +4,22 @@
  * 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 nsContentListDeclarations_h
 #define nsContentListDeclarations_h
 
 #include <stdint.h>
 #include "nsCOMPtr.h"
+#include "nsStringFwd.h"
 
 class nsContentList;
 class nsIAtom;
 class nsIContent;
 class nsINode;
-// Can't use nsStringFwd.h because that's internal-API-only.
-class nsString;
-class nsAString;
 
 namespace mozilla {
 namespace dom {
 class Element;
 } // namespace dom
 } // namespace mozilla
 
 // Magic namespace id that means "match all namespaces".  This is
--- a/dom/base/nsContentPolicyUtils.h
+++ b/dom/base/nsContentPolicyUtils.h
@@ -15,22 +15,22 @@
 #define __nsContentPolicyUtils_h__
 
 #include "nsContentUtils.h"
 #include "nsIContentPolicy.h"
 #include "nsIContent.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIURI.h"
 #include "nsServiceManagerUtils.h"
+#include "nsStringFwd.h"
 
 //XXXtw sadly, this makes consumers of nsContentPolicyUtils depend on widget
 #include "nsIDocument.h"
 #include "nsPIDOMWindow.h"
 
-class nsACString;
 class nsIPrincipal;
 
 #define NS_CONTENTPOLICY_CONTRACTID   "@mozilla.org/layout/content-policy;1"
 #define NS_CONTENTPOLICY_CATEGORY "content-policy"
 #define NS_CONTENTPOLICY_CID                              \
   {0x0e3afd3d, 0xeb60, 0x4c2b,                            \
      { 0x96, 0x3b, 0x56, 0xd7, 0xc4, 0x39, 0xf1, 0x24 }}
 
--- a/dom/base/nsCopySupport.h
+++ b/dom/base/nsCopySupport.h
@@ -3,26 +3,25 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsCopySupport_h__
 #define nsCopySupport_h__
 
 #include "nsError.h"
 #include "nsIDocument.h"
+#include "nsStringFwd.h"
 #include "mozilla/EventForwards.h"
 
 class nsINode;
 class nsISelection;
 class nsIDocument;
 class nsIImageLoadingContent;
 class nsIContent;
 class nsITransferable;
-class nsACString;
-class nsAString;
 class nsIPresShell;
 class nsILoadContext;
 
 class nsCopySupport
 {
   // class of static helper functions for copy support
   public:
     static nsresult ClearSelectionCache();
--- a/dom/base/nsIContent.h
+++ b/dom/base/nsIContent.h
@@ -5,19 +5,19 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef nsIContent_h___
 #define nsIContent_h___
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/BorrowedAttrInfo.h"
 #include "nsCaseTreatment.h" // for enum, cannot be forward-declared
 #include "nsINode.h"
+#include "nsStringFwd.h"
 
 // Forward declarations
-class nsAString;
 class nsIAtom;
 class nsIURI;
 class nsRuleWalker;
 class nsAttrValue;
 class nsAttrName;
 class nsTextFragment;
 class nsIFrame;
 class nsXBLBinding;
--- a/dom/base/nsIContentSerializer.h
+++ b/dom/base/nsIContentSerializer.h
@@ -3,20 +3,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 nsIContentSerializer_h
 #define nsIContentSerializer_h
 
 #include "nsISupports.h"
+#include "nsStringFwd.h"
 
 class nsIContent;
 class nsIDocument;
-class nsAString;
 
 namespace mozilla {
 class Encoding;
 namespace dom {
 class Element;
 } // namespace dom
 } // namespace mozilla
 
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -16,16 +16,17 @@
 #include "nsILoadGroup.h"                // for member (in nsCOMPtr)
 #include "nsINode.h"                     // for base class
 #include "nsIParser.h"
 #include "nsIScriptGlobalObject.h"       // for member (in nsCOMPtr)
 #include "nsIServiceManager.h"
 #include "nsIUUIDGenerator.h"
 #include "nsPIDOMWindow.h"               // for use in inline functions
 #include "nsPropertyTable.h"             // for member
+#include "nsStringFwd.h"
 #include "nsDataHashtable.h"             // for member
 #include "nsURIHashKey.h"                // for member
 #include "mozilla/net/ReferrerPolicy.h"  // for member
 #include "nsWeakReference.h"
 #include "mozilla/UseCounter.h"
 #include "mozilla/WeakPtr.h"
 #include "Units.h"
 #include "nsContentListDeclarations.h"
@@ -49,17 +50,16 @@ namespace mozilla {
 namespace dom {
 class ElementCreationOptionsOrString;
 } // namespace dom
 } // namespace mozilla
 #endif // MOZILLA_INTERNAL_API
 
 class gfxUserFontSet;
 class imgIRequest;
-class nsAString;
 class nsBindingManager;
 class nsIDocShell;
 class nsDocShell;
 class nsDOMNavigationTiming;
 class nsFrameLoader;
 class nsHTMLCSSStyleSheet;
 class nsHTMLDocument;
 class nsHTMLStyleSheet;
--- a/dom/base/nsIGlobalObject.h
+++ b/dom/base/nsIGlobalObject.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/. */
 
 #ifndef nsIGlobalObject_h__
 #define nsIGlobalObject_h__
 
 #include "mozilla/dom/DispatcherTrait.h"
 #include "nsISupports.h"
+#include "nsStringFwd.h"
 #include "nsTArray.h"
 #include "js/TypeDecls.h"
 
 #define NS_IGLOBALOBJECT_IID \
 { 0x11afa8be, 0xd997, 0x4e07, \
 { 0xa6, 0xa3, 0x6f, 0x87, 0x2e, 0xc3, 0xee, 0x7f } }
 
-class nsACString;
-class nsCString;
 class nsCycleCollectionTraversalCallback;
 class nsIPrincipal;
 
 class nsIGlobalObject : public nsISupports,
                         public mozilla::dom::DispatcherTrait
 {
   nsTArray<nsCString> mHostObjectURIs;
   bool mIsDying;
--- a/dom/base/nsNameSpaceManager.h
+++ b/dom/base/nsNameSpaceManager.h
@@ -7,22 +7,21 @@
 #ifndef nsNameSpaceManager_h___
 #define nsNameSpaceManager_h___
 
 #include "nsDataHashtable.h"
 #include "nsHashKeys.h"
 #include "nsIAtom.h"
 #include "nsIDocument.h"
 #include "nsIObserver.h"
+#include "nsStringFwd.h"
 #include "nsTArray.h"
 
 #include "mozilla/StaticPtr.h"
 
-class nsAString;
-
 /**
  * The Name Space Manager tracks the association between a NameSpace
  * URI and the int32_t runtime id. Mappings between NameSpaces and
  * NameSpace prefixes are managed by nsINameSpaces.
  *
  * All NameSpace URIs are stored in a global table so that IDs are
  * consistent accross the app. NameSpace IDs are only consistent at runtime
  * ie: they are not guaranteed to be consistent accross app sessions.
--- a/dom/base/nsNodeInfoManager.h
+++ b/dom/base/nsNodeInfoManager.h
@@ -9,19 +9,19 @@
  */
 
 #ifndef nsNodeInfoManager_h___
 #define nsNodeInfoManager_h___
 
 #include "mozilla/Attributes.h"           // for final
 #include "nsCOMPtr.h"                     // for member
 #include "nsCycleCollectionParticipant.h" // for NS_DECL_CYCLE_*
+#include "nsStringFwd.h"
 #include "plhash.h"                       // for typedef PLHashNumber
 
-class nsAString;
 class nsBindingManager;
 class nsIAtom;
 class nsIDocument;
 class nsIDOMDocumentType;
 class nsIPrincipal;
 struct PLHashEntry;
 struct PLHashTable;
 template<class T> struct already_AddRefed;
--- a/dom/base/nsTextFragment.h
+++ b/dom/base/nsTextFragment.h
@@ -15,18 +15,16 @@
 
 #include "mozilla/Attributes.h"
 #include "mozilla/MemoryReporting.h"
 
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "nsISupportsImpl.h"
 
-class nsString;
-
 // XXX should this normalize the code to keep a \u0000 at the end?
 
 // XXX nsTextFragmentPool?
 
 /**
  * A fragment of text. If mIs2b is 1 then the m2b pointer is valid
  * otherwise the m1b pointer is valid. If m1b is used then each byte
  * of data represents a single ucs2 character with the high byte being
--- a/dom/console/nsIConsoleReportCollector.h
+++ b/dom/console/nsIConsoleReportCollector.h
@@ -4,21 +4,20 @@
  * 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 nsIConsoleReportCollector_h
 #define nsIConsoleReportCollector_h
 
 #include "nsContentUtils.h"
 #include "nsISupports.h"
+#include "nsStringFwd.h"
 #include "nsTArrayForwardDeclare.h"
 
-class nsACString;
 class nsIDocument;
-class nsString;
 
 #define NS_NSICONSOLEREPORTCOLLECTOR_IID \
   {0xdd98a481, 0xd2c4, 0x4203, {0x8d, 0xfa, 0x85, 0xbf, 0xd7, 0xdc, 0xd7, 0x05}}
 
 // An interface for saving reports until we can flush them to the correct
 // window at a later time.
 class NS_NO_VTABLE nsIConsoleReportCollector : public nsISupports
 {
--- a/dom/events/AnimationEvent.h
+++ b/dom/events/AnimationEvent.h
@@ -5,18 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef mozilla_dom_AnimationEvent_h_
 #define mozilla_dom_AnimationEvent_h_
 
 #include "mozilla/EventForwards.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/AnimationEventBinding.h"
 #include "nsIDOMAnimationEvent.h"
-
-class nsAString;
+#include "nsStringFwd.h"
 
 namespace mozilla {
 namespace dom {
 
 class AnimationEvent : public Event,
                        public nsIDOMAnimationEvent
 {
 public:
--- a/dom/events/TouchEvent.h
+++ b/dom/events/TouchEvent.h
@@ -8,20 +8,19 @@
 
 #include "mozilla/dom/Touch.h"
 #include "mozilla/dom/TouchEventBinding.h"
 #include "mozilla/dom/UIEvent.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/TouchEvents.h"
 #include "nsJSEnvironment.h"
+#include "nsStringFwd.h"
 #include "nsWrapperCache.h"
 
-class nsAString;
-
 namespace mozilla {
 namespace dom {
 
 class TouchList final : public nsISupports
                       , public nsWrapperCache
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
--- a/dom/events/TransitionEvent.h
+++ b/dom/events/TransitionEvent.h
@@ -5,18 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef mozilla_dom_TransitionEvent_h_
 #define mozilla_dom_TransitionEvent_h_
 
 #include "mozilla/EventForwards.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/TransitionEventBinding.h"
 #include "nsIDOMTransitionEvent.h"
-
-class nsAString;
+#include "nsStringFwd.h"
 
 namespace mozilla {
 namespace dom {
 
 class TransitionEvent : public Event,
                         public nsIDOMTransitionEvent
 {
 public:
--- a/dom/html/nsIFormProcessor.h
+++ b/dom/html/nsIFormProcessor.h
@@ -10,19 +10,19 @@
  * @created  kmcclusk 10/19/99
  *
  */
 
 #ifndef nsIFormProcessor_h__
 #define nsIFormProcessor_h__
 
 #include "nsISupports.h"
+#include "nsStringFwd.h"
 #include "nsTArrayForwardDeclare.h"
 
-class nsString;
 class nsIDOMHTMLElement;
 
 // {0ae53c0f-8ea2-4916-bedc-717443c3e185}
 #define NS_FORMPROCESSOR_CID \
 { 0x0ae53c0f, 0x8ea2, 0x4916, { 0xbe, 0xdc, 0x71, 0x74, 0x43, 0xc3, 0xe1, 0x85 } }
 
 #define NS_FORMPROCESSOR_CONTRACTID "@mozilla.org/layout/form-processor;1"
 
--- a/dom/html/nsIHTMLCollection.h
+++ b/dom/html/nsIHTMLCollection.h
@@ -3,23 +3,23 @@
 /* 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 nsIHTMLCollection_h___
 #define nsIHTMLCollection_h___
 
 #include "nsIDOMHTMLCollection.h"
+#include "nsStringFwd.h"
 #include "nsTArrayForwardDeclare.h"
 #include "nsWrapperCache.h"
 #include "js/GCAPI.h"
 #include "js/TypeDecls.h"
 
 class nsINode;
-class nsString;
 
 namespace mozilla {
 namespace dom {
 class Element;
 } // namespace dom
 } // namespace mozilla
 
 // IID for the nsIHTMLCollection interface
--- a/dom/html/nsITextControlElement.h
+++ b/dom/html/nsITextControlElement.h
@@ -4,18 +4,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 nsITextControlElement_h___
 #define nsITextControlElement_h___
 
 #include "nsISupports.h"
 #include "nsCOMPtr.h"
+#include "nsStringFwd.h"
 class nsIContent;
-class nsAString;
 class nsISelectionController;
 class nsFrameSelection;
 class nsTextControlFrame;
 
 namespace mozilla {
 
 class ErrorResult;
 class TextEditor;
--- a/dom/indexedDB/IDBEvents.h
+++ b/dom/indexedDB/IDBEvents.h
@@ -6,23 +6,21 @@
 
 #ifndef mozilla_dom_idbevents_h__
 #define mozilla_dom_idbevents_h__
 
 #include "js/RootingAPI.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/Nullable.h"
+#include "nsStringFwd.h"
 
 #define IDBVERSIONCHANGEEVENT_IID \
   {0x3b65d4c3, 0x73ad, 0x492e, {0xb1, 0x2d, 0x15, 0xf9, 0xda, 0xc2, 0x08, 0x4b}}
 
-class nsAString;
-class nsDependentString;
-
 namespace mozilla {
 
 class ErrorResult;
 
 namespace dom {
 
 class EventTarget;
 class GlobalObject;
--- a/dom/indexedDB/ScriptErrorHelper.h
+++ b/dom/indexedDB/ScriptErrorHelper.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_indexeddb_scripterrorhelper_h__
 #define mozilla_dom_indexeddb_scripterrorhelper_h__
 
 #include <inttypes.h>
-
-class nsACString;
-class nsAString;
+#include "nsStringFwd.h"
 
 namespace mozilla {
 namespace dom {
 namespace indexedDB {
 
 // Helper to report a script error to the main thread.
 class ScriptErrorHelper
 {
@@ -36,9 +34,9 @@ public:
                                    bool aIsChrome,
                                    uint64_t aInnerWindowID);
 };
 
 } // namespace indexedDB
 } // namespace dom
 } // namespace mozilla
 
-#endif // mozilla_dom_indexeddb_scripterrorhelper_h__
\ No newline at end of file
+#endif // mozilla_dom_indexeddb_scripterrorhelper_h__
--- a/dom/ipc/nsIContentChild.h
+++ b/dom/ipc/nsIContentChild.h
@@ -5,27 +5,26 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_nsIContentChild_h
 #define mozilla_dom_nsIContentChild_h
 
 #include "mozilla/dom/ipc/IdType.h"
 
 #include "nsISupports.h"
+#include "nsStringFwd.h"
 #include "nsTArrayForwardDeclare.h"
 #include "mozilla/dom/CPOWManagerGetter.h"
 #include "mozilla/ipc/Shmem.h"
 #include "mozilla/jsipc/CrossProcessObjectWrappers.h"
 
 #define NS_ICONTENTCHILD_IID                                    \
   { 0x4eed2e73, 0x94ba, 0x48a8,                                 \
     { 0xa2, 0xd1, 0xa5, 0xed, 0x86, 0xd7, 0xbb, 0xe4 } }
 
-class nsString;
-
 namespace IPC {
 class Principal;
 } // namespace IPC
 
 namespace mozilla {
 namespace ipc {
 class FileDescriptor;
 class PFileDescriptorSetChild;
--- a/dom/media/DecoderTraits.h
+++ b/dom/media/DecoderTraits.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 DecoderTraits_h_
 #define DecoderTraits_h_
 
 #include "nsCOMPtr.h"
-
-class nsAString;
-class nsACString;
+#include "nsStringFwd.h"
 
 namespace mozilla {
 
 class ChannelMediaDecoder;
 class DecoderDoctorDiagnostics;
 class MediaContainerType;
 struct MediaDecoderInit;
 struct MediaFormatReaderInit;
--- a/dom/media/fmp4/MP4Decoder.h
+++ b/dom/media/fmp4/MP4Decoder.h
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* 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/. */
 #if !defined(MP4Decoder_h_)
 #define MP4Decoder_h_
 
-class nsACString;
+#include "nsStringFwd.h"
 
 namespace mozilla {
 
 class MediaContainerType;
 class DecoderDoctorDiagnostics;
 
 // Decoder that uses a bundled MP4 demuxer and platform decoders to play MP4.
 class MP4Decoder
--- a/dom/media/gmp/GMPUtils.h
+++ b/dom/media/gmp/GMPUtils.h
@@ -4,24 +4,24 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GMPUtils_h_
 #define GMPUtils_h_
 
 #include "mozilla/UniquePtr.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/AbstractThread.h"
+#include "nsStringFwd.h"
 #include "nsTArray.h"
 #include "nsCOMPtr.h"
 #include "nsClassHashtable.h"
 
 #define CHROMIUM_CDM_API "chromium-cdm8-host4"
 
 class nsIFile;
-class nsCString;
 class nsISimpleEnumerator;
 
 namespace mozilla {
 
 template<typename T>
 struct DestroyPolicy
 {
   void operator()(T* aGMPObject) const {
--- a/dom/media/platforms/omx/OmxPlatformLayer.h
+++ b/dom/media/platforms/omx/OmxPlatformLayer.h
@@ -5,20 +5,19 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #if !defined(OmxPlatformLayer_h_)
 #define OmxPlatformLayer_h_
 
 #include "OMX_Core.h"
 #include "OMX_Types.h"
 
+#include "nsStringFwd.h"
 #include "OmxPromiseLayer.h"
 
-class nsACString;
-
 namespace mozilla {
 
 class TaskQueue;
 class TrackInfo;
 
 /*
  * This class the the abstract layer of the platform OpenMax IL implementation.
  *
--- a/dom/plugins/ipc/PluginLibrary.h
+++ b/dom/plugins/ipc/PluginLibrary.h
@@ -6,23 +6,23 @@
 
 #ifndef mozilla_PluginLibrary_h
 #define mozilla_PluginLibrary_h 1
 
 #include "prlink.h"
 #include "npapi.h"
 #include "npfunctions.h"
 #include "nscore.h"
+#include "nsStringFwd.h"
 #include "nsTArray.h"
 #include "nsError.h"
 #include "mozilla/EventForwards.h"
 #include "nsSize.h"
 #include "nsRect.h"
 
-class nsCString;
 class nsNPAPIPlugin;
 
 namespace mozilla {
 namespace gfx {
 class DrawTarget;
 }
 namespace layers {
 class Image;
--- a/dom/presentation/interfaces/nsIPresentationService.idl
+++ b/dom/presentation/interfaces/nsIPresentationService.idl
@@ -15,19 +15,19 @@ interface nsIPrincipal;
 
 %{C++
 #define PRESENTATION_SERVICE_CID \
   { 0x1d9bb10c, 0xc0ab, 0x4fe8, \
     { 0x9e, 0x4f, 0x40, 0x58, 0xb8, 0x51, 0x98, 0x32 } }
 #define PRESENTATION_SERVICE_CONTRACTID \
   "@mozilla.org/presentation/presentationservice;1"
 
+#include "nsStringFwd.h"
 #include "nsTArray.h"
 
-class nsString;
 %}
 
 [ref] native URLArrayRef(const nsTArray<nsString>);
 
 [scriptable, uuid(12073206-0065-4b10-9488-a6eb9b23e65b)]
 interface nsIPresentationServiceCallback : nsISupports
 {
   /*
--- a/dom/security/test/gtest/TestCSPParser.cpp
+++ b/dom/security/test/gtest/TestCSPParser.cpp
@@ -4,40 +4,22 @@
  * 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 "gtest/gtest.h"
 
 #include <string.h>
 #include <stdlib.h>
 
-#ifndef MOZILLA_INTERNAL_API
-// some of the includes make use of internal string types
-#define nsAString_h___
-#define nsString_h___
-#define nsStringFwd_h___
-#define nsReadableUtils_h___
-class nsACString;
-class nsAString;
-class nsString;
-class nsCString;
-template<class T> class nsReadingIterator;
-#endif
-
 #include "nsIContentSecurityPolicy.h"
 #include "nsNetUtil.h"
 #include "mozilla/dom/nsCSPContext.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
-
-#ifndef MOZILLA_INTERNAL_API
-#undef nsString_h___
-#undef nsAString_h___
-#undef nsReadableUtils_h___
-#endif
+#include "nsStringFwd.h"
 
 /*
  * Testing the parser is non trivial, especially since we can not call
  * parser functionality directly in compiled code tests.
  * All the tests (except the fuzzy tests at the end) follow the same schemata:
  *   a) create an nsIContentSecurityPolicy object
  *   b) set the selfURI in SetRequestContext
  *   c) append one or more policies by calling AppendPolicy
--- a/dom/smil/nsISMILAttr.h
+++ b/dom/smil/nsISMILAttr.h
@@ -3,20 +3,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 NS_ISMILATTR_H_
 #define NS_ISMILATTR_H_
 
 #include "nscore.h"
+#include "nsStringFwd.h"
 
 class nsSMILValue;
 class nsIContent;
-class nsAString;
 
 namespace mozilla {
 namespace dom {
 class SVGAnimationElement;
 } // namespace dom
 } // namespace mozilla
 
 ////////////////////////////////////////////////////////////////////////
--- a/dom/smil/nsSMILCSSValueType.h
+++ b/dom/smil/nsSMILCSSValueType.h
@@ -6,20 +6,19 @@
 
 /* representation of a value for a SMIL-animated CSS property */
 
 #ifndef NS_SMILCSSVALUETYPE_H_
 #define NS_SMILCSSVALUETYPE_H_
 
 #include "nsISMILType.h"
 #include "nsCSSPropertyID.h"
+#include "nsStringFwd.h"
 #include "mozilla/Attributes.h"
 
-class nsAString;
-
 namespace mozilla {
 struct AnimationValue;
 namespace dom {
 class Element;
 } // namespace dom
 } // namespace mozilla
 
 /*
--- a/dom/smil/nsSMILTimeValueSpec.h
+++ b/dom/smil/nsSMILTimeValueSpec.h
@@ -4,20 +4,20 @@
  * 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 NS_SMILTIMEVALUESPEC_H_
 #define NS_SMILTIMEVALUESPEC_H_
 
 #include "mozilla/Attributes.h"
 #include "nsSMILTimeValueSpecParams.h"
+#include "nsStringFwd.h"
 #include "nsReferencedElement.h"
 #include "nsIDOMEventListener.h"
 
-class nsAString;
 class nsSMILTimeValue;
 class nsSMILTimedElement;
 class nsSMILTimeContainer;
 class nsSMILInstanceTime;
 class nsSMILInterval;
 
 namespace mozilla {
 class EventListenerManager;
--- a/dom/svg/SVGMotionSMILPathUtils.h
+++ b/dom/svg/SVGMotionSMILPathUtils.h
@@ -11,19 +11,19 @@
 #define MOZILLA_SVGMOTIONSMILPATHUTILS_H_
 
 #include "mozilla/Attributes.h"
 #include "gfxPlatform.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/RefPtr.h"
 #include "nsDebug.h"
 #include "nsSMILParserUtils.h"
+#include "nsStringFwd.h"
 #include "nsTArray.h"
 
-class nsAString;
 class nsSVGElement;
 
 namespace mozilla {
 
 class SVGMotionSMILPathUtils
 {
   typedef mozilla::gfx::DrawTarget DrawTarget;
   typedef mozilla::gfx::Path Path;
--- a/dom/svg/SVGTests.h
+++ b/dom/svg/SVGTests.h
@@ -8,17 +8,16 @@
 #define mozilla_dom_SVGTests_h
 
 #include "nsStringFwd.h"
 #include "SVGStringList.h"
 #include "nsCOMPtr.h"
 
 class nsAttrValue;
 class nsIAtom;
-class nsString;
 
 namespace mozilla {
 class DOMSVGStringList;
 
 #define MOZILLA_DOMSVGTESTS_IID \
    { 0x92370da8, 0xda28, 0x4895, \
      {0x9b, 0x1b, 0xe0, 0x06, 0x0d, 0xb7, 0x3f, 0xc3 } }
 
--- a/dom/workers/ScriptLoader.h
+++ b/dom/workers/ScriptLoader.h
@@ -4,22 +4,22 @@
  * 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_workers_scriptloader_h__
 #define mozilla_dom_workers_scriptloader_h__
 
 #include "Workers.h"
 #include "nsIContentPolicy.h"
+#include "nsStringFwd.h"
 
 class nsIPrincipal;
 class nsIURI;
 class nsIDocument;
 class nsILoadGroup;
-class nsString;
 class nsIChannel;
 
 namespace mozilla {
 
 class ErrorResult;
 
 } // namespace mozilla
 
--- a/dom/xbl/nsXBLService.h
+++ b/dom/xbl/nsXBLService.h
@@ -14,17 +14,16 @@
 #include "nsTArray.h"
 #include "nsDataHashtable.h"
 #include "nsHashKeys.h"
 
 class nsXBLBinding;
 class nsXBLDocumentInfo;
 class nsIContent;
 class nsIDocument;
-class nsString;
 class nsIURI;
 class nsIPrincipal;
 
 namespace mozilla {
 namespace dom {
 class EventTarget;
 } // namespace dom
 } // namespace mozilla
--- a/dom/xslt/base/txCore.h
+++ b/dom/xslt/base/txCore.h
@@ -4,18 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef __txCore_h__
 #define __txCore_h__
 
 #include "nscore.h"
 #include "nsDebug.h"
 #include "nsISupportsImpl.h"
-
-class nsAString;
+#include "nsStringFwd.h"
 
 class txObject
 {
 public:
     txObject()
     {
         MOZ_COUNT_CTOR(txObject);
     }
--- a/dom/xslt/nsIDocumentTransformer.h
+++ b/dom/xslt/nsIDocumentTransformer.h
@@ -1,21 +1,21 @@
 /* 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 nsIDocumentTransformer_h__
 #define nsIDocumentTransformer_h__
 
 #include "nsISupports.h"
+#include "nsStringFwd.h"
 
 class nsIDocument;
 class nsIDOMNode;
 class nsIURI;
-class nsString;
 
 #define NS_ITRANSFORMOBSERVER_IID \
 { 0x04b2d17c, 0xe98d, 0x45f5, \
   { 0x9a, 0x67, 0xb7, 0x01, 0x19, 0x59, 0x7d, 0xe7 } }
 
 class nsITransformObserver : public nsISupports
 {
 public:
--- a/dom/xul/nsXULElement.h
+++ b/dom/xul/nsXULElement.h
@@ -24,29 +24,29 @@
 #include "nsIDOMXULMultSelectCntrlEl.h"
 #include "nsIRDFCompositeDataSource.h"
 #include "nsIRDFResource.h"
 #include "nsIURI.h"
 #include "nsIXULTemplateBuilder.h"
 #include "nsLayoutCID.h"
 #include "nsAttrAndChildArray.h"
 #include "nsGkAtoms.h"
+#include "nsStringFwd.h"
 #include "nsStyledElement.h"
 #include "nsIFrameLoader.h"
 #include "nsFrameLoader.h" // Needed because we return an
                            // already_AddRefed<nsFrameLoader> where bindings
                            // want an already_AddRefed<nsIFrameLoader> and hence
                            // bindings need to know that the former can cast to
                            // the latter.
 #include "mozilla/dom/DOMRect.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/DOMString.h"
 
 class nsIDocument;
-class nsString;
 class nsXULPrototypeDocument;
 
 class nsIObjectInputStream;
 class nsIObjectOutputStream;
 class nsIOffThreadScriptReceiver;
 class nsXULPrototypeNode;
 typedef nsTArray<RefPtr<nsXULPrototypeNode> > nsPrototypeArray;
 
--- a/editor/composer/nsComposerCommands.h
+++ b/editor/composer/nsComposerCommands.h
@@ -3,22 +3,22 @@
  * 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 nsComposerCommands_h_
 #define nsComposerCommands_h_
 
 #include "nsIControllerCommand.h"
 #include "nsISupportsImpl.h"            // for NS_DECL_ISUPPORTS_INHERITED, etc
+#include "nsStringFwd.h"
 #include "nscore.h"                     // for nsresult, NS_IMETHOD
 
 class nsIAtom;
 class nsICommandParams;
 class nsISupports;
-class nsString;
 
 namespace mozilla {
 class HTMLEditor;
 } // namespace mozilla
 
 // This is a virtual base class for commands registered with the composer controller.
 // Note that such commands are instantiated once per composer, so can store state.
 // Also note that IsCommandEnabled can be called with an editor that may not
--- a/editor/libeditor/CSSEditUtils.h
+++ b/editor/libeditor/CSSEditUtils.h
@@ -3,27 +3,27 @@
  * 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_CSSEditUtils_h
 #define mozilla_CSSEditUtils_h
 
 #include "mozilla/ChangeStyleTransaction.h" // for ChangeStyleTransaction
 #include "nsCOMPtr.h"               // for already_AddRefed
+#include "nsStringFwd.h"
 #include "nsTArray.h"               // for nsTArray
 #include "nscore.h"                 // for nsAString, nsresult, nullptr
 
 class nsComputedDOMStyle;
 class nsIAtom;
 class nsIContent;
 class nsIDOMCSSStyleDeclaration;
 class nsIDOMElement;
 class nsIDOMNode;
 class nsINode;
-class nsString;
 
 namespace mozilla {
 
 class HTMLEditor;
 namespace dom {
 class Element;
 } // namespace dom
 
--- a/editor/libeditor/ChangeStyleTransaction.h
+++ b/editor/libeditor/ChangeStyleTransaction.h
@@ -6,17 +6,16 @@
 #ifndef mozilla_ChangeStyleTransaction_h
 #define mozilla_ChangeStyleTransaction_h
 
 #include "mozilla/EditTransactionBase.h"  // base class
 #include "nsCOMPtr.h"                     // nsCOMPtr members
 #include "nsCycleCollectionParticipant.h" // various macros
 #include "nsString.h"                     // nsString members
 
-class nsAString;
 class nsIAtom;
 
 namespace mozilla {
 
 namespace dom {
 class Element;
 } // namespace dom
 
--- a/editor/libeditor/EditorBase.h
+++ b/editor/libeditor/EditorBase.h
@@ -43,17 +43,16 @@ class nsIEditActionListener;
 class nsIEditorObserver;
 class nsIInlineSpellChecker;
 class nsINode;
 class nsIPresShell;
 class nsISupports;
 class nsITransaction;
 class nsIWidget;
 class nsRange;
-class nsString;
 class nsTransactionManager;
 
 // This is int32_t instead of int16_t because nsIInlineSpellChecker.idl's
 // spellCheckAfterEditorChange is defined to take it as a long.
 // XXX EditAction causes unnecessary include of EditorBase from some places.
 //     Why don't you move this to nsIEditor.idl?
 enum class EditAction : int32_t
 {
--- a/editor/txtsvc/nsISpellChecker.h
+++ b/editor/txtsvc/nsISpellChecker.h
@@ -3,27 +3,27 @@
  * 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 nsISpellChecker_h__
 #define nsISpellChecker_h__
 
 #include "mozilla/MozPromise.h"
 #include "nsISupports.h"
+#include "nsStringFwd.h"
 #include "nsTArray.h"
 
 #define NS_SPELLCHECKER_CONTRACTID "@mozilla.org/spellchecker;1"
 
 #define NS_ISPELLCHECKER_IID                    \
 { /* 27bff957-b486-40ae-9f5d-af0cdd211868 */    \
 0x27bff957, 0xb486, 0x40ae, \
   { 0x9f, 0x5d, 0xaf, 0x0c, 0xdd, 0x21, 0x18, 0x68 } }
 
 class nsITextServicesDocument;
-class nsString;
 
 /**
  * A generic interface for a spelling checker.
  */
 class nsISpellChecker  : public nsISupports{
 public:
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISPELLCHECKER_IID)
--- a/editor/txtsvc/nsITextServicesDocument.h
+++ b/editor/txtsvc/nsITextServicesDocument.h
@@ -2,21 +2,21 @@
 /* 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 nsITextServicesDocument_h__
 #define nsITextServicesDocument_h__
 
 #include "nsISupports.h"
+#include "nsStringFwd.h"
 
 class nsIDOMDocument;
 class nsIDOMRange;
 class nsIEditor;
-class nsString;
 class nsITextServicesFilter;
 
 /*
 TextServicesDocument interface to outside world
 */
 
 #define NS_ITEXTSERVICESDOCUMENT_IID            \
 { /* 019718E1-CDB5-11d2-8D3C-000000000000 */    \
--- a/editor/txtsvc/nsTextServicesDocument.h
+++ b/editor/txtsvc/nsTextServicesDocument.h
@@ -7,32 +7,32 @@
 #define nsTextServicesDocument_h__
 
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIEditActionListener.h"
 #include "nsISupportsImpl.h"
 #include "nsITextServicesDocument.h"
 #include "nsIWeakReferenceUtils.h"
+#include "nsStringFwd.h"
 #include "nsTArray.h"
 #include "nscore.h"
 
 class OffsetEntry;
 class nsIAtom;
 class nsIContent;
 class nsIContentIterator;
 class nsIDOMCharacterData;
 class nsIDOMDocument;
 class nsIDOMNode;
 class nsIDOMRange;
 class nsIEditor;
 class nsISelection;
 class nsISelectionController;
 class nsITextServicesFilter;
-class nsString;
 
 /** implementation of a text services object.
  *
  */
 class nsTextServicesDocument final : public nsITextServicesDocument,
                                      public nsIEditActionListener
 {
 private:
--- a/gfx/src/nsColor.h
+++ b/gfx/src/nsColor.h
@@ -5,19 +5,17 @@
 
 #ifndef nsColor_h___
 #define nsColor_h___
 
 #include <stddef.h>                     // for size_t
 #include <stdint.h>                     // for uint8_t, uint32_t
 #include "nscore.h"                     // for nsAString
 #include "nsCoord.h"                    // for NSToIntRound
-
-class nsAString;
-class nsString;
+#include "nsStringFwd.h"
 
 // A color is a 32 bit unsigned integer with four components: R, G, B
 // and A.
 typedef uint32_t nscolor;
 
 // Make a color out of r,g,b values. This assumes that the r,g,b values are
 // properly constrained to 0-255. This also assumes that a is 255.
 #define NS_RGB(_r,_g,_b) \
--- a/gfx/thebes/PrintTarget.h
+++ b/gfx/thebes/PrintTarget.h
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_GFX_PRINTTARGET_H
 #define MOZILLA_GFX_PRINTTARGET_H
 
 #include "mozilla/RefPtr.h"
 #include "mozilla/gfx/2D.h"
 #include "nsISupportsImpl.h"
+#include "nsStringFwd.h"
 
 namespace mozilla {
 namespace gfx {
 
 class DrawEventRecorder;
 
 /**
  * A class that is used to draw output that is to be sent to a printer or print
--- a/image/ImageFactory.h
+++ b/image/ImageFactory.h
@@ -4,18 +4,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 mozilla_image_ImageFactory_h
 #define mozilla_image_ImageFactory_h
 
 #include "nsCOMPtr.h"
 #include "nsProxyRelease.h"
+#include "nsStringFwd.h"
 
-class nsCString;
 class nsIRequest;
 
 namespace mozilla {
 namespace image {
 
 class Image;
 class ImageURL;
 class MultipartImage;
--- a/ipc/chromium/src/base/message_pump_libevent.h
+++ b/ipc/chromium/src/base/message_pump_libevent.h
@@ -5,23 +5,22 @@
 // found in the LICENSE file.
 
 #ifndef BASE_MESSAGE_PUMP_LIBEVENT_H_
 #define BASE_MESSAGE_PUMP_LIBEVENT_H_
 
 #include "base/message_pump.h"
 #include "base/time.h"
 #include "mozilla/UniquePtr.h"
+#include "nsStringFwd.h"
 
 // Declare structs we need from libevent.h rather than including it
 struct event_base;
 struct event;
 
-class nsDependentCSubstring;
-
 namespace base {
 
 // Class to monitor sockets and issue callbacks when sockets are ready for I/O
 // TODO(dkegel): add support for background file IO somehow
 class MessagePumpLibevent : public MessagePump {
  public:
 
   // Object returned by WatchFileDescriptor to manage further watching.
--- a/ipc/contentproc/plugin-container.cpp
+++ b/ipc/contentproc/plugin-container.cpp
@@ -1,17 +1,16 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: sw=4 ts=4 et :
  * 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 "nsXPCOM.h"
 #include "nsXULAppAPI.h"
-#include "nsAutoPtr.h"
 #include "mozilla/Bootstrap.h"
 
 #ifdef XP_WIN
 #include <windows.h>
 // we want a wmain entry point
 // but we don't want its DLL load protection, because we'll handle it here
 #define XRE_DONT_PROTECT_DLL_LOAD
 #include "nsWindowsWMain.cpp"
--- a/layout/base/RestyleManager.h
+++ b/layout/base/RestyleManager.h
@@ -5,18 +5,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_RestyleManager_h
 #define mozilla_RestyleManager_h
 
 #include "mozilla/OverflowChangedTracker.h"
 #include "nsChangeHint.h"
 #include "nsPresContext.h"
+#include "nsStringFwd.h"
 
-class nsCString;
 class nsCSSFrameConstructor;
 class nsStyleChangeList;
 
 namespace mozilla {
 
 class EventStates;
 class GeckoRestyleManager;
 class ServoRestyleManager;
--- a/layout/base/nsIPresShell.h
+++ b/layout/base/nsIPresShell.h
@@ -18,16 +18,17 @@
 #include "mozilla/WeakPtr.h"
 #include "gfxPoint.h"
 #include "nsTHashtable.h"
 #include "nsHashKeys.h"
 #include "nsISupports.h"
 #include "nsIContent.h"
 #include "nsISelectionController.h"
 #include "nsQueryFrame.h"
+#include "nsStringFwd.h"
 #include "nsCoord.h"
 #include "nsColor.h"
 #include "nsFrameManagerBase.h"
 #include "nsRect.h"
 #include "nsRegionFwd.h"
 #include "nsWeakReference.h"
 #include <stdio.h> // for FILE definition
 #include "nsChangeHint.h"
@@ -44,17 +45,16 @@ class nsDocShell;
 class nsIDocument;
 class nsIFrame;
 class nsPresContext;
 class nsWindowSizes;
 class nsViewManager;
 class nsView;
 class nsIPageSequenceFrame;
 class nsCanvasFrame;
-class nsAString;
 class nsCaret;
 namespace mozilla {
 class AccessibleCaretEventHub;
 class CSSStyleSheet;
 } // namespace mozilla
 class nsFrameSelection;
 class nsFrameManager;
 class nsILayoutHistoryState;
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -12,16 +12,17 @@
 #include "mozilla/NotNull.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/WeakPtr.h"
 #include "nsColor.h"
 #include "nsCoord.h"
 #include "nsCOMPtr.h"
 #include "nsIPresShell.h"
 #include "nsRect.h"
+#include "nsStringFwd.h"
 #include "nsFont.h"
 #include "gfxFontConstants.h"
 #include "nsIAtom.h"
 #include "nsIObserver.h"
 #include "nsITimer.h"
 #include "nsCRT.h"
 #include "nsIWidgetListener.h"
 #include "nsLanguageAtomService.h"
@@ -41,17 +42,16 @@
 #include "ScrollbarStyles.h"
 #include "nsIMessageManager.h"
 #include "mozilla/RestyleLogging.h"
 #include "Units.h"
 #include "prenv.h"
 #include "mozilla/StaticPresData.h"
 #include "mozilla/StyleBackendType.h"
 
-class nsAString;
 class nsBidi;
 class nsIPrintSettings;
 class nsDocShell;
 class nsIDocShell;
 class nsIDocument;
 class nsITheme;
 class nsIContent;
 class nsIFrame;
--- a/layout/forms/nsIFormControlFrame.h
+++ b/layout/forms/nsIFormControlFrame.h
@@ -2,18 +2,18 @@
 /* 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 nsIFormControlFrame_h___
 #define nsIFormControlFrame_h___
 
 #include "nsQueryFrame.h"
+#include "nsStringFwd.h"
 
-class nsAString;
 class nsIAtom;
 
 /**
   * nsIFormControlFrame is the common interface for frames of form controls. It
   * provides a uniform way of creating widgets, resizing, and painting.
   * @see nsLeafFrame and its base classes for more info
   */
 class nsIFormControlFrame : public nsQueryFrame
--- a/layout/forms/nsIListControlFrame.h
+++ b/layout/forms/nsIListControlFrame.h
@@ -2,18 +2,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 nsIListControlFrame_h___
 #define nsIListControlFrame_h___
 
 #include "nsQueryFrame.h"
-
-class nsAString;
+#include "nsStringFwd.h"
 
 namespace mozilla {
 namespace dom {
 class HTMLOptionElement;
 } // namespace dom
 } // namespace mozilla
 
 /**
--- a/layout/generic/nsHTMLCanvasFrame.h
+++ b/layout/generic/nsHTMLCanvasFrame.h
@@ -5,28 +5,28 @@
 
 /* rendering object for the HTML <canvas> element */
 
 #ifndef nsHTMLCanvasFrame_h___
 #define nsHTMLCanvasFrame_h___
 
 #include "mozilla/Attributes.h"
 #include "nsContainerFrame.h"
+#include "nsStringFwd.h"
 #include "FrameLayerBuilder.h"
 
 namespace mozilla {
 namespace layers {
 class Layer;
 class LayerManager;
 } // namespace layers
 } // namespace mozilla
 
 class nsPresContext;
 class nsDisplayItem;
-class nsAString;
 
 nsIFrame* NS_NewHTMLCanvasFrame (nsIPresShell* aPresShell, nsStyleContext* aContext);
 
 class nsHTMLCanvasFrame final : public nsContainerFrame
 {
 public:
   typedef mozilla::layers::CanvasRenderer CanvasRenderer;
   typedef mozilla::layers::Layer Layer;
--- a/layout/generic/nsVideoFrame.h
+++ b/layout/generic/nsVideoFrame.h
@@ -7,27 +7,27 @@
 /* rendering object for the HTML <video> element */
 
 #ifndef nsVideoFrame_h___
 #define nsVideoFrame_h___
 
 #include "mozilla/Attributes.h"
 #include "nsContainerFrame.h"
 #include "nsIAnonymousContentCreator.h"
+#include "nsStringFwd.h"
 #include "nsTArrayForwardDeclare.h"
 #include "FrameLayerBuilder.h"
 
 namespace mozilla {
 namespace layers {
 class Layer;
 class LayerManager;
 } // namespace layers
 } // namespace mozilla
 
-class nsAString;
 class nsPresContext;
 class nsDisplayItem;
 
 class nsVideoFrame : public nsContainerFrame
                    , public nsIAnonymousContentCreator
 {
 public:
   template <typename T> using Maybe = mozilla::Maybe<T>;
--- a/layout/inspector/inISearchProcess.idl
+++ b/layout/inspector/inISearchProcess.idl
@@ -1,16 +1,15 @@
 /* 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"
 
-interface nsAString;
 interface inISearchObserver;
 
 [scriptable, uuid(D5FA765B-2448-4686-B7C1-5FF13ACB0FC9)]
 interface inISearchProcess : nsISupports
 {
   // indicates if an asynchronous search is in progress
   readonly attribute boolean isActive;
 
--- a/layout/style/ImportRule.h
+++ b/layout/style/ImportRule.h
@@ -8,18 +8,19 @@
 #ifndef mozilla_css_ImportRule_h__
 #define mozilla_css_ImportRule_h__
 
 #include "mozilla/Attributes.h"
 
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/dom/CSSImportRule.h"
 
+#include "nsStringFwd.h"
+
 class nsMediaList;
-class nsString;
 
 namespace mozilla {
 
 class CSSStyleSheet;
 class StyleSheet;
 
 namespace dom {
 class MediaList;
--- a/layout/style/nsMediaList.h
+++ b/layout/style/nsMediaList.h
@@ -11,21 +11,21 @@
 
 #ifndef nsMediaList_h_
 #define nsMediaList_h_
 
 #include "nsAutoPtr.h"
 #include "nsTArray.h"
 #include "nsIAtom.h"
 #include "nsCSSValue.h"
+#include "nsStringFwd.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/MediaList.h"
 
 class nsPresContext;
-class nsAString;
 struct nsMediaFeature;
 
 namespace mozilla {
 namespace css {
 class DocumentRule;
 } // namespace css
 } // namespace mozilla
 
--- a/layout/style/nsStyleUtil.h
+++ b/layout/style/nsStyleUtil.h
@@ -5,21 +5,21 @@
 #ifndef nsStyleUtil_h___
 #define nsStyleUtil_h___
 
 #include "nsCoord.h"
 #include "nsCSSPropertyID.h"
 #include "nsString.h"
 #include "nsTArrayForwardDeclare.h"
 #include "gfxFontFamilyList.h"
+#include "nsStringFwd.h"
 #include "nsStyleStruct.h"
 #include "nsCRT.h"
 
 class nsCSSValue;
-class nsStringComparator;
 class nsStyleCoord;
 class nsIContent;
 class nsIPrincipal;
 class nsIURI;
 struct gfxFontFeature;
 struct gfxAlternateValue;
 struct nsCSSValueList;
 
--- a/netwerk/base/nsILoadInfo.idl
+++ b/netwerk/base/nsILoadInfo.idl
@@ -11,18 +11,17 @@ interface nsIDOMDocument;
 interface nsINode;
 interface nsIPrincipal;
 interface nsIRedirectHistoryEntry;
 interface nsIURI;
 %{C++
 #include "nsTArray.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/LoadTainting.h"
-
-class nsCString;
+#include "nsStringFwd.h"
 %}
 
 [ref] native nsIRedirectHistoryEntryArray(const nsTArray<nsCOMPtr<nsIRedirectHistoryEntry>>);
 native OriginAttributes(mozilla::OriginAttributes);
 [ref] native const_OriginAttributesRef(const mozilla::OriginAttributes);
 [ref] native StringArrayRef(const nsTArray<nsCString>);
 
 typedef unsigned long nsSecurityFlags;
--- a/netwerk/base/nsIURIClassifier.idl
+++ b/netwerk/base/nsIURIClassifier.idl
@@ -1,17 +1,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"
 
 %{C++
+#include "nsStringFwd.h"
 #include "nsTArrayForwardDeclare.h"
-class nsCString;
 %}
 [ref] native StringArrayRef(nsTArray<nsCString>);
 
 interface nsIChannel;
 interface nsIEventTarget;
 interface nsIPrincipal;
 interface nsIURI;
 
--- a/netwerk/cache/nsCacheDevice.h
+++ b/netwerk/cache/nsCacheDevice.h
@@ -5,19 +5,19 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef _nsCacheDevice_h_
 #define _nsCacheDevice_h_
 
 #include "nspr.h"
 #include "nsError.h"
 #include "nsICache.h"
+#include "nsStringFwd.h"
 
 class nsIFile;
-class nsCString;
 class nsCacheEntry;
 class nsICacheVisitor;
 class nsIInputStream;
 class nsIOutputStream;
 
 /******************************************************************************
 * nsCacheDevice
 *******************************************************************************/
--- a/netwerk/cache2/CacheFileUtils.h
+++ b/netwerk/cache2/CacheFileUtils.h
@@ -8,17 +8,16 @@
 #include "nsError.h"
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "mozilla/StaticMutex.h"
 #include "mozilla/TimeStamp.h"
 
 class nsILoadContextInfo;
-class nsACString;
 
 namespace mozilla {
 namespace net {
 namespace CacheFileUtils {
 
 extern const char *kAltDataKey;
 
 already_AddRefed<nsILoadContextInfo>
--- a/netwerk/protocol/about/nsAboutCacheEntry.h
+++ b/netwerk/protocol/about/nsAboutCacheEntry.h
@@ -12,17 +12,16 @@
 #include "nsIStreamListener.h"
 #include "nsString.h"
 #include "nsCOMPtr.h"
 
 class nsIAsyncOutputStream;
 class nsIInputStream;
 class nsILoadContextInfo;
 class nsIURI;
-class nsCString;
 
 class nsAboutCacheEntry final : public nsIAboutModule
 {
 public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSIABOUTMODULE
 
 private:
--- a/netwerk/protocol/http/PSpdyPush.h
+++ b/netwerk/protocol/http/PSpdyPush.h
@@ -23,18 +23,17 @@
 */
 
 #ifndef mozilla_net_SpdyPush_Public_h
 #define mozilla_net_SpdyPush_Public_h
 
 #include "nsAutoPtr.h"
 #include "nsDataHashtable.h"
 #include "nsISupports.h"
-
-class nsCString;
+#include "nsStringFwd.h"
 
 namespace mozilla {
 namespace net {
 
 class Http2PushedStream;
 
 // One cache per load group
 class SpdyPushCache
--- a/netwerk/protocol/http/nsHttpAuthCache.h
+++ b/netwerk/protocol/http/nsHttpAuthCache.h
@@ -5,21 +5,20 @@
 
 #ifndef nsHttpAuthCache_h__
 #define nsHttpAuthCache_h__
 
 #include "nsError.h"
 #include "nsTArray.h"
 #include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
+#include "nsStringFwd.h"
 #include "plhash.h"
 #include "nsIObserver.h"
 
-class nsCString;
-
 namespace mozilla {
 
 class OriginAttributesPattern;
 
 namespace net {
 
 struct nsHttpAuthPath {
     struct nsHttpAuthPath *mNext;
--- a/netwerk/protocol/http/nsIHttpChannelInternal.idl
+++ b/netwerk/protocol/http/nsIHttpChannelInternal.idl
@@ -1,19 +1,19 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* 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"
 
 %{C++
+#include "nsStringFwd.h"
 #include "nsTArrayForwardDeclare.h"
 template<class T> class nsCOMArray;
-class nsCString;
 %}
 [ptr] native StringArray(nsTArray<nsCString>);
 [ref] native StringArrayRef(const nsTArray<nsCString>);
 [ref] native securityMessagesArray(nsCOMArray<nsISecurityConsoleMessage>);
 
 interface nsIAsyncInputStream;
 interface nsIAsyncOutputStream;
 interface nsIPrincipal;
--- a/netwerk/socket/nsISSLSocketControl.idl
+++ b/netwerk/socket/nsISSLSocketControl.idl
@@ -5,18 +5,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
 interface nsIInterfaceRequestor;
 interface nsIX509Cert;
 
 %{C++
+#include "nsStringFwd.h"
 #include "nsTArrayForwardDeclare.h"
-class nsCString;
 %}
 [ref] native nsCStringTArrayRef(nsTArray<nsCString>);
 
 [scriptable, builtinclass, uuid(418265c8-654e-4fbb-ba62-4eed27de1f03)]
 interface nsISSLSocketControl : nsISupports {
     attribute nsIInterfaceRequestor     notificationCallbacks;
 
     void proxyStartSSL();
--- a/netwerk/streamconv/nsStreamConverterService.h
+++ b/netwerk/streamconv/nsStreamConverterService.h
@@ -5,19 +5,19 @@
 
 #ifndef __nsstreamconverterservice__h___
 #define __nsstreamconverterservice__h___
 
 #include "nsIStreamConverterService.h"
 
 #include "nsClassHashtable.h"
 #include "nsCOMArray.h"
+#include "nsStringFwd.h"
 #include "nsTArrayForwardDeclare.h"
 
-class nsCString;
 class nsIAtom;
 
 class nsStreamConverterService : public nsIStreamConverterService {
 public:
     /////////////////////////////////////////////////////
     // nsISupports methods
     NS_DECL_ISUPPORTS
 
--- a/parser/html/nsHtml5ArrayCopy.h
+++ b/parser/html/nsHtml5ArrayCopy.h
@@ -18,18 +18,18 @@
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
  */
 
 #ifndef nsHtml5ArrayCopy_h
 #define nsHtml5ArrayCopy_h
 
+#include "nsStringFwd.h"
 
-class nsString;
 class nsHtml5StackNode;
 class nsHtml5AttributeName;
 
 // Unfortunately, these don't work as template functions because the arguments
 // would need coercion from a template class, which complicates things.
 class nsHtml5ArrayCopy {
   public:
 
--- a/parser/htmlparser/nsIParser.h
+++ b/parser/htmlparser/nsIParser.h
@@ -28,17 +28,16 @@
 #include "mozilla/NotNull.h"
 
 #define NS_IPARSER_IID \
 { 0x2c4ad90a, 0x740e, 0x4212, \
   { 0xba, 0x3f, 0xfe, 0xac, 0xda, 0x4b, 0x92, 0x9e } }
 
 class nsIContentSink;
 class nsIRequestObserver;
-class nsString;
 class nsIURI;
 class nsIChannel;
 namespace mozilla {
 class Encoding;
 }
 
 enum eParserCommands {
   eViewNormal,
--- a/rdf/base/nsIRDFXMLSink.idl
+++ b/rdf/base/nsIRDFXMLSink.idl
@@ -11,18 +11,18 @@
 */
 
 #include "nsISupports.idl"
 
 // XXX Until these get scriptable. See nsIRDFXMLSink::AddNameSpace()
 [ptr] native nsIAtomPtr(nsIAtom);
 [ref] native nsStringRef(nsString);
 %{C++
+#include "nsStringFwd.h"
 class nsIAtom;
-class nsString;
 %}
 
 interface nsIRDFXMLSink;
 
 /**
  * An observer that is notified as progress is made on the load
  * of an RDF/XML document in an <code>nsIRDFXMLSink</code>.
  */
--- a/rdf/base/rdfutil.h
+++ b/rdf/base/rdfutil.h
@@ -17,19 +17,17 @@
   2) All that's left is rdf_PossiblyMakeRelative() and
      -Absolute(). Maybe those go on nsIRDFService, too.
 
  */
 
 #ifndef rdfutil_h__
 #define rdfutil_h__
 
-
-class nsACString;
-class nsCString;
+#include "nsStringFwd.h"
 
 nsresult
 rdf_MakeRelativeRef(const nsACString& aBaseURI, nsCString& aURI);
 
 void
 rdf_FormatDate(PRTime aTime, nsACString &aResult);
 
 PRTime
--- a/security/manager/ssl/nsISiteSecurityService.idl
+++ b/security/manager/ssl/nsISiteSecurityService.idl
@@ -6,18 +6,18 @@
 
 interface nsIURI;
 interface nsIObserver;
 interface nsIHttpChannel;
 interface nsISSLStatus;
 interface nsISimpleEnumerator;
 
 %{C++
+#include "nsStringFwd.h"
 #include "nsTArrayForwardDeclare.h"
-class nsCString;
 namespace mozilla
 {
   namespace pkix
   {
     class Time;
   }
 }
 %}
--- a/security/manager/ssl/nsNSSCertificate.h
+++ b/security/manager/ssl/nsNSSCertificate.h
@@ -12,16 +12,17 @@
 #include "nsIASN1Object.h"
 #include "nsIClassInfo.h"
 #include "nsISerializable.h"
 #include "nsISimpleEnumerator.h"
 #include "nsIX509Cert.h"
 #include "nsIX509CertDB.h"
 #include "nsIX509CertList.h"
 #include "nsNSSShutDown.h"
+#include "nsStringFwd.h"
 
 namespace mozilla { namespace pkix { class DERArray; } }
 
 class nsINSSComponent;
 class nsIASN1Sequence;
 
 class nsNSSCertificate final : public nsIX509Cert,
                                public nsISerializable,
--- a/security/manager/ssl/nsNSSCertificateDB.h
+++ b/security/manager/ssl/nsNSSCertificateDB.h
@@ -10,17 +10,16 @@
 #include "mozilla/Mutex.h"
 #include "mozilla/NotNull.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/UniquePtr.h"
 #include "nsIX509CertDB.h"
 #include "nsNSSShutDown.h"
 #include "nsString.h"
 
-class nsCString;
 class nsIArray;
 
 class nsNSSCertificateDB final : public nsIX509CertDB
                                , public nsNSSShutDownObject
 
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
--- a/toolkit/components/telemetry/ipc/TelemetryIPCAccumulator.h
+++ b/toolkit/components/telemetry/ipc/TelemetryIPCAccumulator.h
@@ -3,22 +3,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/. */
 
 #ifndef TelemetryIPCAccumulator_h__
 #define TelemetryIPCAccumulator_h__
 
 #include "mozilla/AlreadyAddRefed.h"
 #include "mozilla/Maybe.h"
+#include "nsStringFwd.h"
 #include "TelemetryComms.h"
 
 class nsIRunnable;
 class nsITimer;
-class nsAString;
-class nsCString;
 
 namespace mozilla {
 
 class TimeStamp;
 
 namespace TelemetryIPCAccumulator {
 
 // Histogram accumulation functions.
--- a/toolkit/components/windowwatcher/nsDialogParamBlock.h
+++ b/toolkit/components/windowwatcher/nsDialogParamBlock.h
@@ -5,23 +5,22 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef __nsDialogParamBlock_h
 #define __nsDialogParamBlock_h
 
 #include "nsIDialogParamBlock.h"
 #include "nsIMutableArray.h"
 #include "nsCOMPtr.h"
+#include "nsStringFwd.h"
 
 // {4E4AAE11-8901-46cc-8217-DAD7C5415873}
 #define NS_DIALOGPARAMBLOCK_CID \
   {0x4e4aae11, 0x8901, 0x46cc, {0x82, 0x17, 0xda, 0xd7, 0xc5, 0x41, 0x58, 0x73}}
 
-class nsString;
-
 class nsDialogParamBlock : public nsIDialogParamBlock
 {
 public:
   nsDialogParamBlock();
 
   NS_DECL_NSIDIALOGPARAMBLOCK
   NS_DECL_ISUPPORTS
 
--- a/toolkit/xre/nsAppRunner.h
+++ b/toolkit/xre/nsAppRunner.h
@@ -19,31 +19,31 @@
 #define MAXPATHLEN _MAX_PATH
 #elif defined(CCHMAXPATH)
 #define MAXPATHLEN CCHMAXPATH
 #else
 #define MAXPATHLEN 1024
 #endif
 #endif
 
+#include "nsStringFwd.h"
 #include "nsXULAppAPI.h"
 
 // This directory service key is a lot like NS_APP_LOCALSTORE_50_FILE,
 // but it is always the "main" localstore file, even when we're in safe mode
 // and we load localstore from somewhere else.
 #define NS_LOCALSTORE_UNSAFE_FILE "LStoreS"
 
 class nsINativeAppSupport;
 class nsXREDirProvider;
 class nsIToolkitProfileService;
 class nsIFile;
 class nsIProfileLock;
 class nsIProfileUnlocker;
 class nsIFactory;
-class nsString;
 
 extern nsXREDirProvider* gDirServiceProvider;
 
 // NOTE: gAppData will be null in embedded contexts.
 extern const mozilla::XREAppData* gAppData;
 extern bool gSafeMode;
 
 extern int    gArgc;
--- a/tools/profiler/gecko/nsIProfiler.idl
+++ b/tools/profiler/gecko/nsIProfiler.idl
@@ -2,17 +2,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"
 
 %{C++
 #include "nsTArrayForwardDeclare.h"
-class nsCString;
+#include "nsStringFwd.h"
 %}
 
 [ref] native nsCString(const nsCString);
 [ref] native StringArrayRef(const nsTArray<nsCString>);
 
 /**
  * Start-up parameters for subprocesses are passed through nsIObserverService,
  * which, unfortunately, means we need to implement nsISupports in order to
--- a/tools/profiler/public/ChildProfilerController.h
+++ b/tools/profiler/public/ChildProfilerController.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 ChildProfilerController_h
 #define ChildProfilerController_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/RefPtr.h"
+#include "nsStringFwd.h"
 #include "base/process.h"
 
-class nsCString;
-
 namespace mozilla {
 
 class ProfilerChild;
 class PProfilerChild;
 class PProfilerParent;
 
 // ChildProfilerController manages the setup and teardown of ProfilerChild.
 // It's used on the main thread.
--- a/tools/profiler/tasktracer/GeckoTaskTracer.h
+++ b/tools/profiler/tasktracer/GeckoTaskTracer.h
@@ -8,16 +8,17 @@
 #define GECKO_TASK_TRACER_H
 
 #include <stdarg.h>
 
 #include "mozilla/UniquePtr.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/Maybe.h"
 #include "nsCOMPtr.h"
+#include "nsStringFwd.h"
 #include "nsTArrayForwardDeclare.h"
 
 /**
  * TaskTracer provides a way to trace the correlation between different tasks
  * across threads and processes. Unlike sampling based profilers, TaskTracer can
  * tell you where a task is dispatched from, what its original source was, how
  * long it waited in the event queue, and how long it took to execute.
  *
@@ -25,17 +26,16 @@
  * as touch events, timer events, network events, etc. When a source event is
  * created, TaskTracer records the entire chain of Tasks and nsRunnables as they
  * are dispatched to different threads and processes. It records latency,
  * execution time, etc. for each Task and nsRunnable that chains back to the
  * original source event.
  */
 
 class nsIRunnable;
-class nsCString;
 
 namespace mozilla {
 
 class TimeStamp;
 class Runnable;
 
 namespace tasktracer {
 
--- a/widget/EventForwards.h
+++ b/widget/EventForwards.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 mozilla_EventForwards_h__
 #define mozilla_EventForwards_h__
 
 #include <stdint.h>
 
+#include "nsStringFwd.h"
 #include "nsTArray.h"
 
-class nsCString;
-
 /**
  * XXX Following enums should be in BasicEvents.h.  However, currently, it's
  *     impossible to use foward delearation for enum.
  */
 
 /**
  * Return status for event processors.
  */
--- a/widget/cocoa/nsMenuItemX.h
+++ b/widget/cocoa/nsMenuItemX.h
@@ -5,20 +5,20 @@
 
 #ifndef nsMenuItemX_h_
 #define nsMenuItemX_h_
 
 #include "mozilla/RefPtr.h"
 #include "nsMenuBaseX.h"
 #include "nsMenuGroupOwnerX.h"
 #include "nsChangeObserver.h"
+#include "nsStringFwd.h"
 
 #import <Cocoa/Cocoa.h>
 
-class nsString;
 class nsMenuItemIconX;
 class nsMenuX;
 
 enum {
   knsMenuItemNoModifier      = 0,
   knsMenuItemShiftModifier   = (1 << 0),
   knsMenuItemAltModifier     = (1 << 1),
   knsMenuItemControlModifier = (1 << 2),
--- a/widget/cocoa/nsMenuUtilsX.h
+++ b/widget/cocoa/nsMenuUtilsX.h
@@ -3,21 +3,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/. */
 
 #ifndef nsMenuUtilsX_h_
 #define nsMenuUtilsX_h_
 
 #include "nscore.h"
 #include "nsMenuBaseX.h"
+#include "nsStringFwd.h"
 
 #import <Cocoa/Cocoa.h>
 
 class nsIContent;
-class nsString;
 class nsMenuBarX;
 
 // Namespace containing utility functions used in our native menu implementation.
 namespace nsMenuUtilsX
 {
   void          DispatchCommandTo(nsIContent* aTargetContent);
   NSString*     GetTruncatedCocoaLabel(const nsString& itemLabel);
   uint8_t       GeckoModifiersForNodeAttribute(const nsString& modifiersAttribute);
--- a/widget/nsTransferable.h
+++ b/widget/nsTransferable.h
@@ -9,17 +9,16 @@
 #include "nsIFormatConverter.h"
 #include "nsITransferable.h"
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsIPrincipal.h"
 
 class nsIMutableArray;
-class nsString;
 
 //
 // DataStruct
 //
 // Holds a flavor (a mime type) that describes the data and the associated data.
 //
 struct DataStruct
 {
--- a/widget/tests/TestChromeMargin.cpp
+++ b/widget/tests/TestChromeMargin.cpp
@@ -12,36 +12,22 @@
 /* This test no longer compiles now that we've removed nsIContentUtils (bug
  * 647273).  We need to be internal code in order to include nsContentUtils.h,
  * but defining MOZILLA_INTERNAL_API is not enough to make us internal.
  */
 
 #include "TestHarness.h"
 
 #ifndef MOZILLA_INTERNAL_API
-// some of the includes make use of internal string types
-#define nsAString_h___
-#define nsString_h___
-#define nsStringFwd_h___
-#define nsReadableUtils_h___
-class nsACString;
-class nsAString;
-class nsString;
-class nsCString;
-template<class T> class nsReadingIterator;
+#error This test needs MOZILLA_INTERNAL_API (see bug 652123)
 #endif
 
 #include "nscore.h"
 #include "nsContentUtils.h"
-
-#ifndef MOZILLA_INTERNAL_API
-#undef nsString_h___
-#undef nsAString_h___
-#undef nsReadableUtils_h___
-#endif
+#include "nsString.h"
 
 struct DATA {
   bool shouldfail;
   const char* margins;
   int top;
   int right;
   int bottom;
   int left;
--- a/widget/windows/WinModifierKeyState.h
+++ b/widget/windows/WinModifierKeyState.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 mozilla_widget_WinModifierKeyState_h_
 #define mozilla_widget_WinModifierKeyState_h_
 
 #include "mozilla/RefPtr.h"
 #include "mozilla/EventForwards.h"
+#include "nsStringFwd.h"
 #include <windows.h>
 
-class nsCString;
-
 namespace mozilla {
 namespace widget {
 
 class MOZ_STACK_CLASS ModifierKeyState final
 {
 public:
   ModifierKeyState();
   ModifierKeyState(bool aIsShiftDown, bool aIsControlDown, bool aIsAltDown);
--- a/xpcom/base/ErrorNames.h
+++ b/xpcom/base/ErrorNames.h
@@ -3,18 +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_ErrorNames_h
 #define mozilla_ErrorNames_h
 
 #include "nsError.h"
-
-class nsACString;
+#include "nsStringFwd.h"
 
 namespace mozilla {
 
 // Maps the given nsresult to its symbolic name. For example,
 // GetErrorName(NS_OK, name) will result in name == "NS_OK".
 // When the symbolic name is unknown, name will be of the form
 // "NS_ERROR_GENERATE_SUCCESS(<module>, <code>)" or
 // "NS_ERROR_GENERATE_FAILURE(<module>, <code>)".
--- a/xpcom/base/nsrootidl.idl
+++ b/xpcom/base/nsrootidl.idl
@@ -10,18 +10,17 @@
 %{C++
 
 #include "nscore.h"
 typedef int64_t PRTime;
 
 /*
  * Forward declarations for new string types
  */
-class nsAString;
-class nsACString;
+#include "nsStringFwd.h"
 
 /* 
  * Start commenting out the C++ versions of the below in the output header
  */
 #if 0
 %}
 
 typedef boolean             bool   ;
--- a/xpcom/build/nsXPCOM.h
+++ b/xpcom/build/nsXPCOM.h
@@ -13,30 +13,28 @@
 #ifdef __cplusplus
 #define DECL_CLASS(c) class c
 #define DECL_STRUCT(c) struct c
 #else
 #define DECL_CLASS(c) typedef struct c c
 #define DECL_STRUCT(c) typedef struct c c
 #endif
 
-DECL_CLASS(nsAString);
-DECL_CLASS(nsACString);
-
 DECL_CLASS(nsISupports);
 DECL_CLASS(nsIModule);
 DECL_CLASS(nsIComponentManager);
 DECL_CLASS(nsIComponentRegistrar);
 DECL_CLASS(nsIServiceManager);
 DECL_CLASS(nsIFile);
 DECL_CLASS(nsIDirectoryServiceProvider);
 DECL_CLASS(nsIMemory);
 DECL_CLASS(nsIDebug2);
 
 #ifdef __cplusplus
+#include "nsStringFwd.h"
 namespace mozilla {
 struct Module;
 } // namespace mozilla
 #endif
 
 /**
  * Initialises XPCOM. You must call one of the NS_InitXPCOM methods
  * before proceeding to use xpcom. The one exception is that you may
--- a/xpcom/string/nsStringFwd.h
+++ b/xpcom/string/nsStringFwd.h
@@ -1,25 +1,21 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* nsStringFwd.h --- forward declarations for string classes */
 
-#ifndef nsStringFwd_h___
-#define nsStringFwd_h___
+#ifndef nsStringFwd_h
+#define nsStringFwd_h
 
 #include "nscore.h"
 
-#ifndef MOZILLA_INTERNAL_API
-#error Internal string headers are not available from external-linkage code.
-#endif
-
 namespace mozilla {
 namespace detail {
 
 class nsStringRepr;
 class nsCStringRepr;
 
 } // namespace detail
 } // namespace mozilla
@@ -46,9 +42,9 @@ template<size_t N> class nsAutoCStringN;
 using nsAutoCString = nsAutoCStringN<AutoStringDefaultStorageSize>;
 class nsDependentCString;
 class nsDependentCSubstring;
 class nsPromiseFlatCString;
 class nsCStringComparator;
 class nsDefaultCStringComparator;
 class nsXPIDLCString; // deprecated
 
-#endif /* !defined(nsStringFwd_h___) */
+#endif /* !defined(nsStringFwd_h) */