From e78e313fa57186a19428fe49c5d3c7fafe35169a Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Mon, 4 Apr 2016 02:59:15 -0500 Subject: [PATCH] Bug 1259246. Simplify nsDocumentViewer::FindContainerView. r=dholbert Turn a series of nested if's into early return if's with no nesting so it is easier to follow. --- layout/base/nsDocumentViewer.cpp | 64 ++++++++++++++++---------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index e1795098ff60..51561ede87b3 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -2451,40 +2451,40 @@ nsDocumentViewer::DetachFromTopLevelWidget() nsView* nsDocumentViewer::FindContainerView() { - nsView* containerView = nullptr; - - if (mContainer) { - nsCOMPtr docShell(mContainer); - nsCOMPtr pwin(docShell->GetWindow()); - if (pwin) { - nsCOMPtr containerElement = pwin->GetFrameElementInternal(); - if (!containerElement) { - return nullptr; - } - - nsIFrame* subdocFrame = nsLayoutUtils::GetRealPrimaryFrameFor(containerElement); - if (subdocFrame) { - // subdocFrame might not be a subdocument frame; the frame - // constructor can treat a as an inline in some XBL - // cases. Treat that as display:none, the document is not - // displayed. - if (subdocFrame->GetType() == nsGkAtoms::subDocumentFrame) { - NS_ASSERTION(subdocFrame->GetView(), "Subdoc frames must have views"); - nsView* innerView = - static_cast(subdocFrame)->EnsureInnerView(); - containerView = innerView; - } else { - NS_WARN_IF_FALSE(!subdocFrame->GetType(), - "Subdocument container has non-subdocument frame"); - } - } else { - // XXX Silenced by default in bug 1175289 - LAYOUT_WARNING("Subdocument container has no frame"); - } - } + if (!mContainer) { + return nullptr; } - return containerView; + nsCOMPtr docShell(mContainer); + nsCOMPtr pwin(docShell->GetWindow()); + if (!pwin) { + return nullptr; + } + + nsCOMPtr containerElement = pwin->GetFrameElementInternal(); + if (!containerElement) { + return nullptr; + } + + nsIFrame* subdocFrame = nsLayoutUtils::GetRealPrimaryFrameFor(containerElement); + if (!subdocFrame) { + // XXX Silenced by default in bug 1175289 + LAYOUT_WARNING("Subdocument container has no frame"); + return nullptr; + } + + // subdocFrame might not be a subdocument frame; the frame + // constructor can treat a as an inline in some XBL + // cases. Treat that as display:none, the document is not + // displayed. + if (subdocFrame->GetType() != nsGkAtoms::subDocumentFrame) { + NS_WARN_IF_FALSE(!subdocFrame->GetType(), + "Subdocument container has non-subdocument frame"); + return nullptr; + } + + NS_ASSERTION(subdocFrame->GetView(), "Subdoc frames must have views"); + return static_cast(subdocFrame)->EnsureInnerView(); } nsresult