-
Notifications
You must be signed in to change notification settings - Fork 6k
Initial integration of libtxt with Flutter alongside Blink. #3771
Conversation
BUILD.gn
Outdated
| "//lib/ftl:ftl_unittests", | ||
| "//lib/txt/examples:txt_example($host_toolchain)", | ||
| "//lib/txt/tests/txt($host_toolchain)", # txt_unittests | ||
| "//lib/txt/tests/unittest($host_toolchain)", # minikin_unittest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be cleaner if these could be referenced as //lib/txt/examples and //lib/txt/tests, respectively. That will give us more freedom to add more examples and tests over time without changing both repos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
DEPS
Outdated
| Var('fuchsia_git') + '/zip' + '@' + '92dc87ca645fe8e9f5151ef6dac86d8311a7222f', | ||
|
|
||
| 'src/lib/txt': | ||
| Var('fuchsia_git') + '/txt' + '@' + 'Id71461bd96e08eae0e24ab35a040874d960af8e0', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the "I" extra here?
lib/ui/text.dart
Outdated
|
|
||
| // Toggles between Blink text shaping backend and libtxt backend. This allows | ||
| // for debugging and development and is not intended to be a final feature. | ||
| void toggleTxt() native "Paragraph_toggleTxt"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't expose this to Dart. These APIs are meant to be stable. Instead, we should use a command line flag to enable libtxt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed this function for now and started with the flag. I'll finish up the command line flag in a later patch. This pr is getting really big!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't land this patch with this function here.
lib/ui/text/paragraph.cc
Outdated
|
|
||
| Paragraph::Paragraph(PassOwnPtr<RenderView> renderView) | ||
| : m_renderView(renderView) {} | ||
| bool Paragraph::m_usingBlink = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move this bool to the Settings object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
lib/ui/text/paragraph.h
Outdated
| #define FLUTTER_LIB_UI_TEXT_PARAGRAPH_H_ | ||
|
|
||
| #include "flutter/lib/ui/painting/canvas.h" | ||
| #include "flutter/lib/ui/text/paragraph_builder.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need knowledge of the paragraph builder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, left over from before!
lib/ui/text/paragraph_builder.cc
Outdated
| style.ellipsis = ellipsis; | ||
|
|
||
| m_paragraphBuilder.SetParagraphStyle(style); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd put this in an "else". We shouldn't do the blink-related work in the non-blink case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved them all to elses
lib/ui/text/paragraph_builder.cc
Outdated
| } | ||
|
|
||
| m_paragraphBuilder.PushStyle(tstyle); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
lib/ui/text/paragraph_impl.h
Outdated
|
|
||
| #include "flutter/lib/ui/painting/canvas.h" | ||
| #include "flutter/lib/ui/text/text_box.h" | ||
| #include "flutter/sky/engine/core/rendering/RenderView.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The base class shouldn't know about RenderView.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/ui/text/paragraph_impl.h
Outdated
| class ParagraphImpl { | ||
| public: | ||
| virtual void setRenderView(PassOwnPtr<RenderView> renderView, | ||
| std::unique_ptr<txt::Paragraph>& paragraph) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should move to ParagraphImplBlink.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restructured the inheritance to be better. No longer need this function!
lib/ui/text/paragraph_impl_blink.cc
Outdated
|
|
||
| namespace blink { | ||
|
|
||
| IMPLEMENT_WRAPPERTYPEINFO(ui, ParagraphImplBlink); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't need a WRAPPERTYPEINFO. The Paragraph is the object with the Dart wrapper, not this object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed!
lib/ui/text/paragraph_impl_blink.h
Outdated
| ParagraphImplBlink(); | ||
|
|
||
| void setRenderView(PassOwnPtr<RenderView> renderView, | ||
| std::unique_ptr<txt::Paragraph>& paragraph); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be here.
lib/ui/text/paragraph_impl_blink.h
Outdated
| class ParagraphImplBlink : public ParagraphImpl, | ||
| public ftl::RefCountedThreadSafe<ParagraphImplBlink>, | ||
| public tonic::DartWrappable { | ||
| DEFINE_WRAPPERTYPEINFO(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this start wrapper stuff.
lib/ui/text/paragraph_impl_blink.h
Outdated
| namespace blink { | ||
|
|
||
| class ParagraphImplBlink : public ParagraphImpl, | ||
| public ftl::RefCountedThreadSafe<ParagraphImplBlink>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this object ref counted? It seems like it should just be owned by the Paragraph object.
| private: | ||
| friend class ParagraphBuilder; | ||
|
|
||
| std::unique_ptr<ParagraphImpl> m_paragraphImpl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're holding the ParagraphImpl with a unique_ptr, which means they shouldn't inherit from refcounted or do any of that sort of stuff.
lib/ui/text/paragraph_impl_txt.cc
Outdated
| } | ||
|
|
||
| void ParagraphImplTxt::paint(Canvas* canvas, double x, double y) { | ||
| SkCanvas* skCanvas = canvas->canvas(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The style guys says to use names_like_this for local variables. That means this variable should be called sk_canvas.
lib/ui/text/paragraph_impl_txt.cc
Outdated
| SkCanvas* skCanvas = canvas->canvas(); | ||
| if (!skCanvas) | ||
| return; | ||
| txt::ParagraphStyle pStyle = m_paragraph->GetParagraphStyle(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/pStyle/style/
lib/ui/text/paragraph_impl_txt.cc
Outdated
|
|
||
| Dart_Handle ParagraphImplTxt::getPositionForOffset(double dx, | ||
| double dy) { // TODO. | ||
| return NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nullptr
lib/ui/text/paragraph_impl_txt.cc
Outdated
| } | ||
|
|
||
| Dart_Handle ParagraphImplTxt::getWordBoundary(unsigned offset) { // TODO. | ||
| return NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nullptr
|
@abarth @chinmaygarde Should be ready for review again. |
lib/ui/text/paragraph.cc
Outdated
| m_paragraphImpl = std::make_unique<ParagraphImplBlink>(renderView); | ||
| } | ||
|
|
||
| Paragraph::Paragraph(std::unique_ptr<txt::Paragraph>* paragraph) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a std::unique_ptrtxt::Paragraph not a std::unique_ptrtxt::Paragraph*
lib/ui/text/paragraph.cc
Outdated
| Paragraph::Paragraph(PassOwnPtr<RenderView> renderView) | ||
| : m_renderView(renderView) {} | ||
| Paragraph::Paragraph(PassOwnPtr<RenderView> renderView) { | ||
| m_paragraphImpl = std::make_unique<ParagraphImplBlink>(renderView); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move this to the initializer list.
lib/ui/text/paragraph.cc
Outdated
| } | ||
|
|
||
| Paragraph::Paragraph(std::unique_ptr<txt::Paragraph> paragraph) { | ||
| m_paragraphImpl = std::make_unique<ParagraphImplTxt>(std::move(paragraph)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one too.
lib/ui/text/paragraph_impl_blink.cc
Outdated
| namespace blink { | ||
|
|
||
| ParagraphImplBlink::ParagraphImplBlink(PassOwnPtr<RenderView> renderView) { | ||
| m_renderView = renderView; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move this to the intializer list.
lib/ui/text/paragraph_impl_blink.h
Outdated
|
|
||
| class ParagraphImplBlink : public ParagraphImpl { | ||
| public: | ||
| ~ParagraphImplBlink(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
override
|
|
||
| namespace blink { | ||
|
|
||
| class ParagraphImpl { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a virtual destructor.
lib/ui/text/paragraph_impl_blink.h
Outdated
| double maxIntrinsicWidth(); | ||
| double alphabeticBaseline(); | ||
| double ideographicBaseline(); | ||
| bool didExceedMaxLines(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should all be marked override
lib/ui/text/paragraph_impl_txt.cc
Outdated
| } | ||
|
|
||
| double ParagraphImplTxt::minIntrinsicWidth() { | ||
| // TODO(garyq): Implement in the library. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably remove these TODOs from here. They seem to belong in libtxt given that's where the code is missing.
| } | ||
|
|
||
| Dart_Handle ParagraphImplTxt::getPositionForOffset(double dx, double dy) { | ||
| // TODO(garyq): Implement in the library. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These I'd keep here because the code is missing from here.
lib/ui/text/paragraph_impl_txt.h
Outdated
|
|
||
| class ParagraphImplTxt : public ParagraphImpl { | ||
| public: | ||
| ~ParagraphImplTxt(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also missing a bunch of overrides here
* Revert "Initial integration of libtxt with Flutter alongside Blink. (#3771)" This reverts commit c548c65. * Revert "Call Selection.removeSelection if the framework has cleared the selection (#3782)" This reverts commit e5b79ba. * Revert "Update switches to use StringView. (#3781)" This reverts commit 07d4357.
|
Part of flutter/flutter#10476. |

No description provided.