New issue
Advanced search Search tips

Issue 714829 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Apr 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

VisualViewport.width doesn't cause layout when scrollbar visibility changes

Project Member Reported by bokan@chromium.org, Apr 24 2017

Issue description

Chrome Version: 60.0.3079.0
OS: All

What steps will reproduce the problem?
(1) Expand iframe's body element width/height programmatically so that a scrollbar appears
(2) Read value of the iframe's window.view.{width,height}

What is the expected result?
The width/height should be reduced by the thickness of a scrollbar, if system scrollbars are non-overlay.

What happens instead?
The width/height didn't change.

They do change if we try to read the body's clientHeight so it looks like we're missing a necessary layout call. See attached test file
 
viewport_unscaled_size_iframe.html
2.3 KB View Download

Comment 1 by bokan@chromium.org, Apr 25 2017

Cc: skobes@chromium.org
+Steve, are there any guidelines on which properties should perform a layout if one is needed? Or should anything layout dependent do a layout?

In this case, getting the viewport size of an iframe depends on layout because we need to know whether there's a scrollbar present or not. So if JS changes the content size and then queries the viewport size, should we do a layout or is it up to the client code to ensure a a layout is done?

Comment 2 by skobes@chromium.org, Apr 25 2017

Yes, I think any API that depends on layout should ensure that layout is up to date before producing a result.
Project Member

Comment 3 by bugdroid1@chromium.org, Apr 27 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/396aeae063fa2f8a1e7422bc86a568239bf8fca4

commit 396aeae063fa2f8a1e7422bc86a568239bf8fca4
Author: bokan <bokan@chromium.org>
Date: Thu Apr 27 17:40:00 2017

Perform layout when viewport size is queried.

If a Frame has non-overlay scrollbars, the visualViewport's dimensions
should exclude them. In order to know whether the Frame has scrollbars,
we need to perform any pending layouts.

This was only broken for iframes as the main frame viewport size
depends on page scale. Page scale depends on layout to determine
the minimum/initial page scale so we already performed layout when the
main frame's viewport was queried.

BUG= 714829 

Review-Url: https://codereview.chromium.org/2842343002
Cr-Commit-Position: refs/heads/master@{#467718}

[add] https://crrev.com/396aeae063fa2f8a1e7422bc86a568239bf8fca4/third_party/WebKit/LayoutTests/fast/dom/viewport/read-viewport-size-causes-layout.html
[add] https://crrev.com/396aeae063fa2f8a1e7422bc86a568239bf8fca4/third_party/WebKit/LayoutTests/fast/dom/viewport/read-viewport-size-in-iframe-causes-layout.html
[modify] https://crrev.com/396aeae063fa2f8a1e7422bc86a568239bf8fca4/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp

Comment 4 by bokan@chromium.org, Apr 28 2017

Status: Fixed (was: Assigned)

Sign in to add a comment