Bug 1018778 - Part b: use more early returns in nsDocumentViewer::SyncParentSubDocMap; r=roc
authorMs2ger <ms2ger@gmail.com>
Fri, 06 Jun 2014 10:06:25 +0200
changeset 206279 b9f2aaf3eb9fbd632981d0db8cc919b9a583f19f
parent 206278 95d397955216cb33c5140fdc6e7ba95c1b076c5b
child 206280 bf4000a8fce635ac0950dfaefef09757f954a368
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1018778
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1018778 - Part b: use more early returns in nsDocumentViewer::SyncParentSubDocMap; r=roc
layout/base/nsDocumentViewer.cpp
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -568,39 +568,43 @@ nsresult
 nsDocumentViewer::SyncParentSubDocMap()
 {
   nsCOMPtr<nsIDocShell> docShell(mContainer);
   if (!docShell) {
     return NS_OK;
   }
 
   nsCOMPtr<nsPIDOMWindow> pwin(docShell->GetWindow());
-  nsCOMPtr<Element> element;
-  if (mDocument && pwin) {
-    element = pwin->GetFrameElementInternal();
+  if (!mDocument || !pwin) {
+    return NS_OK;
+  }
+
+  nsCOMPtr<Element> element = pwin->GetFrameElementInternal();
+  if (!element) {
+    return NS_OK;
   }
 
-  if (element) {
-    nsCOMPtr<nsIDocShellTreeItem> parent;
-    docShell->GetParent(getter_AddRefs(parent));
-
-    nsCOMPtr<nsPIDOMWindow> parent_win = parent ? parent->GetWindow() : nullptr;
-    if (parent_win) {
-      nsCOMPtr<nsIDocument> parent_doc = parent_win->GetDoc();
-      if (parent_doc) {
-        if (mDocument && parent_doc->GetSubDocumentFor(element) != mDocument) {
-          mDocument->SuppressEventHandling(nsIDocument::eEvents,
-                                           parent_doc->EventHandlingSuppressed());
-        }
-        return parent_doc->SetSubDocumentFor(element, mDocument);
-      }
-    }
+  nsCOMPtr<nsIDocShellTreeItem> parent;
+  docShell->GetParent(getter_AddRefs(parent));
+
+  nsCOMPtr<nsPIDOMWindow> parent_win = parent ? parent->GetWindow() : nullptr;
+  if (!parent_win) {
+    return NS_OK;
   }
 
-  return NS_OK;
+  nsCOMPtr<nsIDocument> parent_doc = parent_win->GetDoc();
+  if (!parent_doc) {
+    return NS_OK;
+  }
+
+  if (mDocument && parent_doc->GetSubDocumentFor(element) != mDocument) {
+    mDocument->SuppressEventHandling(nsIDocument::eEvents,
+                                     parent_doc->EventHandlingSuppressed());
+  }
+  return parent_doc->SetSubDocumentFor(element, mDocument);
 }
 
 NS_IMETHODIMP
 nsDocumentViewer::SetContainer(nsIDocShell* aContainer)
 {
   mContainer = static_cast<nsDocShell*>(aContainer)->asWeakPtr();
   if (mPresContext) {
     mPresContext->SetContainer(mContainer);