From 5b203013b2a601e0f9d80c561e252c77917faecb Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Fri, 29 Mar 2019 15:12:47 +0000 Subject: [PATCH] Bug 1540015 - part 3: Rename Document::GetShell() to Document::GetPresShell() and make it return PresShell* rather than nsIPresShell* r=smaug,emilio This makes `Document::GetShell()` return `PresShell*` instead of `nsIPresShell`. Additonally, "shell" is unclear ("docshell" vs. "presshell"). Therefore, this also renames `Document::GetShell()` to `Document::GetPresShell()`. Similarly, some other method names of `Document` are also renamed from `*Shell*` to `*PresShell*`. Differential Revision: https://phabricator.services.mozilla.com/D25338 --- accessible/base/DocManager.cpp | 7 +- accessible/base/DocManager.h | 5 +- accessible/base/Logging.cpp | 11 +- accessible/base/nsAccessibilityService.cpp | 7 +- accessible/base/nsCoreUtils.cpp | 8 +- accessible/base/nsCoreUtils.h | 6 +- accessible/generic/DocAccessible.cpp | 8 +- chrome/nsChromeRegistry.cpp | 11 +- docshell/base/nsDocShell.cpp | 6 +- dom/animation/KeyframeEffect.cpp | 8 +- dom/animation/KeyframeEffect.h | 4 +- dom/animation/PendingAnimationTracker.cpp | 4 +- dom/base/AnonymousContent.cpp | 6 +- dom/base/DOMIntersectionObserver.cpp | 3 +- dom/base/Document.cpp | 220 +++++++++--------- dom/base/Document.h | 20 +- dom/base/DocumentInlines.h | 4 +- dom/base/DocumentOrShadowRoot.cpp | 7 +- dom/base/Element.cpp | 30 +-- dom/base/FragmentOrElement.cpp | 4 +- dom/base/ResponsiveImageSelector.cpp | 3 +- dom/base/ShadowRoot.cpp | 15 +- dom/base/nsContentSink.cpp | 20 +- dom/base/nsContentUtils.cpp | 27 +-- dom/base/nsContentUtils.h | 3 +- dom/base/nsCopySupport.cpp | 8 +- dom/base/nsDOMWindowUtils.cpp | 25 +- dom/base/nsFocusManager.cpp | 25 +- dom/base/nsFrameLoader.cpp | 24 +- dom/base/nsGlobalWindowInner.cpp | 30 +-- dom/base/nsJSEnvironment.cpp | 4 +- dom/base/nsNodeUtils.cpp | 9 +- dom/base/nsObjectLoadingContent.cpp | 8 +- dom/base/nsRange.cpp | 9 +- dom/canvas/CanvasRenderingContext2D.h | 3 +- .../nsICanvasRenderingContextInternal.h | 3 +- dom/events/ContentEventHandler.cpp | 24 +- dom/events/EventListenerManager.cpp | 7 +- dom/events/EventStateManager.cpp | 10 +- dom/events/IMEStateManager.cpp | 6 +- dom/events/PointerEventHandler.cpp | 6 +- dom/html/ImageDocument.cpp | 14 +- dom/html/MediaDocument.cpp | 8 +- dom/html/PluginDocument.cpp | 4 +- dom/html/nsHTMLDocument.cpp | 13 +- dom/html/nsTextEditorState.cpp | 4 +- dom/ipc/TabChild.cpp | 10 +- dom/ipc/TabParent.cpp | 14 +- .../PrototypeDocumentContentSink.cpp | 7 +- dom/smil/SMILAnimationController.cpp | 6 +- dom/svg/SVGContentUtils.cpp | 3 +- dom/svg/SVGElement.cpp | 12 +- dom/svg/SVGSVGElement.cpp | 3 +- dom/xbl/XBLChildrenElement.cpp | 8 +- dom/xbl/nsBindingManager.cpp | 13 +- dom/xbl/nsXBLPrototypeResources.cpp | 7 +- dom/xbl/nsXBLResourceLoader.cpp | 12 +- dom/xbl/nsXBLService.cpp | 10 +- dom/xul/nsXULElement.cpp | 8 +- editor/libeditor/EditorBase.h | 4 +- gfx/layers/apz/src/FocusTarget.cpp | 4 +- gfx/layers/apz/util/APZCCallbackHelper.cpp | 29 +-- gfx/layers/apz/util/ActiveElementManager.cpp | 7 +- .../apz/util/ChromeProcessController.cpp | 4 +- .../apz/util/ContentProcessController.cpp | 7 +- gfx/layers/apz/util/DoubleTapToZoom.cpp | 19 +- layout/base/AccessibleCaretManager.cpp | 1 + layout/base/GeometryUtils.cpp | 7 +- layout/base/PresShell.cpp | 92 ++++---- layout/base/PresShell.h | 15 +- layout/base/TouchManager.cpp | 2 +- layout/base/nsDocumentViewer.cpp | 32 +-- layout/base/nsIPresShellInlines.h | 11 +- layout/base/nsLayoutUtils.cpp | 5 +- layout/base/nsPresContext.cpp | 9 +- layout/generic/nsFrame.cpp | 10 +- layout/generic/nsSubDocumentFrame.cpp | 16 +- layout/inspector/InspectorUtils.cpp | 12 +- .../painting/RetainedDisplayListBuilder.cpp | 12 +- layout/painting/nsDisplayList.cpp | 6 +- layout/printing/nsPrintJob.cpp | 14 +- layout/style/FontFaceSet.cpp | 6 +- layout/style/ServoStyleSet.cpp | 5 +- layout/style/StyleAnimationValue.cpp | 7 +- layout/style/nsComputedDOMStyle.cpp | 20 +- layout/style/nsHTMLStyleSheet.cpp | 4 +- layout/xul/BoxObject.cpp | 4 +- layout/xul/nsXULPopupManager.cpp | 15 +- layout/xul/nsXULTooltipListener.cpp | 9 +- servo/components/style/gecko/media_queries.rs | 1 + toolkit/components/find/nsWebBrowserFind.cpp | 9 +- .../sessionstore/SessionStoreUtils.cpp | 2 +- .../typeaheadfind/nsTypeAheadFind.cpp | 5 +- uriloader/base/nsDocLoader.cpp | 10 +- widget/android/GeckoSystemStateListener.h | 6 +- widget/cocoa/nsDragService.mm | 8 +- widget/gtk/nsDragService.cpp | 7 +- widget/nsBaseDragService.cpp | 6 +- 98 files changed, 658 insertions(+), 588 deletions(-) diff --git a/accessible/base/DocManager.cpp b/accessible/base/DocManager.cpp index 4f56d9df57119..98e76c672d89a 100644 --- a/accessible/base/DocManager.cpp +++ b/accessible/base/DocManager.cpp @@ -22,6 +22,7 @@ #include "mozilla/Components.h" #include "mozilla/EventListenerManager.h" +#include "mozilla/PresShell.h" #include "mozilla/dom/Event.h" // for Event #include "nsContentUtils.h" #include "nsDocShellLoadTypes.h" @@ -437,8 +438,10 @@ DocAccessible* DocManager::CreateDocOrRootAccessible(Document* aDocument) { } // Ignore documents without presshell and not having root frame. - nsIPresShell* presShell = aDocument->GetShell(); - if (!presShell || presShell->IsDestroying()) return nullptr; + PresShell* presShell = aDocument->GetPresShell(); + if (!presShell || presShell->IsDestroying()) { + return nullptr; + } bool isRootDoc = nsCoreUtils::IsRootDocument(aDocument); diff --git a/accessible/base/DocManager.h b/accessible/base/DocManager.h index 596ebc523e41d..54dc590744fb7 100644 --- a/accessible/base/DocManager.h +++ b/accessible/base/DocManager.h @@ -6,6 +6,7 @@ #define mozilla_a11_DocManager_h_ #include "mozilla/ClearOnShutdown.h" +#include "mozilla/PresShell.h" #include "mozilla/dom/Document.h" #include "nsIDOMEventListener.h" #include "nsRefPtrHashtable.h" @@ -183,8 +184,8 @@ class DocManager : public nsIWebProgressListener, * more than one. */ inline DocAccessible* GetExistingDocAccessible(const dom::Document* aDocument) { - nsIPresShell* ps = aDocument->GetShell(); - return ps ? ps->GetDocAccessible() : nullptr; + PresShell* presShell = aDocument->GetPresShell(); + return presShell ? presShell->GetDocAccessible() : nullptr; } } // namespace a11y diff --git a/accessible/base/Logging.cpp b/accessible/base/Logging.cpp index a42b046827fdc..2427ffaffad5d 100644 --- a/accessible/base/Logging.cpp +++ b/accessible/base/Logging.cpp @@ -22,6 +22,7 @@ #include "prenv.h" #include "nsIDocShellTreeItem.h" #include "nsIURI.h" +#include "mozilla/PresShell.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/HTMLBodyElement.h" #include "mozilla/dom/Selection.h" @@ -164,13 +165,13 @@ static void LogDocState(dom::Document* aDocumentNode) { } static void LogPresShell(dom::Document* aDocumentNode) { - nsIPresShell* ps = aDocumentNode->GetShell(); - printf("presshell: %p", static_cast(ps)); + PresShell* presShell = aDocumentNode->GetPresShell(); + printf("presshell: %p", static_cast(presShell)); nsIScrollableFrame* sf = nullptr; - if (ps) { - printf(", is %s destroying", (ps->IsDestroying() ? "" : "not")); - sf = ps->GetRootScrollFrameAsScrollable(); + if (presShell) { + printf(", is %s destroying", (presShell->IsDestroying() ? "" : "not")); + sf = presShell->GetRootScrollFrameAsScrollable(); } printf(", root scroll frame: %p", static_cast(sf)); } diff --git a/accessible/base/nsAccessibilityService.cpp b/accessible/base/nsAccessibilityService.cpp index f951a91dd18b5..c4bcee1f55b5a 100644 --- a/accessible/base/nsAccessibilityService.cpp +++ b/accessible/base/nsAccessibilityService.cpp @@ -72,6 +72,7 @@ #include "mozilla/dom/EventTarget.h" #include "mozilla/dom/HTMLTableElement.h" #include "mozilla/Preferences.h" +#include "mozilla/PresShell.h" #include "mozilla/Services.h" #include "nsDeckFrame.h" @@ -372,9 +373,9 @@ class PluginTimerCallBack final : public nsITimerCallback, public nsINamed { NS_IMETHOD Notify(nsITimer* aTimer) final { if (!mContent->IsInUncomposedDoc()) return NS_OK; - nsIPresShell* ps = mContent->OwnerDoc()->GetShell(); - if (ps) { - DocAccessible* doc = ps->GetDocAccessible(); + PresShell* presShell = mContent->OwnerDoc()->GetPresShell(); + if (presShell) { + DocAccessible* doc = presShell->GetDocAccessible(); if (doc) { // Make sure that if we created an accessible for the plugin that wasn't // a plugin accessible we remove it before creating the right diff --git a/accessible/base/nsCoreUtils.cpp b/accessible/base/nsCoreUtils.cpp index d45cb71689d03..63aed4bbdade4 100644 --- a/accessible/base/nsCoreUtils.cpp +++ b/accessible/base/nsCoreUtils.cpp @@ -14,7 +14,6 @@ #include "nsXULElement.h" #include "nsIDocShell.h" #include "nsIObserverService.h" -#include "nsIPresShell.h" #include "nsPresContext.h" #include "nsIScrollableFrame.h" #include "nsISelectionController.h" @@ -24,6 +23,7 @@ #include "mozilla/EventListenerManager.h" #include "mozilla/EventStateManager.h" #include "mozilla/MouseEvents.h" +#include "mozilla/PresShell.h" #include "mozilla/TouchEvents.h" #include "nsView.h" #include "nsGkAtoms.h" @@ -70,8 +70,10 @@ void nsCoreUtils::DispatchClickEvent(XULTreeElement *aTree, int32_t aRowIndex, Document *document = tcElm->GetUncomposedDoc(); if (!document) return; - nsCOMPtr presShell = document->GetShell(); - if (!presShell) return; + RefPtr presShell = document->GetPresShell(); + if (!presShell) { + return; + } // Ensure row is visible. aTree->EnsureRowIsVisible(aRowIndex); diff --git a/accessible/base/nsCoreUtils.h b/accessible/base/nsCoreUtils.h index ed02ecd655476..ba1419fa58142 100644 --- a/accessible/base/nsCoreUtils.h +++ b/accessible/base/nsCoreUtils.h @@ -7,11 +7,11 @@ #define nsCoreUtils_h_ #include "mozilla/EventForwards.h" +#include "mozilla/PresShell.h" #include "mozilla/dom/Element.h" #include "nsIAccessibleEvent.h" #include "nsIContent.h" -#include "mozilla/dom/Document.h" // for GetShell() -#include "nsIPresShell.h" +#include "mozilla/dom/Document.h" // for GetPresShell() #include "nsPoint.h" #include "nsTArray.h" @@ -213,7 +213,7 @@ class nsCoreUtils { * Return presShell for the document containing the given DOM node. */ static nsIPresShell *GetPresShellFor(nsINode *aNode) { - return aNode->OwnerDoc()->GetShell(); + return aNode->OwnerDoc()->GetPresShell(); } /** diff --git a/accessible/generic/DocAccessible.cpp b/accessible/generic/DocAccessible.cpp index 4367a1ec4d4f9..3e2ddaf41accf 100644 --- a/accessible/generic/DocAccessible.cpp +++ b/accessible/generic/DocAccessible.cpp @@ -30,7 +30,6 @@ #include "nsIInterfaceRequestorUtils.h" #include "nsImageFrame.h" #include "nsIPersistentProperties2.h" -#include "nsIPresShell.h" #include "nsIServiceManager.h" #include "nsViewManager.h" #include "nsIScrollableFrame.h" @@ -43,6 +42,7 @@ #include "mozilla/EventStateManager.h" #include "mozilla/EventStates.h" #include "mozilla/HTMLEditor.h" +#include "mozilla/PresShell.h" #include "mozilla/TextEditor.h" #include "mozilla/dom/TabChild.h" #include "mozilla/dom/DocumentType.h" @@ -466,8 +466,10 @@ nsRect DocAccessible::RelativeBounds(nsIFrame** aRelativeFrame) const { nsRect bounds; while (document) { - nsIPresShell* presShell = document->GetShell(); - if (!presShell) return nsRect(); + mozilla::PresShell* presShell = document->GetPresShell(); + if (!presShell) { + return nsRect(); + } nsRect scrollPort; nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable(); diff --git a/chrome/nsChromeRegistry.cpp b/chrome/nsChromeRegistry.cpp index 91e1ec374ad61..83426e0270cf8 100644 --- a/chrome/nsChromeRegistry.cpp +++ b/chrome/nsChromeRegistry.cpp @@ -21,11 +21,11 @@ #include "mozilla/dom/Document.h" #include "nsIDOMWindow.h" #include "nsIObserverService.h" -#include "nsIPresShell.h" #include "nsIScriptError.h" #include "nsIWindowMediator.h" #include "nsIPrefService.h" #include "mozilla/Preferences.h" +#include "mozilla/PresShell.h" #include "mozilla/Printf.h" #include "mozilla/StyleSheet.h" #include "mozilla/StyleSheetInlines.h" @@ -38,6 +38,7 @@ nsChromeRegistry* nsChromeRegistry::gChromeRegistry; // DO NOT use namespace mozilla; it'll break due to a naming conflict between // mozilla::TextRange and a TextRange in OSX headers. +using mozilla::PresShell; using mozilla::StyleSheet; using mozilla::dom::Document; using mozilla::dom::IsChromeURI; @@ -344,11 +345,11 @@ nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindowOuter* aWindow) { if (!document) return NS_OK; // Deal with the agent sheets first. Have to do all the style sets by hand. - nsCOMPtr shell = document->GetShell(); - if (shell) { + RefPtr presShell = document->GetPresShell(); + if (presShell) { // Reload only the chrome URL agent style sheets. nsTArray> agentSheets; - rv = shell->GetAgentStyleSheets(agentSheets); + rv = presShell->GetAgentStyleSheets(agentSheets); NS_ENSURE_SUCCESS(rv, rv); nsTArray> newAgentSheets; @@ -370,7 +371,7 @@ nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindowOuter* aWindow) { } } - rv = shell->SetAgentStyleSheets(newAgentSheets); + rv = presShell->SetAgentStyleSheets(newAgentSheets); NS_ENSURE_SUCCESS(rv, rv); } diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index fc71fb3e55830..374b07e5f10c3 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -28,6 +28,7 @@ #include "mozilla/Logging.h" #include "mozilla/MediaFeatureChange.h" #include "mozilla/Preferences.h" +#include "mozilla/PresShell.h" #include "mozilla/ResultExtensions.h" #include "mozilla/ScrollTypes.h" #include "mozilla/Services.h" @@ -7878,8 +7879,9 @@ nsresult nsDocShell::RestoreFromHistory() { } else { rootViewParent = nullptr; } - if (sibling && sibling->GetShell() && sibling->GetShell()->GetViewManager()) { - rootViewSibling = sibling->GetShell()->GetViewManager()->GetRootView(); + if (sibling && sibling->GetPresShell() && + sibling->GetPresShell()->GetViewManager()) { + rootViewSibling = sibling->GetPresShell()->GetViewManager()->GetRootView(); } else { rootViewSibling = nullptr; } diff --git a/dom/animation/KeyframeEffect.cpp b/dom/animation/KeyframeEffect.cpp index 0b67f808b5d53..5c20c701cd2be 100644 --- a/dom/animation/KeyframeEffect.cpp +++ b/dom/animation/KeyframeEffect.cpp @@ -20,6 +20,7 @@ #include "mozilla/LayerAnimationInfo.h" #include "mozilla/LookAndFeel.h" // For LookAndFeel::GetInt #include "mozilla/KeyframeUtils.h" +#include "mozilla/PresShell.h" #include "mozilla/ServoBindings.h" #include "mozilla/StaticPrefs.h" #include "mozilla/TypeTraits.h" @@ -31,7 +32,6 @@ #include "nsCSSPseudoElements.h" // For PseudoStyleType #include "nsDOMMutationObserver.h" // For nsAutoAnimationMutationBatch #include "nsIFrame.h" -#include "nsIPresShell.h" #include "nsIScriptError.h" #include "nsPresContextInlines.h" #include "nsRefreshDriver.h" @@ -1207,7 +1207,7 @@ bool KeyframeEffect::CanThrottleIfNotVisible(nsIFrame& aFrame) const { return false; } - nsIPresShell* presShell = GetPresShell(); + PresShell* presShell = GetPresShell(); if (presShell && !presShell->IsActive()) { return true; } @@ -1409,12 +1409,12 @@ Document* KeyframeEffect::GetRenderedDocument() const { return mTarget->mElement->GetComposedDoc(); } -nsIPresShell* KeyframeEffect::GetPresShell() const { +PresShell* KeyframeEffect::GetPresShell() const { Document* doc = GetRenderedDocument(); if (!doc) { return nullptr; } - return doc->GetShell(); + return doc->GetPresShell(); } /* static */ diff --git a/dom/animation/KeyframeEffect.h b/dom/animation/KeyframeEffect.h index 00e6a9f41b54a..fb0b292117340 100644 --- a/dom/animation/KeyframeEffect.h +++ b/dom/animation/KeyframeEffect.h @@ -34,7 +34,6 @@ struct JSContext; class JSObject; class nsIContent; class nsIFrame; -class nsIPresShell; namespace mozilla { @@ -45,6 +44,7 @@ struct AnimationRule; struct TimingParams; class EffectSet; class ComputedStyle; +class PresShell; namespace dom { class ElementOrCSSPseudoElement; @@ -283,7 +283,7 @@ class KeyframeEffect : public AnimationEffect { } Document* GetRenderedDocument() const; - nsIPresShell* GetPresShell() const; + PresShell* GetPresShell() const; // Associates a warning with the animated property set on the specified frame // indicating why, for example, the property could not be animated on the diff --git a/dom/animation/PendingAnimationTracker.cpp b/dom/animation/PendingAnimationTracker.cpp index 6cca74564cf8f..0d35ef8eefa1a 100644 --- a/dom/animation/PendingAnimationTracker.cpp +++ b/dom/animation/PendingAnimationTracker.cpp @@ -6,10 +6,10 @@ #include "PendingAnimationTracker.h" +#include "mozilla/PresShell.h" #include "mozilla/dom/AnimationTimeline.h" #include "mozilla/dom/Nullable.h" #include "nsIFrame.h" -#include "nsIPresShell.h" #include "nsTransitionManager.h" // For CSSTransition using mozilla::dom::Nullable; @@ -173,7 +173,7 @@ void PendingAnimationTracker::EnsurePaintIsScheduled() { return; } - nsIPresShell* presShell = mDocument->GetShell(); + PresShell* presShell = mDocument->GetPresShell(); if (!presShell) { return; } diff --git a/dom/base/AnonymousContent.cpp b/dom/base/AnonymousContent.cpp index 838d7165986c3..03ccebd7bfb7f 100644 --- a/dom/base/AnonymousContent.cpp +++ b/dom/base/AnonymousContent.cpp @@ -5,11 +5,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "AnonymousContent.h" +#include "mozilla/PresShell.h" +#include "mozilla/dom/Document.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/AnonymousContentBinding.h" #include "nsComputedDOMStyle.h" #include "nsCycleCollectionParticipant.h" -#include "mozilla/dom/Document.h" #include "nsIFrame.h" #include "nsStyledElement.h" #include "HTMLCanvasElement.h" @@ -185,8 +186,7 @@ void AnonymousContent::GetComputedStylePropertyValue( return; } - nsIPresShell* shell = element->OwnerDoc()->GetShell(); - if (!shell) { + if (!element->OwnerDoc()->GetPresShell()) { aRv.Throw(NS_ERROR_NOT_AVAILABLE); return; } diff --git a/dom/base/DOMIntersectionObserver.cpp b/dom/base/DOMIntersectionObserver.cpp index 39e0db760d48b..d5108bc1ceba5 100644 --- a/dom/base/DOMIntersectionObserver.cpp +++ b/dom/base/DOMIntersectionObserver.cpp @@ -9,6 +9,7 @@ #include "nsIFrame.h" #include "nsContentUtils.h" #include "nsLayoutUtils.h" +#include "mozilla/PresShell.h" #include "mozilla/ServoBindings.h" namespace mozilla { @@ -252,7 +253,7 @@ void DOMIntersectionObserver::Update(Document* aDocument, rootFrame, rootRectRelativeToRootFrame, containingBlock); } } else { - nsCOMPtr presShell = aDocument->GetShell(); + RefPtr presShell = aDocument->GetPresShell(); if (presShell) { rootFrame = presShell->GetRootScrollFrame(); if (rootFrame) { diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index 18d2c5d6d3ca2..dfab45acc873f 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -2251,9 +2251,9 @@ void Document::RemoveDocStyleSheetsFromStyleSets() { sheet->ClearAssociatedDocumentOrShadowRoot(); if (sheet->IsApplicable()) { - nsCOMPtr shell = GetShell(); - if (shell) { - shell->StyleSet()->RemoveDocStyleSheet(sheet); + RefPtr presShell = GetPresShell(); + if (presShell) { + presShell->StyleSet()->RemoveDocStyleSheet(sheet); } } // XXX Tell observers? @@ -2267,9 +2267,9 @@ void Document::RemoveStyleSheetsFromStyleSets( sheet->ClearAssociatedDocumentOrShadowRoot(); if (sheet->IsApplicable()) { - nsCOMPtr shell = GetShell(); - if (shell) { - shell->StyleSet()->RemoveStyleSheet(aType, sheet); + RefPtr presShell = GetPresShell(); + if (presShell) { + presShell->StyleSet()->RemoveStyleSheet(aType, sheet); } } // XXX Tell observers? @@ -2323,10 +2323,10 @@ void Document::ResetStylesheetsToURI(nsIURI* aURI) { } // Now set up our style sets - if (nsIPresShell* shell = GetShell()) { - FillStyleSet(shell->StyleSet()); - if (shell->StyleSet()->StyleSheetsHaveChanged()) { - shell->ApplicableStylesChanged(); + if (PresShell* presShell = GetPresShell()) { + FillStyleSet(presShell->StyleSet()); + if (presShell->StyleSet()->StyleSheetsHaveChanged()) { + presShell->ApplicableStylesChanged(); } } } @@ -3630,7 +3630,7 @@ static inline void AssertNoStaleServoDataIn(nsINode& aSubtreeRoot) { #endif } -already_AddRefed Document::CreateShell( +already_AddRefed Document::CreatePresShell( nsPresContext* aContext, nsViewManager* aViewManager, UniquePtr aStyleSet) { NS_ASSERTION(!mPresShell, "We have a presshell already!"); @@ -3640,18 +3640,20 @@ already_AddRefed Document::CreateShell( FillStyleSet(aStyleSet.get()); AssertNoStaleServoDataIn(*this); - RefPtr shell = new PresShell; + RefPtr presShell = new PresShell; // Note: we don't hold a ref to the shell (it holds a ref to us) - mPresShell = shell; - shell->Init(this, aContext, aViewManager, std::move(aStyleSet)); + mPresShell = presShell; + presShell->Init(this, aContext, aViewManager, std::move(aStyleSet)); // Make sure to never paint if we belong to an invisible DocShell. nsCOMPtr docShell(mDocumentContainer); - if (docShell && docShell->IsInvisible()) shell->SetNeverPainting(true); + if (docShell && docShell->IsInvisible()) { + presShell->SetNeverPainting(true); + } MOZ_LOG(gDocumentLeakPRLog, LogLevel::Debug, - ("DOCUMENT %p with PressShell %p and DocShell %p", this, shell.get(), - docShell.get())); + ("DOCUMENT %p with PressShell %p and DocShell %p", this, + presShell.get(), docShell.get())); mExternalResourceMap.ShowViewers(); @@ -3663,11 +3665,11 @@ already_AddRefed Document::CreateShell( // is ready to update we'll flush the font set. MarkUserFontSetDirty(); - return shell.forget(); + return presShell.forget(); } void Document::UpdateFrameRequestCallbackSchedulingState( - nsIPresShell* aOldShell) { + PresShell* aOldPresShell) { // If the condition for shouldBeScheduled changes to depend on some other // variable, add UpdateFrameRequestCallbackSchedulingState() calls to the // places where that variable can change. @@ -3678,7 +3680,7 @@ void Document::UpdateFrameRequestCallbackSchedulingState( return; } - nsIPresShell* presShell = aOldShell ? aOldShell : mPresShell; + PresShell* presShell = aOldPresShell ? aOldPresShell : mPresShell; MOZ_RELEASE_ASSERT(presShell); nsRefreshDriver* rd = presShell->GetPresContext()->RefreshDriver(); @@ -3738,7 +3740,7 @@ bool Document::ShouldThrottleFrameRequests() { return false; } -void Document::DeleteShell() { +void Document::DeletePresShell() { mExternalResourceMap.HideViewers(); if (nsPresContext* presContext = mPresShell->GetPresContext()) { presContext->RefreshDriver()->CancelPendingFullscreenEvents(this); @@ -3755,9 +3757,9 @@ void Document::DeleteShell() { // no point on it. MarkUserFontSetDirty(); - nsIPresShell* oldShell = mPresShell; + PresShell* oldPresShell = mPresShell; mPresShell = nullptr; - UpdateFrameRequestCallbackSchedulingState(oldShell); + UpdateFrameRequestCallbackSchedulingState(oldPresShell); mStyleSetFilled = false; ClearStaleServoData(); @@ -3952,9 +3954,9 @@ void Document::RemoveChildNode(nsIContent* aKid, bool aNotify) { } void Document::AddStyleSheetToStyleSets(StyleSheet* aSheet) { - if (nsIPresShell* shell = GetShell()) { - shell->StyleSet()->AddDocStyleSheet(aSheet, this); - shell->ApplicableStylesChanged(); + if (PresShell* presShell = GetPresShell()) { + presShell->StyleSet()->AddDocStyleSheet(aSheet, this); + presShell->ApplicableStylesChanged(); } } @@ -3992,9 +3994,9 @@ void Document::NotifyStyleSheetRemoved(StyleSheet* aSheet, } void Document::RemoveStyleSheetFromStyleSets(StyleSheet* aSheet) { - if (nsIPresShell* shell = GetShell()) { - shell->StyleSet()->RemoveDocStyleSheet(aSheet); - shell->ApplicableStylesChanged(); + if (PresShell* presShell = GetPresShell()) { + presShell->StyleSet()->RemoveDocStyleSheet(aSheet); + presShell->ApplicableStylesChanged(); } } @@ -4174,10 +4176,10 @@ nsresult Document::AddAdditionalStyleSheet(additionalSheetType aType, mAdditionalSheets[aType].AppendElement(aSheet); - if (nsIPresShell* shell = GetShell()) { + if (PresShell* presShell = GetPresShell()) { SheetType type = ConvertAdditionalSheetType(aType); - shell->StyleSet()->AppendStyleSheet(type, aSheet); - shell->ApplicableStylesChanged(); + presShell->StyleSet()->AppendStyleSheet(type, aSheet); + presShell->ApplicableStylesChanged(); } // Passing false, so documet.styleSheets.length will not be affected by @@ -4199,10 +4201,10 @@ void Document::RemoveAdditionalStyleSheet(additionalSheetType aType, if (!mIsGoingAway) { MOZ_ASSERT(sheetRef->IsApplicable()); - if (nsIPresShell* shell = GetShell()) { + if (PresShell* presShell = GetPresShell()) { SheetType type = ConvertAdditionalSheetType(aType); - shell->StyleSet()->RemoveStyleSheet(type, sheetRef); - shell->ApplicableStylesChanged(); + presShell->StyleSet()->RemoveStyleSheet(type, sheetRef); + presShell->ApplicableStylesChanged(); } } @@ -4941,8 +4943,8 @@ void Document::UnblockDOMContentLoaded() { ("DOCUMENT %p UnblockDOMContentLoaded", this)); mDidFireDOMContentLoaded = true; - if (nsIPresShell* shell = GetShell()) { - shell->GetRefreshDriver()->NotifyDOMContentLoaded(); + if (PresShell* presShell = GetPresShell()) { + presShell->GetRefreshDriver()->NotifyDOMContentLoaded(); } MOZ_ASSERT(mReadyState == READYSTATE_INTERACTIVE); @@ -4971,8 +4973,8 @@ void Document::DocumentStatesChanged(EventStates aStateMask) { } void Document::StyleRuleChanged(StyleSheet* aSheet, css::Rule* aStyleRule) { - if (nsIPresShell* shell = GetShell()) { - shell->ApplicableStylesChanged(); + if (PresShell* presShell = GetPresShell()) { + presShell->ApplicableStylesChanged(); } if (!StyleSheetChangeEventsEnabled()) { @@ -4984,8 +4986,8 @@ void Document::StyleRuleChanged(StyleSheet* aSheet, css::Rule* aStyleRule) { } void Document::StyleRuleAdded(StyleSheet* aSheet, css::Rule* aStyleRule) { - if (nsIPresShell* shell = GetShell()) { - shell->ApplicableStylesChanged(); + if (PresShell* presShell = GetPresShell()) { + presShell->ApplicableStylesChanged(); } if (!StyleSheetChangeEventsEnabled()) { @@ -4997,8 +4999,8 @@ void Document::StyleRuleAdded(StyleSheet* aSheet, css::Rule* aStyleRule) { } void Document::StyleRuleRemoved(StyleSheet* aSheet, css::Rule* aStyleRule) { - if (nsIPresShell* shell = GetShell()) { - shell->ApplicableStylesChanged(); + if (PresShell* presShell = GetPresShell()) { + presShell->ApplicableStylesChanged(); } if (!StyleSheetChangeEventsEnabled()) { @@ -5011,17 +5013,17 @@ void Document::StyleRuleRemoved(StyleSheet* aSheet, css::Rule* aStyleRule) { #undef DO_STYLESHEET_NOTIFICATION -static Element* GetCustomContentContainer(nsIPresShell* aShell) { - if (!aShell || !aShell->GetCanvasFrame()) { +static Element* GetCustomContentContainer(PresShell* aPresShell) { + if (!aPresShell || !aPresShell->GetCanvasFrame()) { return nullptr; } - return aShell->GetCanvasFrame()->GetCustomContentContainer(); + return aPresShell->GetCanvasFrame()->GetCustomContentContainer(); } static void InsertAnonContentIntoCanvas(AnonymousContent& aAnonContent, - nsIPresShell* aShell) { - Element* container = GetCustomContentContainer(aShell); + PresShell* aPresShell) { + Element* container = GetCustomContentContainer(aPresShell); if (!container) { return; } @@ -5031,7 +5033,7 @@ static void InsertAnonContentIntoCanvas(AnonymousContent& aAnonContent, return; } - aShell->GetCanvasFrame()->ShowCustomContentContainer(); + aPresShell->GetCanvasFrame()->ShowCustomContentContainer(); } already_AddRefed Document::InsertAnonymousContent( @@ -5048,14 +5050,14 @@ already_AddRefed Document::InsertAnonymousContent( MakeRefPtr(clone.forget().downcast()); mAnonymousContents.AppendElement(anonContent); - InsertAnonContentIntoCanvas(*anonContent, GetShell()); + InsertAnonContentIntoCanvas(*anonContent, GetPresShell()); return anonContent.forget(); } static void RemoveAnonContentFromCanvas(AnonymousContent& aAnonContent, - nsIPresShell* aShell) { - RefPtr container = GetCustomContentContainer(aShell); + PresShell* aPresShell) { + RefPtr container = GetCustomContentContainer(aPresShell); if (!container) { return; } @@ -5072,10 +5074,11 @@ void Document::RemoveAnonymousContent(AnonymousContent& aContent, } mAnonymousContents.RemoveElementAt(index); - RemoveAnonContentFromCanvas(aContent, GetShell()); + RemoveAnonContentFromCanvas(aContent, GetPresShell()); - if (mAnonymousContents.IsEmpty() && GetCustomContentContainer(GetShell())) { - GetShell()->GetCanvasFrame()->HideCustomContentContainer(); + if (mAnonymousContents.IsEmpty() && + GetCustomContentContainer(GetPresShell())) { + GetPresShell()->GetCanvasFrame()->HideCustomContentContainer(); } } @@ -5085,14 +5088,14 @@ Element* Document::GetAnonRootIfInAnonymousContentContainer( return nullptr; } - nsIPresShell* shell = GetShell(); - if (!shell || !shell->GetCanvasFrame()) { + PresShell* presShell = GetPresShell(); + if (!presShell || !presShell->GetCanvasFrame()) { return nullptr; } nsAutoScriptBlocker scriptBlocker; nsCOMPtr customContainer = - shell->GetCanvasFrame()->GetCustomContentContainer(); + presShell->GetCanvasFrame()->GetCustomContentContainer(); if (!customContainer) { return nullptr; } @@ -5526,9 +5529,9 @@ void Document::EnableStyleSheetsForSetInternal(const nsAString& aSheetSet, if (aUpdateCSSLoader) { CSSLoader()->DocumentStyleSheetSetChanged(); } - if (nsIPresShell* shell = GetShell()) { - if (shell->StyleSet()->StyleSheetsHaveChanged()) { - shell->ApplicableStylesChanged(); + if (PresShell* presShell = GetPresShell()) { + if (presShell->StyleSet()->StyleSheetsHaveChanged()) { + presShell->ApplicableStylesChanged(); } } } @@ -5891,10 +5894,10 @@ void Document::DoNotifyPossibleTitleChange() { nsAutoString title; GetTitle(title); - nsCOMPtr shell = GetShell(); - if (shell) { + RefPtr presShell = GetPresShell(); + if (presShell) { nsCOMPtr container = - shell->GetPresContext()->GetContainerWeak(); + presShell->GetPresContext()->GetContainerWeak(); if (container) { nsCOMPtr docShellWin = do_QueryInterface(container); if (docShellWin) { @@ -7114,8 +7117,8 @@ void Document::FlushPendingNotifications(mozilla::ChangesToFlush aFlush) { mParentDocument->FlushPendingNotifications(parentFlush); } - if (nsIPresShell* shell = GetShell()) { - shell->FlushPendingNotifications(aFlush); + if (RefPtr presShell = GetPresShell()) { + presShell->FlushPendingNotifications(aFlush); } } @@ -7315,10 +7318,11 @@ already_AddRefed Document::CreateElem(const nsAString& aName, } bool Document::IsSafeToFlush() const { - nsIPresShell* shell = GetShell(); - if (!shell) return true; - - return shell->IsSafeToFlush(); + PresShell* presShell = GetPresShell(); + if (!presShell) { + return true; + } + return presShell->IsSafeToFlush(); } void Document::Sanitize() { @@ -8303,12 +8307,12 @@ static void FireOrClearDelayedEvents(nsTArray>& aDocuments, // closed before this event ran. if (!aDocuments[i]->EventHandlingSuppressed()) { fm->FireDelayedEvents(aDocuments[i]); - nsCOMPtr shell = aDocuments[i]->GetShell(); - if (shell) { + RefPtr presShell = aDocuments[i]->GetPresShell(); + if (presShell) { // Only fire events for active documents. bool fire = aFireEvents && aDocuments[i]->GetInnerWindow() && aDocuments[i]->GetInnerWindow()->IsCurrentInnerWindow(); - shell->FireOrClearDelayedEvents(fire); + presShell->FireOrClearDelayedEvents(fire); } } } @@ -8790,9 +8794,9 @@ void Document::SetScrollToRef(nsIURI* aDocumentURI) { void Document::ScrollToRef() { if (mScrolledToRefAlready) { - nsCOMPtr shell = GetShell(); - if (shell) { - shell->ScrollToAnchor(); + RefPtr presShell = GetPresShell(); + if (presShell) { + presShell->ScrollToAnchor(); } return; } @@ -8801,8 +8805,8 @@ void Document::ScrollToRef() { return; } - nsCOMPtr shell = GetShell(); - if (shell) { + RefPtr presShell = GetPresShell(); + if (presShell) { nsresult rv = NS_ERROR_FAILURE; // We assume that the bytes are in UTF-8, as it says in the spec: // http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.1 @@ -8810,7 +8814,7 @@ void Document::ScrollToRef() { // Check an empty string which might be caused by the UTF-8 conversion if (!ref.IsEmpty()) { // Note that GoToAnchor will handle flushing layout as needed. - rv = shell->GoToAnchor(ref, mChangeScrollPosWhenScrollingToRef); + rv = presShell->GoToAnchor(ref, mChangeScrollPosWhenScrollingToRef); } else { rv = NS_ERROR_FAILURE; } @@ -8825,7 +8829,8 @@ void Document::ScrollToRef() { if (unescaped) { NS_ConvertUTF8toUTF16 utf16Str(buff); if (!utf16Str.IsEmpty()) { - rv = shell->GoToAnchor(utf16Str, mChangeScrollPosWhenScrollingToRef); + rv = presShell->GoToAnchor(utf16Str, + mChangeScrollPosWhenScrollingToRef); } } @@ -8836,7 +8841,7 @@ void Document::ScrollToRef() { rv = encoding->DecodeWithoutBOMHandling(unescaped ? buff : mScrollToRef, ref); if (NS_SUCCEEDED(rv) && !ref.IsEmpty()) { - rv = shell->GoToAnchor(ref, mChangeScrollPosWhenScrollingToRef); + rv = presShell->GoToAnchor(ref, mChangeScrollPosWhenScrollingToRef); } } } @@ -9171,8 +9176,8 @@ void Document::ScheduleSVGUseElementShadowTreeUpdate( mSVGUseElementsNeedingShadowTreeUpdate.PutEntry(&aUseElement); - if (nsIPresShell* shell = GetShell()) { - shell->EnsureStyleFlush(); + if (PresShell* presShell = GetPresShell()) { + presShell->EnsureStyleFlush(); } } @@ -9258,12 +9263,12 @@ already_AddRefed Document::CaretPositionFromPoint( FlushPendingNotifications(FlushType::Layout); - nsIPresShell* ps = GetShell(); - if (!ps) { + PresShell* presShell = GetPresShell(); + if (!presShell) { return nullptr; } - nsIFrame* rootFrame = ps->GetRootFrame(); + nsIFrame* rootFrame = presShell->GetRootFrame(); // XUL docs, unlike HTML, have no frame tree until everything's done loading if (!rootFrame) { @@ -9280,7 +9285,7 @@ already_AddRefed Document::CaretPositionFromPoint( // We require frame-relative coordinates for GetContentOffsetsFromPoint. nsPoint aOffset; - nsCOMPtr widget = nsContentUtils::GetWidget(ps, &aOffset); + nsCOMPtr widget = nsContentUtils::GetWidget(presShell, &aOffset); LayoutDeviceIntPoint refPoint = nsContentUtils::ToWidgetPoint( CSSPoint(aX, aY), aOffset, GetPresContext()); nsPoint adjustedPoint = @@ -10222,10 +10227,10 @@ void Document::CleanupFullscreenState() { mFullscreenRoot = nullptr; // Restore the zoom level that was in place prior to entering fullscreen. - if (nsIPresShell* shell = GetShell()) { - if (shell->GetMobileViewportManager()) { - shell->SetResolutionAndScaleTo(mSavedResolution, - nsIPresShell::ChangeOrigin::eMainThread); + if (PresShell* presShell = GetPresShell()) { + if (presShell->GetMobileViewportManager()) { + presShell->SetResolutionAndScaleTo( + mSavedResolution, nsIPresShell::ChangeOrigin::eMainThread); } } @@ -10616,13 +10621,14 @@ bool Document::ApplyFullscreen(UniquePtr aRequest) { // fixed elements are sized to the layout viewport). // This also ensures that things like video controls aren't zoomed in // when in fullscreen mode. - if (nsIPresShell* shell = child->GetShell()) { + if (PresShell* presShell = child->GetPresShell()) { if (RefPtr manager = - shell->GetMobileViewportManager()) { + presShell->GetMobileViewportManager()) { // Save the previous resolution so it can be restored. - child->mSavedResolution = shell->GetResolution(); - shell->SetResolutionAndScaleTo(manager->ComputeIntrinsicResolution(), - nsIPresShell::ChangeOrigin::eMainThread); + child->mSavedResolution = presShell->GetResolution(); + presShell->SetResolutionAndScaleTo( + manager->ComputeIntrinsicResolution(), + nsIPresShell::ChangeOrigin::eMainThread); } } @@ -10892,8 +10898,8 @@ bool Document::SetPointerLock(Element* aElement, StyleCursorKind aCursorStyle) { } #endif - nsIPresShell* shell = GetShell(); - if (!shell) { + PresShell* presShell = GetPresShell(); + if (!presShell) { NS_WARNING("SetPointerLock(): No PresShell"); if (!aElement) { // If we are unlocking pointer lock, but for some reason the doc @@ -10904,19 +10910,19 @@ bool Document::SetPointerLock(Element* aElement, StyleCursorKind aCursorStyle) { } return false; } - nsPresContext* presContext = shell->GetPresContext(); + nsPresContext* presContext = presShell->GetPresContext(); if (!presContext) { NS_WARNING("SetPointerLock(): Unable to get PresContext"); return false; } nsCOMPtr widget; - nsIFrame* rootFrame = shell->GetRootFrame(); + nsIFrame* rootFrame = presShell->GetRootFrame(); if (!NS_WARN_IF(!rootFrame)) { widget = rootFrame->GetNearestWidget(); NS_WARNING_ASSERTION(widget, "SetPointerLock(): Unable to find widget in " - "shell->GetRootFrame()->GetNearestWidget();"); + "presShell->GetRootFrame()->GetNearestWidget();"); if (aElement && !widget) { return false; } @@ -11696,8 +11702,8 @@ void Document::FlushUserFontSet() { if (gfxPlatform::GetPlatform()->DownloadableFontsEnabled()) { nsTArray rules; - nsIPresShell* shell = GetShell(); - if (shell && !shell->StyleSet()->AppendFontFaceRules(rules)) { + PresShell* presShell = GetPresShell(); + if (presShell && !presShell->StyleSet()->AppendFontFaceRules(rules)) { return; } @@ -11715,8 +11721,8 @@ void Document::FlushUserFontSet() { // reflect that we're modifying @font-face rules. (However, // without a reflow, nothing will happen to start any downloads // that are needed.) - if (changed && shell) { - if (nsPresContext* presContext = shell->GetPresContext()) { + if (changed && presShell) { + if (nsPresContext* presContext = presShell->GetPresContext()) { presContext->UserFontSetUpdated(); } } @@ -11728,8 +11734,8 @@ void Document::MarkUserFontSetDirty() { return; } mFontFaceSetDirty = true; - if (nsIPresShell* shell = GetShell()) { - shell->EnsureStyleFlush(); + if (PresShell* presShell = GetPresShell()) { + presShell->EnsureStyleFlush(); } } diff --git a/dom/base/Document.h b/dom/base/Document.h index b759e8a61feb1..3b4e4970c7d4c 100644 --- a/dom/base/Document.h +++ b/dom/base/Document.h @@ -107,7 +107,6 @@ class nsILayoutHistoryState; class nsILoadContext; class nsIObjectLoadingContent; class nsIObserver; -class nsIPresShell; class nsIPrincipal; class nsIRequest; class nsIRunnable; @@ -139,6 +138,7 @@ class EventListenerManager; class FullscreenExit; class FullscreenRequest; class PendingAnimationTracker; +class PresShell; class ServoStyleSet; class SMILAnimationController; enum class StyleCursorKind : uint8_t; @@ -471,8 +471,8 @@ class Document : public nsINode, func_, params_); \ /* FIXME(emilio): Apparently we can keep observing from the BFCache? That \ looks bogus. */ \ - if (nsIPresShell* shell = GetObservingShell()) { \ - shell->func_ params_; \ + if (PresShell* presShell = GetObservingPresShell()) { \ + presShell->func_ params_; \ } \ } while (0) @@ -1244,16 +1244,16 @@ class Document : public nsINode, * method is responsible for calling BeginObservingDocument() on the * presshell if the presshell should observe document mutations. */ - already_AddRefed CreateShell( + already_AddRefed CreatePresShell( nsPresContext* aContext, nsViewManager* aViewManager, UniquePtr aStyleSet); - void DeleteShell(); + void DeletePresShell(); - nsIPresShell* GetShell() const { + PresShell* GetPresShell() const { return GetBFCacheEntry() ? nullptr : mPresShell; } - inline nsIPresShell* GetObservingShell() const; + inline PresShell* GetObservingPresShell() const; // Return whether the presshell for this document is safe to flush. bool IsSafeToFlush() const; @@ -2513,7 +2513,7 @@ class Document : public nsINode, * null. */ void SetDisplayDocument(Document* aDisplayDocument) { - MOZ_ASSERT(!GetShell() && !GetContainer() && !GetWindow(), + MOZ_ASSERT(!GetPresShell() && !GetContainer() && !GetWindow(), "Shouldn't set mDisplayDocument on documents that already " "have a presentation or a docshell or a window"); MOZ_ASSERT(aDisplayDocument, "Must not be null"); @@ -3852,7 +3852,7 @@ class Document : public nsINode, // mPresShell is becoming null; in that case it will be used to get hold of // the relevant refresh driver. void UpdateFrameRequestCallbackSchedulingState( - nsIPresShell* aOldShell = nullptr); + PresShell* aOldPresShell = nullptr); // Helper for GetScrollingElement/IsScrollingElement. bool IsPotentiallyScrollable(HTMLBodyElement* aBody); @@ -4332,7 +4332,7 @@ class Document : public nsINode, // won't be collected uint32_t mMarkedCCGeneration; - nsIPresShell* mPresShell; + PresShell* mPresShell; nsCOMArray mSubtreeModifiedTargets; uint32_t mSubtreeModifiedDepth; diff --git a/dom/base/DocumentInlines.h b/dom/base/DocumentInlines.h index 928231908a3b8..73df7c17d190a 100644 --- a/dom/base/DocumentInlines.h +++ b/dom/base/DocumentInlines.h @@ -17,12 +17,12 @@ namespace mozilla { namespace dom { -inline nsIPresShell* Document::GetObservingShell() const { +inline PresShell* Document::GetObservingPresShell() const { return mPresShell && mPresShell->IsObservingDocument() ? mPresShell : nullptr; } inline nsPresContext* Document::GetPresContext() const { - nsIPresShell* presShell = GetShell(); + PresShell* presShell = GetPresShell(); return presShell ? presShell->GetPresContext() : nullptr; } diff --git a/dom/base/DocumentOrShadowRoot.cpp b/dom/base/DocumentOrShadowRoot.cpp index e74820af6e360..1770f6689ca79 100644 --- a/dom/base/DocumentOrShadowRoot.cpp +++ b/dom/base/DocumentOrShadowRoot.cpp @@ -6,6 +6,7 @@ #include "DocumentOrShadowRoot.h" #include "mozilla/EventStateManager.h" +#include "mozilla/PresShell.h" #include "mozilla/dom/Document.h" #include "mozilla/dom/HTMLInputElement.h" #include "mozilla/dom/ShadowRoot.h" @@ -244,12 +245,12 @@ static void QueryNodesFromRect(DocumentOrShadowRoot& aRoot, const nsRect& aRect, doc->FlushPendingNotifications(FlushType::Layout); } - nsIPresShell* ps = doc->GetShell(); - if (!ps) { + PresShell* presShell = doc->GetPresShell(); + if (!presShell) { return; } - nsIFrame* rootFrame = ps->GetRootFrame(); + nsIFrame* rootFrame = presShell->GetRootFrame(); // XUL docs, unlike HTML, have no frame tree until everything's done loading if (!rootFrame) { return; // return null to premature XUL callers as a reminder to wait diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 8d243268cc2f6..f8b2233e757da 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -34,7 +34,6 @@ #include "nsIURL.h" #include "nsContainerFrame.h" #include "nsIAnonymousContentCreator.h" -#include "nsIPresShell.h" #include "nsPresContext.h" #include "nsStyleConsts.h" #include "nsString.h" @@ -68,6 +67,7 @@ #include "mozilla/FullscreenChange.h" #include "mozilla/InternalMutationEvent.h" #include "mozilla/MouseEvents.h" +#include "mozilla/PresShell.h" #include "mozilla/RestyleManager.h" #include "mozilla/ScrollTypes.h" #include "mozilla/SizeOfState.h" @@ -448,7 +448,7 @@ Element::StyleStateLocks Element::LockedStyleStates() const { void Element::NotifyStyleStateChange(EventStates aStates) { Document* doc = GetComposedDoc(); if (doc) { - nsIPresShell* presShell = doc->GetShell(); + RefPtr presShell = doc->GetPresShell(); if (presShell) { nsAutoScriptBlocker scriptBlocker; presShell->ContentStateChanged(doc, this, aStates); @@ -527,7 +527,7 @@ static bool MayNeedToLoadXBLBinding(const Document& aDocument, // Otherwise, don't do anything else here unless we're dealing with // XUL or an HTML element that may have a plugin-related overlay // (i.e. object or embed). - if (!aDocument.GetShell() || aElement.GetPrimaryFrame()) { + if (!aDocument.GetPresShell() || aElement.GetPrimaryFrame()) { return false; } @@ -698,8 +698,8 @@ nsIScrollableFrame* Element::GetScrollFrame(nsIFrame** aFrame, if (isScrollingElement) { // Our scroll info should map to the root scrollable frame if there is one. - if (nsIPresShell* shell = doc->GetShell()) { - return shell->GetRootScrollFrameAsScrollable(); + if (PresShell* presShell = doc->GetPresShell()) { + return presShell->GetRootScrollFrameAsScrollable(); } } @@ -731,7 +731,7 @@ void Element::ScrollIntoView(const ScrollIntoViewOptions& aOptions) { } // Get the presentation shell - nsCOMPtr presShell = document->GetShell(); + RefPtr presShell = document->GetPresShell(); if (!presShell) { return; } @@ -990,7 +990,7 @@ nsRect Element::GetClientAreaRect() { // We will always have a pres shell if we have a pres context, and we will // only get here if we have a pres context from the root content document // check - nsIPresShell* presShell = doc->GetShell(); + PresShell* presShell = doc->GetPresShell(); // Ensure up to date dimensions, but don't reflow RefPtr viewManager = presShell->GetViewManager(); @@ -1198,8 +1198,8 @@ already_AddRefed Element::AttachShadowWithoutNameChecks( DOCUMENT_FRAGMENT_NODE); if (Document* doc = GetComposedDoc()) { - if (nsIPresShell* shell = doc->GetShell()) { - shell->DestroyFramesForAndRestyle(this); + if (PresShell* presShell = doc->GetPresShell()) { + presShell->DestroyFramesForAndRestyle(this); } } MOZ_ASSERT(!GetPrimaryFrame()); @@ -1319,8 +1319,8 @@ void Element::UnattachShadow() { nsAutoScriptBlocker scriptBlocker; if (Document* doc = GetComposedDoc()) { - if (nsIPresShell* shell = doc->GetShell()) { - shell->DestroyFramesForAndRestyle(this); + if (PresShell* presShell = doc->GetPresShell()) { + presShell->DestroyFramesForAndRestyle(this); } } MOZ_ASSERT(!GetPrimaryFrame()); @@ -2041,8 +2041,8 @@ nsresult Element::SetSMILOverrideStyleDeclaration( // be in a document, if we're clearing animation effects on a target node // that's been detached since the previous animation sample.) if (Document* doc = GetComposedDoc()) { - if (nsIPresShell* shell = doc->GetShell()) { - shell->RestyleForAnimation(this, StyleRestyleHint_RESTYLE_SMIL); + if (PresShell* presShell = doc->GetPresShell()) { + presShell->RestyleForAnimation(this, StyleRestyleHint_RESTYLE_SMIL); } } @@ -4290,8 +4290,8 @@ static void NoteDirtyElement(Element* aElement, uint32_t aBits) { } } - if (nsIPresShell* shell = doc->GetShell()) { - shell->EnsureStyleFlush(); + if (PresShell* presShell = doc->GetPresShell()) { + presShell->EnsureStyleFlush(); } MOZ_ASSERT(parent->IsElement() || parent == doc); diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp index bd385e3002a59..fe751d60be9a0 100644 --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -22,6 +22,7 @@ #include "mozilla/EventListenerManager.h" #include "mozilla/EventStates.h" #include "mozilla/HTMLEditor.h" +#include "mozilla/PresShell.h" #include "mozilla/RestyleManager.h" #include "mozilla/TextEditor.h" #include "mozilla/TouchEvents.h" @@ -43,7 +44,6 @@ #include "nsNetUtil.h" #include "nsIFrame.h" #include "nsIAnonymousContentCreator.h" -#include "nsIPresShell.h" #include "nsPresContext.h" #include "nsStyleConsts.h" #include "nsString.h" @@ -1580,7 +1580,7 @@ static bool ShouldClearPurple(nsIContent* aContent) { // we can act as if it was optimizable. When the primary frame dies, aNode // will end up to the purple buffer because of the refcount change. bool NodeHasActiveFrame(Document* aCurrentDoc, nsINode* aNode) { - return aCurrentDoc->GetShell() && aNode->IsElement() && + return aCurrentDoc->GetPresShell() && aNode->IsElement() && aNode->AsElement()->GetPrimaryFrame(); } diff --git a/dom/base/ResponsiveImageSelector.cpp b/dom/base/ResponsiveImageSelector.cpp index 71b28fd898838..9c5a76c58cf3a 100644 --- a/dom/base/ResponsiveImageSelector.cpp +++ b/dom/base/ResponsiveImageSelector.cpp @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/dom/ResponsiveImageSelector.h" +#include "mozilla/PresShell.h" #include "mozilla/ServoStyleSetInlines.h" #include "mozilla/TextUtils.h" #include "nsIURI.h" @@ -401,7 +402,7 @@ int ResponsiveImageSelector::GetSelectedCandidateIndex() { bool ResponsiveImageSelector::ComputeFinalWidthForCurrentViewport( double* aWidth) { dom::Document* doc = Document(); - nsIPresShell* presShell = doc->GetShell(); + PresShell* presShell = doc->GetPresShell(); nsPresContext* pctx = presShell ? presShell->GetPresContext() : nullptr; if (!pctx) { diff --git a/dom/base/ShadowRoot.cpp b/dom/base/ShadowRoot.cpp index 2266271421112..faffa0601e66a 100644 --- a/dom/base/ShadowRoot.cpp +++ b/dom/base/ShadowRoot.cpp @@ -17,6 +17,7 @@ #include "mozilla/dom/HTMLSlotElement.h" #include "mozilla/EventDispatcher.h" #include "mozilla/IdentifierMapEntry.h" +#include "mozilla/PresShell.h" #include "mozilla/ServoStyleRuleMap.h" #include "mozilla/StyleSheet.h" #include "mozilla/StyleSheetInlines.h" @@ -185,12 +186,12 @@ void ShadowRoot::InvalidateStyleAndLayoutOnSubtree(Element* aElement) { return; } - nsIPresShell* shell = doc->GetShell(); - if (!shell) { + PresShell* presShell = doc->GetPresShell(); + if (!presShell) { return; } - shell->DestroyFramesForAndRestyle(aElement); + presShell->DestroyFramesForAndRestyle(aElement); } void ShadowRoot::AddSlot(HTMLSlotElement* aSlot) { @@ -349,8 +350,8 @@ void ShadowRoot::ApplicableRulesChanged() { return; } - if (nsIPresShell* shell = doc->GetShell()) { - shell->RecordShadowStyleChange(*this); + if (PresShell* presShell = doc->GetPresShell()) { + presShell->RecordShadowStyleChange(*this); } } @@ -534,8 +535,8 @@ void ShadowRoot::MaybeReassignElement(Element* aElement) { } if (Document* doc = GetComposedDoc()) { - if (nsIPresShell* shell = doc->GetShell()) { - shell->SlotAssignmentWillChange(*aElement, oldSlot, assignment.mSlot); + if (RefPtr presShell = doc->GetPresShell()) { + presShell->SlotAssignmentWillChange(*aElement, oldSlot, assignment.mSlot); } } diff --git a/dom/base/nsContentSink.cpp b/dom/base/nsContentSink.cpp index 0686da74ae252..7fc184aeb6b8b 100644 --- a/dom/base/nsContentSink.cpp +++ b/dom/base/nsContentSink.cpp @@ -11,6 +11,7 @@ #include "nsContentSink.h" #include "mozilla/Components.h" +#include "mozilla/PresShell.h" #include "mozilla/dom/Document.h" #include "mozilla/css/Loader.h" #include "mozilla/dom/SRILogHelper.h" @@ -24,7 +25,6 @@ #include "nsIProtocolHandler.h" #include "nsIHttpChannel.h" #include "nsIContent.h" -#include "nsIPresShell.h" #include "nsPresContext.h" #include "nsViewManager.h" #include "nsAtom.h" @@ -1190,14 +1190,14 @@ void nsContentSink::StartLayout(bool aIgnorePendingSheets) { mLastNotificationTime = PR_Now(); mDocument->SetMayStartLayout(true); - nsCOMPtr shell = mDocument->GetShell(); + RefPtr presShell = mDocument->GetPresShell(); // Make sure we don't call Initialize() for a shell that has // already called it. This can happen when the layout frame for // an iframe is constructed *between* the Embed() call for the // docshell in the iframe, and the content sink's call to OpenBody(). // (Bug 153815) - if (shell && !shell->DidInitialize()) { - nsresult rv = shell->Initialize(); + if (presShell && !presShell->DidInitialize()) { + nsresult rv = presShell->Initialize(); if (NS_FAILED(rv)) { return; } @@ -1345,8 +1345,8 @@ nsresult nsContentSink::DidProcessATokenImpl() { } // Get the current user event time - nsIPresShell* shell = mDocument->GetShell(); - if (!shell) { + PresShell* presShell = mDocument->GetPresShell(); + if (!presShell) { // If there's no pres shell in the document, return early since // we're not laying anything out here. return NS_OK; @@ -1358,7 +1358,7 @@ nsresult nsContentSink::DidProcessATokenImpl() { // Check if there's a pending event if (sPendingEventMode != 0 && !mHasPendingEvent && (mDeflectedCount % sEventProbeRate) == 0) { - nsViewManager* vm = shell->GetViewManager(); + nsViewManager* vm = presShell->GetViewManager(); NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE); nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); @@ -1492,15 +1492,15 @@ nsresult nsContentSink::WillParseImpl(void) { return NS_OK; } - nsIPresShell* shell = mDocument->GetShell(); - if (!shell) { + PresShell* presShell = mDocument->GetPresShell(); + if (!presShell) { return NS_OK; } uint32_t currentTime = PR_IntervalToMicroseconds(PR_IntervalNow()); if (sEnablePerfMode == 0) { - nsViewManager* vm = shell->GetViewManager(); + nsViewManager* vm = presShell->GetViewManager(); NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE); uint32_t lastEventTime; vm->GetLastUserEventTime(lastEventTime); diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 199e28447b220..2a9217112fb5a 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -91,6 +91,7 @@ #include "mozilla/ManualNAC.h" #include "mozilla/MouseEvents.h" #include "mozilla/Preferences.h" +#include "mozilla/PresShell.h" #include "mozilla/ResultExtensions.h" #include "mozilla/dom/Selection.h" #include "mozilla/Services.h" @@ -3197,25 +3198,21 @@ void nsContentUtils::SplitExpatName(const char16_t* aExpatName, } // static -nsIPresShell* nsContentUtils::GetPresShellForContent( - const nsIContent* aContent) { +PresShell* nsContentUtils::GetPresShellForContent(const nsIContent* aContent) { Document* doc = aContent->GetComposedDoc(); if (!doc) { return nullptr; } - - return doc->GetShell(); + return doc->GetPresShell(); } // static nsPresContext* nsContentUtils::GetContextForContent( const nsIContent* aContent) { - nsIPresShell* presShell = GetPresShellForContent(aContent); - + PresShell* presShell = GetPresShellForContent(aContent); if (!presShell) { return nullptr; } - return presShell->GetPresContext(); } @@ -4184,7 +4181,7 @@ nsresult nsContentUtils::DispatchInputEvent(Element* aEventTargetElement, } // If we're running xpcshell tests, we fail to get presShell here. // Even in such case, we need to dispatch "input" event without widget. - nsIPresShell* presShell = document->GetShell(); + PresShell* presShell = document->GetPresShell(); if (presShell) { nsPresContext* presContext = presShell->GetPresContext(); if (NS_WARN_IF(!presContext)) { @@ -6298,9 +6295,9 @@ nsIPresShell* nsContentUtils::FindPresShellForDocument(const Document* aDoc) { doc = displayDoc; } - nsIPresShell* shell = doc->GetShell(); - if (shell) { - return shell; + PresShell* presShell = doc->GetPresShell(); + if (presShell) { + return presShell; } nsCOMPtr docShellTreeItem = doc->GetDocShell(); @@ -9833,7 +9830,7 @@ void nsContentUtils::AppendDocumentLevelNativeAnonymousContentTo( size_t oldLength = aElements.Length(); #endif - if (nsIPresShell* presShell = aDocument->GetShell()) { + if (PresShell* presShell = aDocument->GetPresShell()) { if (nsIFrame* scrollFrame = presShell->GetRootScrollFrame()) { nsIAnonymousContentCreator* creator = do_QueryFrame(scrollFrame); MOZ_ASSERT( @@ -10510,9 +10507,9 @@ bool nsContentUtils:: } Document* topLevel = aDocument->GetTopLevelContentDocument(); - return topLevel && topLevel->GetShell() && - topLevel->GetShell()->GetPresContext() && - !topLevel->GetShell()->GetPresContext()->HadContentfulPaint() && + return topLevel && topLevel->GetPresShell() && + topLevel->GetPresShell()->GetPresContext() && + !topLevel->GetPresShell()->GetPresContext()->HadContentfulPaint() && nsThreadManager::MainThreadHasPendingHighPriorityEvents(); } diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index 090075cd5cbb1..3d6f6eb492a67 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -127,6 +127,7 @@ class Dispatcher; class ErrorResult; class EventListenerManager; class HTMLEditor; +class PresShell; class TextEditor; namespace dom { @@ -827,7 +828,7 @@ class nsContentUtils { * @return the pres shell, or nullptr if the content is not in a document * (if GetComposedDoc returns nullptr) */ - static nsIPresShell* GetPresShellForContent(const nsIContent* aContent); + static mozilla::PresShell* GetPresShellForContent(const nsIContent* aContent); /** * Method to do security and content policy checks on the image URI diff --git a/dom/base/nsCopySupport.cpp b/dom/base/nsCopySupport.cpp index 72056eaa0e5bd..6a3c26889e2e3 100644 --- a/dom/base/nsCopySupport.cpp +++ b/dom/base/nsCopySupport.cpp @@ -18,7 +18,6 @@ #include "nsRange.h" #include "imgIContainer.h" #include "imgIRequest.h" -#include "nsIPresShell.h" #include "nsFocusManager.h" #include "mozilla/dom/DataTransfer.h" @@ -56,6 +55,7 @@ #include "mozilla/dom/Element.h" #include "mozilla/EventDispatcher.h" #include "mozilla/Preferences.h" +#include "mozilla/PresShell.h" #include "mozilla/dom/Selection.h" #include "mozilla/IntegerRange.h" @@ -588,8 +588,10 @@ nsIContent* nsCopySupport::GetSelectionForCopy(Document* aDocument, Selection** aSelection) { *aSelection = nullptr; - nsIPresShell* presShell = aDocument->GetShell(); - if (!presShell) return nullptr; + PresShell* presShell = aDocument->GetPresShell(); + if (!presShell) { + return nullptr; + } nsCOMPtr focusedContent; nsCOMPtr selectionController = diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 2318f6ef79d93..d378ca0d3d88b 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -45,6 +45,7 @@ #include "mozilla/EventStateManager.h" #include "mozilla/MiscEvents.h" #include "mozilla/MouseEvents.h" +#include "mozilla/PresShell.h" #include "mozilla/TextEvents.h" #include "mozilla/TextEventDispatcher.h" #include "mozilla/TouchEvents.h" @@ -53,7 +54,6 @@ #include "nsLayoutUtils.h" #include "nsComputedDOMStyle.h" -#include "nsIPresShell.h" #include "nsCSSProps.h" #include "nsIDocShell.h" #include "nsIContentViewer.h" @@ -1040,7 +1040,7 @@ nsIWidget* nsDOMWindowUtils::GetWidgetForElement(Element* aElement) { if (!aElement) return GetWidget(); Document* doc = aElement->GetUncomposedDoc(); - nsIPresShell* presShell = doc ? doc->GetShell() : nullptr; + PresShell* presShell = doc ? doc->GetPresShell() : nullptr; if (presShell) { nsIFrame* frame = aElement->GetPrimaryFrame(); @@ -1376,7 +1376,7 @@ static nsresult getScrollXYAppUnits(const nsWeakPtr& aWindow, bool aFlushLayout, doc->FlushPendingNotifications(FlushType::Layout); } - nsIPresShell* presShell = doc->GetShell(); + PresShell* presShell = doc->GetPresShell(); if (presShell) { nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable(); if (sf) { @@ -1462,7 +1462,7 @@ nsDOMWindowUtils::GetVisualViewportOffsetRelativeToLayoutViewport( nsCOMPtr doc = GetDocument(); NS_ENSURE_STATE(doc); - nsIPresShell* presShell = doc->GetShell(); + PresShell* presShell = doc->GetPresShell(); NS_ENSURE_TRUE(presShell, NS_ERROR_NOT_AVAILABLE); nsPoint offset = presShell->GetVisualViewportOffsetRelativeToLayoutViewport(); @@ -1481,7 +1481,7 @@ nsDOMWindowUtils::GetVisualViewportOffset(int32_t* aOffsetX, nsCOMPtr doc = GetDocument(); NS_ENSURE_STATE(doc); - nsIPresShell* presShell = doc->GetShell(); + PresShell* presShell = doc->GetPresShell(); NS_ENSURE_TRUE(presShell, NS_ERROR_NOT_AVAILABLE); nsPoint offset = presShell->GetVisualViewportOffset(); @@ -1504,7 +1504,7 @@ nsDOMWindowUtils::GetScrollbarSize(bool aFlushLayout, int32_t* aWidth, doc->FlushPendingNotifications(FlushType::Layout); } - nsIPresShell* presShell = doc->GetShell(); + PresShell* presShell = doc->GetPresShell(); NS_ENSURE_TRUE(presShell, NS_ERROR_NOT_AVAILABLE); nsIScrollableFrame* scrollFrame = presShell->GetRootScrollFrameAsScrollable(); @@ -1546,7 +1546,7 @@ nsDOMWindowUtils::NeedsFlush(int32_t aFlushType, bool* aResult) { nsCOMPtr doc = GetDocument(); NS_ENSURE_STATE(doc); - nsIPresShell* presShell = doc->GetShell(); + PresShell* presShell = doc->GetPresShell(); NS_ENSURE_STATE(presShell); FlushType flushType; @@ -1588,7 +1588,7 @@ nsDOMWindowUtils::GetRootBounds(DOMRect** aResult) { NS_ENSURE_STATE(doc); nsRect bounds(0, 0, 0, 0); - nsIPresShell* presShell = doc->GetShell(); + PresShell* presShell = doc->GetPresShell(); if (presShell) { nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable(); if (sf) { @@ -1698,13 +1698,14 @@ nsDOMWindowUtils::DispatchDOMEventViaPresShell(nsINode* aTarget, Event* aEvent, } nsCOMPtr targetDoc = content->GetUncomposedDoc(); NS_ENSURE_STATE(targetDoc); - RefPtr targetShell = targetDoc->GetShell(); - NS_ENSURE_STATE(targetShell); + RefPtr targetPresShell = targetDoc->GetPresShell(); + NS_ENSURE_STATE(targetPresShell); targetDoc->FlushPendingNotifications(FlushType::Layout); nsEventStatus status = nsEventStatus_eIgnore; - targetShell->HandleEventWithTarget(internalEvent, nullptr, content, &status); + targetPresShell->HandleEventWithTarget(internalEvent, nullptr, content, + &status); *aRetVal = (status != nsEventStatus_eConsumeNoDefault); return NS_OK; } @@ -4032,7 +4033,7 @@ nsDOMWindowUtils::GetDirectionFromText(const nsAString& aString, NS_IMETHODIMP nsDOMWindowUtils::EnsureDirtyRootFrame() { Document* doc = GetDocument(); - nsIPresShell* presShell = doc ? doc->GetShell() : nullptr; + PresShell* presShell = doc ? doc->GetPresShell() : nullptr; if (!presShell) { return NS_ERROR_FAILURE; diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index bd7547e18bb5d..3ecaccd945e64 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -21,7 +21,6 @@ #include "nsIDocShellTreeOwner.h" #include "nsIFormControl.h" #include "nsLayoutUtils.h" -#include "nsIPresShell.h" #include "nsFrameTraversal.h" #include "nsIWebNavigation.h" #include "nsCaret.h" @@ -60,6 +59,7 @@ #include "mozilla/IMEStateManager.h" #include "mozilla/LookAndFeel.h" #include "mozilla/Preferences.h" +#include "mozilla/PresShell.h" #include "mozilla/Services.h" #include "mozilla/Unused.h" #include @@ -1482,8 +1482,10 @@ Element* nsFocusManager::CheckIfFocusable(Element* aElement, uint32_t aFlags) { mEventHandlingNeedsFlush = false; doc->FlushPendingNotifications(FlushType::EnsurePresShellInitAndFrames); - nsIPresShell* shell = doc->GetShell(); - if (!shell) return nullptr; + PresShell* presShell = doc->GetPresShell(); + if (!presShell) { + return nullptr; + } // the root content can always be focused, // except in userfocusignored context. @@ -1492,7 +1494,7 @@ Element* nsFocusManager::CheckIfFocusable(Element* aElement, uint32_t aFlags) { } // cannot focus content in print preview mode. Only the root can be focused. - nsPresContext* presContext = shell->GetPresContext(); + nsPresContext* presContext = presShell->GetPresContext(); if (presContext && presContext->Type() == nsPresContext::eContext_PrintPreview) { LOGCONTENT("Cannot focus %s while in print preview", aElement) @@ -2529,7 +2531,7 @@ nsresult nsFocusManager::DetermineElementToMoveFocus( Element* rootContent = doc->GetRootElement(); NS_ENSURE_TRUE(rootContent, NS_OK); - nsIPresShell* presShell = doc->GetShell(); + PresShell* presShell = doc->GetPresShell(); NS_ENSURE_TRUE(presShell, NS_OK); if (aType == MOVEFOCUS_FIRST) { @@ -2776,7 +2778,7 @@ nsresult nsFocusManager::DetermineElementToMoveFocus( NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE); rootContent = doc->GetRootElement(); - presShell = doc->GetShell(); + presShell = doc->GetPresShell(); // We can focus the root element now that we have moved to another // document. @@ -3626,11 +3628,12 @@ bool nsFocusManager::TryToMoveFocusToSubDocument( } } Element* rootElement = subdoc->GetRootElement(); - nsIPresShell* subShell = subdoc->GetShell(); - if (rootElement && subShell) { + PresShell* subPresShell = subdoc->GetPresShell(); + if (rootElement && subPresShell) { nsresult rv = GetNextTabbableContent( - subShell, rootElement, aOriginalStartContent, rootElement, aForward, - (aForward ? 1 : 0), false, aForDocumentNavigation, aResultContent); + subPresShell, rootElement, aOriginalStartContent, rootElement, + aForward, (aForward ? 1 : 0), false, aForDocumentNavigation, + aResultContent); NS_ENSURE_SUCCESS(rv, false); if (*aResultContent) { return true; @@ -3773,7 +3776,7 @@ nsresult nsFocusManager::FocusFirst(Element* aRootElement, // If the found content is in a chrome shell, navigate forward one // tabbable item so that the first item is focused. Note that we // always go forward and not back here. - nsIPresShell* presShell = doc->GetShell(); + PresShell* presShell = doc->GetPresShell(); if (presShell) { return GetNextTabbableContent(presShell, aRootElement, nullptr, aRootElement, true, 1, false, false, diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index 6fa86965b8128..d482e524090a1 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -16,7 +16,6 @@ #include "nsDocShell.h" #include "nsIDOMMozBrowserFrame.h" #include "nsIDOMWindow.h" -#include "nsIPresShell.h" #include "nsIContentInlines.h" #include "nsIContentViewer.h" #include "mozilla/dom/Document.h" @@ -86,6 +85,7 @@ #include "mozilla/gfx/CrossProcessPaint.h" #include "mozilla/jsipc/CrossProcessObjectWrappers.h" #include "mozilla/layout/RenderFrame.h" +#include "mozilla/PresShell.h" #include "mozilla/ServoCSSParser.h" #include "mozilla/ServoStyleSet.h" #include "nsGenericHTMLFrameElement.h" @@ -1005,9 +1005,9 @@ nsresult nsFrameLoader::SwapWithOtherRemoteLoader( return NS_ERROR_NOT_IMPLEMENTED; } - nsIPresShell* ourShell = ourDoc->GetShell(); - nsIPresShell* otherShell = otherDoc->GetShell(); - if (!ourShell || !otherShell) { + PresShell* ourPresShell = ourDoc->GetPresShell(); + PresShell* otherPresShell = otherDoc->GetPresShell(); + if (!ourPresShell || !otherPresShell) { return NS_ERROR_NOT_IMPLEMENTED; } @@ -1153,8 +1153,8 @@ nsresult nsFrameLoader::SwapWithOtherRemoteLoader( ourFrameFrame->EndSwapDocShells(otherFrame); - ourShell->BackingScaleFactorChanged(); - otherShell->BackingScaleFactorChanged(); + ourPresShell->BackingScaleFactorChanged(); + otherPresShell->BackingScaleFactorChanged(); // Initialize browser API if needed now that owner content has changed. InitializeBrowserAPI(); @@ -1417,9 +1417,9 @@ nsresult nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther, NS_ASSERTION(ourDoc == ourParentDocument, "Unexpected parent document"); NS_ASSERTION(otherDoc == otherParentDocument, "Unexpected parent document"); - nsIPresShell* ourShell = ourDoc->GetShell(); - nsIPresShell* otherShell = otherDoc->GetShell(); - if (!ourShell || !otherShell) { + PresShell* ourPresShell = ourDoc->GetPresShell(); + PresShell* otherPresShell = otherDoc->GetPresShell(); + if (!ourPresShell || !otherPresShell) { return NS_ERROR_NOT_IMPLEMENTED; } @@ -1576,8 +1576,8 @@ nsresult nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther, // hi-dpi and low-dpi screens), it will have style data that is based on // the wrong appUnitsPerDevPixel value. So we tell the PresShells that their // backing scale factor may have changed. (Bug 822266) - ourShell->BackingScaleFactorChanged(); - otherShell->BackingScaleFactorChanged(); + ourPresShell->BackingScaleFactorChanged(); + otherPresShell->BackingScaleFactorChanged(); // Initialize browser API if needed now that owner content has changed InitializeBrowserAPI(); @@ -3097,7 +3097,7 @@ already_AddRefed nsFrameLoader::DrawSnapshot( aRv = NS_ERROR_FAILURE; return nullptr; } - nsIPresShell* presShell = document->GetShell(); + PresShell* presShell = document->GetPresShell(); if (NS_WARN_IF(!presShell)) { aRv = NS_ERROR_FAILURE; return nullptr; diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index c4bdb3e262fd8..f81776a459512 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -96,6 +96,7 @@ #include "mozilla/EventListenerManager.h" #include "mozilla/EventStates.h" #include "mozilla/MouseEvents.h" +#include "mozilla/PresShell.h" #include "mozilla/ProcessHangMonitor.h" #include "mozilla/ScrollTypes.h" #include "mozilla/ThrottledEventQueue.h" @@ -123,7 +124,6 @@ #include "nsIEmbeddingSiteWindow.h" #include "nsThreadUtils.h" #include "nsILoadContext.h" -#include "nsIPresShell.h" #include "nsIScrollableFrame.h" #include "nsView.h" #include "nsViewManager.h" @@ -1136,9 +1136,9 @@ void nsGlobalWindowInner::FreeInnerObjects() { } if (mObservingDidRefresh) { - nsIPresShell* shell = mDoc->GetShell(); - if (shell) { - Unused << shell->RemovePostRefreshObserver(this); + PresShell* presShell = mDoc->GetPresShell(); + if (presShell) { + Unused << presShell->RemovePostRefreshObserver(this); } } } @@ -6258,8 +6258,8 @@ already_AddRefed nsGlobalWindowInner::PromiseDocumentFlushed( return nullptr; } - nsIPresShell* shell = mDoc->GetShell(); - if (!shell) { + PresShell* presShell = mDoc->GetPresShell(); + if (!presShell) { aError.Throw(NS_ERROR_FAILURE); return nullptr; } @@ -6282,13 +6282,13 @@ already_AddRefed nsGlobalWindowInner::PromiseDocumentFlushed( UniquePtr flushResolver( new PromiseDocumentFlushedResolver(resultPromise, aCallback)); - if (!shell->NeedStyleFlush() && !shell->NeedLayoutFlush()) { + if (!presShell->NeedStyleFlush() && !presShell->NeedLayoutFlush()) { flushResolver->Call(); return resultPromise.forget(); } if (!mObservingDidRefresh) { - bool success = shell->AddPostRefreshObserver(this); + bool success = presShell->AddPostRefreshObserver(this); if (!success) { aError.Throw(NS_ERROR_FAILURE); return nullptr; @@ -6335,9 +6335,9 @@ void nsGlobalWindowInner::CallOrCancelDocumentFlushedResolvers() { // PromiseDocumentFlushed. Add here and leave. // FIXME: Handle this case inside PromiseDocumentFlushed (bug 1442824). if (mDoc) { - nsIPresShell* shell = mDoc->GetShell(); - if (shell) { - (void)shell->AddPostRefreshObserver(this); + PresShell* presShell = mDoc->GetPresShell(); + if (presShell) { + Unused << presShell->AddPostRefreshObserver(this); break; } } @@ -6366,10 +6366,10 @@ void nsGlobalWindowInner::DidRefresh() { MOZ_ASSERT(mDoc); - nsIPresShell* shell = mDoc->GetShell(); - MOZ_ASSERT(shell); + PresShell* presShell = mDoc->GetPresShell(); + MOZ_ASSERT(presShell); - if (shell->NeedStyleFlush() || shell->NeedLayoutFlush()) { + if (presShell->NeedStyleFlush() || presShell->NeedLayoutFlush()) { // By the time our observer fired, something has already invalidated // style or layout - or perhaps we're still in the middle of a flush that // was interrupted. In either case, we'll wait until the next refresh driver @@ -6378,7 +6378,7 @@ void nsGlobalWindowInner::DidRefresh() { return; } - bool success = shell->RemovePostRefreshObserver(this); + bool success = presShell->RemovePostRefreshObserver(this); if (!success) { return; } diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index 7f2fb348c7b48..48a6fff311333 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -56,6 +56,7 @@ #include "nsGlobalWindow.h" #include "mozilla/AutoRestore.h" #include "mozilla/MainThreadIdlePeriod.h" +#include "mozilla/PresShell.h" #include "mozilla/StaticPrefs.h" #include "mozilla/StaticPtr.h" #include "mozilla/dom/DOMException.h" @@ -89,7 +90,6 @@ #include "GeckoProfiler.h" #include "mozilla/IdleTaskRunner.h" #include "nsIDocShell.h" -#include "nsIPresShell.h" #include "nsViewManager.h" #include "mozilla/EventStateManager.h" @@ -1943,7 +1943,7 @@ void nsJSContext::MaybeRunNextCollectorSlice(nsIDocShell* aDocShell, return; } - nsIPresShell* presShell = rootDocument->GetShell(); + PresShell* presShell = rootDocument->GetPresShell(); if (!presShell) { return; } diff --git a/dom/base/nsNodeUtils.cpp b/dom/base/nsNodeUtils.cpp index cdf472170c281..2e2ede74dca2e 100644 --- a/dom/base/nsNodeUtils.cpp +++ b/dom/base/nsNodeUtils.cpp @@ -31,6 +31,7 @@ #include "mozilla/dom/HTMLImageElement.h" #include "mozilla/dom/HTMLMediaElement.h" #include "mozilla/dom/KeyframeEffect.h" +#include "mozilla/PresShell.h" #include "nsWrapperCacheInlines.h" #include "nsObjectLoadingContent.h" #include "nsDOMMutationObserver.h" @@ -67,8 +68,8 @@ enum class IsRemoveNotification { COMPOSED_DOC_DECL \ NS_ASSERTION(node->OwnerDoc() == doc, "Bogus document"); \ if (remove_ == IsRemoveNotification::Yes && node->GetComposedDoc()) { \ - if (nsIPresShell* shell = doc->GetObservingShell()) { \ - shell->func_ params_; \ + if (PresShell* presShell = doc->GetObservingPresShell()) { \ + presShell->func_ params_; \ } \ } \ doc->BindingManager()->func_ params_; \ @@ -93,8 +94,8 @@ enum class IsRemoveNotification { (remove_ == IsRemoveNotification::Yes && \ !strcmp(#func_, "NativeAnonymousChildListChange"))); \ if (remove_ == IsRemoveNotification::No && last == doc) { \ - if (nsIPresShell* shell = doc->GetObservingShell()) { \ - shell->func_ params_; \ + if (PresShell* presShell = doc->GetObservingPresShell()) { \ + presShell->func_ params_; \ } \ } \ if (needsEnterLeave) { \ diff --git a/dom/base/nsObjectLoadingContent.cpp b/dom/base/nsObjectLoadingContent.cpp index 4e20df4d331a7..f15d358c36a22 100644 --- a/dom/base/nsObjectLoadingContent.cpp +++ b/dom/base/nsObjectLoadingContent.cpp @@ -26,7 +26,6 @@ #include "nsPluginInstanceOwner.h" #include "nsJSNPRuntime.h" #include "nsINestedURI.h" -#include "nsIPresShell.h" #include "nsScriptSecurityManager.h" #include "nsIScriptSecurityManager.h" #include "nsIStreamConverterService.h" @@ -92,6 +91,7 @@ #include "mozilla/dom/HTMLObjectElement.h" #include "mozilla/net/UrlClassifierFeatureFactory.h" #include "mozilla/LoadInfo.h" +#include "mozilla/PresShell.h" #include "nsChannelClassifier.h" #include "nsFocusManager.h" @@ -2485,9 +2485,9 @@ void nsObjectLoadingContent::NotifyStateChanged(ObjectType aOldType, } else if (aOldType != mType) { // If our state changed, then we already recreated frames // Otherwise, need to do that here - nsCOMPtr shell = doc->GetShell(); - if (shell) { - shell->PostRecreateFramesFor(thisEl); + RefPtr presShell = doc->GetPresShell(); + if (presShell) { + presShell->PostRecreateFramesFor(thisEl); } } diff --git a/dom/base/nsRange.cpp b/dom/base/nsRange.cpp index 750d7812fe625..58bdbc52df042 100644 --- a/dom/base/nsRange.cpp +++ b/dom/base/nsRange.cpp @@ -30,6 +30,7 @@ #include "mozilla/dom/ShadowRoot.h" #include "mozilla/dom/Selection.h" #include "mozilla/dom/Text.h" +#include "mozilla/PresShell.h" #include "mozilla/Telemetry.h" #include "mozilla/UniquePtr.h" #include "mozilla/Likely.h" @@ -68,8 +69,8 @@ static void InvalidateAllFrames(nsINode* aNode) { } case nsINode::DOCUMENT_NODE: { Document* doc = static_cast(aNode); - nsIPresShell* shell = doc ? doc->GetShell() : nullptr; - frame = shell ? shell->GetRootFrame() : nullptr; + PresShell* presShell = doc ? doc->GetPresShell() : nullptr; + frame = presShell ? presShell->GetRootFrame() : nullptr; break; } } @@ -2728,8 +2729,8 @@ static void ExtractRectFromOffset(nsIFrame* aFrame, const int32_t aOffset, static nsTextFrame* GetTextFrameForContent(nsIContent* aContent, bool aFlushLayout) { - Document* doc = aContent->OwnerDoc(); - nsIPresShell* presShell = doc->GetShell(); + RefPtr doc = aContent->OwnerDoc(); + PresShell* presShell = doc->GetPresShell(); if (!presShell) { return nullptr; } diff --git a/dom/canvas/CanvasRenderingContext2D.h b/dom/canvas/CanvasRenderingContext2D.h index 3e39f39283ae9..ce09ffdaa477c 100644 --- a/dom/canvas/CanvasRenderingContext2D.h +++ b/dom/canvas/CanvasRenderingContext2D.h @@ -20,6 +20,7 @@ #include "mozilla/dom/CanvasPattern.h" #include "mozilla/gfx/Rect.h" #include "mozilla/gfx/2D.h" +#include "mozilla/PresShell.h" #include "mozilla/UniquePtr.h" #include "gfx2DGlue.h" #include "imgIEncoder.h" @@ -392,7 +393,7 @@ class CanvasRenderingContext2D final : public nsICanvasRenderingContextInternal, */ nsIPresShell* GetPresShell() final { if (mCanvasElement) { - return mCanvasElement->OwnerDoc()->GetShell(); + return mCanvasElement->OwnerDoc()->GetPresShell(); } if (mDocShell) { return mDocShell->GetPresShell(); diff --git a/dom/canvas/nsICanvasRenderingContextInternal.h b/dom/canvas/nsICanvasRenderingContextInternal.h index 37a7315a1696e..606c428734633 100644 --- a/dom/canvas/nsICanvasRenderingContextInternal.h +++ b/dom/canvas/nsICanvasRenderingContextInternal.h @@ -13,6 +13,7 @@ #include "nsRefreshDriver.h" #include "mozilla/dom/HTMLCanvasElement.h" #include "mozilla/dom/OffscreenCanvas.h" +#include "mozilla/PresShell.h" #include "mozilla/RefPtr.h" #include "mozilla/UniquePtr.h" #include "mozilla/NotNull.h" @@ -58,7 +59,7 @@ class nsICanvasRenderingContextInternal : public nsISupports, virtual nsIPresShell* GetPresShell() { if (mCanvasElement) { - return mCanvasElement->OwnerDoc()->GetShell(); + return mCanvasElement->OwnerDoc()->GetPresShell(); } return nullptr; } diff --git a/dom/events/ContentEventHandler.cpp b/dom/events/ContentEventHandler.cpp index d31fcb4804038..99df93db13346 100644 --- a/dom/events/ContentEventHandler.cpp +++ b/dom/events/ContentEventHandler.cpp @@ -8,6 +8,7 @@ #include "mozilla/ContentIterator.h" #include "mozilla/IMEStateManager.h" +#include "mozilla/PresShell.h" #include "mozilla/TextComposition.h" #include "mozilla/TextEvents.h" #include "mozilla/dom/Element.h" @@ -21,7 +22,6 @@ #include "nsFocusManager.h" #include "nsFontMetrics.h" #include "nsFrameSelection.h" -#include "nsIPresShell.h" #include "nsIFrame.h" #include "nsIObjectFrame.h" #include "nsLayoutUtils.h" @@ -287,7 +287,7 @@ nsresult ContentEventHandler::InitRootContent(Selection* aNormalSelection) { NS_ASSERTION(startNode->GetComposedDoc() == endNode->GetComposedDoc(), "firstNormalSelectionRange crosses the document boundary"); - mRootContent = startNode->GetSelectionRootContent(mDocument->GetShell()); + mRootContent = startNode->GetSelectionRootContent(mDocument->GetPresShell()); if (NS_WARN_IF(!mRootContent)) { return NS_ERROR_FAILURE; } @@ -309,8 +309,8 @@ nsresult ContentEventHandler::InitCommon(SelectionType aSelectionType, NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr selectionController; - if (nsIPresShell* shell = mDocument->GetShell()) { - selectionController = shell->GetSelectionControllerForFocusedContent(); + if (PresShell* presShell = mDocument->GetPresShell()) { + selectionController = presShell->GetSelectionControllerForFocusedContent(); } if (NS_WARN_IF(!selectionController)) { return NS_ERROR_NOT_AVAILABLE; @@ -965,8 +965,8 @@ nsresult ContentEventHandler::ExpandToClusterBoundary(nsIContent* aContent, NS_ASSERTION(*aXPOffset <= aContent->TextLength(), "offset is out of range."); - MOZ_DIAGNOSTIC_ASSERT(mDocument->GetShell()); - RefPtr fs = mDocument->GetShell()->FrameSelection(); + MOZ_DIAGNOSTIC_ASSERT(mDocument->GetPresShell()); + RefPtr fs = mDocument->GetPresShell()->FrameSelection(); int32_t offsetInFrame; CaretAssociationHint hint = aForward ? CARET_ASSOCIATE_BEFORE : CARET_ASSOCIATE_AFTER; @@ -2511,9 +2511,9 @@ nsresult ContentEventHandler::OnQueryCharacterAtPoint( aEvent->mReply.mOffset = aEvent->mReply.mTentativeCaretOffset = WidgetQueryContentEvent::NOT_FOUND; - nsIPresShell* shell = mDocument->GetShell(); - NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE); - nsIFrame* rootFrame = shell->GetRootFrame(); + PresShell* presShell = mDocument->GetPresShell(); + NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); + nsIFrame* rootFrame = presShell->GetRootFrame(); NS_ENSURE_TRUE(rootFrame, NS_ERROR_FAILURE); nsIWidget* rootWidget = rootFrame->GetNearestWidget(); NS_ENSURE_TRUE(rootWidget, NS_ERROR_FAILURE); @@ -2623,9 +2623,9 @@ nsresult ContentEventHandler::OnQueryDOMWidgetHittest( NS_ENSURE_TRUE(aEvent->mWidget, NS_ERROR_FAILURE); - nsIPresShell* shell = mDocument->GetShell(); - NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE); - nsIFrame* docFrame = shell->GetRootFrame(); + PresShell* presShell = mDocument->GetPresShell(); + NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); + nsIFrame* docFrame = presShell->GetRootFrame(); NS_ENSURE_TRUE(docFrame, NS_ERROR_FAILURE); LayoutDeviceIntPoint eventLoc = diff --git a/dom/events/EventListenerManager.cpp b/dom/events/EventListenerManager.cpp index 5a961923a674d..93567efee1459 100644 --- a/dom/events/EventListenerManager.cpp +++ b/dom/events/EventListenerManager.cpp @@ -18,6 +18,7 @@ #include "mozilla/Maybe.h" #include "mozilla/MemoryReporting.h" #include "mozilla/Preferences.h" +#include "mozilla/PresShell.h" #include "mozilla/dom/BindingUtils.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/Event.h" @@ -445,9 +446,9 @@ void EventListenerManager::ProcessApzAwareEventListenerAdd() { } if (doc && gfxPlatform::AsyncPanZoomEnabled()) { - nsIPresShell* ps = doc->GetShell(); - if (ps) { - nsIFrame* f = ps->GetRootFrame(); + PresShell* presShell = doc->GetPresShell(); + if (presShell) { + nsIFrame* f = presShell->GetRootFrame(); if (f) { f->SchedulePaint(); } diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index 2932e6e621a20..73ea869b18293 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -855,9 +855,9 @@ void EventStateManager::NotifyTargetUserActivation(WidgetEvent* aEvent, already_AddRefed EventStateManager::ESMFromContentOrThis( nsIContent* aContent) { if (aContent) { - nsIPresShell* shell = aContent->OwnerDoc()->GetShell(); - if (shell) { - nsPresContext* prescontext = shell->GetPresContext(); + PresShell* presShell = aContent->OwnerDoc()->GetPresShell(); + if (presShell) { + nsPresContext* prescontext = presShell->GetPresContext(); if (prescontext) { RefPtr esm = prescontext->EventStateManager(); if (esm) { @@ -4302,9 +4302,9 @@ void EventStateManager::NotifyMouseOver(WidgetMouseEvent* aMouseEvent, if (Document* parentDoc = mDocument->GetParentDocument()) { if (nsCOMPtr docContent = parentDoc->FindContentForSubDocument(mDocument)) { - if (nsIPresShell* parentShell = parentDoc->GetShell()) { + if (PresShell* parentPresShell = parentDoc->GetPresShell()) { RefPtr parentESM = - parentShell->GetPresContext()->EventStateManager(); + parentPresShell->GetPresContext()->EventStateManager(); parentESM->NotifyMouseOver(aMouseEvent, docContent); } } diff --git a/dom/events/IMEStateManager.cpp b/dom/events/IMEStateManager.cpp index 9e0d25bf7d0bb..92eb818178add 100644 --- a/dom/events/IMEStateManager.cpp +++ b/dom/events/IMEStateManager.cpp @@ -14,6 +14,7 @@ #include "mozilla/EventStates.h" #include "mozilla/MouseEvents.h" #include "mozilla/Preferences.h" +#include "mozilla/PresShell.h" #include "mozilla/TextComposition.h" #include "mozilla/TextEvents.h" #include "mozilla/Unused.h" @@ -32,7 +33,6 @@ #include "nsIFormControl.h" #include "nsINode.h" #include "nsIObserverService.h" -#include "nsIPresShell.h" #include "nsISupports.h" #include "nsPresContext.h" @@ -922,11 +922,11 @@ void IMEStateManager::UpdateIMEState(const IMEState& aNewIMEState, return; } - nsCOMPtr presShell; + RefPtr presShell; if (!aEditorBase) { MOZ_ASSERT(aContent, "we must have content"); Document* doc = aContent->OwnerDoc(); - presShell = doc->GetShell(); + presShell = doc->GetPresShell(); } else { presShell = aEditorBase->GetPresShell(); } diff --git a/dom/events/PointerEventHandler.cpp b/dom/events/PointerEventHandler.cpp index 203b2ea88f46c..d5b05ea055040 100644 --- a/dom/events/PointerEventHandler.cpp +++ b/dom/events/PointerEventHandler.cpp @@ -627,8 +627,8 @@ void PointerEventHandler::DispatchGotOrLostPointerCaptureEvent( bool aIsGotCapture, const WidgetPointerEvent* aPointerEvent, nsIContent* aCaptureTarget) { Document* targetDoc = aCaptureTarget->OwnerDoc(); - nsCOMPtr shell = targetDoc->GetShell(); - if (NS_WARN_IF(!shell)) { + RefPtr presShell = targetDoc->GetPresShell(); + if (NS_WARN_IF(!presShell)) { return; } @@ -654,7 +654,7 @@ void PointerEventHandler::DispatchGotOrLostPointerCaptureEvent( aPointerEvent->mWidget); localEvent.AssignPointerEventData(*aPointerEvent, true); - DebugOnly rv = shell->HandleEventWithTarget( + DebugOnly rv = presShell->HandleEventWithTarget( &localEvent, aCaptureTarget->GetPrimaryFrame(), aCaptureTarget, &status); NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), diff --git a/dom/html/ImageDocument.cpp b/dom/html/ImageDocument.cpp index d2f99e77c6362..9b140c144cd46 100644 --- a/dom/html/ImageDocument.cpp +++ b/dom/html/ImageDocument.cpp @@ -12,6 +12,7 @@ #include "mozilla/dom/ImageDocumentBinding.h" #include "mozilla/dom/HTMLImageElement.h" #include "mozilla/dom/MouseEvent.h" +#include "mozilla/PresShell.h" #include "mozilla/StaticPrefs.h" #include "nsRect.h" #include "nsIImageLoadingContent.h" @@ -26,7 +27,6 @@ #include "imgILoader.h" #include "imgIContainer.h" #include "imgINotificationObserver.h" -#include "nsIPresShell.h" #include "nsPresContext.h" #include "nsIChannel.h" #include "nsIContentPolicy.h" @@ -402,12 +402,12 @@ void ImageDocument::ScrollImageTo(int32_t aX, int32_t aY, bool restoreImage) { FlushPendingNotifications(FlushType::Layout); } - nsCOMPtr shell = GetShell(); - if (!shell) { + RefPtr presShell = GetPresShell(); + if (!presShell) { return; } - nsIScrollableFrame* sf = shell->GetRootScrollFrameAsScrollable(); + nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable(); if (!sf) { return; } @@ -835,9 +835,9 @@ float ImageDocument::GetZoomLevel() { #if defined(MOZ_WIDGET_ANDROID) float ImageDocument::GetResolution() { float resolution = mOriginalResolution; - nsCOMPtr shell = GetShell(); - if (shell) { - resolution = shell->GetResolution(); + RefPtr presShell = GetPresShell(); + if (presShell) { + resolution = presShell->GetResolution(); } return resolution; } diff --git a/dom/html/MediaDocument.cpp b/dom/html/MediaDocument.cpp index 1006f19e44191..196adddc0f38d 100644 --- a/dom/html/MediaDocument.cpp +++ b/dom/html/MediaDocument.cpp @@ -8,7 +8,6 @@ #include "nsGkAtoms.h" #include "nsRect.h" #include "nsPresContext.h" -#include "nsIPresShell.h" #include "nsIScrollable.h" #include "nsViewManager.h" #include "nsITextToSubURI.h" @@ -19,6 +18,7 @@ #include "nsNodeInfoManager.h" #include "nsContentUtils.h" #include "nsDocElementCreatedNotificationRunner.h" +#include "mozilla/PresShell.h" #include "mozilla/Services.h" #include "nsServiceManagerUtils.h" #include "nsIPrincipal.h" @@ -242,11 +242,11 @@ nsresult MediaDocument::CreateSyntheticDocument() { nsresult MediaDocument::StartLayout() { mMayStartLayout = true; - nsCOMPtr shell = GetShell(); + RefPtr presShell = GetPresShell(); // Don't mess with the presshell if someone has already handled // its initial reflow. - if (shell && !shell->DidInitialize()) { - nsresult rv = shell->Initialize(); + if (presShell && !presShell->DidInitialize()) { + nsresult rv = presShell->Initialize(); NS_ENSURE_SUCCESS(rv, rv); } diff --git a/dom/html/PluginDocument.cpp b/dom/html/PluginDocument.cpp index 5f7f670ee6db1..b0d57131b1c6c 100644 --- a/dom/html/PluginDocument.cpp +++ b/dom/html/PluginDocument.cpp @@ -7,7 +7,6 @@ #include "MediaDocument.h" #include "nsIPluginDocument.h" #include "nsGkAtoms.h" -#include "nsIPresShell.h" #include "nsIObjectFrame.h" #include "nsNPAPIPluginInstance.h" #include "DocumentInlines.h" @@ -17,6 +16,7 @@ #include "nsContentPolicyUtils.h" #include "nsIPropertyBag2.h" #include "mozilla/dom/Element.h" +#include "mozilla/PresShell.h" #include "nsObjectLoadingContent.h" #include "GeckoProfiler.h" @@ -182,7 +182,7 @@ nsresult PluginDocument::StartDocumentLoad(const char* aCommand, } nsresult PluginDocument::CreateSyntheticPluginDocument() { - NS_ASSERTION(!GetShell() || !GetShell()->DidInitialize(), + NS_ASSERTION(!GetPresShell() || !GetPresShell()->DidInitialize(), "Creating synthetic plugin document content too late"); // make our generic document diff --git a/dom/html/nsHTMLDocument.cpp b/dom/html/nsHTMLDocument.cpp index 24a23eb876d25..e8e9694d7145d 100644 --- a/dom/html/nsHTMLDocument.cpp +++ b/dom/html/nsHTMLDocument.cpp @@ -8,6 +8,7 @@ #include "nsIContentPolicy.h" #include "mozilla/DebugOnly.h" +#include "mozilla/PresShell.h" #include "mozilla/dom/HTMLAllCollection.h" #include "mozilla/dom/FeaturePolicyUtils.h" #include "nsCOMPtr.h" @@ -1432,7 +1433,7 @@ void nsHTMLDocument::Close(ErrorResult& rv) { // above about reusing frames applies. // // XXXhsivonen keeping this around for bug 577508 / 253951 still :-( - if (GetShell()) { + if (GetPresShell()) { FlushPendingNotifications(FlushType::Layout); } } @@ -1873,8 +1874,10 @@ void nsHTMLDocument::TearingDownEditor() { EditingState oldState = mEditingState; mEditingState = eTearingDown; - nsCOMPtr presShell = GetShell(); - if (!presShell) return; + RefPtr presShell = GetPresShell(); + if (!presShell) { + return; + } nsTArray> agentSheets; presShell->GetAgentStyleSheets(agentSheets); @@ -2018,7 +2021,7 @@ nsresult nsHTMLDocument::EditingStateChanged() { EditingState oldState = mEditingState; nsAutoEditingState push(this, eSettingUp); - nsCOMPtr presShell = GetShell(); + RefPtr presShell = GetPresShell(); NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); // Before making this window editable, we need to modify UA style sheet @@ -2200,7 +2203,7 @@ void nsHTMLDocument::MaybeDispatchCheckKeyPressEventModelEvent() { } void nsHTMLDocument::SetKeyPressEventModel(uint16_t aKeyPressEventModel) { - nsIPresShell* presShell = GetShell(); + PresShell* presShell = GetPresShell(); if (!presShell) { return; } diff --git a/dom/html/nsTextEditorState.cpp b/dom/html/nsTextEditorState.cpp index c4edcc72c2776..5eaec65182c06 100644 --- a/dom/html/nsTextEditorState.cpp +++ b/dom/html/nsTextEditorState.cpp @@ -8,7 +8,6 @@ #include "mozilla/TextInputListener.h" #include "nsCOMPtr.h" -#include "nsIPresShell.h" #include "nsView.h" #include "nsCaret.h" #include "nsLayoutCID.h" @@ -35,6 +34,7 @@ #include "nsTextNode.h" #include "nsIController.h" #include "mozilla/AutoRestore.h" +#include "mozilla/PresShell.h" #include "mozilla/TextEvents.h" #include "mozilla/dom/Event.h" #include "mozilla/dom/ScriptSettings.h" @@ -799,7 +799,7 @@ void TextInputListener::OnSelectionChange(Selection& aSelection, if (content) { nsCOMPtr doc = content->GetComposedDoc(); if (doc) { - nsCOMPtr presShell = doc->GetShell(); + RefPtr presShell = doc->GetPresShell(); if (presShell) { nsEventStatus status = nsEventStatus_eIgnore; WidgetEvent event(true, eFormSelect); diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index dc3aff83ed905..ab6855d83ba8c 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -205,7 +205,7 @@ already_AddRefed TabChildBase::GetDocument() const { already_AddRefed TabChildBase::GetPresShell() const { nsCOMPtr result; if (nsCOMPtr doc = GetDocument()) { - result = doc->GetShell(); + result = doc->GetPresShell(); } return result.forget(); } @@ -455,12 +455,12 @@ TabChild::Observe(nsISupports* aSubject, const char* aTopic, nsCOMPtr doc(GetDocument()); if (subject == doc) { - nsCOMPtr shell(doc->GetShell()); - if (shell) { - shell->SetIsFirstPaint(true); + RefPtr presShell = doc->GetPresShell(); + if (presShell) { + presShell->SetIsFirstPaint(true); } - APZCCallbackHelper::InitializeRootDisplayport(shell); + APZCCallbackHelper::InitializeRootDisplayport(presShell); } } } diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 2fc7cd5e0649b..a7d032ac261af 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -2171,7 +2171,7 @@ mozilla::ipc::IPCResult TabParent::RecvAccessKeyNotHandled( // Here we convert the WidgetEvent that we received to an Event // to be able to dispatch it to the element as the target element. Document* doc = mFrameElement->OwnerDoc(); - nsIPresShell* presShell = doc->GetShell(); + PresShell* presShell = doc->GetPresShell(); NS_ENSURE_TRUE(presShell, IPC_OK()); if (presShell->CanDispatchEvent()) { @@ -2538,9 +2538,9 @@ mozilla::ipc::IPCResult TabParent::RecvSetInputContext( already_AddRefed TabParent::GetTopLevelWidget() { nsCOMPtr content = mFrameElement; if (content) { - nsIPresShell* shell = content->OwnerDoc()->GetShell(); - if (shell) { - nsViewManager* vm = shell->GetViewManager(); + PresShell* presShell = content->OwnerDoc()->GetPresShell(); + if (presShell) { + nsViewManager* vm = presShell->GetViewManager(); nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); return widget.forget(); @@ -3297,8 +3297,8 @@ mozilla::ipc::IPCResult TabParent::RecvInvokeDragSession( const gfx::SurfaceFormat& aFormat, const LayoutDeviceIntRect& aDragRect, const IPC::Principal& aPrincipal) { mInitialDataTransferItems.Clear(); - nsIPresShell* shell = mFrameElement->OwnerDoc()->GetShell(); - if (!shell) { + PresShell* presShell = mFrameElement->OwnerDoc()->GetPresShell(); + if (!presShell) { Unused << Manager()->SendEndDragSession(true, true, LayoutDeviceIntPoint(), 0); // Continue sending input events with input priority when stopping the dnd @@ -3307,7 +3307,7 @@ mozilla::ipc::IPCResult TabParent::RecvInvokeDragSession( return IPC_OK(); } - EventStateManager* esm = shell->GetPresContext()->EventStateManager(); + EventStateManager* esm = presShell->GetPresContext()->EventStateManager(); for (uint32_t i = 0; i < aTransfers.Length(); ++i) { mInitialDataTransferItems.AppendElement(std::move(aTransfers[i].items())); } diff --git a/dom/prototype/PrototypeDocumentContentSink.cpp b/dom/prototype/PrototypeDocumentContentSink.cpp index 71316d5e953e2..7976b3b396703 100644 --- a/dom/prototype/PrototypeDocumentContentSink.cpp +++ b/dom/prototype/PrototypeDocumentContentSink.cpp @@ -58,6 +58,7 @@ #include "mozilla/dom/ProcessingInstruction.h" #include "mozilla/dom/ScriptLoader.h" #include "mozilla/LoadInfo.h" +#include "mozilla/PresShell.h" #include "nsXULPrototypeCache.h" #include "nsXULElement.h" @@ -642,9 +643,9 @@ void PrototypeDocumentContentSink::StartLayout() { "PrototypeDocumentContentSink::StartLayout", LAYOUT, mDocumentURI->GetSpecOrDefault()); mDocument->SetMayStartLayout(true); - nsCOMPtr shell = mDocument->GetShell(); - if (shell && !shell->DidInitialize()) { - nsresult rv = shell->Initialize(); + RefPtr presShell = mDocument->GetPresShell(); + if (presShell && !presShell->DidInitialize()) { + nsresult rv = presShell->Initialize(); if (NS_FAILED(rv)) { return; } diff --git a/dom/smil/SMILAnimationController.cpp b/dom/smil/SMILAnimationController.cpp index 67d860b220150..1e906db4aa84a 100644 --- a/dom/smil/SMILAnimationController.cpp +++ b/dom/smil/SMILAnimationController.cpp @@ -9,6 +9,7 @@ #include #include "mozilla/AutoRestore.h" +#include "mozilla/PresShell.h" #include "mozilla/RestyleManager.h" #include "mozilla/SMILTimedElement.h" #include "mozilla/dom/DocumentInlines.h" @@ -17,7 +18,6 @@ #include "nsContentUtils.h" #include "nsCSSProps.h" #include "mozilla/dom/Document.h" -#include "nsIPresShell.h" #include "nsIPresShellInlines.h" #include "nsITimer.h" #include "SMILCompositor.h" @@ -729,8 +729,8 @@ nsRefreshDriver* SMILAnimationController::GetRefreshDriver() { } void SMILAnimationController::FlagDocumentNeedsFlush() { - if (nsIPresShell* shell = mDocument->GetShell()) { - shell->SetNeedStyleFlush(); + if (PresShell* presShell = mDocument->GetPresShell()) { + presShell->SetNeedStyleFlush(); } } diff --git a/dom/svg/SVGContentUtils.cpp b/dom/svg/SVGContentUtils.cpp index 8741d74a33e96..c976cc53cc5a5 100644 --- a/dom/svg/SVGContentUtils.cpp +++ b/dom/svg/SVGContentUtils.cpp @@ -14,6 +14,7 @@ #include "gfxPlatform.h" #include "mozilla/gfx/2D.h" #include "mozilla/dom/SVGSVGElement.h" +#include "mozilla/PresShell.h" #include "mozilla/RefPtr.h" #include "mozilla/SVGContextPaint.h" #include "mozilla/TextUtils.h" @@ -516,7 +517,7 @@ static gfx::Matrix GetCTMInternal(SVGElement* aElement, bool aScreenCTM, float x = 0.0f, y = 0.0f; if (currentDoc && element->NodeInfo()->Equals(nsGkAtoms::svg, kNameSpaceID_SVG)) { - nsIPresShell* presShell = currentDoc->GetShell(); + PresShell* presShell = currentDoc->GetPresShell(); if (presShell) { nsIFrame* frame = element->GetPrimaryFrame(); nsIFrame* ancestorFrame = presShell->GetRootFrame(); diff --git a/dom/svg/SVGElement.cpp b/dom/svg/SVGElement.cpp index 3f2ec5c05210f..7104b28f5fd81 100644 --- a/dom/svg/SVGElement.cpp +++ b/dom/svg/SVGElement.cpp @@ -19,6 +19,7 @@ #include "mozilla/DeclarationBlock.h" #include "mozilla/EventListenerManager.h" #include "mozilla/InternalMutationEvent.h" +#include "mozilla/PresShell.h" #include "mozilla/RestyleManager.h" #include "mozilla/SMILAnimationController.h" #include "mozilla/SVGContentUtils.h" @@ -34,7 +35,6 @@ #include "mozilla/dom/Document.h" #include "nsError.h" #include "nsGkAtoms.h" -#include "nsIPresShell.h" #include "nsIFrame.h" #include "nsQueryObject.h" #include "nsLayoutUtils.h" @@ -105,9 +105,9 @@ JSObject* SVGElement::WrapNode(JSContext* aCx, void SVGElement::DidAnimateClass() { // For Servo, snapshot the element before we change it. - nsIPresShell* shell = OwnerDoc()->GetShell(); - if (shell) { - if (nsPresContext* presContext = shell->GetPresContext()) { + PresShell* presShell = OwnerDoc()->GetPresShell(); + if (presShell) { + if (nsPresContext* presContext = presShell->GetPresContext()) { presContext->RestyleManager()->ClassAttributeWillBeChangedBySMIL(this); } } @@ -121,8 +121,8 @@ void SVGElement::DidAnimateClass() { // FIXME(emilio): This re-selector-matches, but we do the snapshot stuff right // above... Is this needed anymore? - if (shell) { - shell->RestyleForAnimation(this, StyleRestyleHint_RESTYLE_SELF); + if (presShell) { + presShell->RestyleForAnimation(this, StyleRestyleHint_RESTYLE_SELF); } } diff --git a/dom/svg/SVGSVGElement.cpp b/dom/svg/SVGSVGElement.cpp index 8d6736f3ac19c..eec0120241bb6 100644 --- a/dom/svg/SVGSVGElement.cpp +++ b/dom/svg/SVGSVGElement.cpp @@ -12,6 +12,7 @@ #include "mozilla/dom/SVGRect.h" #include "mozilla/dom/SVGViewElement.h" #include "mozilla/EventDispatcher.h" +#include "mozilla/PresShell.h" #include "mozilla/SMILAnimationController.h" #include "mozilla/SMILTimeContainer.h" @@ -319,7 +320,7 @@ void SVGSVGElement::SetCurrentScaleTranslate(float s, float x, float y) { // now dispatch the appropriate event if we are the root element Document* doc = GetUncomposedDoc(); if (doc) { - nsCOMPtr presShell = doc->GetShell(); + RefPtr presShell = doc->GetPresShell(); if (presShell && IsRoot()) { nsEventStatus status = nsEventStatus_eIgnore; if (mPreviousScale == mCurrentScale) { diff --git a/dom/xbl/XBLChildrenElement.cpp b/dom/xbl/XBLChildrenElement.cpp index 6cfbd361ba20a..93a7181e77735 100644 --- a/dom/xbl/XBLChildrenElement.cpp +++ b/dom/xbl/XBLChildrenElement.cpp @@ -5,9 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/dom/XBLChildrenElement.h" -#include "nsCharSeparatedTokenizer.h" + +#include "mozilla/PresShell.h" #include "mozilla/dom/NodeListBinding.h" #include "nsAttrValueOrString.h" +#include "nsCharSeparatedTokenizer.h" namespace mozilla { namespace dom { @@ -46,8 +48,8 @@ void XBLChildrenElement::DoRemoveDefaultContent(bool aNotify) { if (aNotify) { Element* parent = GetParentElement(); if (Document* doc = parent->GetComposedDoc()) { - if (nsIPresShell* shell = doc->GetShell()) { - shell->DestroyFramesForAndRestyle(parent); + if (PresShell* presShell = doc->GetPresShell()) { + presShell->DestroyFramesForAndRestyle(parent); } } } diff --git a/dom/xbl/nsBindingManager.cpp b/dom/xbl/nsBindingManager.cpp index 445057bbdf934..c44c3681689c8 100644 --- a/dom/xbl/nsBindingManager.cpp +++ b/dom/xbl/nsBindingManager.cpp @@ -19,7 +19,6 @@ #include "nsIContentInlines.h" #include "mozilla/dom/Document.h" #include "nsContentUtils.h" -#include "nsIPresShell.h" #include "nsIPresShellInlines.h" #include "nsIXMLContentSink.h" #include "nsContentCID.h" @@ -51,6 +50,7 @@ #include "nsThreadUtils.h" #include "mozilla/dom/NodeListBinding.h" #include "mozilla/dom/ScriptSettings.h" +#include "mozilla/PresShell.h" #include "mozilla/Unused.h" using namespace mozilla; @@ -228,8 +228,7 @@ nsresult nsBindingManager::ClearBinding(Element* aElement) { nsCOMPtr doc = aElement->OwnerDoc(); // Destroy the frames here before the UnbindFromTree happens. - nsIPresShell* presShell = doc->GetShell(); - if (presShell) { + if (PresShell* presShell = doc->GetPresShell()) { presShell->DestroyFramesForAndRestyle(aElement); } @@ -245,9 +244,9 @@ nsresult nsBindingManager::ClearBinding(Element* aElement) { // been removed and style may have changed due to the removal of the // anonymous children. // XXXbz this should be using the current doc (if any), not the owner doc. - presShell = doc->GetShell(); // get the shell again, just in case it changed + // get the shell again, just in case it changed + PresShell* presShell = doc->GetPresShell(); NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); - presShell->PostRecreateFramesFor(aElement); return NS_OK; } @@ -289,8 +288,8 @@ nsresult nsBindingManager::AddToAttachedQueue(nsXBLBinding* aBinding) { } // Make sure that flushes will flush out the new items as needed. - if (nsIPresShell* shell = mDocument->GetShell()) { - shell->SetNeedStyleFlush(); + if (PresShell* presShell = mDocument->GetPresShell()) { + presShell->SetNeedStyleFlush(); } return NS_OK; diff --git a/dom/xbl/nsXBLPrototypeResources.cpp b/dom/xbl/nsXBLPrototypeResources.cpp index a1dde3143a1e8..a02a0601aac79 100644 --- a/dom/xbl/nsXBLPrototypeResources.cpp +++ b/dom/xbl/nsXBLPrototypeResources.cpp @@ -16,6 +16,7 @@ #include "nsLayoutCID.h" #include "mozilla/dom/URL.h" #include "mozilla/DebugOnly.h" +#include "mozilla/PresShell.h" #include "mozilla/ServoBindings.h" #include "mozilla/ServoStyleRuleMap.h" #include "mozilla/StyleSheet.h" @@ -94,9 +95,9 @@ nsresult nsXBLPrototypeResources::FlushSkinSheets() { } // There may be no shell during unlink. - if (auto* shell = doc->GetShell()) { - MOZ_ASSERT(shell->GetPresContext()); - ComputeServoStyles(*shell->StyleSet()); + if (PresShell* presShell = doc->GetPresShell()) { + MOZ_ASSERT(presShell->GetPresContext()); + ComputeServoStyles(*presShell->StyleSet()); } return NS_OK; diff --git a/dom/xbl/nsXBLResourceLoader.cpp b/dom/xbl/nsXBLResourceLoader.cpp index 4d5ab48c0c437..fdd7c1e1c1026 100644 --- a/dom/xbl/nsXBLResourceLoader.cpp +++ b/dom/xbl/nsXBLResourceLoader.cpp @@ -8,7 +8,6 @@ #include "nsString.h" #include "mozilla/dom/Document.h" #include "nsIContent.h" -#include "nsIPresShell.h" #include "nsXBLService.h" #include "nsIServiceManager.h" #include "nsXBLResourceLoader.h" @@ -17,6 +16,7 @@ #include "imgILoader.h" #include "imgRequestProxy.h" #include "mozilla/ComputedStyle.h" +#include "mozilla/PresShell.h" #include "mozilla/StyleSheet.h" #include "mozilla/StyleSheetInlines.h" #include "mozilla/css/Loader.h" @@ -162,8 +162,8 @@ nsXBLResourceLoader::StyleSheetLoaded(StyleSheet* aSheet, bool aWasDeferred, // Our document might have been undisplayed after this sheet load // was started, so check before building the XBL cascade data. - if (nsIPresShell* shell = mBoundDocument->GetShell()) { - mResources->ComputeServoStyles(*shell->StyleSet()); + if (PresShell* presShell = mBoundDocument->GetPresShell()) { + mResources->ComputeServoStyles(*presShell->StyleSet()); } // XXX Check for mPendingScripts when scripts also come online. @@ -214,12 +214,12 @@ void nsXBLResourceLoader::NotifyBoundElements() { continue; } - nsIPresShell* shell = doc->GetShell(); - if (!shell) { + PresShell* presShell = doc->GetPresShell(); + if (!presShell) { continue; } - shell->PostRecreateFramesFor(content->AsElement()); + presShell->PostRecreateFramesFor(content->AsElement()); } // Clear out the whole array. diff --git a/dom/xbl/nsXBLService.cpp b/dom/xbl/nsXBLService.cpp index 86b20172034cc..adcf7a5c5535d 100644 --- a/dom/xbl/nsXBLService.cpp +++ b/dom/xbl/nsXBLService.cpp @@ -36,7 +36,6 @@ #include "nsTArray.h" #include "nsError.h" -#include "nsIPresShell.h" #include "nsIDocumentObserver.h" #include "nsFrameManager.h" #include "nsIScriptSecurityManager.h" @@ -50,6 +49,7 @@ #include "mozilla/Attributes.h" #include "mozilla/EventListenerManager.h" #include "mozilla/Preferences.h" +#include "mozilla/PresShell.h" #include "mozilla/ServoStyleSet.h" #include "mozilla/RestyleManager.h" #include "mozilla/dom/ChildIterator.h" @@ -116,8 +116,8 @@ class nsXBLBindingRequest { // Destroy the frames for mBoundElement. Do this after getting the binding, // since if the binding fetch fails then we don't want to destroy the // frames. - if (nsIPresShell* shell = doc->GetShell()) { - shell->DestroyFramesForAndRestyle(mBoundElement->AsElement()); + if (PresShell* presShell = doc->GetPresShell()) { + presShell->DestroyFramesForAndRestyle(mBoundElement->AsElement()); } MOZ_ASSERT(!mBoundElement->GetPrimaryFrame()); } @@ -360,7 +360,7 @@ static void EnsureSubtreeStyled(Element* aElement) { return; } - nsIPresShell* presShell = aElement->OwnerDoc()->GetShell(); + PresShell* presShell = aElement->OwnerDoc()->GetPresShell(); if (!presShell || !presShell->DidInitialize()) { return; } @@ -410,7 +410,7 @@ class MOZ_RAII AutoStyleElement { } ~AutoStyleElement() { - nsIPresShell* presShell = mElement->OwnerDoc()->GetShell(); + PresShell* presShell = mElement->OwnerDoc()->GetPresShell(); if (!mHadData || !presShell || !presShell->DidInitialize()) { return; } diff --git a/dom/xul/nsXULElement.cpp b/dom/xul/nsXULElement.cpp index 00516d062cbdf..d82ab0bdbbe36 100644 --- a/dom/xul/nsXULElement.cpp +++ b/dom/xul/nsXULElement.cpp @@ -18,6 +18,7 @@ #include "mozilla/EventStateManager.h" #include "mozilla/EventStates.h" #include "mozilla/DeclarationBlock.h" +#include "mozilla/PresShell.h" #include "js/CompilationAndEvaluation.h" #include "js/SourceText.h" #include "nsFocusManager.h" @@ -25,7 +26,6 @@ #include "nsNameSpaceManager.h" #include "nsIObjectInputStream.h" #include "nsIObjectOutputStream.h" -#include "nsIPresShell.h" #include "nsIPrincipal.h" #include "nsIScriptContext.h" #include "nsIScriptError.h" @@ -746,9 +746,9 @@ void nsXULElement::UnregisterAccessKey(const nsAString& aOldValue) { // Document* doc = GetComposedDoc(); if (doc && !aOldValue.IsEmpty()) { - nsIPresShell* shell = doc->GetShell(); + PresShell* presShell = doc->GetPresShell(); - if (shell) { + if (presShell) { Element* element = this; // find out what type of content node this is @@ -761,7 +761,7 @@ void nsXULElement::UnregisterAccessKey(const nsAString& aOldValue) { } if (element) { - shell->GetPresContext()->EventStateManager()->UnregisterAccessKey( + presShell->GetPresContext()->EventStateManager()->UnregisterAccessKey( element, aOldValue.First()); } } diff --git a/editor/libeditor/EditorBase.h b/editor/libeditor/EditorBase.h index 69a05e73391c3..db7f670b89cd8 100644 --- a/editor/libeditor/EditorBase.h +++ b/editor/libeditor/EditorBase.h @@ -197,7 +197,7 @@ class EditorBase : public nsIEditor, Document* GetDocument() const { return mDocument; } PresShell* GetPresShell() const { - return mDocument ? static_cast(mDocument->GetShell()) : nullptr; + return mDocument ? mDocument->GetPresShell() : nullptr; } nsPresContext* GetPresContext() const { PresShell* presShell = GetPresShell(); @@ -220,7 +220,7 @@ class EditorBase : public nsIEditor, if (!mDocument) { return nullptr; } - return static_cast(mDocument->GetShell()); + return mDocument->GetPresShell(); } nsresult GetSelection(SelectionType aSelectionType, diff --git a/gfx/layers/apz/src/FocusTarget.cpp b/gfx/layers/apz/src/FocusTarget.cpp index 0f3ff6593252f..0f9bfd62cffad 100644 --- a/gfx/layers/apz/src/FocusTarget.cpp +++ b/gfx/layers/apz/src/FocusTarget.cpp @@ -11,8 +11,8 @@ #include "mozilla/dom/TabParent.h" // for TabParent #include "mozilla/EventDispatcher.h" // for EventDispatcher #include "mozilla/layout/RenderFrame.h" // For RenderFrame +#include "mozilla/PresShell.h" // For PresShell and nsIPresShell #include "nsIContentInlines.h" // for nsINode::IsEditable() -#include "nsIPresShell.h" // for nsIPresShell #include "nsLayoutUtils.h" // for nsLayoutUtils #define ENABLE_FT_LOGGING 0 @@ -49,7 +49,7 @@ static already_AddRefed GetRetargetEventPresShell( return nullptr; } - nsCOMPtr presShell = retargetEventDoc->GetShell(); + nsCOMPtr presShell = retargetEventDoc->GetPresShell(); return presShell.forget(); } diff --git a/gfx/layers/apz/util/APZCCallbackHelper.cpp b/gfx/layers/apz/util/APZCCallbackHelper.cpp index 21c2df7ffc6ad..677c526b3ecff 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.cpp +++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp @@ -18,6 +18,7 @@ #include "mozilla/layers/ShadowLayers.h" #include "mozilla/layers/WebRenderLayerManager.h" #include "mozilla/layers/WebRenderBridgeChild.h" +#include "mozilla/PresShell.h" #include "mozilla/TouchEvents.h" #include "nsContainerFrame.h" #include "nsContentUtils.h" @@ -73,7 +74,7 @@ static ScreenMargin RecenterDisplayPort(const ScreenMargin& aDisplayPort) { static already_AddRefed GetPresShell(const nsIContent* aContent) { nsCOMPtr result; if (dom::Document* doc = aContent->GetComposedDoc()) { - result = doc->GetShell(); + result = doc->GetPresShell(); } return result.forget(); } @@ -436,11 +437,11 @@ nsPresContext* APZCCallbackHelper::GetPresContextForContent( if (!doc) { return nullptr; } - nsIPresShell* shell = doc->GetShell(); - if (!shell) { + PresShell* presShell = doc->GetPresShell(); + if (!presShell) { return nullptr; } - return shell->GetPresContext(); + return presShell->GetPresContext(); } nsIPresShell* APZCCallbackHelper::GetRootContentDocumentPresShellForContent( @@ -461,11 +462,11 @@ static nsIPresShell* GetRootDocumentPresShell(nsIContent* aContent) { if (!doc) { return nullptr; } - nsIPresShell* shell = doc->GetShell(); - if (!shell) { + PresShell* presShell = doc->GetPresShell(); + if (!presShell) { return nullptr; } - nsPresContext* context = shell->GetPresContext(); + nsPresContext* context = presShell->GetPresContext(); if (!context) { return nullptr; } @@ -646,8 +647,8 @@ static nsIFrame* UpdateRootFrameForTouchTargetDocument(nsIFrame* aRootFrame) { // necessary. if (dom::Document* doc = aRootFrame->PresShell()->GetPrimaryContentDocument()) { - if (nsIPresShell* shell = doc->GetShell()) { - if (nsIFrame* frame = shell->GetRootFrame()) { + if (PresShell* presShell = doc->GetPresShell()) { + if (nsIFrame* frame = presShell->GetRootFrame()) { return frame; } } @@ -838,8 +839,8 @@ APZCCallbackHelper::SendSetTargetAPZCNotification( return nullptr; } sLastTargetAPZCNotificationInputBlock = aInputBlockId; - if (nsIPresShell* shell = aDocument->GetShell()) { - if (nsIFrame* rootFrame = shell->GetRootFrame()) { + if (PresShell* presShell = aDocument->GetPresShell()) { + if (nsIFrame* rootFrame = presShell->GetRootFrame()) { rootFrame = UpdateRootFrameForTouchTargetDocument(rootFrame); bool waitForRefresh = false; @@ -866,7 +867,7 @@ APZCCallbackHelper::SendSetTargetAPZCNotification( "At least one target got a new displayport, need to wait for " "refresh\n"); return MakeUnique( - aWidget, shell, aInputBlockId, std::move(targets)); + aWidget, presShell, aInputBlockId, std::move(targets)); } APZCCH_LOG("Sending target APZCs for input block %" PRIu64 "\n", aInputBlockId); @@ -884,8 +885,8 @@ void APZCCallbackHelper::SendSetAllowedTouchBehaviorNotification( if (!aWidget || !aDocument) { return; } - if (nsIPresShell* shell = aDocument->GetShell()) { - if (nsIFrame* rootFrame = shell->GetRootFrame()) { + if (PresShell* presShell = aDocument->GetPresShell()) { + if (nsIFrame* rootFrame = presShell->GetRootFrame()) { rootFrame = UpdateRootFrameForTouchTargetDocument(rootFrame); nsTArray flags; diff --git a/gfx/layers/apz/util/ActiveElementManager.cpp b/gfx/layers/apz/util/ActiveElementManager.cpp index f95096635509f..4fb5b69c0646d 100644 --- a/gfx/layers/apz/util/ActiveElementManager.cpp +++ b/gfx/layers/apz/util/ActiveElementManager.cpp @@ -8,6 +8,7 @@ #include "mozilla/EventStateManager.h" #include "mozilla/EventStates.h" #include "mozilla/Preferences.h" +#include "mozilla/PresShell.h" #include "base/message_loop.h" #include "base/task.h" #include "mozilla/dom/Element.h" @@ -131,11 +132,11 @@ static nsPresContext* GetPresContextFor(nsIContent* aContent) { if (!aContent) { return nullptr; } - nsIPresShell* shell = aContent->OwnerDoc()->GetShell(); - if (!shell) { + PresShell* presShell = aContent->OwnerDoc()->GetPresShell(); + if (!presShell) { return nullptr; } - return shell->GetPresContext(); + return presShell->GetPresContext(); } void ActiveElementManager::SetActive(dom::Element* aTarget) { diff --git a/gfx/layers/apz/util/ChromeProcessController.cpp b/gfx/layers/apz/util/ChromeProcessController.cpp index 03dbf4a0c7ea6..42c6e44f6d356 100644 --- a/gfx/layers/apz/util/ChromeProcessController.cpp +++ b/gfx/layers/apz/util/ChromeProcessController.cpp @@ -8,6 +8,7 @@ #include "MainThreadUtils.h" // for NS_IsMainThread() #include "base/message_loop.h" // for MessageLoop +#include "mozilla/PresShell.h" #include "mozilla/dom/Element.h" #include "mozilla/layers/CompositorBridgeParent.h" #include "mozilla/layers/APZCCallbackHelper.h" @@ -17,7 +18,6 @@ #include "mozilla/layers/DoubleTapToZoom.h" #include "mozilla/dom/Document.h" #include "nsIInterfaceRequestorUtils.h" -#include "nsIPresShell.h" #include "nsLayoutUtils.h" #include "nsView.h" @@ -141,7 +141,7 @@ void ChromeProcessController::HandleDoubleTap( // Root Content Document. Unfortunately that frame does not know about the // resolution of the document and so we must remove it before calculating // the zoomToRect. - nsIPresShell* presShell = document->GetShell(); + PresShell* presShell = document->GetPresShell(); const float resolution = presShell->GetResolution(); CSSPoint point(aPoint.x / resolution, aPoint.y / resolution); CSSRect zoomToRect = CalculateRectToZoomTo(document, point); diff --git a/gfx/layers/apz/util/ContentProcessController.cpp b/gfx/layers/apz/util/ContentProcessController.cpp index d1949f3d7e0d1..8fac99ab328a4 100644 --- a/gfx/layers/apz/util/ContentProcessController.cpp +++ b/gfx/layers/apz/util/ContentProcessController.cpp @@ -6,6 +6,7 @@ #include "ContentProcessController.h" +#include "mozilla/PresShell.h" #include "mozilla/dom/TabChild.h" #include "mozilla/layers/APZCCallbackHelper.h" #include "mozilla/layers/APZChild.h" @@ -67,11 +68,11 @@ void ContentProcessController::NotifyMozMouseScrollEvent( void ContentProcessController::NotifyFlushComplete() { if (mBrowser) { - nsCOMPtr shell; + RefPtr presShell; if (nsCOMPtr doc = mBrowser->GetDocument()) { - shell = doc->GetShell(); + presShell = doc->GetPresShell(); } - APZCCallbackHelper::NotifyFlushComplete(shell.get()); + APZCCallbackHelper::NotifyFlushComplete(presShell); } } diff --git a/gfx/layers/apz/util/DoubleTapToZoom.cpp b/gfx/layers/apz/util/DoubleTapToZoom.cpp index 2b696e5eda4c0..4bb31fabdc929 100644 --- a/gfx/layers/apz/util/DoubleTapToZoom.cpp +++ b/gfx/layers/apz/util/DoubleTapToZoom.cpp @@ -8,6 +8,7 @@ #include // for std::min, std::max +#include "mozilla/PresShell.h" #include "mozilla/AlreadyAddRefed.h" #include "mozilla/dom/Element.h" #include "nsCOMPtr.h" @@ -16,7 +17,6 @@ #include "nsIDOMWindow.h" #include "nsIFrame.h" #include "nsIFrameInlines.h" -#include "nsIPresShell.h" #include "nsLayoutUtils.h" #include "nsStyleConsts.h" @@ -28,7 +28,7 @@ namespace { using FrameForPointOption = nsLayoutUtils::FrameForPointOption; // Returns the DOM element found at |aPoint|, interpreted as being relative to -// the root frame of |aShell|. If the point is inside a subdocument, returns +// the root frame of |aPresShell|. If the point is inside a subdocument, returns // an element inside the subdocument, rather than the subdocument element // (and does so recursively). // The implementation was adapted from DocumentOrShadowRoot::ElementFromPoint(), @@ -36,8 +36,8 @@ using FrameForPointOption = nsLayoutUtils::FrameForPointOption; // to GetFrameForPoint(), so as to get the behaviour described above in the // presence of subdocuments. static already_AddRefed ElementFromPoint( - const nsCOMPtr& aShell, const CSSPoint& aPoint) { - nsIFrame* rootFrame = aShell->GetRootFrame(); + const RefPtr& aPresShell, const CSSPoint& aPoint) { + nsIFrame* rootFrame = aPresShell->GetRootFrame(); if (!rootFrame) { return nullptr; } @@ -104,17 +104,18 @@ CSSRect CalculateRectToZoomTo(const RefPtr& aRootContentDocument, // An empty rect as return value is interpreted as "zoom out". const CSSRect zoomOut; - nsCOMPtr shell = aRootContentDocument->GetShell(); - if (!shell) { + RefPtr presShell = aRootContentDocument->GetPresShell(); + if (!presShell) { return zoomOut; } - nsIScrollableFrame* rootScrollFrame = shell->GetRootScrollFrameAsScrollable(); + nsIScrollableFrame* rootScrollFrame = + presShell->GetRootScrollFrameAsScrollable(); if (!rootScrollFrame) { return zoomOut; } - nsCOMPtr element = ElementFromPoint(shell, aPoint); + nsCOMPtr element = ElementFromPoint(presShell, aPoint); if (!element) { return zoomOut; } @@ -130,7 +131,7 @@ CSSRect CalculateRectToZoomTo(const RefPtr& aRootContentDocument, FrameMetrics metrics = nsLayoutUtils::CalculateBasicFrameMetrics(rootScrollFrame); CSSRect compositedArea( - CSSPoint::FromAppUnits(shell->GetVisualViewportOffset()), + CSSPoint::FromAppUnits(presShell->GetVisualViewportOffset()), metrics.CalculateCompositedSizeInCssPixels()); const CSSCoord margin = 15; CSSRect rect = diff --git a/layout/base/AccessibleCaretManager.cpp b/layout/base/AccessibleCaretManager.cpp index 8ad3a25ba4483..8732f29546d76 100644 --- a/layout/base/AccessibleCaretManager.cpp +++ b/layout/base/AccessibleCaretManager.cpp @@ -18,6 +18,7 @@ #include "mozilla/dom/TreeWalker.h" #include "mozilla/IMEStateManager.h" #include "mozilla/IntegerPrintfMacros.h" +#include "mozilla/PresShell.h" #include "mozilla/StaticPrefs.h" #include "nsCaret.h" #include "nsContainerFrame.h" diff --git a/layout/base/GeometryUtils.cpp b/layout/base/GeometryUtils.cpp index 32a33b784c9d5..ea178fabc5eae 100644 --- a/layout/base/GeometryUtils.cpp +++ b/layout/base/GeometryUtils.cpp @@ -6,6 +6,7 @@ #include "GeometryUtils.h" +#include "mozilla/PresShell.h" #include "mozilla/dom/CharacterData.h" #include "mozilla/dom/DOMPointBinding.h" #include "mozilla/dom/GeometryUtilsBinding.h" @@ -33,8 +34,8 @@ enum GeometryNodeType { static nsIFrame* GetFrameForNode(nsINode* aNode, GeometryNodeType aType) { Document* doc = aNode->OwnerDoc(); if (aType == GEOMETRY_NODE_TEXT) { - if (nsIPresShell* shell = doc->GetShell()) { - shell->FrameConstructor()->EnsureFrameForTextNodeIsCreatedAfterFlush( + if (PresShell* presShell = doc->GetPresShell()) { + presShell->FrameConstructor()->EnsureFrameForTextNodeIsCreatedAfterFlush( static_cast(aNode)); } } @@ -45,7 +46,7 @@ static nsIFrame* GetFrameForNode(nsINode* aNode, GeometryNodeType aType) { case GEOMETRY_NODE_ELEMENT: return aNode->AsContent()->GetPrimaryFrame(); case GEOMETRY_NODE_DOCUMENT: { - nsIPresShell* presShell = doc->GetShell(); + PresShell* presShell = doc->GetPresShell(); return presShell ? presShell->GetRootFrame() : nullptr; } default: diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index d10b3a667ce47..29b6de405662c 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -1317,9 +1317,9 @@ void PresShell::Destroy() { // hierarchy is torn down to avoid finding deleted frames through // this presshell while the frames are being torn down if (mDocument) { - NS_ASSERTION(mDocument->GetShell() == this, "Wrong shell?"); + NS_ASSERTION(mDocument->GetPresShell() == this, "Wrong shell?"); mDocument->ClearServoRestyleRoot(); - mDocument->DeleteShell(); + mDocument->DeletePresShell(); if (mDocument->HasAnimationController()) { mDocument->GetAnimationController()->NotifyRefreshDriverDestroying(rd); @@ -3415,8 +3415,8 @@ nsresult nsIPresShell::ScrollContentIntoView( } // Flush layout and attempt to scroll in the process. - if (nsIPresShell* shell = composedDoc->GetShell()) { - shell->SetNeedLayoutFlush(); + if (PresShell* presShell = composedDoc->GetPresShell()) { + presShell->SetNeedLayoutFlush(); } composedDoc->FlushPendingNotifications(FlushType::InterruptibleLayout); @@ -4040,8 +4040,8 @@ void PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush aFlush) { } // Don't flush if the doc is already in the bfcache. - if (MOZ_UNLIKELY(mDocument->GetShell() != this)) { - MOZ_DIAGNOSTIC_ASSERT(!mDocument->GetShell(), + if (MOZ_UNLIKELY(mDocument->GetPresShell() != this)) { + MOZ_DIAGNOSTIC_ASSERT(!mDocument->GetPresShell(), "Where did this shell come from?"); isSafeToFlush = false; } @@ -5853,8 +5853,8 @@ void PresShell::EnsureFrameInApproximatelyVisibleList(nsIFrame* aFrame) { // Make sure it's in this pres shell. nsCOMPtr content = aFrame->GetContent(); if (content) { - PresShell* shell = static_cast(content->OwnerDoc()->GetShell()); - MOZ_ASSERT(!shell || shell == this, "wrong shell"); + PresShell* presShell = content->OwnerDoc()->GetPresShell(); + MOZ_ASSERT(!presShell || presShell == this, "wrong shell"); } #endif @@ -5869,8 +5869,8 @@ void PresShell::RemoveFrameFromApproximatelyVisibleList(nsIFrame* aFrame) { // Make sure it's in this pres shell. nsCOMPtr content = aFrame->GetContent(); if (content) { - PresShell* shell = static_cast(content->OwnerDoc()->GetShell()); - MOZ_ASSERT(!shell || shell == this, "wrong shell"); + PresShell* presShell = content->OwnerDoc()->GetPresShell(); + MOZ_ASSERT(!presShell || presShell == this, "wrong shell"); } #endif @@ -6376,9 +6376,9 @@ nsIFrame* PresShell::EventHandler::GetNearestFrameContainingPresShell( } static bool FlushThrottledStyles(Document* aDocument, void* aData) { - nsIPresShell* shell = aDocument->GetShell(); - if (shell && shell->IsVisible()) { - nsPresContext* presContext = shell->GetPresContext(); + PresShell* presShell = aDocument->GetPresShell(); + if (presShell && presShell->IsVisible()) { + nsPresContext* presContext = presShell->GetPresContext(); if (presContext) { presContext->RestyleManager()->UpdateOnlyAnimationStyles(); } @@ -6408,7 +6408,7 @@ PresShell* PresShell::GetShellForEventTarget(nsIFrame* aFrame, if (!doc) { return nullptr; } - return static_cast(doc->GetShell()); + return doc->GetPresShell(); } return nullptr; } @@ -6947,7 +6947,7 @@ bool PresShell::EventHandler::MaybeHandleEventWithAccessibleCaret( if (!retargetEventDoc) { return false; } - nsCOMPtr presShell = retargetEventDoc->GetShell(); + RefPtr presShell = retargetEventDoc->GetPresShell(); if (!presShell) { return false; } @@ -7074,7 +7074,7 @@ nsIFrame* PresShell::EventHandler::GetFrameForHandlingEventWith( MOZ_ASSERT(aGUIEvent); MOZ_ASSERT(aRetargetDocument); - nsCOMPtr retargetPresShell = aRetargetDocument->GetShell(); + RefPtr retargetPresShell = aRetargetDocument->GetPresShell(); // Even if the document doesn't have PresShell, i.e., it's invisible, we // need to dispatch only KeyboardEvent in its nearest visible document // because key focus shouldn't be caught by invisible document. @@ -7088,7 +7088,7 @@ nsIFrame* PresShell::EventHandler::GetFrameForHandlingEventWith( if (!retargetEventDoc) { return nullptr; } - retargetPresShell = retargetEventDoc->GetShell(); + retargetPresShell = retargetEventDoc->GetPresShell(); } } @@ -7552,8 +7552,7 @@ bool PresShell::EventHandler::MaybeHandleEventWithAnotherPresShell( return false; } - RefPtr eventTargetPresShell = - static_cast(eventTargetDocument->GetShell()); + RefPtr eventTargetPresShell = eventTargetDocument->GetPresShell(); if (!eventTargetPresShell) { *aRv = NS_OK; return true; // No PresShell can handle the event. @@ -8257,7 +8256,7 @@ void PresShell::EventHandler::DispatchTouchEventToDOM( RefPtr contentPresShell; if (doc == GetDocument()) { - contentPresShell = static_cast(doc->GetShell()); + contentPresShell = doc->GetPresShell(); if (contentPresShell) { // XXXsmaug huge hack. Pushing possibly capturing content, // even though event target is something else. @@ -8834,9 +8833,10 @@ static void FreezeElement(nsISupports* aSupports, void* /* unused */) { } static bool FreezeSubDocument(Document* aDocument, void* aData) { - nsIPresShell* shell = aDocument->GetShell(); - if (shell) shell->Freeze(); - + PresShell* presShell = aDocument->GetPresShell(); + if (presShell) { + presShell->Freeze(); + } return true; } @@ -8904,9 +8904,10 @@ static void ThawElement(nsISupports* aSupports, void* aShell) { } static bool ThawSubDocument(Document* aDocument, void* aData) { - nsIPresShell* shell = aDocument->GetShell(); - if (shell) shell->Thaw(); - + PresShell* presShell = aDocument->GetPresShell(); + if (presShell) { + presShell->Thaw(); + } return true; } @@ -9920,23 +9921,26 @@ bool nsIPresShell::VerifyIncrementalReflow() { // exact same style information that this document has. UniquePtr newSet = CloneStyleSet(StyleSet()); - nsCOMPtr sh = mDocument->CreateShell(cx, vm, std::move(newSet)); - NS_ENSURE_TRUE(sh, false); + RefPtr presShell = + mDocument->CreatePresShell(cx, vm, std::move(newSet)); + NS_ENSURE_TRUE(presShell, false); // Note that after we create the shell, we must make sure to destroy it - sh->SetVerifyReflowEnable(false); // turn off verify reflow while we're - // reflowing the test frame tree - vm->SetPresShell(sh); + presShell->SetVerifyReflowEnable( + false); // turn off verify reflow while we're + // reflowing the test frame tree + vm->SetPresShell(presShell); { nsAutoCauseReflowNotifier crNotifier(this); - sh->Initialize(); + presShell->Initialize(); } mDocument->BindingManager()->ProcessAttachedQueue(); - sh->FlushPendingNotifications(FlushType::Layout); - sh->SetVerifyReflowEnable(true); // turn on verify reflow again now that - // we're done reflowing the test frame tree + presShell->FlushPendingNotifications(FlushType::Layout); + presShell->SetVerifyReflowEnable( + true); // turn on verify reflow again now that + // we're done reflowing the test frame tree // Force the non-primary presshell to unsuppress; it doesn't want to normally // because it thinks it's hidden - ((PresShell*)sh.get())->mPaintingSuppressed = false; + presShell->mPaintingSuppressed = false; if (VERIFY_REFLOW_NOISY & gVerifyReflowFlags) { printf("Verification Tree built, comparing...\n"); } @@ -9944,7 +9948,7 @@ bool nsIPresShell::VerifyIncrementalReflow() { // Now that the document has been reflowed, use its frame tree to // compare against our frame tree. nsIFrame* root1 = mFrameConstructor->GetRootFrame(); - nsIFrame* root2 = sh->GetRootFrame(); + nsIFrame* root2 = presShell->GetRootFrame(); bool ok = CompareTrees(mPresContext, root1, cx, root2); if (!ok && (VERIFY_REFLOW_NOISY & gVerifyReflowFlags)) { printf("Verify reflow failed, primary tree:\n"); @@ -9962,18 +9966,18 @@ bool nsIPresShell::VerifyIncrementalReflow() { stra.AppendLiteral("C:\\mozilla\\mozilla\\debug\\filea"); stra.AppendInt(num); stra.AppendLiteral(".png"); - gfxUtils::WriteAsPNG(sh, stra); + gfxUtils::WriteAsPNG(presShell, stra); nsString strb; strb.AppendLiteral("C:\\mozilla\\mozilla\\debug\\fileb"); strb.AppendInt(num); strb.AppendLiteral(".png"); - gfxUtils::WriteAsPNG(sh, strb); + gfxUtils::WriteAsPNG(presShell, strb); ++num; } # endif - sh->EndObservingDocument(); - sh->Destroy(); + presShell->EndObservingDocument(); + presShell->Destroy(); if (VERIFY_REFLOW_NOISY & gVerifyReflowFlags) { printf("Finished Verifying Reflow...\n"); } @@ -10477,9 +10481,9 @@ void PresShell::QueryIsActive() { // Helper for propagating mIsActive changes to external resources static bool SetExternalResourceIsActive(Document* aDocument, void* aClosure) { - nsIPresShell* shell = aDocument->GetShell(); - if (shell) { - shell->SetIsActive(*static_cast(aClosure)); + PresShell* presShell = aDocument->GetPresShell(); + if (presShell) { + presShell->SetIsActive(*static_cast(aClosure)); } return true; } diff --git a/layout/base/PresShell.h b/layout/base/PresShell.h index 2e3279af005d6..9addba1a7ea7b 100644 --- a/layout/base/PresShell.h +++ b/layout/base/PresShell.h @@ -171,6 +171,14 @@ class PresShell final : public nsIPresShell, void SetRestoreResolution(float aResolution, LayoutDeviceIntSize aDisplaySize) override; + // Widget notificiations + void WindowSizeMoveDone() override; + void SysColorChanged() override { mPresContext->SysColorChanged(); } + void ThemeChanged() override { mPresContext->ThemeChanged(); } + void BackingScaleFactorChanged() override { + mPresContext->UIResolutionChangedSync(); + } + // nsIViewObserver interface void Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion, @@ -1284,13 +1292,6 @@ class PresShell final : public nsIPresShell, // The callback for the mPaintSuppressionTimer timer. static void sPaintSuppressionCallback(nsITimer* aTimer, void* aPresShell); - // Widget notificiations - void WindowSizeMoveDone() override; - void SysColorChanged() override { mPresContext->SysColorChanged(); } - void ThemeChanged() override { mPresContext->ThemeChanged(); } - void BackingScaleFactorChanged() override { - mPresContext->UIResolutionChangedSync(); - } Document* GetPrimaryContentDocument() override; void PausePainting() override; diff --git a/layout/base/TouchManager.cpp b/layout/base/TouchManager.cpp index e7250f44205ba..209489a64b686 100644 --- a/layout/base/TouchManager.cpp +++ b/layout/base/TouchManager.cpp @@ -61,7 +61,7 @@ void TouchManager::EvictTouchPoint(RefPtr& aTouch, if (node) { Document* doc = node->GetComposedDoc(); if (doc && (!aLimitToDocument || aLimitToDocument == doc)) { - nsIPresShell* presShell = doc->GetShell(); + PresShell* presShell = doc->GetPresShell(); if (presShell) { nsIFrame* frame = presShell->GetRootFrame(); if (frame) { diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 14598117b81dc..72bb0b274c459 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -7,6 +7,7 @@ /* container for a document and its presentation */ #include "gfxContext.h" +#include "mozilla/PresShell.h" #include "mozilla/RestyleManager.h" #include "mozilla/ServoStyleSet.h" #include "nscore.h" @@ -21,7 +22,6 @@ #include "mozilla/dom/PopupBlocker.h" #include "mozilla/dom/Document.h" #include "nsPresContext.h" -#include "nsIPresShell.h" #include "nsIFrame.h" #include "nsIWritablePropertyBag2.h" #include "nsSubDocumentFrame.h" @@ -402,7 +402,7 @@ class nsDocumentViewer final : public nsIContentViewer, nsCOMPtr mWindow; // may be null RefPtr mViewManager; RefPtr mPresContext; - nsCOMPtr mPresShell; + RefPtr mPresShell; RefPtr mSelectionListener; RefPtr mFocusListener; @@ -730,8 +730,8 @@ nsresult nsDocumentViewer::InitPresentationStuff(bool aDoInitialReflow) { UniquePtr styleSet = CreateStyleSet(mDocument); // Now make the shell for the document - mPresShell = - mDocument->CreateShell(mPresContext, mViewManager, std::move(styleSet)); + mPresShell = mDocument->CreatePresShell(mPresContext, mViewManager, + std::move(styleSet)); if (!mPresShell) { return NS_ERROR_FAILURE; } @@ -770,9 +770,9 @@ nsresult nsDocumentViewer::InitPresentationStuff(bool aDoInitialReflow) { p2a = mPresContext->AppUnitsPerDevPixel(); // zoom may have changed it if (aDoInitialReflow) { - nsCOMPtr shell = mPresShell; + RefPtr presShell = mPresShell; // Initial reflow - shell->Initialize(); + presShell->Initialize(); } // now register ourselves as a selection listener, so that we get @@ -880,7 +880,7 @@ nsresult nsDocumentViewer::InitInternal(nsIWidget* aParentWidget, if (!mPresContext && (aParentWidget || containerView || mDocument->IsBeingUsedAsImage() || (mDocument->GetDisplayDocument() && - mDocument->GetDisplayDocument()->GetShell()))) { + mDocument->GetDisplayDocument()->GetPresShell()))) { // Create presentation context if (mIsPageMode) { // Presentation context already created in SetPageMode which is calling @@ -1009,8 +1009,8 @@ nsDocumentViewer::LoadComplete(nsresult aStatus) { // checking for our mDocument and its window. if (mPresShell && !mStopped) { // Hold strong ref because this could conceivably run script - nsCOMPtr shell = mPresShell; - shell->FlushPendingNotifications(FlushType::Layout); + RefPtr presShell = mPresShell; + presShell->FlushPendingNotifications(FlushType::Layout); } nsresult rv = NS_OK; @@ -1144,8 +1144,8 @@ nsDocumentViewer::LoadComplete(nsresult aStatus) { // Now that the document has loaded, we can tell the presshell // to unsuppress painting. if (mPresShell) { - nsCOMPtr shell(mPresShell); - shell->UnsuppressPainting(); + RefPtr presShell = mPresShell; + presShell->UnsuppressPainting(); // mPresShell could have been removed now, see bug 378682/421432 if (mPresShell) { mPresShell->LoadComplete(); @@ -1867,8 +1867,8 @@ nsDocumentViewer::Stop(void) { if (!mLoaded && mPresShell) { // Well, we might as well paint what we have so far. - nsCOMPtr shell(mPresShell); // bug 378682 - shell->UnsuppressPainting(); + RefPtr presShell = mPresShell; // bug 378682 + presShell->UnsuppressPainting(); } return NS_OK; @@ -2192,8 +2192,8 @@ nsDocumentViewer::Show(void) { // shown... if (mPresShell) { - nsCOMPtr shell(mPresShell); // bug 378682 - shell->UnsuppressPainting(); + RefPtr presShell = mPresShell; // bug 378682 + presShell->UnsuppressPainting(); } } @@ -4270,7 +4270,7 @@ void nsDocumentViewer::SetPrintPreviewPresentation(nsViewManager* aViewManager, mWindow = nullptr; mViewManager = aViewManager; mPresContext = aPresContext; - mPresShell = aPresShell; + mPresShell = static_cast(aPresShell); if (ShouldAttachToTopLevel()) { DetachFromTopLevelWidget(); diff --git a/layout/base/nsIPresShellInlines.h b/layout/base/nsIPresShellInlines.h index c54175d912941..355780518a573 100644 --- a/layout/base/nsIPresShellInlines.h +++ b/layout/base/nsIPresShellInlines.h @@ -7,12 +7,13 @@ #ifndef nsIPresShellInlines_h #define nsIPresShellInlines_h +#include "mozilla/PresShell.h" #include "mozilla/dom/Document.h" void nsIPresShell::SetNeedLayoutFlush() { mNeedLayoutFlush = true; if (mozilla::dom::Document* doc = mDocument->GetDisplayDocument()) { - if (nsIPresShell* shell = doc->GetShell()) { + if (mozilla::PresShell* shell = doc->GetPresShell()) { shell->mNeedLayoutFlush = true; } } @@ -27,8 +28,8 @@ void nsIPresShell::SetNeedLayoutFlush() { void nsIPresShell::SetNeedStyleFlush() { mNeedStyleFlush = true; if (mozilla::dom::Document* doc = mDocument->GetDisplayDocument()) { - if (nsIPresShell* shell = doc->GetShell()) { - shell->mNeedStyleFlush = true; + if (mozilla::PresShell* presShell = doc->GetPresShell()) { + presShell->mNeedStyleFlush = true; } } @@ -47,8 +48,8 @@ void nsIPresShell::EnsureStyleFlush() { void nsIPresShell::SetNeedThrottledAnimationFlush() { mNeedThrottledAnimationFlush = true; if (mozilla::dom::Document* doc = mDocument->GetDisplayDocument()) { - if (nsIPresShell* shell = doc->GetShell()) { - shell->mNeedThrottledAnimationFlush = true; + if (mozilla::PresShell* presShell = doc->GetPresShell()) { + presShell->mNeedThrottledAnimationFlush = true; } } } diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 63149eba4eba8..fb137455ca1c7 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -20,6 +20,7 @@ #include "mozilla/Likely.h" #include "mozilla/Maybe.h" #include "mozilla/MemoryReporting.h" +#include "mozilla/PresShell.h" #include "mozilla/ServoStyleSetInlines.h" #include "mozilla/StaticPrefs.h" #include "mozilla/Unused.h" @@ -597,7 +598,7 @@ static nsIFrame* GetScrollFrameFromContent(nsIContent* aContent) { if (aContent->OwnerDoc()->GetRootElement() == aContent) { nsIPresShell* presShell = frame ? frame->PresShell() : nullptr; if (!presShell) { - presShell = aContent->OwnerDoc()->GetShell(); + presShell = aContent->OwnerDoc()->GetPresShell(); } // We want the scroll frame, the root scroll frame differs from all // others in that the primary frame is not the scroll frame. @@ -9357,7 +9358,7 @@ CSSRect nsLayoutUtils::GetBoundingContentRect( static already_AddRefed GetPresShell(const nsIContent* aContent) { nsCOMPtr result; if (Document* doc = aContent->GetComposedDoc()) { - result = doc->GetShell(); + result = doc->GetPresShell(); } return result.forget(); } diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 6ebe08850e027..b2ea3a4bd7860 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -14,12 +14,12 @@ #include "mozilla/Encoding.h" #include "mozilla/EventDispatcher.h" #include "mozilla/EventStateManager.h" +#include "mozilla/PresShell.h" #include "base/basictypes.h" #include "nsCOMPtr.h" #include "nsCSSFrameConstructor.h" -#include "nsIPresShell.h" #include "nsIPresShellInlines.h" #include "nsDocShell.h" #include "nsIContentViewer.h" @@ -616,9 +616,10 @@ nsresult nsPresContext::Init(nsDeviceContext* aDeviceContext) { // printing screws up things. Assert that in other cases it does, // but whenever the shell is null just fall back on using our own // refresh driver. - NS_ASSERTION(!parent || mDocument->IsStaticDocument() || parent->GetShell(), - "How did we end up with a presshell if our parent doesn't " - "have one?"); + NS_ASSERTION( + !parent || mDocument->IsStaticDocument() || parent->GetPresShell(), + "How did we end up with a presshell if our parent doesn't " + "have one?"); if (parent && parent->GetPresContext()) { nsCOMPtr ourItem = mDocument->GetDocShell(); if (ourItem) { diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 4a9daa0085e7f..a3baa195a84a0 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -21,6 +21,7 @@ #include "mozilla/gfx/2D.h" #include "mozilla/gfx/gfxVars.h" #include "mozilla/gfx/PathHelpers.h" +#include "mozilla/PresShell.h" #include "mozilla/Sprintf.h" #include "mozilla/StaticPrefs.h" @@ -47,7 +48,6 @@ #include "nsPresContext.h" #include "nsPresContextInlines.h" #include "nsStyleConsts.h" -#include "nsIPresShell.h" #include "mozilla/Logging.h" #include "nsLayoutUtils.h" #include "LayoutLogging.h" @@ -4701,9 +4701,11 @@ NS_IMETHODIMP nsFrame::HandleRelease(nsPresContext* aPresContext, if (!frameSelection && captureContent) { Document* doc = captureContent->GetUncomposedDoc(); if (doc) { - nsIPresShell* capturingShell = doc->GetShell(); - if (capturingShell && capturingShell != PresContext()->GetPresShell()) { - frameSelection = capturingShell->FrameSelection(); + mozilla::PresShell* capturingPresShell = doc->GetPresShell(); + if (capturingPresShell && + capturingPresShell != + static_cast(PresContext()->GetPresShell())) { + frameSelection = capturingPresShell->FrameSelection(); } } } diff --git a/layout/generic/nsSubDocumentFrame.cpp b/layout/generic/nsSubDocumentFrame.cpp index ab783d41f2148..8ef8e3481242b 100644 --- a/layout/generic/nsSubDocumentFrame.cpp +++ b/layout/generic/nsSubDocumentFrame.cpp @@ -13,6 +13,10 @@ #include "gfxPrefs.h" +#include "mozilla/Preferences.h" +#include "mozilla/PresShell.h" +#include "mozilla/dom/Document.h" +#include "mozilla/dom/HTMLFrameElement.h" #include "mozilla/layout/RenderFrame.h" #include "nsCOMPtr.h" @@ -23,8 +27,6 @@ #include "nsIContentViewer.h" #include "nsIContentInlines.h" #include "nsPresContext.h" -#include "nsIPresShell.h" -#include "mozilla/dom/Document.h" #include "nsView.h" #include "nsViewManager.h" #include "nsGkAtoms.h" @@ -42,8 +44,6 @@ #include "nsIPermissionManager.h" #include "nsServiceManagerUtils.h" #include "nsQueryObject.h" -#include "mozilla/Preferences.h" -#include "mozilla/dom/HTMLFrameElement.h" #include "RetainedDisplayListBuilder.h" using namespace mozilla; @@ -1024,12 +1024,12 @@ static void DestroyDisplayItemDataForFrames(nsIFrame* aFrame) { static bool BeginSwapDocShellsForDocument(Document* aDocument, void*) { MOZ_ASSERT(aDocument, "null document"); - nsIPresShell* shell = aDocument->GetShell(); - if (shell) { + PresShell* presShell = aDocument->GetPresShell(); + if (presShell) { // Disable painting while the views are detached, see bug 946929. - shell->SetNeverPainting(true); + presShell->SetNeverPainting(true); - nsIFrame* rootFrame = shell->GetRootFrame(); + nsIFrame* rootFrame = presShell->GetRootFrame(); if (rootFrame) { ::DestroyDisplayItemDataForFrames(rootFrame); } diff --git a/layout/inspector/InspectorUtils.cpp b/layout/inspector/InspectorUtils.cpp index d8aa7aeedcaec..36b7d4183e31b 100644 --- a/layout/inspector/InspectorUtils.cpp +++ b/layout/inspector/InspectorUtils.cpp @@ -17,7 +17,6 @@ #include "nsIStyleSheetLinkingElement.h" #include "nsIContentInlines.h" #include "mozilla/dom/Document.h" -#include "nsIPresShell.h" #include "nsIDOMWindow.h" #include "nsXBLBinding.h" #include "nsXBLPrototypeBinding.h" @@ -28,6 +27,7 @@ #include "mozilla/EventStateManager.h" #include "nsAtom.h" #include "nsRange.h" +#include "mozilla/PresShell.h" #include "mozilla/StyleSheetInlines.h" #include "mozilla/dom/CharacterData.h" #include "mozilla/dom/Element.h" @@ -58,7 +58,7 @@ void InspectorUtils::GetAllStyleSheets(GlobalObject& aGlobalObject, Document& aDocument, bool aDocumentOnly, nsTArray>& aResult) { // Get the agent, then user and finally xbl sheets in the style set. - nsIPresShell* presShell = aDocument.GetShell(); + PresShell* presShell = aDocument.GetPresShell(); if (presShell) { ServoStyleSet* styleSet = presShell->StyleSet(); @@ -168,8 +168,8 @@ void InspectorUtils::GetCSSStyleRules( } Document* doc = aElement.OwnerDoc(); - nsIPresShell* shell = doc->GetShell(); - if (!shell) { + PresShell* presShell = doc->GetPresShell(); + if (!presShell) { return; } @@ -178,7 +178,7 @@ void InspectorUtils::GetCSSStyleRules( AutoTArray maps; { - ServoStyleSet* styleSet = shell->StyleSet(); + ServoStyleSet* styleSet = presShell->StyleSet(); ServoStyleRuleMap* map = styleSet->StyleRuleMap(); maps.AppendElement(map); } @@ -598,7 +598,7 @@ already_AddRefed InspectorUtils::GetCleanComputedStyleForElement( return nullptr; } - nsIPresShell* presShell = doc->GetShell(); + PresShell* presShell = doc->GetPresShell(); if (!presShell) { return nullptr; } diff --git a/layout/painting/RetainedDisplayListBuilder.cpp b/layout/painting/RetainedDisplayListBuilder.cpp index fa7ee063d9050..01be1282281bf 100644 --- a/layout/painting/RetainedDisplayListBuilder.cpp +++ b/layout/painting/RetainedDisplayListBuilder.cpp @@ -14,6 +14,7 @@ #include "nsViewManager.h" #include "nsCanvasFrame.h" #include "mozilla/AutoRestore.h" +#include "mozilla/PresShell.h" /** * Code for doing display list building for a modified subset of the window, @@ -724,7 +725,7 @@ static nsIFrame* GetRootFrameForPainting(nsDisplayListBuilder* aBuilder, // what painting uses. Walk up to the nsSubDocumentFrame owning // us, and then ask that which subdoc it's going to paint. - nsIPresShell* presShell = aDocument->GetShell(); + PresShell* presShell = aDocument->GetPresShell(); if (!presShell) { return nullptr; } @@ -752,10 +753,11 @@ static nsIFrame* GetRootFrameForPainting(nsDisplayListBuilder* aBuilder, nsSubDocumentFrame* subdocumentFrame = do_QueryFrame(subDocFrame); MOZ_ASSERT(subdocumentFrame); - presShell = subdocumentFrame->GetSubdocumentPresShellForPainting( - aBuilder->IsIgnoringPaintSuppression() - ? nsSubDocumentFrame::IGNORE_PAINT_SUPPRESSION - : 0); + presShell = static_cast( + subdocumentFrame->GetSubdocumentPresShellForPainting( + aBuilder->IsIgnoringPaintSuppression() + ? nsSubDocumentFrame::IGNORE_PAINT_SUPPRESSION + : 0)); return presShell ? presShell->GetRootFrame() : nullptr; } diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index 1255ba0831478..1e7cabe8239af 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -28,11 +28,11 @@ #include "mozilla/dom/TouchEvent.h" #include "mozilla/gfx/2D.h" #include "mozilla/layers/PLayerTransaction.h" +#include "mozilla/PresShell.h" #include "mozilla/ShapeUtils.h" #include "nsCSSRendering.h" #include "nsCSSRenderingGradients.h" #include "nsISelectionController.h" -#include "nsIPresShell.h" #include "nsRegion.h" #include "nsStyleStructInlines.h" #include "nsStyleTransformMatrix.h" @@ -2541,10 +2541,10 @@ static bool TriggerPendingAnimationsOnSubDocuments(Document* aDocument, void* aReadyTime) { PendingAnimationTracker* tracker = aDocument->GetPendingAnimationTracker(); if (tracker) { - nsIPresShell* shell = aDocument->GetShell(); + PresShell* presShell = aDocument->GetPresShell(); // If paint-suppression is in effect then we haven't finished painting // this document yet so we shouldn't start animations - if (!shell || !shell->IsPaintingSuppressed()) { + if (!presShell || !presShell->IsPaintingSuppressed()) { const TimeStamp& readyTime = *static_cast(aReadyTime); tracker->TriggerPendingAnimationsOnNextTick(readyTime); } diff --git a/layout/printing/nsPrintJob.cpp b/layout/printing/nsPrintJob.cpp index fe4379a63d0e9..d9f6d11e46d79 100644 --- a/layout/printing/nsPrintJob.cpp +++ b/layout/printing/nsPrintJob.cpp @@ -83,10 +83,10 @@ static const char kPrintingPromptService[] = #include "nsContentCID.h" #include "nsLayoutCID.h" #include "nsContentUtils.h" -#include "nsIPresShell.h" #include "nsLayoutStylesheetCache.h" #include "nsLayoutUtils.h" #include "mozilla/Preferences.h" +#include "mozilla/PresShell.h" #include "Text.h" #include "nsWidgetsCID.h" @@ -2238,7 +2238,7 @@ nsresult nsPrintJob::ReflowPrintObject(const UniquePtr& aPO) { UniquePtr styleSet = mDocViewerPrint->CreateStyleSet(aPO->mDocument); - aPO->mPresShell = aPO->mDocument->CreateShell( + aPO->mPresShell = aPO->mDocument->CreatePresShell( aPO->mPresContext, aPO->mViewManager, std::move(styleSet)); if (!aPO->mPresShell) { return NS_ERROR_FAILURE; @@ -2426,14 +2426,14 @@ static nsINode* GetCorrespondingNodeInDocument(const nsINode* aNode, static NS_NAMED_LITERAL_STRING(kEllipsis, u"\x2026"); static nsresult DeleteUnselectedNodes(Document* aOrigDoc, Document* aDoc) { - nsIPresShell* origShell = aOrigDoc->GetShell(); - nsIPresShell* shell = aDoc->GetShell(); - NS_ENSURE_STATE(origShell && shell); + PresShell* origPresShell = aOrigDoc->GetPresShell(); + PresShell* presShell = aDoc->GetPresShell(); + NS_ENSURE_STATE(origPresShell && presShell); RefPtr origSelection = - origShell->GetCurrentSelection(SelectionType::eNormal); + origPresShell->GetCurrentSelection(SelectionType::eNormal); RefPtr selection = - shell->GetCurrentSelection(SelectionType::eNormal); + presShell->GetCurrentSelection(SelectionType::eNormal); NS_ENSURE_STATE(origSelection && selection); nsINode* bodyNode = aDoc->GetBodyElement(); diff --git a/layout/style/FontFaceSet.cpp b/layout/style/FontFaceSet.cpp index 1b8e64aa385f0..f19746af2d1cd 100644 --- a/layout/style/FontFaceSet.cpp +++ b/layout/style/FontFaceSet.cpp @@ -22,6 +22,7 @@ #include "mozilla/AsyncEventDispatcher.h" #include "mozilla/Logging.h" #include "mozilla/Preferences.h" +#include "mozilla/PresShell.h" #include "mozilla/ServoBindings.h" #include "mozilla/ServoCSSParser.h" #include "mozilla/ServoStyleSet.h" @@ -42,7 +43,6 @@ #include "mozilla/dom/Document.h" #include "nsILoadContext.h" #include "nsINetworkPredictor.h" -#include "nsIPresShell.h" #include "nsIPresShellInlines.h" #include "nsIPrincipal.h" #include "nsISupportsPriority.h" @@ -1709,8 +1709,8 @@ void FontFaceSet::MarkUserFontSetDirty() { // Ensure we trigger at least a style flush, that will eventually flush the // user font set. Otherwise the font loads that that flush may cause could // never be triggered. - if (nsIPresShell* shell = mDocument->GetShell()) { - shell->EnsureStyleFlush(); + if (PresShell* presShell = mDocument->GetPresShell()) { + presShell->EnsureStyleFlush(); } mDocument->MarkUserFontSetDirty(); } diff --git a/layout/style/ServoStyleSet.cpp b/layout/style/ServoStyleSet.cpp index aa9f577f737cf..4f4157a6f4b4f 100644 --- a/layout/style/ServoStyleSet.cpp +++ b/layout/style/ServoStyleSet.cpp @@ -13,6 +13,7 @@ #include "mozilla/EffectCompositor.h" #include "mozilla/IntegerRange.h" #include "mozilla/LookAndFeel.h" +#include "mozilla/PresShell.h" #include "mozilla/ServoBindings.h" #include "mozilla/RestyleManager.h" #include "mozilla/ServoStyleRuleMap.h" @@ -1346,8 +1347,8 @@ bool ServoStyleSet::MayTraverseFrom(const Element* aElement) { } bool ServoStyleSet::ShouldTraverseInParallel() const { - MOZ_ASSERT(mDocument->GetShell(), "Styling a document without a shell?"); - if (!mDocument->GetShell()->IsActive()) { + MOZ_ASSERT(mDocument->GetPresShell(), "Styling a document without a shell?"); + if (!mDocument->GetPresShell()->IsActive()) { return false; } #ifdef MOZ_GECKO_PROFILER diff --git a/layout/style/StyleAnimationValue.cpp b/layout/style/StyleAnimationValue.cpp index 0c3b4be3b052d..14f30f5301a95 100644 --- a/layout/style/StyleAnimationValue.cpp +++ b/layout/style/StyleAnimationValue.cpp @@ -10,6 +10,7 @@ #include "mozilla/ArrayUtils.h" #include "mozilla/MathAlgorithms.h" +#include "mozilla/PresShell.h" #include "mozilla/ServoStyleSet.h" #include "mozilla/Tuple.h" #include "mozilla/UniquePtr.h" @@ -316,8 +317,8 @@ AnimationValue AnimationValue::FromString(nsCSSPropertyID aProperty, return result; } - nsCOMPtr shell = doc->GetShell(); - if (!shell) { + RefPtr presShell = doc->GetPresShell(); + if (!presShell) { return result; } @@ -334,7 +335,7 @@ AnimationValue AnimationValue::FromString(nsCSSPropertyID aProperty, return result; } - result.mServo = shell->StyleSet()->ComputeAnimationValue( + result.mServo = presShell->StyleSet()->ComputeAnimationValue( aElement, declarations, computedStyle); return result; } diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 62a6117f00eb0..12348b1836603 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -12,6 +12,7 @@ #include "mozilla/FloatingPoint.h" #include "mozilla/FontPropertyTypes.h" #include "mozilla/Preferences.h" +#include "mozilla/PresShell.h" #include "mozilla/StaticPtr.h" #include "nsError.h" @@ -99,17 +100,17 @@ already_AddRefed GetBackgroundList( // Whether aDocument needs to restyle for aElement static bool DocumentNeedsRestyle(const Document* aDocument, Element* aElement, nsAtom* aPseudo) { - nsIPresShell* shell = aDocument->GetShell(); - if (!shell) { + PresShell* presShell = aDocument->GetPresShell(); + if (!presShell) { return true; } - nsPresContext* presContext = shell->GetPresContext(); + nsPresContext* presContext = presShell->GetPresContext(); MOZ_ASSERT(presContext); // Unfortunately we don't know if the sheet change affects mElement or not, so // just assume it will and that we need to flush normally. - ServoStyleSet* styleSet = shell->StyleSet(); + ServoStyleSet* styleSet = presShell->StyleSet(); if (styleSet->StyleSheetsHaveChanged()) { return true; } @@ -570,8 +571,9 @@ nsComputedDOMStyle::GetUnanimatedComputedStyleNoFlush(Element* aElement, } PseudoStyleType pseudoType = GetPseudoType(aPseudo); - nsIPresShell* shell = aElement->OwnerDoc()->GetShell(); - MOZ_ASSERT(shell, "How in the world did we get a style a few lines above?"); + PresShell* presShell = aElement->OwnerDoc()->GetPresShell(); + MOZ_ASSERT(presShell, + "How in the world did we get a style a few lines above?"); Element* elementOrPseudoElement = EffectCompositor::GetElementToRestyle(aElement, pseudoType); @@ -579,8 +581,8 @@ nsComputedDOMStyle::GetUnanimatedComputedStyleNoFlush(Element* aElement, return nullptr; } - return shell->StyleSet()->GetBaseContextForElement(elementOrPseudoElement, - style); + return presShell->StyleSet()->GetBaseContextForElement(elementOrPseudoElement, + style); } nsMargin nsComputedDOMStyle::GetAdjustedValuesForBoxSizing() { @@ -827,7 +829,7 @@ void nsComputedDOMStyle::UpdateCurrentStyleSources(bool aNeedsLayoutFlush) { } } - mPresShell = document->GetShell(); + mPresShell = document->GetPresShell(); if (!mPresShell || !mPresShell->GetPresContext()) { ClearComputedStyle(); return; diff --git a/layout/style/nsHTMLStyleSheet.cpp b/layout/style/nsHTMLStyleSheet.cpp index f7317905ce55c..7807f4cf036e4 100644 --- a/layout/style/nsHTMLStyleSheet.cpp +++ b/layout/style/nsHTMLStyleSheet.cpp @@ -14,9 +14,9 @@ #include "nsGkAtoms.h" #include "nsPresContext.h" #include "mozilla/EventStates.h" +#include "mozilla/PresShell.h" #include "mozilla/dom/Document.h" #include "mozilla/dom/DocumentInlines.h" -#include "nsIPresShell.h" #include "nsStyleConsts.h" #include "nsError.h" #include "mozilla/MemoryReporting.h" @@ -91,7 +91,7 @@ void nsHTMLStyleSheet::Reset() { nsresult nsHTMLStyleSheet::ImplLinkColorSetter( RefPtr &aDecl, nscolor aColor) { - if (!mDocument || !mDocument->GetShell()) { + if (!mDocument || !mDocument->GetPresShell()) { return NS_OK; } diff --git a/layout/xul/BoxObject.cpp b/layout/xul/BoxObject.cpp index 2670776a2dffc..464fe5423371b 100644 --- a/layout/xul/BoxObject.cpp +++ b/layout/xul/BoxObject.cpp @@ -6,8 +6,8 @@ #include "mozilla/dom/BoxObject.h" #include "nsCOMPtr.h" +#include "mozilla/PresShell.h" #include "mozilla/dom/Document.h" -#include "nsIPresShell.h" #include "nsPresContext.h" #include "nsIContent.h" #include "nsContainerFrame.h" @@ -116,7 +116,7 @@ nsIPresShell* BoxObject::GetPresShell(bool aFlushLayout) { doc->FlushPendingNotifications(FlushType::Layout); } - return doc->GetShell(); + return doc->GetPresShell(); } nsresult BoxObject::GetOffsetRect(nsIntRect& aRect) { diff --git a/layout/xul/nsXULPopupManager.cpp b/layout/xul/nsXULPopupManager.cpp index a85f9fabfa6b2..c2ee9aeedf095 100644 --- a/layout/xul/nsXULPopupManager.cpp +++ b/layout/xul/nsXULPopupManager.cpp @@ -43,6 +43,7 @@ #include "mozilla/EventStateManager.h" #include "mozilla/LookAndFeel.h" #include "mozilla/MouseEvents.h" +#include "mozilla/PresShell.h" #include "mozilla/Services.h" #include "mozilla/widget/nsAutoRollup.h" @@ -538,8 +539,10 @@ nsMenuPopupFrame* nsXULPopupManager::GetPopupFrameForContent( if (aShouldFlush) { Document* document = aContent->GetUncomposedDoc(); if (document) { - nsCOMPtr presShell = document->GetShell(); - if (presShell) presShell->FlushPendingNotifications(FlushType::Layout); + RefPtr presShell = document->GetPresShell(); + if (presShell) { + presShell->FlushPendingNotifications(FlushType::Layout); + } } } @@ -594,7 +597,7 @@ void nsXULPopupManager::InitTriggerEvent(Event* aEvent, nsIContent* aPopup, } Document* doc = aPopup->GetUncomposedDoc(); if (doc) { - nsIPresShell* presShell = doc->GetShell(); + PresShell* presShell = doc->GetPresShell(); nsPresContext* presContext; if (presShell && (presContext = presShell->GetPresContext())) { nsPresContext* rootDocPresContext = presContext->GetRootPresContext(); @@ -784,8 +787,10 @@ static void CheckCaretDrawingState() { nsCOMPtr focusedDoc = piWindow->GetDoc(); if (!focusedDoc) return; - nsIPresShell* presShell = focusedDoc->GetShell(); - if (!presShell) return; + PresShell* presShell = focusedDoc->GetPresShell(); + if (!presShell) { + return; + } RefPtr caret = presShell->GetCaret(); if (!caret) return; diff --git a/layout/xul/nsXULTooltipListener.cpp b/layout/xul/nsXULTooltipListener.cpp index 6b325cd1ce4ab..b0b029b53aeb3 100644 --- a/layout/xul/nsXULTooltipListener.cpp +++ b/layout/xul/nsXULTooltipListener.cpp @@ -25,8 +25,9 @@ #include "nsTreeColumns.h" #include "nsContentUtils.h" #include "mozilla/ErrorResult.h" -#include "mozilla/Preferences.h" #include "mozilla/LookAndFeel.h" +#include "mozilla/Preferences.h" +#include "mozilla/PresShell.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/Event.h" // for Event #include "mozilla/dom/MouseEvent.h" @@ -524,7 +525,7 @@ nsresult nsXULTooltipListener::FindTooltip(nsIContent* aTarget, // non-XUL elements should just use the default tooltip if (!aTarget->IsXULElement()) { nsIPopupContainer* popupContainer = - nsIPopupContainer::GetPopupContainer(document->GetShell()); + nsIPopupContainer::GetPopupContainer(document->GetPresShell()); NS_ENSURE_STATE(popupContainer); if (RefPtr tooltip = popupContainer->GetDefaultTooltip()) { tooltip.forget(aTooltip); @@ -541,7 +542,7 @@ nsresult nsXULTooltipListener::FindTooltip(nsIContent* aTarget, if (!tooltipText.IsEmpty()) { // specifying tooltiptext means we will always use the default tooltip nsIPopupContainer* popupContainer = - nsIPopupContainer::GetPopupContainer(document->GetShell()); + nsIPopupContainer::GetPopupContainer(document->GetPresShell()); NS_ENSURE_STATE(popupContainer); if (RefPtr tooltip = popupContainer->GetDefaultTooltip()) { tooltip->SetAttr(kNameSpaceID_None, nsGkAtoms::label, tooltipText, true); @@ -584,7 +585,7 @@ nsresult nsXULTooltipListener::FindTooltip(nsIContent* aTarget, // titletips should just use the default tooltip if (mIsSourceTree && mNeedTitletip) { nsIPopupContainer* popupContainer = - nsIPopupContainer::GetPopupContainer(document->GetShell()); + nsIPopupContainer::GetPopupContainer(document->GetPresShell()); NS_ENSURE_STATE(popupContainer); NS_IF_ADDREF(*aTooltip = popupContainer->GetDefaultTooltip()); } diff --git a/servo/components/style/gecko/media_queries.rs b/servo/components/style/gecko/media_queries.rs index 4c04d9573e56c..b39e748ce2b2e 100644 --- a/servo/components/style/gecko/media_queries.rs +++ b/servo/components/style/gecko/media_queries.rs @@ -169,6 +169,7 @@ impl Device { self.document() .mPresShell .as_ref()? + ._base .mPresContext .mRawPtr .as_ref() diff --git a/toolkit/components/find/nsWebBrowserFind.cpp b/toolkit/components/find/nsWebBrowserFind.cpp index 2dae59a193cdc..4bb8841755bcb 100644 --- a/toolkit/components/find/nsWebBrowserFind.cpp +++ b/toolkit/components/find/nsWebBrowserFind.cpp @@ -17,7 +17,6 @@ #include "nsPIDOMWindow.h" #include "nsIURI.h" #include "nsIDocShell.h" -#include "nsIPresShell.h" #include "nsPresContext.h" #include "mozilla/dom/Document.h" #include "nsISelectionController.h" @@ -33,6 +32,7 @@ #include "nsError.h" #include "nsFocusManager.h" #include "nsRange.h" +#include "mozilla/PresShell.h" #include "mozilla/Services.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/Selection.h" @@ -324,7 +324,7 @@ void nsWebBrowserFind::SetSelectionAndScroll(nsPIDOMWindowOuter* aWindow, return; } - nsIPresShell* presShell = doc->GetShell(); + PresShell* presShell = doc->GetPresShell(); if (!presShell) { return; } @@ -707,7 +707,7 @@ already_AddRefed nsWebBrowserFind::GetFrameSelection( return nullptr; } - nsIPresShell* presShell = doc->GetShell(); + PresShell* presShell = doc->GetPresShell(); if (!presShell) { return nullptr; } @@ -734,8 +734,7 @@ already_AddRefed nsWebBrowserFind::GetFrameSelection( } } - selCon = do_QueryInterface(presShell); - sel = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL); + sel = presShell->GetSelection(nsISelectionController::SELECTION_NORMAL); return sel.forget(); } diff --git a/toolkit/components/sessionstore/SessionStoreUtils.cpp b/toolkit/components/sessionstore/SessionStoreUtils.cpp index 409943f911436..8b9d45fab52a4 100644 --- a/toolkit/components/sessionstore/SessionStoreUtils.cpp +++ b/toolkit/components/sessionstore/SessionStoreUtils.cpp @@ -262,7 +262,7 @@ void SessionStoreUtils::RestoreDocShellCapabilities( static void CollectCurrentScrollPosition(JSContext* aCx, Document& aDocument, Nullable& aRetVal) { - nsIPresShell* presShell = aDocument.GetShell(); + PresShell* presShell = aDocument.GetPresShell(); if (!presShell) { return; } diff --git a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp index 337ba6e1a1318..c2ab1c30480e8 100644 --- a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp +++ b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp @@ -8,6 +8,7 @@ #include "nsIServiceManager.h" #include "mozilla/ErrorResult.h" #include "mozilla/ModuleUtils.h" +#include "mozilla/PresShell.h" #include "mozilla/Services.h" #include "nsIWebBrowserChrome.h" #include "nsCURILoader.h" @@ -1132,7 +1133,7 @@ nsTypeAheadFind::IsRangeVisible(nsRange* aRange, bool aMustBeInViewPort, nsCOMPtr node = aRange->GetStartContainer(); Document* doc = node->OwnerDoc(); - nsCOMPtr presShell = doc->GetShell(); + RefPtr presShell = doc->GetPresShell(); if (!presShell) { return NS_ERROR_UNEXPECTED; } @@ -1318,7 +1319,7 @@ NS_IMETHODIMP nsTypeAheadFind::IsRangeRendered(nsRange* aRange, bool* aResult) { nsINode* node = aRange->GetStartContainer(); - nsCOMPtr presShell = node->OwnerDoc()->GetShell(); + RefPtr presShell = node->OwnerDoc()->GetPresShell(); if (!presShell) { return NS_ERROR_UNEXPECTED; } diff --git a/uriloader/base/nsDocLoader.cpp b/uriloader/base/nsDocLoader.cpp index 4533cf92d073e..1158dfc24b5ca 100644 --- a/uriloader/base/nsDocLoader.cpp +++ b/uriloader/base/nsDocLoader.cpp @@ -759,12 +759,12 @@ void nsDocLoader::DocLoaderIsEmpty(bool aFlushLayout) { // Now unsuppress painting on the presshell, if we // haven't done that yet. - nsCOMPtr shell = doc->GetShell(); - if (shell && !shell->IsDestroying()) { - shell->UnsuppressPainting(); + RefPtr presShell = doc->GetPresShell(); + if (presShell && !presShell->IsDestroying()) { + presShell->UnsuppressPainting(); - if (!shell->IsDestroying()) { - shell->LoadComplete(); + if (!presShell->IsDestroying()) { + presShell->LoadComplete(); } } } diff --git a/widget/android/GeckoSystemStateListener.h b/widget/android/GeckoSystemStateListener.h index b127518f0fc13..2e100bdeee29d 100644 --- a/widget/android/GeckoSystemStateListener.h +++ b/widget/android/GeckoSystemStateListener.h @@ -7,11 +7,11 @@ #define GeckoSystemStateListener_h #include "GeneratedJNINatives.h" +#include "mozilla/Assertions.h" +#include "mozilla/PresShell.h" #include "mozilla/dom/Document.h" -#include "nsIPresShell.h" #include "nsIWindowMediator.h" #include "nsPIDOMWindow.h" -#include "mozilla/Assertions.h" namespace mozilla { @@ -44,7 +44,7 @@ class GeckoSystemStateListener final continue; } if (dom::Document* doc = window->GetExtantDoc()) { - if (nsIPresShell* presShell = doc->GetShell()) { + if (PresShell* presShell = doc->GetPresShell()) { presShell->ThemeChanged(); } } diff --git a/widget/cocoa/nsDragService.mm b/widget/cocoa/nsDragService.mm index 53d929431a54e..70468344810ea 100644 --- a/widget/cocoa/nsDragService.mm +++ b/widget/cocoa/nsDragService.mm @@ -23,7 +23,9 @@ #include "nsRect.h" #include "nsPoint.h" #include "nsIIOService.h" +#include "mozilla/PresShell.h" #include "mozilla/dom/Document.h" +#include "mozilla/dom/DocumentInlines.h" #include "nsIContent.h" #include "nsView.h" #include "nsCocoaUtils.h" @@ -603,11 +605,7 @@ nsPresContext* pc = nullptr; nsCOMPtr content = do_QueryInterface(mImage); if (content) { - RefPtr document = content->OwnerDoc(); - if (document) { - nsIPresShell* shell = document->GetShell(); - pc = shell ? shell->GetPresContext() : nullptr; - } + pc = content->OwnerDoc()->GetPresContext(); } if (pc) { diff --git a/widget/gtk/nsDragService.cpp b/widget/gtk/nsDragService.cpp index 0f7ef96b90fb1..3ab8b1d75e786 100644 --- a/widget/gtk/nsDragService.cpp +++ b/widget/gtk/nsDragService.cpp @@ -28,6 +28,7 @@ #include "mozilla/BasicEvents.h" #include "mozilla/Services.h" #include "mozilla/ClearOnShutdown.h" +#include "mozilla/PresShell.h" #include "gfxXlibSurface.h" #include "gfxContext.h" @@ -261,8 +262,10 @@ static void OnSourceGrabEventAfter(GtkWidget *widget, GdkEvent *event, static GtkWindow *GetGtkWindow(dom::Document *aDocument) { if (!aDocument) return nullptr; - nsCOMPtr presShell = aDocument->GetShell(); - if (!presShell) return nullptr; + PresShell *presShell = aDocument->GetPresShell(); + if (!presShell) { + return nullptr; + } RefPtr vm = presShell->GetViewManager(); if (!vm) return nullptr; diff --git a/widget/nsBaseDragService.cpp b/widget/nsBaseDragService.cpp index 62c695174a65e..6e1edf5f869b4 100644 --- a/widget/nsBaseDragService.cpp +++ b/widget/nsBaseDragService.cpp @@ -18,7 +18,6 @@ #include "nsFrameLoaderOwner.h" #include "mozilla/dom/Document.h" #include "nsIContent.h" -#include "nsIPresShell.h" #include "nsViewManager.h" #include "nsINode.h" #include "nsPresContext.h" @@ -36,6 +35,7 @@ #endif #include "mozilla/MouseEvents.h" #include "mozilla/Preferences.h" +#include "mozilla/PresShell.h" #include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/DataTransferItemList.h" #include "mozilla/dom/DataTransfer.h" @@ -458,7 +458,7 @@ NS_IMETHODIMP nsBaseDragService::FireDragEventAtSource(EventMessage aEventMessage, uint32_t aKeyModifiers) { if (mSourceNode && mSourceDocument && !mSuppressLevel) { - nsCOMPtr presShell = mSourceDocument->GetShell(); + RefPtr presShell = mSourceDocument->GetPresShell(); if (presShell) { nsEventStatus status = nsEventStatus_eIgnore; WidgetDragEvent event(true, aEventMessage, nullptr); @@ -511,7 +511,7 @@ static nsIPresShell* GetPresShellForContent(nsINode* aDOMNode) { RefPtr document = content->GetComposedDoc(); if (document) { document->FlushPendingNotifications(FlushType::Display); - return document->GetShell(); + return document->GetPresShell(); } return nullptr;