diff --git a/engine/src/flutter/lib/ui/BUILD.gn b/engine/src/flutter/lib/ui/BUILD.gn index 846b0d2857..d9f0c7e246 100644 --- a/engine/src/flutter/lib/ui/BUILD.gn +++ b/engine/src/flutter/lib/ui/BUILD.gn @@ -44,6 +44,12 @@ source_set("ui") { "painting/rrect.h", "painting/shader.cc", "painting/shader.h", + "text/paragraph_builder.cc", + "text/paragraph_builder.h", + "text/paragraph.cc", + "text/paragraph.h", + "text/text_box.cc", + "text/text_box.h", "ui_dart_state.cc", "ui_dart_state.h", "window/window.cc", @@ -67,24 +73,6 @@ source_set("ui") { "//mojo/services/asset_bundle/interfaces", ] - if (is_fuchsia) { - sources += [ - "text/paragraph_builder_stub.cc", - "text/paragraph_builder_stub.h", - "text/paragraph_stub.cc", - "text/paragraph_stub.h", - ] - } else { - sources += [ - "text/paragraph_builder.cc", - "text/paragraph_builder.h", - "text/paragraph.cc", - "text/paragraph.h", - "text/text_box.cc", - "text/text_box.h", - ] - } - if (is_android) { deps += [ # TODO(abarth): In principle, these libraries should be fully independent. diff --git a/engine/src/flutter/lib/ui/dart_ui.cc b/engine/src/flutter/lib/ui/dart_ui.cc index 54942de9b6..9a5b6c554a 100644 --- a/engine/src/flutter/lib/ui/dart_ui.cc +++ b/engine/src/flutter/lib/ui/dart_ui.cc @@ -18,19 +18,13 @@ #include "flutter/lib/ui/painting/path.h" #include "flutter/lib/ui/painting/picture_recorder.h" #include "flutter/lib/ui/painting/picture.h" +#include "flutter/lib/ui/text/paragraph_builder.h" +#include "flutter/lib/ui/text/paragraph.h" #include "flutter/lib/ui/window/window.h" #include "lib/ftl/build_config.h" #include "lib/tonic/converter/dart_converter.h" #include "lib/tonic/logging/dart_error.h" -#if defined(OS_FUCHSIA) -#include "flutter/lib/ui/text/paragraph_builder_stub.h" -#include "flutter/lib/ui/text/paragraph_stub.h" -#else -#include "flutter/lib/ui/text/paragraph_builder.h" -#include "flutter/lib/ui/text/paragraph.h" -#endif - using tonic::ToDart; namespace blink { diff --git a/engine/src/flutter/lib/ui/text/paragraph_builder_stub.cc b/engine/src/flutter/lib/ui/text/paragraph_builder_stub.cc deleted file mode 100644 index 53e3d08c4c..0000000000 --- a/engine/src/flutter/lib/ui/text/paragraph_builder_stub.cc +++ /dev/null @@ -1,59 +0,0 @@ -// 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. - -#include "flutter/lib/ui/text/paragraph_builder_stub.h" - -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_args.h" -#include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/dart_library_natives.h" - -namespace blink { - -static void ParagraphBuilder_constructor(Dart_NativeArguments args) { - DartCallConstructor(&ParagraphBuilder::create, args); -} - -IMPLEMENT_WRAPPERTYPEINFO(ui, ParagraphBuilder); - -#define FOR_EACH_BINDING(V) \ - V(ParagraphBuilder, pushStyle) \ - V(ParagraphBuilder, pop) \ - V(ParagraphBuilder, addText) \ - V(ParagraphBuilder, build) - -FOR_EACH_BINDING(DART_NATIVE_CALLBACK) - -void ParagraphBuilder::RegisterNatives(tonic::DartLibraryNatives* natives) { - natives->Register( - {{"ParagraphBuilder_constructor", ParagraphBuilder_constructor, 1, true}, - FOR_EACH_BINDING(DART_REGISTER_NATIVE)}); -} - -ParagraphBuilder::ParagraphBuilder() {} - -ParagraphBuilder::~ParagraphBuilder() {} - -void ParagraphBuilder::pushStyle(tonic::Int32List& encoded, - const std::string& fontFamily, - double fontSize, - double letterSpacing, - double wordSpacing, - double height) { - encoded.Release(); -} - -void ParagraphBuilder::pop() {} - -void ParagraphBuilder::addText(const std::string& text) {} - -ftl::RefPtr ParagraphBuilder::build(tonic::Int32List& encoded, - const std::string& fontFamily, - double fontSize, - double lineHeight) { - encoded.Release(); - return Paragraph::create(); -} - -} // namespace blink diff --git a/engine/src/flutter/lib/ui/text/paragraph_builder_stub.h b/engine/src/flutter/lib/ui/text/paragraph_builder_stub.h deleted file mode 100644 index cee9717550..0000000000 --- a/engine/src/flutter/lib/ui/text/paragraph_builder_stub.h +++ /dev/null @@ -1,53 +0,0 @@ -// 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, - public tonic::DartWrappable { - DEFINE_WRAPPERTYPEINFO(); - FRIEND_MAKE_REF_COUNTED(ParagraphBuilder); - - public: - static ftl::RefPtr create() { - return ftl::MakeRefCounted(); - } - - ~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 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_ diff --git a/engine/src/flutter/lib/ui/text/paragraph_stub.cc b/engine/src/flutter/lib/ui/text/paragraph_stub.cc deleted file mode 100644 index a718df8b38..0000000000 --- a/engine/src/flutter/lib/ui/text/paragraph_stub.cc +++ /dev/null @@ -1,81 +0,0 @@ -// 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. - -#include "flutter/lib/ui/text/paragraph_stub.h" - -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_args.h" -#include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/dart_library_natives.h" - -using tonic::ToDart; - -namespace blink { - -IMPLEMENT_WRAPPERTYPEINFO(ui, Paragraph); - -#define FOR_EACH_BINDING(V) \ - V(Paragraph, width) \ - V(Paragraph, height) \ - V(Paragraph, minIntrinsicWidth) \ - V(Paragraph, maxIntrinsicWidth) \ - V(Paragraph, alphabeticBaseline) \ - V(Paragraph, ideographicBaseline) \ - V(Paragraph, layout) \ - V(Paragraph, paint) \ - V(Paragraph, getWordBoundary) \ - V(Paragraph, getRectsForRange) \ - V(Paragraph, getPositionForOffset) - -DART_BIND_ALL(Paragraph, FOR_EACH_BINDING) - -Paragraph::Paragraph() {} - -Paragraph::~Paragraph() {} - -double Paragraph::width() { - return 0.0; -} - -double Paragraph::height() { - return 0.0; -} - -double Paragraph::minIntrinsicWidth() { - return 0.0; -} - -double Paragraph::maxIntrinsicWidth() { - return 0.0; -} - -double Paragraph::alphabeticBaseline() { - return 0.0; -} - -double Paragraph::ideographicBaseline() { - return 0.0; -} - -void Paragraph::layout(double width) {} - -void Paragraph::paint(Canvas* canvas, double x, double y) {} - -void Paragraph::getRectsForRange(unsigned start, unsigned end) {} - -Dart_Handle Paragraph::getPositionForOffset(double dx, double dy) { - Dart_Handle result = Dart_NewList(2); - Dart_ListSetAt(result, 0, ToDart(0)); - Dart_ListSetAt(result, 1, ToDart(0)); - return result; -} - -Dart_Handle Paragraph::getWordBoundary(unsigned offset) { - Dart_Handle result = Dart_NewList(2); - Dart_ListSetAt(result, 0, ToDart(0)); - Dart_ListSetAt(result, 1, ToDart(0)); - return result; -} - -} // namespace blink diff --git a/engine/src/flutter/lib/ui/text/paragraph_stub.h b/engine/src/flutter/lib/ui/text/paragraph_stub.h deleted file mode 100644 index 2ae78920f1..0000000000 --- a/engine/src/flutter/lib/ui/text/paragraph_stub.h +++ /dev/null @@ -1,51 +0,0 @@ -// 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_STUB_H_ -#define FLUTTER_LIB_UI_TEXT_PARAGRAPH_STUB_H_ - -#include "flutter/lib/ui/painting/canvas.h" -#include "lib/tonic/dart_wrappable.h" - -namespace tonic { -class DartLibraryNatives; -} // namespace tonic - -namespace blink { - -class Paragraph : public ftl::RefCountedThreadSafe, - public tonic::DartWrappable { - DEFINE_WRAPPERTYPEINFO(); - FRIEND_MAKE_REF_COUNTED(Paragraph); - - public: - static ftl::RefPtr create() { - return ftl::MakeRefCounted(); - } - - ~Paragraph() override; - - double width(); - double height(); - double minIntrinsicWidth(); - double maxIntrinsicWidth(); - double alphabeticBaseline(); - double ideographicBaseline(); - - void layout(double width); - void paint(Canvas* canvas, double x, double y); - - void getRectsForRange(unsigned start, unsigned end); - Dart_Handle getPositionForOffset(double dx, double dy); - Dart_Handle getWordBoundary(unsigned offset); - - static void RegisterNatives(tonic::DartLibraryNatives* natives); - - private: - Paragraph(); -}; - -} // namespace blink - -#endif // FLUTTER_LIB_UI_TEXT_PARAGRAPH_STUB_H_ diff --git a/engine/src/flutter/lib/ui/ui_dart_state.cc b/engine/src/flutter/lib/ui/ui_dart_state.cc index ac04b1ce05..8029cff398 100644 --- a/engine/src/flutter/lib/ui/ui_dart_state.cc +++ b/engine/src/flutter/lib/ui/ui_dart_state.cc @@ -6,16 +6,13 @@ #include "flutter/lib/ui/mojo_services.h" #include "flutter/lib/ui/window/window.h" +#include "flutter/sky/engine/platform/fonts/FontSelector.h" #include "lib/tonic/converter/dart_converter.h" #if defined(OS_ANDROID) #include "flutter/lib/jni/dart_jni.h" #endif -#if !defined(OS_FUCHSIA) -#include "flutter/sky/engine/platform/fonts/FontSelector.h" -#endif - using tonic::ToDart; namespace blink { @@ -73,8 +70,6 @@ DartJniIsolateData* UIDartState::jni_data() { } #endif // defined(OS_ANDROID) -#if !defined(OS_FUCHSIA) - void UIDartState::set_font_selector(PassRefPtr selector) { font_selector_ = selector; } @@ -83,6 +78,4 @@ PassRefPtr UIDartState::font_selector() { return font_selector_; } -#endif // !defined(OS_FUCHSIA) - } // namespace blink diff --git a/engine/src/flutter/lib/ui/ui_dart_state.h b/engine/src/flutter/lib/ui/ui_dart_state.h index 111630fbab..a85e200301 100644 --- a/engine/src/flutter/lib/ui/ui_dart_state.h +++ b/engine/src/flutter/lib/ui/ui_dart_state.h @@ -6,14 +6,11 @@ #define FLUTTER_LIB_UI_UI_DART_STATE_H_ #include "dart/runtime/include/dart_api.h" +#include "flutter/sky/engine/wtf/RefPtr.h" #include "lib/ftl/build_config.h" #include "lib/tonic/dart_persistent_value.h" #include "lib/tonic/dart_state.h" -#if !defined(OS_FUCHSIA) -#include "flutter/sky/engine/wtf/RefPtr.h" -#endif - namespace blink { class FontSelector; class DartJniIsolateData; @@ -49,10 +46,8 @@ class UIDartState : public tonic::DartState { DartJniIsolateData* jni_data(); #endif -#if !defined(OS_FUCHSIA) void set_font_selector(PassRefPtr selector); PassRefPtr font_selector(); -#endif private: void DidSetIsolate() override; @@ -62,14 +57,11 @@ class UIDartState : public tonic::DartState { std::string debug_name_; std::unique_ptr mojo_services_; std::unique_ptr window_; + RefPtr font_selector_; #if defined(OS_ANDROID) std::unique_ptr jni_data_; #endif - -#if !defined(OS_FUCHSIA) - RefPtr font_selector_; -#endif }; } // namespace blink