paragraph_builder_stub.h 1.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
// 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.

#ifndef FLUTTER_LIB_UI_TEXT_PARAGRAPH_BUILDER_STUB_H_
#define FLUTTER_LIB_UI_TEXT_PARAGRAPH_BUILDER_STUB_H_

#include "flutter/lib/ui/text/paragraph_stub.h"
#include "lib/tonic/dart_wrappable.h"
#include "lib/tonic/typed_data/int32_list.h"

namespace tonic {
class DartLibraryNatives;
}  // namespace tonic

namespace blink {

class ParagraphBuilder : public ftl::RefCountedThreadSafe<ParagraphBuilder>,
                         public tonic::DartWrappable {
  DEFINE_WRAPPERTYPEINFO();
  FRIEND_MAKE_REF_COUNTED(ParagraphBuilder);

 public:
  static ftl::RefPtr<ParagraphBuilder> create() {
    return ftl::MakeRefCounted<ParagraphBuilder>();
  }

  ~ParagraphBuilder() override;

  void pushStyle(tonic::Int32List& encoded,
                 const std::string& fontFamily,
                 double fontSize,
                 double letterSpacing,
                 double wordSpacing,
                 double height);
  void pop();

  void addText(const std::string& text);

  ftl::RefPtr<Paragraph> build(tonic::Int32List& encoded,
                               const std::string& fontFamily,
                               double fontSize,
                               double lineHeight);

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

 private:
  ParagraphBuilder();
};

}  // namespace blink

#endif  // FLUTTER_LIB_UI_TEXT_PARAGRAPH_BUILDER_STUB_H_