5#include "flutter/lib/ui/text/paragraph.h"
7#include "flutter/common/settings.h"
8#include "flutter/common/task_runners.h"
9#include "flutter/fml/logging.h"
10#include "flutter/fml/task_runner.h"
11#include "third_party/dart/runtime/include/dart_api.h"
24Paragraph::Paragraph(std::unique_ptr<txt::Paragraph> paragraph)
25 : m_paragraph_(
std::move(paragraph)) {}
27Paragraph::~Paragraph() =
default;
30 return m_paragraph_->GetMaxWidth();
34 return m_paragraph_->GetHeight();
37double Paragraph::longestLine() {
38 return m_paragraph_->GetLongestLine();
41double Paragraph::minIntrinsicWidth() {
42 return m_paragraph_->GetMinIntrinsicWidth();
45double Paragraph::maxIntrinsicWidth() {
46 return m_paragraph_->GetMaxIntrinsicWidth();
49double Paragraph::alphabeticBaseline() {
50 return m_paragraph_->GetAlphabeticBaseline();
53double Paragraph::ideographicBaseline() {
54 return m_paragraph_->GetIdeographicBaseline();
57bool Paragraph::didExceedMaxLines() {
58 return m_paragraph_->DidExceedMaxLines();
61void Paragraph::layout(
double width) {
62 m_paragraph_->Layout(
width);
66 if (!m_paragraph_ || !canvas) {
78 const std::vector<txt::Paragraph::TextBox>& boxes) {
85 uint64_t position = 0;
86 for (uint64_t
i = 0;
i < boxes.size();
i++) {
97tonic::Float32List Paragraph::getRectsForRange(
unsigned start,
99 unsigned boxHeightStyle,
100 unsigned boxWidthStyle) {
101 std::vector<txt::Paragraph::TextBox> boxes = m_paragraph_->GetRectsForRange(
107tonic::Float32List Paragraph::getRectsForPlaceholders() {
108 std::vector<txt::Paragraph::TextBox> boxes =
109 m_paragraph_->GetRectsForPlaceholders();
115 m_paragraph_->GetGlyphPositionAtCoordinate(
dx, dy);
116 std::vector<size_t>
result = {
118 static_cast<size_t>(
pos.affinity)
126 std::array<Dart_Handle, 7> arguments = {
142 const bool found = m_paragraph_->GetGlyphInfoAt(utf16Offset, &glyphInfo);
156 m_paragraph_->GetClosestGlyphInfoAtCoordinate(
dx, dy, &glyphInfo);
167 m_paragraph_->GetWordBoundary(utf16Offset);
173 std::vector<txt::LineMetrics> metrics = m_paragraph_->GetLineMetrics();
177 if (utf16Offset >=
line.start_index && utf16Offset <=
line.end_index) {
178 line_start =
line.start_index;
179 line_end =
line.end_index;
183 std::vector<int>
result = {line_start, line_end};
187tonic::Float64List Paragraph::computeLineMetrics()
const {
188 std::vector<txt::LineMetrics> metrics = m_paragraph_->GetLineMetrics();
193 tonic::Float64List
result(
195 uint64_t position = 0;
196 for (uint64_t
i = 0;
i < metrics.size();
i++) {
198 result[position++] =
static_cast<double>(
line.hard_break);
209 result[position++] =
static_cast<double>(
line.line_number);
218 const bool found = m_paragraph_->GetLineMetricsAt(lineNumber, &
line);
222 std::array<Dart_Handle, 9> arguments = {
243size_t Paragraph::getNumberOfLines()
const {
244 return m_paragraph_->GetNumberOfLines();
247int Paragraph::getLineNumberAt(
size_t utf16Offset)
const {
248 return m_paragraph_->GetLineNumberAt(utf16Offset);
251void Paragraph::dispose() {
252 m_paragraph_.reset();
static void round(SkPoint *p)
DisplayListBuilder * builder()
DART_EXPORT Dart_Handle Dart_NewDouble(double value)
struct _Dart_Handle * Dart_Handle
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_InvokeClosure(Dart_Handle closure, int number_of_arguments, Dart_Handle *arguments)
@ Dart_TypedData_kFloat32
@ Dart_TypedData_kFloat64
DART_EXPORT Dart_Handle Dart_NewTypedData(Dart_TypedData_Type type, intptr_t length)
DART_EXPORT Dart_Handle Dart_Null(void)
DART_EXPORT Dart_Handle Dart_NewInteger(int64_t value)
DART_EXPORT Dart_Handle Dart_NewBoolean(bool value)
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
IMPLEMENT_WRAPPERTYPEINFO(flutter_gpu, FlutterGpuTestClass)
static tonic::Float32List EncodeTextBoxes(const std::vector< txt::Paragraph::TextBox > &boxes)
Dart_Handle glyphInfoFrom(Dart_Handle constructor, const skia::textlayout::Paragraph::GlyphInfo &glyphInfo)
Dart_Handle ToDart(const T &object)
bool CheckAndHandleError(Dart_Handle handle)
SkScalar fBottom
larger y-axis bounds
SkScalar fLeft
smaller x-axis bounds
SkScalar fRight
larger x-axis bounds
SkScalar fTop
smaller y-axis bounds
TextRange fGraphemeClusterTextRange
SkRect fGraphemeLayoutBounds