Skip to content

Commit

Permalink
Bug 1540015 - part 1: Make Document.h stop including nsIPresShell.h r…
Browse files Browse the repository at this point in the history
…=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
  • Loading branch information
masayuki-nakano committed Mar 29, 2019
1 parent e845354 commit e705b32
Show file tree
Hide file tree
Showing 30 changed files with 55 additions and 18 deletions.
1 change: 1 addition & 0 deletions dom/animation/Animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions dom/animation/AnimationUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct JSContext;

namespace mozilla {

enum class PseudoStyleType : uint8_t;
class ComputedTimingFunction;
class EffectSet;

Expand Down
13 changes: 4 additions & 9 deletions dom/base/Document.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -107,6 +107,7 @@ class nsILayoutHistoryState;
class nsILoadContext;
class nsIObjectLoadingContent;
class nsIObserver;
class nsIPresShell;
class nsIPrincipal;
class nsIRequest;
class nsIRunnable;
Expand Down Expand Up @@ -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; }

Expand Down
14 changes: 13 additions & 1 deletion dom/base/DocumentInlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLBodyElement*>(GetHtmlChildElement(nsGkAtoms::body));
}
Expand Down
3 changes: 2 additions & 1 deletion dom/base/Location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
1 change: 1 addition & 0 deletions dom/base/PostMessageEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions dom/base/nsContentUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions dom/base/nsDOMWindowUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions dom/base/nsGlobalWindowInner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions dom/base/nsHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions dom/base/nsNodeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions dom/browser-element/BrowserElementParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 4 additions & 3 deletions dom/events/Event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down
1 change: 1 addition & 0 deletions dom/html/HTMLLinkElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions dom/html/HTMLMenuElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions dom/html/HTMLSourceElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions dom/plugins/base/nsPluginInstanceOwner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions dom/smil/SMILAnimationController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions dom/smil/SMILTimedElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions dom/svg/SVGAElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion dom/xul/XULBroadcastManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions layout/inspector/inLayoutUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions layout/style/nsHTMLStyleSheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions layout/style/nsMediaFeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions layout/xul/nsImageBoxFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions layout/xul/nsXULPopupManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions parser/html/nsHtml5SVGLoadDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 2 additions & 0 deletions toolkit/components/sessionstore/SessionStoreUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions toolkit/components/windowwatcher/nsWindowWatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 5 additions & 3 deletions widget/cocoa/nsMenuUtilsX.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;

Expand Down

0 comments on commit e705b32

Please sign in to comment.