Bug 1507540 part 2. Use more notxpcom attributes in docshell/. r=smaug

This commit is contained in:
Boris Zbarsky 2018-11-19 20:17:53 -05:00
Родитель b88f0dc956
Коммит 71db58cf83
33 изменённых файлов: 129 добавлений и 234 удалений

Просмотреть файл

@ -1115,62 +1115,48 @@ nsDocShell::ValidateOrigin(nsIDocShellTreeItem* aOriginTreeItem,
originIsFile && targetIsFile;
}
nsresult
nsDocShell::GetEldestPresContext(nsPresContext** aPresContext)
nsPresContext*
nsDocShell::GetEldestPresContext()
{
NS_ENSURE_ARG_POINTER(aPresContext);
*aPresContext = nullptr;
nsCOMPtr<nsIContentViewer> viewer = mContentViewer;
nsIContentViewer* viewer = mContentViewer;
while (viewer) {
nsCOMPtr<nsIContentViewer> prevViewer;
viewer->GetPreviousViewer(getter_AddRefs(prevViewer));
nsIContentViewer* prevViewer = viewer->GetPreviousViewer();
if (!prevViewer) {
return viewer->GetPresContext(aPresContext);
return viewer->GetPresContext();
}
viewer = prevViewer;
}
return NS_OK;
return nullptr;
}
NS_IMETHODIMP
nsDocShell::GetPresContext(nsPresContext** aPresContext)
nsPresContext*
nsDocShell::GetPresContext()
{
NS_ENSURE_ARG_POINTER(aPresContext);
*aPresContext = nullptr;
if (!mContentViewer) {
return NS_OK;
return nullptr;
}
return mContentViewer->GetPresContext(aPresContext);
return mContentViewer->GetPresContext();
}
NS_IMETHODIMP_(nsIPresShell*)
nsIPresShell*
nsDocShell::GetPresShell()
{
RefPtr<nsPresContext> presContext;
(void)GetPresContext(getter_AddRefs(presContext));
nsPresContext* presContext = GetPresContext();
return presContext ? presContext->GetPresShell() : nullptr;
}
NS_IMETHODIMP
nsDocShell::GetEldestPresShell(nsIPresShell** aPresShell)
nsIPresShell*
nsDocShell::GetEldestPresShell()
{
nsresult rv = NS_OK;
NS_ENSURE_ARG_POINTER(aPresShell);
*aPresShell = nullptr;
RefPtr<nsPresContext> presContext;
(void)GetEldestPresContext(getter_AddRefs(presContext));
nsPresContext* presContext = GetEldestPresContext();
if (presContext) {
NS_IF_ADDREF(*aPresShell = presContext->GetPresShell());
return presContext->GetPresShell();
}
return rv;
return nullptr;
}
NS_IMETHODIMP
@ -3398,18 +3384,16 @@ nsDocShell::SetTreeOwner(nsIDocShellTreeOwner* aTreeOwner)
return NS_OK;
}
NS_IMETHODIMP
void
nsDocShell::SetChildOffset(int32_t aChildOffset)
{
mChildOffset = aChildOffset;
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::GetChildOffset(int32_t* aChildOffset)
int32_t
nsDocShell::GetChildOffset()
{
*aChildOffset = mChildOffset;
return NS_OK;
return mChildOffset;
}
NS_IMETHODIMP
@ -3946,8 +3930,7 @@ nsDocShell::SetDeviceSizeIsPageSize(bool aValue)
{
if (mDeviceSizeIsPageSize != aValue) {
mDeviceSizeIsPageSize = aValue;
RefPtr<nsPresContext> presContext;
GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = GetPresContext();
if (presContext) {
presContext->MediaFeatureValuesChanged({
MediaFeatureChangeReason::DeviceSizeIsPageSizeChange });
@ -8108,8 +8091,10 @@ nsDocShell::RestoreFromHistory()
// that's about to go away.
if (mContentViewer) {
nsCOMPtr<nsIContentViewer> previousViewer;
mContentViewer->GetPreviousViewer(getter_AddRefs(previousViewer));
// Make sure to hold a strong ref to previousViewer here while we
// drop the reference to it from mContentViewer.
nsCOMPtr<nsIContentViewer> previousViewer =
mContentViewer->GetPreviousViewer();
if (previousViewer) {
mContentViewer->SetPreviousViewer(nullptr);
previousViewer->Destroy();
@ -8819,8 +8804,7 @@ nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer)
// Try to extract the canvas background color from the old
// presentation shell, so we can use it for the next document.
nsCOMPtr<nsIPresShell> shell;
contentViewer->GetPresShell(getter_AddRefs(shell));
nsCOMPtr<nsIPresShell> shell = contentViewer->GetPresShell();
if (shell) {
bgcolor = shell->GetCanvasBackground();
@ -8878,8 +8862,7 @@ nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer)
// Stuff the bgcolor from the old pres shell into the new
// pres shell. This improves page load continuity.
nsCOMPtr<nsIPresShell> shell;
mContentViewer->GetPresShell(getter_AddRefs(shell));
nsCOMPtr<nsIPresShell> shell = mContentViewer->GetPresShell();
if (shell) {
shell->SetCanvasBackground(bgcolor);
@ -9999,12 +9982,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
// If not a zombie, don't stop content until data
// starts arriving from the new URI...
nsCOMPtr<nsIContentViewer> zombieViewer;
if (mContentViewer) {
mContentViewer->GetPreviousViewer(getter_AddRefs(zombieViewer));
}
if (zombieViewer ||
if ((mContentViewer && mContentViewer->GetPreviousViewer()) ||
LOAD_TYPE_HAS_FLAGS(aLoadType, LOAD_FLAGS_STOP_CONTENT)) {
rv = Stop(nsIWebNavigation::STOP_ALL);
} else {
@ -10039,12 +10017,12 @@ nsDocShell::InternalLoad(nsIURI* aURI,
// the case, we need to go ahead and force it into its shentry so we
// can restore it.
if (mContentViewer) {
nsCOMPtr<nsIContentViewer> prevViewer;
mContentViewer->GetPreviousViewer(getter_AddRefs(prevViewer));
nsCOMPtr<nsIContentViewer> prevViewer =
mContentViewer->GetPreviousViewer();
if (prevViewer) {
#ifdef DEBUG
nsCOMPtr<nsIContentViewer> prevPrevViewer;
prevViewer->GetPreviousViewer(getter_AddRefs(prevPrevViewer));
nsCOMPtr<nsIContentViewer> prevPrevViewer =
prevViewer->GetPreviousViewer();
NS_ASSERTION(!prevPrevViewer, "Should never have viewer chain here");
#endif
nsCOMPtr<nsISHEntry> viewerEntry;
@ -14084,11 +14062,9 @@ nsDocShell::SetDisplayMode(uint32_t aDisplayMode)
if (aDisplayMode != mDisplayMode) {
mDisplayMode = aDisplayMode;
RefPtr<nsPresContext> presContext;
if (NS_SUCCEEDED(GetPresContext(getter_AddRefs(presContext)))) {
presContext->MediaFeatureValuesChangedAllDocuments({
MediaFeatureChangeReason::DisplayModeChange });
}
RefPtr<nsPresContext> presContext = GetPresContext();
presContext->MediaFeatureValuesChangedAllDocuments({
MediaFeatureChangeReason::DisplayModeChange });
}
return NS_OK;

Просмотреть файл

@ -886,7 +886,7 @@ private: // member functions
nsresult RefreshURIFromQueue();
nsresult Embed(nsIContentViewer* aContentViewer,
const char* aCommand, nsISupports* aExtraInfo);
nsresult GetEldestPresContext(nsPresContext** aPresContext);
nsPresContext* GetEldestPresContext();
nsresult CheckLoadingPermissions();
nsresult PersistLayoutHistoryState();
nsresult LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType);

Просмотреть файл

@ -422,8 +422,7 @@ nsDocShellTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem,
Set the preferred size on the aShellItem.
*/
RefPtr<nsPresContext> presContext;
mWebBrowser->mDocShell->GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = mWebBrowser->mDocShell->GetPresContext();
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
nsIPresShell* presShell = presContext->GetPresShell();

Просмотреть файл

@ -43,9 +43,9 @@ interface nsIContentViewer : nsISupports
[noscript,notxpcom,nostdcall] void loadStart(in Document aDoc);
void loadComplete(in nsresult aStatus);
[noscript] readonly attribute boolean loadCompleted;
[notxpcom,nostdcall] readonly attribute boolean loadCompleted;
[noscript] readonly attribute boolean isStopped;
[notxpcom,nostdcall] readonly attribute boolean isStopped;
/**
* aPermitUnloadFlags are passed to PermitUnload to indicate what action to take
@ -153,7 +153,7 @@ interface nsIContentViewer : nsISupports
* The previous content viewer, which has been |close|d but not
* |destroy|ed.
*/
[noscript] attribute nsIContentViewer previousViewer;
[notxpcom,nostdcall] attribute nsIContentViewer previousViewer;
void move(in long aX, in long aY);
@ -214,8 +214,10 @@ interface nsIContentViewer : nsISupports
*/
attribute boolean isHidden;
[noscript] readonly attribute nsIPresShellPtr presShell;
[noscript] readonly attribute nsPresContextPtr presContext;
// presShell can be null.
[notxpcom,nostdcall] readonly attribute nsIPresShellPtr presShell;
// presContext can be null.
[notxpcom,nostdcall] readonly attribute nsPresContextPtr presContext;
// aDocument must not be null.
[noscript] void setDocumentInternal(in Document aDocument,
in boolean aForceReuseInnerWindow);

Просмотреть файл

@ -238,18 +238,18 @@ interface nsIDocShell : nsIDocShellTreeItem
/**
* Presentation context for the currently loaded document. This may be null.
*/
[noscript] readonly attribute nsPresContext presContext;
[notxpcom,nostdcall] readonly attribute nsPresContext presContext;
/**
* Presentation shell for the currently loaded document. This may be null.
*/
[noscript,notxpcom] nsIPresShell GetPresShell();
[notxpcom,nostdcall] readonly attribute nsIPresShell presShell;
/**
* Presentation shell for the oldest document, if this docshell is
* currently transitioning between documents.
*/
[noscript] readonly attribute nsIPresShell eldestPresShell;
[notxpcom,nostdcall] readonly attribute nsIPresShell eldestPresShell;
/**
* Content Viewer that is currently loaded for this DocShell. This may
@ -559,7 +559,7 @@ interface nsIDocShell : nsIDocShellTreeItem
* The original offset of this child in its container. This property is -1 for
* dynamically added docShells.
*/
[noscript] attribute long childOffset;
[notxpcom,nostdcall] attribute long childOffset;
/**
* Find out whether the docshell is currently in the middle of a page

Просмотреть файл

@ -290,8 +290,7 @@ FuzzingFunctions::SynthesizeKeyboardEvents(const GlobalObject&,
return;
}
RefPtr<nsPresContext> presContext;
docShell->GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = docShell->GetPresContext();
if (NS_WARN_IF(!presContext)) {
aRv.Throw(NS_ERROR_FAILURE);
return;

Просмотреть файл

@ -392,11 +392,7 @@ TextInputProcessor::BeginInputTransactionInternal(
if (NS_WARN_IF(!docShell)) {
return NS_ERROR_FAILURE;
}
RefPtr<nsPresContext> presContext;
nsresult rv = docShell->GetPresContext(getter_AddRefs(presContext));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
RefPtr<nsPresContext> presContext = docShell->GetPresContext();
if (NS_WARN_IF(!presContext)) {
return NS_ERROR_FAILURE;
}
@ -445,6 +441,7 @@ TextInputProcessor::BeginInputTransactionInternal(
}
}
nsresult rv = NS_OK;
if (aForTests) {
bool isAPZAware = gfxPrefs::TestEventsAsyncEnabled();
rv = dispatcher->BeginTestInputTransaction(this, isAPZAware);

Просмотреть файл

@ -6628,14 +6628,11 @@ nsContentUtils::IsSubDocumentTabbable(nsIContent* aContent)
return false;
}
nsCOMPtr<nsIContentViewer> zombieViewer;
contentViewer->GetPreviousViewer(getter_AddRefs(zombieViewer));
// If there are 2 viewers for the current docshell, that
// means the current document may be a zombie document.
// While load and pageshow events are dispatched, zombie viewer is the old,
// to be hidden document.
if (zombieViewer) {
if (contentViewer->GetPreviousViewer()) {
bool inOnLoad = false;
docShell->GetIsExecutingOnLoadHandler(&inOnLoad);
return inOnLoad;

Просмотреть файл

@ -243,9 +243,7 @@ nsDOMWindowUtils::GetPresContext()
nsIDocShell *docShell = window->GetDocShell();
if (!docShell)
return nullptr;
RefPtr<nsPresContext> presContext;
docShell->GetPresContext(getter_AddRefs(presContext));
return presContext;
return docShell->GetPresContext();
}
nsIDocument*

Просмотреть файл

@ -818,8 +818,7 @@ nsFrameLoader::MarginsChanged(uint32_t aMarginWidth,
// Trigger a restyle if there's a prescontext
// FIXME: This could do something much less expensive.
RefPtr<nsPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = mDocShell->GetPresContext();
if (presContext)
// rebuild, because now the same nsMappedAttributes* will produce
// a different style

Просмотреть файл

@ -3112,8 +3112,7 @@ nsGlobalWindowOuter::DevToCSSIntPixels(int32_t px)
if (!mDocShell)
return px; // assume 1:1
RefPtr<nsPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = mDocShell->GetPresContext();
if (!presContext)
return px;
@ -3126,8 +3125,7 @@ nsGlobalWindowOuter::CSSToDevIntPixels(int32_t px)
if (!mDocShell)
return px; // assume 1:1
RefPtr<nsPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = mDocShell->GetPresContext();
if (!presContext)
return px;
@ -3140,8 +3138,7 @@ nsGlobalWindowOuter::DevToCSSIntPixels(nsIntSize px)
if (!mDocShell)
return px; // assume 1:1
RefPtr<nsPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = mDocShell->GetPresContext();
if (!presContext)
return px;
@ -3156,8 +3153,7 @@ nsGlobalWindowOuter::CSSToDevIntPixels(nsIntSize px)
if (!mDocShell)
return px; // assume 1:1
RefPtr<nsPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = mDocShell->GetPresContext();
if (!presContext)
return px;
@ -3173,8 +3169,7 @@ nsGlobalWindowOuter::GetInnerSize(CSSIntSize& aSize)
NS_ENSURE_STATE(mDocShell);
RefPtr<nsPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = mDocShell->GetPresContext();
RefPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
if (!presContext || !presShell) {
@ -3402,8 +3397,7 @@ nsGlobalWindowOuter::GetScreenXY(CallerType aCallerType, ErrorResult& aError)
int32_t x = 0, y = 0;
aError = treeOwnerAsWin->GetPosition(&x, &y); // LayoutDevice px values
RefPtr<nsPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = mDocShell->GetPresContext();
if (!presContext) {
return CSSIntPoint(x, y);
}
@ -3493,8 +3487,7 @@ nsGlobalWindowOuter::GetDevicePixelRatioOuter(CallerType aCallerType)
return 1.0;
}
RefPtr<nsPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = mDocShell->GetPresContext();
if (!presContext) {
return 1.0;
}
@ -3647,8 +3640,7 @@ nsGlobalWindowOuter::SetDocShellWidthAndHeight(int32_t aInnerWidth, int32_t aInn
void
nsGlobalWindowOuter::SetCSSViewportWidthAndHeight(nscoord aInnerWidth, nscoord aInnerHeight)
{
RefPtr<nsPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = mDocShell->GetPresContext();
nsRect shellArea = presContext->GetVisibleArea();
shellArea.SetHeight(aInnerHeight);
@ -4838,7 +4830,7 @@ nsGlobalWindowOuter::FocusOuter(ErrorResult& aError)
}
if (lookForPresShell) {
mDocShell->GetEldestPresShell(getter_AddRefs(presShell));
presShell = mDocShell->GetEldestPresShell();
}
nsCOMPtr<nsIDocShellTreeItem> parentDsti;
@ -7475,7 +7467,7 @@ nsGlobalWindowOuter::SetCursorOuter(const nsAString& aCursor, ErrorResult& aErro
RefPtr<nsPresContext> presContext;
if (mDocShell) {
mDocShell->GetPresContext(getter_AddRefs(presContext));
presContext = mDocShell->GetPresContext();
}
if (presContext) {
@ -7649,8 +7641,7 @@ void
nsGlobalWindowOuter::CheckForDPIChange()
{
if (mDocShell) {
RefPtr<nsPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = mDocShell->GetPresContext();
if (presContext) {
if (presContext->DeviceContext()->CheckDPIChange()) {
presContext->UIResolutionChanged();

Просмотреть файл

@ -399,8 +399,7 @@ NS_HandleScriptError(nsIScriptGlobalObject *aScriptGlobal,
nsCOMPtr<nsPIDOMWindowInner> win(do_QueryInterface(aScriptGlobal));
nsIDocShell *docShell = win ? win->GetDocShell() : nullptr;
if (docShell) {
RefPtr<nsPresContext> presContext;
docShell->GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = docShell->GetPresContext();
static int32_t errorDepth; // Recursion prevention
++errorDepth;
@ -449,8 +448,7 @@ public:
AutoRestore<bool> recursionGuard(sHandlingScriptError);
sHandlingScriptError = true;
RefPtr<nsPresContext> presContext;
win->GetDocShell()->GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = win->GetDocShell()->GetPresContext();
RootedDictionary<ErrorEventInit> init(rootingCx);
init.mCancelable = true;

Просмотреть файл

@ -5288,7 +5288,7 @@ CanvasRenderingContext2D::DrawWindow(nsGlobalWindowInner& aWindow, double aX,
RefPtr<nsPresContext> presContext;
nsIDocShell* docshell = aWindow.GetDocShell();
if (docshell) {
docshell->GetPresContext(getter_AddRefs(presContext));
presContext = docshell->GetPresContext();
}
if (!presContext) {
aError.Throw(NS_ERROR_FAILURE);

Просмотреть файл

@ -4363,8 +4363,7 @@ EventStateManager::NotifyMouseOut(WidgetMouseEvent* aMouseEvent,
if (subdocFrame) {
nsIDocShell* docshell = subdocFrame->GetDocShell();
if (docshell) {
RefPtr<nsPresContext> presContext;
docshell->GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = docshell->GetPresContext();
if (presContext) {
EventStateManager* kidESM = presContext->EventStateManager();

Просмотреть файл

@ -1806,8 +1806,7 @@ void
IMEContentObserver::IMENotificationSender::Dispatch(nsIDocShell* aDocShell)
{
if (XRE_IsContentProcess() && aDocShell) {
RefPtr<nsPresContext> presContext;
aDocShell->GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = aDocShell->GetPresContext();
if (presContext) {
nsRefreshDriver* refreshDriver = presContext->RefreshDriver();
if (refreshDriver) {

Просмотреть файл

@ -285,8 +285,7 @@ TouchEvent::PrefEnabled(nsIDocShell* aDocShell)
if (enabled && aDocShell) {
// APZ might be disabled on this particular widget, in which case
// TouchEvent support will also be disabled. Try to detect that.
RefPtr<nsPresContext> pc;
aDocShell->GetPresContext(getter_AddRefs(pc));
RefPtr<nsPresContext> pc = aDocShell->GetPresContext();
if (pc && pc->GetRootWidget()) {
enabled &= pc->GetRootWidget()->AsyncPanZoomEnabled();
}

Просмотреть файл

@ -323,8 +323,7 @@ nsGenericHTMLFrameElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
if (cur != val) {
scrollable->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_X, val);
scrollable->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_Y, val);
RefPtr<nsPresContext> presContext;
docshell->GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = docshell->GetPresContext();
nsIPresShell* shell = presContext ? presContext->GetPresShell() : nullptr;
nsIFrame* rootScroll = shell ? shell->GetRootScrollFrame() : nullptr;
if (rootScroll) {

Просмотреть файл

@ -320,15 +320,13 @@ void MediaEngineTabVideoSource::Draw() {
nsCOMPtr<nsIPresShell> presShell;
if (mWindow) {
RefPtr<nsPresContext> presContext;
nsIDocShell* docshell = mWindow->GetDocShell();
if (docshell) {
docshell->GetPresContext(getter_AddRefs(presContext));
presShell = docshell->GetPresShell();
}
if (!presContext) {
if (!presShell) {
return;
}
presShell = presContext->PresShell();
}
RefPtr<layers::ImageContainer> container =

Просмотреть файл

@ -77,7 +77,7 @@ PaintFragment::Record(nsIDocShell* aDocShell,
// Grab the presentation shell to render
RefPtr<nsPresContext> presContext;
if (aDocShell) {
aDocShell->GetPresContext(getter_AddRefs(presContext));
presContext = aDocShell->GetPresContext();
}
if (!presContext) {
PF_LOG("Couldn't find PresContext.\n");

Просмотреть файл

@ -154,9 +154,7 @@ gfxSVGGlyphsDocument::SetupPresentation()
NS_ENSURE_SUCCESS(rv, rv);
}
nsCOMPtr<nsIPresShell> presShell;
rv = viewer->GetPresShell(getter_AddRefs(presShell));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPresShell> presShell = viewer->GetPresShell();
if (!presShell->DidInitialize()) {
rv = presShell->Initialize();
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -208,8 +208,7 @@ SVGDocumentWrapper::SetCurrentTime(float aTime)
void
SVGDocumentWrapper::TickRefreshDriver()
{
nsCOMPtr<nsIPresShell> presShell;
mViewer->GetPresShell(getter_AddRefs(presShell));
nsCOMPtr<nsIPresShell> presShell = mViewer->GetPresShell();
if (presShell) {
nsPresContext* presContext = presShell->GetPresContext();
if (presContext) {

Просмотреть файл

@ -71,15 +71,10 @@ public:
nsIFrame* GetRootLayoutFrame();
/**
* Returns (by reference) the nsIPresShell for the wrapped document.
*
* @param[out] aPresShell On success, this will be populated with a pointer
* to the wrapped document's nsIPresShell.
*
* @return NS_OK on success, or an error code on failure.
* Returns the nsIPresShell for the wrapped document.
*/
inline nsresult GetPresShell(nsIPresShell** aPresShell)
{ return mViewer->GetPresShell(aPresShell); }
inline nsIPresShell* GetPresShell()
{ return mViewer->GetPresShell(); }
/**
* Modifier to update the viewport dimensions of the wrapped document. This

Просмотреть файл

@ -289,12 +289,8 @@ SVGDrawingCallback::operator()(gfxContext* aContext,
MOZ_ASSERT(mSVGDocumentWrapper, "need an SVGDocumentWrapper");
// Get (& sanity-check) the helper-doc's presShell
nsCOMPtr<nsIPresShell> presShell;
if (NS_FAILED(mSVGDocumentWrapper->GetPresShell(getter_AddRefs(presShell)))) {
NS_WARNING("Unable to draw -- presShell lookup failed");
return false;
}
MOZ_ASSERT(presShell, "GetPresShell succeeded but returned null");
nsCOMPtr<nsIPresShell> presShell = mSVGDocumentWrapper->GetPresShell();
MOZ_ASSERT(presShell, "GetPresShell returned null for an SVG image?");
#ifdef MOZ_GECKO_PROFILER
nsIDocument* doc = presShell->GetDocument();

Просмотреть файл

@ -412,9 +412,7 @@ private:
bool ShouldAttachToTopLevel();
protected:
// These return the current shell/prescontext etc.
nsIPresShell* GetPresShell();
nsPresContext* GetPresContext();
// Returns the current viewmanager. Might be null.
nsViewManager* GetViewManager();
void DetachFromTopLevelWidget();
@ -1235,18 +1233,16 @@ nsDocumentViewer::LoadComplete(nsresult aStatus)
return rv;
}
NS_IMETHODIMP
nsDocumentViewer::GetLoadCompleted(bool *aOutLoadCompleted)
bool
nsDocumentViewer::GetLoadCompleted()
{
*aOutLoadCompleted = mLoaded;
return NS_OK;
return mLoaded;
}
NS_IMETHODIMP
nsDocumentViewer::GetIsStopped(bool* aOutIsStopped)
bool
nsDocumentViewer::GetIsStopped()
{
*aOutIsStopped = mStopped;
return NS_OK;
return mStopped;
}
NS_IMETHODIMP
@ -1558,15 +1554,13 @@ AttachContainerRecurse(nsIDocShell* aShell)
if (doc) {
doc->SetContainer(static_cast<nsDocShell*>(aShell));
}
RefPtr<nsPresContext> pc;
viewer->GetPresContext(getter_AddRefs(pc));
RefPtr<nsPresContext> pc = viewer->GetPresContext();
if (pc) {
pc->SetContainer(static_cast<nsDocShell*>(aShell));
nsCOMPtr<nsILinkHandler> handler = do_QueryInterface(aShell);
pc->SetLinkHandler(handler);
}
nsCOMPtr<nsIPresShell> presShell;
viewer->GetPresShell(getter_AddRefs(presShell));
nsCOMPtr<nsIPresShell> presShell = viewer->GetPresShell();
if (presShell) {
presShell->SetForwardingContainer(WeakPtr<nsDocShell>());
}
@ -1728,13 +1722,11 @@ DetachContainerRecurse(nsIDocShell *aShell)
if (doc) {
doc->SetContainer(nullptr);
}
RefPtr<nsPresContext> pc;
viewer->GetPresContext(getter_AddRefs(pc));
RefPtr<nsPresContext> pc = viewer->GetPresContext();
if (pc) {
pc->Detach();
}
nsCOMPtr<nsIPresShell> presShell;
viewer->GetPresShell(getter_AddRefs(presShell));
nsCOMPtr<nsIPresShell> presShell = viewer->GetPresShell();
if (presShell) {
auto weakShell = static_cast<nsDocShell*>(aShell);
presShell->SetForwardingContainer(weakShell);
@ -2093,22 +2085,6 @@ nsDocumentViewer::GetViewManager()
return mViewManager;
}
NS_IMETHODIMP
nsDocumentViewer::GetPresShell(nsIPresShell** aResult)
{
nsIPresShell* shell = GetPresShell();
NS_IF_ADDREF(*aResult = shell);
return NS_OK;
}
NS_IMETHODIMP
nsDocumentViewer::GetPresContext(nsPresContext** aResult)
{
nsPresContext* pc = GetPresContext();
NS_IF_ADDREF(*aResult = pc);
return NS_OK;
}
NS_IMETHODIMP
nsDocumentViewer::GetBounds(nsIntRect& aResult)
{
@ -2117,15 +2093,13 @@ nsDocumentViewer::GetBounds(nsIntRect& aResult)
return NS_OK;
}
NS_IMETHODIMP
nsDocumentViewer::GetPreviousViewer(nsIContentViewer** aViewer)
nsIContentViewer*
nsDocumentViewer::GetPreviousViewer()
{
*aViewer = mPreviousViewer;
NS_IF_ADDREF(*aViewer);
return NS_OK;
return mPreviousViewer;
}
NS_IMETHODIMP
void
nsDocumentViewer::SetPreviousViewer(nsIContentViewer* aViewer)
{
// NOTE: |Show| sets |mPreviousViewer| to null without calling this
@ -2145,8 +2119,10 @@ nsDocumentViewer::SetPreviousViewer(nsIContentViewer* aViewer)
// It's very important that if this ever gets changed the code
// before the RestorePresentation call in nsDocShell::InternalLoad
// be changed accordingly.
nsCOMPtr<nsIContentViewer> prevViewer;
aViewer->GetPreviousViewer(getter_AddRefs(prevViewer));
//
// Make sure we hold a strong ref to prevViewer here, since we'll
// tell aViewer to drop it.
nsCOMPtr<nsIContentViewer> prevViewer = aViewer->GetPreviousViewer();
if (prevViewer) {
aViewer->SetPreviousViewer(nullptr);
aViewer->Destroy();
@ -2155,7 +2131,6 @@ nsDocumentViewer::SetPreviousViewer(nsIContentViewer* aViewer)
}
mPreviousViewer = aViewer;
return NS_OK;
}
NS_IMETHODIMP
@ -2876,8 +2851,7 @@ NS_IMETHODIMP nsDocumentViewer::ScrollToNode(nsINode* aNode)
{
NS_ENSURE_ARG(aNode);
NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);
nsCOMPtr<nsIPresShell> presShell;
NS_ENSURE_SUCCESS(GetPresShell(getter_AddRefs(presShell)), NS_ERROR_FAILURE);
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
// Get the nsIContent interface, because that's what we need to
// get the primary frame
@ -3521,8 +3495,7 @@ nsDocumentViewer::GetContentSizeInternal(int32_t* aWidth, int32_t* aHeight,
{
NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);
nsCOMPtr<nsIPresShell> presShell;
GetPresShell(getter_AddRefs(presShell));
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
// Flush out all content and style updates. We can't use a resize reflow
@ -3545,8 +3518,7 @@ nsDocumentViewer::GetContentSizeInternal(int32_t* aWidth, int32_t* aHeight,
nsIPresShell::ResizeReflowOptions::eBSizeLimit);
NS_ENSURE_SUCCESS(rv, rv);
RefPtr<nsPresContext> presContext;
GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = GetPresContext();
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
// Protect against bogus returns here
@ -3582,8 +3554,7 @@ NS_IMETHODIMP
nsDocumentViewer::GetContentSizeConstrained(int32_t aMaxWidth, int32_t aMaxHeight,
int32_t* aWidth, int32_t* aHeight)
{
RefPtr<nsPresContext> presContext;
GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = GetPresContext();
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
nscoord maxWidth = NS_UNCONSTRAINEDSIZE;
@ -3798,8 +3769,7 @@ nsDocViewerFocusListener::HandleEvent(Event* aEvent)
{
NS_ENSURE_STATE(mDocViewer);
nsCOMPtr<nsIPresShell> shell;
mDocViewer->GetPresShell(getter_AddRefs(shell));
nsCOMPtr<nsIPresShell> shell = mDocViewer->GetPresShell();
NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE);
nsCOMPtr<nsISelectionController> selCon = do_QueryInterface(shell);

Просмотреть файл

@ -7647,8 +7647,7 @@ nsLayoutUtils::GetDeviceContextForScreenInfo(nsPIDOMWindowOuter* aWindow)
win->EnsureSizeAndPositionUpToDate();
RefPtr<nsPresContext> presContext;
docShell->GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = docShell->GetPresContext();
if (presContext) {
nsDeviceContext* context = presContext->DeviceContext();
if (context) {
@ -9215,9 +9214,8 @@ MaybeReflowForInflationScreenSizeChange(nsPresContext *aPresContext)
nsTArray<nsCOMPtr<nsIContentViewer> > array;
cv->AppendSubtree(array);
for (uint32_t i = 0, iEnd = array.Length(); i < iEnd; ++i) {
nsCOMPtr<nsIPresShell> shell;
nsCOMPtr<nsIContentViewer> cv = array[i];
cv->GetPresShell(getter_AddRefs(shell));
nsCOMPtr<nsIPresShell> shell = cv->GetPresShell();
if (shell) {
nsIFrame *rootFrame = shell->GetRootFrame();
if (rootFrame) {

Просмотреть файл

@ -2068,15 +2068,11 @@ nsPresContext::EnsureVisible()
nsCOMPtr<nsIContentViewer> cv;
docShell->GetContentViewer(getter_AddRefs(cv));
// Make sure this is the content viewer we belong with
if (cv) {
RefPtr<nsPresContext> currentPresContext;
cv->GetPresContext(getter_AddRefs(currentPresContext));
if (currentPresContext == this) {
// OK, this is us. We want to call Show() on the content viewer.
nsresult result = cv->Show();
if (NS_SUCCEEDED(result)) {
return true;
}
if (cv && cv->GetPresContext() == this) {
// OK, this is us. We want to call Show() on the content viewer.
nsresult result = cv->Show();
if (NS_SUCCEEDED(result)) {
return true;
}
}
}

Просмотреть файл

@ -4589,8 +4589,8 @@ ScrollFrameHelper::GetPageLoadingState() -> LoadingState
if (ds) {
nsCOMPtr<nsIContentViewer> cv;
ds->GetContentViewer(getter_AddRefs(cv));
cv->GetLoadCompleted(&loadCompleted);
cv->GetIsStopped(&stopped);
loadCompleted = cv->GetLoadCompleted();
stopped = cv->GetIsStopped();
}
return loadCompleted ? (stopped ? LoadingState::Stopped : LoadingState::Loaded)
: LoadingState::Loading;

Просмотреть файл

@ -1212,8 +1212,7 @@ EndSwapDocShellsForDocument(nsIDocument* aDocument, void*)
nsCOMPtr<nsIContentViewer> cv;
ds->GetContentViewer(getter_AddRefs(cv));
while (cv) {
RefPtr<nsPresContext> pc;
cv->GetPresContext(getter_AddRefs(pc));
RefPtr<nsPresContext> pc = cv->GetPresContext();
if (pc && pc->GetPresShell()) {
pc->GetPresShell()->SetNeverPainting(ds->IsInvisible());
}
@ -1222,9 +1221,7 @@ EndSwapDocShellsForDocument(nsIDocument* aDocument, void*)
nsView* v = cv->FindContainerView();
dc->Init(v ? v->GetNearestWidget(nullptr) : nullptr);
}
nsCOMPtr<nsIContentViewer> prev;
cv->GetPreviousViewer(getter_AddRefs(prev));
cv = prev;
cv = cv->GetPreviousViewer();
}
}

Просмотреть файл

@ -41,15 +41,13 @@ doc_viewer(nsIDocShell *aDocShell)
return result.forget();
}
static already_AddRefed<nsIPresShell>
static nsIPresShell*
pres_shell(nsIDocShell *aDocShell)
{
nsCOMPtr<nsIContentViewer> cv = doc_viewer(aDocShell);
if (!cv)
return nullptr;
nsCOMPtr<nsIPresShell> result;
cv->GetPresShell(getter_AddRefs(result));
return result.forget();
return cv->GetPresShell();
}
static nsViewManager*

Просмотреть файл

@ -111,10 +111,7 @@ nsSessionStoreUtils::ForEachNonDynamicChildFrame(mozIDOMWindowProxy* aWindow,
continue;
}
int32_t childOffset = 0;
rv = childDocShell->GetChildOffset(&childOffset);
NS_ENSURE_SUCCESS(rv, rv);
int32_t childOffset = childDocShell->GetChildOffset();
aCallback->HandleFrame(item->GetWindow(), childOffset);
}

Просмотреть файл

@ -785,8 +785,7 @@ nsTypeAheadFind::GetSearchContainers(nsISupports *aContainer,
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
RefPtr<nsPresContext> presContext;
docShell->GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = docShell->GetPresContext();
if (!presShell || !presContext)
return NS_ERROR_FAILURE;

Просмотреть файл

@ -129,10 +129,13 @@ class ThumbnailHelper final
{
nsCOMPtr<nsPIDOMWindowOuter> win = nsPIDOMWindowOuter::From(aWindow);
nsCOMPtr<nsIDocShell> docShell = win->GetDocShell();
RefPtr<nsPresContext> presContext;
if (!docShell) {
return nullptr;
}
if (!docShell || NS_FAILED(docShell->GetPresContext(
getter_AddRefs(presContext))) || !presContext) {
RefPtr<nsPresContext> presContext = docShell->GetPresContext();
if (!presContext) {
return nullptr;
}

Просмотреть файл

@ -712,8 +712,7 @@ bool nsWebShellWindow::ExecuteCloseHandler()
nsCOMPtr<nsIContentViewer> contentViewer;
mDocShell->GetContentViewer(getter_AddRefs(contentViewer));
if (contentViewer) {
RefPtr<nsPresContext> presContext;
contentViewer->GetPresContext(getter_AddRefs(presContext));
RefPtr<nsPresContext> presContext = contentViewer->GetPresContext();
nsEventStatus status = nsEventStatus_eIgnore;
WidgetMouseEvent event(true, eClose, nullptr,