New issue
Advanced search Search tips

Issue 709808 link

Starred by 4 users

Issue metadata

Status: Fixed
Owner:
Closed: Dec 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Feature

Blocking:
issue 657748



Sign in to add a comment

white-space is broken in display:contents

Reported by oriol-bu...@hotmail.com, Apr 9 2017

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:55.0) Gecko/20100101 Firefox/55.0

Steps to reproduce the problem:
Add white-space:pre to an element with display:contents

What is the expected behavior?
white-space should work properly for the text directly inside the element, just like it work for the text in children elements.

What went wrong?
Newlines collapse (despite spaces and tabs being preserved). Tabs seem to cause some kind of weird overlap with the following element.

Did this work before? No 

Does this work in other browsers? Yes

Chrome version: 59.0.3055.0  Channel: n/a
OS Version: 10.0
Flash Version: Shockwave Flash 25.0 r0

In the attached testcase, the text should appear just exactly as if display:contents wasn't there.

It works correctly on Firefox.
 
testcase.htm
438 bytes View Download

Comment 1 by shans@chromium.org, Apr 10 2017

Labels: Needs-Bisect
Status: Untriaged (was: Unconfirmed)
This is working correctly in m56, broken by m59. Please use the behavior in Firefox as a guide for correctness.

(Alternatively, *correct* behavior is that the arrow to the left of "Why does the span start here????" points to the beginning of the line below "Spaces and tabs do not collapse". *incorrect* behavior is that it points somewhere in the middle of the line).

I strongly suspect this is a layout issue, but we can wait until bisection to see what turns up.

Comment 2 by ajha@chromium.org, Apr 10 2017

Labels: Needs-Triage-M59

Comment 3 by r...@opera.com, Apr 10 2017

Cc: eco...@igalia.com
I only see that it's broken on ToT if I run with --enable-experimental-web-platform-features.
Cc: jmukthavaram@chromium.org
Labels: Needs-Feedback
Unable to reproduce the issue on windows 10,Mac 10.12.4 & Ubuntu 14.04 using chrome reported version-59.0.3055.0 ,stable-57.0.2987.133 & Canary-59.0.3067.0 as per the provided html file. Observed that the arrow to the left of "Why does the span start here????" points to the beginning of the line below "Spaces and tabs do not collapse".
Same behaviour observed in Firefox also.
Please find the attached screencast & let us know if we miss anything to reproduce the issue.

Thank you!!

709808-3055.mp4
202 KB View Download
Did you enable experimental web platform features?
As comment 3 says, display:contents requires that flag.
Attaching my screencast. The colors are not great because it's a gif. What program do you use to record screencasts?

screencast.gif
177 KB View Download

Comment 6 by r...@opera.com, Apr 10 2017

Blocking: 657748
Cc: -eco...@igalia.com r...@opera.com
Labels: -OS-Windows -Pri-2 -Needs-Feedback -Arch-x86_64 -Hotlist-Interop -Needs-Bisect -Needs-Triage-M59 OS-All Pri-3
Owner: eco...@igalia.com
Status: Assigned (was: Untriaged)
This feature is not shipped, so no need to target a fix for it. Just made it blocking the display:contents issue.

Labels: Update-Quarterly

Comment 8 by shend@chromium.org, Apr 11 2017

Labels: Type-Feature
Labels: -Type-Bug

Comment 10 by eco...@igalia.com, Apr 19 2017

I believe this is another instance of https://groups.google.com/a/chromium.org/forum/#!topic/layout-dev/8ldUMbjFUwU, where we're using the parent layout object style for text layout.

I'm not sure how painful it's going to be to fix it yet.
Owner: futhark@chromium.org
Cc: -r...@opera.com
Project Member

Comment 14 by bugdroid1@chromium.org, Dec 5 2017

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

commit fc5c3629044888b8d723cc11424879bb883d8d3e
Author: Rune Lillesveen <futhark@chromium.org>
Date: Tue Dec 05 12:13:10 2017

Wrap text child of display:contents in anonymous if necessary.

A text node gets its style from its flat tree parent. The problem is
that our layout code expects the LayoutObject parent to have the same
inherited styles as the text node. That is not the case if a text node
has display:contents ancestors and the display:contents parent does not
have the same inherited styles as the closest ancestor generating a box.

Example:

  <div>
    <div style="display:contents;font-size:50px">Text</div>
  </div>

We're solving this by inserting an anonymous inline between the
LayoutText and its parent LayoutObject. We do not try to merge inline
wrappers for subsequent text nodes, so for:

  <div style="display:contents:color:pink">A<!-- -->B</div>

we create one wrapper for each of A and B, even though one would
suffice.

We attach and detach these wrappers on-demand, so if, for instance, the
inherited computed styles of the display:contents change so that it
matches the computed styles of the LayoutObject parent, we detach the
wrapper as it's no longer needed.

We also currently detach the wrapper when the computed style of the
display:contents and hence the computed style of the wrapper changes. We
could have optimized this through more checking and SetStyle on the
anonymous wrapper.

Bug:  717460 ,  706316 ,  709808 ,  713019 
Change-Id: Ia53b9fe2c0a6067c4600dab49cdf43f23b95b8fa
Tests: see removed lines from TestExpectations.
Reviewed-on: https://chromium-review.googlesource.com/806158
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: Robert Hogan <robhogan@gmail.com>
Reviewed-by: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521673}
[modify] https://crrev.com/fc5c3629044888b8d723cc11424879bb883d8d3e/third_party/WebKit/LayoutTests/TestExpectations
[modify] https://crrev.com/fc5c3629044888b8d723cc11424879bb883d8d3e/third_party/WebKit/Source/core/dom/LayoutTreeBuilder.cpp
[modify] https://crrev.com/fc5c3629044888b8d723cc11424879bb883d8d3e/third_party/WebKit/Source/core/dom/LayoutTreeBuilder.h
[modify] https://crrev.com/fc5c3629044888b8d723cc11424879bb883d8d3e/third_party/WebKit/Source/core/dom/Text.cpp
[modify] https://crrev.com/fc5c3629044888b8d723cc11424879bb883d8d3e/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
[modify] https://crrev.com/fc5c3629044888b8d723cc11424879bb883d8d3e/third_party/WebKit/Source/core/layout/LayoutInline.cpp
[modify] https://crrev.com/fc5c3629044888b8d723cc11424879bb883d8d3e/third_party/WebKit/Source/core/layout/LayoutObjectTest.cpp
[modify] https://crrev.com/fc5c3629044888b8d723cc11424879bb883d8d3e/third_party/WebKit/Source/core/style/ComputedStyle.cpp
[modify] https://crrev.com/fc5c3629044888b8d723cc11424879bb883d8d3e/third_party/WebKit/Source/core/style/ComputedStyle.h

Status: Fixed (was: Assigned)

Sign in to add a comment