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

Use culled recct for <br> if it is not selected

|NGBoxFragmentPainter| skips painitng if the ink overflow
is outside of culled rect, but doesn't apply the optimization
to <br> because its ink overflow is empty but selection needs
to be painted.

This patch restricts it only when the <br> is selected.

Note, currently there are 3 code paths that paint <br>:
1. Legacy
2. LayoutNG (NGPaintFragment)
3. LayoutNG (NGFragmentItem, not enabled yet, crbug.com/982194)
This patch changes 2 and 3.

Bug: 982194
Change-Id: I87a0b21b5dae3e9d04daa71a3366f4b37cdb7268
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2147439Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758874}
parent 5d6779c9
...@@ -58,6 +58,10 @@ LayoutRectOutsets BoxStrutToLayoutRectOutsets( ...@@ -58,6 +58,10 @@ LayoutRectOutsets BoxStrutToLayoutRectOutsets(
LayoutUnit(box_strut.bottom), LayoutUnit(box_strut.left)); LayoutUnit(box_strut.bottom), LayoutUnit(box_strut.left));
} }
inline bool HasSelection(const LayoutObject* layout_object) {
return layout_object->GetSelectionState() != SelectionState::kNone;
}
inline bool IsVisibleToPaint(const NGPhysicalFragment& fragment, inline bool IsVisibleToPaint(const NGPhysicalFragment& fragment,
const ComputedStyle& style) { const ComputedStyle& style) {
return !fragment.IsHiddenForPaint() && return !fragment.IsHiddenForPaint() &&
...@@ -1364,7 +1368,8 @@ void NGBoxFragmentPainter::PaintInlineChildren( ...@@ -1364,7 +1368,8 @@ void NGBoxFragmentPainter::PaintInlineChildren(
if (!paint_info.IntersectsCullRect(child->InkOverflow(), if (!paint_info.IntersectsCullRect(child->InkOverflow(),
paint_offset + child->Offset()) && paint_offset + child->Offset()) &&
// Don't skip empty size text in order to paint selection for <br>. // Don't skip empty size text in order to paint selection for <br>.
!(child_fragment.IsText() && child_fragment.Size().IsEmpty())) !(child_fragment.IsText() && child_fragment.Size().IsEmpty() &&
HasSelection(child_fragment.GetLayoutObject())))
continue; continue;
if (child_fragment.Type() == NGPhysicalFragment::kFragmentText) { if (child_fragment.Type() == NGPhysicalFragment::kFragmentText) {
...@@ -1437,7 +1442,7 @@ void NGBoxFragmentPainter::PaintTextItem(const NGInlineCursor& cursor, ...@@ -1437,7 +1442,7 @@ void NGBoxFragmentPainter::PaintTextItem(const NGInlineCursor& cursor,
if (!paint_info.IntersectsCullRect( if (!paint_info.IntersectsCullRect(
item.InkOverflow(), paint_offset + item.OffsetInContainerBlock()) && item.InkOverflow(), paint_offset + item.OffsetInContainerBlock()) &&
// Don't skip <br>, it doesn't have ink but need to paint selection. // Don't skip <br>, it doesn't have ink but need to paint selection.
!item.IsLineBreak()) !(item.IsLineBreak() && HasSelection(item.GetLayoutObject())))
return; return;
NGTextFragmentPainter<NGInlineCursor> text_painter(cursor, parent_offset); NGTextFragmentPainter<NGInlineCursor> text_painter(cursor, parent_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