paragraph_builder.h 2.3 KB
Newer Older
1 2 3 4
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
#ifndef FLUTTER_LIB_UI_TEXT_PARAGRAPH_BUILDER_H_
#define FLUTTER_LIB_UI_TEXT_PARAGRAPH_BUILDER_H_
7

8
#include <memory>
9
#include "flutter/lib/ui/dart_wrapper.h"
10
#include "flutter/lib/ui/painting/paint.h"
11
#include "flutter/lib/ui/text/paragraph.h"
12
#include "flutter/third_party/txt/src/txt/paragraph_builder.h"
13
#include "third_party/tonic/typed_data/int32_list.h"
14

15
namespace tonic {
A
Adam Barth 已提交
16
class DartLibraryNatives;
17 18 19
}  // namespace tonic

namespace blink {
20

21 22
class Paragraph;

23
class ParagraphBuilder : public RefCountedDartWrappable<ParagraphBuilder> {
24
  DEFINE_WRAPPERTYPEINFO();
25
  FML_FRIEND_MAKE_REF_COUNTED(ParagraphBuilder);
26

27
 public:
28
  static fml::RefPtr<ParagraphBuilder> create(tonic::Int32List& encoded,
29 30 31
                                              const std::string& fontFamily,
                                              double fontSize,
                                              double lineHeight,
32
                                              const std::u16string& ellipsis,
J
Jason Simmons 已提交
33
                                              const std::string& locale);
34

35
  ~ParagraphBuilder() override;
36

37 38 39 40 41
  void pushStyle(tonic::Int32List& encoded,
                 const std::string& fontFamily,
                 double fontSize,
                 double letterSpacing,
                 double wordSpacing,
42
                 double height,
43 44
                 const std::string& locale,
                 Dart_Handle background_objects,
45 46 47
                 Dart_Handle background_data,
                 Dart_Handle foreground_objects,
                 Dart_Handle foreground_data);
48

49
  void pop();
50

51
  Dart_Handle addText(const std::u16string& text);
52

53
  fml::RefPtr<Paragraph> build();
A
Adam Barth 已提交
54

55
  static void RegisterNatives(tonic::DartLibraryNatives* natives);
56

57
 private:
58 59 60 61
  explicit ParagraphBuilder(tonic::Int32List& encoded,
                            const std::string& fontFamily,
                            double fontSize,
                            double lineHeight,
62
                            const std::u16string& ellipsis,
J
Jason Simmons 已提交
63 64
                            const std::string& locale);

65
  std::unique_ptr<txt::ParagraphBuilder> m_paragraphBuilder;
66 67
};

68
}  // namespace blink
69

70
#endif  // FLUTTER_LIB_UI_TEXT_PARAGRAPH_BUILDER_H_