Commit 4e1ef19a authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Make PaintDocumentMarkers() not to crash

This patch changes |NGTextFragmentPainter<Cursor>::Paint()| to pass valid text
to |PaintDocumentMarkers()| to avoid hit |DCHECK()| in |NGFragmentItem::
InlinePositionForOffset()|.

Bug: 982194
Change-Id: I95ec067ef8d77ca44d48076f49404a57132c9fb0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1942590
Auto-Submit: Yoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720326}
parent 4b800219
...@@ -312,6 +312,10 @@ void PaintDocumentMarkers(GraphicsContext& context, ...@@ -312,6 +312,10 @@ void PaintDocumentMarkers(GraphicsContext& context,
} // namespace } // namespace
StringView NGTextPainterCursor::CurrentText() const {
return CurrentItem()->Text();
}
const NGPaintFragment& NGTextPainterCursor::RootPaintFragment() const { const NGPaintFragment& NGTextPainterCursor::RootPaintFragment() const {
if (!root_paint_fragment_) if (!root_paint_fragment_)
root_paint_fragment_ = paint_fragment_.Root(); root_paint_fragment_ = paint_fragment_.Root();
...@@ -475,7 +479,7 @@ void NGTextFragmentPainter<Cursor>::Paint(const PaintInfo& paint_info, ...@@ -475,7 +479,7 @@ void NGTextFragmentPainter<Cursor>::Paint(const PaintInfo& paint_info,
ComputeMarkersToPaint(node, text_item.IsEllipsis()); ComputeMarkersToPaint(node, text_item.IsEllipsis());
if (paint_info.phase != PaintPhase::kSelection && if (paint_info.phase != PaintPhase::kSelection &&
paint_info.phase != PaintPhase::kTextClip && !is_printing) { paint_info.phase != PaintPhase::kTextClip && !is_printing) {
PaintDocumentMarkers(context, text_item, fragment_paint_info.text, PaintDocumentMarkers(context, text_item, cursor_.CurrentText(),
markers_to_paint, box_rect.offset, style, markers_to_paint, box_rect.offset, style,
DocumentMarkerPaintPhase::kBackground, nullptr); DocumentMarkerPaintPhase::kBackground, nullptr);
if (have_selection) { if (have_selection) {
...@@ -576,7 +580,7 @@ void NGTextFragmentPainter<Cursor>::Paint(const PaintInfo& paint_info, ...@@ -576,7 +580,7 @@ void NGTextFragmentPainter<Cursor>::Paint(const PaintInfo& paint_info,
if (paint_info.phase != PaintPhase::kForeground) if (paint_info.phase != PaintPhase::kForeground)
return; return;
PaintDocumentMarkers(context, text_item, fragment_paint_info.text, PaintDocumentMarkers(context, text_item, cursor_.CurrentText(),
markers_to_paint, box_rect.offset, style, markers_to_paint, box_rect.offset, style,
DocumentMarkerPaintPhase::kForeground, &text_painter); DocumentMarkerPaintPhase::kForeground, &text_painter);
} }
......
...@@ -38,6 +38,7 @@ class NGTextPainterCursor { ...@@ -38,6 +38,7 @@ class NGTextPainterCursor {
const NGPaintFragment& PaintFragment() const { return paint_fragment_; } const NGPaintFragment& PaintFragment() const { return paint_fragment_; }
const NGPhysicalTextFragment* CurrentItem() const { return &text_fragment_; } const NGPhysicalTextFragment* CurrentItem() const { return &text_fragment_; }
StringView CurrentText() const;
const NGPaintFragment& RootPaintFragment() const; const NGPaintFragment& RootPaintFragment() const;
private: private:
......
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