From e705b3211cbcf70c2a6f245f2487c239b1ed4823 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Fri, 29 Mar 2019 15:11:04 +0000 Subject: [PATCH] Bug 1540015 - part 1: Make Document.h stop including nsIPresShell.h r=smaug If `Document::GetShell()` returns `PresShell*` rather than `nsIPresShell`, it's a good step to deCOMTaminate `PresShell`. This patch makes `Document.h` stop including `nsIPresShell.h` since `nsIPresShell.h` includes `Document.h` indirectly and that causes bustage when we make `Document::GetShell()` return `PresShell*`. Differential Revision: https://phabricator.services.mozilla.com/D25332 --HG-- extra : moz-landing-system : lando --- dom/animation/Animation.cpp | 1 + dom/animation/AnimationUtils.h | 1 + dom/base/Document.h | 13 ++++--------- dom/base/DocumentInlines.h | 14 +++++++++++++- dom/base/Location.cpp | 3 ++- dom/base/PostMessageEvent.cpp | 1 + dom/base/nsContentUtils.cpp | 1 + dom/base/nsDOMWindowUtils.cpp | 1 + dom/base/nsGlobalWindowInner.cpp | 1 + dom/base/nsHistory.cpp | 1 + dom/base/nsNodeUtils.cpp | 1 + dom/browser-element/BrowserElementParent.cpp | 1 + dom/events/Event.cpp | 7 ++++--- dom/html/HTMLLinkElement.cpp | 1 + dom/html/HTMLMenuElement.cpp | 1 + dom/html/HTMLSourceElement.cpp | 1 + dom/plugins/base/nsPluginInstanceOwner.cpp | 1 + dom/smil/SMILAnimationController.cpp | 1 + dom/smil/SMILTimedElement.cpp | 1 + dom/svg/SVGAElement.cpp | 1 + dom/xul/XULBroadcastManager.cpp | 3 ++- layout/inspector/inLayoutUtils.cpp | 1 + layout/style/nsHTMLStyleSheet.cpp | 1 + layout/style/nsMediaFeatures.cpp | 1 + layout/xul/nsImageBoxFrame.cpp | 1 + layout/xul/nsXULPopupManager.cpp | 1 + parser/html/nsHtml5SVGLoadDispatcher.cpp | 1 + .../components/sessionstore/SessionStoreUtils.cpp | 2 ++ .../components/windowwatcher/nsWindowWatcher.cpp | 1 + widget/cocoa/nsMenuUtilsX.mm | 8 +++++--- 30 files changed, 55 insertions(+), 18 deletions(-) diff --git a/dom/animation/Animation.cpp b/dom/animation/Animation.cpp index 233ac366623f..d990c754c41e 100644 --- a/dom/animation/Animation.cpp +++ b/dom/animation/Animation.cpp @@ -9,6 +9,7 @@ #include "mozilla/dom/AnimationBinding.h" #include "mozilla/dom/AnimationPlaybackEvent.h" #include "mozilla/dom/Document.h" +#include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/DocumentTimeline.h" #include "mozilla/AnimationEventDispatcher.h" #include "mozilla/AnimationTarget.h" diff --git a/dom/animation/AnimationUtils.h b/dom/animation/AnimationUtils.h index 42201e78f9a4..7af19aedca96 100644 --- a/dom/animation/AnimationUtils.h +++ b/dom/animation/AnimationUtils.h @@ -19,6 +19,7 @@ struct JSContext; namespace mozilla { +enum class PseudoStyleType : uint8_t; class ComputedTimingFunction; class EffectSet; diff --git a/dom/base/Document.h b/dom/base/Document.h index 538ea3b982cd..b759e8a61feb 100644 --- a/dom/base/Document.h +++ b/dom/base/Document.h @@ -6,6 +6,7 @@ #ifndef mozilla_dom_Document_h___ #define mozilla_dom_Document_h___ +#include "mozilla/EventStates.h" // for EventStates #include "mozilla/FlushType.h" // for enum #include "mozilla/Pair.h" // for Pair #include "nsAutoPtr.h" // for member @@ -23,7 +24,6 @@ #include "nsILoadGroup.h" // for member (in nsCOMPtr) #include "nsINode.h" // for base class #include "nsIParser.h" -#include "nsIPresShell.h" #include "nsIChannelEventSink.h" #include "nsIProgressEventSink.h" #include "nsIRadioGroupContainer.h" @@ -107,6 +107,7 @@ class nsILayoutHistoryState; class nsILoadContext; class nsIObjectLoadingContent; class nsIObserver; +class nsIPresShell; class nsIPrincipal; class nsIRequest; class nsIRunnable; @@ -1252,18 +1253,12 @@ class Document : public nsINode, return GetBFCacheEntry() ? nullptr : mPresShell; } - nsIPresShell* GetObservingShell() const { - return mPresShell && mPresShell->IsObservingDocument() ? mPresShell - : nullptr; - } + inline nsIPresShell* GetObservingShell() const; // Return whether the presshell for this document is safe to flush. bool IsSafeToFlush() const; - nsPresContext* GetPresContext() const { - nsIPresShell* shell = GetShell(); - return shell ? shell->GetPresContext() : nullptr; - } + inline nsPresContext* GetPresContext() const; bool HasShellOrBFCacheEntry() const { return mPresShell || mBFCacheEntry; } diff --git a/dom/base/DocumentInlines.h b/dom/base/DocumentInlines.h index 3661747b449b..928231908a3b 100644 --- a/dom/base/DocumentInlines.h +++ b/dom/base/DocumentInlines.h @@ -6,14 +6,26 @@ #ifndef mozilla_dom_DocumentInlines_h #define mozilla_dom_DocumentInlines_h -#include "nsContentUtils.h" #include "mozilla/dom/Document.h" + #include "mozilla/dom/HTMLBodyElement.h" +#include "nsContentUtils.h" +#include "nsIPresShell.h" +#include "nsPresContext.h" #include "nsStyleSheetService.h" namespace mozilla { namespace dom { +inline nsIPresShell* Document::GetObservingShell() const { + return mPresShell && mPresShell->IsObservingDocument() ? mPresShell : nullptr; +} + +inline nsPresContext* Document::GetPresContext() const { + nsIPresShell* presShell = GetShell(); + return presShell ? presShell->GetPresContext() : nullptr; +} + inline HTMLBodyElement* Document::GetBodyElement() { return static_cast(GetHtmlChildElement(nsGkAtoms::body)); } diff --git a/dom/base/Location.cpp b/dom/base/Location.cpp index 7345bccf70fe..02b753193c45 100644 --- a/dom/base/Location.cpp +++ b/dom/base/Location.cpp @@ -19,7 +19,6 @@ #include "nsCOMPtr.h" #include "nsEscape.h" #include "nsIDOMWindow.h" -#include "mozilla/dom/Document.h" #include "nsIPresShell.h" #include "nsPresContext.h" #include "nsError.h" @@ -33,6 +32,8 @@ #include "mozilla/Components.h" #include "mozilla/NullPrincipal.h" #include "mozilla/Unused.h" +#include "mozilla/dom/Document.h" +#include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/LocationBinding.h" #include "mozilla/dom/ScriptSettings.h" #include "ReferrerInfo.h" diff --git a/dom/base/PostMessageEvent.cpp b/dom/base/PostMessageEvent.cpp index 30072e329860..1bb2c3ec9682 100644 --- a/dom/base/PostMessageEvent.cpp +++ b/dom/base/PostMessageEvent.cpp @@ -8,6 +8,7 @@ #include "MessageEvent.h" #include "mozilla/dom/BlobBinding.h" +#include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/File.h" #include "mozilla/dom/FileList.h" #include "mozilla/dom/FileListBinding.h" diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 068b5ee7e14d..199e28447b22 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -50,6 +50,7 @@ #include "mozilla/dom/ContentChild.h" #include "mozilla/dom/CustomElementRegistry.h" #include "mozilla/dom/Document.h" +#include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/MessageBroadcaster.h" #include "mozilla/dom/DocumentFragment.h" #include "mozilla/dom/DOMException.h" diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 0cdcb03e340d..2318f6ef79d9 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -19,6 +19,7 @@ #include "mozilla/dom/Animation.h" #include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/BlobBinding.h" +#include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/Event.h" #include "mozilla/dom/Touch.h" #include "mozilla/PendingAnimationTracker.h" diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index 0f605566e65d..c4bdb3e262fd 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -18,6 +18,7 @@ #include "nsDOMNavigationTiming.h" #include "nsIDOMStorageManager.h" #include "mozilla/dom/ContentFrameMessageManager.h" +#include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/DOMJSProxyHandler.h" #include "mozilla/dom/DOMPrefs.h" #include "mozilla/dom/EventTarget.h" diff --git a/dom/base/nsHistory.cpp b/dom/base/nsHistory.cpp index ed161c6038f8..fe033a17db49 100644 --- a/dom/base/nsHistory.cpp +++ b/dom/base/nsHistory.cpp @@ -10,6 +10,7 @@ #include "nsCOMPtr.h" #include "nsPIDOMWindow.h" #include "mozilla/dom/Document.h" +#include "mozilla/dom/DocumentInlines.h" #include "nsIPresShell.h" #include "nsPresContext.h" #include "nsIDocShell.h" diff --git a/dom/base/nsNodeUtils.cpp b/dom/base/nsNodeUtils.cpp index 8e9cfe208cdf..cdf472170c28 100644 --- a/dom/base/nsNodeUtils.cpp +++ b/dom/base/nsNodeUtils.cpp @@ -11,6 +11,7 @@ #include "nsIContent.h" #include "nsIContentInlines.h" #include "mozilla/dom/Document.h" +#include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/Element.h" #include "nsIMutationObserver.h" #include "mozilla/EventListenerManager.h" diff --git a/dom/browser-element/BrowserElementParent.cpp b/dom/browser-element/BrowserElementParent.cpp index bc8d3d2a5f48..a8cd8ed1a3de 100644 --- a/dom/browser-element/BrowserElementParent.cpp +++ b/dom/browser-element/BrowserElementParent.cpp @@ -16,6 +16,7 @@ #include "BrowserElementParent.h" #include "mozilla/EventDispatcher.h" +#include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/HTMLIFrameElement.h" #include "mozilla/dom/ToJSValue.h" #include "mozilla/dom/WindowProxyHolder.h" diff --git a/dom/events/Event.cpp b/dom/events/Event.cpp index b1df64e2e690..66e53d3d5302 100644 --- a/dom/events/Event.cpp +++ b/dom/events/Event.cpp @@ -7,8 +7,6 @@ #include "AccessCheck.h" #include "base/basictypes.h" #include "ipc/IPCMessageUtils.h" -#include "mozilla/dom/Event.h" -#include "mozilla/dom/ShadowRoot.h" #include "mozilla/EventDispatcher.h" #include "mozilla/ContentEvents.h" #include "mozilla/DOMEventTargetHelper.h" @@ -21,6 +19,10 @@ #include "mozilla/Preferences.h" #include "mozilla/TextEvents.h" #include "mozilla/TouchEvents.h" +#include "mozilla/dom/Document.h" +#include "mozilla/dom/DocumentInlines.h" +#include "mozilla/dom/Event.h" +#include "mozilla/dom/ShadowRoot.h" #include "nsContentUtils.h" #include "nsCOMPtr.h" #include "nsDeviceContext.h" @@ -29,7 +31,6 @@ #include "nsIFrame.h" #include "nsIContent.h" #include "nsIContentInlines.h" -#include "mozilla/dom/Document.h" #include "nsIPresShell.h" #include "nsIScrollableFrame.h" #include "nsJSEnvironment.h" diff --git a/dom/html/HTMLLinkElement.cpp b/dom/html/HTMLLinkElement.cpp index f536f5f1df07..83633af42cad 100644 --- a/dom/html/HTMLLinkElement.cpp +++ b/dom/html/HTMLLinkElement.cpp @@ -12,6 +12,7 @@ #include "mozilla/EventStates.h" #include "mozilla/MemoryReporting.h" #include "mozilla/Preferences.h" +#include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/HTMLLinkElementBinding.h" #include "nsContentUtils.h" #include "nsGenericHTMLElement.h" diff --git a/dom/html/HTMLMenuElement.cpp b/dom/html/HTMLMenuElement.cpp index ccb8066708d8..50be13aee836 100644 --- a/dom/html/HTMLMenuElement.cpp +++ b/dom/html/HTMLMenuElement.cpp @@ -8,6 +8,7 @@ #include "mozilla/BasicEvents.h" #include "mozilla/EventDispatcher.h" +#include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/HTMLMenuElementBinding.h" #include "mozilla/dom/HTMLMenuItemElement.h" #include "nsIMenuBuilder.h" diff --git a/dom/html/HTMLSourceElement.cpp b/dom/html/HTMLSourceElement.cpp index 024b00f6f014..8ab627811d55 100644 --- a/dom/html/HTMLSourceElement.cpp +++ b/dom/html/HTMLSourceElement.cpp @@ -7,6 +7,7 @@ #include "mozilla/dom/HTMLSourceElement.h" #include "mozilla/dom/HTMLSourceElementBinding.h" +#include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/HTMLImageElement.h" #include "mozilla/dom/HTMLMediaElement.h" #include "mozilla/dom/ResponsiveImageSelector.h" diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index 6d7268a54592..3c26d5e9010c 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -52,6 +52,7 @@ using mozilla::DefaultXDisplay; #include "mozilla/MouseEvents.h" #include "mozilla/NullPrincipal.h" #include "mozilla/TextEvents.h" +#include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/DragEvent.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/Event.h" diff --git a/dom/smil/SMILAnimationController.cpp b/dom/smil/SMILAnimationController.cpp index 99e4f4952385..67d860b22015 100644 --- a/dom/smil/SMILAnimationController.cpp +++ b/dom/smil/SMILAnimationController.cpp @@ -11,6 +11,7 @@ #include "mozilla/AutoRestore.h" #include "mozilla/RestyleManager.h" #include "mozilla/SMILTimedElement.h" +#include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/SVGAnimationElement.h" #include "nsContentUtils.h" diff --git a/dom/smil/SMILTimedElement.cpp b/dom/smil/SMILTimedElement.cpp index e752f239c0ee..ce8a7a6c4076 100644 --- a/dom/smil/SMILTimedElement.cpp +++ b/dom/smil/SMILTimedElement.cpp @@ -17,6 +17,7 @@ #include "mozilla/SMILTimeValue.h" #include "mozilla/SMILTimeValueSpec.h" #include "mozilla/TaskCategory.h" +#include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/SVGAnimationElement.h" #include "nsAttrValueInlines.h" #include "nsGkAtoms.h" diff --git a/dom/svg/SVGAElement.cpp b/dom/svg/SVGAElement.cpp index f5a893196060..16457b54b7b4 100644 --- a/dom/svg/SVGAElement.cpp +++ b/dom/svg/SVGAElement.cpp @@ -9,6 +9,7 @@ #include "mozilla/Attributes.h" #include "mozilla/EventDispatcher.h" #include "mozilla/EventStates.h" +#include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/SVGAElementBinding.h" #include "nsCOMPtr.h" #include "nsContentUtils.h" diff --git a/dom/xul/XULBroadcastManager.cpp b/dom/xul/XULBroadcastManager.cpp index c6822b9c3d9d..949dab43a1f3 100644 --- a/dom/xul/XULBroadcastManager.cpp +++ b/dom/xul/XULBroadcastManager.cpp @@ -8,8 +8,9 @@ #include "nsCOMPtr.h" #include "nsContentUtils.h" #include "mozilla/EventDispatcher.h" -#include "nsXULElement.h" #include "mozilla/Logging.h" +#include "mozilla/dom/DocumentInlines.h" +#include "nsXULElement.h" struct BroadcastListener { nsWeakPtr mListener; diff --git a/layout/inspector/inLayoutUtils.cpp b/layout/inspector/inLayoutUtils.cpp index 8463a7bc6772..0d48127622fa 100644 --- a/layout/inspector/inLayoutUtils.cpp +++ b/layout/inspector/inLayoutUtils.cpp @@ -14,6 +14,7 @@ #include "nsIPresShell.h" #include "nsPresContext.h" #include "mozilla/EventStateManager.h" +#include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/Element.h" using namespace mozilla; diff --git a/layout/style/nsHTMLStyleSheet.cpp b/layout/style/nsHTMLStyleSheet.cpp index c28f3df270bf..f7317905ce55 100644 --- a/layout/style/nsHTMLStyleSheet.cpp +++ b/layout/style/nsHTMLStyleSheet.cpp @@ -15,6 +15,7 @@ #include "nsPresContext.h" #include "mozilla/EventStates.h" #include "mozilla/dom/Document.h" +#include "mozilla/dom/DocumentInlines.h" #include "nsIPresShell.h" #include "nsStyleConsts.h" #include "nsError.h" diff --git a/layout/style/nsMediaFeatures.cpp b/layout/style/nsMediaFeatures.cpp index fa6f993c6048..96d272b25fc5 100644 --- a/layout/style/nsMediaFeatures.cpp +++ b/layout/style/nsMediaFeatures.cpp @@ -18,6 +18,7 @@ #include "nsIBaseWindow.h" #include "nsIDocShell.h" #include "mozilla/dom/Document.h" +#include "mozilla/dom/DocumentInlines.h" #include "nsIWidget.h" #include "nsContentUtils.h" #include "mozilla/StyleSheet.h" diff --git a/layout/xul/nsImageBoxFrame.cpp b/layout/xul/nsImageBoxFrame.cpp index 5a56e22e553c..38c83173a580 100644 --- a/layout/xul/nsImageBoxFrame.cpp +++ b/layout/xul/nsImageBoxFrame.cpp @@ -26,6 +26,7 @@ #include "nsLeafFrame.h" #include "nsIPresShell.h" #include "mozilla/dom/Document.h" +#include "mozilla/dom/DocumentInlines.h" #include "nsImageMap.h" #include "nsILinkHandler.h" #include "nsIURL.h" diff --git a/layout/xul/nsXULPopupManager.cpp b/layout/xul/nsXULPopupManager.cpp index 6425e4042db4..a85f9fabfa6b 100644 --- a/layout/xul/nsXULPopupManager.cpp +++ b/layout/xul/nsXULPopupManager.cpp @@ -32,6 +32,7 @@ #include "nsIObserverService.h" #include "XULDocument.h" #include "mozilla/AnimationUtils.h" +#include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/Event.h" // for Event #include "mozilla/dom/KeyboardEvent.h" diff --git a/parser/html/nsHtml5SVGLoadDispatcher.cpp b/parser/html/nsHtml5SVGLoadDispatcher.cpp index 758a49ed678f..bf2f2d39ddbb 100644 --- a/parser/html/nsHtml5SVGLoadDispatcher.cpp +++ b/parser/html/nsHtml5SVGLoadDispatcher.cpp @@ -6,6 +6,7 @@ #include "mozilla/BasicEvents.h" #include "mozilla/EventDispatcher.h" #include "mozilla/dom/Document.h" +#include "mozilla/dom/DocumentInlines.h" #include "nsIPresShell.h" #include "nsPresContext.h" diff --git a/toolkit/components/sessionstore/SessionStoreUtils.cpp b/toolkit/components/sessionstore/SessionStoreUtils.cpp index 01aea6244329..409943f91143 100644 --- a/toolkit/components/sessionstore/SessionStoreUtils.cpp +++ b/toolkit/components/sessionstore/SessionStoreUtils.cpp @@ -4,6 +4,8 @@ #include "js/JSON.h" #include "jsapi.h" +#include "mozilla/dom/Document.h" +#include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/HTMLInputElement.h" #include "mozilla/dom/HTMLSelectElement.h" #include "mozilla/dom/HTMLTextAreaElement.h" diff --git a/toolkit/components/windowwatcher/nsWindowWatcher.cpp b/toolkit/components/windowwatcher/nsWindowWatcher.cpp index c79b5bb02acf..1e0555f5b167 100644 --- a/toolkit/components/windowwatcher/nsWindowWatcher.cpp +++ b/toolkit/components/windowwatcher/nsWindowWatcher.cpp @@ -27,6 +27,7 @@ #include "nsIDocShellTreeOwner.h" #include "nsIDocumentLoader.h" #include "mozilla/dom/Document.h" +#include "mozilla/dom/DocumentInlines.h" #include "nsIDOMWindow.h" #include "nsIDOMChromeWindow.h" #include "nsIPrompt.h" diff --git a/widget/cocoa/nsMenuUtilsX.mm b/widget/cocoa/nsMenuUtilsX.mm index bad87d6ed538..5bc169ee0c51 100644 --- a/widget/cocoa/nsMenuUtilsX.mm +++ b/widget/cocoa/nsMenuUtilsX.mm @@ -3,8 +3,12 @@ * 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/Event.h" #include "nsMenuUtilsX.h" + +#include "mozilla/dom/Document.h" +#include "mozilla/dom/DocumentInlines.h" +#include "mozilla/dom/Event.h" +#include "mozilla/dom/XULCommandEvent.h" #include "nsMenuBarX.h" #include "nsMenuX.h" #include "nsMenuItemX.h" @@ -14,10 +18,8 @@ #include "nsCocoaWindow.h" #include "nsGkAtoms.h" #include "nsGlobalWindowInner.h" -#include "mozilla/dom/Document.h" #include "nsPIDOMWindow.h" #include "nsQueryObject.h" -#include "mozilla/dom/XULCommandEvent.h" using namespace mozilla;