Commit 84fd2dda authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Move EnsureId to NGTextFragmentPainter

This patch moves |EnsureNodeId()| to inside of
|NGTextFragmentPainter::Paint()| from its callers.

All callers do the same preparations, this unifies them

Bug: 924681
Change-Id: I3f0ca7d1ca418943604254ffd425df4e9edb7c33
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1761872
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Auto-Submit: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688685}
parent 412caffa
...@@ -50,16 +50,7 @@ void InlinePainter::Paint(const PaintInfo& paint_info) { ...@@ -50,16 +50,7 @@ void InlinePainter::Paint(const PaintInfo& paint_info) {
fragment->Offset(); fragment->Offset();
if (fragment->PhysicalFragment().IsText()) { if (fragment->PhysicalFragment().IsText()) {
const auto& text_fragment = NGTextFragmentPainter(*fragment).Paint(paint_info, child_offset);
To<NGPhysicalTextFragment>(fragment->PhysicalFragment());
DOMNodeId node_id = kInvalidDOMNodeId;
if (auto* node = text_fragment.GetNode()) {
if (node->GetLayoutObject()->IsText())
node_id = ToLayoutText(node->GetLayoutObject())->EnsureNodeId();
}
NGTextFragmentPainter(*fragment).Paint(paint_info, child_offset,
node_id);
} else { } else {
NGInlineBoxFragmentPainter(*fragment).Paint(paint_info, child_offset); NGInlineBoxFragmentPainter(*fragment).Paint(paint_info, child_offset);
} }
......
...@@ -993,16 +993,8 @@ void NGBoxFragmentPainter::PaintTextChild(const NGPaintFragment& paint_fragment, ...@@ -993,16 +993,8 @@ void NGBoxFragmentPainter::PaintTextChild(const NGPaintFragment& paint_fragment,
paint_info.phase != PaintPhase::kMask) paint_info.phase != PaintPhase::kMask)
return; return;
const auto& text_fragment =
To<NGPhysicalTextFragment>(paint_fragment.PhysicalFragment());
DOMNodeId node_id = kInvalidDOMNodeId;
if (auto* node = text_fragment.GetNode()) {
if (node->GetLayoutObject()->IsText())
node_id = ToLayoutText(node->GetLayoutObject())->EnsureNodeId();
}
NGTextFragmentPainter text_painter(paint_fragment); NGTextFragmentPainter text_painter(paint_fragment);
text_painter.Paint(paint_info, paint_offset, node_id); text_painter.Paint(paint_info, paint_offset);
} }
void NGBoxFragmentPainter::PaintAtomicInline(const PaintInfo& paint_info) { void NGBoxFragmentPainter::PaintAtomicInline(const PaintInfo& paint_info) {
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "third_party/blink/renderer/core/style/applied_text_decoration.h" #include "third_party/blink/renderer/core/style/applied_text_decoration.h"
#include "third_party/blink/renderer/core/style/computed_style.h" #include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/platform/fonts/character_range.h" #include "third_party/blink/renderer/platform/fonts/character_range.h"
#include "third_party/blink/renderer/platform/graphics/dom_node_id.h"
#include "third_party/blink/renderer/platform/graphics/graphics_context_state_saver.h" #include "third_party/blink/renderer/platform/graphics/graphics_context_state_saver.h"
#include "third_party/blink/renderer/platform/graphics/paint/drawing_recorder.h" #include "third_party/blink/renderer/platform/graphics/paint/drawing_recorder.h"
...@@ -266,8 +267,7 @@ void NGTextFragmentPainter::PaintSymbol(const PaintInfo& paint_info, ...@@ -266,8 +267,7 @@ void NGTextFragmentPainter::PaintSymbol(const PaintInfo& paint_info,
// 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.
void NGTextFragmentPainter::Paint(const PaintInfo& paint_info, void NGTextFragmentPainter::Paint(const PaintInfo& paint_info,
const PhysicalOffset& paint_offset, const PhysicalOffset& paint_offset) {
DOMNodeId node_id) {
const auto& text_fragment = const auto& text_fragment =
To<NGPhysicalTextFragment>(fragment_.PhysicalFragment()); To<NGPhysicalTextFragment>(fragment_.PhysicalFragment());
const ComputedStyle& style = fragment_.Style(); const ComputedStyle& style = fragment_.Style();
...@@ -398,6 +398,12 @@ void NGTextFragmentPainter::Paint(const PaintInfo& paint_info, ...@@ -398,6 +398,12 @@ void NGTextFragmentPainter::Paint(const PaintInfo& paint_info,
style.GetTextEmphasisPosition()); style.GetTextEmphasisPosition());
} }
DOMNodeId node_id = kInvalidDOMNodeId;
if (Node* node = text_fragment.GetNode()) {
if (auto* layout_text = ToLayoutTextOrNull(node->GetLayoutObject()))
node_id = layout_text->EnsureNodeId();
}
unsigned length = text_fragment.Text().length(); unsigned length = text_fragment.Text().length();
if (!paint_selected_text_only) { if (!paint_selected_text_only) {
// Paint text decorations except line-through. // Paint text decorations except line-through.
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#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/graphics/dom_node_id.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
namespace blink { namespace blink {
...@@ -25,9 +24,7 @@ class NGTextFragmentPainter { ...@@ -25,9 +24,7 @@ class NGTextFragmentPainter {
public: public:
explicit NGTextFragmentPainter(const NGPaintFragment&); explicit NGTextFragmentPainter(const NGPaintFragment&);
void Paint(const PaintInfo&, void Paint(const PaintInfo&, const PhysicalOffset& paint_offset);
const PhysicalOffset& paint_offset,
DOMNodeId node_id);
private: private:
void PaintSymbol(const PaintInfo& paint_info, void PaintSymbol(const PaintInfo& paint_info,
......
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