Flutter Engine
txt::StyledRuns Class Reference

#include <styled_runs.h>

Classes

struct  Run
 

Public Member Functions

 StyledRuns ()
 
 ~StyledRuns ()
 
 StyledRuns (const StyledRuns &other)=delete
 
 StyledRuns (StyledRuns &&other)
 
const StyledRunsoperator= (StyledRuns &&other)
 
void swap (StyledRuns &other)
 
size_t AddStyle (const TextStyle &style)
 
const TextStyleGetStyle (size_t style_index) const
 
void StartRun (size_t style_index, size_t start)
 
void EndRunIfNeeded (size_t end)
 
size_t size () const
 
Run GetRun (size_t index) const
 

Detailed Description

Definition at line 31 of file styled_runs.h.

Constructor & Destructor Documentation

◆ StyledRuns() [1/3]

txt::StyledRuns::StyledRuns ( )
default

◆ ~StyledRuns()

txt::StyledRuns::~StyledRuns ( )
default

◆ StyledRuns() [2/3]

txt::StyledRuns::StyledRuns ( const StyledRuns other)
delete

◆ StyledRuns() [3/3]

txt::StyledRuns::StyledRuns ( StyledRuns &&  other)

Definition at line 28 of file styled_runs.cc.

28  {
29  styles_.swap(other.styles_);
30  runs_.swap(other.runs_);
31 }

Member Function Documentation

◆ AddStyle()

size_t txt::StyledRuns::AddStyle ( const TextStyle style)

Definition at line 44 of file styled_runs.cc.

Referenced by txt::BM_StyledRunsGetRun(), txt::ParagraphBuilderTxt::ParagraphBuilderTxt(), and txt::ParagraphBuilderTxt::PushStyle().

44  {
45  const size_t style_index = styles_.size();
46  styles_.push_back(style);
47  return style_index;
48 }

◆ EndRunIfNeeded()

void txt::StyledRuns::EndRunIfNeeded ( size_t  end)

Definition at line 59 of file styled_runs.cc.

References txt::end.

Referenced by txt::BM_StyledRunsGetRun(), txt::ParagraphBuilderTxt::Build(), and StartRun().

59  {
60  if (runs_.empty())
61  return;
62  IndexedRun& run = runs_.back();
63  if (run.start == end) {
64  // The run is empty. We can skip it.
65  runs_.pop_back();
66  } else {
67  run.end = end;
68  }
69 }

◆ GetRun()

StyledRuns::Run txt::StyledRuns::GetRun ( size_t  index) const

Definition at line 71 of file styled_runs.cc.

Referenced by txt::BM_StyledRunsGetRun(), txt::ParagraphTxt::ParagraphTxt(), and size().

71  {
72  const IndexedRun& run = runs_[index];
73  return Run{styles_[run.style_index], run.start, run.end};
74 }

◆ GetStyle()

const TextStyle & txt::StyledRuns::GetStyle ( size_t  style_index) const

Definition at line 50 of file styled_runs.cc.

Referenced by txt::ParagraphBuilderTxt::PeekStyle().

50  {
51  return styles_[style_index];
52 }

◆ operator=()

const StyledRuns & txt::StyledRuns::operator= ( StyledRuns &&  other)

Definition at line 33 of file styled_runs.cc.

33  {
34  styles_.swap(other.styles_);
35  runs_.swap(other.runs_);
36  return *this;
37 }

◆ size()

size_t txt::StyledRuns::size ( ) const
inline

Definition at line 59 of file styled_runs.h.

References txt::StyledRuns::Run::end, FRIEND_TEST_WINDOWS_DISABLED, GetRun(), and txt::StyledRuns::Run::start.

Referenced by txt::ParagraphTxt::ParagraphTxt().

59 { return runs_.size(); }

◆ StartRun()

void txt::StyledRuns::StartRun ( size_t  style_index,
size_t  start 
)

◆ swap()

void txt::StyledRuns::swap ( StyledRuns other)

Definition at line 39 of file styled_runs.cc.

39  {
40  styles_.swap(other.styles_);
41  runs_.swap(other.runs_);
42 }

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