Commit f9cbcfa4 authored by David Bokan's avatar David Bokan Committed by Commit Bot

Fix URL bar clipping with min-scale > 1

In https://crrev.com/bf23241073ef806810f2aa90bbb153b639239c81, I rewrote
UpdateViewportContainerSizes to be compatible with Blink generated
property trees. As part of this, we now make use of the outer viewport's
clip node. However, unlike the layer's bounds, the clip node's bounds
do not include the resize we perform to match the content width of the
page.

In WebViewImpl::ResizeAfterLayout, we resize the FrameView (and thus the
LayoutView) after we do a layout. We do this so that the layout viewport
is sized according to the minimum possible page scale (so pos: fixed
Elements are in the correct locations when the page is fully zoomed
out).

However, this isn't accounted for correctly in the ClipNode. This CL
applies the minimum scale to the clip bounds directly when computing the
clip as a result of URL bar movement. We should really fix the place
where the ClipNode is computed but this CL will need to be merged so
this is a minimal fix.

Note also, the ClipNode is correctly calculated with blink-gen-property-
trees enabled. This fix is thus only required when that's turned off.

Bug: 898757
Change-Id: I9c8ea517c2e98b6b2ac552b1ae64bd1675547614
Reviewed-on: https://chromium-review.googlesource.com/c/1313278Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604932}
parent 49429f43
......@@ -2509,34 +2509,40 @@ void LayerTreeHostImpl::UpdateViewportContainerSizes() {
// for changes in the size (e.g. browser controls) since the last resize from
// Blink.
auto* property_trees = active_tree_->property_trees();
gfx::Vector2dF inner_bounds_delta(0.f, delta_from_top_controls);
if (property_trees->inner_viewport_container_bounds_delta() ==
inner_bounds_delta)
gfx::Vector2dF bounds_delta(0.f, delta_from_top_controls);
if (property_trees->inner_viewport_container_bounds_delta() == bounds_delta)
return;
property_trees->SetInnerViewportContainerBoundsDelta(inner_bounds_delta);
property_trees->SetInnerViewportContainerBoundsDelta(bounds_delta);
ClipNode* inner_clip_node = property_trees->clip_tree.Node(
InnerViewportScrollLayer()->clip_tree_index());
inner_clip_node->clip.set_height(
InnerViewportScrollNode()->container_bounds.height() +
inner_bounds_delta.y());
InnerViewportScrollNode()->container_bounds.height() + bounds_delta.y());
// Adjust the outer viewport container as well, since adjusting only the
// inner may cause its bounds to exceed those of the outer, causing scroll
// clamping.
if (OuterViewportScrollNode()) {
gfx::Vector2dF outer_bounds_delta = gfx::ScaleVector2d(
inner_bounds_delta, 1.f / active_tree_->min_page_scale_factor());
gfx::Vector2dF scaled_bounds_delta = gfx::ScaleVector2d(
bounds_delta, 1.f / active_tree_->min_page_scale_factor());
property_trees->SetOuterViewportContainerBoundsDelta(outer_bounds_delta);
property_trees->SetInnerViewportScrollBoundsDelta(outer_bounds_delta);
property_trees->SetOuterViewportContainerBoundsDelta(scaled_bounds_delta);
property_trees->SetInnerViewportScrollBoundsDelta(scaled_bounds_delta);
ClipNode* outer_clip_node = property_trees->clip_tree.Node(
OuterViewportScrollLayer()->clip_tree_index());
outer_clip_node->clip.set_height(
OuterViewportScrollNode()->container_bounds.height() +
outer_bounds_delta.y());
float container_height =
OuterViewportScrollNode()->container_bounds.height();
// TODO(bokan): The container bounds for the outer viewport are incorrectly
// computed pre-Blink-Gen-Property-Trees so we must apply the minimum page
// scale factor. https://crbug.com/901083
if (!settings().use_layer_lists)
container_height *= active_tree_->min_page_scale_factor();
outer_clip_node->clip.set_height(container_height + bounds_delta.y());
// Expand all clips between the outer viewport and the inner viewport.
auto* outer_ancestor = property_trees->clip_tree.parent(outer_clip_node);
......
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