Commit ce828beb authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[LayoutNG] SelfPaintingLayer is left visible when ellipsized

NGLineTruncator truncates lines by suppressing fragments to
be clipped. However, when such fragments have
SelfPaintingLayer, they are still painted by LayerPainter.

This patch moves such fragments to the outside of the
clipping area, the same way we used to use until r581177.

Note that we used to move to line_width before r581177,
but it's not enough when the block has padding. This
patch moves to NearlyMax instead.

Bug: 899902
Change-Id: I6192f230e2da3af11346acb5795483f9cc3a6a6a
Reviewed-on: https://chromium-review.googlesource.com/c/1319889
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605996}
parent 82e305ac
......@@ -289,6 +289,7 @@ crbug.com/591099 fast/table/unbreakable-images-quirk.html [ Failure ]
crbug.com/591099 fast/text/descent-clip-in-scaled-page.html [ Failure ]
crbug.com/591099 fast/text/ellipsis-in-relative-inline-right.html [ Failure ]
crbug.com/591099 fast/text/ellipsis-in-relative-inline.html [ Failure ]
crbug.com/899902 fast/text/ellipsis-with-self-painting-layer.html [ Pass ]
crbug.com/796943 fast/text/international/shape-across-elements-simple.html [ Pass ]
crbug.com/591099 fast/text/whitespace/018.html [ Failure ]
crbug.com/591099 fast/writing-mode/auto-sizing-orthogonal-flows.html [ Failure ]
......
......@@ -543,6 +543,7 @@ crbug.com/774229 editing/pasteboard/copy-paste-white-space.html [ Failure ]
crbug.com/855279 fast/css/text-overflow-ellipsis-vertical-hittest.html [ Failure ]
crbug.com/591099 fast/dom/nodesFromRect/nodesFromRect-basic.html [ Failure ]
crbug.com/591099 fast/css-intrinsic-dimensions/height-positioned.html [ Failure ]
crbug.com/899902 fast/text/ellipsis-with-self-painting-layer.html [ Failure ]
crbug.com/796943 fast/text/international/shape-across-elements-simple.html [ Failure ]
crbug.com/877946 external/wpt/css/CSS2/linebox/anonymous-inline-inherit-001.html [ Failure ]
crbug.com/859233 external/wpt/css/css-break/hit-test-inline-fragmentation-with-border-radius.html [ Failure ]
......
<!DOCTYPE html>
<style>
div {
font-size: 10px;
border: 1px blue solid;
width: 10ch;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.padding > div {
padding-right: 4ch;
}
.inline-block {
background: red;
display: inline-block;
width: 4ch;
height: 1em;
}
.layer {
transform: translateY(0px);
}
</style>
<body>
<div>123456789012</div>
<div>123456789012</div>
<div>123456789012</div>
<div>123456789012</div>
<div>123456789012</div>
<div>123456789012</div>
<section class="padding">
<div>123456789012</div>
<div>123456789012</div>
<div>123456789012</div>
<div>123456789012</div>
<div>123456789012</div>
<div>123456789012</div>
</section>
</body>
<!DOCTYPE html>
<style>
div {
font-size: 10px;
border: 1px blue solid;
width: 10ch;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.padding > div {
padding-right: 4ch;
}
.inline-block {
background: red;
display: inline-block;
width: 4ch;
height: 1em;
}
.layer {
transform: translateY(0px);
}
</style>
<body>
<div>123456789012</div>
<div>12345678
<span class="inline-block"></span>
</div>
<div>12345678
<span class="inline-block layer"></span>
</div>
<div>1234567890123
<span class="inline-block layer"></span>
</div>
<div>12345678
<span class="layer">0000</span>
</div>
<div>1234567890123
<span class="layer">0000</span>
</div>
<section class="padding">
<div>123456789012</div>
<div>12345678
<span class="inline-block"></span>
</div>
<div>12345678
<span class="inline-block layer"></span>
</div>
<div>1234567890123
<span class="inline-block layer"></span>
</div>
<div>12345678
<span class="layer">0000</span>
</div>
<div>1234567890123
<span class="layer">0000</span>
</div>
</section>
</body>
......@@ -6,6 +6,7 @@
#include "third_party/blink/renderer/core/layout/ng/inline/ng_inline_item_result.h"
#include "third_party/blink/renderer/core/layout/ng/inline/ng_text_fragment_builder.h"
#include "third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h"
#include "third_party/blink/renderer/platform/fonts/font_baseline.h"
#include "third_party/blink/renderer/platform/fonts/shaping/harfbuzz_shaper.h"
......@@ -115,6 +116,24 @@ LayoutUnit NGLineTruncator::TruncateLine(
// Hide this child from being painted.
void NGLineTruncator::HideChild(NGLineBoxFragmentBuilder::Child* child) {
DCHECK(child->HasInFlowFragment());
// If this child has self painting layer, not producing fragments will not
// suppress painting because layers are painted separately. Move it out of the
// clipping area.
const NGPhysicalFragment* fragment = child->PhysicalFragment();
DCHECK(fragment);
if (const NGPhysicalBoxFragment* box_fragment =
ToNGPhysicalBoxFragmentOrNull(fragment)) {
if (box_fragment->HasSelfPaintingLayer()) {
// |avilable_width_| may not be enough when the contaning block has
// paddings, because clipping is at the content box but ellipsizing is at
// the padding box. Just move to the max because we don't know paddings,
// and max should do what we need.
child->offset.inline_offset = LayoutUnit::NearlyMax();
return;
}
}
// TODO(kojii): Not producing fragments is the most clean and efficient way to
// hide them, but we may want to revisit how to do this to reduce special
// casing in other code.
......
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