Commit 5f22b640 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

[LayoutNG] Fix -webkit-background-clip:text for inline elements

Previously the clip mask was painted at wrong place.

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng;luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I73ffd1011ae04c7751c1efff52e63bd6186a9483
Reviewed-on: https://chromium-review.googlesource.com/1211968
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589373}
parent 1ec1fd0d
<!DOCTYPE html>
<style>
body {
font-size: 40px;
}
.text-clip {
background: blue;
-webkit-background-clip: text;
color: rgba(255,0,0,0.5);
}
</style>
Passes if all texts below are purple.
<br>
<div class="text-clip">&nbsp;Text1&nbsp;&nbsp;Text2&nbsp;</div>
<div class="text-clip">&nbsp;Text3&nbsp;&nbsp;Text4&nbsp;</div>
<!DOCTYPE html>
<style>
body {
font-size: 40px;
}
.text-clip {
background: blue;
-webkit-background-clip: text;
color: rgba(255,0,0,0.5);
}
.relative {
position: relative;
left: 10px;
}
</style>
Passes if all texts below are purple.
<br>
<!-- The &nbsp;s are to avoid glyph overflows. -->
<span class="text-clip">&nbsp;Text1&nbsp;</span><span class="text-clip">&nbsp;Text2&nbsp;</span>
<br>
<span class="text-clip">&nbsp;Text3&nbsp;</span><span class="text-clip">&nbsp;Text4&nbsp;</span>
...@@ -762,8 +762,8 @@ void NGBoxFragmentPainter::PaintTextClipMask(GraphicsContext& context, ...@@ -762,8 +762,8 @@ void NGBoxFragmentPainter::PaintTextClipMask(GraphicsContext& context,
bool object_has_multiple_boxes) { bool object_has_multiple_boxes) {
PaintInfo paint_info(context, mask_rect, PaintPhase::kTextClip, PaintInfo paint_info(context, mask_rect, PaintPhase::kTextClip,
kGlobalPaintNormalPhase, 0); kGlobalPaintNormalPhase, 0);
LayoutSize local_offset = box_fragment_.Offset().ToLayoutSize();
if (object_has_multiple_boxes) { if (object_has_multiple_boxes) {
LayoutSize local_offset = box_fragment_.Offset().ToLayoutSize();
NGInlineBoxFragmentPainter inline_box_painter(box_fragment_); NGInlineBoxFragmentPainter inline_box_painter(box_fragment_);
if (box_fragment_.Style().BoxDecorationBreak() == if (box_fragment_.Style().BoxDecorationBreak() ==
EBoxDecorationBreak::kSlice) { EBoxDecorationBreak::kSlice) {
...@@ -778,7 +778,7 @@ void NGBoxFragmentPainter::PaintTextClipMask(GraphicsContext& context, ...@@ -778,7 +778,7 @@ void NGBoxFragmentPainter::PaintTextClipMask(GraphicsContext& context,
} }
inline_box_painter.Paint(paint_info, paint_offset - local_offset); inline_box_painter.Paint(paint_info, paint_offset - local_offset);
} else { } else {
PaintObject(paint_info, paint_offset - local_offset); PaintObject(paint_info, paint_offset);
} }
} }
......
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