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

[FragmentItem] Implement IsHiddenForPaint

This patch fixes ellipsis by implementing IsHiddenForPaint().

Fixes ~50 failures.

Bug: 982194
Change-Id: Icabef1450f9c80132cd56db55d0ab73ad72c8ddd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1880894Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709821}
parent 5f0ccb78
......@@ -17,7 +17,7 @@ NGFragmentItem::NGFragmentItem(const NGPhysicalTextFragment& text)
sub_type_(static_cast<unsigned>(text.TextType())),
style_variant_(static_cast<unsigned>(text.StyleVariant())),
is_generated_text_(text.IsGeneratedText()),
is_hidden_for_paint_(false),
is_hidden_for_paint_(text.IsHiddenForPaint()),
text_direction_(static_cast<unsigned>(text.ResolvedDirection())) {
DCHECK_LE(text_.start_offset, text_.end_offset);
#if DCHECK_IS_ON()
......@@ -46,7 +46,7 @@ NGFragmentItem::NGFragmentItem(const NGPhysicalBoxFragment& box,
rect_({PhysicalOffset(), box.Size()}),
type_(kBox),
style_variant_(static_cast<unsigned>(box.StyleVariant())),
is_hidden_for_paint_(false),
is_hidden_for_paint_(box.IsHiddenForPaint()),
text_direction_(static_cast<unsigned>(resolved_direction)) {}
NGFragmentItem::~NGFragmentItem() {
......
......@@ -63,6 +63,12 @@ inline bool IsVisibleToPaint(const NGPhysicalFragment& fragment,
style.Visibility() == EVisibility::kVisible;
}
inline bool IsVisibleToPaint(const NGFragmentItem& item,
const ComputedStyle& style) {
return !item.IsHiddenForPaint() &&
style.Visibility() == EVisibility::kVisible;
}
bool FragmentVisibleToHitTestRequest(const NGPaintFragment& paint_fragment,
const HitTestRequest& request) {
const NGPhysicalFragment& fragment = paint_fragment.PhysicalFragment();
......@@ -1157,7 +1163,9 @@ void NGBoxFragmentPainter::PaintTextChild(const NGPaintFragment& paint_fragment,
void NGBoxFragmentPainter::PaintTextItem(const NGInlineCursor& cursor,
const PaintInfo& paint_info,
const PhysicalOffset& paint_offset) {
DCHECK_EQ(cursor.CurrentItem()->Type(), NGFragmentItem::kText);
DCHECK(cursor.CurrentItem());
const NGFragmentItem& item = *cursor.CurrentItem();
DCHECK_EQ(item.Type(), NGFragmentItem::kText);
DCHECK(items_);
// Only paint during the foreground/selection phases.
......@@ -1167,6 +1175,13 @@ void NGBoxFragmentPainter::PaintTextItem(const NGInlineCursor& cursor,
paint_info.phase != PaintPhase::kMask)
return;
// Need to check |IsHiddenForPaint()| for each item, but checking the style is
// not needed if we reach here, because text items should have the same style
// as their parents.
if (UNLIKELY(item.IsHiddenForPaint()))
return;
DCHECK(IsVisibleToPaint(item, item.Style()));
NGTextFragmentPainter<NGInlineCursor> text_painter(cursor);
text_painter.Paint(paint_info, paint_offset);
}
......@@ -1193,14 +1208,18 @@ NGBoxFragmentPainter::MoveTo NGBoxFragmentPainter::PaintBoxItem(
DCHECK_EQ(item.Type(), NGFragmentItem::kBox);
DCHECK(items_);
const ComputedStyle& style = item.Style();
if (UNLIKELY(!IsVisibleToPaint(item, style)))
return kSkipChildren;
// Nothing to paint if this is a culled inline box. Proceed to its
// descendants.
const NGPhysicalBoxFragment* child_fragment = item.BoxFragment();
if (!child_fragment)
return kDontSkipChildren;
if (child_fragment->HasSelfPaintingLayer() ||
child_fragment->IsHiddenForPaint() || child_fragment->IsFloating())
DCHECK(!child_fragment->IsHiddenForPaint());
if (child_fragment->HasSelfPaintingLayer() || child_fragment->IsFloating())
return kSkipChildren;
// TODO(kojii): Check CullRect.
......
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