Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the ParagraphImpl class from the text API #11012

Merged
merged 1 commit into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,6 @@ FILE: ../../../flutter/lib/ui/text/paragraph.cc
FILE: ../../../flutter/lib/ui/text/paragraph.h
FILE: ../../../flutter/lib/ui/text/paragraph_builder.cc
FILE: ../../../flutter/lib/ui/text/paragraph_builder.h
FILE: ../../../flutter/lib/ui/text/paragraph_impl.cc
FILE: ../../../flutter/lib/ui/text/paragraph_impl.h
FILE: ../../../flutter/lib/ui/text/paragraph_impl_txt.cc
FILE: ../../../flutter/lib/ui/text/paragraph_impl_txt.h
FILE: ../../../flutter/lib/ui/text/text_box.cc
FILE: ../../../flutter/lib/ui/text/text_box.h
FILE: ../../../flutter/lib/ui/ui.dart
Expand Down
4 changes: 0 additions & 4 deletions lib/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ source_set("ui") {
"text/paragraph.h",
"text/paragraph_builder.cc",
"text/paragraph_builder.h",
"text/paragraph_impl.cc",
"text/paragraph_impl.h",
"text/paragraph_impl_txt.cc",
"text/paragraph_impl_txt.h",
"text/text_box.cc",
"text/text_box.h",
"ui_dart_state.cc",
Expand Down
54 changes: 38 additions & 16 deletions lib/ui/text/paragraph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ IMPLEMENT_WRAPPERTYPEINFO(ui, Paragraph);
DART_BIND_ALL(Paragraph, FOR_EACH_BINDING)

Paragraph::Paragraph(std::unique_ptr<txt::Paragraph> paragraph)
: m_paragraphImpl(
std::make_unique<ParagraphImplTxt>(std::move(paragraph))) {}
: m_paragraph(std::move(paragraph)) {}

Paragraph::~Paragraph() = default;

Expand All @@ -51,64 +50,87 @@ size_t Paragraph::GetAllocationSize() {
}

double Paragraph::width() {
return m_paragraphImpl->width();
return m_paragraph->GetMaxWidth();
}

double Paragraph::height() {
return m_paragraphImpl->height();
return m_paragraph->GetHeight();
}

double Paragraph::longestLine() {
return m_paragraphImpl->longestLine();
return m_paragraph->GetLongestLine();
}

double Paragraph::minIntrinsicWidth() {
return m_paragraphImpl->minIntrinsicWidth();
return m_paragraph->GetMinIntrinsicWidth();
}

double Paragraph::maxIntrinsicWidth() {
return m_paragraphImpl->maxIntrinsicWidth();
return m_paragraph->GetMaxIntrinsicWidth();
}

double Paragraph::alphabeticBaseline() {
return m_paragraphImpl->alphabeticBaseline();
return m_paragraph->GetAlphabeticBaseline();
}

double Paragraph::ideographicBaseline() {
return m_paragraphImpl->ideographicBaseline();
return m_paragraph->GetIdeographicBaseline();
}

bool Paragraph::didExceedMaxLines() {
return m_paragraphImpl->didExceedMaxLines();
return m_paragraph->DidExceedMaxLines();
}

void Paragraph::layout(double width) {
m_paragraphImpl->layout(width);
m_paragraph->Layout(width);
}

void Paragraph::paint(Canvas* canvas, double x, double y) {
m_paragraphImpl->paint(canvas, x, y);
SkCanvas* sk_canvas = canvas->canvas();
if (!sk_canvas)
return;
m_paragraph->Paint(sk_canvas, x, y);
}

std::vector<TextBox> Paragraph::getRectsForRange(unsigned start,
unsigned end,
unsigned boxHeightStyle,
unsigned boxWidthStyle) {
return m_paragraphImpl->getRectsForRange(
std::vector<TextBox> result;
std::vector<txt::Paragraph::TextBox> boxes = m_paragraph->GetRectsForRange(
start, end, static_cast<txt::Paragraph::RectHeightStyle>(boxHeightStyle),
static_cast<txt::Paragraph::RectWidthStyle>(boxWidthStyle));
for (const txt::Paragraph::TextBox& box : boxes) {
result.emplace_back(box.rect, static_cast<TextDirection>(box.direction));
}
return result;
}

std::vector<TextBox> Paragraph::getRectsForPlaceholders() {
return m_paragraphImpl->getRectsForPlaceholders();
std::vector<TextBox> result;
std::vector<txt::Paragraph::TextBox> boxes =
m_paragraph->GetRectsForPlaceholders();
for (const txt::Paragraph::TextBox& box : boxes) {
result.emplace_back(box.rect, static_cast<TextDirection>(box.direction));
}
return result;
}

Dart_Handle Paragraph::getPositionForOffset(double dx, double dy) {
return m_paragraphImpl->getPositionForOffset(dx, dy);
Dart_Handle result = Dart_NewListOf(Dart_CoreType_Int, 2);
txt::Paragraph::PositionWithAffinity pos =
m_paragraph->GetGlyphPositionAtCoordinate(dx, dy);
Dart_ListSetAt(result, 0, ToDart(pos.position));
Dart_ListSetAt(result, 1, ToDart(static_cast<int>(pos.affinity)));
return result;
}

Dart_Handle Paragraph::getWordBoundary(unsigned offset) {
return m_paragraphImpl->getWordBoundary(offset);
txt::Paragraph::Range<size_t> point = m_paragraph->GetWordBoundary(offset);
Dart_Handle result = Dart_NewListOf(Dart_CoreType_Int, 2);
Dart_ListSetAt(result, 0, ToDart(point.start));
Dart_ListSetAt(result, 1, ToDart(point.end));
return result;
}

} // namespace flutter
4 changes: 1 addition & 3 deletions lib/ui/text/paragraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#include "flutter/fml/message_loop.h"
#include "flutter/lib/ui/dart_wrapper.h"
#include "flutter/lib/ui/painting/canvas.h"
#include "flutter/lib/ui/text/paragraph_impl.h"
#include "flutter/lib/ui/text/paragraph_impl_txt.h"
#include "flutter/lib/ui/text/text_box.h"
#include "flutter/third_party/txt/src/txt/paragraph.h"

Expand Down Expand Up @@ -56,7 +54,7 @@ class Paragraph : public RefCountedDartWrappable<Paragraph> {
static void RegisterNatives(tonic::DartLibraryNatives* natives);

private:
std::unique_ptr<ParagraphImpl> m_paragraphImpl;
std::unique_ptr<txt::Paragraph> m_paragraph;

explicit Paragraph(std::unique_ptr<txt::Paragraph> paragraph);
};
Expand Down
7 changes: 0 additions & 7 deletions lib/ui/text/paragraph_impl.cc

This file was deleted.

53 changes: 0 additions & 53 deletions lib/ui/text/paragraph_impl.h

This file was deleted.

110 changes: 0 additions & 110 deletions lib/ui/text/paragraph_impl_txt.cc

This file was deleted.

48 changes: 0 additions & 48 deletions lib/ui/text/paragraph_impl_txt.h

This file was deleted.