forked from firka/flutter
Remove the ParagraphImpl class from the text API (flutter/engine#11012)
ParagraphImpl was used to switch between libtxt and Blink implementations of text rendering and is now obsolete.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/lib/ui/text/paragraph_impl.h"
|
||||
|
||||
namespace flutter {} // namespace flutter
|
||||
@@ -1,53 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_LIB_UI_TEXT_PARAGRAPH_IMPL_H_
|
||||
#define FLUTTER_LIB_UI_TEXT_PARAGRAPH_IMPL_H_
|
||||
|
||||
#include "flutter/lib/ui/painting/canvas.h"
|
||||
#include "flutter/lib/ui/text/text_box.h"
|
||||
#include "flutter/third_party/txt/src/txt/paragraph.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
class ParagraphImpl {
|
||||
public:
|
||||
virtual ~ParagraphImpl(){};
|
||||
|
||||
virtual double width() = 0;
|
||||
|
||||
virtual double height() = 0;
|
||||
|
||||
virtual double longestLine() = 0;
|
||||
|
||||
virtual double minIntrinsicWidth() = 0;
|
||||
|
||||
virtual double maxIntrinsicWidth() = 0;
|
||||
|
||||
virtual double alphabeticBaseline() = 0;
|
||||
|
||||
virtual double ideographicBaseline() = 0;
|
||||
|
||||
virtual bool didExceedMaxLines() = 0;
|
||||
|
||||
virtual void layout(double width) = 0;
|
||||
|
||||
virtual void paint(Canvas* canvas, double x, double y) = 0;
|
||||
|
||||
virtual std::vector<TextBox> getRectsForRange(
|
||||
unsigned start,
|
||||
unsigned end,
|
||||
txt::Paragraph::RectHeightStyle rect_height_style,
|
||||
txt::Paragraph::RectWidthStyle rect_width_style) = 0;
|
||||
|
||||
virtual std::vector<TextBox> getRectsForPlaceholders() = 0;
|
||||
|
||||
virtual Dart_Handle getPositionForOffset(double dx, double dy) = 0;
|
||||
|
||||
virtual Dart_Handle getWordBoundary(unsigned offset) = 0;
|
||||
};
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_LIB_UI_TEXT_PARAGRAPH_IMPL_H_
|
||||
@@ -1,110 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/lib/ui/text/paragraph_impl_txt.h"
|
||||
|
||||
#include "flutter/common/task_runners.h"
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "flutter/fml/task_runner.h"
|
||||
#include "flutter/lib/ui/text/paragraph.h"
|
||||
#include "flutter/lib/ui/text/paragraph_impl.h"
|
||||
#include "third_party/skia/include/core/SkPoint.h"
|
||||
#include "third_party/tonic/converter/dart_converter.h"
|
||||
|
||||
using tonic::ToDart;
|
||||
|
||||
namespace flutter {
|
||||
|
||||
ParagraphImplTxt::ParagraphImplTxt(std::unique_ptr<txt::Paragraph> paragraph)
|
||||
: m_paragraph(std::move(paragraph)) {}
|
||||
|
||||
ParagraphImplTxt::~ParagraphImplTxt() {}
|
||||
|
||||
double ParagraphImplTxt::width() {
|
||||
return m_paragraph->GetMaxWidth();
|
||||
}
|
||||
|
||||
double ParagraphImplTxt::height() {
|
||||
return m_paragraph->GetHeight();
|
||||
}
|
||||
|
||||
double ParagraphImplTxt::longestLine() {
|
||||
return m_paragraph->GetLongestLine();
|
||||
}
|
||||
|
||||
double ParagraphImplTxt::minIntrinsicWidth() {
|
||||
return m_paragraph->GetMinIntrinsicWidth();
|
||||
}
|
||||
|
||||
double ParagraphImplTxt::maxIntrinsicWidth() {
|
||||
return m_paragraph->GetMaxIntrinsicWidth();
|
||||
}
|
||||
|
||||
double ParagraphImplTxt::alphabeticBaseline() {
|
||||
return m_paragraph->GetAlphabeticBaseline();
|
||||
}
|
||||
|
||||
double ParagraphImplTxt::ideographicBaseline() {
|
||||
return m_paragraph->GetIdeographicBaseline();
|
||||
}
|
||||
|
||||
bool ParagraphImplTxt::didExceedMaxLines() {
|
||||
return m_paragraph->DidExceedMaxLines();
|
||||
}
|
||||
|
||||
void ParagraphImplTxt::layout(double width) {
|
||||
m_width = width;
|
||||
m_paragraph->Layout(width);
|
||||
}
|
||||
|
||||
void ParagraphImplTxt::paint(Canvas* canvas, double x, double y) {
|
||||
SkCanvas* sk_canvas = canvas->canvas();
|
||||
if (!sk_canvas)
|
||||
return;
|
||||
m_paragraph->Paint(sk_canvas, x, y);
|
||||
}
|
||||
|
||||
std::vector<TextBox> ParagraphImplTxt::getRectsForRange(
|
||||
unsigned start,
|
||||
unsigned end,
|
||||
txt::Paragraph::RectHeightStyle rect_height_style,
|
||||
txt::Paragraph::RectWidthStyle rect_width_style) {
|
||||
std::vector<TextBox> result;
|
||||
std::vector<txt::Paragraph::TextBox> boxes = m_paragraph->GetRectsForRange(
|
||||
start, end, rect_height_style, rect_width_style);
|
||||
for (const txt::Paragraph::TextBox& box : boxes) {
|
||||
result.emplace_back(box.rect, static_cast<TextDirection>(box.direction));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<TextBox> ParagraphImplTxt::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<flutter::TextDirection>(box.direction));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Dart_Handle ParagraphImplTxt::getPositionForOffset(double dx, double 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 ParagraphImplTxt::getWordBoundary(unsigned 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
|
||||
@@ -1,48 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_LIB_UI_TEXT_PARAGRAPH_IMPL_TXT_H_
|
||||
#define FLUTTER_LIB_UI_TEXT_PARAGRAPH_IMPL_TXT_H_
|
||||
|
||||
#include "flutter/lib/ui/painting/canvas.h"
|
||||
#include "flutter/lib/ui/text/paragraph_impl.h"
|
||||
#include "flutter/lib/ui/text/text_box.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
class ParagraphImplTxt : public ParagraphImpl {
|
||||
public:
|
||||
~ParagraphImplTxt() override;
|
||||
|
||||
explicit ParagraphImplTxt(std::unique_ptr<txt::Paragraph> paragraph);
|
||||
|
||||
double width() override;
|
||||
double height() override;
|
||||
double longestLine() override;
|
||||
double minIntrinsicWidth() override;
|
||||
double maxIntrinsicWidth() override;
|
||||
double alphabeticBaseline() override;
|
||||
double ideographicBaseline() override;
|
||||
bool didExceedMaxLines() override;
|
||||
|
||||
void layout(double width) override;
|
||||
void paint(Canvas* canvas, double x, double y) override;
|
||||
|
||||
std::vector<TextBox> getRectsForRange(
|
||||
unsigned start,
|
||||
unsigned end,
|
||||
txt::Paragraph::RectHeightStyle rect_height_style,
|
||||
txt::Paragraph::RectWidthStyle rect_width_style) override;
|
||||
std::vector<TextBox> getRectsForPlaceholders() override;
|
||||
Dart_Handle getPositionForOffset(double dx, double dy) override;
|
||||
Dart_Handle getWordBoundary(unsigned offset) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<txt::Paragraph> m_paragraph;
|
||||
double m_width = -1.0;
|
||||
};
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_LIB_UI_TEXT_PARAGRAPH_IMPL_TXT_H_
|
||||
Reference in New Issue
Block a user