mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Add ParagraphBuilder::PeekStyle() to allow Flutter style inheritance.
Change-Id: Ia198778d9a7cfd7053390e6195bf8e03245add77
This commit is contained in:
parent
ffd0311172
commit
130cc7e044
@ -52,7 +52,7 @@ class Paragraph {
|
||||
|
||||
~Paragraph();
|
||||
|
||||
// NOTE: Minikin Layout doLayout() and LineBreaker addStyleRun() has an
|
||||
// Minikin Layout doLayout() and LineBreaker addStyleRun() has an
|
||||
// O(N^2) (according to benchmarks) time complexity where N is the total
|
||||
// number of characters. However, this is not significant for reasonably sized
|
||||
// paragraphs. It is currently recommended to break up very long paragraphs
|
||||
|
||||
@ -72,6 +72,10 @@ void ParagraphBuilder::Pop() {
|
||||
runs_.StartRun(style_index, text_index);
|
||||
}
|
||||
|
||||
const TextStyle& ParagraphBuilder::PeekStyle() const {
|
||||
return runs_.PeekStyle();
|
||||
}
|
||||
|
||||
void ParagraphBuilder::AddText(const std::u16string& text) {
|
||||
text_.insert(text_.end(), text.begin(), text.end());
|
||||
}
|
||||
|
||||
@ -56,6 +56,9 @@ class ParagraphBuilder {
|
||||
// builder.AddText(" Back to normal again.");
|
||||
void Pop();
|
||||
|
||||
// Returns the last TextStyle on the stack.
|
||||
const TextStyle& PeekStyle() const;
|
||||
|
||||
// Adds text to the builder. Forms the proper runs to use the upper-most style
|
||||
// on the style_stack_;
|
||||
void AddText(const std::u16string& text);
|
||||
|
||||
@ -46,6 +46,10 @@ size_t StyledRuns::AddStyle(const TextStyle& style) {
|
||||
return style_index;
|
||||
}
|
||||
|
||||
const TextStyle& StyledRuns::PeekStyle() const {
|
||||
return styles_.back();
|
||||
}
|
||||
|
||||
void StyledRuns::StartRun(size_t style_index, size_t start) {
|
||||
runs_.push_back(IndexedRun{style_index, start, start});
|
||||
}
|
||||
|
||||
@ -49,6 +49,9 @@ class StyledRuns {
|
||||
|
||||
size_t AddStyle(const TextStyle& style);
|
||||
|
||||
// Returns the last TextStyle on the stack.
|
||||
const TextStyle& PeekStyle() const;
|
||||
|
||||
void StartRun(size_t style_index, size_t start);
|
||||
|
||||
void EndRunIfNeeded(size_t end);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user