Bug 1542506 - Make nsDocShell use mozilla::PresShell* directly rather than nsIPresShell* r=bzbarsky

This patch makes `nsDocShell::GetPresShell()` and
`nsDocShell::GetEldestPresShell()` return `mozilla::PresShell*` and
some non-public methods use `mozilla::PresShell*` directly.

Differential Revision: https://phabricator.services.mozilla.com/D26424

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Masayuki Nakano 2019-04-13 01:03:13 +00:00
parent a7d5749be6
commit 0986fb819b
31 changed files with 259 additions and 270 deletions

View File

@ -339,8 +339,8 @@ void nsAccessibilityService::FireAccessibleEvent(uint32_t aEvent,
}
Accessible* nsAccessibilityService::GetRootDocumentAccessible(
nsIPresShell* aPresShell, bool aCanCreate) {
nsIPresShell* ps = aPresShell;
PresShell* aPresShell, bool aCanCreate) {
PresShell* presShell = aPresShell;
Document* documentNode = aPresShell->GetDocument();
if (documentNode) {
nsCOMPtr<nsIDocShellTreeItem> treeItem(documentNode->GetDocShell());
@ -349,10 +349,11 @@ Accessible* nsAccessibilityService::GetRootDocumentAccessible(
treeItem->GetRootTreeItem(getter_AddRefs(rootTreeItem));
if (treeItem != rootTreeItem) {
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(rootTreeItem));
ps = docShell->GetPresShell();
presShell = docShell->GetPresShell();
}
return aCanCreate ? GetDocAccessible(ps) : ps->GetDocAccessible();
return aCanCreate ? GetDocAccessible(presShell)
: presShell->GetDocAccessible();
}
}
return nullptr;

View File

@ -26,6 +26,8 @@ class nsITreeView;
namespace mozilla {
class PresShell;
namespace dom {
class DOMStringList;
}
@ -108,7 +110,7 @@ class nsAccessibilityService final : public mozilla::a11y::DocManager,
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIOBSERVER
Accessible* GetRootDocumentAccessible(nsIPresShell* aPresShell,
Accessible* GetRootDocumentAccessible(mozilla::PresShell* aPresShell,
bool aCanCreate);
already_AddRefed<Accessible> CreatePluginAccessible(nsPluginFrame* aFrame,
nsIContent* aContent,

View File

@ -6,6 +6,7 @@
#include "RootAccessible.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/PresShell.h" // for nsAccUtils::GetDocAccessibleFor()
#define CreateEvent CreateEventA

View File

@ -649,9 +649,8 @@ nsDocShell::GetInterface(const nsIID& aIID, void** aSink) {
NS_ADDREF((nsISupports*)*aSink);
return NS_OK;
} else if (aIID.Equals(NS_GET_IID(nsISelectionDisplay))) {
nsIPresShell* shell = GetPresShell();
if (shell) {
return shell->QueryInterface(aIID, aSink);
if (PresShell* presShell = GetPresShell()) {
return presShell->QueryInterface(aIID, aSink);
}
} else if (aIID.Equals(NS_GET_IID(nsIDocShellTreeOwner))) {
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
@ -1107,12 +1106,12 @@ nsPresContext* nsDocShell::GetPresContext() {
return mContentViewer->GetPresContext();
}
nsIPresShell* nsDocShell::GetPresShell() {
PresShell* nsDocShell::GetPresShell() {
nsPresContext* presContext = GetPresContext();
return presContext ? presContext->GetPresShell() : nullptr;
}
nsIPresShell* nsDocShell::GetEldestPresShell() {
PresShell* nsDocShell::GetEldestPresShell() {
nsPresContext* presContext = GetEldestPresContext();
if (presContext) {
@ -1228,7 +1227,7 @@ NS_IMETHODIMP
nsDocShell::GetCharset(nsACString& aCharset) {
aCharset.Truncate();
nsIPresShell* presShell = GetPresShell();
PresShell* presShell = GetPresShell();
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
Document* doc = presShell->GetDocument();
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
@ -2370,8 +2369,7 @@ nsDocShell::SetMetaViewportOverride(
// Inform our presShell that it needs to re-check its need for a viewport
// override.
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
if (presShell) {
if (RefPtr<PresShell> presShell = GetPresShell()) {
presShell->UpdateViewportOverridden(true);
}
@ -5141,10 +5139,10 @@ void nsDocShell::DoGetPositionAndSize(int32_t* aX, int32_t* aY, int32_t* aWidth,
NS_IMETHODIMP
nsDocShell::Repaint(bool aForce) {
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
PresShell* presShell = GetPresShell();
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
nsViewManager* viewManager = presShell->GetViewManager();
RefPtr<nsViewManager> viewManager = presShell->GetViewManager();
NS_ENSURE_TRUE(viewManager, NS_ERROR_FAILURE);
viewManager->InvalidateAllViews();
@ -5203,7 +5201,7 @@ nsDocShell::GetVisibility(bool* aVisibility) {
return NS_OK;
}
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
PresShell* presShell = GetPresShell();
if (!presShell) {
return NS_OK;
}
@ -5228,17 +5226,13 @@ nsDocShell::GetVisibility(bool* aVisibility) {
RefPtr<nsDocShell> docShell = this;
RefPtr<nsDocShell> parentItem = docShell->GetParentDocshell();
while (parentItem) {
presShell = docShell->GetPresShell();
nsCOMPtr<nsIPresShell> pPresShell = parentItem->GetPresShell();
// Null-check for crash in bug 267804
if (!pPresShell) {
if (!parentItem->GetPresShell()) {
MOZ_ASSERT_UNREACHABLE("parent docshell has null pres shell");
return NS_OK;
}
vm = presShell->GetViewManager();
vm = docShell->GetPresShell()->GetViewManager();
if (vm) {
view = vm->GetRootView();
}
@ -5298,9 +5292,8 @@ nsDocShell::SetIsActive(bool aIsActive) {
mIsActive = aIsActive;
// Tell the PresShell about it.
nsCOMPtr<nsIPresShell> pshell = GetPresShell();
if (pshell) {
pshell->SetIsActive(aIsActive);
if (RefPtr<PresShell> presShell = GetPresShell()) {
presShell->SetIsActive(aIsActive);
}
// Tell the window about it
@ -5634,10 +5627,10 @@ nsresult nsDocShell::SetCurScrollPosEx(int32_t aCurHorizontalPos,
// Set the visual viewport offset as well.
nsCOMPtr<nsIPresShell> shell = GetPresShell();
NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE);
RefPtr<PresShell> presShell = GetPresShell();
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
nsPresContext* presContext = shell->GetPresContext();
nsPresContext* presContext = presShell->GetPresContext();
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
// Only the root content document can have a distinct visual viewport offset.
@ -5647,12 +5640,12 @@ nsresult nsDocShell::SetCurScrollPosEx(int32_t aCurHorizontalPos,
// Not on a platform with a distinct visual viewport - don't bother setting
// the visual viewport offset.
if (!shell->IsVisualViewportSizeSet()) {
if (!presShell->IsVisualViewportSizeSet()) {
return NS_OK;
}
shell->ScrollToVisual(targetPos, layers::FrameMetrics::eMainThread,
scrollMode);
presShell->ScrollToVisual(targetPos, layers::FrameMetrics::eMainThread,
scrollMode);
return NS_OK;
}
@ -7612,8 +7605,7 @@ nsresult nsDocShell::RestoreFromHistory() {
nsView* rootViewParent = nullptr;
nsIntRect newBounds(0, 0, 0, 0);
nsCOMPtr<nsIPresShell> oldPresShell = GetPresShell();
if (oldPresShell) {
if (PresShell* oldPresShell = GetPresShell()) {
nsViewManager* vm = oldPresShell->GetViewManager();
if (vm) {
nsView* oldRootView = vm->GetRootView();
@ -7842,7 +7834,7 @@ nsresult nsDocShell::RestoreFromHistory() {
rv = privWin->RestoreWindowState(windowState);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPresShell> shell = GetPresShell();
RefPtr<PresShell> presShell = GetPresShell();
// We may be displayed on a different monitor (or in a different
// HiDPI mode) than when we got into the history list. So we need
@ -7851,16 +7843,17 @@ nsresult nsDocShell::RestoreFromHistory() {
// Because the prescontext normally handles resolution changes via
// a runnable (see nsPresContext::UIResolutionChanged), its device
// context won't be -immediately- updated as a result of calling
// shell->BackingScaleFactorChanged().
// presShell->BackingScaleFactorChanged().
// But we depend on that device context when adjusting the view size
// via mContentViewer->SetBounds(newBounds) below. So we need to
// explicitly tell it to check for changed resolution here.
if (shell && shell->GetPresContext()->DeviceContext()->CheckDPIChange()) {
shell->BackingScaleFactorChanged();
if (presShell &&
presShell->GetPresContext()->DeviceContext()->CheckDPIChange()) {
presShell->BackingScaleFactorChanged();
}
nsViewManager* newVM = shell ? shell->GetViewManager() : nullptr;
nsViewManager* newVM = presShell ? presShell->GetViewManager() : nullptr;
nsView* newRootView = newVM ? newVM->GetRootView() : nullptr;
// Insert the new root view at the correct location in the view tree.
@ -7943,7 +7936,7 @@ nsresult nsDocShell::RestoreFromHistory() {
mContentViewer->SetBounds(newBounds);
} else {
nsIScrollableFrame* rootScrollFrame =
shell->GetRootScrollFrameAsScrollable();
presShell->GetRootScrollFrameAsScrollable();
if (rootScrollFrame) {
rootScrollFrame->PostScrolledAreaEventForCurrentArea();
}
@ -7959,8 +7952,8 @@ nsresult nsDocShell::RestoreFromHistory() {
nsDocShell::FinishRestore();
// Restart plugins, and paint the content.
if (shell) {
shell->Thaw();
if (presShell) {
presShell->Thaw();
}
return privWin->FireDelayedDOMEvents();
@ -8146,10 +8139,8 @@ nsresult nsDocShell::CreateContentViewer(const nsACString& aContentType,
// the ID can be used to distinguish it from the other parts.
nsCOMPtr<nsIMultiPartChannel> multiPartChannel(do_QueryInterface(aRequest));
if (multiPartChannel) {
nsCOMPtr<nsIPresShell> shell = GetPresShell();
if (NS_SUCCEEDED(rv) && shell) {
Document* doc = shell->GetDocument();
if (doc) {
if (PresShell* presShell = GetPresShell()) {
if (Document* doc = presShell->GetDocument()) {
uint32_t partID;
multiPartChannel->GetPartID(&partID);
doc->SetPartID(partID);
@ -10420,14 +10411,14 @@ nsresult nsDocShell::ScrollToAnchor(bool aCurHasRef, bool aNewHasRef,
return NS_OK;
}
nsCOMPtr<nsIPresShell> shell = GetPresShell();
if (!shell) {
RefPtr<PresShell> presShell = GetPresShell();
if (!presShell) {
// If we failed to get the shell, or if there is no shell,
// nothing left to do here.
return NS_OK;
}
nsIScrollableFrame* rootScroll = shell->GetRootScrollFrameAsScrollable();
nsIScrollableFrame* rootScroll = presShell->GetRootScrollFrameAsScrollable();
if (rootScroll) {
rootScroll->ClearDidHistoryRestore();
}
@ -10460,7 +10451,8 @@ nsresult nsDocShell::ScrollToAnchor(bool aCurHasRef, bool aNewHasRef,
nsresult rv = NS_ERROR_FAILURE;
NS_ConvertUTF8toUTF16 uStr(aNewHash);
if (!uStr.IsEmpty()) {
rv = shell->GoToAnchor(uStr, scroll, nsIPresShell::SCROLL_SMOOTH_AUTO);
rv =
presShell->GoToAnchor(uStr, scroll, nsIPresShell::SCROLL_SMOOTH_AUTO);
}
if (NS_FAILED(rv)) {
@ -10471,8 +10463,8 @@ nsresult nsDocShell::ScrollToAnchor(bool aCurHasRef, bool aNewHasRef,
nsUnescape(str);
NS_ConvertUTF8toUTF16 utf16Str(str);
if (!utf16Str.IsEmpty()) {
rv = shell->GoToAnchor(utf16Str, scroll,
nsIPresShell::SCROLL_SMOOTH_AUTO);
rv = presShell->GoToAnchor(utf16Str, scroll,
nsIPresShell::SCROLL_SMOOTH_AUTO);
}
free(str);
}
@ -10505,12 +10497,12 @@ nsresult nsDocShell::ScrollToAnchor(bool aCurHasRef, bool aNewHasRef,
//
// When aNewHash contains "%00", unescaped string may be empty.
// And GoToAnchor asserts if we ask it to scroll to an empty ref.
shell->GoToAnchor(uStr, scroll && !uStr.IsEmpty(),
nsIPresShell::SCROLL_SMOOTH_AUTO);
presShell->GoToAnchor(uStr, scroll && !uStr.IsEmpty(),
nsIPresShell::SCROLL_SMOOTH_AUTO);
}
} else {
// Tell the shell it's at an anchor, without scrolling.
shell->GoToAnchor(EmptyString(), false);
presShell->GoToAnchor(EmptyString(), false);
// An empty anchor was found, but if it's a load from history,
// we don't have to jump to the top of the page. Scrollbar
@ -11626,10 +11618,9 @@ nsresult nsDocShell::PersistLayoutHistoryState() {
if (mOSHE) {
bool scrollRestorationIsManual = mOSHE->GetScrollRestorationIsManual();
nsCOMPtr<nsIPresShell> shell = GetPresShell();
nsCOMPtr<nsILayoutHistoryState> layoutState;
if (shell) {
rv = shell->CaptureHistoryState(getter_AddRefs(layoutState));
if (RefPtr<PresShell> presShell = GetPresShell()) {
rv = presShell->CaptureHistoryState(getter_AddRefs(layoutState));
} else if (scrollRestorationIsManual) {
// Even if we don't have layout anymore, we may want to reset the
// current scroll state in layout history.
@ -12014,10 +12005,10 @@ nsresult nsDocShell::GetPromptAndStringBundle(nsIPrompt** aPrompt,
}
nsIScrollableFrame* nsDocShell::GetRootScrollFrame() {
nsCOMPtr<nsIPresShell> shell = GetPresShell();
NS_ENSURE_TRUE(shell, nullptr);
PresShell* presShell = GetPresShell();
NS_ENSURE_TRUE(presShell, nullptr);
return shell->GetRootScrollFrameAsScrollable();
return presShell->GetRootScrollFrameAsScrollable();
}
nsresult nsDocShell::EnsureScriptEnvironment() {
@ -13101,7 +13092,7 @@ nsDocShell::GetOSHEId(uint32_t* aSHEntryId) {
NS_IMETHODIMP
nsDocShell::GetAsyncPanZoomEnabled(bool* aOut) {
if (nsIPresShell* presShell = GetPresShell()) {
if (PresShell* presShell = GetPresShell()) {
*aOut = presShell->AsyncPanZoomEnabled();
return NS_OK;
}
@ -13374,7 +13365,7 @@ nsDocShell::SetColorMatrix(float* aMatrix, uint32_t aMatrixLen) {
return NS_ERROR_INVALID_ARG;
}
nsIPresShell* presShell = GetPresShell();
PresShell* presShell = GetPresShell();
if (!presShell) {
return NS_ERROR_FAILURE;
}

View File

@ -1241,14 +1241,11 @@ void ChromeTooltipListener::sTooltipCallback(nsITimer* aTimer,
// finding the screen coords of its toplevel widget...
nsCOMPtr<nsIDocShell> docShell =
do_GetInterface(static_cast<nsIWebBrowser*>(self->mWebBrowser));
nsCOMPtr<nsIPresShell> shell;
if (docShell) {
shell = docShell->GetPresShell();
}
RefPtr<PresShell> presShell = docShell ? docShell->GetPresShell() : nullptr;
nsIWidget* widget = nullptr;
if (shell) {
nsViewManager* vm = shell->GetViewManager();
if (presShell) {
nsViewManager* vm = presShell->GetViewManager();
if (vm) {
nsView* view = vm->GetRootView();
if (view) {
@ -1279,8 +1276,8 @@ void ChromeTooltipListener::sTooltipCallback(nsITimer* aTimer,
tooltipText != self->mLastShownTooltipText)) {
LayoutDeviceIntPoint screenDot = widget->WidgetToScreenOffset();
double scaleFactor = 1.0;
if (shell->GetPresContext()) {
nsDeviceContext* dc = shell->GetPresContext()->DeviceContext();
if (presShell->GetPresContext()) {
nsDeviceContext* dc = presShell->GetPresContext()->DeviceContext();
scaleFactor = double(AppUnitsPerCSSPixel()) /
dc->AppUnitsPerDevPixelAtUnitFullZoom();
}

View File

@ -17,11 +17,11 @@
#include "nsIURI.h"
class nsCommandManager;
class nsPresContext;
class nsIPresShell;
class nsDocShellLoadState;
namespace mozilla {
class Encoding;
class HTMLEditor;
class PresShell;
namespace dom {
class BrowsingContext;
class ClientSource;
@ -34,8 +34,8 @@ class ClientSource;
*/
[ptr] native nsPresContext(nsPresContext);
[ptr] native nsIPresShell(nsIPresShell);
[ptr] native nsCommandManager(nsCommandManager);
[ptr] native PresShell(mozilla::PresShell);
[ref] native MaybeURI(mozilla::Maybe<nsCOMPtr<nsIURI>>);
[ref] native Encoding(const mozilla::Encoding*);
native UniqueClientSource(mozilla::UniquePtr<mozilla::dom::ClientSource>);
@ -149,13 +149,13 @@ interface nsIDocShell : nsIDocShellTreeItem
/**
* Presentation shell for the currently loaded document. This may be null.
*/
[notxpcom,nostdcall] readonly attribute nsIPresShell presShell;
[notxpcom,nostdcall] readonly attribute PresShell presShell;
/**
* Presentation shell for the oldest document, if this docshell is
* currently transitioning between documents.
*/
[notxpcom,nostdcall] readonly attribute nsIPresShell eldestPresShell;
[notxpcom,nostdcall] readonly attribute PresShell eldestPresShell;
/**
* Content Viewer that is currently loaded for this DocShell. This may

View File

@ -7,6 +7,7 @@
#include "VisualViewport.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/PresShell.h"
#include "mozilla/ToString.h"
#include "nsIScrollableFrame.h"
#include "nsIDocShell.h"
@ -59,8 +60,7 @@ void VisualViewport::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
CSSSize VisualViewport::VisualViewportSize() const {
CSSSize size = CSSSize(0, 0);
nsIPresShell* presShell = GetPresShell();
if (presShell) {
if (PresShell* presShell = GetPresShell()) {
if (presShell->IsVisualViewportSizeSet()) {
size = CSSRect::FromAppUnits(presShell->GetVisualViewportSize());
} else {
@ -85,8 +85,7 @@ double VisualViewport::Height() const {
double VisualViewport::Scale() const {
double scale = 1;
nsIPresShell* presShell = GetPresShell();
if (presShell) {
if (PresShell* presShell = GetPresShell()) {
scale = presShell->GetResolution();
}
return scale;
@ -95,8 +94,7 @@ double VisualViewport::Scale() const {
CSSPoint VisualViewport::VisualViewportOffset() const {
CSSPoint offset = CSSPoint(0, 0);
nsIPresShell* presShell = GetPresShell();
if (presShell) {
if (PresShell* presShell = GetPresShell()) {
offset = CSSPoint::FromAppUnits(presShell->GetVisualViewportOffset());
}
return offset;
@ -105,7 +103,7 @@ CSSPoint VisualViewport::VisualViewportOffset() const {
CSSPoint VisualViewport::LayoutViewportOffset() const {
CSSPoint offset = CSSPoint(0, 0);
if (nsIPresShell* presShell = GetPresShell()) {
if (PresShell* presShell = GetPresShell()) {
offset = CSSPoint::FromAppUnits(presShell->GetLayoutViewportOffset());
}
return offset;
@ -123,7 +121,7 @@ double VisualViewport::OffsetTop() const {
return PageTop() - LayoutViewportOffset().Y();
}
nsIPresShell* VisualViewport::GetPresShell() const {
PresShell* VisualViewport::GetPresShell() const {
nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
if (!window) {
return nullptr;
@ -138,7 +136,7 @@ nsIPresShell* VisualViewport::GetPresShell() const {
}
nsPresContext* VisualViewport::GetPresContext() const {
nsIPresShell* presShell = GetPresShell();
PresShell* presShell = GetPresShell();
if (!presShell) {
return nullptr;
}
@ -276,7 +274,7 @@ void VisualViewport::FireScrollEvent() {
mScrollEvent->Revoke();
mScrollEvent = nullptr;
if (nsIPresShell* presShell = GetPresShell()) {
if (PresShell* presShell = GetPresShell()) {
if (presShell->GetVisualViewportOffset() != prevVisualOffset) {
// The internal event will be fired whenever the visual viewport's
// *absolute* offset changed, i.e. relative to the page.

View File

@ -14,6 +14,9 @@
#include "nsIPresShell.h"
namespace mozilla {
class PresShell;
namespace dom {
/* Visual Viewport API spec:
@ -89,7 +92,7 @@ class VisualViewport final : public mozilla::DOMEventTargetHelper {
CSSSize VisualViewportSize() const;
CSSPoint VisualViewportOffset() const;
CSSPoint LayoutViewportOffset() const;
nsIPresShell* GetPresShell() const;
PresShell* GetPresShell() const;
nsPresContext* GetPresContext() const;
void FireResizeEvent();

View File

@ -6392,8 +6392,7 @@ nsIPresShell* nsContentUtils::FindPresShellForDocument(const Document* aDoc) {
// Walk the docshell tree to find the nearest container that has a
// presshell, and return that.
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(docShellTreeItem);
nsIPresShell* presShell = docShell->GetPresShell();
if (presShell) {
if (PresShell* presShell = docShell->GetPresShell()) {
return presShell;
}
nsCOMPtr<nsIDocShellTreeItem> parent;

View File

@ -212,7 +212,7 @@ nsDOMWindowUtils::nsDOMWindowUtils(nsGlobalWindowOuter* aWindow) {
nsDOMWindowUtils::~nsDOMWindowUtils() { OldWindowSize::GetAndRemove(mWindow); }
nsIPresShell* nsDOMWindowUtils::GetPresShell() {
PresShell* nsDOMWindowUtils::GetPresShell() {
nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryReferent(mWindow);
if (!window) return nullptr;
@ -347,7 +347,7 @@ NS_IMETHODIMP
nsDOMWindowUtils::Redraw(uint32_t aCount, uint32_t* aDurationOut) {
if (aCount == 0) aCount = 1;
if (nsIPresShell* presShell = GetPresShell()) {
if (PresShell* presShell = GetPresShell()) {
nsIFrame* rootFrame = presShell->GetRootFrame();
if (rootFrame) {
@ -371,7 +371,7 @@ nsDOMWindowUtils::Redraw(uint32_t aCount, uint32_t* aDurationOut) {
NS_IMETHODIMP
nsDOMWindowUtils::UpdateLayerTree() {
if (nsIPresShell* presShell = GetPresShell()) {
if (PresShell* presShell = GetPresShell()) {
// Don't flush throttled animations since it might fire MozAfterPaint event
// (in WebRender it constantly does), thus the reftest harness can't take
// any snapshot until the throttled animations finished.
@ -393,7 +393,7 @@ nsDOMWindowUtils::UpdateLayerTree() {
NS_IMETHODIMP
nsDOMWindowUtils::GetContentViewerSize(uint32_t* aDisplayWidth,
uint32_t* aDisplayHeight) {
nsIPresShell* presShell = GetPresShell();
PresShell* presShell = GetPresShell();
LayoutDeviceIntSize displaySize;
if (!presShell || !nsLayoutUtils::GetContentViewerSize(
@ -434,7 +434,7 @@ nsDOMWindowUtils::SetDisplayPortForElement(float aXPx, float aYPx,
float aWidthPx, float aHeightPx,
Element* aElement,
uint32_t aPriority) {
nsIPresShell* presShell = GetPresShell();
PresShell* presShell = GetPresShell();
if (!presShell) {
return NS_ERROR_FAILURE;
}
@ -514,7 +514,7 @@ NS_IMETHODIMP
nsDOMWindowUtils::SetDisplayPortMarginsForElement(
float aLeftMargin, float aTopMargin, float aRightMargin,
float aBottomMargin, Element* aElement, uint32_t aPriority) {
nsIPresShell* presShell = GetPresShell();
PresShell* presShell = GetPresShell();
if (!presShell) {
return NS_ERROR_FAILURE;
}
@ -542,7 +542,7 @@ NS_IMETHODIMP
nsDOMWindowUtils::SetDisplayPortBaseForElement(int32_t aX, int32_t aY,
int32_t aWidth, int32_t aHeight,
Element* aElement) {
nsIPresShell* presShell = GetPresShell();
PresShell* presShell = GetPresShell();
if (!presShell) {
return NS_ERROR_FAILURE;
}
@ -562,7 +562,7 @@ nsDOMWindowUtils::SetDisplayPortBaseForElement(int32_t aX, int32_t aY,
NS_IMETHODIMP
nsDOMWindowUtils::SetResolutionAndScaleTo(float aResolution) {
nsIPresShell* presShell = GetPresShell();
PresShell* presShell = GetPresShell();
if (!presShell) {
return NS_ERROR_FAILURE;
}
@ -577,7 +577,7 @@ NS_IMETHODIMP
nsDOMWindowUtils::SetRestoreResolution(float aResolution,
uint32_t aDisplayWidth,
uint32_t aDisplayHeight) {
nsIPresShell* presShell = GetPresShell();
PresShell* presShell = GetPresShell();
if (!presShell) {
return NS_ERROR_FAILURE;
}
@ -590,7 +590,7 @@ nsDOMWindowUtils::SetRestoreResolution(float aResolution,
NS_IMETHODIMP
nsDOMWindowUtils::GetResolution(float* aResolution) {
nsIPresShell* presShell = GetPresShell();
PresShell* presShell = GetPresShell();
if (!presShell) {
return NS_ERROR_FAILURE;
}
@ -602,8 +602,7 @@ nsDOMWindowUtils::GetResolution(float* aResolution) {
NS_IMETHODIMP
nsDOMWindowUtils::SetIsFirstPaint(bool aIsFirstPaint) {
nsIPresShell* presShell = GetPresShell();
if (presShell) {
if (PresShell* presShell = GetPresShell()) {
presShell->SetIsFirstPaint(aIsFirstPaint);
return NS_OK;
}
@ -612,8 +611,7 @@ nsDOMWindowUtils::SetIsFirstPaint(bool aIsFirstPaint) {
NS_IMETHODIMP
nsDOMWindowUtils::GetIsFirstPaint(bool* aIsFirstPaint) {
nsIPresShell* presShell = GetPresShell();
if (presShell) {
if (PresShell* presShell = GetPresShell()) {
*aIsFirstPaint = presShell->GetIsFirstPaint();
return NS_OK;
}
@ -622,8 +620,7 @@ nsDOMWindowUtils::GetIsFirstPaint(bool* aIsFirstPaint) {
NS_IMETHODIMP
nsDOMWindowUtils::GetPresShellId(uint32_t* aPresShellId) {
nsIPresShell* presShell = GetPresShell();
if (presShell) {
if (PresShell* presShell = GetPresShell()) {
*aPresShellId = presShell->GetPresShellId();
return NS_OK;
}
@ -1028,8 +1025,7 @@ nsIWidget* nsDOMWindowUtils::GetWidget(nsPoint* aOffset) {
if (window) {
nsIDocShell* docShell = window->GetDocShell();
if (docShell) {
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
return nsContentUtils::GetWidget(presShell, aOffset);
return nsContentUtils::GetWidget(docShell->GetPresShell(), aOffset);
}
}
@ -1037,17 +1033,19 @@ nsIWidget* nsDOMWindowUtils::GetWidget(nsPoint* aOffset) {
}
nsIWidget* nsDOMWindowUtils::GetWidgetForElement(Element* aElement) {
if (!aElement) return GetWidget();
Document* doc = aElement->GetUncomposedDoc();
PresShell* presShell = doc ? doc->GetPresShell() : nullptr;
if (presShell) {
nsIFrame* frame = aElement->GetPrimaryFrame();
if (!frame) {
frame = presShell->GetRootFrame();
if (!aElement) {
return GetWidget();
}
if (Document* doc = aElement->GetUncomposedDoc()) {
if (PresShell* presShell = doc->GetPresShell()) {
nsIFrame* frame = aElement->GetPrimaryFrame();
if (!frame) {
frame = presShell->GetRootFrame();
}
if (frame) {
return frame->GetNearestWidget();
}
}
if (frame) return frame->GetNearestWidget();
}
return nullptr;
@ -1346,7 +1344,7 @@ nsDOMWindowUtils::DisableNonTestMouseEvents(bool aDisable) {
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
nsIDocShell* docShell = window->GetDocShell();
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
PresShell* presShell = docShell->GetPresShell();
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
presShell->DisableNonTestMouseEvents(aDisable);
return NS_OK;
@ -1376,8 +1374,7 @@ static nsresult getScrollXYAppUnits(const nsWeakPtr& aWindow, bool aFlushLayout,
doc->FlushPendingNotifications(FlushType::Layout);
}
PresShell* presShell = doc->GetPresShell();
if (presShell) {
if (PresShell* presShell = doc->GetPresShell()) {
nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable();
if (sf) {
aScrollPos = sf->GetScrollPosition();
@ -1742,7 +1739,7 @@ nsDOMWindowUtils::SendQueryContentEvent(uint32_t aType, int64_t aOffset,
nsIDocShell* docShell = window->GetDocShell();
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
PresShell* presShell = docShell->GetPresShell();
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
nsPresContext* presContext = presShell->GetPresContext();
@ -2591,8 +2588,7 @@ nsDOMWindowUtils::GetUnanimatedComputedStyle(Element* aElement,
return NS_ERROR_INVALID_ARG;
}
nsIPresShell* shell = GetPresShell();
if (!shell) {
if (!GetPresShell()) {
return NS_ERROR_FAILURE;
}
@ -3005,7 +3001,7 @@ nsDOMWindowUtils::GetPaintingSuppressed(bool* aPaintingSuppressed) {
nsIDocShell* docShell = window->GetDocShell();
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
PresShell* presShell = docShell->GetPresShell();
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
*aPaintingSuppressed = presShell->IsPaintingSuppressed();
@ -3030,7 +3026,7 @@ nsDOMWindowUtils::SetVisualViewportSize(float aWidth, float aHeight) {
return NS_ERROR_ILLEGAL_VALUE;
}
nsIPresShell* presShell = GetPresShell();
PresShell* presShell = GetPresShell();
if (!presShell) {
return NS_ERROR_FAILURE;
}
@ -3057,7 +3053,7 @@ nsresult nsDOMWindowUtils::RemoteFrameFullscreenReverted() {
return NS_OK;
}
static void PrepareForFullscreenChange(nsIPresShell* aPresShell,
static void PrepareForFullscreenChange(PresShell* aPresShell,
const nsSize& aSize,
nsSize* aOldSize = nullptr) {
if (!aPresShell) {
@ -3158,7 +3154,7 @@ nsDOMWindowUtils::SelectAtPoint(float aX, float aY, uint32_t aSelectBehavior,
return NS_ERROR_INVALID_ARG;
}
nsIPresShell* presShell = GetPresShell();
PresShell* presShell = GetPresShell();
if (!presShell) {
return NS_ERROR_UNEXPECTED;
}
@ -3367,7 +3363,7 @@ nsDOMWindowUtils::SetPaintFlashing(bool aPaintFlashing) {
if (presContext) {
presContext->SetPaintFlashing(aPaintFlashing);
// Clear paint flashing colors
nsIPresShell* presShell = GetPresShell();
PresShell* presShell = GetPresShell();
if (!aPaintFlashing && presShell) {
nsIFrame* rootFrame = presShell->GetRootFrame();
if (rootFrame) {
@ -3914,7 +3910,7 @@ nsDOMWindowUtils::ForceUseCounterFlush(nsINode* aNode) {
NS_IMETHODIMP
nsDOMWindowUtils::HasRuleProcessorUsedByMultipleStyleSets(uint32_t aSheetType,
bool* aRetVal) {
nsIPresShell* presShell = GetPresShell();
PresShell* presShell = GetPresShell();
if (!presShell) {
return NS_ERROR_FAILURE;
}
@ -3925,8 +3921,8 @@ nsDOMWindowUtils::HasRuleProcessorUsedByMultipleStyleSets(uint32_t aSheetType,
NS_IMETHODIMP
nsDOMWindowUtils::RespectDisplayPortSuppression(bool aEnabled) {
nsCOMPtr<nsIPresShell> shell(GetPresShell());
shell->RespectDisplayportSuppression(aEnabled);
RefPtr<PresShell> presShell = GetPresShell();
presShell->RespectDisplayportSuppression(aEnabled);
return NS_OK;
}

View File

@ -14,13 +14,13 @@
#include "mozilla/BasicEvents.h"
class nsGlobalWindowOuter;
class nsIPresShell;
class nsIWidget;
class nsPresContext;
class nsView;
struct nsPoint;
namespace mozilla {
class PresShell;
namespace dom {
class Document;
class Element;
@ -77,7 +77,7 @@ class nsDOMWindowUtils final : public nsIDOMWindowUtils,
nsIWidget* GetWidget(nsPoint* aOffset = nullptr);
nsIWidget* GetWidgetForElement(mozilla::dom::Element* aElement);
nsIPresShell* GetPresShell();
mozilla::PresShell* GetPresShell();
nsPresContext* GetPresContext();
mozilla::dom::Document* GetDocument();
mozilla::layers::LayerTransactionChild* GetLayerTransaction();

View File

@ -302,8 +302,7 @@ Element* nsFocusManager::GetFocusedDescendant(
if (!docShell) {
break;
}
nsIPresShell* presShell = docShell->GetPresShell();
if (!presShell) {
if (!docShell->GetPresShell()) {
break;
}
}
@ -600,12 +599,14 @@ nsFocusManager::MoveCaretToFocus(mozIDOMWindowProxy* aWindow) {
docShell->GetEditable(&isEditable);
if (isEditable) return NS_OK;
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
RefPtr<PresShell> presShell = docShell->GetPresShell();
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
nsCOMPtr<nsPIDOMWindowOuter> window = nsPIDOMWindowOuter::From(aWindow);
nsCOMPtr<nsIContent> content = window->GetFocusedElement();
if (content) MoveCaretToFocus(presShell, content);
if (content) {
MoveCaretToFocus(presShell, content);
}
}
}
@ -725,8 +726,7 @@ nsFocusManager::WindowLowered(mozIDOMWindowProxy* aWindow) {
if (mFocusedWindow) {
nsCOMPtr<nsIDocShell> docShell = mFocusedWindow->GetDocShell();
if (docShell) {
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
if (presShell) {
if (PresShell* presShell = docShell->GetPresShell()) {
RefPtr<nsFrameSelection> frameSelection = presShell->FrameSelection();
frameSelection->SetDragState(false);
}
@ -906,7 +906,7 @@ nsFocusManager::WindowHidden(mozIDOMWindowProxy* aWindow) {
RefPtr<Element> oldFocusedElement = mFocusedElement.forget();
nsCOMPtr<nsIDocShell> focusedDocShell = mFocusedWindow->GetDocShell();
nsCOMPtr<nsIPresShell> presShell = focusedDocShell->GetPresShell();
RefPtr<PresShell> presShell = focusedDocShell->GetPresShell();
if (oldFocusedElement && oldFocusedElement->IsInComposedDoc()) {
NotifyFocusStateChange(oldFocusedElement, nullptr,
@ -1314,7 +1314,7 @@ void nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags,
if (aFocusChanged) {
nsCOMPtr<nsIDocShell> docShell = newWindow->GetDocShell();
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
RefPtr<PresShell> presShell = docShell->GetPresShell();
if (presShell && presShell->DidInitialize())
ScrollIntoView(presShell, elementToFocus, aFlags);
}
@ -1566,7 +1566,7 @@ bool nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear,
// Keep a ref to presShell since dispatching the DOM event may cause
// the document to be destroyed.
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
RefPtr<PresShell> presShell = docShell->GetPresShell();
if (!presShell) {
mFocusedElement = nullptr;
mFocusedWindow = nullptr;
@ -1733,8 +1733,10 @@ void nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, Element* aElement,
nsCOMPtr<nsIDocShell> docShell = aWindow->GetDocShell();
if (!docShell) return;
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
if (!presShell) return;
RefPtr<PresShell> presShell = docShell->GetPresShell();
if (!presShell) {
return;
}
// If the focus actually changed, set the focus method (mouse, keyboard, etc).
// Otherwise, just get the current focus method and use that. This ensures
@ -1749,7 +1751,9 @@ void nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, Element* aElement,
// else
if (CheckIfFocusable(aElement, aFlags)) {
aWindow->SetFocusedElement(aElement, focusMethod);
if (aFocusChanged) ScrollIntoView(presShell, aElement, aFlags);
if (aFocusChanged) {
ScrollIntoView(presShell, aElement, aFlags);
}
}
return;
}
@ -2169,8 +2173,10 @@ void nsFocusManager::RaiseWindow(nsPIDOMWindowOuter* aWindow) {
nsCOMPtr<nsIDocShell> docShell = aWindow->GetDocShell();
if (!docShell) return;
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
if (!presShell) return;
PresShell* presShell = docShell->GetPresShell();
if (!presShell) {
return;
}
nsViewManager* vm = presShell->GetViewManager();
if (vm) {
@ -2212,8 +2218,10 @@ void nsFocusManager::UpdateCaret(bool aMoveCaretToFocus, bool aUpdateVisibility,
bool browseWithCaret = Preferences::GetBool("accessibility.browsewithcaret");
nsCOMPtr<nsIPresShell> presShell = focusedDocShell->GetPresShell();
if (!presShell) return;
RefPtr<PresShell> presShell = focusedDocShell->GetPresShell();
if (!presShell) {
return;
}
// If this is an editable document which isn't contentEditable, or a
// contentEditable document and the node to focus is contentEditable,
@ -2231,7 +2239,9 @@ void nsFocusManager::UpdateCaret(bool aMoveCaretToFocus, bool aUpdateVisibility,
if (!isContentEditableDoc || isFocusEditable) return;
}
if (!isEditable && aMoveCaretToFocus) MoveCaretToFocus(presShell, aContent);
if (!isEditable && aMoveCaretToFocus) {
MoveCaretToFocus(presShell, aContent);
}
if (!aUpdateVisibility) return;

View File

@ -87,7 +87,6 @@
#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"
@ -754,8 +753,7 @@ bool nsFrameLoader::Show(int32_t marginWidth, int32_t marginHeight,
mDocShell->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_Y,
scrollbarPrefY);
nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
if (presShell) {
if (PresShell* presShell = mDocShell->GetPresShell()) {
// Ensure root scroll frame is reflowed in case scroll preferences or
// margins have changed
nsIFrame* rootScrollFrame = presShell->GetRootScrollFrame();
@ -783,8 +781,7 @@ bool nsFrameLoader::Show(int32_t marginWidth, int32_t marginHeight,
// sub-document. This shouldn't be necessary, but given the way our
// editor works, it is. See
// https://bugzilla.mozilla.org/show_bug.cgi?id=284245
presShell = mDocShell->GetPresShell();
if (presShell) {
if (RefPtr<PresShell> presShell = mDocShell->GetPresShell()) {
Document* doc = presShell->GetDocument();
nsHTMLDocument* htmlDoc =
doc && doc->IsHTMLOrXHTML() ? doc->AsHTMLDocument() : nullptr;

View File

@ -14,12 +14,12 @@
#include "nsString.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/Preferences.h"
#include "mozilla/PresShell.h"
#include "nsControllerCommandTable.h"
#include "nsCommandParams.h"
#include "nsPIDOMWindow.h"
#include "nsIPresShell.h"
#include "nsIDocShell.h"
#include "nsISelectionController.h"
#include "nsIWebNavigation.h"
@ -129,7 +129,7 @@ class nsSelectionCommandsBase : public nsIControllerCommand {
virtual ~nsSelectionCommandsBase() {}
static nsresult GetPresShellFromWindow(nsPIDOMWindowOuter *aWindow,
nsIPresShell **aPresShell);
PresShell **aPresShell);
static nsresult GetSelectionControllerFromWindow(
nsPIDOMWindowOuter *aWindow, nsISelectionController **aSelCon);
@ -207,7 +207,7 @@ nsSelectionCommandsBase::DoCommandParams(const char *aCommandName,
// protected methods
nsresult nsSelectionCommandsBase::GetPresShellFromWindow(
nsPIDOMWindowOuter *aWindow, nsIPresShell **aPresShell) {
nsPIDOMWindowOuter *aWindow, PresShell **aPresShell) {
*aPresShell = nullptr;
NS_ENSURE_TRUE(aWindow, NS_ERROR_FAILURE);
@ -220,13 +220,14 @@ nsresult nsSelectionCommandsBase::GetPresShellFromWindow(
nsresult nsSelectionCommandsBase::GetSelectionControllerFromWindow(
nsPIDOMWindowOuter *aWindow, nsISelectionController **aSelCon) {
*aSelCon = nullptr;
nsCOMPtr<nsIPresShell> presShell;
RefPtr<PresShell> presShell;
GetPresShellFromWindow(aWindow, getter_AddRefs(presShell));
if (presShell) return CallQueryInterface(presShell, aSelCon);
return NS_ERROR_FAILURE;
if (!presShell) {
*aSelCon = nullptr;
return NS_ERROR_FAILURE;
}
*aSelCon = presShell.forget().take();
return NS_OK;
}
#if 0
@ -511,7 +512,7 @@ nsresult nsClipboardCommand::DoCommand(const char *aCommandName,
nsIDocShell *docShell = window->GetDocShell();
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
RefPtr<PresShell> presShell = docShell->GetPresShell();
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
EventMessage eventMessage = eCopy;
@ -930,7 +931,7 @@ nsLookUpDictionaryCommand::DoCommandParams(const char *aCommandName,
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
PresShell *presShell = docShell->GetPresShell();
if (NS_WARN_IF(!presShell)) {
return NS_ERROR_FAILURE;
}

View File

@ -4230,8 +4230,10 @@ void nsGlobalWindowInner::UpdateCanvasFocus(bool aFocusChanged,
docShell->GetEditable(&editable);
if (editable) return;
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
if (!presShell || !mDoc) return;
PresShell* presShell = docShell->GetPresShell();
if (!presShell || !mDoc) {
return;
}
Element* rootElement = mDoc->GetRootElement();
if (rootElement) {

View File

@ -1585,12 +1585,11 @@ void nsGlobalWindowOuter::SetInitialPrincipalToSubject() {
mDoc->SetIsInitialDocument(true);
}
nsCOMPtr<nsIPresShell> shell = GetDocShell()->GetPresShell();
if (shell && !shell->DidInitialize()) {
RefPtr<PresShell> presShell = GetDocShell()->GetPresShell();
if (presShell && !presShell->DidInitialize()) {
// Ensure that if someone plays with this document they will get
// layout happening.
shell->Initialize();
presShell->Initialize();
}
}
@ -3373,7 +3372,7 @@ nsresult nsGlobalWindowOuter::GetInnerSize(CSSIntSize& aSize) {
NS_ENSURE_STATE(mDocShell);
RefPtr<nsPresContext> presContext = mDocShell->GetPresContext();
RefPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
PresShell* presShell = mDocShell->GetPresShell();
if (!presContext || !presShell) {
aSize = CSSIntSize(0, 0);
@ -3416,7 +3415,7 @@ void nsGlobalWindowOuter::SetInnerWidthOuter(int32_t aInnerWidth,
}
CheckSecurityWidthAndHeight(&aInnerWidth, nullptr, aCallerType);
RefPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
RefPtr<PresShell> presShell = mDocShell->GetPresShell();
// Setting inner width should set the visual viewport. Most of the
// time, this is the same as the CSS viewport, and when we set one,
@ -3478,7 +3477,7 @@ void nsGlobalWindowOuter::SetInnerHeightOuter(int32_t aInnerHeight,
}
CheckSecurityWidthAndHeight(nullptr, &aInnerHeight, aCallerType);
RefPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
RefPtr<PresShell> presShell = mDocShell->GetPresShell();
// Setting inner height should set the visual viewport. Most of the
// time, this is the same as the CSS viewport, and when we set one,
@ -3655,7 +3654,7 @@ nsRect nsGlobalWindowOuter::GetInnerScreenRect() {
return nsRect();
}
nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
PresShell* presShell = mDocShell->GetPresShell();
if (!presShell) {
return nsRect();
}
@ -3720,7 +3719,7 @@ uint64_t nsGlobalWindowOuter::GetMozPaintCountOuter() {
return 0;
}
nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
PresShell* presShell = mDocShell->GetPresShell();
return presShell ? presShell->GetPaintCount() : 0;
}
@ -4064,7 +4063,7 @@ already_AddRefed<nsIWidget> nsGlobalWindowOuter::GetMainWidget() {
nsIWidget* nsGlobalWindowOuter::GetNearestWidget() const {
nsIDocShell* docShell = GetDocShell();
NS_ENSURE_TRUE(docShell, nullptr);
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
PresShell* presShell = docShell->GetPresShell();
NS_ENSURE_TRUE(presShell, nullptr);
nsIFrame* rootFrame = presShell->GetRootFrame();
NS_ENSURE_TRUE(rootFrame, nullptr);
@ -4440,9 +4439,9 @@ bool nsGlobalWindowOuter::SetWidgetFullscreen(FullscreenReason aReason,
if (!NS_WARN_IF(!IsChromeWindow())) {
if (!NS_WARN_IF(mChromeFields.mFullscreenPresShell)) {
if (nsIPresShell* shell = mDocShell->GetPresShell()) {
if (nsRefreshDriver* rd = shell->GetRefreshDriver()) {
mChromeFields.mFullscreenPresShell = do_GetWeakReference(shell);
if (PresShell* presShell = mDocShell->GetPresShell()) {
if (nsRefreshDriver* rd = presShell->GetRefreshDriver()) {
mChromeFields.mFullscreenPresShell = do_GetWeakReference(presShell);
MOZ_ASSERT(mChromeFields.mFullscreenPresShell);
rd->SetIsResizeSuppressed();
rd->Freeze();
@ -4568,9 +4567,10 @@ void nsGlobalWindowOuter::EnsureReflowFlushAndPaint() {
if (!mDocShell) return;
nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
if (!presShell) return;
RefPtr<PresShell> presShell = mDocShell->GetPresShell();
if (!presShell) {
return;
}
// Flush pending reflows.
if (mDoc) {
@ -4919,23 +4919,9 @@ void nsGlobalWindowOuter::FocusOuter() {
return;
}
nsCOMPtr<nsIPresShell> presShell;
// Don't look for a presshell if we're a root chrome window that's got
// about:blank loaded. We don't want to focus our widget in that case.
// XXXbz should we really be checking for IsInitialDocument() instead?
bool lookForPresShell = true;
if (mDocShell->ItemType() == nsIDocShellTreeItem::typeChrome &&
GetPrivateRoot() == this && mDoc) {
nsIURI* ourURI = mDoc->GetDocumentURI();
if (ourURI) {
lookForPresShell = !NS_IsAboutBlank(ourURI);
}
}
if (lookForPresShell) {
presShell = mDocShell->GetEldestPresShell();
}
nsCOMPtr<nsIDocShellTreeItem> parentDsti;
mDocShell->GetParent(getter_AddRefs(parentDsti));
@ -6563,7 +6549,7 @@ Selection* nsGlobalWindowOuter::GetSelectionOuter() {
return nullptr;
}
nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
PresShell* presShell = mDocShell->GetPresShell();
if (!presShell) {
return nullptr;
}
@ -7323,7 +7309,7 @@ nsIScrollableFrame* nsGlobalWindowOuter::GetScrollFrame() {
return nullptr;
}
nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
PresShell* presShell = mDocShell->GetPresShell();
if (presShell) {
return presShell->GetRootScrollFrameAsScrollable();
}
@ -7498,7 +7484,7 @@ void nsGlobalWindowOuter::SetCursorOuter(const nsAString& aCursor,
if (presContext) {
// Need root widget.
nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
PresShell* presShell = mDocShell->GetPresShell();
if (!presShell) {
aError.Throw(NS_ERROR_FAILURE);
return;

View File

@ -699,8 +699,8 @@ void CanvasGradient::AddColorStop(float aOffset, const nsAString& aColorstr,
return;
}
nsIPresShell* shell = mContext ? mContext->GetPresShell() : nullptr;
ServoStyleSet* styleSet = shell ? shell->StyleSet() : nullptr;
PresShell* presShell = mContext ? mContext->GetPresShell() : nullptr;
ServoStyleSet* styleSet = presShell ? presShell->StyleSet() : nullptr;
nscolor color;
bool ok = ServoCSSParser::ComputeColor(styleSet, NS_RGB(0, 0, 0), aColorstr,
@ -985,7 +985,7 @@ bool CanvasRenderingContext2D::ParseColor(const nsAString& aString,
Document* document = mCanvasElement ? mCanvasElement->OwnerDoc() : nullptr;
css::Loader* loader = document ? document->CSSLoader() : nullptr;
nsIPresShell* presShell = GetPresShell();
PresShell* presShell = GetPresShell();
ServoStyleSet* set = presShell ? presShell->StyleSet() : nullptr;
// First, try computing the color without handling currentcolor.
@ -2161,7 +2161,7 @@ static already_AddRefed<RawServoDeclarationBlock> CreateFontDeclarationForServo(
}
static already_AddRefed<ComputedStyle> GetFontStyleForServo(
Element* aElement, const nsAString& aFont, nsIPresShell* aPresShell,
Element* aElement, const nsAString& aFont, PresShell* aPresShell,
nsAString& aOutUsedFont, ErrorResult& aError) {
RefPtr<RawServoDeclarationBlock> declarations =
CreateFontDeclarationForServo(aFont, aPresShell->GetDocument());
@ -2225,7 +2225,7 @@ CreateFilterDeclarationForServo(const nsAString& aFilter, Document* aDocument) {
static already_AddRefed<ComputedStyle> ResolveFilterStyleForServo(
const nsAString& aFilterString, const ComputedStyle* aParentStyle,
nsIPresShell* aPresShell, ErrorResult& aError) {
PresShell* aPresShell, ErrorResult& aError) {
RefPtr<RawServoDeclarationBlock> declarations =
CreateFilterDeclarationForServo(aFilterString, aPresShell->GetDocument());
if (!declarations) {
@ -2257,7 +2257,7 @@ bool CanvasRenderingContext2D::ParseFilter(
return false;
}
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
RefPtr<PresShell> presShell = GetPresShell();
if (!presShell) {
aError.Throw(NS_ERROR_FAILURE);
return false;
@ -2334,7 +2334,7 @@ class CanvasUserSpaceMetrics : public UserSpaceMetricsWithSize {
};
void CanvasRenderingContext2D::UpdateFilter() {
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
RefPtr<PresShell> presShell = GetPresShell();
if (!presShell || presShell->IsDestroying()) {
// Ensure we set an empty filter and update the state to
// reflect the current "taint" status of the canvas
@ -3124,7 +3124,7 @@ bool CanvasRenderingContext2D::SetFontInternal(const nsAString& aFont,
return false;
}
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
RefPtr<PresShell> presShell = GetPresShell();
if (!presShell) {
aError.Throw(NS_ERROR_FAILURE);
return false;
@ -3647,8 +3647,10 @@ nsresult CanvasRenderingContext2D::DrawOrMeasureText(
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
if (!presShell) return NS_ERROR_FAILURE;
RefPtr<PresShell> presShell = GetPresShell();
if (!presShell) {
return NS_ERROR_FAILURE;
}
Document* document = presShell->GetDocument();
@ -3882,7 +3884,7 @@ gfxFontGroup* CanvasRenderingContext2D::GetCurrentFontStyle() {
ErrorResult err;
NS_NAMED_LITERAL_STRING(kDefaultFontStyle, "10px sans-serif");
static float kDefaultFontSize = 10.0;
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
RefPtr<PresShell> presShell = GetPresShell();
bool fontUpdated = SetFontInternal(kDefaultFontStyle, err);
if (err.Failed() || !fontUpdated) {
err.SuppressException();

View File

@ -391,7 +391,7 @@ class CanvasRenderingContext2D final : public nsICanvasRenderingContextInternal,
/**
* Gets the pres shell from either the canvas element or the doc shell
*/
nsIPresShell* GetPresShell() final {
PresShell* GetPresShell() final {
if (mCanvasElement) {
return mCanvasElement->OwnerDoc()->GetPresShell();
}

View File

@ -28,6 +28,7 @@
class nsDisplayListBuilder;
namespace mozilla {
class PresShell;
namespace layers {
class CanvasLayer;
class CanvasRenderer;
@ -57,7 +58,7 @@ class nsICanvasRenderingContextInternal : public nsISupports,
AddPostRefreshObserverIfNecessary();
}
virtual nsIPresShell* GetPresShell() {
virtual mozilla::PresShell* GetPresShell() {
if (mCanvasElement) {
return mCanvasElement->OwnerDoc()->GetPresShell();
}

View File

@ -1149,22 +1149,25 @@ bool EventStateManager::WalkESMTreeToHandleAccessKey(
nsCOMPtr<nsIDocShell> subDS = do_QueryInterface(subShellItem);
if (subDS && IsShellVisible(subDS)) {
nsCOMPtr<nsIPresShell> subPS = subDS->GetPresShell();
// Guarantee subPresShell lifetime while we're handling access key
// since somebody may assume that it won't be deleted before the
// corresponding nsPresContext and EventStateManager.
RefPtr<PresShell> subPresShell = subDS->GetPresShell();
// Docshells need not have a presshell (eg. display:none
// iframes, docshells in transition between documents, etc).
if (!subPS) {
if (!subPresShell) {
// Oh, well. Just move on to the next child
continue;
}
nsPresContext* subPC = subPS->GetPresContext();
RefPtr<nsPresContext> subPresContext = subPresShell->GetPresContext();
EventStateManager* esm =
static_cast<EventStateManager*>(subPC->EventStateManager());
RefPtr<EventStateManager> esm =
static_cast<EventStateManager*>(subPresContext->EventStateManager());
if (esm && esm->WalkESMTreeToHandleAccessKey(
aEvent, subPC, aAccessCharCodes, nullptr,
aEvent, subPresContext, aAccessCharCodes, nullptr,
eAccessKeyProcessingDown, aExecute)) {
return true;
}
@ -1177,16 +1180,21 @@ bool EventStateManager::WalkESMTreeToHandleAccessKey(
docShell->GetParent(getter_AddRefs(parentShellItem));
nsCOMPtr<nsIDocShell> parentDS = do_QueryInterface(parentShellItem);
if (parentDS) {
nsCOMPtr<nsIPresShell> parentPS = parentDS->GetPresShell();
NS_ASSERTION(parentPS, "Our PresShell exists but the parent's does not?");
// Guarantee parentPresShell lifetime while we're handling access key
// since somebody may assume that it won't be deleted before the
// corresponding nsPresContext and EventStateManager.
RefPtr<PresShell> parentPresShell = parentDS->GetPresShell();
NS_ASSERTION(parentPresShell,
"Our PresShell exists but the parent's does not?");
nsPresContext* parentPC = parentPS->GetPresContext();
NS_ASSERTION(parentPC, "PresShell without PresContext");
RefPtr<nsPresContext> parentPresContext =
parentPresShell->GetPresContext();
NS_ASSERTION(parentPresContext, "PresShell without PresContext");
EventStateManager* esm =
static_cast<EventStateManager*>(parentPC->EventStateManager());
RefPtr<EventStateManager> esm = static_cast<EventStateManager*>(
parentPresContext->EventStateManager());
if (esm && esm->WalkESMTreeToHandleAccessKey(
aEvent, parentPC, aAccessCharCodes, docShell,
aEvent, parentPresContext, aAccessCharCodes, docShell,
eAccessKeyProcessingDown, aExecute)) {
return true;
}

View File

@ -2437,7 +2437,7 @@ mozilla::ipc::IPCResult TabChild::RecvRenderLayers(
// a content viewer if one doesn't exist yet. Creating a content viewer can
// cause JS to run, which we want to avoid. nsIDocShell::GetPresShell
// returns null if no content viewer exists yet.
if (nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell()) {
if (RefPtr<PresShell> presShell = docShell->GetPresShell()) {
presShell->SetIsActive(true);
if (nsIFrame* root = presShell->GetRootFrame()) {
@ -2752,7 +2752,7 @@ void TabChild::MakeHidden() {
// here because that would create a content viewer if one doesn't exist yet.
// Creating a content viewer can cause JS to run, which we want to avoid.
// nsIDocShell::GetPresShell returns null if no content viewer exists yet.
if (nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell()) {
if (RefPtr<PresShell> presShell = docShell->GetPresShell()) {
if (nsPresContext* presContext = presShell->GetPresContext()) {
nsRootPresContext* rootPresContext = presContext->GetRootPresContext();
nsIFrame* rootFrame = presShell->GetRootFrame();
@ -2957,7 +2957,7 @@ void TabChild::SchedulePaint() {
// a content viewer if one doesn't exist yet. Creating a content viewer can
// cause JS to run, which we want to avoid. nsIDocShell::GetPresShell
// returns null if no content viewer exists yet.
if (nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell()) {
if (RefPtr<PresShell> presShell = docShell->GetPresShell()) {
if (nsIFrame* root = presShell->GetRootFrame()) {
root->SchedulePaint();
}

View File

@ -9,12 +9,12 @@
#include "mozilla/gfx/DataSurfaceHelpers.h"
#include "mozilla/layers/SharedRGBImage.h"
#include "mozilla/layers/TextureClient.h"
#include "mozilla/PresShell.h"
#include "mozilla/RefPtr.h"
#include "mozilla/UniquePtrExtensions.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "nsGlobalWindow.h"
#include "nsIDocShell.h"
#include "nsIPresShell.h"
#include "nsPresContext.h"
#include "gfxContext.h"
#include "gfx2DGlue.h"
@ -296,7 +296,7 @@ void MediaEngineTabVideoSource::Draw() {
}
}
nsCOMPtr<nsIPresShell> presShell;
RefPtr<PresShell> presShell;
if (mWindow) {
nsIDocShell* docshell = mWindow->GetDocShell();
if (docshell) {

View File

@ -364,8 +364,7 @@ nsEditingSession::SetupEditorOnWindow(mozIDOMWindowProxy* aWindow) {
// only if we haven't found some error above,
nsCOMPtr<nsIDocShell> docShell = window->GetDocShell();
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
RefPtr<PresShell> presShell =
static_cast<PresShell*>(docShell->GetPresShell());
RefPtr<PresShell> presShell = docShell->GetPresShell();
if (NS_WARN_IF(!presShell)) {
return NS_ERROR_FAILURE;
}
@ -1200,8 +1199,7 @@ void nsEditingSession::RestoreAnimationMode(nsPIDOMWindowOuter* aWindow) {
nsCOMPtr<nsIDocShell> docShell = aWindow ? aWindow->GetDocShell() : nullptr;
NS_ENSURE_TRUE_VOID(docShell);
RefPtr<PresShell> presShell =
static_cast<PresShell*>(docShell->GetPresShell());
RefPtr<PresShell> presShell = docShell->GetPresShell();
if (NS_WARN_IF(!presShell)) {
return;
}
@ -1291,8 +1289,7 @@ nsresult nsEditingSession::ReattachToWindow(mozIDOMWindowProxy* aWindow) {
if (!mInteractive) {
// Disable animation of images in this document:
RefPtr<PresShell> presShell =
static_cast<PresShell*>(docShell->GetPresShell());
RefPtr<PresShell> presShell = docShell->GetPresShell();
if (NS_WARN_IF(!presShell)) {
return NS_ERROR_FAILURE;
}

View File

@ -6227,9 +6227,9 @@ already_AddRefed<nsPIDOMWindowOuter> PresShell::GetRootWindow() {
// If we don't have DOM window, we're zombie, we should find the root window
// with our parent shell.
nsCOMPtr<nsIPresShell> parent = GetParentPresShellForEventHandling();
NS_ENSURE_TRUE(parent, nullptr);
return parent->GetRootWindow();
RefPtr<PresShell> parentPresShell = GetParentPresShellForEventHandling();
NS_ENSURE_TRUE(parentPresShell, nullptr);
return parentPresShell->GetRootWindow();
}
already_AddRefed<nsPIDOMWindowOuter>
@ -6255,7 +6255,7 @@ already_AddRefed<nsIContent> nsIPresShell::GetFocusedContentInOurWindow()
return nullptr;
}
already_AddRefed<nsIPresShell> PresShell::GetParentPresShellForEventHandling() {
already_AddRefed<PresShell> PresShell::GetParentPresShellForEventHandling() {
NS_ENSURE_TRUE(mPresContext, nullptr);
// Now, find the parent pres shell and send the event there
@ -6272,7 +6272,7 @@ already_AddRefed<nsIPresShell> PresShell::GetParentPresShellForEventHandling() {
nsCOMPtr<nsIDocShell> parentDocShell = do_QueryInterface(parentTreeItem);
NS_ENSURE_TRUE(parentDocShell && treeItem != parentTreeItem, nullptr);
nsCOMPtr<nsIPresShell> parentPresShell = parentDocShell->GetPresShell();
RefPtr<PresShell> parentPresShell = parentDocShell->GetPresShell();
return parentPresShell.forget();
}
@ -6283,7 +6283,7 @@ nsresult PresShell::EventHandler::RetargetEventToParent(
// or a root content is not present.
// That way at least the UI key bindings can work.
nsCOMPtr<nsIPresShell> parentPresShell = GetParentPresShellForEventHandling();
RefPtr<PresShell> parentPresShell = GetParentPresShellForEventHandling();
NS_ENSURE_TRUE(parentPresShell, NS_ERROR_FAILURE);
// Fake the event as though it's from the parent pres shell's root frame.

View File

@ -501,7 +501,7 @@ class PresShell final : public nsIPresShell,
void QueryIsActive();
nsresult UpdateImageLockingState();
already_AddRefed<nsIPresShell> GetParentPresShellForEventHandling();
already_AddRefed<PresShell> GetParentPresShellForEventHandling();
/**
* EventHandler is implementation of nsIPresShell::HandleEvent().
@ -1273,7 +1273,7 @@ class PresShell final : public nsIPresShell,
already_AddRefed<nsPIDOMWindowOuter> GetFocusedDOMWindowInOurWindow() {
return mPresShell->GetFocusedDOMWindowInOurWindow();
}
already_AddRefed<nsIPresShell> GetParentPresShellForEventHandling() {
already_AddRefed<PresShell> GetParentPresShellForEventHandling() {
return mPresShell->GetParentPresShellForEventHandling();
}
void PushDelayedEventIntoQueue(UniquePtr<DelayedEvent>&& aDelayedEvent) {

View File

@ -236,7 +236,7 @@ nsIPresShell* nsSubDocumentFrame::GetSubdocumentPresShellForPainting(
if (!mFrameLoader) return nullptr;
nsIDocShell* docShell = mFrameLoader->GetDocShell(IgnoreErrors());
if (!docShell) return nullptr;
presShell = static_cast<mozilla::PresShell*>(docShell->GetPresShell());
presShell = docShell->GetPresShell();
}
}
@ -1246,10 +1246,8 @@ nsIFrame* nsSubDocumentFrame::ObtainIntrinsicSizeFrame() {
// Try to get an nsIFrame for our sub-document's document element
nsIFrame* subDocRoot = nullptr;
nsIDocShell* docShell = GetDocShell();
if (docShell) {
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
if (presShell) {
if (nsIDocShell* docShell = GetDocShell()) {
if (mozilla::PresShell* presShell = docShell->GetPresShell()) {
nsIScrollableFrame* scrollable =
presShell->GetRootScrollFrameAsScrollable();
if (scrollable) {

View File

@ -1291,14 +1291,14 @@ void nsPrintJob::ShowPrintProgress(bool aIsForPrinting, bool& aDoNotify) {
//---------------------------------------------------------------------
bool nsPrintJob::IsThereARangeSelection(nsPIDOMWindowOuter* aDOMWin) {
if (mDisallowSelectionPrint) return false;
nsCOMPtr<nsIPresShell> presShell;
if (aDOMWin) {
presShell = aDOMWin->GetDocShell()->GetPresShell();
if (mDisallowSelectionPrint || !aDOMWin) {
return false;
}
if (!presShell) return false;
PresShell* presShell = aDOMWin->GetDocShell()->GetPresShell();
if (!presShell) {
return false;
}
// check here to see if there is a range selection
// so we know whether to turn on the "Selection" radio button
@ -2050,12 +2050,12 @@ void nsPrintJob::UpdateZoomRatio(nsPrintObject* aPO, bool aSetPixelScale) {
nsresult nsPrintJob::UpdateSelectionAndShrinkPrintObject(
nsPrintObject* aPO, bool aDocumentIsTopLevel) {
nsCOMPtr<nsIPresShell> displayShell = aPO->mDocShell->GetPresShell();
PresShell* displayPresShell = aPO->mDocShell->GetPresShell();
// Transfer Selection Ranges to the new Print PresShell
RefPtr<Selection> selection, selectionPS;
// It's okay if there is no display shell, just skip copying the selection
if (displayShell) {
selection = displayShell->GetCurrentSelection(SelectionType::eNormal);
if (displayPresShell) {
selection = displayPresShell->GetCurrentSelection(SelectionType::eNormal);
}
selectionPS = aPO->mPresShell->GetCurrentSelection(SelectionType::eNormal);

View File

@ -9,6 +9,7 @@
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/EventListenerManager.h"
#include "mozilla/dom/Document.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Event.h" // for Event
#include "mozilla/dom/HTMLInputElement.h"
@ -17,6 +18,7 @@
#include "mozilla/dom/MouseEvent.h"
#include "mozilla/dom/PageTransitionEvent.h"
#include "mozilla/Logging.h"
#include "mozilla/PresShell.h"
#include "nsIFormAutoComplete.h"
#include "nsIInputListAutoComplete.h"
#include "nsIAutoCompleteSimpleResult.h"
@ -29,9 +31,7 @@
#include "nsPIDOMWindow.h"
#include "nsIWebNavigation.h"
#include "nsIContentViewer.h"
#include "mozilla/dom/Document.h"
#include "nsIContent.h"
#include "nsIPresShell.h"
#include "nsRect.h"
#include "nsILoginManager.h"
#include "nsToolkitCompsCID.h"
@ -378,7 +378,7 @@ nsFormFillController::SetPopupOpen(bool aPopupOpen) {
NS_ENSURE_STATE(content);
nsCOMPtr<nsIDocShell> docShell = GetDocShellForInput(mFocusedInput);
NS_ENSURE_STATE(docShell);
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
RefPtr<PresShell> presShell = docShell->GetPresShell();
NS_ENSURE_STATE(presShell);
presShell->ScrollContentIntoView(
content,

View File

@ -219,9 +219,7 @@ nsTypeAheadFind::SetDocShell(nsIDocShell* aDocShell) {
mWebBrowserFind = do_GetInterface(aDocShell);
NS_ENSURE_TRUE(mWebBrowserFind, NS_ERROR_FAILURE);
nsCOMPtr<nsIPresShell> presShell;
presShell = aDocShell->GetPresShell();
mPresShell = do_GetWeakReference(presShell);
mPresShell = do_GetWeakReference(aDocShell->GetPresShell());
ReleaseStrongMemberVariables();
return NS_OK;
@ -745,7 +743,7 @@ nsresult nsTypeAheadFind::GetSearchContainers(
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aContainer));
if (!docShell) return NS_ERROR_FAILURE;
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
RefPtr<PresShell> presShell = docShell->GetPresShell();
RefPtr<nsPresContext> presContext = docShell->GetPresContext();

View File

@ -6,9 +6,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/ArrayUtils.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/PresShell.h"
#include "mozilla/TextEventDispatcher.h"
#include "mozilla/TextEventDispatcherListener.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/layers/CompositorBridgeChild.h"
#include "mozilla/layers/CompositorBridgeParent.h"
@ -27,7 +28,6 @@
#include "nsISimpleEnumerator.h"
#include "nsIContent.h"
#include "mozilla/dom/Document.h"
#include "nsIPresShell.h"
#include "nsIServiceManager.h"
#include "mozilla/Preferences.h"
#include "BasicLayers.h"
@ -1795,7 +1795,8 @@ void nsBaseWidget::ZoomToRect(const uint32_t& aPresShellId,
a11y::Accessible* nsBaseWidget::GetRootAccessible() {
NS_ENSURE_TRUE(mWidgetListener, nullptr);
nsIPresShell* presShell = mWidgetListener->GetPresShell();
PresShell* presShell =
static_cast<PresShell*>(mWidgetListener->GetPresShell());
NS_ENSURE_TRUE(presShell, nullptr);
// If container is null then the presshell is not active. This often happens

View File

@ -51,7 +51,6 @@
#include "nsIScriptSecurityManager.h"
// For calculating size
#include "nsIPresShell.h"
#include "nsPresContext.h"
#include "nsIBaseWindow.h"
@ -62,6 +61,7 @@
#include "mozilla/DebugOnly.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/PresShell.h"
#include "mozilla/dom/BrowsingContext.h"
#include "mozilla/dom/LoadURIOptionsBinding.h"
@ -307,7 +307,7 @@ bool nsWebShellWindow::RequestWindowClose(nsIWidget* aWidget) {
: nullptr);
nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(window);
nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
RefPtr<PresShell> presShell = mDocShell->GetPresShell();
if (!presShell) {
mozilla::DebugOnly<bool> dying;
MOZ_ASSERT(NS_SUCCEEDED(mDocShell->IsBeingDestroyed(&dying)) && dying,