Commit 99b55faa authored by Koji Ishii's avatar Koji Ishii Committed by Chromium LUCI CQ

Remove NGPaintFragment From NGTextFragmentPainter

The code to call |NGBoxFragmentPainter| was removed in r832702
<crrev.com/c/2567145> and <crrev.com/c/2586636>.

Bug: 1154531
Change-Id: I5f09a206dc15464bda98f577e0a26f3132039f6f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586450Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836172}
parent ea4ddecc
...@@ -1677,19 +1677,7 @@ void NGBoxFragmentPainter::PaintAtomicInlineChild(const NGPaintFragment& child, ...@@ -1677,19 +1677,7 @@ void NGBoxFragmentPainter::PaintAtomicInlineChild(const NGPaintFragment& child,
void NGBoxFragmentPainter::PaintTextChild(const NGPaintFragment& paint_fragment, void NGBoxFragmentPainter::PaintTextChild(const NGPaintFragment& paint_fragment,
const PaintInfo& paint_info, const PaintInfo& paint_info,
const PhysicalOffset& paint_offset) { const PhysicalOffset& paint_offset) {
// Inline blocks should be painted by PaintAtomicInlineChild. NOTREACHED();
DCHECK(!paint_fragment.PhysicalFragment().IsAtomicInline());
// Only paint during the foreground/selection phases.
if (paint_info.phase != PaintPhase::kForeground &&
paint_info.phase != PaintPhase::kSelectionDragImage &&
paint_info.phase != PaintPhase::kTextClip &&
paint_info.phase != PaintPhase::kMask)
return;
NGTextPainterCursor cursor(paint_fragment);
NGTextFragmentPainter<NGTextPainterCursor> text_painter(cursor);
text_painter.Paint(paint_info, paint_offset);
} }
void NGBoxFragmentPainter::PaintTextItem(const NGInlineCursor& cursor, void NGBoxFragmentPainter::PaintTextItem(const NGInlineCursor& cursor,
...@@ -1717,7 +1705,7 @@ void NGBoxFragmentPainter::PaintTextItem(const NGInlineCursor& cursor, ...@@ -1717,7 +1705,7 @@ void NGBoxFragmentPainter::PaintTextItem(const NGInlineCursor& cursor,
ScopedDisplayItemFragment display_item_fragment(paint_info.context, ScopedDisplayItemFragment display_item_fragment(paint_info.context,
item.FragmentId()); item.FragmentId());
NGTextFragmentPainter<NGInlineCursor> text_painter(cursor, parent_offset); NGTextFragmentPainter text_painter(cursor, parent_offset);
text_painter.Paint(paint_info, paint_offset); text_painter.Paint(paint_info, paint_offset);
} }
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include "third_party/blink/renderer/core/paint/highlight_painting_utils.h" #include "third_party/blink/renderer/core/paint/highlight_painting_utils.h"
#include "third_party/blink/renderer/core/paint/inline_text_box_painter.h" #include "third_party/blink/renderer/core/paint/inline_text_box_painter.h"
#include "third_party/blink/renderer/core/paint/list_marker_painter.h" #include "third_party/blink/renderer/core/paint/list_marker_painter.h"
#include "third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h"
#include "third_party/blink/renderer/core/paint/ng/ng_text_painter.h" #include "third_party/blink/renderer/core/paint/ng/ng_text_painter.h"
#include "third_party/blink/renderer/core/paint/paint_info.h" #include "third_party/blink/renderer/core/paint/paint_info.h"
#include "third_party/blink/renderer/core/paint/text_painter_base.h" #include "third_party/blink/renderer/core/paint/text_painter_base.h"
...@@ -54,8 +53,6 @@ Color SelectionBackgroundColor(const Document& document, ...@@ -54,8 +53,6 @@ Color SelectionBackgroundColor(const Document& document,
return color; return color;
} }
// TODO(yosin): Remove |AsDisplayItemClient| once the transition to
// |NGFragmentItem| is done. http://crbug.com/982194
inline const DisplayItemClient& AsDisplayItemClient( inline const DisplayItemClient& AsDisplayItemClient(
const NGInlineCursor& cursor, const NGInlineCursor& cursor,
bool for_selection) { bool for_selection) {
...@@ -67,12 +64,6 @@ inline const DisplayItemClient& AsDisplayItemClient( ...@@ -67,12 +64,6 @@ inline const DisplayItemClient& AsDisplayItemClient(
return *cursor.Current().GetDisplayItemClient(); return *cursor.Current().GetDisplayItemClient();
} }
inline const DisplayItemClient& AsDisplayItemClient(
const NGTextPainterCursor& cursor,
bool for_selection) {
return cursor.PaintFragment();
}
inline PhysicalRect ComputeBoxRect(const NGInlineCursor& cursor, inline PhysicalRect ComputeBoxRect(const NGInlineCursor& cursor,
const PhysicalOffset& paint_offset, const PhysicalOffset& paint_offset,
const PhysicalOffset& parent_offset) { const PhysicalOffset& parent_offset) {
...@@ -85,17 +76,6 @@ inline PhysicalRect ComputeBoxRect(const NGInlineCursor& cursor, ...@@ -85,17 +76,6 @@ inline PhysicalRect ComputeBoxRect(const NGInlineCursor& cursor,
return box_rect; return box_rect;
} }
inline PhysicalRect ComputeBoxRect(const NGTextPainterCursor& cursor,
const PhysicalOffset& paint_offset,
const PhysicalOffset& parent_offset) {
PhysicalRect box_rect = cursor.PaintFragment().Rect();
// We round the y-axis to ensure consistent line heights.
PhysicalOffset adjusted_paint_offset(paint_offset.left,
LayoutUnit(paint_offset.top.Round()));
box_rect.offset += adjusted_paint_offset;
return box_rect;
}
inline const NGInlineCursor& InlineCursorForBlockFlow( inline const NGInlineCursor& InlineCursorForBlockFlow(
const NGInlineCursor& cursor, const NGInlineCursor& cursor,
base::Optional<NGInlineCursor>* storage) { base::Optional<NGInlineCursor>* storage) {
...@@ -106,83 +86,6 @@ inline const NGInlineCursor& InlineCursorForBlockFlow( ...@@ -106,83 +86,6 @@ inline const NGInlineCursor& InlineCursorForBlockFlow(
return **storage; return **storage;
} }
inline const NGInlineCursor& InlineCursorForBlockFlow(
const NGTextPainterCursor& cursor,
base::Optional<NGInlineCursor>* storage) {
if (*storage)
return **storage;
storage->emplace(cursor.RootPaintFragment());
(*storage)->MoveTo(cursor.PaintFragment());
return **storage;
}
// TODO(yosin): Remove |GetTextFragmentPaintInfo| once the transition to
// |NGFragmentItem| is done. http://crbug.com/982194
inline NGTextFragmentPaintInfo GetTextFragmentPaintInfo(
const NGInlineCursor& cursor) {
return cursor.CurrentItem()->TextPaintInfo(cursor.Items());
}
inline NGTextFragmentPaintInfo GetTextFragmentPaintInfo(
const NGTextPainterCursor& cursor) {
return cursor.CurrentItem()->PaintInfo();
}
// TODO(yosin): Remove |GetLineLeftAndRightForOffsets| once the transition to
// |NGFragmentItem| is done. http://crbug.com/982194
inline std::pair<LayoutUnit, LayoutUnit> GetLineLeftAndRightForOffsets(
const NGFragmentItem& text_item,
StringView text,
unsigned start_offset,
unsigned end_offset) {
return text_item.LineLeftAndRightForOffsets(text, start_offset, end_offset);
}
inline std::pair<LayoutUnit, LayoutUnit> GetLineLeftAndRightForOffsets(
const NGPhysicalTextFragment& text_fragment,
StringView text,
unsigned start_offset,
unsigned end_offset) {
return text_fragment.LineLeftAndRightForOffsets(start_offset, end_offset);
}
// TODO(yosin): Remove |ComputeLayoutSelectionStatus| once the transition to
// |NGFragmentItem| is done. http://crbug.com/982194
inline LayoutSelectionStatus ComputeLayoutSelectionStatus(
const NGInlineCursor& cursor) {
return cursor.Current()
.GetLayoutObject()
->GetFrame()
->Selection()
.ComputeLayoutSelectionStatus(cursor);
}
SelectionState ComputeSelectionState(const NGInlineCursor& cursor) {
return cursor.Current()
.GetLayoutObject()
->GetDocument()
.GetFrame()
->Selection()
.ComputeLayoutSelectionStateForCursor(cursor.Current());
}
// TODO(yosin): Remove |ComputeLocalRect| once the transition to
// |NGFragmentItem| is done. http://crbug.com/982194
inline PhysicalRect ComputeLocalRect(const NGFragmentItem& text_item,
StringView text,
unsigned start_offset,
unsigned end_offset) {
return text_item.LocalRect(text, start_offset, end_offset);
}
inline PhysicalRect ComputeLocalRect(
const NGPhysicalTextFragment& text_fragment,
StringView text,
unsigned start_offset,
unsigned end_offset) {
return text_fragment.LocalRect(start_offset, end_offset);
}
DocumentMarkerVector ComputeMarkersToPaint(Node* node, bool is_ellipsis) { DocumentMarkerVector ComputeMarkersToPaint(Node* node, bool is_ellipsis) {
// TODO(yoichio): Handle first-letter // TODO(yoichio): Handle first-letter
auto* text_node = DynamicTo<Text>(node); auto* text_node = DynamicTo<Text>(node);
...@@ -220,8 +123,7 @@ unsigned GetTextContentOffset(const Text& text, unsigned offset) { ...@@ -220,8 +123,7 @@ unsigned GetTextContentOffset(const Text& text, unsigned offset) {
// If "bar" is a TextFragment. That start(), end() {4, 7} correspond this // If "bar" is a TextFragment. That start(), end() {4, 7} correspond this
// offset. If a marker has StartOffset / EndOffset as {2, 6}, // offset. If a marker has StartOffset / EndOffset as {2, 6},
// ClampOffset returns{ 4,6 }, which represents "ba" on "foo_bar". // ClampOffset returns{ 4,6 }, which represents "ba" on "foo_bar".
template <typename TextItem> unsigned ClampOffset(unsigned offset, const NGFragmentItem& text_fragment) {
unsigned ClampOffset(unsigned offset, const TextItem& text_fragment) {
return std::min(std::max(offset, text_fragment.StartOffset()), return std::min(std::max(offset, text_fragment.StartOffset()),
text_fragment.EndOffset()); text_fragment.EndOffset());
} }
...@@ -245,14 +147,13 @@ void PaintRect(GraphicsContext& context, ...@@ -245,14 +147,13 @@ void PaintRect(GraphicsContext& context,
PaintRect(context, PhysicalRect(rect.offset + location, rect.size), color); PaintRect(context, PhysicalRect(rect.offset + location, rect.size), color);
} }
template <typename TextItem> PhysicalRect MarkerRectForForeground(const NGFragmentItem& text_fragment,
PhysicalRect MarkerRectForForeground(const TextItem& text_fragment,
StringView text, StringView text,
unsigned start_offset, unsigned start_offset,
unsigned end_offset) { unsigned end_offset) {
LayoutUnit start_position, end_position; LayoutUnit start_position, end_position;
std::tie(start_position, end_position) = GetLineLeftAndRightForOffsets( std::tie(start_position, end_position) =
text_fragment, text, start_offset, end_offset); text_fragment.LineLeftAndRightForOffsets(text, start_offset, end_offset);
const LayoutUnit height = text_fragment.Size() const LayoutUnit height = text_fragment.Size()
.ConvertToLogical(static_cast<WritingMode>( .ConvertToLogical(static_cast<WritingMode>(
...@@ -262,9 +163,8 @@ PhysicalRect MarkerRectForForeground(const TextItem& text_fragment, ...@@ -262,9 +163,8 @@ PhysicalRect MarkerRectForForeground(const TextItem& text_fragment,
} }
// Copied from InlineTextBoxPainter // Copied from InlineTextBoxPainter
template <typename TextItem>
void PaintDocumentMarkers(const PaintInfo& paint_info, void PaintDocumentMarkers(const PaintInfo& paint_info,
const TextItem& text_fragment, const NGFragmentItem& text_fragment,
StringView text, StringView text,
const DocumentMarkerVector& markers_to_paint, const DocumentMarkerVector& markers_to_paint,
const PhysicalOffset& box_origin, const PhysicalOffset& box_origin,
...@@ -320,8 +220,8 @@ void PaintDocumentMarkers(const PaintInfo& paint_info, ...@@ -320,8 +220,8 @@ void PaintDocumentMarkers(const PaintInfo& paint_info,
document, style, node, kPseudoIdTargetText); document, style, node, kPseudoIdTargetText);
} }
PaintRect(paint_info.context, PhysicalOffset(box_origin), PaintRect(paint_info.context, PhysicalOffset(box_origin),
ComputeLocalRect(text_fragment, text, paint_start_offset, text_fragment.LocalRect(text, paint_start_offset,
paint_end_offset), paint_end_offset),
color); color);
break; break;
} }
...@@ -342,8 +242,8 @@ void PaintDocumentMarkers(const PaintInfo& paint_info, ...@@ -342,8 +242,8 @@ void PaintDocumentMarkers(const PaintInfo& paint_info,
const auto& styleable_marker = To<StyleableMarker>(*marker); const auto& styleable_marker = To<StyleableMarker>(*marker);
if (marker_paint_phase == DocumentMarkerPaintPhase::kBackground) { if (marker_paint_phase == DocumentMarkerPaintPhase::kBackground) {
PaintRect(paint_info.context, PhysicalOffset(box_origin), PaintRect(paint_info.context, PhysicalOffset(box_origin),
ComputeLocalRect(text_fragment, text, paint_start_offset, text_fragment.LocalRect(text, paint_start_offset,
paint_end_offset), paint_end_offset),
styleable_marker.BackgroundColor()); styleable_marker.BackgroundColor());
break; break;
} }
...@@ -371,8 +271,18 @@ class SelectionPaintState { ...@@ -371,8 +271,18 @@ class SelectionPaintState {
public: public:
explicit SelectionPaintState(const NGInlineCursor& containing_block) explicit SelectionPaintState(const NGInlineCursor& containing_block)
: selection_status_(ComputeLayoutSelectionStatus(containing_block)), : SelectionPaintState(containing_block,
state_(ComputeSelectionState(containing_block)), containing_block.Current()
.GetLayoutObject()
->GetDocument()
.GetFrame()
->Selection()) {}
explicit SelectionPaintState(const NGInlineCursor& containing_block,
const FrameSelection& frame_selection)
: selection_status_(
frame_selection.ComputeLayoutSelectionStatus(containing_block)),
state_(frame_selection.ComputeLayoutSelectionStateForCursor(
containing_block.Current())),
containing_block_(containing_block) {} containing_block_(containing_block) {}
const LayoutSelectionStatus& Status() const { return selection_status_; } const LayoutSelectionStatus& Status() const { return selection_status_; }
...@@ -465,12 +375,11 @@ class SelectionPaintState { ...@@ -465,12 +375,11 @@ class SelectionPaintState {
bool paint_selected_text_separately_; bool paint_selected_text_separately_;
}; };
template <typename Cursor>
class SelectionBoundsRecorder { class SelectionBoundsRecorder {
STACK_ALLOCATED(); STACK_ALLOCATED();
public: public:
SelectionBoundsRecorder(const Cursor& cursor, SelectionBoundsRecorder(const NGInlineCursor& cursor,
SelectionPaintState& selection, SelectionPaintState& selection,
PaintController& paint_controller, PaintController& paint_controller,
const PhysicalOffset& box_rect_offset) const PhysicalOffset& box_rect_offset)
...@@ -482,14 +391,13 @@ class SelectionBoundsRecorder { ...@@ -482,14 +391,13 @@ class SelectionBoundsRecorder {
~SelectionBoundsRecorder(); ~SelectionBoundsRecorder();
private: private:
const Cursor& cursor_; const NGInlineCursor& cursor_;
SelectionPaintState& selection_; SelectionPaintState& selection_;
PaintController& paint_controller_; PaintController& paint_controller_;
const PhysicalOffset& box_rect_offset_; const PhysicalOffset& box_rect_offset_;
}; };
template <> SelectionBoundsRecorder::~SelectionBoundsRecorder() {
SelectionBoundsRecorder<NGInlineCursor>::~SelectionBoundsRecorder() {
DCHECK(RuntimeEnabledFeatures::CompositeAfterPaintEnabled()); DCHECK(RuntimeEnabledFeatures::CompositeAfterPaintEnabled());
const FrameSelection& frame_selection = const FrameSelection& frame_selection =
...@@ -530,11 +438,6 @@ SelectionBoundsRecorder<NGInlineCursor>::~SelectionBoundsRecorder() { ...@@ -530,11 +438,6 @@ SelectionBoundsRecorder<NGInlineCursor>::~SelectionBoundsRecorder() {
paint_controller_.RecordSelection(start, end); paint_controller_.RecordSelection(start, end);
} }
template <>
SelectionBoundsRecorder<NGTextPainterCursor>::~SelectionBoundsRecorder() {
NOTREACHED();
}
// Check if text-emphasis and ruby annotation text are on different sides. // Check if text-emphasis and ruby annotation text are on different sides.
// See InlineTextBox::GetEmphasisMarkPosition(). // See InlineTextBox::GetEmphasisMarkPosition().
// //
...@@ -566,23 +469,11 @@ bool ShouldPaintEmphasisMark(const ComputedStyle& style, ...@@ -566,23 +469,11 @@ bool ShouldPaintEmphasisMark(const ComputedStyle& style,
} // namespace } // namespace
StringView NGTextPainterCursor::CurrentText() const { void NGTextFragmentPainter::PaintSymbol(const LayoutObject* layout_object,
return CurrentItem()->Text(); const ComputedStyle& style,
} const PhysicalSize box_size,
const PaintInfo& paint_info,
const NGPaintFragment& NGTextPainterCursor::RootPaintFragment() const { const PhysicalOffset& paint_offset) {
if (!root_paint_fragment_)
root_paint_fragment_ = paint_fragment_.Root();
return *root_paint_fragment_;
}
template <typename Cursor>
void NGTextFragmentPainter<Cursor>::PaintSymbol(
const LayoutObject* layout_object,
const ComputedStyle& style,
const PhysicalSize box_size,
const PaintInfo& paint_info,
const PhysicalOffset& paint_offset) {
PhysicalRect marker_rect( PhysicalRect marker_rect(
ListMarker::RelativeSymbolMarkerRect(style, box_size.width)); ListMarker::RelativeSymbolMarkerRect(style, box_size.width));
marker_rect.Move(paint_offset); marker_rect.Move(paint_offset);
...@@ -592,9 +483,8 @@ void NGTextFragmentPainter<Cursor>::PaintSymbol( ...@@ -592,9 +483,8 @@ void NGTextFragmentPainter<Cursor>::PaintSymbol(
// This is copied from InlineTextBoxPainter::PaintSelection() but lacks of // This is copied from InlineTextBoxPainter::PaintSelection() but lacks of
// ltr, expanding new line wrap or so which uses InlineTextBox functions. // ltr, expanding new line wrap or so which uses InlineTextBox functions.
template <typename Cursor> void NGTextFragmentPainter::Paint(const PaintInfo& paint_info,
void NGTextFragmentPainter<Cursor>::Paint(const PaintInfo& paint_info, const PhysicalOffset& paint_offset) {
const PhysicalOffset& paint_offset) {
const auto& text_item = *cursor_.CurrentItem(); const auto& text_item = *cursor_.CurrentItem();
// We can skip painting if the fragment (including selection) is invisible. // We can skip painting if the fragment (including selection) is invisible.
if (!text_item.TextLength()) if (!text_item.TextLength())
...@@ -610,7 +500,7 @@ void NGTextFragmentPainter<Cursor>::Paint(const PaintInfo& paint_info, ...@@ -610,7 +500,7 @@ void NGTextFragmentPainter<Cursor>::Paint(const PaintInfo& paint_info,
return; return;
const NGTextFragmentPaintInfo& fragment_paint_info = const NGTextFragmentPaintInfo& fragment_paint_info =
GetTextFragmentPaintInfo(cursor_); cursor_.Current()->TextPaintInfo(cursor_.Items());
const LayoutObject* layout_object = text_item.GetLayoutObject(); const LayoutObject* layout_object = text_item.GetLayoutObject();
const Document& document = layout_object->GetDocument(); const Document& document = layout_object->GetDocument();
const bool is_printing = document.Printing(); const bool is_printing = document.Printing();
...@@ -651,7 +541,7 @@ void NGTextFragmentPainter<Cursor>::Paint(const PaintInfo& paint_info, ...@@ -651,7 +541,7 @@ void NGTextFragmentPainter<Cursor>::Paint(const PaintInfo& paint_info,
// Ensure the selection bounds are recorded on the paint chunk regardless of // Ensure the selection bounds are recorded on the paint chunk regardless of
// whether the diplay item that contains the actual selection painting is // whether the diplay item that contains the actual selection painting is
// reused. // reused.
base::Optional<SelectionBoundsRecorder<Cursor>> selection_recorder; base::Optional<SelectionBoundsRecorder> selection_recorder;
if (UNLIKELY(RuntimeEnabledFeatures::CompositeAfterPaintEnabled() && if (UNLIKELY(RuntimeEnabledFeatures::CompositeAfterPaintEnabled() &&
selection && paint_info.phase == PaintPhase::kForeground && selection && paint_info.phase == PaintPhase::kForeground &&
!is_printing)) { !is_printing)) {
...@@ -816,7 +706,4 @@ void NGTextFragmentPainter<Cursor>::Paint(const PaintInfo& paint_info, ...@@ -816,7 +706,4 @@ void NGTextFragmentPainter<Cursor>::Paint(const PaintInfo& paint_info,
DocumentMarkerPaintPhase::kForeground, &text_painter); DocumentMarkerPaintPhase::kForeground, &text_painter);
} }
template class NGTextFragmentPainter<NGTextPainterCursor>;
template class NGTextFragmentPainter<NGInlineCursor>;
} // namespace blink } // namespace blink
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "third_party/blink/renderer/core/layout/ng/inline/ng_inline_cursor.h" #include "third_party/blink/renderer/core/layout/ng/inline/ng_inline_cursor.h"
#include "third_party/blink/renderer/core/layout/ng/inline/ng_physical_text_fragment.h" #include "third_party/blink/renderer/core/layout/ng/inline/ng_physical_text_fragment.h"
#include "third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h"
#include "third_party/blink/renderer/core/style/computed_style_constants.h" #include "third_party/blink/renderer/core/style/computed_style_constants.h"
#include "third_party/blink/renderer/platform/geometry/layout_rect.h" #include "third_party/blink/renderer/platform/geometry/layout_rect.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
...@@ -17,7 +16,6 @@ namespace blink { ...@@ -17,7 +16,6 @@ namespace blink {
class ComputedStyle; class ComputedStyle;
class DisplayItemClient; class DisplayItemClient;
class LayoutObject; class LayoutObject;
class NGPaintFragment;
class NGInlineCursor; class NGInlineCursor;
struct NGTextFragmentPaintInfo; struct NGTextFragmentPaintInfo;
struct PaintInfo; struct PaintInfo;
...@@ -25,41 +23,16 @@ struct PhysicalOffset; ...@@ -25,41 +23,16 @@ struct PhysicalOffset;
struct PhysicalRect; struct PhysicalRect;
struct PhysicalSize; struct PhysicalSize;
// The helper class for templatize |NGTextFragmentPainter|. // Text fragment painter for LayoutNG. Operates on NGFragmentItem that IsText()
// TODO(yosin): Remove |NGTextPainterCursor| once the transition to // and handles clipping, selection, etc. Delegates to NGTextPainter to paint the
// |NGFragmentItem| is done. http://crbug.com/982194
class NGTextPainterCursor {
STACK_ALLOCATED();
public:
explicit NGTextPainterCursor(const NGPaintFragment& paint_fragment)
: paint_fragment_(paint_fragment),
text_fragment_(
To<NGPhysicalTextFragment>(paint_fragment.PhysicalFragment())) {}
const NGPaintFragment& PaintFragment() const { return paint_fragment_; }
const NGPhysicalTextFragment* CurrentItem() const { return &text_fragment_; }
StringView CurrentText() const;
const NGPaintFragment& RootPaintFragment() const;
private:
const NGPaintFragment& paint_fragment_;
const NGPhysicalTextFragment& text_fragment_;
mutable const NGPaintFragment* root_paint_fragment_ = nullptr;
};
// Text fragment painter for LayoutNG. Operates on NGPhysicalTextFragments and
// handles clipping, selection, etc. Delegates to NGTextPainter to paint the
// text itself. // text itself.
// TODO(yosin): We should make |NGTextFragmentPainter| non-template class onnce
// we get rid of |NGPaintFragment|.
template <typename Cursor>
class NGTextFragmentPainter { class NGTextFragmentPainter {
STACK_ALLOCATED(); STACK_ALLOCATED();
public: public:
explicit NGTextFragmentPainter(const Cursor& cursor) : cursor_(cursor) {} explicit NGTextFragmentPainter(const NGInlineCursor& cursor)
NGTextFragmentPainter(const Cursor& cursor, : cursor_(cursor) {}
NGTextFragmentPainter(const NGInlineCursor& cursor,
const PhysicalOffset& parent_offset) const PhysicalOffset& parent_offset)
: cursor_(cursor), parent_offset_(parent_offset) {} : cursor_(cursor), parent_offset_(parent_offset) {}
...@@ -83,14 +56,11 @@ class NGTextFragmentPainter { ...@@ -83,14 +56,11 @@ class NGTextFragmentPainter {
const PaintInfo& paint_info, const PaintInfo& paint_info,
const PhysicalOffset& paint_offset); const PhysicalOffset& paint_offset);
const Cursor& cursor_; const NGInlineCursor& cursor_;
PhysicalOffset parent_offset_; PhysicalOffset parent_offset_;
base::Optional<NGInlineCursor> inline_cursor_for_block_flow_; base::Optional<NGInlineCursor> inline_cursor_for_block_flow_;
}; };
extern template class NGTextFragmentPainter<NGTextPainterCursor>;
extern template class NGTextFragmentPainter<NGInlineCursor>;
} // namespace blink } // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_NG_NG_TEXT_FRAGMENT_PAINTER_H_ #endif // THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_NG_NG_TEXT_FRAGMENT_PAINTER_H_
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