Bug 1520037 - Reuse 'BrowsingContext::TopLevelBrowsingContext()'. r=nika
authorAlastor Wu <alwu@mozilla.com>
Tue, 15 Jan 2019 17:06:12 +0000
changeset 453970 53c350ccfd5b5b39fdef94f4ecf37f29c70aed60
parent 453969 113f3db802c4ed0408d8cca513c595959d1be8a7
child 453971 3965ba4c93b0abad99169221725928084d7f759e
push id76093
push useralwu@mozilla.com
push dateTue, 15 Jan 2019 17:42:19 +0000
treeherderautoland@53c350ccfd5b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika
bugs1520037
milestone66.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 1520037 - Reuse 'BrowsingContext::TopLevelBrowsingContext()'. r=nika GetTop() can simply wrap the result from TopLevelBrowsingContext(). Differential Revision: https://phabricator.services.mozilla.com/D16511
docshell/base/BrowsingContext.cpp
--- a/docshell/base/BrowsingContext.cpp
+++ b/docshell/base/BrowsingContext.cpp
@@ -419,22 +419,17 @@ void BrowsingContext::Focus(ErrorResult&
 void BrowsingContext::Blur(ErrorResult& aError) {
   ContentChild* cc = ContentChild::GetSingleton();
   cc->SendWindowBlur(BrowsingContextId(mBrowsingContextId));
 }
 
 Nullable<WindowProxyHolder> BrowsingContext::GetTop(ErrorResult& aError) {
   // We never return null or throw an error, but the implementation in
   // nsGlobalWindow does and we need to use the same signature.
-  BrowsingContext* bc = this;
-  BrowsingContext* parent;
-  while ((parent = bc->mParent)) {
-    bc = parent;
-  }
-  return WindowProxyHolder(bc);
+  return WindowProxyHolder(TopLevelBrowsingContext());
 }
 
 void BrowsingContext::GetOpener(JSContext* aCx,
                                 JS::MutableHandle<JS::Value> aOpener,
                                 ErrorResult& aError) const {
   auto* opener = GetOpener();
   if (!opener) {
     aOpener.setNull();