Make lib/ui/text/... compatible with .clang-tidy. (flutter/engine#48156)

This commit is contained in:
Matan Lurey 2023-11-16 18:00:09 -08:00 committed by GitHub
parent c58953c1e4
commit 7571e558d4
4 changed files with 32 additions and 32 deletions

View File

@ -22,55 +22,55 @@ namespace flutter {
IMPLEMENT_WRAPPERTYPEINFO(ui, Paragraph);
Paragraph::Paragraph(std::unique_ptr<txt::Paragraph> paragraph)
: m_paragraph(std::move(paragraph)) {}
: m_paragraph_(std::move(paragraph)) {}
Paragraph::~Paragraph() = default;
double Paragraph::width() {
return m_paragraph->GetMaxWidth();
return m_paragraph_->GetMaxWidth();
}
double Paragraph::height() {
return m_paragraph->GetHeight();
return m_paragraph_->GetHeight();
}
double Paragraph::longestLine() {
return m_paragraph->GetLongestLine();
return m_paragraph_->GetLongestLine();
}
double Paragraph::minIntrinsicWidth() {
return m_paragraph->GetMinIntrinsicWidth();
return m_paragraph_->GetMinIntrinsicWidth();
}
double Paragraph::maxIntrinsicWidth() {
return m_paragraph->GetMaxIntrinsicWidth();
return m_paragraph_->GetMaxIntrinsicWidth();
}
double Paragraph::alphabeticBaseline() {
return m_paragraph->GetAlphabeticBaseline();
return m_paragraph_->GetAlphabeticBaseline();
}
double Paragraph::ideographicBaseline() {
return m_paragraph->GetIdeographicBaseline();
return m_paragraph_->GetIdeographicBaseline();
}
bool Paragraph::didExceedMaxLines() {
return m_paragraph->DidExceedMaxLines();
return m_paragraph_->DidExceedMaxLines();
}
void Paragraph::layout(double width) {
m_paragraph->Layout(width);
m_paragraph_->Layout(width);
}
void Paragraph::paint(Canvas* canvas, double x, double y) {
if (!m_paragraph || !canvas) {
if (!m_paragraph_ || !canvas) {
// disposed.
return;
}
DisplayListBuilder* builder = canvas->builder();
if (builder) {
m_paragraph->Paint(builder, x, y);
m_paragraph_->Paint(builder, x, y);
}
}
@ -98,7 +98,7 @@ tonic::Float32List Paragraph::getRectsForRange(unsigned start,
unsigned end,
unsigned boxHeightStyle,
unsigned boxWidthStyle) {
std::vector<txt::Paragraph::TextBox> boxes = m_paragraph->GetRectsForRange(
std::vector<txt::Paragraph::TextBox> boxes = m_paragraph_->GetRectsForRange(
start, end, static_cast<txt::Paragraph::RectHeightStyle>(boxHeightStyle),
static_cast<txt::Paragraph::RectWidthStyle>(boxWidthStyle));
return EncodeTextBoxes(boxes);
@ -106,13 +106,13 @@ tonic::Float32List Paragraph::getRectsForRange(unsigned start,
tonic::Float32List Paragraph::getRectsForPlaceholders() {
std::vector<txt::Paragraph::TextBox> boxes =
m_paragraph->GetRectsForPlaceholders();
m_paragraph_->GetRectsForPlaceholders();
return EncodeTextBoxes(boxes);
}
Dart_Handle Paragraph::getPositionForOffset(double dx, double dy) {
txt::Paragraph::PositionWithAffinity pos =
m_paragraph->GetGlyphPositionAtCoordinate(dx, dy);
m_paragraph_->GetGlyphPositionAtCoordinate(dx, dy);
std::vector<size_t> result = {
pos.position, // size_t already
static_cast<size_t>(pos.affinity) // affinity (enum)
@ -121,13 +121,13 @@ Dart_Handle Paragraph::getPositionForOffset(double dx, double dy) {
}
Dart_Handle Paragraph::getWordBoundary(unsigned offset) {
txt::Paragraph::Range<size_t> point = m_paragraph->GetWordBoundary(offset);
txt::Paragraph::Range<size_t> point = m_paragraph_->GetWordBoundary(offset);
std::vector<size_t> result = {point.start, point.end};
return tonic::DartConverter<decltype(result)>::ToDart(result);
}
Dart_Handle Paragraph::getLineBoundary(unsigned utf16Offset) {
std::vector<txt::LineMetrics> metrics = m_paragraph->GetLineMetrics();
std::vector<txt::LineMetrics> metrics = m_paragraph_->GetLineMetrics();
int line_start = -1;
int line_end = -1;
for (txt::LineMetrics& line : metrics) {
@ -142,7 +142,7 @@ Dart_Handle Paragraph::getLineBoundary(unsigned utf16Offset) {
}
tonic::Float64List Paragraph::computeLineMetrics() const {
std::vector<txt::LineMetrics> metrics = m_paragraph->GetLineMetrics();
std::vector<txt::LineMetrics> metrics = m_paragraph_->GetLineMetrics();
// Layout:
// boxes.size() groups of 9 which are the line metrics
@ -172,7 +172,7 @@ tonic::Float64List Paragraph::computeLineMetrics() const {
Dart_Handle Paragraph::getLineMetricsAt(int lineNumber,
Dart_Handle constructor) const {
skia::textlayout::LineMetrics line;
const bool found = m_paragraph->GetLineMetricsAt(lineNumber, &line);
const bool found = m_paragraph_->GetLineMetricsAt(lineNumber, &line);
if (!found) {
return Dart_Null();
}
@ -198,15 +198,15 @@ Dart_Handle Paragraph::getLineMetricsAt(int lineNumber,
}
size_t Paragraph::getNumberOfLines() const {
return m_paragraph->GetNumberOfLines();
return m_paragraph_->GetNumberOfLines();
}
int Paragraph::getLineNumberAt(size_t utf16Offset) const {
return m_paragraph->GetLineNumberAt(utf16Offset);
return m_paragraph_->GetLineNumberAt(utf16Offset);
}
void Paragraph::dispose() {
m_paragraph.reset();
m_paragraph_.reset();
ClearDartWrapper();
}

View File

@ -54,7 +54,7 @@ class Paragraph : public RefCountedDartWrappable<Paragraph> {
void dispose();
private:
std::unique_ptr<txt::Paragraph> m_paragraph;
std::unique_ptr<txt::Paragraph> m_paragraph_;
explicit Paragraph(std::unique_ptr<txt::Paragraph> paragraph);
};

View File

@ -301,7 +301,7 @@ ParagraphBuilder::ParagraphBuilder(
->GetFontCollection();
auto impeller_enabled = UIDartState::Current()->IsImpellerEnabled();
m_paragraphBuilder = txt::ParagraphBuilder::CreateSkiaBuilder(
m_paragraph_builder_ = txt::ParagraphBuilder::CreateSkiaBuilder(
style, font_collection.GetFontCollection(), impeller_enabled);
}
@ -389,7 +389,7 @@ void ParagraphBuilder::pushStyle(const tonic::Int32List& encoded,
// Set to use the properties of the previous style if the property is not
// explicitly given.
txt::TextStyle style = m_paragraphBuilder->PeekStyle();
txt::TextStyle style = m_paragraph_builder_->PeekStyle();
style.half_leading = mask & kTSLeadingDistributionMask;
// Only change the style property from the previous value if a new explicitly
@ -492,11 +492,11 @@ void ParagraphBuilder::pushStyle(const tonic::Int32List& encoded,
decodeFontVariations(font_variations_data, style.font_variations);
}
m_paragraphBuilder->PushStyle(style);
m_paragraph_builder_->PushStyle(style);
}
void ParagraphBuilder::pop() {
m_paragraphBuilder->Pop();
m_paragraph_builder_->Pop();
}
Dart_Handle ParagraphBuilder::addText(const std::u16string& text) {
@ -514,7 +514,7 @@ Dart_Handle ParagraphBuilder::addText(const std::u16string& text) {
return tonic::ToDart("string is not well-formed UTF-16");
}
m_paragraphBuilder->AddText(text);
m_paragraph_builder_->AddText(text);
return Dart_Null();
}
@ -528,12 +528,12 @@ void ParagraphBuilder::addPlaceholder(double width,
width, height, static_cast<txt::PlaceholderAlignment>(alignment),
static_cast<txt::TextBaseline>(baseline), baseline_offset);
m_paragraphBuilder->AddPlaceholder(placeholder_run);
m_paragraph_builder_->AddPlaceholder(placeholder_run);
}
void ParagraphBuilder::build(Dart_Handle paragraph_handle) {
Paragraph::Create(paragraph_handle, m_paragraphBuilder->Build());
m_paragraphBuilder.reset();
Paragraph::Create(paragraph_handle, m_paragraph_builder_->Build());
m_paragraph_builder_.reset();
ClearDartWrapper();
}

View File

@ -80,7 +80,7 @@ class ParagraphBuilder : public RefCountedDartWrappable<ParagraphBuilder> {
const std::string& locale,
bool applyRoundingHack);
std::unique_ptr<txt::ParagraphBuilder> m_paragraphBuilder;
std::unique_ptr<txt::ParagraphBuilder> m_paragraph_builder_;
};
} // namespace flutter