Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@GaryQian
Copy link
Contributor

No description provided.

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
Copy link
Contributor

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.

Copy link
Contributor Author

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',
Copy link
Contributor

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";
Copy link
Contributor

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.

Copy link
Contributor Author

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!

Copy link
Contributor

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.


Paragraph::Paragraph(PassOwnPtr<RenderView> renderView)
: m_renderView(renderView) {}
bool Paragraph::m_usingBlink = true;
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

#define FLUTTER_LIB_UI_TEXT_PARAGRAPH_H_

#include "flutter/lib/ui/painting/canvas.h"
#include "flutter/lib/ui/text/paragraph_builder.h"
Copy link
Contributor

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?

Copy link
Contributor Author

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!

style.ellipsis = ellipsis;

m_paragraphBuilder.SetParagraphStyle(style);
}
Copy link
Contributor

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.

Copy link
Contributor Author

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

}

m_paragraphBuilder.PushStyle(tstyle);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here


#include "flutter/lib/ui/painting/canvas.h"
#include "flutter/lib/ui/text/text_box.h"
#include "flutter/sky/engine/core/rendering/RenderView.h"
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

class ParagraphImpl {
public:
virtual void setRenderView(PassOwnPtr<RenderView> renderView,
std::unique_ptr<txt::Paragraph>& paragraph) = 0;
Copy link
Contributor

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.

Copy link
Contributor Author

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!


namespace blink {

IMPLEMENT_WRAPPERTYPEINFO(ui, ParagraphImplBlink);
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed!

ParagraphImplBlink();

void setRenderView(PassOwnPtr<RenderView> renderView,
std::unique_ptr<txt::Paragraph>& paragraph);
Copy link
Contributor

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.

class ParagraphImplBlink : public ParagraphImpl,
public ftl::RefCountedThreadSafe<ParagraphImplBlink>,
public tonic::DartWrappable {
DEFINE_WRAPPERTYPEINFO();
Copy link
Contributor

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.

namespace blink {

class ParagraphImplBlink : public ParagraphImpl,
public ftl::RefCountedThreadSafe<ParagraphImplBlink>,
Copy link
Contributor

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;
Copy link
Contributor

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.

}

void ParagraphImplTxt::paint(Canvas* canvas, double x, double y) {
SkCanvas* skCanvas = canvas->canvas();
Copy link
Contributor

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.

SkCanvas* skCanvas = canvas->canvas();
if (!skCanvas)
return;
txt::ParagraphStyle pStyle = m_paragraph->GetParagraphStyle();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/pStyle/style/


Dart_Handle ParagraphImplTxt::getPositionForOffset(double dx,
double dy) { // TODO.
return NULL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullptr

}

Dart_Handle ParagraphImplTxt::getWordBoundary(unsigned offset) { // TODO.
return NULL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullptr

@GaryQian
Copy link
Contributor Author

GaryQian commented Jun 16, 2017

@abarth @chinmaygarde Should be ready for review again.

m_paragraphImpl = std::make_unique<ParagraphImplBlink>(renderView);
}

Paragraph::Paragraph(std::unique_ptr<txt::Paragraph>* paragraph) {
Copy link
Contributor

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*

Paragraph::Paragraph(PassOwnPtr<RenderView> renderView)
: m_renderView(renderView) {}
Paragraph::Paragraph(PassOwnPtr<RenderView> renderView) {
m_paragraphImpl = std::make_unique<ParagraphImplBlink>(renderView);
Copy link
Contributor

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.

}

Paragraph::Paragraph(std::unique_ptr<txt::Paragraph> paragraph) {
m_paragraphImpl = std::make_unique<ParagraphImplTxt>(std::move(paragraph));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one too.

namespace blink {

ParagraphImplBlink::ParagraphImplBlink(PassOwnPtr<RenderView> renderView) {
m_renderView = renderView;
Copy link
Contributor

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.


class ParagraphImplBlink : public ParagraphImpl {
public:
~ParagraphImplBlink();
Copy link
Contributor

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a virtual destructor.

double maxIntrinsicWidth();
double alphabeticBaseline();
double ideographicBaseline();
bool didExceedMaxLines();
Copy link
Contributor

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

}

double ParagraphImplTxt::minIntrinsicWidth() {
// TODO(garyq): Implement in the library.
Copy link
Contributor

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.
Copy link
Contributor

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.


class ParagraphImplTxt : public ParagraphImpl {
public:
~ParagraphImplTxt();
Copy link
Contributor

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

@abarth
Copy link
Contributor

abarth commented Jun 16, 2017

LGTM

@GaryQian GaryQian merged commit c548c65 into flutter:master Jun 16, 2017
pylaligand added a commit that referenced this pull request Jun 16, 2017
pylaligand added a commit that referenced this pull request Jun 16, 2017
* 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.
ianloic added a commit that referenced this pull request Jun 16, 2017
ianloic added a commit that referenced this pull request Jun 16, 2017
…3785)

* Revert "Enable line join styles and miter limit. (#3777)"

This reverts commit 5403f65.

* Revert "Revert "Update switches to use StringView." (#3784)"

This reverts commit 80f039f.

* Revert "Initial integration of libtxt with Flutter alongside Blink. (#3771)"

This reverts commit c548c65.
@eseidelGoogle
Copy link
Contributor

Part of flutter/flutter#10476.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants