Bug 1668784 - Return empty oop iframe metrics rather than no metrics for OOP iframes that we still haven't positioned and such. r=hiro

This is the right thing to do. If the compositor still hasn't sent
BrowserChild its visible position, then we should just be
non-intersecting, not carry on with the root document state.

Fix the test to not be racy, as the layout / positioning of the iframe
is async with Fission / Chromium site isolation enabled.

Differential Revision: https://phabricator.services.mozilla.com/D92240
This commit is contained in:
Emilio Cobos Álvarez
2020-10-02 21:30:37 +00:00
parent 80e7719885
commit 869f3bcf09
2 changed files with 8 additions and 6 deletions

View File

@@ -447,17 +447,17 @@ static Maybe<OopIframeMetrics> GetOopIframeMetrics(Document& aDocument,
PresShell* rootPresShell = rootDoc->GetPresShell(); PresShell* rootPresShell = rootDoc->GetPresShell();
if (!rootPresShell || rootPresShell->IsDestroying()) { if (!rootPresShell || rootPresShell->IsDestroying()) {
return Nothing(); return Some(OopIframeMetrics{});
} }
nsIFrame* inProcessRootFrame = rootPresShell->GetRootFrame(); nsIFrame* inProcessRootFrame = rootPresShell->GetRootFrame();
if (!inProcessRootFrame) { if (!inProcessRootFrame) {
return Nothing(); return Some(OopIframeMetrics{});
} }
BrowserChild* browserChild = BrowserChild::GetFrom(rootDoc->GetDocShell()); BrowserChild* browserChild = BrowserChild::GetFrom(rootDoc->GetDocShell());
if (!browserChild) { if (!browserChild) {
return Nothing(); return Some(OopIframeMetrics{});
} }
MOZ_DIAGNOSTIC_ASSERT(!browserChild->IsTopLevel()); MOZ_DIAGNOSTIC_ASSERT(!browserChild->IsTopLevel());
@@ -470,7 +470,7 @@ static Maybe<OopIframeMetrics> GetOopIframeMetrics(Document& aDocument,
Maybe<LayoutDeviceRect> remoteDocumentVisibleRect = Maybe<LayoutDeviceRect> remoteDocumentVisibleRect =
browserChild->GetTopLevelViewportVisibleRectInSelfCoords(); browserChild->GetTopLevelViewportVisibleRectInSelfCoords();
if (!remoteDocumentVisibleRect) { if (!remoteDocumentVisibleRect) {
return Nothing(); return Some(OopIframeMetrics{});
} }
return Some(OopIframeMetrics{ return Some(OopIframeMetrics{

View File

@@ -8,8 +8,10 @@
<div id="target" style="width: 100px; height: 100px; position: absolute; right: 0"></div> <div id="target" style="width: 100px; height: 100px; position: absolute; right: 0"></div>
<script> <script>
const observer = new IntersectionObserver(records => { const observer = new IntersectionObserver(records => {
let { rootBounds, intersectionRect } = records[0]; if (records[0].isIntersecting) {
window.top.postMessage({ rootBounds, intersectionRect }, "*"); let { rootBounds, intersectionRect } = records[0];
window.top.postMessage({ rootBounds, intersectionRect }, "*");
}
}, {}); }, {});
observer.observe(document.getElementById("target")); observer.observe(document.getElementById("target"));
</script> </script>