Bug 1440537 - SwapFrameLoaders should flush frames. r=bzbarsky
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 29 Apr 2019 18:45:03 +0000
changeset 530605 f6766ba4ac77c6757c4e4db7598a2e685f23fcf6
parent 530604 a558a615474857b1b6ff193166d2746c8ecb1358
child 530606 87f038262ac3d4431a569c1fad9bee5668a332de
child 530664 49514be011cabfc71a4f65f3c0a87c8b413c469f
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs1440537
milestone68.0a1
first release with
nightly linux32
f6766ba4ac77 / 68.0a1 / 20190429215338 / files
nightly linux64
f6766ba4ac77 / 68.0a1 / 20190429215338 / files
nightly mac
f6766ba4ac77 / 68.0a1 / 20190429215338 / files
nightly win32
f6766ba4ac77 / 68.0a1 / 20190429215338 / files
nightly win64
f6766ba4ac77 / 68.0a1 / 20190429215338 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1440537 - SwapFrameLoaders should flush frames. r=bzbarsky swapFrameLoaders relies on frame information, but doesn't ensure it's up-to-date. The test for this (test_swapFrameLoaders.xul) is relying right now on one of flushes from the inner documents to also flush the parent document and thus ensure there's a frame created. With the patch for this bug, that flush no longer propagates to the parent document, and the test fails because we throw in: https://searchfox.org/mozilla-central/rev/66086345467c69685434dd1c5177b30a7511b1a5/dom/base/nsFrameLoader.cpp#1634 This API could probably be made to work without that requirement, but it's probably not worth it. For now just flush. Differential Revision: https://phabricator.services.mozilla.com/D29160
dom/html/nsGenericHTMLFrameElement.cpp
dom/xul/XULFrameElement.cpp
--- a/dom/html/nsGenericHTMLFrameElement.cpp
+++ b/dom/html/nsGenericHTMLFrameElement.cpp
@@ -168,16 +168,21 @@ void nsGenericHTMLFrameElement::SwapFram
 
 void nsGenericHTMLFrameElement::SwapFrameLoaders(
     XULFrameElement& aOtherLoaderOwner, ErrorResult& rv) {
   aOtherLoaderOwner.SwapFrameLoaders(this, rv);
 }
 
 void nsGenericHTMLFrameElement::SwapFrameLoaders(
     nsFrameLoaderOwner* aOtherLoaderOwner, mozilla::ErrorResult& rv) {
+  if (RefPtr<Document> doc = GetComposedDoc()) {
+    // SwapWithOtherLoader relies on frames being up-to-date.
+    doc->FlushPendingNotifications(FlushType::Frames);
+  }
+
   RefPtr<nsFrameLoader> loader = GetFrameLoader();
   RefPtr<nsFrameLoader> otherLoader = aOtherLoaderOwner->GetFrameLoader();
   if (!loader || !otherLoader) {
     rv.Throw(NS_ERROR_NOT_IMPLEMENTED);
     return;
   }
 
   rv = loader->SwapWithOtherLoader(otherLoader, this, aOtherLoaderOwner);
--- a/dom/xul/XULFrameElement.cpp
+++ b/dom/xul/XULFrameElement.cpp
@@ -117,16 +117,21 @@ void XULFrameElement::SwapFrameLoaders(X
     return;
   }
 
   aOtherLoaderOwner.SwapFrameLoaders(this, rv);
 }
 
 void XULFrameElement::SwapFrameLoaders(nsFrameLoaderOwner* aOtherLoaderOwner,
                                        mozilla::ErrorResult& rv) {
+  if (RefPtr<Document> doc = GetComposedDoc()) {
+    // SwapWithOtherLoader relies on frames being up-to-date.
+    doc->FlushPendingNotifications(FlushType::Frames);
+  }
+
   RefPtr<nsFrameLoader> loader = GetFrameLoader();
   RefPtr<nsFrameLoader> otherLoader = aOtherLoaderOwner->GetFrameLoader();
   if (!loader || !otherLoader) {
     rv.Throw(NS_ERROR_NOT_IMPLEMENTED);
     return;
   }
 
   rv = loader->SwapWithOtherLoader(otherLoader, this, aOtherLoaderOwner);