Commit 08dc4f84 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[FragmentItem] Fix NGBoxFragmentPainter::PaintTextClipMask

Bug: 982194
Change-Id: I1b55db65d9fae0903d91d0fb682da5c15ac0891c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2028876Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737232}
parent 01dcb256
...@@ -412,7 +412,7 @@ void NGBoxFragmentPainter::PaintObject( ...@@ -412,7 +412,7 @@ void NGBoxFragmentPainter::PaintObject(
// Self-painting inline box paints only parts of the container block. // Self-painting inline box paints only parts of the container block.
// Adjust |paint_offset| because it is the offset of the inline box, but // Adjust |paint_offset| because it is the offset of the inline box, but
// |descendants_| has offsets to the contaiing block. // |descendants_| has offsets to the contaiing block.
DCHECK(box_item_ && box_item_->HasSelfPaintingLayer()); DCHECK(box_item_);
const PhysicalOffset paint_offset_to_inline_formatting_context = const PhysicalOffset paint_offset_to_inline_formatting_context =
paint_offset - box_item_->OffsetInContainerBlock(); paint_offset - box_item_->OffsetInContainerBlock();
PaintInlineItems(paint_info.ForDescendants(), PaintInlineItems(paint_info.ForDescendants(),
...@@ -1443,27 +1443,46 @@ void NGBoxFragmentPainter::PaintTextClipMask(GraphicsContext& context, ...@@ -1443,27 +1443,46 @@ 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);
if (object_has_multiple_boxes) { if (!object_has_multiple_boxes) {
DCHECK(paint_fragment_);
PhysicalOffset local_offset = paint_fragment_->Offset();
DCHECK(paint_fragment_);
NGInlineBoxFragmentPainter inline_box_painter(*paint_fragment_);
if (box_fragment_.Style().BoxDecorationBreak() ==
EBoxDecorationBreak::kSlice) {
LayoutUnit offset_on_line;
LayoutUnit total_width;
inline_box_painter.ComputeFragmentOffsetOnLine(
box_fragment_.Style().Direction(), &offset_on_line, &total_width);
LayoutSize line_offset(offset_on_line, LayoutUnit());
local_offset -=
PhysicalOffset(box_fragment_.Style().IsHorizontalWritingMode()
? line_offset
: line_offset.TransposedSize());
}
inline_box_painter.Paint(paint_info, paint_offset - local_offset);
} else {
PaintObject(paint_info, paint_offset); PaintObject(paint_info, paint_offset);
return;
}
if (paint_fragment_) {
NGInlineBoxFragmentPainter inline_box_painter(*paint_fragment_);
PaintTextClipMask(paint_info, paint_offset - paint_fragment_->Offset(),
&inline_box_painter);
return;
}
DCHECK(box_item_);
// TODO(kojii): Callers have the |NGInlineCursor| that can be passed down to
// here.
NGInlineCursor cursor;
cursor.MoveTo(*box_item_);
NGInlineCursor descendants = cursor.CursorForDescendants();
NGInlineBoxFragmentPainter inline_box_painter(*box_item_, &descendants);
PaintTextClipMask(paint_info,
paint_offset - box_item_->OffsetInContainerBlock(),
&inline_box_painter);
}
void NGBoxFragmentPainter::PaintTextClipMask(
const PaintInfo& paint_info,
PhysicalOffset paint_offset,
NGInlineBoxFragmentPainter* inline_box_painter) {
const ComputedStyle& style = box_fragment_.Style();
if (style.BoxDecorationBreak() == EBoxDecorationBreak::kSlice) {
LayoutUnit offset_on_line;
LayoutUnit total_width;
inline_box_painter->ComputeFragmentOffsetOnLine(
style.Direction(), &offset_on_line, &total_width);
if (style.IsHorizontalWritingMode())
paint_offset.left += offset_on_line;
else
paint_offset.top += offset_on_line;
} }
inline_box_painter->Paint(paint_info, paint_offset);
} }
PhysicalRect NGBoxFragmentPainter::AdjustRectForScrolledContent( PhysicalRect NGBoxFragmentPainter::AdjustRectForScrolledContent(
......
...@@ -24,6 +24,7 @@ class HitTestResult; ...@@ -24,6 +24,7 @@ class HitTestResult;
class NGFragmentItems; class NGFragmentItems;
class NGInlineCursor; class NGInlineCursor;
class NGInlineBackwardCursor; class NGInlineBackwardCursor;
class NGInlineBoxFragmentPainter;
class NGPhysicalFragment; class NGPhysicalFragment;
class ScopedPaintState; class ScopedPaintState;
struct PaintInfo; struct PaintInfo;
...@@ -41,6 +42,9 @@ class NGBoxFragmentPainter : public BoxPainterBase { ...@@ -41,6 +42,9 @@ class NGBoxFragmentPainter : public BoxPainterBase {
// Construct for an inline formatting context. // Construct for an inline formatting context.
NGBoxFragmentPainter(const NGPaintFragment&); NGBoxFragmentPainter(const NGPaintFragment&);
// Construct for an inline box. // Construct for an inline box.
NGBoxFragmentPainter(const NGPhysicalBoxFragment& box_fragment,
const NGPaintFragment* paint_fragment,
const NGFragmentItem* box_item);
NGBoxFragmentPainter(const NGFragmentItem& item, NGBoxFragmentPainter(const NGFragmentItem& item,
const NGPhysicalBoxFragment& fragment, const NGPhysicalBoxFragment& fragment,
NGInlineCursor* descendants); NGInlineCursor* descendants);
...@@ -73,6 +77,9 @@ class NGBoxFragmentPainter : public BoxPainterBase { ...@@ -73,6 +77,9 @@ class NGBoxFragmentPainter : public BoxPainterBase {
const IntRect& mask_rect, const IntRect& mask_rect,
const PhysicalOffset& paint_offset, const PhysicalOffset& paint_offset,
bool object_has_multiple_boxes) override; bool object_has_multiple_boxes) override;
void PaintTextClipMask(const PaintInfo& paint_info,
PhysicalOffset paint_offset,
NGInlineBoxFragmentPainter* inline_box_painter);
PhysicalRect AdjustRectForScrolledContent( PhysicalRect AdjustRectForScrolledContent(
const PaintInfo&, const PaintInfo&,
const BoxPainterBase::FillLayerInfo&, const BoxPainterBase::FillLayerInfo&,
...@@ -82,6 +89,7 @@ class NGBoxFragmentPainter : public BoxPainterBase { ...@@ -82,6 +89,7 @@ class NGBoxFragmentPainter : public BoxPainterBase {
NGBoxFragmentPainter(const NGPhysicalBoxFragment&, NGBoxFragmentPainter(const NGPhysicalBoxFragment&,
const DisplayItemClient& display_item_client, const DisplayItemClient& display_item_client,
const NGPaintFragment* = nullptr, const NGPaintFragment* = nullptr,
const NGFragmentItem* = nullptr,
NGInlineCursor* descendants = nullptr); NGInlineCursor* descendants = nullptr);
enum MoveTo { kDontSkipChildren, kSkipChildren }; enum MoveTo { kDontSkipChildren, kSkipChildren };
...@@ -281,19 +289,24 @@ inline NGBoxFragmentPainter::NGBoxFragmentPainter( ...@@ -281,19 +289,24 @@ inline NGBoxFragmentPainter::NGBoxFragmentPainter(
const NGPhysicalBoxFragment& box, const NGPhysicalBoxFragment& box,
const DisplayItemClient& display_item_client, const DisplayItemClient& display_item_client,
const NGPaintFragment* paint_fragment, const NGPaintFragment* paint_fragment,
const NGFragmentItem* box_item,
NGInlineCursor* descendants) NGInlineCursor* descendants)
: BoxPainterBase(&box.GetDocument(), box.Style(), box.GeneratingNode()), : BoxPainterBase(&box.GetDocument(), box.Style(), box.GeneratingNode()),
box_fragment_(box), box_fragment_(box),
display_item_client_(display_item_client), display_item_client_(display_item_client),
paint_fragment_(paint_fragment), paint_fragment_(paint_fragment),
items_(box.Items()), items_(box.Items()),
box_item_(box_item),
descendants_(descendants) { descendants_(descendants) {
DCHECK(box.IsBox() || box.IsRenderedLegend()); DCHECK(box.IsBox() || box.IsRenderedLegend());
DCHECK(!paint_fragment || !descendants); DCHECK(!paint_fragment || !descendants);
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
if (box.IsInlineBox()) { if (box.IsInlineBox()) {
DCHECK(paint_fragment_ || box_item_);
if (paint_fragment) if (paint_fragment)
DCHECK_EQ(&paint_fragment->PhysicalFragment(), &box); DCHECK_EQ(&paint_fragment->PhysicalFragment(), &box);
if (box_item)
DCHECK_EQ(box_item->BoxFragment(), &box);
} else if (box.ChildrenInline()) { } else if (box.ChildrenInline()) {
// If no children, there maybe or may not be NGPaintFragment. // If no children, there maybe or may not be NGPaintFragment.
// TODO(kojii): To be investigated if this correct or should be fixed. // TODO(kojii): To be investigated if this correct or should be fixed.
...@@ -321,6 +334,7 @@ inline NGBoxFragmentPainter::NGBoxFragmentPainter( ...@@ -321,6 +334,7 @@ inline NGBoxFragmentPainter::NGBoxFragmentPainter(
: NGBoxFragmentPainter(fragment, : NGBoxFragmentPainter(fragment,
*fragment.GetLayoutObject(), *fragment.GetLayoutObject(),
/* paint_fragment */ nullptr, /* paint_fragment */ nullptr,
/* box_item */ nullptr,
/* descendants */ nullptr) {} /* descendants */ nullptr) {}
inline NGBoxFragmentPainter::NGBoxFragmentPainter( inline NGBoxFragmentPainter::NGBoxFragmentPainter(
...@@ -333,6 +347,20 @@ inline NGBoxFragmentPainter::NGBoxFragmentPainter( ...@@ -333,6 +347,20 @@ inline NGBoxFragmentPainter::NGBoxFragmentPainter(
: *static_cast<const DisplayItemClient*>( : *static_cast<const DisplayItemClient*>(
fragment.GetLayoutObject()), fragment.GetLayoutObject()),
paint_fragment, paint_fragment,
/* box_item */ nullptr,
/* descendants */ nullptr) {}
inline NGBoxFragmentPainter::NGBoxFragmentPainter(
const NGPhysicalBoxFragment& fragment,
const NGPaintFragment* paint_fragment,
const NGFragmentItem* box_item)
: NGBoxFragmentPainter(
fragment,
paint_fragment
? *static_cast<const DisplayItemClient*>(paint_fragment)
: *static_cast<const DisplayItemClient*>(box_item),
paint_fragment,
box_item,
/* descendants */ nullptr) {} /* descendants */ nullptr) {}
inline NGBoxFragmentPainter::NGBoxFragmentPainter( inline NGBoxFragmentPainter::NGBoxFragmentPainter(
...@@ -349,10 +377,10 @@ inline NGBoxFragmentPainter::NGBoxFragmentPainter( ...@@ -349,10 +377,10 @@ inline NGBoxFragmentPainter::NGBoxFragmentPainter(
: NGBoxFragmentPainter(fragment, : NGBoxFragmentPainter(fragment,
item, item,
/* paint_fragment */ nullptr, /* paint_fragment */ nullptr,
&item,
descendants) { descendants) {
DCHECK_EQ(item.BoxFragment(), &fragment); DCHECK_EQ(item.BoxFragment(), &fragment);
DCHECK(fragment.IsInlineBox()); DCHECK(fragment.IsInlineBox());
box_item_ = &item;
} }
} // namespace blink } // namespace blink
......
...@@ -122,7 +122,7 @@ void NGInlineBoxFragmentPainterBase::PaintBackgroundBorderShadow( ...@@ -122,7 +122,7 @@ void NGInlineBoxFragmentPainterBase::PaintBackgroundBorderShadow(
// TODO(kojii): not applicable for line box // TODO(kojii): not applicable for line box
NGBoxFragmentPainter box_painter( NGBoxFragmentPainter box_painter(
To<NGPhysicalBoxFragment>(inline_box_fragment_), To<NGPhysicalBoxFragment>(inline_box_fragment_),
inline_box_paint_fragment_); inline_box_paint_fragment_, inline_box_item_);
const NGBorderEdges& border_edges = BorderEdges(); const NGBorderEdges& border_edges = BorderEdges();
PaintBoxDecorationBackground(box_painter, paint_info, paint_offset, PaintBoxDecorationBackground(box_painter, paint_info, paint_offset,
adjusted_frame_rect, geometry, adjusted_frame_rect, geometry,
......
...@@ -149,6 +149,13 @@ class NGInlineBoxFragmentPainter : public NGInlineBoxFragmentPainterBase { ...@@ -149,6 +149,13 @@ class NGInlineBoxFragmentPainter : public NGInlineBoxFragmentPainterBase {
DCHECK_EQ(inline_box_fragment.BoxType(), DCHECK_EQ(inline_box_fragment.BoxType(),
NGPhysicalFragment::NGBoxType::kInlineBox); NGPhysicalFragment::NGBoxType::kInlineBox);
} }
NGInlineBoxFragmentPainter(const NGFragmentItem& inline_box_item,
NGInlineCursor* descendants = nullptr)
: NGInlineBoxFragmentPainter(inline_box_item,
*inline_box_item.BoxFragment(),
descendants) {
DCHECK(inline_box_item.BoxFragment());
}
void Paint(const PaintInfo&, const PhysicalOffset& paint_offset); void Paint(const PaintInfo&, const PhysicalOffset& paint_offset);
......
...@@ -131,7 +131,6 @@ crbug.com/626703 external/wpt/webvtt/rendering/cues-with-video/processing-model/ ...@@ -131,7 +131,6 @@ crbug.com/626703 external/wpt/webvtt/rendering/cues-with-video/processing-model/
crbug.com/626703 external/wpt/webvtt/rendering/cues-with-video/processing-model/selectors/cue_function/outline_shorthand.html [ Failure ] crbug.com/626703 external/wpt/webvtt/rendering/cues-with-video/processing-model/selectors/cue_function/outline_shorthand.html [ Failure ]
crbug.com/982194 external/wpt/webxr/events_referenceSpace_reset_inline.https.html [ Timeout ] crbug.com/982194 external/wpt/webxr/events_referenceSpace_reset_inline.https.html [ Timeout ]
crbug.com/982194 fast/backgrounds/background-clip-text-multiline-linebreak.html [ Failure ] crbug.com/982194 fast/backgrounds/background-clip-text-multiline-linebreak.html [ Failure ]
crbug.com/982194 fast/backgrounds/background-clip-text-multiline.html [ Crash ]
crbug.com/982194 fast/block/positioning/absolute-in-inline-dynamic.html [ Failure ] crbug.com/982194 fast/block/positioning/absolute-in-inline-dynamic.html [ Failure ]
crbug.com/982194 fast/block/positioning/rel-positioned-inline-changes-width.html [ Failure ] crbug.com/982194 fast/block/positioning/rel-positioned-inline-changes-width.html [ Failure ]
crbug.com/982194 fast/css/first-line-hover-001.html [ Failure Pass ] crbug.com/982194 fast/css/first-line-hover-001.html [ Failure Pass ]
......
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