Flutter Engine
txt::ParagraphBuilderTxt Class Reference

#include <paragraph_builder_txt.h>

Inheritance diagram for txt::ParagraphBuilderTxt:
txt::ParagraphBuilder

Public Member Functions

 ParagraphBuilderTxt (const ParagraphStyle &style, std::shared_ptr< FontCollection > font_collection)
 
virtual ~ParagraphBuilderTxt ()
 
virtual void PushStyle (const TextStyle &style) override
 
virtual void Pop () override
 
virtual const TextStylePeekStyle () override
 
virtual void AddText (const std::u16string &text) override
 
virtual void AddPlaceholder (PlaceholderRun &span) override
 
virtual std::unique_ptr< ParagraphBuild () override
 
- Public Member Functions inherited from txt::ParagraphBuilder
virtual ~ParagraphBuilder ()=default
 

Additional Inherited Members

- Static Public Member Functions inherited from txt::ParagraphBuilder
static std::unique_ptr< ParagraphBuilderCreateTxtBuilder (const ParagraphStyle &style, std::shared_ptr< FontCollection > font_collection)
 
- Protected Member Functions inherited from txt::ParagraphBuilder
 ParagraphBuilder ()=default
 

Detailed Description

Definition at line 28 of file paragraph_builder_txt.h.

Constructor & Destructor Documentation

◆ ParagraphBuilderTxt()

txt::ParagraphBuilderTxt::ParagraphBuilderTxt ( const ParagraphStyle style,
std::shared_ptr< FontCollection font_collection 
)

Definition at line 23 of file paragraph_builder_txt.cc.

References txt::StyledRuns::AddStyle(), txt::ParagraphStyle::GetTextStyle(), txt::StyledRuns::StartRun(), and ~ParagraphBuilderTxt().

26  : font_collection_(std::move(font_collection)) {
27  SetParagraphStyle(style);
28 }

◆ ~ParagraphBuilderTxt()

txt::ParagraphBuilderTxt::~ParagraphBuilderTxt ( )
virtualdefault

Referenced by ParagraphBuilderTxt().

Member Function Documentation

◆ AddPlaceholder()

void txt::ParagraphBuilderTxt::AddPlaceholder ( PlaceholderRun span)
overridevirtual

Implements txt::ParagraphBuilder.

Definition at line 64 of file paragraph_builder_txt.cc.

References AddText(), txt::objReplacementChar, and txt::StyledRuns::StartRun().

Referenced by txt::TEST_F().

64  {
65  obj_replacement_char_indexes_.insert(text_.size());
66  runs_.StartRun(PeekStyleIndex(), text_.size());
67  AddText(std::u16string(1ull, objReplacementChar));
68  runs_.StartRun(PeekStyleIndex(), text_.size());
69  inline_placeholders_.push_back(span);
70 }
void StartRun(size_t style_index, size_t start)
Definition: styled_runs.cc:54
const int objReplacementChar
Definition: paragraph_txt.h:48
virtual void AddText(const std::u16string &text) override

◆ AddText()

◆ Build()

std::unique_ptr< Paragraph > txt::ParagraphBuilderTxt::Build ( )
overridevirtual

Implements txt::ParagraphBuilder.

Definition at line 72 of file paragraph_builder_txt.cc.

References txt::StyledRuns::EndRunIfNeeded().

Referenced by txt::BM_ParagraphBuilderLongParagraphConstruct(), txt::BM_ParagraphBuilderShortParagraphConstruct(), and txt::BuildParagraph().

72  {
73  runs_.EndRunIfNeeded(text_.size());
74 
75  std::unique_ptr<ParagraphTxt> paragraph = std::make_unique<ParagraphTxt>();
76  paragraph->SetText(std::move(text_), std::move(runs_));
77  paragraph->SetInlinePlaceholders(std::move(inline_placeholders_),
78  std::move(obj_replacement_char_indexes_));
79  paragraph->SetParagraphStyle(paragraph_style_);
80  paragraph->SetFontCollection(font_collection_);
81  SetParagraphStyle(paragraph_style_);
82  return paragraph;
83 }
void EndRunIfNeeded(size_t end)
Definition: styled_runs.cc:59

◆ PeekStyle()

const TextStyle & txt::ParagraphBuilderTxt::PeekStyle ( )
overridevirtual

Implements txt::ParagraphBuilder.

Definition at line 56 of file paragraph_builder_txt.cc.

References txt::StyledRuns::GetStyle().

56  {
57  return runs_.GetStyle(PeekStyleIndex());
58 }
const TextStyle & GetStyle(size_t style_index) const
Definition: styled_runs.cc:50

◆ Pop()

void txt::ParagraphBuilderTxt::Pop ( )
overridevirtual

Implements txt::ParagraphBuilder.

Definition at line 44 of file paragraph_builder_txt.cc.

References txt::StyledRuns::StartRun().

Referenced by txt::BENCHMARK_DEFINE_F(), txt::BENCHMARK_F(), txt::BM_ParagraphBuilderLongParagraphConstruct(), txt::BM_ParagraphBuilderPushPop(), txt::BM_ParagraphBuilderShortParagraphConstruct(), and txt::TEST_F().

44  {
45  if (style_stack_.empty()) {
46  return;
47  }
48  style_stack_.pop_back();
49  runs_.StartRun(PeekStyleIndex(), text_.size());
50 }
void StartRun(size_t style_index, size_t start)
Definition: styled_runs.cc:54

◆ PushStyle()

void txt::ParagraphBuilderTxt::PushStyle ( const TextStyle style)
overridevirtual

Implements txt::ParagraphBuilder.

Definition at line 38 of file paragraph_builder_txt.cc.

References txt::StyledRuns::AddStyle(), and txt::StyledRuns::StartRun().

Referenced by txt::BENCHMARK_DEFINE_F(), txt::BENCHMARK_F(), txt::BM_ParagraphBuilderLongParagraphConstruct(), txt::BM_ParagraphBuilderPushPop(), txt::BM_ParagraphBuilderPushStyle(), txt::BM_ParagraphBuilderShortParagraphConstruct(), and txt::TEST_F().

38  {
39  size_t style_index = runs_.AddStyle(style);
40  style_stack_.push_back(style_index);
41  runs_.StartRun(style_index, text_.size());
42 }
size_t AddStyle(const TextStyle &style)
Definition: styled_runs.cc:44
void StartRun(size_t style_index, size_t start)
Definition: styled_runs.cc:54

The documentation for this class was generated from the following files: