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 ]
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 http/tests/intersection-observer/cross-origin-iframe-with-nesting.html [ Failure ]
crbug.com/807675 http/tests/images/image-decode-in-frame.html [ Crash Failure ]
......
......@@ -64,7 +64,8 @@ RemoteFrameView* RemoteFrameView::Create(RemoteFrame* remote_frame) {
}
void RemoteFrameView::UpdateViewportIntersectionsForSubtree() {
if (!remote_frame_->OwnerLayoutObject())
LayoutEmbeddedContent* owner = remote_frame_->OwnerLayoutObject();
if (!owner)
return;
LocalFrameView* local_root_view =
......@@ -72,38 +73,44 @@ void RemoteFrameView::UpdateViewportIntersectionsForSubtree() {
if (!local_root_view)
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;
if (remote_frame_->OwnerLayoutObject()->MapToVisualRectInAncestorSpace(
nullptr, rect, kUseGeometryMapper)) {
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);
DocumentLifecycle::LifecycleState parent_state =
owner->GetDocument().Lifecycle().GetState();
// If the parent LocalFrameView is throttled and out-of-date, then we can't
// get any useful information.
if (parent_state >= DocumentLifecycle::kLayoutClean) {
// 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(owner->ContentBoxOffset());
if (owner->MapToVisualRectInAncestorSpace(nullptr, rect,
kUseGeometryMapper)) {
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_)
return;
// TODO(szager): Propagate occlusion information.
last_viewport_intersection_ = viewport_intersection;
remote_frame_->Client()->UpdateRemoteViewportIntersection(
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