Bug 772807 - Clean up editor/ includes with include-what-you-use; r=ehsan
authorAryeh Gregor <ayg@aryeh.name>
Fri, 13 Jul 2012 09:33:42 +0300
changeset 99560 4e24278d2273dac7a5f8a681e078e207d09da12a
parent 99559 3afe01d22000559dc82b7b000bd78c3ec5947f6b
child 99561 f1c05fde89c7ef658b27651da9c065437f066167
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersehsan
bugs772807
milestone16.0a1
Bug 772807 - Clean up editor/ includes with include-what-you-use; r=ehsan
content/base/src/nsGkAtomList.h
content/html/content/src/nsTextEditorState.cpp
editor/composer/src/nsComposeTxtSrvFilter.cpp
editor/composer/src/nsComposeTxtSrvFilter.h
editor/composer/src/nsComposerCommands.cpp
editor/composer/src/nsComposerCommands.h
editor/composer/src/nsComposerCommandsUpdater.cpp
editor/composer/src/nsComposerCommandsUpdater.h
editor/composer/src/nsComposerController.cpp
editor/composer/src/nsComposerController.h
editor/composer/src/nsComposerDocumentCommands.cpp
editor/composer/src/nsComposerRegistration.cpp
editor/composer/src/nsEditingSession.cpp
editor/composer/src/nsEditingSession.h
editor/composer/src/nsEditorSpellCheck.cpp
editor/composer/src/nsEditorSpellCheck.h
editor/libeditor/base/ChangeAttributeTxn.cpp
editor/libeditor/base/ChangeAttributeTxn.h
editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp
editor/libeditor/base/ChangeCSSInlineStyleTxn.h
editor/libeditor/base/CreateElementTxn.cpp
editor/libeditor/base/CreateElementTxn.h
editor/libeditor/base/DeleteNodeTxn.cpp
editor/libeditor/base/DeleteNodeTxn.h
editor/libeditor/base/DeleteRangeTxn.cpp
editor/libeditor/base/DeleteRangeTxn.h
editor/libeditor/base/DeleteTextTxn.cpp
editor/libeditor/base/DeleteTextTxn.h
editor/libeditor/base/EditAggregateTxn.cpp
editor/libeditor/base/EditAggregateTxn.h
editor/libeditor/base/EditTxn.cpp
editor/libeditor/base/EditTxn.h
editor/libeditor/base/IMETextTxn.cpp
editor/libeditor/base/IMETextTxn.h
editor/libeditor/base/InsertElementTxn.cpp
editor/libeditor/base/InsertElementTxn.h
editor/libeditor/base/InsertTextTxn.cpp
editor/libeditor/base/InsertTextTxn.h
editor/libeditor/base/JoinElementTxn.cpp
editor/libeditor/base/JoinElementTxn.h
editor/libeditor/base/PlaceholderTxn.cpp
editor/libeditor/base/SetDocTitleTxn.cpp
editor/libeditor/base/SetDocTitleTxn.h
editor/libeditor/base/SplitElementTxn.cpp
editor/libeditor/base/SplitElementTxn.h
editor/libeditor/base/nsEditPropertyAtomList.h
editor/libeditor/base/nsEditRules.h
editor/libeditor/base/nsEditor.cpp
editor/libeditor/base/nsEditor.h
editor/libeditor/base/nsEditorCommands.cpp
editor/libeditor/base/nsEditorCommands.h
editor/libeditor/base/nsEditorController.cpp
editor/libeditor/base/nsEditorController.h
editor/libeditor/base/nsEditorEventListener.cpp
editor/libeditor/base/nsEditorEventListener.h
editor/libeditor/base/nsEditorUtils.cpp
editor/libeditor/base/nsEditorUtils.h
editor/libeditor/base/nsSelectionState.cpp
editor/libeditor/base/nsSelectionState.h
editor/libeditor/base/nsStyleSheetTxns.cpp
editor/libeditor/base/nsStyleSheetTxns.h
editor/libeditor/html/TextEditorTest.cpp
editor/libeditor/html/TextEditorTest.h
editor/libeditor/html/TypeInState.cpp
editor/libeditor/html/TypeInState.h
editor/libeditor/html/nsEditProperty.cpp
editor/libeditor/html/nsHTMLAbsPosition.cpp
editor/libeditor/html/nsHTMLAnonymousUtils.cpp
editor/libeditor/html/nsHTMLCSSUtils.cpp
editor/libeditor/html/nsHTMLCSSUtils.h
editor/libeditor/html/nsHTMLDataTransfer.cpp
editor/libeditor/html/nsHTMLEditRules.cpp
editor/libeditor/html/nsHTMLEditRules.h
editor/libeditor/html/nsHTMLEditUtils.cpp
editor/libeditor/html/nsHTMLEditor.cpp
editor/libeditor/html/nsHTMLEditor.h
editor/libeditor/html/nsHTMLEditorEventListener.cpp
editor/libeditor/html/nsHTMLEditorEventListener.h
editor/libeditor/html/nsHTMLEditorStyle.cpp
editor/libeditor/html/nsHTMLInlineTableEditor.cpp
editor/libeditor/html/nsHTMLObjectResizer.cpp
editor/libeditor/html/nsHTMLObjectResizer.h
editor/libeditor/html/nsHTMLURIRefObject.cpp
editor/libeditor/html/nsHTMLURIRefObject.h
editor/libeditor/html/nsTableEditor.cpp
editor/libeditor/html/nsWSRunObject.cpp
editor/libeditor/html/nsWSRunObject.h
editor/libeditor/text/nsInternetCiter.cpp
editor/libeditor/text/nsInternetCiter.h
editor/libeditor/text/nsPlaintextDataTransfer.cpp
editor/libeditor/text/nsPlaintextEditor.cpp
editor/libeditor/text/nsPlaintextEditor.h
editor/libeditor/text/nsTextEditRules.cpp
editor/libeditor/text/nsTextEditRules.h
editor/libeditor/text/nsTextEditRulesBidi.cpp
editor/libeditor/text/nsTextEditUtils.cpp
editor/libeditor/text/nsTextEditUtils.h
editor/txmgr/src/nsTransactionItem.cpp
editor/txmgr/src/nsTransactionItem.h
editor/txmgr/src/nsTransactionList.cpp
editor/txmgr/src/nsTransactionList.h
editor/txmgr/src/nsTransactionManager.cpp
editor/txmgr/src/nsTransactionManager.h
editor/txmgr/src/nsTransactionManagerFactory.cpp
editor/txmgr/src/nsTransactionStack.cpp
editor/txmgr/src/nsTransactionStack.h
editor/txtsvc/src/nsFilteredContentIterator.cpp
editor/txtsvc/src/nsFilteredContentIterator.h
editor/txtsvc/src/nsTextServicesDocument.cpp
editor/txtsvc/src/nsTextServicesDocument.h
layout/forms/nsTextControlFrame.cpp
layout/style/nsStyleStructList.h
parser/htmlparser/public/nsHTMLTagList.h
xpcom/build/ServiceList.h
xpcom/string/public/nsTDependentSubstring.h
xpcom/string/public/nsTString.h
xpcom/string/public/nsTSubstring.h
xpcom/string/public/nsTSubstringTuple.h
xpcom/string/public/string-template-def-char.h
xpcom/string/public/string-template-def-unichar.h
--- a/content/base/src/nsGkAtomList.h
+++ b/content/base/src/nsGkAtomList.h
@@ -1,13 +1,15 @@
 /* -*- Mode: C++; 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/. */
 
+// IWYU pragma: private, include "nsGkAtoms.h"
+
 /*
   This file contains the list of all atoms used by gklayout;
   see nsGkAtoms for access to the atoms.
 */
 
 /*
   This file is designed to be used as inline input to nsGkAtoms.cpp and nsGkAtoms.h
   *only* through the magic of C preprocessing.
--- a/content/html/content/src/nsTextEditorState.cpp
+++ b/content/html/content/src/nsTextEditorState.cpp
@@ -9,16 +9,17 @@
 #include "nsCOMPtr.h"
 #include "nsIPresShell.h"
 #include "nsIView.h"
 #include "nsCaret.h"
 #include "nsEditorCID.h"
 #include "nsLayoutCID.h"
 #include "nsITextControlFrame.h" 
 #include "nsIPlaintextEditor.h"
+#include "nsIDOMCharacterData.h"
 #include "nsIDOMDocument.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsTextControlFrame.h"
 #include "nsIControllers.h"
 #include "nsIDOMHTMLInputElement.h"
 #include "nsIDOMHTMLTextAreaElement.h"
 #include "nsITransactionManager.h"
 #include "nsIControllerContext.h"
--- a/editor/composer/src/nsComposeTxtSrvFilter.cpp
+++ b/editor/composer/src/nsComposeTxtSrvFilter.cpp
@@ -1,18 +1,22 @@
 /* -*- Mode: C++; 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 "nsCaseTreatment.h"
 #include "nsComposeTxtSrvFilter.h"
-#include "nsIContent.h"
-#include "nsIDOMNode.h"
-#include "nsString.h"
-#include "nsINameSpaceManager.h"
+#include "nsError.h"                    // for NS_OK
+#include "nsIContent.h"                 // for nsIContent
+#include "nsID.h"
+#include "nsIDOMNode.h"                 // for nsIDOMNode
+#include "nsINameSpaceManager.h"        // for kNameSpaceID_None
+#include "nsLiteralString.h"            // for NS_LITERAL_STRING
+#include "nscore.h"                     // for NS_IMETHODIMP
 
 nsComposeTxtSrvFilter::nsComposeTxtSrvFilter() :
   mIsForMail(false)
 {
 
   mBlockQuoteAtom  = do_GetAtom("blockquote");
   mSpanAtom        = do_GetAtom("span");
   mTableAtom       = do_GetAtom("table");
--- a/editor/composer/src/nsComposeTxtSrvFilter.h
+++ b/editor/composer/src/nsComposeTxtSrvFilter.h
@@ -1,18 +1,20 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef nsComposeTxtSrvFilter_h__
 #define nsComposeTxtSrvFilter_h__
 
+#include "nsCOMPtr.h"                   // for nsCOMPtr
+#include "nsIAtom.h"                    // for nsIAtom
+#include "nsISupportsImpl.h"            // for NS_DECL_ISUPPORTS
 #include "nsITextServicesFilter.h"
-#include "nsIAtom.h"
 
 /**
  * This class implements a filter interface, that enables
  * those using it to skip over certain nodes when traversing content
  *
  * This filter is used to skip over various form control nodes and
  * mail's cite nodes
  */
--- a/editor/composer/src/nsComposerCommands.cpp
+++ b/editor/composer/src/nsComposerCommands.cpp
@@ -1,33 +1,39 @@
 /* -*- Mode: C++; 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 "nsIEditor.h"
-#include "nsIHTMLEditor.h"
-#include "nsIHTMLAbsPosEditor.h"
-
-#include "nsIDOMElement.h"
-#include "nsIAtom.h"
-#include "nsGkAtoms.h"
-
-#include "nsIClipboard.h"
+#include <stdio.h>                      // for printf
 
-#include "nsCOMPtr.h"
-
+#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
+#include "nsAString.h"
+#include "nsCOMPtr.h"                   // for nsCOMPtr, do_QueryInterface, etc
+#include "nsComponentManagerUtils.h"    // for do_CreateInstance
 #include "nsComposerCommands.h"
-#include "nsReadableUtils.h"
-#include "nsUnicharUtils.h"
-#include "nsICommandParams.h"
-#include "nsComponentManagerUtils.h"
+#include "nsDebug.h"                    // for NS_ENSURE_TRUE, etc
+#include "nsError.h"                    // for NS_OK, NS_ERROR_FAILURE, etc
+#include "nsGkAtoms.h"                  // for nsGkAtoms, nsGkAtoms::font, etc
+#include "nsIAtom.h"                    // for nsIAtom, etc
+#include "nsIClipboard.h"               // for nsIClipboard, etc
+#include "nsICommandParams.h"           // for nsICommandParams, etc
+#include "nsID.h"
+#include "nsIDOMElement.h"              // for nsIDOMElement
+#include "nsIEditor.h"                  // for nsIEditor
+#include "nsIHTMLAbsPosEditor.h"        // for nsIHTMLAbsPosEditor
+#include "nsIHTMLEditor.h"              // for nsIHTMLEditor, etc
+#include "nsLiteralString.h"            // for NS_LITERAL_STRING
+#include "nsReadableUtils.h"            // for EmptyString
+#include "nsString.h"                   // for nsAutoString, nsString, etc
+#include "nsStringFwd.h"                // for nsAFlatString
+#include "prtypes.h"                    // for PRInt32
 
-#include "mozilla/Assertions.h"
+class nsISupports;
 
 //prototype
 nsresult GetListState(nsIHTMLEditor* aEditor, bool* aMixed,
                       nsAString& aLocalName);
 nsresult RemoveOneProperty(nsIHTMLEditor* aEditor, const nsAString& aProp);
 nsresult RemoveTextProperty(nsIHTMLEditor* aEditor, const nsAString& aProp);
 nsresult SetTextProperty(nsIHTMLEditor *aEditor, const nsAString& aProp);
 
--- a/editor/composer/src/nsComposerCommands.h
+++ b/editor/composer/src/nsComposerCommands.h
@@ -2,20 +2,24 @@
 /* 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 nsComposerCommands_h_
 #define nsComposerCommands_h_
 
 #include "nsIControllerCommand.h"
-#include "nsString.h"
+#include "nsISupportsImpl.h"            // for NS_DECL_ISUPPORTS_INHERITED, etc
+#include "nscore.h"                     // for nsresult, NS_IMETHOD
 
+class nsIAtom;
+class nsICommandParams;
 class nsIEditor;
-class nsIAtom;
+class nsISupports;
+class nsString;
 
 // 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
 // have an editor yet (because the document is loading). Most commands will want
 // to return false in this case.
 // Don't hold on to any references to the editor or document from
 // your command. This will cause leaks. Also, be aware that the document the
--- a/editor/composer/src/nsComposerCommandsUpdater.cpp
+++ b/editor/composer/src/nsComposerCommandsUpdater.cpp
@@ -1,27 +1,33 @@
 /* -*- Mode: C++; 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 "nsPIDOMWindow.h"
+#include "mozilla/mozalloc.h"           // for operator new
+#include "nsAString.h"
+#include "nsComponentManagerUtils.h"    // for do_CreateInstance
 #include "nsComposerCommandsUpdater.h"
-#include "nsComponentManagerUtils.h"
-#include "nsIDOMDocument.h"
-#include "nsISelection.h"
+#include "nsDebug.h"                    // for NS_ENSURE_TRUE, etc
+#include "nsError.h"                    // for NS_OK, NS_ERROR_FAILURE, etc
+#include "nsICommandManager.h"          // for nsICommandManager
+#include "nsID.h"                       // for NS_GET_IID, etc
+#include "nsIDOMWindow.h"               // for nsIDOMWindow
+#include "nsIDocShell.h"                // for nsIDocShell
+#include "nsIInterfaceRequestorUtils.h"  // for do_GetInterface
+#include "nsISelection.h"               // for nsISelection
+#include "nsITransactionManager.h"      // for nsITransactionManager
+#include "nsLiteralString.h"            // for NS_LITERAL_STRING
+#include "nsPICommandUpdater.h"         // for nsPICommandUpdater
+#include "nsPIDOMWindow.h"              // for nsPIDOMWindow
 
-#include "nsIInterfaceRequestorUtils.h"
-#include "nsString.h"
-
-#include "nsICommandManager.h"
-
-#include "nsIDocShell.h"
-#include "nsITransactionManager.h"
+class nsIDOMDocument;
+class nsITransaction;
 
 nsComposerCommandsUpdater::nsComposerCommandsUpdater()
 :  mDirtyState(eStateUninitialized)
 ,  mSelectionCollapsed(eStateUninitialized)
 ,  mFirstDoOfFirstUndo(true)
 {
 }
 
--- a/editor/composer/src/nsComposerCommandsUpdater.h
+++ b/editor/composer/src/nsComposerCommandsUpdater.h
@@ -5,27 +5,30 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 
 
 
 #ifndef nsComposerCommandsUpdater_h__
 #define nsComposerCommandsUpdater_h__
 
-#include "nsCOMPtr.h"
-#include "nsITimer.h"
-#include "nsWeakPtr.h"
-#include "nsPICommandUpdater.h"
-
+#include "nsCOMPtr.h"                   // for already_AddRefed, nsCOMPtr
+#include "nsIDocumentStateListener.h"
 #include "nsISelectionListener.h"
-#include "nsIDocumentStateListener.h"
-#include "nsITransactionListener.h"
+#include "nsISupportsImpl.h"            // for NS_DECL_ISUPPORTS
+#include "nsITimer.h"                   // for NS_DECL_NSITIMERCALLBACK, etc
+#include "nsITransactionListener.h"     // for nsITransactionListener
+#include "nsIWeakReferenceUtils.h"      // for nsWeakPtr
+#include "nscore.h"                     // for NS_IMETHOD, nsresult, etc
+#include "prtypes.h"                    // for PRInt8
 
-class nsIDocShell;
+class nsIDOMWindow;
+class nsITransaction;
 class nsITransactionManager;
+class nsPICommandUpdater;
 
 class nsComposerCommandsUpdater : public nsISelectionListener,
                                   public nsIDocumentStateListener,
                                   public nsITransactionListener,
                                   public nsITimerCallback
 {
 public:
 
--- a/editor/composer/src/nsComposerController.cpp
+++ b/editor/composer/src/nsComposerController.cpp
@@ -1,17 +1,21 @@
 /* -*- Mode: C++; 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 "nsIControllerCommandTable.h"
+#include "mozilla/mozalloc.h"           // for operator new
+#include "nsComposerCommands.h"         // for nsStyleUpdatingCommand, etc
 #include "nsComposerController.h"
-#include "nsComposerCommands.h"
-#include "nsGkAtoms.h"
+#include "nsError.h"                    // for NS_OK
+#include "nsGkAtoms.h"                  // for nsGkAtoms, nsGkAtoms::a, etc
+#include "nsIControllerCommandTable.h"  // for nsIControllerCommandTable
+
+class nsIControllerCommand;
 
 #define NS_REGISTER_ONE_COMMAND(_cmdClass, _cmdName)                    \
   {                                                                     \
     _cmdClass* theCmd = new _cmdClass();                                \
     inCommandTable->RegisterCommand(_cmdName,                           \
                        static_cast<nsIControllerCommand *>(theCmd));    \
   }
 
--- a/editor/composer/src/nsComposerController.h
+++ b/editor/composer/src/nsComposerController.h
@@ -2,16 +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 nsComposerController_h__
 #define nsComposerController_h__
 
 
+#include "nscore.h"                     // for nsresult
+
 class nsIControllerCommandTable;
 
 
 // The plaintext editor controller is used for basic text editing and html editing
 // commands in composer
 // The refCon that gets passed to its commands is initially nsIEditingSession, 
 //   and after successfule editor creation it is changed to nsIEditor.
 #define NS_EDITORDOCSTATECONTROLLER_CID \
--- a/editor/composer/src/nsComposerDocumentCommands.cpp
+++ b/editor/composer/src/nsComposerDocumentCommands.cpp
@@ -1,34 +1,40 @@
 /* -*- Mode: C++; 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 "nsIEditor.h"
-#include "nsIEditingSession.h"
-#include "nsIPlaintextEditor.h"
-#include "nsIHTMLEditor.h"
-#include "nsIHTMLObjectResizer.h"
-#include "nsIHTMLInlineTableEditor.h"
+#include "nsAutoPtr.h"                  // for nsRefPtr, getter_AddRefs, etc
+#include "nsCOMPtr.h"                   // for nsCOMPtr, do_QueryInterface, etc
+#include "nsCRT.h"                      // for nsCRT
+#include "nsComposerCommands.h"         // for nsSetDocumentOptionsCommand, etc
+#include "nsDebug.h"                    // for NS_ENSURE_ARG_POINTER, etc
+#include "nsError.h"                    // for NS_ERROR_INVALID_ARG, etc
+#include "nsICommandParams.h"           // for nsICommandParams
+#include "nsIDOMDocument.h"             // for nsIDOMDocument
+#include "nsIDocShell.h"                // for nsIDocShell
+#include "nsIDocument.h"                // for nsIDocument
+#include "nsIEditingSession.h"          // for nsIEditingSession, etc
+#include "nsIEditor.h"                  // for nsIEditor
+#include "nsIHTMLEditor.h"              // for nsIHTMLEditor
+#include "nsIHTMLInlineTableEditor.h"   // for nsIHTMLInlineTableEditor
+#include "nsIHTMLObjectResizer.h"       // for nsIHTMLObjectResizer
+#include "nsIPlaintextEditor.h"         // for nsIPlaintextEditor, etc
+#include "nsIPresShell.h"               // for nsIPresShell
+#include "nsISelectionController.h"     // for nsISelectionController
+#include "nsISupportsImpl.h"            // for nsPresContext::Release
+#include "nsISupportsUtils.h"           // for NS_IF_ADDREF
+#include "nsIURI.h"                     // for nsIURI
+#include "nsPresContext.h"              // for nsPresContext
+#include "nscore.h"                     // for NS_IMETHODIMP, nsresult, etc
+#include "prtypes.h"                    // for PRUint32, PRInt32
 
-#include "nsIDOMDocument.h"
-#include "nsIDocument.h"
-#include "nsISelectionController.h"
-#include "nsIPresShell.h"
-#include "nsPresContext.h"
-#include "nsIDocShell.h"
-#include "nsIURI.h"
-
-#include "nsCOMPtr.h"
-
-#include "nsComposerCommands.h"
-#include "nsICommandParams.h"
-#include "nsCRT.h"
+class nsISupports;
 
 //defines
 #define STATE_ENABLED  "state_enabled"
 #define STATE_ALL "state_all"
 #define STATE_ATTRIBUTE "state_attribute"
 #define STATE_DATA "state_data"
 
 static
--- a/editor/composer/src/nsComposerRegistration.cpp
+++ b/editor/composer/src/nsComposerRegistration.cpp
@@ -1,24 +1,36 @@
 /* -*- Mode: C++; 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 "mozilla/ModuleUtils.h"
+#include <stddef.h>                     // for NULL
 
-#include "nsEditingSession.h"       // for the CID
-#include "nsComposerController.h"   // for the CID
-#include "nsEditorSpellCheck.h"     // for the CID
-#include "nsComposeTxtSrvFilter.h"
-#include "nsIController.h"
-#include "nsIControllerContext.h"
-#include "nsIControllerCommandTable.h"
+#include "mozilla/Module.h"             // for Module, Module::CIDEntry, etc
+#include "mozilla/ModuleUtils.h"
+#include "mozilla/mozalloc.h"           // for operator new
+#include "nsCOMPtr.h"                   // for nsCOMPtr, getter_AddRefs, etc
+#include "nsComponentManagerUtils.h"    // for do_CreateInstance
+#include "nsComposeTxtSrvFilter.h"      // for nsComposeTxtSrvFilter, etc
+#include "nsComposerController.h"       // for nsComposerController, etc
+#include "nsDebug.h"                    // for NS_ENSURE_SUCCESS
+#include "nsEditingSession.h"           // for NS_EDITINGSESSION_CID, etc
+#include "nsEditorSpellCheck.h"         // for NS_EDITORSPELLCHECK_CID, etc
+#include "nsError.h"                    // for NS_ERROR_NO_AGGREGATION, etc
+#include "nsIController.h"              // for nsIController
+#include "nsIControllerCommandTable.h"  // for nsIControllerCommandTable, etc
+#include "nsIControllerContext.h"       // for nsIControllerContext
+#include "nsID.h"                       // for NS_DEFINE_NAMED_CID, etc
+#include "nsISupportsImpl.h"
+#include "nsISupportsUtils.h"           // for NS_ADDREF, NS_RELEASE
+#include "nsServiceManagerUtils.h"      // for do_GetService
+#include "nscore.h"                     // for nsresult
 
-#include "nsServiceManagerUtils.h"
+class nsISupports;
 
 #define NS_HTMLEDITOR_COMMANDTABLE_CID \
 { 0x13e50d8d, 0x9cee, 0x4ad1, { 0xa3, 0xa2, 0x4a, 0x44, 0x2f, 0xdf, 0x7d, 0xfa } }
 
 #define NS_HTMLEDITOR_DOCSTATE_COMMANDTABLE_CID \
 { 0xa33982d3, 0x1adf, 0x4162, { 0x99, 0x41, 0xf7, 0x34, 0xbc, 0x45, 0xe4, 0xed } }
 
 
--- a/editor/composer/src/nsEditingSession.cpp
+++ b/editor/composer/src/nsEditingSession.cpp
@@ -1,57 +1,61 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=2 sw=2 et tw=78: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsPIDOMWindow.h"
-#include "nsIDOMWindowUtils.h"
-#include "nsIDOMHTMLDocument.h"
-#include "nsIDocument.h"
-#include "nsIHTMLDocument.h"
-#include "nsIDOMDocument.h"
-#include "nsIURI.h"
-#include "nsISelectionPrivate.h"
-#include "nsITransactionManager.h"
-
-#include "nsIEditorDocShell.h"
-#include "nsIDocShell.h"
-
-#include "nsIChannel.h"
-#include "nsIWebProgress.h"
-#include "nsIWebNavigation.h"
-#include "nsIRefreshURI.h"
+#include <string.h>                     // for NULL, strcmp
 
-#include "nsIControllers.h"
-#include "nsIController.h"
-#include "nsIControllerContext.h"
-#include "nsICommandManager.h"
-#include "nsPICommandUpdater.h"
-
-#include "nsIPresShell.h"
-
-#include "nsComposerCommandsUpdater.h"
+#include "imgIContainer.h"              // for imgIContainer, etc
+#include "mozFlushType.h"               // for mozFlushType::Flush_Frames
+#include "mozilla/mozalloc.h"           // for operator new
+#include "nsAString.h"
+#include "nsComponentManagerUtils.h"    // for do_CreateInstance
+#include "nsComposerCommandsUpdater.h"  // for nsComposerCommandsUpdater
+#include "nsDebug.h"                    // for NS_ENSURE_SUCCESS, etc
 #include "nsEditingSession.h"
+#include "nsError.h"                    // for NS_ERROR_FAILURE, NS_OK, etc
+#include "nsIChannel.h"                 // for nsIChannel
+#include "nsICommandManager.h"          // for nsICommandManager
+#include "nsIContentViewer.h"           // for nsIContentViewer
+#include "nsIController.h"              // for nsIController
+#include "nsIControllerContext.h"       // for nsIControllerContext
+#include "nsIControllers.h"             // for nsIControllers
+#include "nsID.h"                       // for NS_GET_IID, etc
+#include "nsIDOMDocument.h"             // for nsIDOMDocument
+#include "nsIDOMHTMLDocument.h"         // for nsIDOMHTMLDocument
+#include "nsIDOMWindow.h"               // for nsIDOMWindow
+#include "nsIDOMWindowUtils.h"          // for nsIDOMWindowUtils
+#include "nsIDocShell.h"                // for nsIDocShell
+#include "nsIDocument.h"                // for nsIDocument
+#include "nsIDocumentStateListener.h"
+#include "nsIEditor.h"                  // for nsIEditor
+#include "nsIEditorDocShell.h"          // for nsIEditorDocShell
+#include "nsIHTMLDocument.h"            // for nsIHTMLDocument, etc
+#include "nsIInterfaceRequestorUtils.h"  // for do_GetInterface
+#include "nsIPlaintextEditor.h"         // for nsIPlaintextEditor, etc
+#include "nsIRefreshURI.h"              // for nsIRefreshURI
+#include "nsIRequest.h"                 // for nsIRequest
+#include "nsISelection.h"               // for nsISelection
+#include "nsISelectionPrivate.h"        // for nsISelectionPrivate
+#include "nsITimer.h"                   // for nsITimer, etc
+#include "nsITransactionManager.h"      // for nsITransactionManager
+#include "nsIWeakReference.h"           // for nsISupportsWeakReference, etc
+#include "nsIWebNavigation.h"           // for nsIWebNavigation
+#include "nsIWebProgress.h"             // for nsIWebProgress, etc
+#include "nsLiteralString.h"            // for NS_LITERAL_STRING
+#include "nsPICommandUpdater.h"         // for nsPICommandUpdater
+#include "nsPIDOMWindow.h"              // for nsPIDOMWindow
+#include "nsReadableUtils.h"            // for AppendUTF16toUTF8
+#include "nsStringFwd.h"                // for nsAFlatString
 
-#include "nsComponentManagerUtils.h"
-#include "nsIInterfaceRequestorUtils.h"
-
-#include "nsIContentViewer.h"
-#include "nsISelectionController.h"
-#include "nsIPlaintextEditor.h"
-#include "nsIEditor.h"
-
-#include "nsIScriptContext.h"
-#include "imgIContainer.h"
-
-#if DEBUG
-//#define NOISY_DOC_LOADING  1
-#endif
+class nsISupports;
+class nsIURI;
 
 /*---------------------------------------------------------------------------
 
   nsEditingSession
 
 ----------------------------------------------------------------------------*/
 nsEditingSession::nsEditingSession()
 : mDoneSetup(false)
--- a/editor/composer/src/nsEditingSession.h
+++ b/editor/composer/src/nsEditingSession.h
@@ -3,44 +3,52 @@
  * 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 nsEditingSession_h__
 #define nsEditingSession_h__
 
 
 #ifndef nsWeakReference_h__
-#include "nsWeakReference.h"
+#include "nsWeakReference.h"            // for nsSupportsWeakReference, etc
 #endif
 
-#include "nsITimer.h"
-#include "nsAutoPtr.h"
+#include "nsAutoPtr.h"                  // for nsRefPtr
+#include "nsCOMPtr.h"                   // for nsCOMPtr
+#include "nsISupportsImpl.h"            // for NS_DECL_ISUPPORTS
+#include "nsIWeakReferenceUtils.h"      // for nsWeakPtr
+#include "nsWeakReference.h"            // for nsSupportsWeakReference, etc
+#include "nscore.h"                     // for nsresult
+#include "prtypes.h"                    // for PRUint32, PRUint16
 
 #ifndef __gen_nsIWebProgressListener_h__
 #include "nsIWebProgressListener.h"
 #endif
 
 #ifndef __gen_nsIEditingSession_h__
-#include "nsIEditingSession.h"
+#include "nsIEditingSession.h"          // for NS_DECL_NSIEDITINGSESSION, etc
 #endif
 
-#include "nsString.h"
+#include "nsString.h"                   // for nsCString
+
+class nsIDOMWindow;
+class nsISupports;
+class nsITimer;
 
 #define NS_EDITINGSESSION_CID                            \
 { 0xbc26ff01, 0xf2bd, 0x11d4, { 0xa7, 0x3c, 0xe5, 0xa4, 0xb5, 0xa8, 0xbd, 0xfc } }
 
 
-class nsIWebProgress;
-class nsIDocShell;
-class nsIEditorDocShell;
+class nsComposerCommandsUpdater;
 class nsIChannel;
+class nsIControllers;
+class nsIDocShell;
 class nsIEditor;
-class nsIControllers;
-
-class nsComposerCommandsUpdater;
+class nsIEditorDocShell;
+class nsIWebProgress;
 
 class nsEditingSession : public nsIEditingSession,
                          public nsIWebProgressListener,
                          public nsSupportsWeakReference
 {
 public:
 
                   nsEditingSession();
--- a/editor/composer/src/nsEditorSpellCheck.cpp
+++ b/editor/composer/src/nsEditorSpellCheck.cpp
@@ -1,36 +1,50 @@
 /* -*- Mode: C++; 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 "nsEditorSpellCheck.h"
-
-#include "nsStyleUtil.h"
-#include "nsIContent.h"
-#include "nsIDOMElement.h"
-#include "nsITextServicesDocument.h"
-#include "nsISpellChecker.h"
-#include "nsISelection.h"
-#include "nsIDOMRange.h"
-#include "nsIEditor.h"
-#include "nsIHTMLEditor.h"
+#include <stdlib.h>                     // for getenv
 
-#include "nsIComponentManager.h"
-#include "nsIContentPrefService.h"
-#include "nsServiceManagerUtils.h"
-#include "nsIChromeRegistry.h"
-#include "nsString.h"
-#include "nsReadableUtils.h"
-#include "nsITextServicesFilter.h"
-#include "nsUnicharUtils.h"
-#include "mozilla/Services.h"
-#include "mozilla/Preferences.h"
-#include "mozilla/dom/Element.h"
+#include "mozilla/Attributes.h"         // for MOZ_FINAL
+#include "mozilla/Preferences.h"        // for Preferences
+#include "mozilla/Services.h"           // for GetXULChromeRegistryService
+#include "mozilla/dom/Element.h"        // for Element
+#include "mozilla/mozalloc.h"           // for operator delete, etc
+#include "nsAString.h"                  // for nsAString_internal::IsEmpty, etc
+#include "nsComponentManagerUtils.h"    // for do_CreateInstance
+#include "nsDebug.h"                    // for NS_ENSURE_TRUE, etc
+#include "nsDependentSubstring.h"       // for Substring
+#include "nsEditorSpellCheck.h"
+#include "nsError.h"                    // for NS_ERROR_NOT_INITIALIZED, etc
+#include "nsIChromeRegistry.h"          // for nsIXULChromeRegistry
+#include "nsIContent.h"                 // for nsIContent
+#include "nsIContentPrefService.h"      // for nsIContentPrefService, etc
+#include "nsIDOMDocument.h"             // for nsIDOMDocument
+#include "nsIDOMElement.h"              // for nsIDOMElement
+#include "nsIDOMRange.h"                // for nsIDOMRange
+#include "nsIDocument.h"                // for nsIDocument
+#include "nsIEditor.h"                  // for nsIEditor
+#include "nsIHTMLEditor.h"              // for nsIHTMLEditor
+#include "nsISelection.h"               // for nsISelection
+#include "nsISpellChecker.h"            // for nsISpellChecker, etc
+#include "nsISupportsBase.h"            // for nsISupports
+#include "nsISupportsUtils.h"           // for NS_ADDREF
+#include "nsITextServicesDocument.h"    // for nsITextServicesDocument
+#include "nsITextServicesFilter.h"      // for nsITextServicesFilter
+#include "nsIURI.h"                     // for nsIURI
+#include "nsIVariant.h"                 // for nsIWritableVariant, etc
+#include "nsLiteralString.h"            // for NS_LITERAL_STRING, etc
+#include "nsMemory.h"                   // for nsMemory
+#include "nsReadableUtils.h"            // for ToNewUnicode, EmptyString, etc
+#include "nsServiceManagerUtils.h"      // for do_GetService
+#include "nsString.h"                   // for nsAutoString, nsString, etc
+#include "nsStringFwd.h"                // for nsAFlatString
+#include "nsStyleUtil.h"                // for nsStyleUtil
 
 using namespace mozilla;
 
 class UpdateDictionnaryHolder {
   private:
     nsEditorSpellCheck* mSpellCheck;
   public:
     UpdateDictionnaryHolder(nsEditorSpellCheck* esc): mSpellCheck(esc) {
--- a/editor/composer/src/nsEditorSpellCheck.h
+++ b/editor/composer/src/nsEditorSpellCheck.h
@@ -2,23 +2,28 @@
 /* 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 nsEditorSpellCheck_h___
 #define nsEditorSpellCheck_h___
 
 
-#include "nsIEditorSpellCheck.h"
-#include "nsISpellChecker.h"
-#include "nsIURI.h"
-#include "nsWeakReference.h"
-#include "nsCOMPtr.h"
+#include "nsCOMPtr.h"                   // for nsCOMPtr
 #include "nsCycleCollectionParticipant.h"
-#include "nsDataHashtable.h"
+#include "nsIEditorSpellCheck.h"        // for NS_DECL_NSIEDITORSPELLCHECK, etc
+#include "nsISupportsImpl.h"
+#include "nsString.h"                   // for nsString
+#include "nsTArray.h"                   // for nsTArray
+#include "nscore.h"                     // for nsresult
+#include "prtypes.h"                    // for PRInt32
+
+class nsIEditor;
+class nsISpellChecker;
+class nsITextServicesFilter;
 
 #define NS_EDITORSPELLCHECK_CID                     \
 { /* {75656ad9-bd13-4c5d-939a-ec6351eea0cc} */        \
     0x75656ad9, 0xbd13, 0x4c5d,                       \
     { 0x93, 0x9a, 0xec, 0x63, 0x51, 0xee, 0xa0, 0xcc }\
 }
 
 class LastDictionary;
--- a/editor/libeditor/base/ChangeAttributeTxn.cpp
+++ b/editor/libeditor/base/ChangeAttributeTxn.cpp
@@ -1,15 +1,20 @@
 /* -*- Mode: C++; 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 "ChangeAttributeTxn.h"
-#include "nsIDOMElement.h"
+#include "nsAString.h"
+#include "nsDebug.h"                    // for NS_ASSERTION
+#include "nsError.h"                    // for NS_ERROR_NOT_INITIALIZED, etc
+#include "nsIDOMElement.h"              // for nsIDOMElement
+#include "nsIEditor.h"                  // for nsIEditor
+#include "nsString.h"                   // for nsString
 
 ChangeAttributeTxn::ChangeAttributeTxn()
   : EditTxn()
 {
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(ChangeAttributeTxn)
 
--- a/editor/libeditor/base/ChangeAttributeTxn.h
+++ b/editor/libeditor/base/ChangeAttributeTxn.h
@@ -3,18 +3,23 @@
  * 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 ChangeAttributeTxn_h__
 #define ChangeAttributeTxn_h__
 
 #include "EditTxn.h"
 #include "nsCOMPtr.h"
+#include "nsCycleCollectionParticipant.h"
 #include "nsIDOMElement.h"
-#include "nsIEditor.h"
+#include "nsISupportsImpl.h"
+#include "nsString.h"
+#include "nscore.h"
+
+class nsIEditor;
 
 /**
  * A transaction that changes an attribute of a content node. 
  * This transaction covers add, remove, and change attribute.
  */
 class ChangeAttributeTxn : public EditTxn
 {
 public:
--- a/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp
+++ b/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp
@@ -1,22 +1,33 @@
 /* -*- Mode: C++; 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 "ChangeCSSInlineStyleTxn.h"
-#include "nsIDOMElement.h"
-#include "nsIDOMCSSStyleDeclaration.h"
+#include "nsAString.h"                  // for nsAString_internal::Append, etc
+#include "nsCRT.h"                      // for nsCRT
+#include "nsDebug.h"                    // for NS_ENSURE_SUCCESS, etc
+#include "nsError.h"                    // for NS_ERROR_NULL_POINTER, etc
+#include "nsGkAtoms.h"                  // for nsGkAtoms, etc
+#include "nsIAtom.h"                    // for nsIAtom
+#include "nsIDOMCSSStyleDeclaration.h"  // for nsIDOMCSSStyleDeclaration
+#include "nsIDOMElement.h"              // for nsIDOMElement
 #include "nsIDOMElementCSSInlineStyle.h"
-#include "nsReadableUtils.h"
+#include "nsISupportsImpl.h"            // for EditTxn::QueryInterface, etc
+#include "nsISupportsUtils.h"           // for NS_ADDREF
+#include "nsLiteralString.h"            // for NS_LITERAL_STRING, etc
+#include "nsReadableUtils.h"            // for ToNewUnicode
+#include "nsString.h"                   // for nsAutoString, nsString, etc
 #include "nsUnicharUtils.h"
-#include "nsCRT.h"
-#include "nsIAtom.h"
-#include "nsGkAtoms.h"
+#include "nsXPCOM.h"                    // for NS_Free
+#include "prtypes.h"                    // for PRUnichar, PRUint32
+
+class nsIEditor;
 
 #define kNullCh (PRUnichar('\0'))
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(ChangeCSSInlineStyleTxn)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(ChangeCSSInlineStyleTxn,
                                                 EditTxn)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mElement)
--- a/editor/libeditor/base/ChangeCSSInlineStyleTxn.h
+++ b/editor/libeditor/base/ChangeCSSInlineStyleTxn.h
@@ -3,18 +3,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 ChangeCSSInlineStyleTxn_h__
 #define ChangeCSSInlineStyleTxn_h__
 
 #include "EditTxn.h"
 #include "nsCOMPtr.h"
+#include "nsCycleCollectionParticipant.h"
+#include "nsID.h"
 #include "nsIDOMElement.h"
-#include "nsIEditor.h"
+#include "nsString.h"
+#include "nscore.h"
+
+class nsIAtom;
+class nsIEditor;
 
 /**
  * A transaction that changes the value of a CSS inline style of a content node. 
  * This transaction covers add, remove, and change a property's value.
  */
 class ChangeCSSInlineStyleTxn : public EditTxn
 {
 public:
--- a/editor/libeditor/base/CreateElementTxn.cpp
+++ b/editor/libeditor/base/CreateElementTxn.cpp
@@ -1,21 +1,32 @@
 /* -*- Mode: C++; 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 <stdio.h>
+
 #include "CreateElementTxn.h"
+#include "mozilla/dom/Element.h"
+#include "nsAlgorithm.h"
+#include "nsDebug.h"
 #include "nsEditor.h"
-#include "nsIDOMNodeList.h"
+#include "nsError.h"
+#include "nsIContent.h"
+#include "nsIDOMCharacterData.h"
+#include "nsIEditor.h"
+#include "nsINode.h"
 #include "nsISelection.h"
-#include "nsIDOMElement.h"
+#include "nsISupportsUtils.h"
+#include "nsMemory.h"
 #include "nsReadableUtils.h"
-
-#include "mozilla/dom/Element.h"
+#include "nsStringFwd.h"
+#include "nsString.h"
+#include "nsAString.h"
 
 #ifdef DEBUG
 static bool gNoisy = false;
 #endif
 
 using namespace mozilla;
 
 CreateElementTxn::CreateElementTxn()
--- a/editor/libeditor/base/CreateElementTxn.h
+++ b/editor/libeditor/base/CreateElementTxn.h
@@ -2,19 +2,25 @@
 /* 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 CreateElementTxn_h__
 #define CreateElementTxn_h__
 
 #include "EditTxn.h"
-#include "nsEditor.h"
+#include "nsCOMPtr.h"
+#include "nsCycleCollectionParticipant.h"
 #include "nsIDOMNode.h"
-#include "nsCOMPtr.h"
+#include "nsISupportsImpl.h"
+#include "nsString.h"
+#include "nscore.h"
+#include "prtypes.h"
+
+class nsEditor;
 
 /**
  * A transaction that creates a new node in the content tree.
  */
 class CreateElementTxn : public EditTxn
 {
 public:
   enum { eAppend=-1 };
--- a/editor/libeditor/base/DeleteNodeTxn.cpp
+++ b/editor/libeditor/base/DeleteNodeTxn.cpp
@@ -1,16 +1,19 @@
 /* -*- Mode: C++; 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 "DeleteNodeTxn.h"
+#include "nsDebug.h"
+#include "nsEditor.h"
+#include "nsError.h"
 #include "nsSelectionState.h" // nsRangeUpdater
-#include "nsEditor.h"
+#include "nsAString.h"
 
 
 DeleteNodeTxn::DeleteNodeTxn()
   : EditTxn(), mNode(), mParent(), mRefNode(), mRangeUpdater(nsnull)
 {
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(DeleteNodeTxn)
--- a/editor/libeditor/base/DeleteNodeTxn.h
+++ b/editor/libeditor/base/DeleteNodeTxn.h
@@ -2,22 +2,25 @@
 /* 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 DeleteNodeTxn_h__
 #define DeleteNodeTxn_h__
 
 #include "EditTxn.h"
-
+#include "nsCOMPtr.h"
+#include "nsCycleCollectionParticipant.h"
 #include "nsIContent.h"
-#include "nsCOMPtr.h"
+#include "nsINode.h"
+#include "nsISupportsImpl.h"
+#include "nscore.h"
 
+class nsEditor;
 class nsRangeUpdater;
-class nsEditor;
 
 /**
  * A transaction that deletes a single element
  */
 class DeleteNodeTxn : public EditTxn
 {
 public:
   /** initialize the transaction.
--- a/editor/libeditor/base/DeleteRangeTxn.cpp
+++ b/editor/libeditor/base/DeleteRangeTxn.cpp
@@ -1,20 +1,30 @@
 /* -*- Mode: C++; 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 "DeleteNodeTxn.h"
 #include "DeleteRangeTxn.h"
 #include "DeleteTextTxn.h"
-#include "DeleteNodeTxn.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/Selection.h"
+#include "mozilla/mozalloc.h"
+#include "nsCOMPtr.h"
+#include "nsDebug.h"
+#include "nsEditor.h"
+#include "nsError.h"
+#include "nsIContent.h"
 #include "nsIContentIterator.h"
-#include "nsComponentManagerUtils.h"
+#include "nsIDOMCharacterData.h"
+#include "nsINode.h"
+#include "nsAString.h"
 
-#include "mozilla/Util.h"
+class nsIDOMRange;
 
 using namespace mozilla;
 
 // note that aEditor is not refcounted
 DeleteRangeTxn::DeleteRangeTxn()
   : EditAggregateTxn(),
     mRange(),
     mEditor(nsnull),
--- a/editor/libeditor/base/DeleteRangeTxn.h
+++ b/editor/libeditor/base/DeleteRangeTxn.h
@@ -2,20 +2,28 @@
 /* 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 DeleteRangeTxn_h__
 #define DeleteRangeTxn_h__
 
 #include "EditAggregateTxn.h"
+#include "EditTxn.h"
+#include "nsAutoPtr.h"
+#include "nsCycleCollectionParticipant.h"
+#include "nsID.h"
+#include "nsIEditor.h"
+#include "nsISupportsImpl.h"
 #include "nsRange.h"
-#include "nsEditor.h"
-#include "nsCOMPtr.h"
+#include "nscore.h"
+#include "prtypes.h"
 
+class nsEditor;
+class nsINode;
 class nsRangeUpdater;
 
 /**
  * A transaction that deletes an entire range in the content tree
  */
 class DeleteRangeTxn : public EditAggregateTxn
 {
 public:
--- a/editor/libeditor/base/DeleteTextTxn.cpp
+++ b/editor/libeditor/base/DeleteTextTxn.cpp
@@ -1,17 +1,25 @@
 /* -*- Mode: C++; 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 "DeleteTextTxn.h"
+#include "mozilla/Assertions.h"
 #include "mozilla/Selection.h"
+#include "nsAutoPtr.h"
+#include "nsDebug.h"
+#include "nsEditor.h"
+#include "nsError.h"
+#include "nsIEditor.h"
+#include "nsISelection.h"
+#include "nsISupportsImpl.h"
 #include "nsSelectionState.h"
-#include "nsEditor.h"
+#include "nsAString.h"
 
 using namespace mozilla;
 
 DeleteTextTxn::DeleteTextTxn() :
   EditTxn(),
   mEditor(nsnull),
   mCharData(),
   mOffset(0),
--- a/editor/libeditor/base/DeleteTextTxn.h
+++ b/editor/libeditor/base/DeleteTextTxn.h
@@ -2,18 +2,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 DeleteTextTxn_h__
 #define DeleteTextTxn_h__
 
 #include "EditTxn.h"
+#include "nsCOMPtr.h"
+#include "nsCycleCollectionParticipant.h"
+#include "nsID.h"
 #include "nsIDOMCharacterData.h"
-#include "nsCOMPtr.h"
+#include "nsString.h"
+#include "nscore.h"
+#include "prtypes.h"
 
 class nsEditor;
 class nsRangeUpdater;
 
 /**
  * A transaction that removes text from a content node.
  */
 class DeleteTextTxn : public EditTxn
--- a/editor/libeditor/base/EditAggregateTxn.cpp
+++ b/editor/libeditor/base/EditAggregateTxn.cpp
@@ -1,15 +1,21 @@
 /* -*- Mode: C++; 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 "EditAggregateTxn.h"
-#include "nsCOMPtr.h"
+#include "nsAString.h"
+#include "nsCOMPtr.h"                   // for nsCOMPtr
+#include "nsError.h"                    // for NS_OK, etc
+#include "nsISupportsUtils.h"           // for NS_ADDREF
+#include "nsITransaction.h"             // for nsITransaction
+#include "nsString.h"                   // for nsAutoString
+#include "prtypes.h"                    // for PRUint32
 
 EditAggregateTxn::EditAggregateTxn()
   : EditTxn()
 {
 }
 NS_IMPL_CYCLE_COLLECTION_CLASS(EditAggregateTxn)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(EditAggregateTxn, EditTxn)
--- a/editor/libeditor/base/EditAggregateTxn.h
+++ b/editor/libeditor/base/EditAggregateTxn.h
@@ -2,20 +2,25 @@
 /* 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 EditAggregateTxn_h__
 #define EditAggregateTxn_h__
 
 #include "EditTxn.h"
-#include "nsIAtom.h"
+#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
+#include "nsCycleCollectionParticipant.h"
+#include "nsIAtom.h"
+#include "nsISupportsImpl.h"
 #include "nsTArray.h"
-#include "nsAutoPtr.h"
+#include "nscore.h"
+
+class nsITransaction;
 
 /**
  * base class for all document editing transactions that require aggregation.
  * provides a list of child transactions.
  */
 class EditAggregateTxn : public EditTxn
 {
 public:
--- a/editor/libeditor/base/EditTxn.cpp
+++ b/editor/libeditor/base/EditTxn.cpp
@@ -1,14 +1,16 @@
 /* -*- Mode: C++; 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 "EditTxn.h"
+#include "nsError.h"
+#include "nsISupportsBase.h"
 
 NS_IMPL_CYCLE_COLLECTION_0(EditTxn)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(EditTxn)
   NS_INTERFACE_MAP_ENTRY(nsITransaction)
   NS_INTERFACE_MAP_ENTRY(nsPIEditorTransaction)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsITransaction)
 NS_INTERFACE_MAP_END
--- a/editor/libeditor/base/EditTxn.h
+++ b/editor/libeditor/base/EditTxn.h
@@ -1,20 +1,21 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef EditTxn_h__
 #define EditTxn_h__
 
+#include "nsCycleCollectionParticipant.h"
+#include "nsISupportsImpl.h"
 #include "nsITransaction.h"
-#include "nsString.h"
 #include "nsPIEditorTransaction.h"
-#include "nsCycleCollectionParticipant.h"
+#include "nscore.h"
 
 /**
  * Base class for all document editing transactions.
  */
 class EditTxn : public nsITransaction,
                 public nsPIEditorTransaction
 {
 public:
--- a/editor/libeditor/base/IMETextTxn.cpp
+++ b/editor/libeditor/base/IMETextTxn.cpp
@@ -1,22 +1,33 @@
 /* -*- Mode: C++; 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 "IMETextTxn.h"
-#include "nsIDOMCharacterData.h"
-#include "nsRange.h"
-#include "nsIPrivateTextRange.h"
-#include "nsISelection.h"
-#include "nsISelectionPrivate.h"
-#include "nsISelectionController.h"
-#include "nsComponentManagerUtils.h"
-#include "nsIEditor.h"
+#include "mozilla/mozalloc.h"           // for operator new
+#include "nsAString.h"                  // for nsAString_internal::Length, etc
+#include "nsAutoPtr.h"                  // for nsRefPtr
+#include "nsDebug.h"                    // for NS_ASSERTION, etc
+#include "nsError.h"                    // for NS_SUCCEEDED, NS_FAILED, etc
+#include "nsGUIEvent.h"                 // for nsTextRangeStyle
+#include "nsIDOMCharacterData.h"        // for nsIDOMCharacterData
+#include "nsIDOMRange.h"                // for nsRange::SetEnd, etc
+#include "nsIEditor.h"                  // for nsIEditor
+#include "nsIPresShell.h"               // for SelectionType
+#include "nsIPrivateTextRange.h"        // for nsIPrivateTextRange, etc
+#include "nsISelection.h"               // for nsISelection
+#include "nsISelectionController.h"     // for nsISelectionController, etc
+#include "nsISelectionPrivate.h"        // for nsISelectionPrivate
+#include "nsISupportsImpl.h"            // for nsRange::AddRef, etc
+#include "nsISupportsUtils.h"           // for NS_ADDREF_THIS, NS_RELEASE
+#include "nsITransaction.h"             // for nsITransaction
+#include "nsRange.h"                    // for nsRange
+#include "nsString.h"                   // for nsString
 
 // #define DEBUG_IMETXN
 
 IMETextTxn::IMETextTxn()
   : EditTxn()
 {
 }
 
--- a/editor/libeditor/base/IMETextTxn.h
+++ b/editor/libeditor/base/IMETextTxn.h
@@ -2,21 +2,26 @@
 /* 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 IMETextTxn_h__
 #define IMETextTxn_h__
 
 #include "EditTxn.h"
+#include "nsCOMPtr.h"
+#include "nsCycleCollectionParticipant.h"
+#include "nsID.h"
 #include "nsIDOMCharacterData.h"
 #include "nsIPrivateTextRange.h"
-#include "nsCOMPtr.h"
-#include "nsWeakPtr.h"
-#include "nsIAtom.h"
+#include "nsString.h"
+#include "nscore.h"
+#include "prtypes.h"
+
+class nsITransaction;
 
 // {D4D25721-2813-11d3-9EA3-0060089FE59B}
 #define IME_TEXT_TXN_CID							\
 {0xd4d25721, 0x2813, 0x11d3,						\
 {0x9e, 0xa3, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b }}
 
 
 class nsIEditor;
--- a/editor/libeditor/base/InsertElementTxn.cpp
+++ b/editor/libeditor/base/InsertElementTxn.cpp
@@ -1,18 +1,26 @@
 /* -*- Mode: C++; 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 <stdio.h>                      // for printf
+
 #include "InsertElementTxn.h"
-#include "nsISelection.h"
-#include "nsIContent.h"
-#include "nsIDOMNodeList.h"
-#include "nsReadableUtils.h"
+#include "nsAString.h"
+#include "nsDebug.h"                    // for NS_ENSURE_TRUE, etc
+#include "nsError.h"                    // for NS_ERROR_NULL_POINTER, etc
+#include "nsIContent.h"                 // for nsIContent
+#include "nsIEditor.h"                  // for nsIEditor
+#include "nsINode.h"                    // for nsINode
+#include "nsISelection.h"               // for nsISelection
+#include "nsMemory.h"                   // for nsMemory
+#include "nsReadableUtils.h"            // for ToNewCString
+#include "nsString.h"                   // for nsString
 
 #ifdef DEBUG
 static bool gNoisy = false;
 #endif
 
 
 InsertElementTxn::InsertElementTxn()
   : EditTxn()
--- a/editor/libeditor/base/InsertElementTxn.h
+++ b/editor/libeditor/base/InsertElementTxn.h
@@ -1,20 +1,25 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef InsertElementTxn_h__
 #define InsertElementTxn_h__
 
-#include "EditTxn.h"
-#include "nsIEditor.h"
-#include "nsIDOMNode.h"
-#include "nsCOMPtr.h"
+#include "EditTxn.h"                    // for EditTxn, NS_DECL_EDITTXN
+#include "nsCOMPtr.h"                   // for nsCOMPtr
+#include "nsCycleCollectionParticipant.h"
+#include "nsIDOMNode.h"                 // for nsIDOMNode
+#include "nsISupportsImpl.h"            // for NS_DECL_ISUPPORTS_INHERITED
+#include "nscore.h"                     // for NS_IMETHOD
+#include "prtypes.h"                    // for PRInt32
+
+class nsIEditor;
 
 /**
  * A transaction that inserts a single element
  */
 class InsertElementTxn : public EditTxn
 {
 public:
   /** initialize the transaction.
--- a/editor/libeditor/base/InsertTextTxn.cpp
+++ b/editor/libeditor/base/InsertTextTxn.cpp
@@ -1,17 +1,24 @@
 /* -*- Mode: C++; 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 <stdio.h>                      // for printf
+
 #include "InsertTextTxn.h"
-#include "nsIDOMCharacterData.h"
-#include "nsISelection.h"
-#include "EditAggregateTxn.h"
+#include "nsAString.h"
+#include "nsDebug.h"                    // for NS_ASSERTION, etc
+#include "nsError.h"                    // for NS_OK, etc
+#include "nsIDOMCharacterData.h"        // for nsIDOMCharacterData
+#include "nsIEditor.h"                  // for nsIEditor
+#include "nsISelection.h"               // for nsISelection
+#include "nsISupportsUtils.h"           // for NS_ADDREF_THIS, NS_RELEASE
+#include "nsITransaction.h"             // for nsITransaction
 
 #ifdef DEBUG
 static bool gNoisy = false;
 #endif
 
 InsertTextTxn::InsertTextTxn()
   : EditTxn()
 {
--- a/editor/libeditor/base/InsertTextTxn.h
+++ b/editor/libeditor/base/InsertTextTxn.h
@@ -1,20 +1,29 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef InsertTextTxn_h__
 #define InsertTextTxn_h__
 
-#include "EditTxn.h"
-#include "nsIDOMCharacterData.h"
-#include "nsIEditor.h"
-#include "nsCOMPtr.h"
+#include "EditTxn.h"                    // for EditTxn, NS_DECL_EDITTXN
+#include "nsCOMPtr.h"                   // for nsCOMPtr
+#include "nsCycleCollectionParticipant.h"
+#include "nsID.h"                       // for nsIID
+#include "nsIDOMCharacterData.h"        // for nsIDOMCharacterData
+#include "nsISupportsImpl.h"            // for NS_DECL_ISUPPORTS_INHERITED
+#include "nsString.h"                   // for nsString
+#include "nscore.h"                     // for NS_IMETHOD, nsAString
+#include "prtypes.h"                    // for PRUint32
+
+class nsIEditor;
+class nsITransaction;
+
 
 #define INSERT_TEXT_TXN_CID \
 {/* 93276f00-ab2c-11d2-8f4b-006008159b0c*/ \
 0x93276f00, 0xab2c, 0x11d2, \
 {0x8f, 0xb4, 0x0, 0x60, 0x8, 0x15, 0x9b, 0xc} }
 
 /**
   * A transaction that inserts text into a content node. 
--- a/editor/libeditor/base/JoinElementTxn.cpp
+++ b/editor/libeditor/base/JoinElementTxn.cpp
@@ -1,17 +1,24 @@
 /* -*- Mode: C++; 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 <stdio.h>                      // for printf
+
 #include "JoinElementTxn.h"
-#include "nsEditor.h"
-#include "nsIDOMNodeList.h"
-#include "nsIDOMCharacterData.h"
+#include "nsAString.h"
+#include "nsDebug.h"                    // for NS_ASSERTION, etc
+#include "nsEditor.h"                   // for nsEditor
+#include "nsError.h"                    // for NS_ERROR_NULL_POINTER, etc
+#include "nsIDOMCharacterData.h"        // for nsIDOMCharacterData
+#include "nsIEditor.h"                  // for nsEditor::IsModifiableNode
+#include "nsINode.h"                    // for nsINode
+#include "nsISupportsImpl.h"            // for EditTxn::QueryInterface, etc
 
 #ifdef DEBUG
 static bool gNoisy = false;
 #endif
 
 JoinElementTxn::JoinElementTxn()
   : EditTxn()
 {
--- a/editor/libeditor/base/JoinElementTxn.h
+++ b/editor/libeditor/base/JoinElementTxn.h
@@ -1,20 +1,23 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef JoinElementTxn_h__
 #define JoinElementTxn_h__
 
-#include "EditTxn.h"
-#include "nsIDOMNode.h"
-#include "nsCOMPtr.h"
-#include "nsIEditor.h"
+#include "EditTxn.h"                    // for EditTxn, NS_DECL_EDITTXN
+#include "nsCOMPtr.h"                   // for nsCOMPtr
+#include "nsCycleCollectionParticipant.h"
+#include "nsID.h"                       // for REFNSIID
+#include "nsIDOMNode.h"                 // for nsIDOMNode
+#include "nscore.h"                     // for NS_IMETHOD
+#include "prtypes.h"                    // for PRUint32
 
 class nsEditor;
 
 /**
  * A transaction that joins two elements E1 (left node) and E2 (right node)
  * into a single node E.  
  * The children of E are the children of E1 followed by the children of E2.
  * After DoTransaction() and RedoTransaction(), E1 is removed from the content
--- a/editor/libeditor/base/PlaceholderTxn.cpp
+++ b/editor/libeditor/base/PlaceholderTxn.cpp
@@ -2,16 +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 "PlaceholderTxn.h"
 #include "nsEditor.h"
 #include "IMETextTxn.h"
 #include "nsGkAtoms.h"
+#include "nsISelection.h"
 
 PlaceholderTxn::PlaceholderTxn() :  EditAggregateTxn(), 
                                     mAbsorb(true), 
                                     mForwarding(nsnull),
                                     mIMETextTxn(nsnull),
                                     mCommitted(false),
                                     mStartSel(nsnull),
                                     mEndSel(),
--- a/editor/libeditor/base/SetDocTitleTxn.cpp
+++ b/editor/libeditor/base/SetDocTitleTxn.cpp
@@ -1,20 +1,30 @@
 /* -*- Mode: C++; 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 "SetDocTitleTxn.h"
-#include "nsIDOMNode.h"
-#include "nsIDOMNodeList.h"
-#include "nsIDOMDocument.h"
-#include "nsIDOMText.h"
-#include "nsIDOMElement.h"
-#include "mozilla/dom/Element.h"
+#include "mozilla/dom/Element.h"        // for Element
+#include "nsAString.h"
+#include "nsCOMPtr.h"                   // for nsCOMPtr, getter_AddRefs, etc
+#include "nsDebug.h"                    // for NS_ENSURE_SUCCESS, etc
+#include "nsError.h"                    // for NS_OK, NS_ERROR_FAILURE, etc
+#include "nsIDOMCharacterData.h"        // for nsIDOMCharacterData
+#include "nsIDOMDocument.h"             // for nsIDOMDocument
+#include "nsIDOMElement.h"              // for nsIDOMElement
+#include "nsIDOMNode.h"                 // for nsIDOMNode
+#include "nsIDOMNodeList.h"             // for nsIDOMNodeList
+#include "nsIDOMText.h"                 // for nsIDOMText
+#include "nsIDocument.h"                // for nsIDocument
+#include "nsIEditor.h"                  // for nsIEditor
+#include "nsIHTMLEditor.h"              // for nsIHTMLEditor
+#include "nsLiteralString.h"            // for NS_LITERAL_STRING
+#include "prtypes.h"                    // for PRUint32
 
 using namespace mozilla;
 
 // note that aEditor is not refcounted
 SetDocTitleTxn::SetDocTitleTxn()
   : EditTxn()
 , mIsTransient(false)
 {
--- a/editor/libeditor/base/SetDocTitleTxn.h
+++ b/editor/libeditor/base/SetDocTitleTxn.h
@@ -1,21 +1,21 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef SetDocTitleTxn_h__
 #define SetDocTitleTxn_h__
 
-#include "EditTxn.h"
-#include "nsIEditor.h"
-#include "nsIHTMLEditor.h"
-#include "nsITransaction.h"
-#include "nsCOMPtr.h"
+#include "EditTxn.h"                    // for EditTxn, NS_DECL_EDITTXN
+#include "nsString.h"                   // for nsString
+#include "nscore.h"                     // for NS_IMETHOD, nsAString, etc
+
+class nsIHTMLEditor;
 
 /**
  * A transaction that changes the document's title,
  *  which is a text node under the <title> tag in a page's <head> section
  * provides default concrete behavior for all nsITransaction methods.
  */
 class SetDocTitleTxn : public EditTxn
 {
--- a/editor/libeditor/base/SplitElementTxn.cpp
+++ b/editor/libeditor/base/SplitElementTxn.cpp
@@ -1,18 +1,25 @@
 /* -*- Mode: C++; 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 <stdio.h>                      // for printf
+
 #include "SplitElementTxn.h"
-#include "nsEditor.h"
-#include "nsIDOMNode.h"
-#include "nsISelection.h"
-#include "nsIDOMCharacterData.h"
+#include "nsAString.h"
+#include "nsDebug.h"                    // for NS_ASSERTION, etc
+#include "nsEditor.h"                   // for nsEditor
+#include "nsError.h"                    // for NS_ERROR_NOT_INITIALIZED, etc
+#include "nsIDOMCharacterData.h"        // for nsIDOMCharacterData
+#include "nsIDOMNode.h"                 // for nsIDOMNode
+#include "nsIEditor.h"                  // for nsEditor::DebugDumpContent, etc
+#include "nsISelection.h"               // for nsISelection
+#include "nsISupportsUtils.h"           // for NS_ADDREF
 
 #ifdef DEBUG
 static bool gNoisy = false;
 #endif
 
 
 // note that aEditor is not refcounted
 SplitElementTxn::SplitElementTxn()
--- a/editor/libeditor/base/SplitElementTxn.h
+++ b/editor/libeditor/base/SplitElementTxn.h
@@ -1,20 +1,23 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef SplitElementTxn_h__
 #define SplitElementTxn_h__
 
-#include "EditTxn.h"
-#include "nsIDOMNode.h"
-#include "nsCOMPtr.h"
-#include "nsIEditor.h"
+#include "EditTxn.h"                    // for EditTxn, NS_DECL_EDITTXN
+#include "nsCOMPtr.h"                   // for nsCOMPtr
+#include "nsCycleCollectionParticipant.h"
+#include "nsIDOMNode.h"                 // for nsIDOMNode
+#include "nsISupportsImpl.h"            // for NS_DECL_ISUPPORTS_INHERITED
+#include "nscore.h"                     // for NS_IMETHOD
+#include "prtypes.h"                    // for PRInt32
 
 class nsEditor;
 
 /**
  * A transaction that splits an element E into two identical nodes, E1 and E2
  * with the children of E divided between E1 and E2.
  */
 class SplitElementTxn : public EditTxn
--- a/editor/libeditor/base/nsEditPropertyAtomList.h
+++ b/editor/libeditor/base/nsEditPropertyAtomList.h
@@ -1,12 +1,14 @@
 /* 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/. */
 
+// IWYU pragma: private, include "nsEditProperty.h"
+
 /******
 
   This file contains the list of all editor nsIAtoms and their values
 
   It is designed to be used as inline input to nsEditProperty.cpp *only*
   through the magic of C preprocessing.
 
   All entries must be enclosed in the macro EDITOR_ATOM which will have cruel
--- a/editor/libeditor/base/nsEditRules.h
+++ b/editor/libeditor/base/nsEditRules.h
@@ -6,16 +6,18 @@
 #ifndef nsEditRules_h__
 #define nsEditRules_h__
 
 // FB45AC36-E8F1-44ae-8FB7-466E1BE119B0
 #define NS_IEDITRULES_IID \
 { 0x2cc50d11, 0x9909, 0x433f, \
   { 0xb6, 0xfb, 0x4c, 0xf2, 0x56, 0xe5, 0xe5, 0x71 } }
 
+#include "nsEditor.h"
+
 class nsPlaintextEditor;
 class nsISelection;
 
 /***************************************************************************
  * base for an object to encapsulate any additional info needed to be passed
  * to rules system by the editor
  */
 class nsRulesInfo
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -1,103 +1,132 @@
 /* -*- Mode: C++; 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 "pratom.h"
-#include "nsIDOMDocument.h"
-#include "nsIDOMHTMLElement.h"
-#include "nsIDOMNSEvent.h"
-#include "nsIMEStateManager.h"
-#include "nsFocusManager.h"
-#include "nsUnicharUtils.h"
-#include "nsReadableUtils.h"
-#include "nsIObserverService.h"
-#include "mozilla/Services.h"
+#include <stdio.h>                      // for NULL, stdout
+#include <string.h>                     // for strcmp
+
+#include "ChangeAttributeTxn.h"         // for ChangeAttributeTxn
+#include "CreateElementTxn.h"           // for CreateElementTxn
+#include "DeleteNodeTxn.h"              // for DeleteNodeTxn
+#include "DeleteRangeTxn.h"             // for DeleteRangeTxn
+#include "DeleteTextTxn.h"              // for DeleteTextTxn
+#include "EditAggregateTxn.h"           // for EditAggregateTxn
+#include "EditTxn.h"                    // for EditTxn
+#include "IMETextTxn.h"                 // for IMETextTxn
+#include "InsertElementTxn.h"           // for InsertElementTxn
+#include "InsertTextTxn.h"              // for InsertTextTxn
+#include "JoinElementTxn.h"             // for JoinElementTxn
+#include "PlaceholderTxn.h"             // for PlaceholderTxn
+#include "SplitElementTxn.h"            // for SplitElementTxn
+#include "mozFlushType.h"               // for mozFlushType::Flush_Frames
 #include "mozISpellCheckingEngine.h"
-#include "nsIEditorSpellCheck.h"
-#include "mozInlineSpellChecker.h"
-
-#include "nsIDOMText.h"
-#include "nsIDOMElement.h"
-#include "nsIDOMAttr.h"
-#include "nsIDOMNode.h"
-#include "nsIDOMDocumentFragment.h"
-#include "nsIDOMNamedNodeMap.h"
-#include "nsIDOMNodeList.h"
-#include "nsIDOMRange.h"
-#include "nsIDOMHTMLBRElement.h"
-#include "nsIDocument.h"
+#include "mozInlineSpellChecker.h"      // for mozInlineSpellChecker
+#include "mozilla/FunctionTimer.h"      // for NS_TIME_FUNCTION
+#include "mozilla/Preferences.h"        // for Preferences
+#include "mozilla/Selection.h"          // for Selection, etc
+#include "mozilla/Services.h"           // for GetObserverService
+#include "mozilla/Util.h"               // for DebugOnly
+#include "mozilla/dom/Element.h"        // for Element, nsINode::AsElement
+#include "mozilla/mozalloc.h"           // for operator new, etc
+#include "nsAString.h"                  // for nsAString_internal::Length, etc
+#include "nsCCUncollectableMarker.h"    // for nsCCUncollectableMarker
+#include "nsCaret.h"                    // for nsCaret, StCaretHider
+#include "nsCaseTreatment.h"
+#include "nsCharTraits.h"               // for NS_IS_HIGH_SURROGATE, etc
+#include "nsComponentManagerUtils.h"    // for do_CreateInstance
+#include "nsComputedDOMStyle.h"         // for nsComputedDOMStyle
+#include "nsContentUtils.h"             // for nsContentUtils
+#include "nsDOMString.h"                // for DOMStringIsNull
+#include "nsDebug.h"                    // for NS_ENSURE_TRUE, etc
+#include "nsEditProperty.h"             // for nsEditProperty, etc
+#include "nsEditor.h"
+#include "nsEditorEventListener.h"      // for nsEditorEventListener
+#include "nsEditorUtils.h"              // for nsAutoRules, etc
+#include "nsError.h"                    // for NS_OK, etc
+#include "nsEvent.h"                    // for nsEventStatus, etc
+#include "nsFocusManager.h"             // for nsFocusManager
+#include "nsFrameSelection.h"           // for nsFrameSelection
+#include "nsGUIEvent.h"                 // for nsKeyEvent, nsEvent, etc
+#include "nsGkAtoms.h"                  // for nsGkAtoms, nsGkAtoms::dir
+#include "nsIAbsorbingTransaction.h"    // for nsIAbsorbingTransaction
+#include "nsIAtom.h"                    // for nsIAtom
+#include "nsIContent.h"                 // for nsIContent
+#include "nsIDOMAttr.h"                 // for nsIDOMAttr
+#include "nsIDOMCharacterData.h"        // for nsIDOMCharacterData
+#include "nsIDOMDocument.h"             // for nsIDOMDocument
+#include "nsIDOMElement.h"              // for nsIDOMElement
+#include "nsIDOMEvent.h"                // for nsIDOMEvent
+#include "nsIDOMEventListener.h"        // for nsIDOMEventListener
+#include "nsIDOMEventTarget.h"          // for nsIDOMEventTarget
+#include "nsIDOMHTMLElement.h"          // for nsIDOMHTMLElement
+#include "nsIDOMKeyEvent.h"             // for nsIDOMKeyEvent, etc
+#include "nsIDOMMouseEvent.h"           // for nsIDOMMouseEvent
+#include "nsIDOMNSEvent.h"              // for nsIDOMNSEvent
+#include "nsIDOMNamedNodeMap.h"         // for nsIDOMNamedNodeMap
+#include "nsIDOMNode.h"                 // for nsIDOMNode, etc
+#include "nsIDOMNodeList.h"             // for nsIDOMNodeList
+#include "nsIDOMRange.h"                // for nsIDOMRange
+#include "nsIDOMText.h"                 // for nsIDOMText
+#include "nsIDocument.h"                // for nsIDocument
+#include "nsIDocumentStateListener.h"   // for nsIDocumentStateListener
+#include "nsIEditActionListener.h"      // for nsIEditActionListener
+#include "nsIEditorObserver.h"          // for nsIEditorObserver
+#include "nsIEditorSpellCheck.h"        // for nsIEditorSpellCheck
+#include "nsIEnumerator.h"              // for nsIEnumerator, etc
+#include "nsIFrame.h"                   // for nsIFrame
+#include "nsIInlineSpellChecker.h"      // for nsIInlineSpellChecker, etc
+#include "nsIMEStateManager.h"          // for nsIMEStateManager
+#include "nsINameSpaceManager.h"        // for kNameSpaceID_None, etc
+#include "nsINode.h"                    // for nsINode, etc
+#include "nsIObserverService.h"         // for nsIObserverService
+#include "nsIPlaintextEditor.h"         // for nsIPlaintextEditor, etc
+#include "nsIPresShell.h"               // for nsIPresShell
+#include "nsIPrivateTextRange.h"        // for nsIPrivateTextRange, etc
+#include "nsISelection.h"               // for nsISelection, etc
+#include "nsISelectionController.h"     // for nsISelectionController, etc
+#include "nsISelectionDisplay.h"        // for nsISelectionDisplay, etc
+#include "nsISelectionPrivate.h"        // for nsISelectionPrivate, etc
+#include "nsISupportsBase.h"            // for nsISupports
+#include "nsISupportsUtils.h"           // for NS_ADDREF, NS_IF_ADDREF
+#include "nsITransaction.h"             // for nsITransaction
 #include "nsITransactionManager.h"
-#include "nsIAbsorbingTransaction.h"
-#include "nsIPresShell.h"
-#include "nsISelection.h"
-#include "nsISelectionPrivate.h"
-#include "nsISelectionController.h"
-#include "nsIEnumerator.h"
-#include "nsEditProperty.h"
-#include "nsIAtom.h"
-#include "nsCaret.h"
-#include "nsIWidget.h"
-#include "nsIPlaintextEditor.h"
-#include "nsGUIEvent.h"
-
-#include "nsIFrame.h"  // Needed by IME code
-
-#include "nsCSSStyleSheet.h"
-
-#include "nsIContent.h"
-#include "nsDOMString.h"
-#include "nsServiceManagerUtils.h"
-
-// transactions the editor knows how to build
-#include "EditAggregateTxn.h"
-#include "PlaceholderTxn.h"
-#include "ChangeAttributeTxn.h"
-#include "CreateElementTxn.h"
-#include "InsertElementTxn.h"
-#include "DeleteNodeTxn.h"
-#include "InsertTextTxn.h"
-#include "DeleteTextTxn.h"
-#include "DeleteRangeTxn.h"
-#include "SplitElementTxn.h"
-#include "JoinElementTxn.h"
-#include "nsStyleSheetTxns.h"
-#include "IMETextTxn.h"
-#include "nsString.h"
-
-#include "nsEditor.h"
-#include "nsEditorUtils.h"
-#include "nsEditorEventListener.h"
-#include "nsISelectionDisplay.h"
-#include "nsIInlineSpellChecker.h"
-#include "nsINameSpaceManager.h"
-#include "nsIParserService.h"
-
-#include "nsITransferable.h"
-#include "nsComputedDOMStyle.h"
-#include "nsTextEditUtils.h"
-#include "nsComputedDOMStyle.h"
-
-#include "mozilla/FunctionTimer.h"
-#include "mozilla/Preferences.h"
-#include "mozilla/dom/Element.h"
-#include "nsContentUtils.h"
-#include "nsCCUncollectableMarker.h"
+#include "nsIWeakReference.h"           // for nsISupportsWeakReference
+#include "nsIWidget.h"                  // for nsIWidget, IMEState, etc
+#include "nsPIDOMWindow.h"              // for nsPIDOMWindow
+#include "nsPresContext.h"              // for nsPresContext
+#include "nsRange.h"                    // for nsRange
+#include "nsReadableUtils.h"            // for EmptyString, ToNewCString
+#include "nsString.h"                   // for nsAutoString, nsString, etc
+#include "nsStringFwd.h"                // for nsAFlatString
+#include "nsStyleConsts.h"              // for NS_STYLE_DIRECTION_RTL, etc
+#include "nsStyleContext.h"             // for nsStyleContext
+#include "nsStyleSheetTxns.h"           // for AddStyleSheetTxn, etc
+#include "nsStyleStruct.h"              // for nsStyleDisplay, nsStyleText, etc
+#include "nsStyleStructFwd.h"           // for nsIFrame::GetStyleUIReset, etc
+#include "nsTextEditUtils.h"            // for nsTextEditUtils
+#include "nsThreadUtils.h"              // for nsRunnable
+#include "nsTransactionManager.h"       // for nsTransactionManager
+#include "prtime.h"                     // for PR_Now
+
+class nsIOutputStream;
+class nsIParserService;
+class nsITransferable;
 
 #define NS_ERROR_EDITOR_NO_SELECTION NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_EDITOR,1)
 #define NS_ERROR_EDITOR_NO_TEXTNODE  NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_EDITOR,2)
 
 #ifdef NS_DEBUG_EDITOR
 static bool gNoisy = false;
 #endif
 
 #ifdef DEBUG
-#include "nsIDOMHTMLDocument.h"
+#include "nsIDOMHTMLDocument.h"         // for nsIDOMHTMLDocument
 #endif
 
 using namespace mozilla;
 using namespace mozilla::widget;
 
 // Defined in nsEditorRegistration.cpp
 extern nsIParserService *sParserService;
 
--- a/editor/libeditor/base/nsEditor.h
+++ b/editor/libeditor/base/nsEditor.h
@@ -1,66 +1,86 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef __editor_h__
 #define __editor_h__
 
-#include "nsCOMPtr.h"
-#include "nsWeakReference.h"
-
-#include "nsIEditor.h"
-#include "nsIPlaintextEditor.h"
-#include "nsIEditorIMESupport.h"
-#include "nsIPhonetic.h"
+#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
+#include "nsAutoPtr.h"                  // for nsRefPtr
+#include "nsCOMArray.h"                 // for nsCOMArray
+#include "nsCOMPtr.h"                   // for already_AddRefed, nsCOMPtr
+#include "nsCycleCollectionParticipant.h"
+#include "nsEditProperty.h"             // for nsEditProperty, etc
+#include "nsIEditor.h"                  // for nsIEditor::EDirection, etc
+#include "nsIEditorIMESupport.h"        // for NS_DECL_NSIEDITORIMESUPPORT, etc
+#include "nsIObserver.h"                // for NS_DECL_NSIOBSERVER, etc
+#include "nsIPhonetic.h"                // for NS_DECL_NSIPHONETIC, etc
+#include "nsIPlaintextEditor.h"         // for nsIPlaintextEditor, etc
+#include "nsISupportsImpl.h"            // for nsEditor::Release, etc
+#include "nsIWeakReferenceUtils.h"      // for nsWeakPtr
+#include "nsLiteralString.h"            // for NS_LITERAL_STRING
+#include "nsSelectionState.h"           // for nsRangeUpdater, etc
+#include "nsString.h"                   // for nsCString
+#include "nsWeakReference.h"            // for nsSupportsWeakReference
+#include "nscore.h"                     // for nsresult, nsAString, etc
+#include "prtypes.h"                    // for PRInt32, PRUint32, PRInt8, etc
 
-#include "nsIAtom.h"
-#include "nsIDOMDocument.h"
-#include "mozilla/Selection.h"
-#include "nsIDOMCharacterData.h"
-#include "nsIPrivateTextRange.h"
-#include "nsTransactionManager.h"
-#include "nsIComponentManager.h"
-#include "nsCOMArray.h"
-#include "nsIEditActionListener.h"
-#include "nsIEditorObserver.h"
-#include "nsIDocumentStateListener.h"
-#include "nsIDOMElement.h"
-#include "nsSelectionState.h"
-#include "nsIEditorSpellCheck.h"
-#include "nsIInlineSpellChecker.h"
-#include "nsIDOMEventTarget.h"
-#include "nsStubMutationObserver.h"
-#include "nsIViewManager.h"
-#include "nsCycleCollectionParticipant.h"
-#include "nsIObserver.h"
-
-class nsIDOMCharacterData;
-class nsIDOMRange;
-class nsIPresShell;
+class AddStyleSheetTxn;
 class ChangeAttributeTxn;
 class CreateElementTxn;
-class InsertElementTxn;
 class DeleteNodeTxn;
-class InsertTextTxn;
 class DeleteTextTxn;
-class SplitElementTxn;
-class JoinElementTxn;
 class EditAggregateTxn;
 class IMETextTxn;
-class AddStyleSheetTxn;
+class InsertElementTxn;
+class InsertTextTxn;
+class JoinElementTxn;
 class RemoveStyleSheetTxn;
-class nsIFile;
-class nsISelectionController;
+class SplitElementTxn;
+class nsCSSStyleSheet;
+class nsIAtom;
+class nsIContent;
+class nsIDOMCharacterData;
+class nsIDOMDataTransfer;
+class nsIDOMDocument;
+class nsIDOMElement;
+class nsIDOMEvent;
+class nsIDOMEventListener;
 class nsIDOMEventTarget;
-class nsCSSStyleSheet;
+class nsIDOMKeyEvent;
+class nsIDOMNSEvent;
+class nsIDOMNode;
+class nsIDOMRange;
+class nsIDocument;
+class nsIDocumentStateListener;
+class nsIEditActionListener;
+class nsIEditorObserver;
+class nsIInlineSpellChecker;
+class nsINode;
+class nsIPresShell;
+class nsIPrivateTextRangeList;
+class nsISelection;
+class nsISupports;
+class nsITransaction;
+class nsIWidget;
 class nsKeyEvent;
-class nsIDOMNSEvent;
+class nsRange;
+class nsString;
+class nsTransactionManager;
+
+namespace mozilla {
+class Selection;
+
+namespace dom {
+class Element;
+}  // namespace dom
+}  // namespace mozilla
 
 namespace mozilla {
 namespace widget {
 struct IMEState;
 } // namespace widget
 } // namespace mozilla
 
 #define kMOZEditorBogusNodeAttrAtom nsEditProperty::mozEditorBogusNode
--- a/editor/libeditor/base/nsEditorCommands.cpp
+++ b/editor/libeditor/base/nsEditorCommands.cpp
@@ -1,25 +1,37 @@
 /* -*- Mode: C++; 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 "mozFlushType.h"
+#include "mozilla/Assertions.h"
+#include "nsCOMPtr.h"
 #include "nsCRT.h"
-#include "nsString.h"
-
+#include "nsDebug.h"
+#include "nsEditorCommands.h"
+#include "nsError.h"
+#include "nsIClipboard.h"
+#include "nsICommandParams.h"
+#include "nsID.h"
+#include "nsIDOMDocument.h"
+#include "nsIDocument.h"
 #include "nsIEditor.h"
-#include "nsIPlaintextEditor.h"
 #include "nsIEditorMailSupport.h"
+#include "nsIPlaintextEditor.h"
+#include "nsISelection.h"
 #include "nsISelectionController.h"
-#include "nsIClipboard.h"
+#include "nsITransferable.h"
+#include "nsString.h"
+#include "nsAString.h"
+#include "prtypes.h"
 
-#include "nsEditorCommands.h"
-#include "nsIDocument.h"
+class nsISupports;
 
 
 #define STATE_ENABLED  "state_enabled"
 #define STATE_DATA "state_data"
 
 
 nsBaseEditorCommand::nsBaseEditorCommand()
 {
--- a/editor/libeditor/base/nsEditorCommands.h
+++ b/editor/libeditor/base/nsEditorCommands.h
@@ -1,19 +1,22 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef nsIEditorCommand_h_
 #define nsIEditorCommand_h_
 
-#include "nsCOMPtr.h"
 #include "nsIControllerCommand.h"
-#include "nsIAtom.h"
+#include "nsISupportsImpl.h"
+#include "nscore.h"
+
+class nsICommandParams;
+class nsISupports;
 
 // This is a virtual base class for commands registered with the editor controller.
 // Note that such commands can be shared by more than on editor instance, so
 // MUST be stateless. Any state must be stored via the refCon (an nsIEditor).
 class nsBaseEditorCommand : public nsIControllerCommand
 {
 public:
 
--- a/editor/libeditor/base/nsEditorController.cpp
+++ b/editor/libeditor/base/nsEditorController.cpp
@@ -1,19 +1,22 @@
 /* -*- Mode: C++; 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 "nsString.h"
-#include "nsIComponentManager.h"
+#include "mozilla/mozalloc.h"
+#include "nsDebug.h"
+#include "nsEditorCommands.h"
 #include "nsEditorController.h"
-#include "nsEditorCommands.h"
+#include "nsError.h"
 #include "nsIControllerCommandTable.h"
 
+class nsIControllerCommand;
+
 
 
 #define NS_REGISTER_ONE_COMMAND(_cmdClass, _cmdName)                                      \
   {                                                                                       \
     _cmdClass* theCmd = new _cmdClass();                                                  \
     NS_ENSURE_TRUE(theCmd, NS_ERROR_OUT_OF_MEMORY);                                       \
     inCommandTable->RegisterCommand(_cmdName,                                             \
                                    static_cast<nsIControllerCommand *>(theCmd));          \
--- a/editor/libeditor/base/nsEditorController.h
+++ b/editor/libeditor/base/nsEditorController.h
@@ -1,16 +1,18 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef nsEditorController_h__
 #define nsEditorController_h__
 
+#include "nscore.h"
+
 #define NS_EDITORCONTROLLER_CID \
 { 0x26fb965c, 0x9de6, 0x11d3, { 0xbc, 0xcc, 0x0, 0x60, 0xb0, 0xfc, 0x76, 0xbd } }
 
 #define NS_EDITINGCONTROLLER_CID \
 { 0x2c5a5cdd, 0xe742, 0x4dfe, { 0x86, 0xb8, 0x06, 0x93, 0x09, 0xbf, 0x6c, 0x91 } }
 
 class nsIControllerCommandTable;
 
--- a/editor/libeditor/base/nsEditorEventListener.cpp
+++ b/editor/libeditor/base/nsEditorEventListener.cpp
@@ -1,49 +1,66 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=4 sw=2 et tw=78: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
+#include "mozilla/Preferences.h"        // for Preferences
+#include "mozilla/dom/Element.h"        // for Element
+#include "nsAString.h"
+#include "nsCaret.h"                    // for nsCaret
+#include "nsDebug.h"                    // for NS_ENSURE_TRUE, etc
+#include "nsEditor.h"                   // for nsEditor, etc
 #include "nsEditorEventListener.h"
-#include "nsEditor.h"
+#include "nsEventListenerManager.h"     // for nsEventListenerManager
+#include "nsFocusManager.h"             // for nsFocusManager
+#include "nsGUIEvent.h"                 // for NS_EVENT_FLAG_BUBBLE, etc
+#include "nsGkAtoms.h"                  // for nsGkAtoms, nsGkAtoms::input
+#include "nsIClipboard.h"               // for nsIClipboard, etc
+#include "nsIContent.h"                 // for nsIContent
+#include "nsID.h"
+#include "nsIDOMDOMStringList.h"        // for nsIDOMDOMStringList
+#include "nsIDOMDataTransfer.h"         // for nsIDOMDataTransfer
+#include "nsIDOMDocument.h"             // for nsIDOMDocument
+#include "nsIDOMDragEvent.h"            // for nsIDOMDragEvent
+#include "nsIDOMElement.h"              // for nsIDOMElement
+#include "nsIDOMEvent.h"                // for nsIDOMEvent
+#include "nsIDOMEventTarget.h"          // for nsIDOMEventTarget
+#include "nsIDOMKeyEvent.h"             // for nsIDOMKeyEvent
+#include "nsIDOMMouseEvent.h"           // for nsIDOMMouseEvent
+#include "nsIDOMNSEvent.h"              // for nsIDOMNSEvent
+#include "nsIDOMNode.h"                 // for nsIDOMNode
+#include "nsIDOMRange.h"                // for nsIDOMRange
+#include "nsIDocument.h"                // for nsIDocument
+#include "nsIEditor.h"                  // for nsEditor::GetSelection, etc
+#include "nsIEditorIMESupport.h"
+#include "nsIEditorMailSupport.h"       // for nsIEditorMailSupport
+#include "nsIFocusManager.h"            // for nsIFocusManager
+#include "nsIFormControl.h"             // for nsIFormControl, etc
+#include "nsIMEStateManager.h"          // for nsIMEStateManager
+#include "nsINode.h"                    // for nsINode, ::NODE_IS_EDITABLE, etc
+#include "nsIPlaintextEditor.h"         // for nsIPlaintextEditor, etc
+#include "nsIPresShell.h"               // for nsIPresShell
+#include "nsIPrivateTextEvent.h"        // for nsIPrivateTextEvent
+#include "nsIPrivateTextRange.h"        // for nsIPrivateTextRangeList
+#include "nsISelection.h"               // for nsISelection
+#include "nsISelectionController.h"     // for nsISelectionController, etc
+#include "nsISelectionPrivate.h"        // for nsISelectionPrivate
+#include "nsITransferable.h"            // for kFileMime, kHTMLMime, etc
+#include "nsLiteralString.h"            // for NS_LITERAL_STRING
+#include "nsServiceManagerUtils.h"      // for do_GetService
+#include "nsString.h"                   // for nsAutoString
+#include "prtypes.h"                    // for PRInt32, PRUint16, PRUint32
+#ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
+#include "nsContentUtils.h"             // for nsContentUtils, etc
+#include "nsIBidiKeyboard.h"            // for nsIBidiKeyboard
+#endif
 
-#include "nsIDOMDOMStringList.h"
-#include "nsIDOMEvent.h"
-#include "nsIDOMNSEvent.h"
-#include "nsIDOMDocument.h"
-#include "nsIDOMEventTarget.h"
-#include "nsIDocument.h"
-#include "nsIPresShell.h"
-#include "nsISelection.h"
-#include "nsISelectionController.h"
-#include "nsIDOMKeyEvent.h"
-#include "nsIDOMMouseEvent.h"
-#include "nsIPrivateTextEvent.h"
-#include "nsIEditorMailSupport.h"
-#include "nsFocusManager.h"
-#include "nsEventListenerManager.h"
-#include "nsIMEStateManager.h"
-#include "mozilla/Preferences.h"
-
-// Drag & Drop, Clipboard
-#include "nsIServiceManager.h"
-#include "nsIClipboard.h"
-#include "nsIContent.h"
-#include "nsISupportsPrimitives.h"
-#include "nsIDOMRange.h"
-#include "nsEditorUtils.h"
-#include "nsISelectionPrivate.h"
-#include "nsIDOMDragEvent.h"
-#include "nsIFocusManager.h"
-#include "nsIDOMWindow.h"
-#include "nsContentUtils.h"
-#include "nsIBidiKeyboard.h"
-#include "mozilla/dom/Element.h"
-#include "nsIFormControl.h"
+class nsPresContext;
 
 using namespace mozilla;
 
 nsEditorEventListener::nsEditorEventListener() :
   mEditor(nsnull), mCommitText(false),
   mInTransaction(false)
 #ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
   , mHaveBidiKeyboards(false)
--- a/editor/libeditor/base/nsEditorEventListener.h
+++ b/editor/libeditor/base/nsEditorEventListener.h
@@ -1,22 +1,26 @@
 /* -*- Mode: C++; tab-width: 4; 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/. */
 
 #ifndef nsEditorEventListener_h__
 #define nsEditorEventListener_h__
 
+#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
+#include "nsError.h"
+#include "nsIDOMEventListener.h"
+#include "nsISupportsImpl.h"
+#include "nscore.h"
 
-#include "nsIDOMEvent.h"
-#include "nsIDOMEventListener.h"
-
-#include "nsCaret.h"
+class nsCaret;
+class nsIDOMEvent;
+class nsIPresShell;
 
 // X.h defines KeyPress
 #ifdef KeyPress
 #undef KeyPress
 #endif
 
 #ifdef XP_WIN
 // On Windows, we support switching the text direction by pressing Ctrl+Shift
--- a/editor/libeditor/base/nsEditorUtils.cpp
+++ b/editor/libeditor/base/nsEditorUtils.cpp
@@ -1,27 +1,33 @@
 /* -*- Mode: C++; 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 "nsCOMArray.h"
+#include "nsComponentManagerUtils.h"
 #include "nsEditorUtils.h"
-#include "nsIDOMDocument.h"
-#include "nsIDOMRange.h"
-#include "nsIContent.h"
-#include "nsLayoutCID.h"
-
+#include "nsError.h"
+#include "nsIClipboardDragDropHookList.h"
 // hooks
 #include "nsIClipboardDragDropHooks.h"
-#include "nsIClipboardDragDropHookList.h"
-#include "nsISimpleEnumerator.h"
+#include "nsIContent.h"
+#include "nsIContentIterator.h"
+#include "nsIDOMDocument.h"
 #include "nsIDocShell.h"
 #include "nsIDocument.h"
 #include "nsIInterfaceRequestorUtils.h"
+#include "nsINode.h"
+#include "nsISelection.h"
+#include "nsISimpleEnumerator.h"
+
+class nsIDOMRange;
+class nsISupports;
 
 
 /******************************************************************************
  * nsAutoSelectionReset
  *****************************************************************************/
 
 nsAutoSelectionReset::nsAutoSelectionReset(nsISelection *aSel, nsEditor *aEd) : 
 mSel(nsnull)
--- a/editor/libeditor/base/nsEditorUtils.h
+++ b/editor/libeditor/base/nsEditorUtils.h
@@ -4,25 +4,29 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 
 #ifndef nsEditorUtils_h__
 #define nsEditorUtils_h__
 
 
 #include "nsCOMPtr.h"
-#include "nsIDOMNode.h"
-#include "nsISelection.h"
-#include "nsIEditor.h"
-#include "nsIAtom.h"
+#include "nsDebug.h"
 #include "nsEditor.h"
-#include "nsIContentIterator.h"
-#include "nsCOMArray.h"
+#include "nsIDOMNode.h"
+#include "nsIEditor.h"
+#include "nscore.h"
+#include "prtypes.h"
 
-class nsPlaintextEditor;
+class nsIAtom;
+class nsIContentIterator;
+class nsIDOMDocument;
+class nsIDOMRange;
+class nsISelection;
+template <class E> class nsCOMArray;
 
 /***************************************************************************
  * stack based helper class for batching a collection of txns inside a 
  * placeholder txn.
  */
 class NS_STACK_CLASS nsAutoPlaceHolderBatch
 {
   private:
@@ -221,19 +225,19 @@ struct NS_STACK_CLASS DOMPoint
 class nsEditorUtils
 {
   public:
     static bool IsDescendantOf(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 *aOffset = 0);
     static bool IsLeafNode(nsIDOMNode *aNode);
 };
 
 
-class nsITransferable;
 class nsIDOMEvent;
 class nsISimpleEnumerator;
+class nsITransferable;
 
 class nsEditorHookUtils
 {
   public:
     static bool     DoInsertionHook(nsIDOMDocument *aDoc, nsIDOMEvent *aEvent,
                                     nsITransferable *aTrans);
   private:
     static nsresult GetHookEnumeratorFromDocument(nsIDOMDocument *aDoc,
--- a/editor/libeditor/base/nsSelectionState.cpp
+++ b/editor/libeditor/base/nsSelectionState.cpp
@@ -1,20 +1,28 @@
 /* -*- Mode: C++; 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 "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
+#include "nsAString.h"                  // for nsAString_internal::Length
+#include "nsAutoPtr.h"                  // for nsRefPtr, getter_AddRefs, etc
+#include "nsCycleCollectionParticipant.h"
+#include "nsDebug.h"                    // for NS_ENSURE_TRUE, etc
+#include "nsEditor.h"                   // for nsEditor
+#include "nsEditorUtils.h"              // for nsEditorUtils
+#include "nsError.h"                    // for NS_OK, etc
+#include "nsIDOMCharacterData.h"        // for nsIDOMCharacterData
+#include "nsIDOMNode.h"                 // for nsIDOMNode
+#include "nsIDOMRange.h"                // for nsIDOMRange, etc
+#include "nsISelection.h"               // for nsISelection
+#include "nsISupportsImpl.h"            // for nsRange::Release
+#include "nsRange.h"                    // for nsRange
 #include "nsSelectionState.h"
-#include "nsIDOMCharacterData.h"
-#include "nsIDOMNode.h"
-#include "nsRange.h"
-#include "nsISelection.h"
-#include "nsEditor.h"
-#include "nsEditorUtils.h"
 
 
 /***************************************************************************
  * class for recording selection info.  stores selection as collection of
  * { {startnode, startoffset} , {endnode, endoffset} } tuples.  Can't store
  * ranges since dom gravity will possibly change the ranges.
  */
 nsSelectionState::nsSelectionState() : mArray(){}
--- a/editor/libeditor/base/nsSelectionState.h
+++ b/editor/libeditor/base/nsSelectionState.h
@@ -2,23 +2,25 @@
 /* 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 __selectionstate_h__
 #define __selectionstate_h__
 
 #include "nsCOMPtr.h"
+#include "nsIDOMNode.h"
+#include "nsINode.h"
 #include "nsTArray.h"
-#include "nsIDOMNode.h"
-#include "nsIDOMRange.h"
-#include "nsCycleCollectionParticipant.h"
-#include "nsINode.h"
+#include "nscore.h"
+#include "prtypes.h"
 
+class nsCycleCollectionTraversalCallback;
 class nsIDOMCharacterData;
+class nsIDOMRange;
 class nsISelection;
 class nsRange;
 
 /***************************************************************************
  * class for recording selection info.  stores selection as collection of
  * { {startnode, startoffset} , {endnode, endoffset} } tuples.  Can't store
  * ranges since dom gravity will possibly change the ranges.
  */
--- a/editor/libeditor/base/nsStyleSheetTxns.cpp
+++ b/editor/libeditor/base/nsStyleSheetTxns.cpp
@@ -1,23 +1,28 @@
 /* -*- Mode: C++; 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 "nsEditor.h"
+#include <stddef.h>                     // for NULL
 
-#include "nsCSSStyleSheet.h"
-#include "nsIDocument.h"
-#include "nsIDocumentObserver.h"
-#include "nsISelectionController.h"
+#include "nsAString.h"
+#include "nsCOMPtr.h"                   // for nsCOMPtr, do_QueryInterface, etc
+#include "nsCSSStyleSheet.h"            // for nsCSSStyleSheet
+#include "nsDebug.h"                    // for NS_ENSURE_TRUE
+#include "nsError.h"                    // for NS_OK, etc
+#include "nsIDOMDocument.h"             // for nsIDOMDocument
+#include "nsIDocument.h"                // for nsIDocument
+#include "nsIDocumentObserver.h"        // for UPDATE_STYLE
+#include "nsIEditor.h"                  // for nsIEditor
+#include "nsStyleSheetTxns.h"
 
-
-#include "nsStyleSheetTxns.h"
+class nsIStyleSheet;
 
 static void
 AddStyleSheet(nsIEditor* aEditor, nsIStyleSheet* aSheet)
 {
   nsCOMPtr<nsIDOMDocument> domDoc;
   aEditor->GetDocument(getter_AddRefs(domDoc));
   nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
   if (doc) {
--- a/editor/libeditor/base/nsStyleSheetTxns.h
+++ b/editor/libeditor/base/nsStyleSheetTxns.h
@@ -1,19 +1,25 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef nsStylesheetTxns_h__
 #define nsStylesheetTxns_h__
 
-#include "EditTxn.h"
-#include "nsCOMPtr.h"
-#include "nsIEditor.h"
+#include "EditTxn.h"                    // for EditTxn, NS_DECL_EDITTXN
+#include "nsAutoPtr.h"                  // for nsRefPtr
+#include "nsCSSStyleSheet.h"            // for nsCSSStyleSheet
+#include "nsCycleCollectionParticipant.h"
+#include "nsID.h"                       // for REFNSIID
+#include "nsISupportsImpl.h"            // for nsCSSStyleSheet::Release
+#include "nscore.h"                     // for NS_IMETHOD
+
+class nsIEditor;
 
 class AddStyleSheetTxn : public EditTxn
 {
 public:
   /** Initialize the transaction.
     * @param aEditor the object providing core editing operations
     * @param aSheet   the stylesheet to add
     */
--- a/editor/libeditor/html/TextEditorTest.cpp
+++ b/editor/libeditor/html/TextEditorTest.cpp
@@ -2,27 +2,32 @@
 /* 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/. */
 
 #ifdef DEBUG
 
 #include <stdio.h>
 
-#include "nsIEditor.h"
-#include "nsIHTMLEditor.h"
 #include "TextEditorTest.h"
-#include "nsISelection.h"
+#include "nsDebug.h"
+#include "nsEditProperty.h"
+#include "nsError.h"
 #include "nsIDOMCharacterData.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMNode.h"
 #include "nsIDOMNodeList.h"
-#include "nsEditProperty.h"
+#include "nsIEditor.h"
+#include "nsIHTMLEditor.h"
+#include "nsIPlaintextEditor.h"
+#include "nsISelection.h"
+#include "nsLiteralString.h"
+#include "nsReadableUtils.h"
 #include "nsString.h"
-#include "nsReadableUtils.h"
+#include "nsStringFwd.h"
 
 #define TEST_RESULT(r) { if (NS_FAILED(r)) {printf("FAILURE result=%X\n", r); return r; } }
 #define TEST_POINTER(p) { if (!p) {printf("FAILURE null pointer\n"); return NS_ERROR_NULL_POINTER; } }
 
 TextEditorTest::TextEditorTest()
 {
   printf("constructed a TextEditorTest\n");
 }
--- a/editor/libeditor/html/TextEditorTest.h
+++ b/editor/libeditor/html/TextEditorTest.h
@@ -1,21 +1,24 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef __TextEditorTest_h__
 #define __TextEditorTest_h__
 
+#include "nscore.h"
+#include "prtypes.h"
+
+class nsIEditor;
+class nsIPlaintextEditor;
 #ifdef DEBUG
 
 #include "nsCOMPtr.h"
-#include "nsIEditor.h"
-#include "nsIPlaintextEditor.h"
 
 class TextEditorTest
 {
 public:
 
   void Run(nsIEditor *aEditor, PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
   TextEditorTest();
   ~TextEditorTest();
--- a/editor/libeditor/html/TypeInState.cpp
+++ b/editor/libeditor/html/TypeInState.cpp
@@ -1,16 +1,32 @@
 /* -*- Mode: C++; 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 <stddef.h>
+
 #include "TypeInState.h"
+#include "mozilla/mozalloc.h"
+#include "nsAString.h"
+#include "nsDebug.h"
+#include "nsEditProperty.h"
 #include "nsEditor.h"
+#include "nsError.h"
+#include "nsIDOMNode.h"
+#include "nsISelection.h"
+#include "nsISupportsBase.h"
+#include "nsReadableUtils.h"
+#include "nsStringFwd.h"
+#include "nsTraceRefcnt.h"
+
+class nsIAtom;
+class nsIDOMDocument;
 
 /********************************************************************
  *                     XPCOM cruft 
  *******************************************************************/
 
 NS_IMPL_CYCLE_COLLECTION_1(TypeInState, mLastSelectionContainer)
 NS_IMPL_CYCLE_COLLECTING_ADDREF(TypeInState)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(TypeInState)
--- a/editor/libeditor/html/TypeInState.h
+++ b/editor/libeditor/html/TypeInState.h
@@ -2,23 +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 TypeInState_h__
 #define TypeInState_h__
 
 #include "nsCOMPtr.h"
-#include "nsIDOMNode.h"
-#include "nsISelection.h"
+#include "nsCycleCollectionParticipant.h"
 #include "nsISelectionListener.h"
-#include "nsEditProperty.h"
+#include "nsISupportsImpl.h"
 #include "nsString.h"
 #include "nsTArray.h"
-#include "nsCycleCollectionParticipant.h"
+#include "nscore.h"
+#include "prtypes.h"
+
+class nsIAtom;
+class nsIDOMNode;
+class nsISelection;
 
 struct PropItem
 {
   nsIAtom *tag;
   nsString attr;
   nsString value;
   
   PropItem();
--- a/editor/libeditor/html/nsEditProperty.cpp
+++ b/editor/libeditor/html/nsEditProperty.cpp
@@ -7,17 +7,17 @@
 
 #include "nsMemory.h"
 #include "nsStaticAtom.h"
 #include "nsEditProperty.h"
 
 using namespace mozilla;
 
 #define EDITOR_ATOM(name_, value_) nsIAtom* nsEditProperty::name_ = 0;
-#include "nsEditPropertyAtomList.h"
+#include "nsEditPropertyAtomList.h" // IWYU pragma: keep
 #undef EDITOR_ATOM
 
 /* From the HTML 4.0 DTD, 
 
 INLINE:
 <!-- %inline; covers inline or "text-level" elements -->
  <!ENTITY % inline "#PCDATA | %fontstyle; | %phrase; | %special; | %formctrl;">
  <!ENTITY % fontstyle "TT | I | B | BIG | SMALL">
@@ -33,23 +33,23 @@ BLOCK:
        BLOCKQUOTE | FORM | HR | TABLE | FIELDSET | ADDRESS">
 
 But what about BODY, TR, TD, TH, CAPTION, COL, COLGROUP, THEAD, TFOOT, LI, DT, DD, LEGEND, etc.?
  
 
 */
 
 #define EDITOR_ATOM(name_, value_) NS_STATIC_ATOM_BUFFER(name_##_buffer, value_)
-#include "nsEditPropertyAtomList.h"
+#include "nsEditPropertyAtomList.h" // IWYU pragma: keep
 #undef EDITOR_ATOM
 
 void
 nsEditProperty::RegisterAtoms()
 {
   // inline tags
   static const nsStaticAtom property_atoms[] = {
 #define EDITOR_ATOM(name_, value_) NS_STATIC_ATOM(name_##_buffer, &name_),
-#include "nsEditPropertyAtomList.h"
+#include "nsEditPropertyAtomList.h" // IWYU pragma: keep
 #undef EDITOR_ATOM
   };
   
   NS_RegisterStaticAtoms(property_atoms);
 }
--- a/editor/libeditor/html/nsHTMLAbsPosition.cpp
+++ b/editor/libeditor/html/nsHTMLAbsPosition.cpp
@@ -1,39 +1,60 @@
 /* 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 <math.h>
 
-#include "nsHTMLEditor.h"
-
-#include "nsIContent.h"
-#include "nsIEditor.h"
-#include "nsIPresShell.h"
-
-#include "nsISelection.h"
-
-#include "nsTextEditUtils.h"
+#include "mozilla/Preferences.h"
+#include "mozilla/Selection.h"
+#include "mozilla/dom/Element.h"
+#include "mozilla/mozalloc.h"
+#include "nsAString.h"
+#include "nsAlgorithm.h"
+#include "nsAutoPtr.h"
+#include "nsCOMPtr.h"
+#include "nsDebug.h"
+#include "nsEditProperty.h"
+#include "nsEditRules.h"
+#include "nsEditor.h"
 #include "nsEditorUtils.h"
-#include "nsHTMLEditUtils.h"
-#include "nsTextEditRules.h"
+#include "nsError.h"
+#include "nsGkAtoms.h"
+#include "nsHTMLCSSUtils.h"
 #include "nsHTMLEditRules.h"
-
-#include "nsIDOMHTMLElement.h"
-#include "nsIDOMNodeList.h"
-
+#include "nsHTMLEditUtils.h"
+#include "nsHTMLEditor.h"
+#include "nsHTMLObjectResizer.h"
+#include "nsIContent.h"
+#include "nsIDOMCSSPrimitiveValue.h"
+#include "nsIDOMCSSStyleDeclaration.h"
+#include "nsIDOMCSSValue.h"
+#include "nsIDOMElement.h"
+#include "nsIDOMEventListener.h"
 #include "nsIDOMEventTarget.h"
-
-#include "nsIDOMCSSValue.h"
-#include "nsIDOMCSSPrimitiveValue.h"
+#include "nsIDOMNode.h"
 #include "nsIDOMRGBColor.h"
-
-#include "mozilla/Preferences.h"
-#include "mozilla/dom/Element.h"
+#include "nsIDOMWindow.h"
+#include "nsIEditor.h"
+#include "nsIHTMLEditor.h"
+#include "nsIHTMLObjectResizer.h"
+#include "nsINode.h"
+#include "nsIPresShell.h"
+#include "nsISelection.h"
+#include "nsISupportsImpl.h"
+#include "nsISupportsUtils.h"
+#include "nsLiteralString.h"
+#include "nsReadableUtils.h"
+#include "nsString.h"
+#include "nsStringFwd.h"
+#include "nsTextEditRules.h"
+#include "nsTextEditUtils.h"
+#include "nscore.h"
+#include "prtypes.h"
 
 using namespace mozilla;
 
 #define  BLACK_BG_RGB_TRIGGER 0xd0
 
 NS_IMETHODIMP
 nsHTMLEditor::AbsolutePositionSelection(bool aEnabled)
 {
--- a/editor/libeditor/html/nsHTMLAnonymousUtils.cpp
+++ b/editor/libeditor/html/nsHTMLAnonymousUtils.cpp
@@ -1,36 +1,57 @@
 /* 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/Attributes.h"
+#include "mozilla/dom/Element.h"
+#include "mozilla/mozalloc.h"
+#include "nsAString.h"
+#include "nsAutoPtr.h"
+#include "nsCOMPtr.h"
+#include "nsContentUtils.h"
+#include "nsDebug.h"
+#include "nsEditProperty.h"
+#include "nsError.h"
+#include "nsHTMLCSSUtils.h"
 #include "nsHTMLEditor.h"
-
+#include "nsIAtom.h"
 #include "nsIContent.h"
-#include "nsIDocument.h"
-#include "nsIEditor.h"
-#include "nsIPresShell.h"
-#include "nsPresContext.h"
-
-#include "nsISelection.h"
-
-#include "nsTextEditUtils.h"
-#include "nsEditorUtils.h"
-#include "nsHTMLEditUtils.h"
-#include "nsTextEditRules.h"
-
-#include "nsIDOMHTMLElement.h"
-#include "nsIDOMEventTarget.h"
-
-#include "nsIDOMCSSValue.h"
+#include "nsID.h"
 #include "nsIDOMCSSPrimitiveValue.h"
 #include "nsIDOMCSSStyleDeclaration.h"
+#include "nsIDOMCSSValue.h"
+#include "nsIDOMElement.h"
+#include "nsIDOMEventTarget.h"
+#include "nsIDOMHTMLElement.h"
+#include "nsIDOMNode.h"
+#include "nsIDOMWindow.h"
+#include "nsIDocument.h"
+#include "nsIDocumentObserver.h"
+#include "nsIHTMLAbsPosEditor.h"
+#include "nsIHTMLEditor.h"
+#include "nsIHTMLInlineTableEditor.h"
+#include "nsIHTMLObjectResizer.h"
 #include "nsIMutationObserver.h"
+#include "nsINode.h"
+#include "nsIPresShell.h"
+#include "nsISupportsImpl.h"
+#include "nsISupportsUtils.h"
+#include "nsLiteralString.h"
+#include "nsPresContext.h"
+#include "nsReadableUtils.h"
+#include "nsString.h"
+#include "nsStringFwd.h"
 #include "nsUnicharUtils.h"
-#include "nsContentUtils.h"
+#include "nscore.h"
+#include "prtypes.h"
+
+class nsIDOMEventListener;
+class nsISelection;
 
 using namespace mozilla;
 
 // retrieve an integer stored into a CSS computed float value
 static PRInt32 GetCSSFloatValue(nsIDOMCSSStyleDeclaration * aDecl,
                                 const nsAString & aProperty)
 {
   NS_ENSURE_ARG_POINTER(aDecl);
--- a/editor/libeditor/html/nsHTMLCSSUtils.cpp
+++ b/editor/libeditor/html/nsHTMLCSSUtils.cpp
@@ -1,31 +1,51 @@
 /* -*- Mode: C++; 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 "nsHTMLEditor.h"
+#include "ChangeCSSInlineStyleTxn.h"
+#include "EditTxn.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/Preferences.h"
+#include "mozilla/dom/Element.h"
+#include "mozilla/mozalloc.h"
+#include "nsAString.h"
+#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
-#include "nsHTMLEditUtils.h"
+#include "nsColor.h"
+#include "nsContentUtils.h"
+#include "nsDebug.h"
+#include "nsDependentSubstring.h"
 #include "nsEditProperty.h"
-#include "ChangeCSSInlineStyleTxn.h"
+#include "nsError.h"
+#include "nsGkAtoms.h"
+#include "nsHTMLCSSUtils.h"
+#include "nsHTMLEditor.h"
+#include "nsIAtom.h"
+#include "nsIContent.h"
+#include "nsIDOMCSSStyleDeclaration.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMElementCSSInlineStyle.h"
-#include "nsIContent.h"
-#include "nsIAtom.h"
-#include "nsTextEditUtils.h"
+#include "nsIDOMNode.h"
+#include "nsIDOMWindow.h"
+#include "nsIDocument.h"
+#include "nsIEditor.h"
+#include "nsINode.h"
+#include "nsISupportsImpl.h"
+#include "nsISupportsUtils.h"
+#include "nsLiteralString.h"
+#include "nsPIDOMWindow.h"
 #include "nsReadableUtils.h"
+#include "nsString.h"
+#include "nsStringFwd.h"
+#include "nsStringIterator.h"
+#include "nsSubstringTuple.h"
 #include "nsUnicharUtils.h"
-#include "nsHTMLCSSUtils.h"
-#include "nsColor.h"
-#include "nsAttrName.h"
-#include "nsAutoPtr.h"
-#include "mozilla/Preferences.h"
-#include "nsContentUtils.h"
 
 using namespace mozilla;
 
 static
 void ProcessBValue(const nsAString * aInputString, nsAString & aOutputString,
                    const char * aDefaultValueString,
                    const char * aPrependString, const char* aAppendString)
 {
--- a/editor/libeditor/html/nsHTMLCSSUtils.h
+++ b/editor/libeditor/html/nsHTMLCSSUtils.h
@@ -1,25 +1,34 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef nsHTMLCSSUtils_h__
 #define nsHTMLCSSUtils_h__
 
-#include "nsCOMPtr.h"
-#include "nsString.h"
-#include "nsTArray.h"
-#include "nsIDOMNode.h"
-#include "nsIDOMElement.h"
-#include "nsIHTMLEditor.h"
-#include "ChangeCSSInlineStyleTxn.h"
-#include "nsEditProperty.h"
-#include "nsIDOMCSSStyleDeclaration.h"
+#include "nsCOMPtr.h"                   // for already_AddRefed
+#include "nsTArray.h"                   // for nsTArray
+#include "nscore.h"                     // for nsAString, nsresult, nsnull
+#include "prtypes.h"                    // for PRUint8, PRInt32, PRUint32
+
+class ChangeCSSInlineStyleTxn;
+class nsIAtom;
+class nsIContent;
+class nsIDOMCSSStyleDeclaration;
+class nsIDOMElement;
+class nsIDOMNode;
+class nsINode;
+class nsString;
+namespace mozilla {
+namespace dom {
+class Element;
+}  // namespace dom
+}  // namespace mozilla
 
 #define SPECIFIED_STYLE_TYPE    1
 #define COMPUTED_STYLE_TYPE     2
 
 class nsHTMLEditor;
 class nsIDOMWindow;
 
 typedef void (*nsProcessValueFunc)(const nsAString * aInputString, nsAString & aOutputString,
--- a/editor/libeditor/html/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/html/nsHTMLDataTransfer.cpp
@@ -1,104 +1,109 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=2 sw=2 et tw=78: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "mozilla/Util.h"
-
-#include "nsHTMLEditor.h"
-#include "nsHTMLEditRules.h"
-#include "nsTextEditUtils.h"
-#include "nsHTMLEditUtils.h"
-#include "nsWSRunObject.h"
+#include <string.h>
 
-#include "nsIDOMNode.h"
-#include "nsIDOMDocument.h"
-#include "nsIDOMComment.h"
-#include "nsIDOMNodeList.h"
-#include "nsIDocument.h"
-#include "nsIDOMMouseEvent.h"
-#include "nsISelection.h"
-#include "nsISelectionPrivate.h"
-#include "nsIDOMHTMLAnchorElement.h"
-#include "nsIDOMHTMLImageElement.h"
-#include "nsISelectionController.h"
-#include "nsIFileChannel.h"
-
-#include "nsIDocumentObserver.h"
-#include "nsIDocumentStateListener.h"
-
-#include "nsIEnumerator.h"
-#include "nsIContent.h"
-#include "nsIContentIterator.h"
-#include "nsIDOMRange.h"
-#include "nsIDOMDOMStringList.h"
-#include "nsIDOMDragEvent.h"
+#include "mozilla/Preferences.h"
+#include "mozilla/Selection.h"
+#include "mozilla/Util.h"
+#include "nsAString.h"
+#include "nsAutoPtr.h"
 #include "nsCOMArray.h"
-#include "nsIFile.h"
-#include "nsIURL.h"
-#include "nsIComponentManager.h"
-#include "nsIServiceManager.h"
-#include "nsIDocumentEncoder.h"
+#include "nsCOMPtr.h"
+#include "nsCRT.h"
+#include "nsCRTGlue.h"
+#include "nsComponentManagerUtils.h"
+#include "nsContentUtils.h"
+#include "nsDebug.h"
+#include "nsDependentSubstring.h"
+#include "nsEditProperty.h"
+#include "nsEditRules.h"
+#include "nsEditor.h"
+#include "nsEditorUtils.h"
+#include "nsError.h"
+#include "nsGUIEvent.h"
+#include "nsGkAtoms.h"
+#include "nsHTMLEditUtils.h"
+#include "nsHTMLEditor.h"
+#include "nsIClipboard.h"
+#include "nsIContent.h"
+#include "nsIContentFilter.h"
+#include "nsIDOMComment.h"
+#include "nsIDOMDOMStringList.h"
+#include "nsIDOMDataTransfer.h"
+#include "nsIDOMDocument.h"
 #include "nsIDOMDocumentFragment.h"
-#include "nsIPresShell.h"
-#include "nsPresContext.h"
-#include "nsXPCOM.h"
-#include "nsISupportsPrimitives.h"
-#include "nsLinebreakConverter.h"
-#include "nsHtml5Module.h"
-#include "nsTreeSanitizer.h"
-
-// netwerk
-#include "nsIURI.h"
-#include "nsNetUtil.h"
-#include "nsIMIMEService.h"
-
-// Drag & Drop, Clipboard
-#include "nsIClipboard.h"
-#include "nsITransferable.h"
-#include "nsIDragService.h"
-#include "nsIDOMUIEvent.h"
-#include "nsIOutputStream.h"
-#include "nsIInputStream.h"
-#include "nsDirectoryServiceDefs.h"
-
-// for relativization
-#include "nsUnicharUtils.h"
-#include "nsIDOMTreeWalker.h"
-#include "nsIDOMNodeFilter.h"
-#include "nsIDOMNamedNodeMap.h"
+#include "nsIDOMElement.h"
+#include "nsIDOMHTMLAnchorElement.h"
+#include "nsIDOMHTMLBodyElement.h"
+#include "nsIDOMHTMLEmbedElement.h"
+#include "nsIDOMHTMLFrameElement.h"
+#include "nsIDOMHTMLIFrameElement.h"
+#include "nsIDOMHTMLImageElement.h"
+#include "nsIDOMHTMLInputElement.h"
 #include "nsIDOMHTMLLinkElement.h"
 #include "nsIDOMHTMLObjectElement.h"
-#include "nsIDOMHTMLFrameElement.h"
-#include "nsIDOMHTMLIFrameElement.h"
-#include "nsIDOMHTMLInputElement.h"
 #include "nsIDOMHTMLScriptElement.h"
-#include "nsIDOMHTMLEmbedElement.h"
 #include "nsIDOMHTMLTableCellElement.h"
+#include "nsIDOMHTMLTableElement.h"
 #include "nsIDOMHTMLTableRowElement.h"
-#include "nsIDOMHTMLTableElement.h"
-#include "nsIDOMHTMLBodyElement.h"
-
-// Misc
-#include "nsEditorUtils.h"
-#include "nsIContentFilter.h"
-#include "nsEventDispatcher.h"
+#include "nsIDOMNode.h"
+#include "nsIDOMRange.h"
+#include "nsIDocShell.h"
+#include "nsIDocShellTreeItem.h"
+#include "nsIDocument.h"
+#include "nsIEditor.h"
+#include "nsIEditorIMESupport.h"
+#include "nsIEditorMailSupport.h"
+#include "nsIFile.h"
+#include "nsIInputStream.h"
+#include "nsIMIMEService.h"
+#include "nsINameSpaceManager.h"
+#include "nsINode.h"
+#include "nsIParserUtils.h"
+#include "nsIPlaintextEditor.h"
+#include "nsIPrincipal.h"
+#include "nsISelection.h"
+#include "nsISupportsImpl.h"
+#include "nsISupportsPrimitives.h"
+#include "nsISupportsUtils.h"
+#include "nsITransferable.h"
+#include "nsIURI.h"
+#include "nsIVariant.h"
+#include "nsLinebreakConverter.h"
+#include "nsLiteralString.h"
+#include "nsNetUtil.h"
+#include "nsPlaintextEditor.h"
+#include "nsRange.h"
+#include "nsReadableUtils.h"
+#include "nsSelectionState.h"
+#include "nsServiceManagerUtils.h"
+#include "nsStreamUtils.h"
+#include "nsString.h"
+#include "nsStringFwd.h"
+#include "nsStringIterator.h"
+#include "nsSubstringTuple.h"
+#include "nsTextEditRules.h"
+#include "nsTextEditUtils.h"
+#include "nsTreeSanitizer.h"
+#include "nsWSRunObject.h"
+#include "nsXPCOM.h"
+#include "nscore.h"
 #include "plbase64.h"
 #include "prmem.h"
-#include "nsStreamUtils.h"
-#include "nsIPrincipal.h"
-#include "nsIDocShell.h"
-#include "nsIDocShellTreeItem.h"
-#include "nsContentUtils.h"
-#include "mozilla/Preferences.h"
-#include "nsIParserUtils.h"
-#include "nsILoadContext.h"
+#include "prtypes.h"
+
+class nsIAtom;
+class nsILoadContext;
+class nsISupports;
 
 using namespace mozilla;
 
 const PRUnichar nbsp = 160;
 
 #define kInsertCookie  "_moz_Insert Here_moz_"
 
 #define NS_FOUND_TARGET NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_EDITOR, 3)
--- a/editor/libeditor/html/nsHTMLEditRules.cpp
+++ b/editor/libeditor/html/nsHTMLEditRules.cpp
@@ -1,54 +1,68 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=2 sw=2 et tw=79: */
 /* 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 <stdlib.h>
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Preferences.h"
+#include "mozilla/Selection.h"
+#include "mozilla/dom/Element.h"
+#include "mozilla/mozalloc.h"
+#include "nsAString.h"
+#include "nsAlgorithm.h"
+#include "nsCOMArray.h"
+#include "nsCRT.h"
+#include "nsCRTGlue.h"
+#include "nsComponentManagerUtils.h"
+#include "nsContentUtils.h"
+#include "nsDebug.h"
+#include "nsEditProperty.h"
+#include "nsEditor.h"
+#include "nsEditorUtils.h"
+#include "nsError.h"
+#include "nsGkAtoms.h"
+#include "nsHTMLCSSUtils.h"
 #include "nsHTMLEditRules.h"
-
-#include "nsEditor.h"
-#include "nsTextEditUtils.h"
 #include "nsHTMLEditUtils.h"
-#include "nsHTMLCSSUtils.h"
 #include "nsHTMLEditor.h"
-
-#include "nsIServiceManager.h"
-#include "nsCRT.h"
+#include "nsIAtom.h"
 #include "nsIContent.h"
 #include "nsIContentIterator.h"
+#include "nsID.h"
+#include "nsIDOMCharacterData.h"
+#include "nsIDOMDocument.h"
+#include "nsIDOMElement.h"
 #include "nsIDOMNode.h"
+#include "nsIDOMRange.h"
 #include "nsIDOMText.h"
-#include "nsIDOMElement.h"
-#include "nsIDOMNodeList.h"
+#include "nsIEnumerator.h"
+#include "nsIHTMLAbsPosEditor.h"
+#include "nsIHTMLDocument.h"
+#include "nsINode.h"
 #include "nsISelection.h"
 #include "nsISelectionPrivate.h"
-#include "nsISelectionController.h"
-#include "nsIDOMRange.h"
-#include "nsIDOMCharacterData.h"
-#include "nsIEnumerator.h"
-#include "nsIDOMNamedNodeMap.h"
+#include "nsLiteralString.h"
+#include "nsPlaintextEditor.h"
 #include "nsRange.h"
-
-#include "nsEditorUtils.h"
+#include "nsReadableUtils.h"
+#include "nsString.h"
+#include "nsStringFwd.h"
+#include "nsTArray.h"
+#include "nsTextEditUtils.h"
+#include "nsThreadUtils.h"
+#include "nsUnicharUtils.h"
 #include "nsWSRunObject.h"
 
-#include "InsertTextTxn.h"
-#include "DeleteTextTxn.h"
-#include "nsReadableUtils.h"
-#include "nsUnicharUtils.h"
-
-#include "nsFrameSelection.h"
-#include "nsContentUtils.h"
-#include "nsTArray.h"
-#include "nsIHTMLDocument.h"
-
-#include "mozilla/Preferences.h"
-#include "mozilla/dom/Element.h"
+class nsISupports;
+class nsRulesInfo;
 
 using namespace mozilla;
 
 //const static char* kMOZEditorBogusNodeAttr="MOZ_EDITOR_BOGUS_NODE";
 //const static char* kMOZEditorBogusNodeValue="TRUE";
 
 enum
 {
--- a/editor/libeditor/html/nsHTMLEditRules.h
+++ b/editor/libeditor/html/nsHTMLEditRules.h
@@ -1,31 +1,52 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef nsHTMLEditRules_h__
 #define nsHTMLEditRules_h__
 
-#include "nsTextEditRules.h"
-#include "nsIHTMLEditor.h"
-#include "nsIEditActionListener.h"
-#include "nsCOMArray.h"
+#include "TypeInState.h"
+#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
-#include "nsString.h"
-#include "nsEditorUtils.h"
-#include "TypeInState.h"
-#include "nsReadableUtils.h"
+#include "nsEditor.h"
+#include "nsIEditActionListener.h"
+#include "nsIEditor.h"
+#include "nsIHTMLEditor.h"
+#include "nsISupportsImpl.h"
+#include "nsSelectionState.h"
 #include "nsTArray.h"
-#include "nsRange.h"
+#include "nsTextEditRules.h"
+#include "nsTraceRefcnt.h"
+#include "nscore.h"
+#include "prtypes.h"
 
+class nsHTMLEditor;
+class nsIAtom;
+class nsIDOMCharacterData;
+class nsIDOMDocument;
 class nsIDOMElement;
+class nsIDOMNode;
+class nsIDOMRange;
 class nsIEditor;
-class nsHTMLEditor;
+class nsINode;
+class nsISelection;
+class nsPlaintextEditor;
+class nsRange;
+class nsRulesInfo;
+namespace mozilla {
+class Selection;
+namespace dom {
+class Element;
+}  // namespace dom
+}  // namespace mozilla
+struct DOMPoint;
+template <class E> class nsCOMArray;
 
 struct StyleCache : public PropItem
 {
   bool mPresent;
   
   StyleCache() : PropItem(), mPresent(false) {
     MOZ_COUNT_CTOR(StyleCache);
   }
--- a/editor/libeditor/html/nsHTMLEditUtils.cpp
+++ b/editor/libeditor/html/nsHTMLEditUtils.cpp
@@ -1,31 +1,34 @@
 /* -*- Mode: C++; 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 "./../../mozilla-config.h"     // for MOZ_MEDIA
+#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
+#include "mozilla/Util.h"               // for ArrayLength
+#include "mozilla/dom/Element.h"        // for Element
+#include "nsAString.h"                  // for nsAString_internal::IsEmpty
+#include "nsCOMPtr.h"                   // for nsCOMPtr, operator==, etc
+#include "nsCaseTreatment.h"
+#include "nsDebug.h"                    // for NS_PRECONDITION, etc
+#include "nsEditProperty.h"             // for nsEditProperty, etc
+#include "nsEditor.h"                   // for nsEditor
+#include "nsError.h"                    // for NS_SUCCEEDED
+#include "nsGkAtoms.h"                  // for nsGkAtoms, nsGkAtoms::a, etc
 #include "nsHTMLEditUtils.h"
-
-#include "mozilla/Assertions.h"
-#include "mozilla/Util.h"
-#include "mozilla/dom/Element.h"
-
-#include "nsTextEditUtils.h"
-
-#include "nsString.h"
-#include "nsUnicharUtils.h"
-#include "nsEditor.h"
-#include "nsEditProperty.h"
-#include "nsIAtom.h"
-#include "nsIDOMNode.h"
-#include "nsIContent.h"
-#include "nsIDOMNodeList.h"
-#include "nsIDOMHTMLAnchorElement.h"
 #include "nsHTMLTags.h"
+#include "nsIAtom.h"                    // for nsIAtom
+#include "nsIDOMHTMLAnchorElement.h"    // for nsIDOMHTMLAnchorElement
+#include "nsIDOMNode.h"                 // for nsIDOMNode
+#include "nsINameSpaceManager.h"        // for kNameSpaceID_None
+#include "nsLiteralString.h"            // for NS_LITERAL_STRING
+#include "nsString.h"                   // for nsAutoString
+#include "nsTextEditUtils.h"            // for nsTextEditUtils
 
 using namespace mozilla;
 
 ///////////////////////////////////////////////////////////////////////////
 //                  
 bool 
 nsHTMLEditUtils::IsBig(nsIDOMNode *node)
 {
--- a/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/editor/libeditor/html/nsHTMLEditor.cpp
@@ -12,27 +12,28 @@
 #include "nsHTMLEditUtils.h"
 
 #include "nsHTMLEditorEventListener.h"
 #include "TypeInState.h"
 
 #include "nsHTMLURIRefObject.h"
 
 #include "nsIDOMText.h"
+#include "nsIDOMNamedNodeMap.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMAttr.h"
 #include "nsIDocument.h"
 #include "nsIDOMEventTarget.h" 
 #include "nsIDOMKeyEvent.h"
-#include "nsISelectionPrivate.h"
 #include "nsIDOMHTMLAnchorElement.h"
 #include "nsISelectionController.h"
 #include "nsIDOMHTMLDocument.h"
 #include "nsILinkHandler.h"
+#include "nsIInlineSpellChecker.h"
 
 #include "mozilla/css/Loader.h"
 #include "nsCSSStyleSheet.h"
 #include "nsIDOMStyleSheet.h"
 
 #include "nsIEnumerator.h"
 #include "nsIContent.h"
 #include "nsIContentIterator.h"
@@ -58,16 +59,17 @@
 #include "TextEditorTest.h"
 #include "nsEditorUtils.h"
 #include "nsWSRunObject.h"
 #include "nsGkAtoms.h"
 #include "nsIWidget.h"
 
 #include "nsIFrame.h"
 #include "nsIParserService.h"
+#include "mozilla/Selection.h"
 #include "mozilla/dom/Element.h"
 #include "nsTextFragment.h"
 
 using namespace mozilla;
 using namespace mozilla::widget;
 
 // Some utilities to handle annoying overloading of "A" tag for link and named anchor
 static char hrefText[] = "href";
--- a/editor/libeditor/html/nsHTMLEditor.h
+++ b/editor/libeditor/html/nsHTMLEditor.h
@@ -26,23 +26,25 @@
 
 #include "nsEditProperty.h"
 #include "nsHTMLCSSUtils.h"
 
 #include "nsHTMLObjectResizer.h"
 #include "nsIHTMLAbsPosEditor.h"
 #include "nsIHTMLInlineTableEditor.h"
 #include "nsIHTMLObjectResizeListener.h"
+#include "nsIHTMLObjectResizer.h"
 
 #include "nsIDocumentObserver.h"
 
 #include "nsPoint.h"
 #include "nsTArray.h"
 #include "nsAutoPtr.h"
 #include "nsAttrName.h"
+#include "nsStubMutationObserver.h"
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/Element.h"
 
 class nsIDOMKeyEvent;
 class nsITransferable;
 class nsIDocumentEncoder;
 class nsIClipboard;
--- a/editor/libeditor/html/nsHTMLEditorEventListener.cpp
+++ b/editor/libeditor/html/nsHTMLEditorEventListener.cpp
@@ -1,31 +1,35 @@
 /* -*- Mode: C++; 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 "nsHTMLEditorEventListener.h"
+#include "nsAutoPtr.h"
+#include "nsCOMPtr.h"
+#include "nsDebug.h"
+#include "nsEditor.h"
+#include "nsError.h"
+#include "nsHTMLEditUtils.h"
 #include "nsHTMLEditor.h"
-#include "nsString.h"
-
+#include "nsHTMLEditorEventListener.h"
+#include "nsIDOMElement.h"
 #include "nsIDOMEvent.h"
+#include "nsIDOMEventTarget.h"
+#include "nsIDOMMouseEvent.h"
 #include "nsIDOMNSEvent.h"
-#include "nsIDOMElement.h"
-#include "nsIDOMMouseEvent.h"
-#include "nsISelection.h"
+#include "nsIDOMNode.h"
 #include "nsIDOMRange.h"
-#include "nsIDOMEventTarget.h"
-#include "nsIDOMHTMLTableElement.h"
-#include "nsIDOMHTMLTableCellElement.h"
-#include "nsIContent.h"
-
+#include "nsIEditor.h"
+#include "nsIHTMLEditor.h"
+#include "nsIHTMLInlineTableEditor.h"
 #include "nsIHTMLObjectResizer.h"
-#include "nsEditProperty.h"
-#include "nsTextEditUtils.h"
-#include "nsHTMLEditUtils.h"
+#include "nsISelection.h"
+#include "nsISupportsImpl.h"
+#include "nsLiteralString.h"
+#include "prtypes.h"
 
 /*
  * nsHTMLEditorEventListener implementation
  *
  */
 
 #ifdef DEBUG
 nsresult
--- a/editor/libeditor/html/nsHTMLEditorEventListener.h
+++ b/editor/libeditor/html/nsHTMLEditorEventListener.h
@@ -2,18 +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 nsHTMLEditorEventListener_h__
 #define nsHTMLEditorEventListener_h__
 
 #include "nsEditorEventListener.h"
+#include "nscore.h"
 
+class nsEditor;
 class nsHTMLEditor;
+class nsIDOMEvent;
 
 class nsHTMLEditorEventListener : public nsEditorEventListener
 {
 public:
   nsHTMLEditorEventListener() :
     nsEditorEventListener()
   {
   }
--- a/editor/libeditor/html/nsHTMLEditorStyle.cpp
+++ b/editor/libeditor/html/nsHTMLEditorStyle.cpp
@@ -1,34 +1,62 @@
 /* -*- Mode: C++; 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 "nsUnicharUtils.h"
-
+#include "TypeInState.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/Selection.h"
+#include "mozilla/dom/Element.h"
+#include "mozilla/mozalloc.h"
+#include "nsAString.h"
+#include "nsAttrName.h"
+#include "nsAutoPtr.h"
+#include "nsCOMArray.h"
+#include "nsCOMPtr.h"
+#include "nsCaseTreatment.h"
+#include "nsComponentManagerUtils.h"
+#include "nsDebug.h"
+#include "nsEditProperty.h"
+#include "nsEditRules.h"
+#include "nsEditor.h"
+#include "nsEditorUtils.h"
+#include "nsError.h"
+#include "nsGkAtoms.h"
+#include "nsHTMLCSSUtils.h"
+#include "nsHTMLEditUtils.h"
 #include "nsHTMLEditor.h"
-#include "nsHTMLEditRules.h"
-#include "nsTextEditUtils.h"
-#include "nsHTMLEditUtils.h"
-#include "nsIDOMNodeList.h"
-#include "nsIDOMAttr.h"
-#include "nsIDOMMouseEvent.h"
+#include "nsIAtom.h"
+#include "nsIContent.h"
+#include "nsIContentIterator.h"
+#include "nsIDOMCharacterData.h"
+#include "nsIDOMElement.h"
+#include "nsIDOMNode.h"
+#include "nsIDOMRange.h"
+#include "nsIEditor.h"
+#include "nsIEditorIMESupport.h"
+#include "nsIEnumerator.h"
+#include "nsINameSpaceManager.h"
+#include "nsINode.h"
 #include "nsISelection.h"
 #include "nsISelectionPrivate.h"
-#include "nsIDOMHTMLImageElement.h"
-#include "nsISelectionController.h"
-#include "nsIDocumentObserver.h"
-#include "TypeInState.h"
+#include "nsISupportsImpl.h"
+#include "nsLiteralString.h"
+#include "nsReadableUtils.h"
+#include "nsSelectionState.h"
+#include "nsString.h"
+#include "nsStringFwd.h"
+#include "nsTArray.h"
+#include "nsTextEditRules.h"
+#include "nsTextEditUtils.h"
+#include "nsUnicharUtils.h"
+#include "nscore.h"
+#include "prtypes.h"
 
-#include "nsIEnumerator.h"
-#include "nsIContent.h"
-#include "nsIContentIterator.h"
-#include "nsAttrName.h"
-
-#include "mozilla/dom/Element.h"
+class nsISupports;
 
 using namespace mozilla;
 
 NS_IMETHODIMP nsHTMLEditor::AddDefaultProperty(nsIAtom *aProperty, 
                                             const nsAString & aAttribute, 
                                             const nsAString & aValue)
 {
   nsString outValue;
--- a/editor/libeditor/html/nsHTMLInlineTableEditor.cpp
+++ b/editor/libeditor/html/nsHTMLInlineTableEditor.cpp
@@ -1,21 +1,32 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "mozilla/dom/Element.h"
+#include "nsAString.h"
+#include "nsCOMPtr.h"
+#include "nsDebug.h"
+#include "nsError.h"
+#include "nsHTMLEditUtils.h"
 #include "nsHTMLEditor.h"
+#include "nsIContent.h"
+#include "nsIDOMElement.h"
+#include "nsIDOMEventTarget.h"
 #include "nsIDOMHTMLElement.h"
-#include "nsIDOMEventTarget.h"
+#include "nsIDOMNode.h"
+#include "nsIHTMLEditor.h"
+#include "nsIHTMLObjectResizer.h"
 #include "nsIPresShell.h"
-#include "nsIDocumentObserver.h"
-#include "nsIContent.h"
-#include "nsHTMLEditUtils.h"
+#include "nsLiteralString.h"
 #include "nsReadableUtils.h"
-#include "mozilla/dom/Element.h"
+#include "nsString.h"
+#include "nscore.h"
+#include "prtypes.h"
 
 // Uncomment the following line if you want to disable
 // table deletion when the only column/row is removed
 // #define DISABLE_TABLE_DELETION 1
 
 NS_IMETHODIMP
 nsHTMLEditor::SetInlineTableEditingEnabled(bool aIsEnabled)
 {
--- a/editor/libeditor/html/nsHTMLObjectResizer.cpp
+++ b/editor/libeditor/html/nsHTMLObjectResizer.cpp
@@ -1,39 +1,55 @@
 /* -*- Mode: C++; 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 "mozilla/LookAndFeel.h"
+#include "mozilla/Preferences.h"
+#include "mozilla/mozalloc.h"
+#include "nsAString.h"
+#include "nsAlgorithm.h"
+#include "nsAutoPtr.h"
+#include "nsCOMArray.h"
+#include "nsCOMPtr.h"
+#include "nsDebug.h"
+#include "nsEditProperty.h"
+#include "nsEditorUtils.h"
+#include "nsError.h"
+#include "nsHTMLCSSUtils.h"
+#include "nsHTMLEditUtils.h"
+#include "nsHTMLEditor.h"
 #include "nsHTMLObjectResizer.h"
-
+#include "nsIAtom.h"
+#include "nsIContent.h"
+#include "nsID.h"
+#include "nsIDOMDocument.h"
+#include "nsIDOMElement.h"
+#include "nsIDOMEvent.h"
 #include "nsIDOMEventTarget.h"
+#include "nsIDOMMouseEvent.h"
+#include "nsIDOMNode.h"
 #include "nsIDOMText.h"
-
-#include "nsIDOMCSSValue.h"
-#include "nsIDOMCSSPrimitiveValue.h"
-
-#include "nsIContent.h"
 #include "nsIDocument.h"
-#include "nsIDocumentObserver.h"
 #include "nsIEditor.h"
+#include "nsIHTMLEditor.h"
+#include "nsIHTMLObjectResizeListener.h"
+#include "nsIHTMLObjectResizer.h"
 #include "nsIPresShell.h"
+#include "nsISupportsUtils.h"
 #include "nsPIDOMWindow.h"
-
-#include "nsHTMLEditor.h"
-#include "nsEditor.h"
-#include "nsEditorUtils.h"
-#include "nsHTMLEditUtils.h"
+#include "nsReadableUtils.h"
+#include "nsString.h"
+#include "nsStringFwd.h"
+#include "nsSubstringTuple.h"
+#include "nscore.h"
+#include "prtypes.h"
 
-#include "nsPoint.h"
-
-#include "nsIServiceManager.h"
-#include "mozilla/Preferences.h"
-
-#include "mozilla/LookAndFeel.h"
+class nsISelection;
 
 using namespace mozilla;
 
 class nsHTMLEditUtils;
 
 // ==================================================================
 // DocumentResizeEventListener
 // ==================================================================
--- a/editor/libeditor/html/nsHTMLObjectResizer.h
+++ b/editor/libeditor/html/nsHTMLObjectResizer.h
@@ -1,30 +1,23 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef _nshtmlobjectresizer__h
 #define _nshtmlobjectresizer__h
 
-#include "nsCOMPtr.h"
-#include "nsWeakReference.h"
-#include "nsIDOMNode.h"
-#include "nsIDOMElement.h"
-
-#include "nsISelection.h"
-#include "nsString.h"
-#include "nsIHTMLEditor.h"
-#include "nsIHTMLObjectResizer.h"
-
-#include "nsIDOMMouseEvent.h"
-
 #include "nsIDOMEventListener.h"
 #include "nsISelectionListener.h"
+#include "nsISupportsImpl.h"
+#include "nsIWeakReferenceUtils.h"
+#include "nsLiteralString.h"
+
+class nsIHTMLEditor;
 
 #define kTopLeft       NS_LITERAL_STRING("nw")
 #define kTop           NS_LITERAL_STRING("n")
 #define kTopRight      NS_LITERAL_STRING("ne")
 #define kLeft          NS_LITERAL_STRING("w")
 #define kRight         NS_LITERAL_STRING("e")
 #define kBottomLeft    NS_LITERAL_STRING("sw")
 #define kBottom        NS_LITERAL_STRING("s")
--- a/editor/libeditor/html/nsHTMLURIRefObject.cpp
+++ b/editor/libeditor/html/nsHTMLURIRefObject.cpp
@@ -60,22 +60,28 @@
 
 		// this calls nsIStreamListener::OnDataAvailable()
 		rv = theChannel->AsyncOpen(listener, nsnull);
 
 		nsCOMPtr<nsIRequest> theRequest = do_QueryInterface(theChannel);
     // Now we can do things on nsIRequest (like what?)
  */
 
+#include "mozilla/mozalloc.h"
+#include "nsAString.h"
+#include "nsDebug.h"
+#include "nsError.h"
 #include "nsHTMLURIRefObject.h"
-
-#include "nsAString.h"
-#include "nsString.h"
+#include "nsID.h"
 #include "nsIDOMAttr.h"
 #include "nsIDOMElement.h"
+#include "nsIDOMNamedNodeMap.h"
+#include "nsIDOMNode.h"
+#include "nsISupportsUtils.h"
+#include "nsString.h"
 
 // String classes change too often and I can't keep up.
 // Set this macro to this week's approved case-insensitive compare routine.
 #define MATCHES(tagName, str) tagName.EqualsIgnoreCase(str)
 
 nsHTMLURIRefObject::nsHTMLURIRefObject()
 {
   mCurAttrIndex = mAttributeCnt = 0;
--- a/editor/libeditor/html/nsHTMLURIRefObject.h
+++ b/editor/libeditor/html/nsHTMLURIRefObject.h
@@ -1,20 +1,22 @@
 /* -*- Mode: C++; 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 "nsCOMPtr.h"
+#include "nsISupportsImpl.h"
 #include "nsIURIRefObject.h"
+#include "nscore.h"
+#include "prtypes.h"
 
-#include "nsCOMPtr.h"
-#include "nsIDOMNode.h"
-#include "nsIDOMNamedNodeMap.h"
-#include "nsString.h"
+class nsIDOMNamedNodeMap;
+class nsIDOMNode;
 
 #ifndef nsHTMLURIRefObject_h__
 #define nsHTMLURIRefObject_h__
 
 #define NS_URI_REF_OBJECT_CID                          \
 { /* {bdd79df6-1dd1-11b2-b29c-c3d63a58f1d2} */         \
     0xbdd79df6, 0x1dd1, 0x11b2,                        \
     { 0xb2, 0x9c, 0xc3, 0xd6, 0x3a, 0x58, 0xf1, 0xd2 } \
--- a/editor/libeditor/html/nsTableEditor.cpp
+++ b/editor/libeditor/html/nsTableEditor.cpp
@@ -1,39 +1,51 @@
 /* -*- Mode: C++; 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 "nscore.h"
+#include <stdio.h>
+
+#include "mozilla/Assertions.h"
+#include "mozilla/dom/Element.h"
+#include "nsAString.h"
+#include "nsAlgorithm.h"
+#include "nsCOMPtr.h"
+#include "nsDebug.h"
+#include "nsEditProperty.h"
 #include "nsEditor.h"
+#include "nsEditorUtils.h"
+#include "nsError.h"
+#include "nsGkAtoms.h"
+#include "nsHTMLEditUtils.h"
+#include "nsHTMLEditor.h"
+#include "nsIAtom.h"
+#include "nsIContent.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMNode.h"
-#include "nsIDOMNodeList.h"
 #include "nsIDOMRange.h"
+#include "nsIEditor.h"
 #include "nsIFrame.h"
+#include "nsIHTMLEditor.h"
+#include "nsINode.h"
 #include "nsIPresShell.h"
 #include "nsISelection.h"
-#include "nsISelectionPrivate.h"
-#include "nsLayoutCID.h"
-#include "nsIContent.h"
-#include "nsIContentIterator.h"
-#include "nsIAtom.h"
+#include "nsISelectionPrivate.h"  // For nsISelectionPrivate::TABLESELECTION_ defines
+#include "nsISupportsUtils.h"
 #include "nsITableCellLayout.h" // For efficient access to table cell
+#include "nsITableEditor.h"
 #include "nsITableLayout.h"     //  data owned by the table and cell frames
-#include "nsHTMLEditor.h"
-#include "nsISelectionPrivate.h"  // For nsISelectionPrivate::TABLESELECTION_ defines
+#include "nsLayoutErrors.h"
+#include "nsLiteralString.h"
+#include "nsQueryFrame.h"
+#include "nsString.h"
 #include "nsTArray.h"
-
-#include "nsEditorUtils.h"
-#include "nsTextEditUtils.h"
-#include "nsHTMLEditUtils.h"
-#include "nsLayoutErrors.h"
-
-#include "mozilla/dom/Element.h"
+#include "nscore.h"
+#include "prtypes.h"
 
 using namespace mozilla;
 
 /***************************************************************************
  * stack based helper class for restoring selection after table edit
  */
 class NS_STACK_CLASS nsSetSelectionAfterTableEdit
 {
--- a/editor/libeditor/html/nsWSRunObject.cpp
+++ b/editor/libeditor/html/nsWSRunObject.cpp
@@ -1,23 +1,34 @@
 /* -*- Mode: C++; 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 "mozilla/Assertions.h"
+#include "mozilla/mozalloc.h"
+#include "nsAString.h"
+#include "nsAutoPtr.h"
+#include "nsCRT.h"
+#include "nsContentUtils.h"
+#include "nsDebug.h"
+#include "nsEditorUtils.h"
+#include "nsError.h"
+#include "nsHTMLEditor.h"
+#include "nsIContent.h"
+#include "nsIDOMCharacterData.h"
+#include "nsIDOMNode.h"
+#include "nsIDOMRange.h"
+#include "nsISupportsImpl.h"
+#include "nsRange.h"
+#include "nsSelectionState.h"
+#include "nsString.h"
+#include "nsTextEditUtils.h"
 #include "nsTextFragment.h"
 #include "nsWSRunObject.h"
-#include "nsIDOMNode.h"
-#include "nsHTMLEditor.h"
-#include "nsTextEditUtils.h"
-#include "nsIContent.h"
-#include "nsIDOMCharacterData.h"
-#include "nsCRT.h"
-#include "nsRange.h"
-#include "nsContentUtils.h"
 
 const PRUnichar nbsp = 160;
 
 static bool IsBlockNode(nsIDOMNode* node)
 {
   bool isBlock (false);
   nsHTMLEditor::NodeIsBlockStatic(node, &isBlock);
   return isBlock;
--- a/editor/libeditor/html/nsWSRunObject.h
+++ b/editor/libeditor/html/nsWSRunObject.h
@@ -1,26 +1,29 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef __wsrunobject_h__
 #define __wsrunobject_h__
 
+#include "nsCOMArray.h"
 #include "nsCOMPtr.h"
-#include "nsIDOMNode.h"
-#include "nsCOMArray.h"
 #include "nsIContent.h"
+#include "nsIDOMNode.h"
 #include "nsIEditor.h"
-#include "nsEditorUtils.h"
+#include "nsINode.h"
+#include "nscore.h"
+#include "prtypes.h"
 
+class nsHTMLEditor;
 class nsIDOMDocument;
 class nsIDOMNode;
-class nsHTMLEditor;
+struct DOMPoint;
 
 // class nsWSRunObject represents the entire whitespace situation
 // around a given point.  It collects up a list of nodes that contain
 // whitespace and categorizes in up to 3 different WSFragments (detailed
 // below).  Each WSFragment is a collection of whitespace that is
 // either all insignificant, or that is significant.  A WSFragment could
 // consist of insignificant whitespace because it is after a block
 // boundary or after a break.  Or it could be insignificant because it
--- a/editor/libeditor/text/nsInternetCiter.cpp
+++ b/editor/libeditor/text/nsInternetCiter.cpp
@@ -1,25 +1,26 @@
 /* -*- Mode: C++; 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 "nsString.h"
-#include "nsReadableUtils.h"
-#include "nsInternetCiter.h"
-#include "nsCRT.h"
-
+#include "nsAString.h"
 #include "nsCOMPtr.h"
-
-// Line breaker stuff
-#include "nsIServiceManager.h"
+#include "nsCRT.h"
+#include "nsDebug.h"
+#include "nsDependentSubstring.h"
+#include "nsError.h"
+#include "nsILineBreaker.h"
+#include "nsInternetCiter.h"
 #include "nsLWBrkCIID.h"
-#include "nsILineBreaker.h"
+#include "nsServiceManagerUtils.h"
+#include "nsString.h"
+#include "nsStringIterator.h"
 
 const PRUnichar gt ('>');
 const PRUnichar space (' ');
 const PRUnichar nbsp (0xa0);
 const PRUnichar nl ('\n');
 const PRUnichar cr('\r');
 
 /** Mail citations using the Internet style: > This is a citation
--- a/editor/libeditor/text/nsInternetCiter.h
+++ b/editor/libeditor/text/nsInternetCiter.h
@@ -1,17 +1,18 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef nsInternetCiter_h__
 #define nsInternetCiter_h__
 
-#include "nsString.h"
+#include "nscore.h"
+#include "prtypes.h"
 
 /** Mail citations using standard Internet style.
   */
 class nsInternetCiter
 {
 public:
   static nsresult GetCiteString(const nsAString & aInString, nsAString & aOutString);
 
--- a/editor/libeditor/text/nsPlaintextDataTransfer.cpp
+++ b/editor/libeditor/text/nsPlaintextDataTransfer.cpp
@@ -1,48 +1,55 @@
 /* -*- Mode: C++; 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 "mozilla/Util.h"
-
-#include "nsPlaintextEditor.h"
-
-#include "nsIDOMDocument.h"
-#include "nsIDocument.h"
+#include "nsAString.h"
+#include "nsCOMPtr.h"
+#include "nsCRT.h"
+#include "nsComponentManagerUtils.h"
+#include "nsContentUtils.h"
+#include "nsDebug.h"
+#include "nsEditor.h"
+#include "nsEditorUtils.h"
+#include "nsError.h"
+#include "nsGUIEvent.h"
+#include "nsIClipboard.h"
 #include "nsIContent.h"
-#include "nsIFormControl.h"
-#include "nsIDOMEventTarget.h" 
-#include "nsIDOMNSEvent.h"
-#include "nsIDOMMouseEvent.h"
+#include "nsIDOMDataTransfer.h"
+#include "nsIDOMDocument.h"
 #include "nsIDOMDragEvent.h"
-#include "nsISelection.h"
-#include "nsCRT.h"
-#include "nsServiceManagerUtils.h"
-
+#include "nsIDOMEvent.h"
+#include "nsIDOMNode.h"
 #include "nsIDOMRange.h"
-#include "nsIDOMDOMStringList.h"
-#include "nsIDocumentEncoder.h"
-#include "nsISupportsPrimitives.h"
-
-// Drag & Drop, Clipboard
-#include "nsIClipboard.h"
-#include "nsITransferable.h"
+#include "nsIDOMUIEvent.h"
+#include "nsIDocument.h"
 #include "nsIDragService.h"
-#include "nsIDOMUIEvent.h"
-#include "nsCopySupport.h"
+#include "nsIDragSession.h"
+#include "nsIEditor.h"
+#include "nsIEditorIMESupport.h"
+#include "nsIFormControl.h"
+#include "nsIPlaintextEditor.h"
+#include "nsISelection.h"
+#include "nsISupportsPrimitives.h"
+#include "nsITransferable.h"
+#include "nsIVariant.h"
+#include "nsLiteralString.h"
+#include "nsPlaintextEditor.h"
+#include "nsSelectionState.h"
+#include "nsServiceManagerUtils.h"
+#include "nsString.h"
+#include "nsXPCOM.h"
+#include "nscore.h"
+#include "prtypes.h"
 
-// Misc
-#include "nsEditorUtils.h"
-#include "nsContentCID.h"
-#include "nsISelectionPrivate.h"
-#include "nsFrameSelection.h"
-#include "nsEventDispatcher.h"
-#include "nsContentUtils.h"
+class nsILoadContext;
+class nsISupports;
 
 using namespace mozilla;
 
 NS_IMETHODIMP nsPlaintextEditor::PrepareTransferable(nsITransferable **transferable)
 {
   // Create generic Transferable for getting the data
   nsresult rv = CallCreateInstance("@mozilla.org/widget/transferable;1", transferable);
   NS_ENSURE_SUCCESS(rv, rv);
--- a/editor/libeditor/text/nsPlaintextEditor.cpp
+++ b/editor/libeditor/text/nsPlaintextEditor.cpp
@@ -1,59 +1,73 @@
 /* -*- Mode: C++; 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 "nsPlaintextEditor.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/FunctionTimer.h"
+#include "mozilla/Preferences.h"
+#include "mozilla/Selection.h"
+#include "mozilla/dom/Element.h"
+#include "mozilla/mozalloc.h"
+#include "nsAString.h"
+#include "nsAutoPtr.h"
+#include "nsCRT.h"
 #include "nsCaret.h"
-#include "nsTextEditUtils.h"
-#include "nsTextEditRules.h"
-#include "nsIEditActionListener.h"
-#include "nsIDOMNodeList.h"
-#include "nsIDOMDocument.h"
-#include "nsIDocument.h"
-#include "nsIDOMEventTarget.h" 
-#include "nsIDOMKeyEvent.h"
-#include "nsISelection.h"
-#include "nsISelectionPrivate.h"
-#include "nsISelectionController.h"
+#include "nsCharTraits.h"
+#include "nsComponentManagerUtils.h"
+#include "nsContentCID.h"
+#include "nsCopySupport.h"
+#include "nsDebug.h"
+#include "nsDependentSubstring.h"
+#include "nsEditRules.h"
+#include "nsEditorUtils.h"  // nsAutoEditBatch, nsAutoRules
+#include "nsError.h"
 #include "nsGUIEvent.h"
-#include "nsCRT.h"
-
-#include "nsIEnumerator.h"
+#include "nsGkAtoms.h"
+#include "nsIClipboard.h"
 #include "nsIContent.h"
 #include "nsIContentIterator.h"
-#include "nsIDOMRange.h"
-#include "nsISupportsArray.h"
-#include "nsIComponentManager.h"
-#include "nsIServiceManager.h"
+#include "nsIDOMCharacterData.h"
+#include "nsIDOMDocument.h"
+#include "nsIDOMElement.h"
+#include "nsIDOMEventTarget.h" 
+#include "nsIDOMKeyEvent.h"
+#include "nsIDOMNode.h"
+#include "nsIDOMNodeList.h"
 #include "nsIDocumentEncoder.h"
+#include "nsIEditorIMESupport.h"
+#include "nsINameSpaceManager.h"
+#include "nsINode.h"
 #include "nsIPresShell.h"
+#include "nsIPrivateTextRange.h"
+#include "nsISelection.h"
+#include "nsISelectionController.h"
+#include "nsISelectionPrivate.h"
 #include "nsISupportsPrimitives.h"
+#include "nsITransferable.h"
+#include "nsIWeakReferenceUtils.h"
+#include "nsInternetCiter.h"
+#include "nsLiteralString.h"
+#include "nsPlaintextEditor.h"
 #include "nsReadableUtils.h"
-
-// Misc
-#include "nsEditorUtils.h"  // nsAutoEditBatch, nsAutoRules
+#include "nsServiceManagerUtils.h"
+#include "nsString.h"
+#include "nsStringFwd.h"
+#include "nsSubstringTuple.h"
+#include "nsTextEditRules.h"
+#include "nsTextEditUtils.h"
 #include "nsUnicharUtils.h"
-#include "nsContentCID.h"
-#include "nsInternetCiter.h"
-#include "nsEventDispatcher.h"
-#include "nsGkAtoms.h"
-#include "nsDebug.h"
-#include "mozilla/Preferences.h"
-#include "mozilla/dom/Element.h"
+#include "nsXPCOM.h"
 
-// Drag & Drop, Clipboard
-#include "nsIClipboard.h"
-#include "nsITransferable.h"
-#include "nsCopySupport.h"
-
-#include "mozilla/FunctionTimer.h"
+class nsIOutputStream;
+class nsISupports;
+class nsISupportsArray;
 
 using namespace mozilla;
 
 nsPlaintextEditor::nsPlaintextEditor()
 : nsEditor()
 , mRules(nsnull)
 , mWrapToWindow(false)
 , mWrapColumn(0)
--- a/editor/libeditor/text/nsPlaintextEditor.h
+++ b/editor/libeditor/text/nsPlaintextEditor.h
@@ -2,29 +2,40 @@
 /* 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 nsPlaintextEditor_h__
 #define nsPlaintextEditor_h__
 
 #include "nsCOMPtr.h"
-
-#include "nsIPlaintextEditor.h"
-#include "nsIEditorMailSupport.h"
-
+#include "nsCycleCollectionParticipant.h"
 #include "nsEditor.h"
-#include "nsIDOMElement.h"
-#include "nsIDOMEventListener.h"
+#include "nsIEditor.h"
+#include "nsIEditorMailSupport.h"
+#include "nsIPlaintextEditor.h"
+#include "nsISupportsImpl.h"
+#include "nscore.h"
+#include "prtypes.h"
 
-#include "nsEditRules.h"
-#include "nsCycleCollectionParticipant.h"
- 
+class nsIContent;
+class nsIDOMDataTransfer;
+class nsIDOMDocument;
+class nsIDOMElement;
+class nsIDOMEvent;
+class nsIDOMEventTarget;
+class nsIDOMKeyEvent;
+class nsIDOMNode;
+class nsIDocumentEncoder;
+class nsIEditRules;
+class nsIOutputStream;
+class nsIPrivateTextRangeList;
+class nsISelection;
+class nsISelectionController;
 class nsITransferable;
-class nsIDocumentEncoder;
 
 /**
  * The text editor implementation.
  * Use to edit text document represented as a DOM tree. 
  */
 class nsPlaintextEditor : public nsEditor,
                           public nsIPlaintextEditor,
                           public nsIEditorMailSupport
--- a/editor/libeditor/text/nsTextEditRules.cpp
+++ b/editor/libeditor/text/nsTextEditRules.cpp
@@ -1,47 +1,50 @@
 /* -*- Mode: C++; 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 "nsTextEditRules.h"
-
-#include "nsEditor.h"
-#include "nsTextEditUtils.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/LookAndFeel.h"
+#include "mozilla/Preferences.h"
+#include "mozilla/Selection.h"
+#include "mozilla/dom/Element.h"
+#include "nsAString.h"
+#include "nsAutoPtr.h"
+#include "nsCOMPtr.h"
 #include "nsCRT.h"
-
-#include "nsCOMPtr.h"
-#include "nsIServiceManager.h"
+#include "nsCRTGlue.h"
+#include "nsComponentManagerUtils.h"
+#include "nsContentUtils.h"
+#include "nsDebug.h"
+#include "nsEditor.h"
+#include "nsEditorUtils.h"
+#include "nsError.h"
+#include "nsGkAtoms.h"
+#include "nsIContent.h"
+#include "nsIDOMCharacterData.h"
+#include "nsIDOMDocument.h"
+#include "nsIDOMElement.h"
 #include "nsIDOMNode.h"
-#include "nsIDOMElement.h"
+#include "nsIDOMNodeFilter.h"
+#include "nsIDOMNodeIterator.h"
+#include "nsIDOMNodeList.h"
 #include "nsIDOMText.h"
-#include "nsIDOMNodeList.h"
+#include "nsINameSpaceManager.h"
+#include "nsINode.h"
+#include "nsIPlaintextEditor.h"
 #include "nsISelection.h"
 #include "nsISelectionPrivate.h"
-#include "nsISelectionController.h"
-#include "nsIDOMRange.h"
-#include "nsIDOMCharacterData.h"
-#include "nsIContent.h"
-#include "nsIContentIterator.h"
-#include "nsEditorUtils.h"
-#include "EditTxn.h"
-#include "nsEditProperty.h"
+#include "nsISupportsBase.h"
+#include "nsLiteralString.h"
+#include "nsNodeIterator.h"
+#include "nsTextEditRules.h"
+#include "nsTextEditUtils.h"
 #include "nsUnicharUtils.h"
-#include "DeleteTextTxn.h"
-#include "nsNodeIterator.h"
-#include "nsIDOMNodeFilter.h"
-#include "nsContentUtils.h"
-
-// for IBMBIDI
-#include "nsFrameSelection.h"
-
-#include "mozilla/Preferences.h"
-#include "mozilla/LookAndFeel.h"
-#include "mozilla/dom/Element.h"
 
 using namespace mozilla;
 
 #define CANCEL_OPERATION_IF_READONLY_OR_DISABLED \
   if (IsReadonly() || IsDisabled()) \
   {                     \
     *aCancel = true; \
     return NS_OK;       \
--- a/editor/libeditor/text/nsTextEditRules.h
+++ b/editor/libeditor/text/nsTextEditRules.h
@@ -2,22 +2,33 @@
 /* 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 nsTextEditRules_h__
 #define nsTextEditRules_h__
 
 #include "nsCOMPtr.h"
-
+#include "nsCycleCollectionParticipant.h"
+#include "nsEditRules.h"
+#include "nsEditor.h"
+#include "nsIEditor.h"
+#include "nsISupportsImpl.h"
+#include "nsITimer.h"
 #include "nsPlaintextEditor.h"
-#include "nsIDOMNode.h"
+#include "nsString.h"
+#include "nscore.h"
+#include "prtypes.h"
 
-#include "nsEditRules.h"
-#include "nsITimer.h"
+class nsIDOMElement;
+class nsIDOMNode;
+class nsISelection;
+namespace mozilla {
+class Selection;
+}  // namespace mozilla
 
 /** Object that encapsulates HTML text-specific editing rules.
   *  
   * To be a good citizen, edit rules must live by these restrictions:
   * 1. All data manipulation is through the editor.  
   *    Content nodes in the document tree must <B>not</B> be manipulated directly.
   *    Content nodes in document fragments that are not part of the document itself
   *    may be manipulated at will.  Operations on document fragments must <B>not</B>
--- a/editor/libeditor/text/nsTextEditRulesBidi.cpp
+++ b/editor/libeditor/text/nsTextEditRulesBidi.cpp
@@ -1,22 +1,30 @@
 /* -*- Mode: C++; 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 "nsTextEditRules.h"
+#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
+#include "nsDebug.h"
+#include "nsError.h"
+#include "nsFrameSelection.h"
+#include "nsIContent.h"
 #include "nsIDOMNode.h"
-#include "nsIContent.h"
+#include "nsIEditor.h"
 #include "nsIPresShell.h"
+#include "nsISelection.h"
+#include "nsISelectionPrivate.h"
+#include "nsISupportsImpl.h"
+#include "nsPlaintextEditor.h"
 #include "nsPresContext.h"
-#include "nsIFrame.h"
-#include "nsISelectionPrivate.h"
-#include "nsFrameSelection.h"
+#include "nsTextEditRules.h"
+#include "nscore.h"
+#include "prtypes.h"
 
 // Test for distance between caret and text that will be deleted
 nsresult
 nsTextEditRules::CheckBidiLevelForDeletion(nsISelection         *aSelection,
                                            nsIDOMNode           *aSelNode, 
                                            PRInt32               aSelOffset, 
                                            nsIEditor::EDirection aAction,
                                            bool                 *aCancel)
--- a/editor/libeditor/text/nsTextEditUtils.cpp
+++ b/editor/libeditor/text/nsTextEditUtils.cpp
@@ -1,20 +1,29 @@
 /* -*- Mode: C++; 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 "nsTextEditUtils.h"
-
+#include "mozilla/Assertions.h"
 #include "mozilla/dom/Element.h"
-
+#include "nsAString.h"
+#include "nsCOMPtr.h"
+#include "nsCaseTreatment.h"
+#include "nsDebug.h"
 #include "nsEditor.h"
+#include "nsError.h"
+#include "nsGkAtoms.h"
+#include "nsIDOMElement.h"
+#include "nsIDOMNode.h"
+#include "nsINameSpaceManager.h"
+#include "nsLiteralString.h"
 #include "nsPlaintextEditor.h"
-#include "nsEditProperty.h"
+#include "nsString.h"
+#include "nsTextEditUtils.h"
 
 using namespace mozilla;
 
 ///////////////////////////////////////////////////////////////////////////
 // IsBody: true if node an html body node
 bool 
 nsTextEditUtils::IsBody(nsIDOMNode *node)
 {
--- a/editor/libeditor/text/nsTextEditUtils.h
+++ b/editor/libeditor/text/nsTextEditUtils.h
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef nsTextEditUtils_h__
 #define nsTextEditUtils_h__
 
-#include "nsError.h"  // for nsresult
+#include "nscore.h"
 
 namespace mozilla {
 namespace dom {
 class Element;
 } // namespace dom
 } // namespace mozilla
 
 class nsIDOMNode;
--- a/editor/txmgr/src/nsTransactionItem.cpp
+++ b/editor/txmgr/src/nsTransactionItem.cpp
@@ -1,19 +1,23 @@
 /* -*- Mode: C++; 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 "mozilla/mozalloc.h"
+#include "nsAutoPtr.h"
+#include "nsCOMPtr.h"
+#include "nsDebug.h"
+#include "nsError.h"
 #include "nsITransaction.h"
-#include "nsTransactionStack.h"
+#include "nsTraceRefcnt.h"
+#include "nsTransactionItem.h"
 #include "nsTransactionManager.h"
-#include "nsTransactionItem.h"
-#include "nsCOMPtr.h"
-#include "nsAutoPtr.h"
+#include "nsTransactionStack.h"
 
 nsTransactionItem::nsTransactionItem(nsITransaction *aTransaction)
     : mTransaction(aTransaction), mUndoStack(0), mRedoStack(0)
 {
 }
 
 nsTransactionItem::~nsTransactionItem()
 {
--- a/editor/txmgr/src/nsTransactionItem.h
+++ b/editor/txmgr/src/nsTransactionItem.h
@@ -1,22 +1,25 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef nsTransactionItem_h__
 #define nsTransactionItem_h__
 
-#include "nsITransaction.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
+#include "nsISupportsImpl.h"
+#include "nscore.h"
+#include "prtypes.h"
 
+class nsITransaction;
+class nsTransactionManager;
 class nsTransactionStack;
-class nsTransactionManager;
 
 class nsTransactionItem
 {
   nsCOMPtr<nsITransaction> mTransaction;
   nsTransactionStack      *mUndoStack;
   nsTransactionStack      *mRedoStack;
   nsAutoRefCnt             mRefCnt;
 
--- a/editor/txmgr/src/nsTransactionList.cpp
+++ b/editor/txmgr/src/nsTransactionList.cpp
@@ -1,17 +1,25 @@
 /* -*- Mode: C++; 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 "mozilla/mozalloc.h"
+#include "nsCOMPtr.h"
+#include "nsDebug.h"
+#include "nsError.h"
+#include "nsID.h"
+#include "nsISupportsUtils.h"
 #include "nsITransactionManager.h"
 #include "nsTransactionItem.h"
 #include "nsTransactionList.h"
 #include "nsTransactionStack.h"
+#include "nscore.h"
+#include "prtypes.h"
 
 NS_IMPL_ISUPPORTS1(nsTransactionList, nsITransactionList)
 
 nsTransactionList::nsTransactionList(nsITransactionManager *aTxnMgr, nsTransactionStack *aTxnStack)
   : mTxnStack(aTxnStack)
   , mTxnItem(0)
 {
   if (aTxnMgr)
--- a/editor/txmgr/src/nsTransactionList.h
+++ b/editor/txmgr/src/nsTransactionList.h
@@ -1,25 +1,25 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef nsTransactionList_h__
 #define nsTransactionList_h__
 
-#include "nsWeakReference.h"
+#include "nsAutoPtr.h"
+#include "nsISupportsImpl.h"
 #include "nsITransactionList.h"
-#include "nsTransactionItem.h"
-#include "nsAutoPtr.h"
+#include "nsIWeakReferenceUtils.h"
 
 class nsITransaction;
 class nsITransactionManager;
+class nsTransactionItem;
 class nsTransactionStack;
-class nsTransactionRedoStack;
 
 /** implementation of a transaction list object.
  *
  */
 class nsTransactionList : public nsITransactionList
 {
 private:
 
--- a/editor/txmgr/src/nsTransactionManager.cpp
+++ b/editor/txmgr/src/nsTransactionManager.cpp
@@ -1,24 +1,29 @@
 /* -*- Mode: C++; 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 "nsITransaction.h"
-#include "nsITransactionListener.h"
-
-#include "nsTransactionItem.h"
-#include "nsTransactionStack.h"
-#include "nsVoidArray.h"
-#include "nsTransactionManager.h"
-#include "nsTransactionList.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/mozalloc.h"
 #include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
-#include "mozilla/Assertions.h"
+#include "nsDebug.h"
+#include "nsError.h"
+#include "nsISupportsBase.h"
+#include "nsISupportsUtils.h"
+#include "nsITransaction.h"
+#include "nsITransactionList.h"
+#include "nsITransactionListener.h"
+#include "nsIWeakReference.h"
+#include "nsTransactionItem.h"
+#include "nsTransactionList.h"
+#include "nsTransactionManager.h"
+#include "nsTransactionStack.h"
 
 nsTransactionManager::nsTransactionManager(PRInt32 aMaxTransactionCount)
   : mMaxTransactionCount(aMaxTransactionCount)
   , mDoStack(nsTransactionStack::FOR_UNDO)
   , mUndoStack(nsTransactionStack::FOR_UNDO)
   , mRedoStack(nsTransactionStack::FOR_REDO)
 {
 }
--- a/editor/txmgr/src/nsTransactionManager.h
+++ b/editor/txmgr/src/nsTransactionManager.h
@@ -1,22 +1,25 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef nsTransactionManager_h__
 #define nsTransactionManager_h__
 
-#include "nsWeakReference.h"
+#include "nsCOMArray.h"
+#include "nsCOMPtr.h"
+#include "nsCycleCollectionParticipant.h"
+#include "nsISupportsImpl.h"
 #include "nsITransactionManager.h"
-#include "nsCOMArray.h"
-#include "nsITransactionListener.h"
-#include "nsCycleCollectionParticipant.h"
 #include "nsTransactionStack.h"
+#include "nsWeakReference.h"
+#include "nscore.h"
+#include "prtypes.h"
 
 class nsITransaction;
 class nsITransactionListener;
 class nsTransactionItem;
 
 /** implementation of a transaction manager object.
  *
  */
--- a/editor/txmgr/src/nsTransactionManagerFactory.cpp
+++ b/editor/txmgr/src/nsTransactionManagerFactory.cpp
@@ -1,17 +1,21 @@
 /* -*- 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 <stddef.h>
+
+#include "mozilla/Module.h"
 #include "mozilla/ModuleUtils.h"
+#include "nsID.h"
+#include "nsITransactionManager.h"
+#include "nsTransactionManager.h"
 #include "nsTransactionManagerCID.h"
-#include "nsTransactionStack.h"
-#include "nsTransactionManager.h"
 
 ////////////////////////////////////////////////////////////////////////
 // Define the contructor function for the objects
 //
 // NOTE: This creates an instance of objects by using the default constructor
 //
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransactionManager)
 NS_DEFINE_NAMED_CID(NS_TRANSACTIONMANAGER_CID);
--- a/editor/txmgr/src/nsTransactionStack.cpp
+++ b/editor/txmgr/src/nsTransactionStack.cpp
@@ -1,20 +1,20 @@
 /* -*- Mode: C++; 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 "nsITransaction.h"
+#include "nsAutoPtr.h"
+#include "nsCOMPtr.h"
+#include "nsCycleCollectionParticipant.h"
+#include "nsISupportsUtils.h"
 #include "nsTransactionItem.h"
 #include "nsTransactionStack.h"
-#include "nsCOMPtr.h"
-#include "nsAutoPtr.h"
-#include "nsCycleCollectionParticipant.h"
-#include "mozilla/Util.h"
+#include "nscore.h"
 
 nsTransactionStack::nsTransactionStack(nsTransactionStack::Type aType)
   : mQue(0)
   , mType(aType)
 {
 }
 
 nsTransactionStack::~nsTransactionStack()
--- a/editor/txmgr/src/nsTransactionStack.h
+++ b/editor/txmgr/src/nsTransactionStack.h
@@ -1,19 +1,21 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef nsTransactionStack_h__
 #define nsTransactionStack_h__
 
+#include "nsCOMPtr.h"
 #include "nsDeque.h"
-#include "nsCOMPtr.h"
+#include "prtypes.h"
 
+class nsCycleCollectionTraversalCallback;
 class nsTransactionItem;
 
 class nsTransactionStack
 {
 public:
   enum Type { FOR_UNDO, FOR_REDO };
 
   explicit nsTransactionStack(Type aType);
--- a/editor/txtsvc/src/nsFilteredContentIterator.cpp
+++ b/editor/txtsvc/src/nsFilteredContentIterator.cpp
@@ -1,23 +1,30 @@
 /* -*- Mode: C++; 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 "mozilla/mozalloc.h"
+#include "nsComponentManagerUtils.h"
+#include "nsContentUtils.h"
+#include "nsDebug.h"
+#include "nsError.h"
 #include "nsFilteredContentIterator.h"
-#include "nsIContentIterator.h"
-#include "nsComponentManagerUtils.h"
+#include "nsIAtom.h"
 #include "nsIContent.h"
-#include "nsString.h"
-#include "nsIEnumerator.h"
-
-#include "nsContentUtils.h"
-
+#include "nsIContentIterator.h"
 #include "nsIDOMNode.h"
+#include "nsIDOMRange.h"
+#include "nsINode.h"
+#include "nsISupportsBase.h"
+#include "nsISupportsUtils.h"
+#include "nsITextServicesFilter.h"
+#include "nsRange.h"
+#include "prtypes.h"
 
 //------------------------------------------------------------
 nsFilteredContentIterator::nsFilteredContentIterator(nsITextServicesFilter* aFilter) :
   mFilter(aFilter),
   mDidSkip(false),
   mIsOutOfRange(false),
   mDirection(eDirNotSet)
 {
--- a/editor/txtsvc/src/nsFilteredContentIterator.h
+++ b/editor/txtsvc/src/nsFilteredContentIterator.h
@@ -1,22 +1,27 @@
 /* -*- Mode: C++; 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/. */
 
 #ifndef nsFilteredContentIterator_h__
 #define nsFilteredContentIterator_h__
 
+#include "nsCOMPtr.h"
+#include "nsCycleCollectionParticipant.h"
 #include "nsIContentIterator.h"
-#include "nsCOMPtr.h"
-#include "nsIAtom.h"
-#include "nsITextServicesFilter.h"
-#include "nsRange.h"
-#include "nsCycleCollectionParticipant.h"
+#include "nsISupportsImpl.h"
+#include "nscore.h"
+
+class nsIAtom;
+class nsIDOMNode;
+class nsIDOMRange;
+class nsINode;
+class nsITextServicesFilter;
 
 /**
  * 
  */
 class nsFilteredContentIterator : public nsIContentIterator
 {
 public:
 
--- a/editor/txtsvc/src/nsTextServicesDocument.cpp
+++ b/editor/txtsvc/src/nsTextServicesDocument.cpp
@@ -1,37 +1,47 @@
 /* -*- Mode: C++; 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 "mozilla/Util.h"
-
-#include "nscore.h"
-#include "nsLayoutCID.h"
-#include "nsIAtom.h"
-#include "nsStaticAtom.h"
-#include "nsString.h"
-#include "nsIEnumerator.h"
-#include "nsIContent.h"
-#include "nsIContentIterator.h"
-#include "nsIDOMNodeList.h"
-#include "nsIDOMRange.h"
-#include "nsContentUtils.h"
-#include "nsISelection.h"
-#include "nsIPlaintextEditor.h"
+#include <stddef.h>                     // for NULL
+
+#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
+#include "mozilla/mozalloc.h"           // for operator new, etc
+#include "nsAString.h"                  // for nsAString_internal::Length, etc
+#include "nsAutoPtr.h"                  // for nsRefPtr
+#include "nsContentUtils.h"             // for nsContentUtils
+#include "nsDebug.h"                    // for NS_ENSURE_TRUE, etc
+#include "nsDependentSubstring.h"       // for Substring
+#include "nsError.h"                    // for NS_OK, NS_ERROR_FAILURE, etc
+#include "nsFilteredContentIterator.h"  // for nsFilteredContentIterator
+#include "nsIContent.h"                 // for nsIContent, etc
+#include "nsIContentIterator.h"         // for nsIContentIterator
+#include "nsID.h"                       // for NS_GET_IID
+#include "nsIDOMDocument.h"             // for nsIDOMDocument
+#include "nsIDOMElement.h"              // for nsIDOMElement
+#include "nsIDOMHTMLDocument.h"         // for nsIDOMHTMLDocument
+#include "nsIDOMHTMLElement.h"          // for nsIDOMHTMLElement
+#include "nsIDOMNode.h"                 // for nsIDOMNode, etc
+#include "nsIDOMRange.h"                // for nsIDOMRange, etc
+#include "nsIEditor.h"                  // for nsIEditor, etc
+#include "nsINode.h"                    // for nsINode
+#include "nsIPlaintextEditor.h"         // for nsIPlaintextEditor
+#include "nsISelection.h"               // for nsISelection
+#include "nsISelectionController.h"     // for nsISelectionController, etc
+#include "nsISupportsBase.h"            // for nsISupports
+#include "nsISupportsUtils.h"           // for NS_IF_ADDREF, NS_ADDREF, etc
+#include "nsITextServicesFilter.h"      // for nsITextServicesFilter
+#include "nsIWordBreaker.h"             // for nsWordRange, nsIWordBreaker
+#include "nsRange.h"                    // for nsRange
+#include "nsStaticAtom.h"               // for NS_STATIC_ATOM, etc
+#include "nsString.h"                   // for nsString, nsAutoString
 #include "nsTextServicesDocument.h"
-#include "nsFilteredContentIterator.h"
-
-#include "nsIDOMElement.h"
-#include "nsIDOMHTMLElement.h"
-#include "nsIDOMHTMLDocument.h"
-
-#include "nsIWordBreaker.h"
-#include "nsIServiceManager.h"
+#include "nscore.h"                     // for nsresult, NS_IMETHODIMP, etc
 
 #define LOCK_DOC(doc)
 #define UNLOCK_DOC(doc)
 
 using namespace mozilla;
 
 class OffsetEntry
 {
@@ -60,17 +70,17 @@ public:
   PRInt32 mNodeOffset;
   PRInt32 mStrOffset;
   PRInt32 mLength;
   bool    mIsInsertedText;
   bool    mIsValid;
 };
 
 #define TS_ATOM(name_, value_) nsIAtom* nsTextServicesDocument::name_ = 0;
-#include "nsTSAtomList.h"
+#include "nsTSAtomList.h" // IWYU pragma: keep
 #undef TS_ATOM
 
 nsTextServicesDocument::nsTextServicesDocument()
 {
   mRefCnt         = 0;
 
   mSelStartIndex  = -1;
   mSelStartOffset = -1;
@@ -81,26 +91,26 @@ nsTextServicesDocument::nsTextServicesDo
 }
 
 nsTextServicesDocument::~nsTextServicesDocument()
 {
   ClearOffsetTable(&mOffsetTable);
 }
 
 #define TS_ATOM(name_, value_) NS_STATIC_ATOM_BUFFER(name_##_buffer, value_)
-#include "nsTSAtomList.h"
+#include "nsTSAtomList.h" // IWYU pragma: keep
 #undef TS_ATOM
 
 /* static */
 void
 nsTextServicesDocument::RegisterAtoms()
 {
   static const nsStaticAtom ts_atoms[] = {
 #define TS_ATOM(name_, value_) NS_STATIC_ATOM(name_##_buffer, &name_),
-#include "nsTSAtomList.h"
+#include "nsTSAtomList.h" // IWYU pragma: keep
 #undef TS_ATOM
   };
 
   NS_RegisterStaticAtoms(ts_atoms);
 }
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsTextServicesDocument)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsTextServicesDocument)
--- a/editor/txtsvc/src/nsTextServicesDocument.h
+++ b/editor/txtsvc/src/nsTextServicesDocument.h
@@ -2,30 +2,38 @@
 /* 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 nsTextServicesDocument_h__
 #define nsTextServicesDocument_h__
 
 #include "nsCOMPtr.h"
-#include "nsIDOMDocument.h"
-#include "nsIDOMRange.h"
-#include "nsIContent.h"
-#include "nsIContentIterator.h"
-#include "nsIEditor.h"
+#include "nsCycleCollectionParticipant.h"
 #include "nsIEditActionListener.h"
+#include "nsISupportsImpl.h"
 #include "nsITextServicesDocument.h"
+#include "nsIWeakReferenceUtils.h"
 #include "nsTArray.h"
-#include "nsISelectionController.h"
-#include "nsITextServicesFilter.h"
-#include "nsWeakReference.h"
-#include "nsCycleCollectionParticipant.h"
+#include "nscore.h"
+#include "prtypes.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 : public nsITextServicesDocument,
                                public nsIEditActionListener
 {
 private:
--- a/layout/forms/nsTextControlFrame.cpp
+++ b/layout/forms/nsTextControlFrame.cpp
@@ -10,17 +10,16 @@
 #include "nsIServiceManager.h"
 #include "nsFrameSelection.h"
 #include "nsIPlaintextEditor.h"
 #include "nsEditorCID.h"
 #include "nsLayoutCID.h"
 #include "nsIDocumentEncoder.h"
 #include "nsCaret.h"
 #include "nsISelectionListener.h"
-#include "nsISelectionPrivate.h"
 #include "nsIController.h"
 #include "nsIControllers.h"
 #include "nsIControllerContext.h"
 #include "nsGenericHTMLElement.h"
 #include "nsIEditorIMESupport.h"
 #include "nsIPhonetic.h"
 #include "nsTextFragment.h"
 #include "nsIEditorObserver.h"
@@ -69,16 +68,17 @@
 #include "nsContentCreatorFunctions.h"
 #include "nsINativeKeyBindings.h"
 #include "nsIJSContextStack.h"
 #include "nsFocusManager.h"
 #include "nsTextEditRules.h"
 #include "nsPresState.h"
 
 #include "mozilla/FunctionTimer.h"
+#include "mozilla/Selection.h"
 
 #define DEFAULT_COLUMN_WIDTH 20
 
 using namespace mozilla;
 
 nsIFrame*
 NS_NewTextControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
 {
--- a/layout/style/nsStyleStructList.h
+++ b/layout/style/nsStyleStructList.h
@@ -1,14 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 // vim:cindent:ts=8:et:sw=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/. */
 
+// IWYU pragma: private, include "nsStyleStructFwd.h"
+
 /*
  * list of structs that contain the data provided by nsStyleContext, the
  * internal API for computed style data for an element
  */
 
 /*
  * This file is intended to be used by different parts of the code, with
  * the STYLE_STRUCT macro (or the STYLE_STRUCT_INHERITED and
--- a/parser/htmlparser/public/nsHTMLTagList.h
+++ b/parser/htmlparser/public/nsHTMLTagList.h
@@ -1,13 +1,15 @@
 /* -*- Mode: C++; 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/. */
 
+// IWYU pragma: private, include "nsHTMLTags.h"
+
 /******
 
   This file contains the list of all HTML tags 
   See nsHTMLTags.h for access to the enum values for tags
 
   It is designed to be used as inline input to nsHTMLTags.cpp and
   nsHTMLContentSink *only* through the magic of C preprocessing.
 
--- a/xpcom/build/ServiceList.h
+++ b/xpcom/build/ServiceList.h
@@ -1,12 +1,14 @@
 /* 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/. */
 
+// IWYU pragma: private, include "mozilla/Services.h"
+
 #ifdef ACCESSIBILITY
 MOZ_SERVICE(AccessibilityService, nsIAccessibilityService, "@mozilla.org/accessibilityService;1")
 #endif
 MOZ_SERVICE(ChromeRegistryService, nsIChromeRegistry, "@mozilla.org/chrome/chrome-registry;1")
 MOZ_SERVICE(ToolkitChromeRegistryService, nsIToolkitChromeRegistry, "@mozilla.org/chrome/chrome-registry;1")
 MOZ_SERVICE(XULChromeRegistryService, nsIXULChromeRegistry, "@mozilla.org/chrome/chrome-registry;1")
 MOZ_SERVICE(XULOverlayProviderService, nsIXULOverlayProvider, "@mozilla.org/chrome/chrome-registry;1")
 MOZ_SERVICE(IOService, nsIIOService, "@mozilla.org/network/io-service;1")
--- a/xpcom/string/public/nsTDependentSubstring.h
+++ b/xpcom/string/public/nsTDependentSubstring.h
@@ -1,14 +1,15 @@
 /* -*- 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/. */
 
+// IWYU pragma: private, include "nsDependentSubstring.h"
 
   /**
    * nsTDependentSubstring_CharT
    *
    * A string class which wraps an external array of string characters. It
    * is the client code's responsibility to ensure that the external buffer
    * remains valid for a long as the string is alive.
    *
--- a/xpcom/string/public/nsTString.h
+++ b/xpcom/string/public/nsTString.h
@@ -1,14 +1,15 @@
 /* -*- 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/. */
 
+// IWYU pragma: private, include "nsString.h"
 
   /**
    * This is the canonical null-terminated string class.  All subclasses
    * promise null-terminated storage.  Instances of this class allocate
    * strings on the heap.
    *
    * NAMES:
    *   nsString for wide characters
--- a/xpcom/string/public/nsTSubstring.h
+++ b/xpcom/string/public/nsTSubstring.h
@@ -1,14 +1,16 @@
 /* -*- 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/. */
 
+// IWYU pragma: private, include "nsAString.h"
+
 #ifndef MOZILLA_INTERNAL_API
 #error Cannot use internal string classes without MOZILLA_INTERNAL_API defined. Use the frozen header nsStringAPI.h instead.
 #endif
 
   /**
    * The base for string comparators
    */
 class nsTStringComparator_CharT
--- a/xpcom/string/public/nsTSubstringTuple.h
+++ b/xpcom/string/public/nsTSubstringTuple.h
@@ -1,14 +1,15 @@
 //* -*- 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/. */
 
+// IWYU pragma: private, include "nsSubstringTuple.h"
 
   /**
    * nsTSubstringTuple_CharT
    *
    * Represents a tuple of string fragments.  Built as a recursive binary tree.
    * It is used to implement the concatenation of two or more string objects.
    *
    * NOTE: This class is a private implementation detail and should never be 
--- a/xpcom/string/public/string-template-def-char.h
+++ b/xpcom/string/public/string-template-def-char.h
@@ -1,14 +1,16 @@
 /* -*- 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/. */
 
+// IWYU pragma: private, include "nsString.h"
+
 #define CharT                               char
 #define CharT_is_char                       1
 #define nsTAString_IncompatibleCharT        nsAString
 #define nsTString_CharT                     nsCString
 #define nsTFixedString_CharT                nsFixedCString
 #define nsTAutoString_CharT                 nsCAutoString
 #define nsTSubstring_CharT                  nsACString
 #define nsTSubstringTuple_CharT             nsCSubstringTuple
--- a/xpcom/string/public/string-template-def-unichar.h
+++ b/xpcom/string/public/string-template-def-unichar.h
@@ -1,14 +1,16 @@
 /* -*- 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/. */
 
+// IWYU pragma: private, include "nsString.h"
+
 #define CharT                               PRUnichar
 #define CharT_is_PRUnichar                  1
 #define nsTAString_IncompatibleCharT        nsACString
 #define nsTString_CharT                     nsString
 #define nsTFixedString_CharT                nsFixedString
 #define nsTAutoString_CharT                 nsAutoString
 #define nsTSubstring_CharT                  nsAString
 #define nsTSubstringTuple_CharT             nsSubstringTuple