New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 785212 link

Starred by 4 users

Issue metadata

Status: Fixed
Owner:
Closed: Jul 30
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 2
Type: Bug



Sign in to add a comment

[css-contain] contain: layout does not become a containing block

Reported by subterra...@gmail.com, Nov 15 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3268.0 Safari/537.36

Steps to reproduce the problem:
1. Apply 'contain: layout' to an element.
2. It makes no sense.

What is the expected behavior?
According to the specification[1], 'contain: layout' ensures that its content is totally opaque, containing block for absolute and fixed positioned descendants, and other benefits.

In addition to the above, UA can optimize the layout process.

[1] https://drafts.csswg.org/css-contain/

What went wrong?
Nothing happens. The content doesn't become opaque. The fixed descendant is positioned to outer of the element.

Chrome renders the whole document as a layout root instead of the element.

Did this work before? N/A 

Does this work in other browsers? N/A

Chrome version: 64.0.3268.0  Channel: canary
OS Version: OS X 10.13.1
Flash Version: 

'contain: paint', 'contain: size' and 'contain: style' work well.
 
index.html
2.9 KB View Download
layout.png
48.7 KB View Download
Components: -Blink>CSS Blink>Layout
ComputedStyle is correct here so moving to Layout for triage
Cc: sc00335...@techmahindra.com
Labels: M-64 Needs-Triage-M64 Triaged-ET OS-Linux OS-Windows
Status: Untriaged (was: Unconfirmed)
Able to reproduce this issue on reported version 64.0.3268.0  and on latest canary 64.0.3271.0 using Mac 10.12.6, Windows 10 and Ubuntu 14.04 with steps mentioned in comment#0. i.e; Content doesn't become opaque and fixed descendant is positioned to outer of the element.

This issue is seen from M50. [50.0.2661.0]. Hence considering this issue as Non-regression and marking as Untriaged.

NOTE: Issue is seen in Firefox as well.
Status: Available (was: Untriaged)
Summary: contain: layout does not become a containing block (was: CSS Containment 'contain: layout' doesn't work at all.)
"opaque" is not talking about the color; it is just used in the sense that follows in the next part of the sentence: "This ensures that the containing element is totally opaque for layout purposes; nothing outside can affect its internal layout, and vice versa."

The containing block aspect is a more recent change (https://github.com/w3c/csswg-drafts/commit/e25416007e6ce7f2fc87854cb42fe953b290c71a), it looks like we don't implement that yet. Marking as available for that.
Project Member

Comment 4 by bugdroid1@chromium.org, May 16 2018

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

commit bff3225e24a51702b9dd412db44a3144316ff075
Author: Manuel Rego Casasnovas <rego@igalia.com>
Date: Wed May 16 12:01:24 2018

[css-contain] Layout containment abspos and fixed descendants

An element with "contain: layout" should be the containing block
of any absolutely or fixed positioned descendants.

The spec is very clear regarding this
(https://drafts.csswg.org/css-contain/#containment-layout):
"The element acts as a containing block for absolutely positioned
 and fixed positioned descendants."

The patch just adds a new condition to
ComputedStyle::CanContainFixedPositionObjects().

We already had the condition for paint containment before,
so this takes advantage to add WPT tests to verify that case too.

This patch causes that contain-layout-005.html starts to fail,
but that's because of  crbug.com/843329 .
There are more failing tests related to that bug, so TestExpectations
is modified to reference it.

BUG= 785212 
TEST=external/wpt/css/css-contain/contain-layout-006.html
TEST=external/wpt/css/css-contain/contain-layout-007.html

Change-Id: I8bb1d637bd7742961a414a5007b8ee8a8d3e66ea
Reviewed-on: https://chromium-review.googlesource.com/1059557
Reviewed-by: Morten Stenshorne <mstensho@chromium.org>
Commit-Queue: Manuel Rego Casasnovas <rego@igalia.com>
Cr-Commit-Position: refs/heads/master@{#559045}
[modify] https://crrev.com/bff3225e24a51702b9dd412db44a3144316ff075/third_party/WebKit/LayoutTests/TestExpectations
[add] https://crrev.com/bff3225e24a51702b9dd412db44a3144316ff075/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-layout-006.html
[add] https://crrev.com/bff3225e24a51702b9dd412db44a3144316ff075/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-layout-007.html
[add] https://crrev.com/bff3225e24a51702b9dd412db44a3144316ff075/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-paint-009.html
[add] https://crrev.com/bff3225e24a51702b9dd412db44a3144316ff075/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-paint-010.html
[modify] https://crrev.com/bff3225e24a51702b9dd412db44a3144316ff075/third_party/WebKit/LayoutTests/fast/dom/Element/offset-parent-contain.html
[modify] https://crrev.com/bff3225e24a51702b9dd412db44a3144316ff075/third_party/blink/renderer/core/style/computed_style.h

Comment 5 by r...@igalia.com, May 16 2018

Owner: r...@igalia.com
Status: Fixed (was: Available)
Summary: [css-contain] contain: layout does not become a containing block (was: contain: layout does not become a containing block)
The issue related to abspos or fixed elements should be fixed now.
Project Member

Comment 6 by bugdroid1@chromium.org, May 18 2018

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

commit 1ccccf2277af4c7bf162ac01d2674fc888b6b5c9
Author: Manuel Rego Casasnovas <rego@igalia.com>
Date: Fri May 18 22:46:06 2018

[css-contain] Revert r559045 that broke YouTube on mobile

This is a revert of https://chromium-review.googlesource.com/1059557,
but we still keep the tests as they are right according to the spec.

We're reverting this as the branch point for M68 is very close,
we'll re-evaluate what to do once the branch is done.

BUG= 785212 ,843900,843905
TBR=mstensho@chromium.org,eae@chromium.org

Change-Id: I0d8faffe06ebd7f930daccf9dc17a412d9bcc40d
Reviewed-on: https://chromium-review.googlesource.com/1065680
Reviewed-by: Manuel Rego Casasnovas <rego@igalia.com>
Reviewed-by: Emil A Eklund <eae@chromium.org>
Commit-Queue: Manuel Rego Casasnovas <rego@igalia.com>
Cr-Commit-Position: refs/heads/master@{#560082}
[modify] https://crrev.com/1ccccf2277af4c7bf162ac01d2674fc888b6b5c9/third_party/WebKit/LayoutTests/TestExpectations
[add] https://crrev.com/1ccccf2277af4c7bf162ac01d2674fc888b6b5c9/third_party/WebKit/LayoutTests/fast/dom/Element/offset-parent-contain-expected.txt
[modify] https://crrev.com/1ccccf2277af4c7bf162ac01d2674fc888b6b5c9/third_party/blink/renderer/core/style/computed_style.h

Comment 7 by r...@igalia.com, May 21 2018

Cc: flor...@rivoal.net e...@chromium.org
Status: Assigned (was: Fixed)
Reopening this, as it was needed to revert the change,
as it broke YouTube on mobile.
Project Member

Comment 8 by bugdroid1@chromium.org, May 22 2018

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

commit 10def17fd2d6c1e0c72c812e897c73eea1bd6bcd
Author: Manuel Rego Casasnovas <rego@igalia.com>
Date: Tue May 22 21:41:42 2018

[css-contain] Use counter for layout containment positioned descendants

The patch to fix  crbug.com/785212  broke some sites,
it was making "contain: layout" elements to behave as containing blocks
for absolutely and fixed positioned descendants.

To check how many websites are affected by this, we're adding
a use counter in this patch.

BUG= 785212 

Change-Id: I35ea1f58a4e7570543c911607c1e6b81bc401ea8
Reviewed-on: https://chromium-review.googlesource.com/1067917
Commit-Queue: Manuel Rego Casasnovas <rego@igalia.com>
Reviewed-by: Chris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560789}
[modify] https://crrev.com/10def17fd2d6c1e0c72c812e897c73eea1bd6bcd/third_party/blink/public/platform/web_feature.mojom
[modify] https://crrev.com/10def17fd2d6c1e0c72c812e897c73eea1bd6bcd/third_party/blink/renderer/core/frame/use_counter_test.cc
[modify] https://crrev.com/10def17fd2d6c1e0c72c812e897c73eea1bd6bcd/third_party/blink/renderer/core/layout/layout_object.cc
[modify] https://crrev.com/10def17fd2d6c1e0c72c812e897c73eea1bd6bcd/tools/metrics/histograms/enums.xml

Project Member

Comment 9 by bugdroid1@chromium.org, Jul 20

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

commit db71b93784806ce5e46bdadd494c472858f21d43
Author: Manuel Rego Casasnovas <rego@igalia.com>
Date: Fri Jul 20 23:26:47 2018

[css-contain] Layout containment abspos and fixed descendants

An element with "contain: layout" should be the containing block
of any absolutely or fixed positioned descendants.

The spec is very clear regarding this
(https://drafts.csswg.org/css-contain/#containment-layout):
"The element acts as a containing block for absolutely positioned
 and fixed positioned descendants."

This was already implemented in r559045 but it was reverted
temporary as some sites (like YouTube on mobile) got broken.
For that reason we added a use counter, that is now in lower numbers
since YouTube has been updated to follow the new behavior.

The WPT test suite already has tests covering this,
so this patch just removes them from TestExpectations file.

BUG= 785212 

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I381af403bba1b6976e88ac02a462b28c424aa3af
Reviewed-on: https://chromium-review.googlesource.com/1144939
Commit-Queue: Manuel Rego <rego@igalia.com>
Reviewed-by: Emil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577030}
[modify] https://crrev.com/db71b93784806ce5e46bdadd494c472858f21d43/third_party/WebKit/LayoutTests/TestExpectations
[delete] https://crrev.com/025c4917a3d0a3420ec520807c348741988102ac/third_party/WebKit/LayoutTests/fast/dom/Element/offset-parent-contain-expected.txt
[modify] https://crrev.com/db71b93784806ce5e46bdadd494c472858f21d43/third_party/blink/renderer/core/layout/layout_block.cc
[modify] https://crrev.com/db71b93784806ce5e46bdadd494c472858f21d43/third_party/blink/renderer/core/layout/layout_object.cc
[modify] https://crrev.com/db71b93784806ce5e46bdadd494c472858f21d43/third_party/blink/renderer/core/layout/layout_table_box_component.cc
[modify] https://crrev.com/db71b93784806ce5e46bdadd494c472858f21d43/third_party/blink/renderer/core/layout/ng/inline/ng_inline_item.cc

Note this current open issue on the spec, which is distinct from this, but related:
https://github.com/w3c/csswg-drafts/issues/2942
Status: Fixed (was: Assigned)
Regarding last comment by Florian, we'll report a new bug once that's on the spec.
Apart from that we found issues related to paint containment and stacking contexts:
https://bugs.chromium.org/p/chromium/issues/detail?id=868102

This issue is now fixed.
Cc: manoranj...@chromium.org r...@igalia.com susan.boorgula@chromium.org
 Issue 869279  has been merged into this issue.

Sign in to add a comment