Commit 9d2b24b2 authored by Stefan Zager's avatar Stefan Zager Committed by Commit Bot

Don't compute viewport intersection if parent frame is throttled

If a RemoteFrameView is inside a throttled LocalFrameView with out-of-
date layout, then it's not possible to compute its viewport
intersection. In that case, just propagate an empty intersection (which
is probably correct, because a throttled frame is presumably off
screen).

BUG=711468
R=kenrb@chromium.org

Change-Id: Ie400c407871aab74561b4e34eefece17aa8c3e27
Reviewed-on: https://chromium-review.googlesource.com/1173345Reviewed-by: default avatarKen Buchanan <kenrb@chromium.org>
Commit-Queue: Stefan Zager <szager@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583002}
parent 498eeb39
...@@ -119,7 +119,6 @@ crbug.com/801992 http/tests/misc/iframe-script-modify-attr.html [ Pass Crash ] ...@@ -119,7 +119,6 @@ crbug.com/801992 http/tests/misc/iframe-script-modify-attr.html [ Pass Crash ]
crbug.com/711468 virtual/gpu/fast/canvas/canvas-composite-image.html [ Pass Timeout ] crbug.com/711468 virtual/gpu/fast/canvas/canvas-composite-image.html [ Pass Timeout ]
crbug.com/711468 virtual/gpu/fast/canvas/canvas-scale-strokePath-shadow.html [ Pass Timeout ] crbug.com/711468 virtual/gpu/fast/canvas/canvas-scale-strokePath-shadow.html [ Pass Timeout ]
crbug.com/711468 http/tests/intersection-observer/cross-origin-iframe-with-nesting.html [ Failure ]
crbug.com/807675 http/tests/images/image-decode-in-frame.html [ Crash Failure ] crbug.com/807675 http/tests/images/image-decode-in-frame.html [ Crash Failure ]
......
...@@ -64,7 +64,8 @@ RemoteFrameView* RemoteFrameView::Create(RemoteFrame* remote_frame) { ...@@ -64,7 +64,8 @@ RemoteFrameView* RemoteFrameView::Create(RemoteFrame* remote_frame) {
} }
void RemoteFrameView::UpdateViewportIntersectionsForSubtree() { void RemoteFrameView::UpdateViewportIntersectionsForSubtree() {
if (!remote_frame_->OwnerLayoutObject()) LayoutEmbeddedContent* owner = remote_frame_->OwnerLayoutObject();
if (!owner)
return; return;
LocalFrameView* local_root_view = LocalFrameView* local_root_view =
...@@ -72,38 +73,44 @@ void RemoteFrameView::UpdateViewportIntersectionsForSubtree() { ...@@ -72,38 +73,44 @@ void RemoteFrameView::UpdateViewportIntersectionsForSubtree() {
if (!local_root_view) if (!local_root_view)
return; return;
// Start with rect in remote frame's coordinate space. Then
// mapToVisualRectInAncestorSpace will move it to the local root's coordinate
// space and account for any clip from containing elements such as a
// scrollable div. Passing nullptr as an argument to
// mapToVisualRectInAncestorSpace causes it to be clipped to the viewport,
// even if there are RemoteFrame ancestors in the frame tree.
LayoutRect rect(0, 0, frame_rect_.Width(), frame_rect_.Height());
rect.Move(remote_frame_->OwnerLayoutObject()->ContentBoxOffset());
IntRect viewport_intersection; IntRect viewport_intersection;
if (remote_frame_->OwnerLayoutObject()->MapToVisualRectInAncestorSpace( DocumentLifecycle::LifecycleState parent_state =
nullptr, rect, kUseGeometryMapper)) { owner->GetDocument().Lifecycle().GetState();
IntRect root_visible_rect(IntPoint(), local_root_view->Size());
IntRect intersected_rect = EnclosingIntRect(rect); // If the parent LocalFrameView is throttled and out-of-date, then we can't
intersected_rect.Intersect(root_visible_rect); // get any useful information.
if (parent_state >= DocumentLifecycle::kLayoutClean) {
// Translate the intersection rect from the root frame's coordinate space // Start with rect in remote frame's coordinate space. Then
// to the remote frame's coordinate space. // mapToVisualRectInAncestorSpace will move it to the local root's
FloatRect viewport_intersection_float = // coordinate space and account for any clip from containing elements such
remote_frame_->OwnerLayoutObject() // as a scrollable div. Passing nullptr as an argument to
->AncestorToLocalQuad(local_root_view->GetLayoutView(), // mapToVisualRectInAncestorSpace causes it to be clipped to the viewport,
FloatQuad(intersected_rect), // even if there are RemoteFrame ancestors in the frame tree.
kTraverseDocumentBoundaries | kUseTransforms) LayoutRect rect(0, 0, frame_rect_.Width(), frame_rect_.Height());
.BoundingBox(); rect.Move(owner->ContentBoxOffset());
viewport_intersection_float.Move( if (owner->MapToVisualRectInAncestorSpace(nullptr, rect,
-remote_frame_->OwnerLayoutObject()->ContentBoxOffset()); kUseGeometryMapper)) {
viewport_intersection = EnclosingIntRect(viewport_intersection_float); IntRect root_visible_rect(IntPoint(), local_root_view->Size());
IntRect intersected_rect = EnclosingIntRect(rect);
intersected_rect.Intersect(root_visible_rect);
// Translate the intersection rect from the root frame's coordinate space
// to the remote frame's coordinate space.
FloatRect viewport_intersection_float =
remote_frame_->OwnerLayoutObject()
->AncestorToLocalQuad(
local_root_view->GetLayoutView(), FloatQuad(intersected_rect),
kTraverseDocumentBoundaries | kUseTransforms)
.BoundingBox();
viewport_intersection_float.Move(
-remote_frame_->OwnerLayoutObject()->ContentBoxOffset());
viewport_intersection = EnclosingIntRect(viewport_intersection_float);
}
} }
if (viewport_intersection == last_viewport_intersection_) if (viewport_intersection == last_viewport_intersection_)
return; return;
// TODO(szager): Propagate occlusion information.
last_viewport_intersection_ = viewport_intersection; last_viewport_intersection_ = viewport_intersection;
remote_frame_->Client()->UpdateRemoteViewportIntersection( remote_frame_->Client()->UpdateRemoteViewportIntersection(
viewport_intersection); viewport_intersection);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment