Commit 505d351f authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[FragmentItem] Pass NGInlineCursor to NG{Inline,Box}FragmentPainter

Following up r741013 <crrev.com/c/2053633>, this patch passes
|NGInlineCursor|. This |NGInlineCursor| can be the source of
all necessary operations when painting/hit-testing
|LayoutInline|.

Bug: 982194
Change-Id: I43bdb8354a3e63ad58b2f9334e19e43cda39eb6d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2053904Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741350}
parent dd3e68b8
...@@ -1064,12 +1064,11 @@ bool LayoutInline::NodeAtPoint(HitTestResult& result, ...@@ -1064,12 +1064,11 @@ bool LayoutInline::NodeAtPoint(HitTestResult& result,
const NGFragmentItem& item = *cursor.Current().Item(); const NGFragmentItem& item = *cursor.Current().Item();
const NGPhysicalBoxFragment* box_fragment = item.BoxFragment(); const NGPhysicalBoxFragment* box_fragment = item.BoxFragment();
DCHECK(box_fragment); DCHECK(box_fragment);
NGInlineCursor descendants = cursor.CursorForDescendants();
// NGBoxFragmentPainter::NodeAtPoint() takes an offset that is accumulated // NGBoxFragmentPainter::NodeAtPoint() takes an offset that is accumulated
// up to the fragment itself. Compute this offset. // up to the fragment itself. Compute this offset.
const PhysicalOffset child_offset = const PhysicalOffset child_offset =
accumulated_offset + item.OffsetInContainerBlock(); accumulated_offset + item.OffsetInContainerBlock();
if (NGBoxFragmentPainter(item, *box_fragment, &descendants) if (NGBoxFragmentPainter(cursor, item, *box_fragment)
.NodeAtPoint(result, hit_test_location, child_offset, .NodeAtPoint(result, hit_test_location, child_offset,
hit_test_action)) hit_test_action))
return true; return true;
......
...@@ -82,6 +82,11 @@ NGInlineCursor::NGInlineCursor(const NGPaintFragment& root_paint_fragment) { ...@@ -82,6 +82,11 @@ NGInlineCursor::NGInlineCursor(const NGPaintFragment& root_paint_fragment) {
SetRoot(root_paint_fragment); SetRoot(root_paint_fragment);
} }
NGInlineCursor::NGInlineCursor(const NGInlineBackwardCursor& backward_cursor)
: NGInlineCursor(backward_cursor.cursor_) {
MoveTo(backward_cursor.Current());
}
bool NGInlineCursor::operator==(const NGInlineCursor& other) const { bool NGInlineCursor::operator==(const NGInlineCursor& other) const {
if (root_paint_fragment_) { if (root_paint_fragment_) {
return root_paint_fragment_ == other.root_paint_fragment_ && return root_paint_fragment_ == other.root_paint_fragment_ &&
......
...@@ -25,6 +25,7 @@ class LayoutObject; ...@@ -25,6 +25,7 @@ class LayoutObject;
class LayoutUnit; class LayoutUnit;
class NGFragmentItem; class NGFragmentItem;
class NGFragmentItems; class NGFragmentItems;
class NGInlineBackwardCursor;
class NGInlineBreakToken; class NGInlineBreakToken;
class NGInlineCursor; class NGInlineCursor;
class NGPaintFragment; class NGPaintFragment;
...@@ -177,6 +178,7 @@ class CORE_EXPORT NGInlineCursor { ...@@ -177,6 +178,7 @@ class CORE_EXPORT NGInlineCursor {
ItemsSpan items); ItemsSpan items);
explicit NGInlineCursor(const NGPaintFragment& root_paint_fragment); explicit NGInlineCursor(const NGPaintFragment& root_paint_fragment);
NGInlineCursor(const NGInlineCursor& other) = default; NGInlineCursor(const NGInlineCursor& other) = default;
NGInlineCursor(const NGInlineBackwardCursor& backward_cursor);
// Creates an |NGInlineCursor| without the root. Even when callers don't know // Creates an |NGInlineCursor| without the root. Even when callers don't know
// the root of the inline formatting context, this cursor can |MoveTo()| // the root of the inline formatting context, this cursor can |MoveTo()|
...@@ -465,6 +467,8 @@ class CORE_EXPORT NGInlineBackwardCursor { ...@@ -465,6 +467,8 @@ class CORE_EXPORT NGInlineBackwardCursor {
Vector<const NGPaintFragment*, 16> sibling_paint_fragments_; Vector<const NGPaintFragment*, 16> sibling_paint_fragments_;
Vector<NGInlineCursor::ItemsSpan::iterator, 16> sibling_item_iterators_; Vector<NGInlineCursor::ItemsSpan::iterator, 16> sibling_item_iterators_;
wtf_size_t current_index_; wtf_size_t current_index_;
friend class NGInlineCursor;
}; };
CORE_EXPORT std::ostream& operator<<(std::ostream&, const NGInlineCursor&); CORE_EXPORT std::ostream& operator<<(std::ostream&, const NGInlineCursor&);
......
...@@ -443,7 +443,7 @@ void NGBoxFragmentPainter::PaintObject( ...@@ -443,7 +443,7 @@ void NGBoxFragmentPainter::PaintObject(
if (paint_phase != PaintPhase::kSelfOutlineOnly && if (paint_phase != PaintPhase::kSelfOutlineOnly &&
(!physical_box_fragment.Children().empty() || (!physical_box_fragment.Children().empty() ||
physical_box_fragment.HasItems() || descendants_) && physical_box_fragment.HasItems() || inline_box_cursor_) &&
!paint_info.DescendantPaintingBlocked()) { !paint_info.DescendantPaintingBlocked()) {
if (RuntimeEnabledFeatures::LayoutNGFragmentPaintEnabled()) { if (RuntimeEnabledFeatures::LayoutNGFragmentPaintEnabled()) {
if (UNLIKELY(paint_phase == PaintPhase::kForeground && if (UNLIKELY(paint_phase == PaintPhase::kForeground &&
...@@ -452,17 +452,18 @@ void NGBoxFragmentPainter::PaintObject( ...@@ -452,17 +452,18 @@ void NGBoxFragmentPainter::PaintObject(
} }
if (paint_phase != PaintPhase::kFloat) { if (paint_phase != PaintPhase::kFloat) {
if (UNLIKELY(descendants_)) { if (UNLIKELY(inline_box_cursor_)) {
// Use the descendants cursor for this painter if it is given. // Use the descendants cursor for this painter if it is given.
// 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_); DCHECK(box_item_);
NGInlineCursor descendants = inline_box_cursor_->CursorForDescendants();
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(),
paint_offset_to_inline_formatting_context, paint_offset_to_inline_formatting_context,
box_item_->OffsetInContainerBlock(), descendants_); box_item_->OffsetInContainerBlock(), &descendants);
} else if (items_) { } else if (items_) {
if (physical_box_fragment.IsBlockFlow()) { if (physical_box_fragment.IsBlockFlow()) {
PaintBlockFlowContents(paint_info, paint_offset); PaintBlockFlowContents(paint_info, paint_offset);
...@@ -1474,8 +1475,10 @@ void NGBoxFragmentPainter::PaintBoxItem(const NGFragmentItem& item, ...@@ -1474,8 +1475,10 @@ void NGBoxFragmentPainter::PaintBoxItem(const NGFragmentItem& item,
return; return;
} }
DCHECK(child_fragment->IsInlineBox());
NGInlineBoxFragmentPainter(cursor, item, *child_fragment) NGInlineBoxFragmentPainter(cursor, item, *child_fragment)
.Paint(paint_info, paint_offset); .Paint(paint_info, paint_offset);
return;
} }
NGInlineCursor children = cursor.CursorForDescendants(); NGInlineCursor children = cursor.CursorForDescendants();
...@@ -1530,14 +1533,10 @@ void NGBoxFragmentPainter::PaintTextClipMask(GraphicsContext& context, ...@@ -1530,14 +1533,10 @@ void NGBoxFragmentPainter::PaintTextClipMask(GraphicsContext& context,
return; return;
} }
DCHECK(inline_box_cursor_);
DCHECK(box_item_); DCHECK(box_item_);
// TODO(kojii): Callers have the |NGInlineCursor| that can be passed down to NGInlineBoxFragmentPainter inline_box_painter(*inline_box_cursor_,
// here. *box_item_);
NGInlineCursor cursor;
cursor.MoveTo(*box_item_);
NGInlineCursor descendants = cursor.CursorForDescendants();
NGInlineBoxFragmentPainter inline_box_painter(cursor, *box_item_,
&descendants);
PaintTextClipMask(paint_info, PaintTextClipMask(paint_info,
paint_offset - box_item_->OffsetInContainerBlock(), paint_offset - box_item_->OffsetInContainerBlock(),
&inline_box_painter); &inline_box_painter);
...@@ -1862,7 +1861,7 @@ bool NGBoxFragmentPainter::HitTestLineBoxFragment( ...@@ -1862,7 +1861,7 @@ bool NGBoxFragmentPainter::HitTestLineBoxFragment(
bool NGBoxFragmentPainter::HitTestChildBoxFragment( bool NGBoxFragmentPainter::HitTestChildBoxFragment(
const HitTestContext& hit_test, const HitTestContext& hit_test,
const NGPhysicalBoxFragment& fragment, const NGPhysicalBoxFragment& fragment,
const NGInlineBackwardCursor& cursor, const NGInlineBackwardCursor& backward_cursor,
const PhysicalOffset& physical_offset) { const PhysicalOffset& physical_offset) {
// Note: Floats should only be hit tested in the |kHitTestFloat| phase, so we // Note: Floats should only be hit tested in the |kHitTestFloat| phase, so we
// shouldn't enter a float when |action| doesn't match. However, as floats may // shouldn't enter a float when |action| doesn't match. However, as floats may
...@@ -1876,7 +1875,7 @@ bool NGBoxFragmentPainter::HitTestChildBoxFragment( ...@@ -1876,7 +1875,7 @@ bool NGBoxFragmentPainter::HitTestChildBoxFragment(
DCHECK(!fragment.IsAtomicInline()); DCHECK(!fragment.IsAtomicInline());
DCHECK(!fragment.IsFloating()); DCHECK(!fragment.IsFloating());
if (const NGPaintFragment* paint_fragment = if (const NGPaintFragment* paint_fragment =
cursor.Current().PaintFragment()) { backward_cursor.Current().PaintFragment()) {
if (fragment.IsInlineBox()) { if (fragment.IsInlineBox()) {
return NGBoxFragmentPainter(*paint_fragment) return NGBoxFragmentPainter(*paint_fragment)
.NodeAtPoint(hit_test, physical_offset); .NodeAtPoint(hit_test, physical_offset);
...@@ -1887,17 +1886,17 @@ bool NGBoxFragmentPainter::HitTestChildBoxFragment( ...@@ -1887,17 +1886,17 @@ bool NGBoxFragmentPainter::HitTestChildBoxFragment(
.NodeAtPoint(*hit_test.result, hit_test.location, physical_offset, .NodeAtPoint(*hit_test.result, hit_test.location, physical_offset,
hit_test.action); hit_test.action);
} }
NGInlineCursor cursor(backward_cursor);
const NGFragmentItem* item = cursor.Current().Item(); const NGFragmentItem* item = cursor.Current().Item();
DCHECK(item); DCHECK(item);
DCHECK_EQ(item->BoxFragment(), &fragment); DCHECK_EQ(item->BoxFragment(), &fragment);
NGInlineCursor descendants = cursor.CursorForDescendants();
if (fragment.IsInlineBox()) { if (fragment.IsInlineBox()) {
return NGBoxFragmentPainter(*item, fragment, &descendants) return NGBoxFragmentPainter(cursor, *item, fragment)
.NodeAtPoint(hit_test, physical_offset); .NodeAtPoint(hit_test, physical_offset);
} }
// When traversing into a different inline formatting context, // When traversing into a different inline formatting context,
// |inline_root_offset| needs to be updated. // |inline_root_offset| needs to be updated.
return NGBoxFragmentPainter(*item, fragment, &descendants) return NGBoxFragmentPainter(cursor, *item, fragment)
.NodeAtPoint(*hit_test.result, hit_test.location, physical_offset, .NodeAtPoint(*hit_test.result, hit_test.location, physical_offset,
hit_test.action); hit_test.action);
} }
...@@ -1965,9 +1964,10 @@ bool NGBoxFragmentPainter::HitTestChildren( ...@@ -1965,9 +1964,10 @@ bool NGBoxFragmentPainter::HitTestChildren(
NGInlineCursor cursor(*paint_fragment_); NGInlineCursor cursor(*paint_fragment_);
return HitTestChildren(hit_test, cursor, accumulated_offset); return HitTestChildren(hit_test, cursor, accumulated_offset);
} }
if (UNLIKELY(descendants_)) { if (UNLIKELY(inline_box_cursor_)) {
if (*descendants_) NGInlineCursor descendants = inline_box_cursor_->CursorForDescendants();
return HitTestChildren(hit_test, *descendants_, accumulated_offset); if (descendants)
return HitTestChildren(hit_test, descendants, accumulated_offset);
return false; return false;
} }
if (items_) { if (items_) {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "third_party/blink/renderer/core/layout/api/hit_test_action.h" #include "third_party/blink/renderer/core/layout/api/hit_test_action.h"
#include "third_party/blink/renderer/core/layout/background_bleed_avoidance.h" #include "third_party/blink/renderer/core/layout/background_bleed_avoidance.h"
#include "third_party/blink/renderer/core/layout/ng/geometry/ng_border_edges.h" #include "third_party/blink/renderer/core/layout/ng/geometry/ng_border_edges.h"
#include "third_party/blink/renderer/core/layout/ng/inline/ng_inline_cursor.h"
#include "third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h" #include "third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h"
#include "third_party/blink/renderer/core/paint/box_painter_base.h" #include "third_party/blink/renderer/core/paint/box_painter_base.h"
#include "third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h" #include "third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h"
...@@ -42,13 +43,9 @@ class NGBoxFragmentPainter : public BoxPainterBase { ...@@ -42,13 +43,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, NGBoxFragmentPainter(const NGInlineCursor& inline_box_cursor,
const NGPaintFragment* paint_fragment, const NGFragmentItem& item,
const NGFragmentItem* box_item, const NGPhysicalBoxFragment& fragment);
NGInlineCursor* descendants);
NGBoxFragmentPainter(const NGFragmentItem& item,
const NGPhysicalBoxFragment& fragment,
NGInlineCursor* descendants);
void Paint(const PaintInfo&); void Paint(const PaintInfo&);
void PaintObject(const PaintInfo&, void PaintObject(const PaintInfo&,
...@@ -95,8 +92,8 @@ class NGBoxFragmentPainter : public BoxPainterBase { ...@@ -95,8 +92,8 @@ 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, const NGInlineCursor* inline_box_cursor = nullptr,
NGInlineCursor* descendants = nullptr); const NGFragmentItem* = nullptr);
enum MoveTo { kDontSkipChildren, kSkipChildren }; enum MoveTo { kDontSkipChildren, kSkipChildren };
bool ShouldPaint(const ScopedPaintState&) const; bool ShouldPaint(const ScopedPaintState&) const;
...@@ -294,7 +291,7 @@ class NGBoxFragmentPainter : public BoxPainterBase { ...@@ -294,7 +291,7 @@ class NGBoxFragmentPainter : public BoxPainterBase {
const NGPaintFragment* paint_fragment_; const NGPaintFragment* paint_fragment_;
const NGFragmentItems* items_; const NGFragmentItems* items_;
const NGFragmentItem* box_item_ = nullptr; const NGFragmentItem* box_item_ = nullptr;
NGInlineCursor* descendants_ = nullptr; const NGInlineCursor* inline_box_cursor_ = nullptr;
mutable base::Optional<NGBorderEdges> border_edges_; mutable base::Optional<NGBorderEdges> border_edges_;
}; };
...@@ -302,37 +299,44 @@ inline NGBoxFragmentPainter::NGBoxFragmentPainter( ...@@ -302,37 +299,44 @@ 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, const NGInlineCursor* inline_box_cursor,
NGInlineCursor* descendants) const NGFragmentItem* box_item)
: 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), box_item_(box_item),
descendants_(descendants) { inline_box_cursor_(inline_box_cursor) {
DCHECK(box.IsBox() || box.IsRenderedLegend()); DCHECK(box.IsBox() || box.IsRenderedLegend());
DCHECK(!paint_fragment || !descendants);
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
if (box.IsInlineBox()) { if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) {
DCHECK(paint_fragment_ || box_item_); DCHECK(!paint_fragment_);
if (inline_box_cursor_)
DCHECK_EQ(inline_box_cursor_->Current().Item(), box_item_);
if (box_item_)
DCHECK_EQ(box_item_->BoxFragment(), &box);
DCHECK_EQ(box.IsInlineBox(), !!inline_box_cursor_);
DCHECK_EQ(box.IsInlineBox(), !!box_item_);
} else {
DCHECK(!inline_box_cursor_);
DCHECK(!box_item_);
if (paint_fragment) if (paint_fragment)
DCHECK_EQ(&paint_fragment->PhysicalFragment(), &box); DCHECK_EQ(&paint_fragment->PhysicalFragment(), &box);
if (box_item) if (box.IsInlineBox()) {
DCHECK_EQ(box_item->BoxFragment(), &box); DCHECK(paint_fragment_);
} else if (!box.IsInlineFormattingContext()) { } else if (box.IsInlineFormattingContext()) {
// We may not have |paint_fragment_| nor |box_item_|. // If no children, there maybe or may not be NGPaintFragment.
} else { // TODO(kojii): To be investigated if this correct or should be fixed.
// If no children, there maybe or may not be NGPaintFragment. if (!box.Children().empty()) {
// TODO(kojii): To be investigated if this correct or should be fixed. if (!box.GetLayoutObject() ||
if (!box.Children().empty()) { !box.GetLayoutObject()->PaintBlockedByDisplayLock(
if (!box.GetLayoutObject() || DisplayLockLifecycleTarget::kChildren)) {
!box.GetLayoutObject()->PaintBlockedByDisplayLock( DCHECK(paint_fragment);
DisplayLockLifecycleTarget::kChildren)) { }
DCHECK(paint_fragment || box.HasItems());
} }
if (paint_fragment) } else {
DCHECK_EQ(&paint_fragment->PhysicalFragment(), &box); // We may not have |paint_fragment_| nor |box_item_|.
} }
} }
#endif #endif
...@@ -343,8 +347,8 @@ inline NGBoxFragmentPainter::NGBoxFragmentPainter( ...@@ -343,8 +347,8 @@ inline NGBoxFragmentPainter::NGBoxFragmentPainter(
: NGBoxFragmentPainter(fragment, : NGBoxFragmentPainter(fragment,
*fragment.GetLayoutObject(), *fragment.GetLayoutObject(),
/* paint_fragment */ nullptr, /* paint_fragment */ nullptr,
/* box_item */ nullptr, /* inline_box_cursor */ nullptr,
/* descendants */ nullptr) {} /* box_item */ nullptr) {}
inline NGBoxFragmentPainter::NGBoxFragmentPainter( inline NGBoxFragmentPainter::NGBoxFragmentPainter(
const NGPhysicalBoxFragment& fragment, const NGPhysicalBoxFragment& fragment,
...@@ -356,22 +360,8 @@ inline NGBoxFragmentPainter::NGBoxFragmentPainter( ...@@ -356,22 +360,8 @@ inline NGBoxFragmentPainter::NGBoxFragmentPainter(
: *static_cast<const DisplayItemClient*>( : *static_cast<const DisplayItemClient*>(
fragment.GetLayoutObject()), fragment.GetLayoutObject()),
paint_fragment, paint_fragment,
/* box_item */ nullptr, /* inline_box_cursor */ nullptr,
/* descendants */ nullptr) {} /* box_item */ nullptr) {}
inline NGBoxFragmentPainter::NGBoxFragmentPainter(
const NGPhysicalBoxFragment& fragment,
const NGPaintFragment* paint_fragment,
const NGFragmentItem* box_item,
NGInlineCursor* descendants)
: NGBoxFragmentPainter(
fragment,
paint_fragment
? *static_cast<const DisplayItemClient*>(paint_fragment)
: *static_cast<const DisplayItemClient*>(box_item),
paint_fragment,
box_item,
descendants) {}
inline NGBoxFragmentPainter::NGBoxFragmentPainter( inline NGBoxFragmentPainter::NGBoxFragmentPainter(
const NGPaintFragment& paint_fragment) const NGPaintFragment& paint_fragment)
...@@ -381,14 +371,14 @@ inline NGBoxFragmentPainter::NGBoxFragmentPainter( ...@@ -381,14 +371,14 @@ inline NGBoxFragmentPainter::NGBoxFragmentPainter(
&paint_fragment) {} &paint_fragment) {}
inline NGBoxFragmentPainter::NGBoxFragmentPainter( inline NGBoxFragmentPainter::NGBoxFragmentPainter(
const NGInlineCursor& inline_box_cursor,
const NGFragmentItem& item, const NGFragmentItem& item,
const NGPhysicalBoxFragment& fragment, const NGPhysicalBoxFragment& fragment)
NGInlineCursor* descendants)
: NGBoxFragmentPainter(fragment, : NGBoxFragmentPainter(fragment,
item, item,
/* paint_fragment */ nullptr, /* paint_fragment */ nullptr,
&item, &inline_box_cursor,
descendants) { &item) {
DCHECK_EQ(item.BoxFragment(), &fragment); DCHECK_EQ(item.BoxFragment(), &fragment);
DCHECK(fragment.IsInlineBox()); DCHECK(fragment.IsInlineBox());
} }
......
...@@ -71,9 +71,10 @@ void NGInlineBoxFragmentPainter::Paint(const PaintInfo& paint_info, ...@@ -71,9 +71,10 @@ void NGInlineBoxFragmentPainter::Paint(const PaintInfo& paint_info,
suppress_box_decoration_background); suppress_box_decoration_background);
return; return;
} }
DCHECK(inline_box_cursor_);
DCHECK(inline_box_item_); DCHECK(inline_box_item_);
NGBoxFragmentPainter box_painter(*inline_box_item_, PhysicalFragment(), NGBoxFragmentPainter box_painter(*inline_box_cursor_, *inline_box_item_,
descendants_); PhysicalFragment());
box_painter.PaintObject(paint_info, adjusted_paint_offset, box_painter.PaintObject(paint_info, adjusted_paint_offset,
suppress_box_decoration_background); suppress_box_decoration_background);
} }
...@@ -131,10 +132,9 @@ void NGInlineBoxFragmentPainterBase::PaintBackgroundBorderShadow( ...@@ -131,10 +132,9 @@ void NGInlineBoxFragmentPainterBase::PaintBackgroundBorderShadow(
return; return;
} }
DCHECK(inline_box_cursor_); DCHECK(inline_box_cursor_);
NGInlineCursor descendants = inline_box_cursor_->CursorForDescendants();
NGBoxFragmentPainter box_painter( NGBoxFragmentPainter box_painter(
To<NGPhysicalBoxFragment>(inline_box_fragment_), *inline_box_cursor_, *inline_box_item_,
inline_box_paint_fragment_, inline_box_item_, &descendants); To<NGPhysicalBoxFragment>(inline_box_fragment_));
PaintBoxDecorationBackground(box_painter, paint_info, paint_offset, PaintBoxDecorationBackground(box_painter, paint_info, paint_offset,
adjusted_frame_rect, geometry, adjusted_frame_rect, geometry,
object_has_multiple_boxes, object_has_multiple_boxes,
...@@ -371,10 +371,23 @@ void NGInlineBoxFragmentPainter::PaintAllFragments( ...@@ -371,10 +371,23 @@ void NGInlineBoxFragmentPainter::PaintAllFragments(
DCHECK(item); DCHECK(item);
const NGPhysicalBoxFragment* box_fragment = item->BoxFragment(); const NGPhysicalBoxFragment* box_fragment = item->BoxFragment();
DCHECK(box_fragment); DCHECK(box_fragment);
NGInlineCursor descendants = cursor.CursorForDescendants(); NGInlineBoxFragmentPainter(cursor, *item, *box_fragment)
NGInlineBoxFragmentPainter(cursor, *item, *box_fragment, &descendants)
.Paint(paint_info, paint_offset); .Paint(paint_info, paint_offset);
} }
} }
#if DCHECK_IS_ON()
void NGInlineBoxFragmentPainter::CheckValid() const {
if (inline_box_item_) {
DCHECK(inline_box_cursor_);
DCHECK_EQ(inline_box_cursor_->Current().Item(), inline_box_item_);
}
DCHECK_EQ(inline_box_fragment_.Type(),
NGPhysicalFragment::NGFragmentType::kFragmentBox);
DCHECK_EQ(inline_box_fragment_.BoxType(),
NGPhysicalFragment::NGBoxType::kInlineBox);
}
#endif
} // namespace blink } // namespace blink
...@@ -148,27 +148,20 @@ class NGInlineBoxFragmentPainter : public NGInlineBoxFragmentPainterBase { ...@@ -148,27 +148,20 @@ class NGInlineBoxFragmentPainter : public NGInlineBoxFragmentPainterBase {
// Constructor for |NGFragmentItem|. // Constructor for |NGFragmentItem|.
NGInlineBoxFragmentPainter(const NGInlineCursor& inline_box_cursor, NGInlineBoxFragmentPainter(const NGInlineCursor& inline_box_cursor,
const NGFragmentItem& inline_box_item, const NGFragmentItem& inline_box_item,
const NGPhysicalBoxFragment& inline_box_fragment, const NGPhysicalBoxFragment& inline_box_fragment)
NGInlineCursor* descendants = nullptr)
: NGInlineBoxFragmentPainterBase(inline_box_cursor, : NGInlineBoxFragmentPainterBase(inline_box_cursor,
inline_box_item, inline_box_item,
inline_box_fragment, inline_box_fragment,
*inline_box_fragment.GetLayoutObject(), *inline_box_fragment.GetLayoutObject(),
inline_box_fragment.Style(), inline_box_fragment.Style(),
inline_box_fragment.Style()), inline_box_fragment.Style()) {
descendants_(descendants) { CheckValid();
DCHECK_EQ(inline_box_fragment.Type(),
NGPhysicalFragment::NGFragmentType::kFragmentBox);
DCHECK_EQ(inline_box_fragment.BoxType(),
NGPhysicalFragment::NGBoxType::kInlineBox);
} }
NGInlineBoxFragmentPainter(const NGInlineCursor& inline_box_cursor, NGInlineBoxFragmentPainter(const NGInlineCursor& inline_box_cursor,
const NGFragmentItem& inline_box_item, const NGFragmentItem& inline_box_item)
NGInlineCursor* descendants = nullptr)
: NGInlineBoxFragmentPainter(inline_box_cursor, : NGInlineBoxFragmentPainter(inline_box_cursor,
inline_box_item, inline_box_item,
*inline_box_item.BoxFragment(), *inline_box_item.BoxFragment()) {
descendants) {
DCHECK(inline_box_item.BoxFragment()); DCHECK(inline_box_item.BoxFragment());
} }
...@@ -185,8 +178,13 @@ class NGInlineBoxFragmentPainter : public NGInlineBoxFragmentPainterBase { ...@@ -185,8 +178,13 @@ class NGInlineBoxFragmentPainter : public NGInlineBoxFragmentPainterBase {
const NGBorderEdges BorderEdges() const final; const NGBorderEdges BorderEdges() const final;
#if DCHECK_IS_ON()
void CheckValid() const;
#else
void CheckValid() const {}
#endif
mutable base::Optional<NGBorderEdges> border_edges_; mutable base::Optional<NGBorderEdges> border_edges_;
NGInlineCursor* descendants_ = nullptr;
}; };
// Painter for LayoutNG line box fragments. Line boxes don't paint anything, // Painter for LayoutNG line box fragments. Line boxes don't paint anything,
......
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