-
Notifications
You must be signed in to change notification settings - Fork 6k
[Skwasm] Correctly handle paragraphs with empty text. #51695
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -176,5 +176,5 @@ Future<void> testMain() async { | |
|
|
||
| // In Roboto, the width should be 11 here. In the test font, it would be square (16 points) | ||
| expect(metrics!.width, 11); | ||
| }, solo: true); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We desperately need a lint that prevents this.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I was wondering about this. We used to have a lint I thought, but it disappeared apparently. I was surprised to find I had been able to check this in too |
||
| }); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,4 +39,11 @@ Future<void> testMain() async { | |
|
|
||
| expect(() => builder.build(), returnsNormally); | ||
| }); | ||
|
|
||
| test('build and layout a paragraph with an empty addText', () { | ||
| final ParagraphBuilder builder = ParagraphBuilder(ParagraphStyle()); | ||
| builder.addText(''); | ||
| final Paragraph paragraph = builder.build(); | ||
| paragraph.layout(const ParagraphConstraints(width: double.infinity)); | ||
| }); | ||
|
Comment on lines
+43
to
+51
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a bit odd to have a test with no expectations. Can we add one to emphasize what the test is checking? e.g. expect(
() => paragraph.layout(const ParagraphConstraints(width: double.infinity)),
returnsNormally,
);
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's probably some use in actually checking the layout properties of an empty paragraph.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a separate test for a straight up empty paragraph (with no So I'd rather just do one that doesn't read any metrics. But I think doing the |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
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 was going to suggest using
Iterable<int>.generate(...)instead, but then realized thatutf8.decode(...)takes aList<int>. I wonder why.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.
Typically anything but a raw
Listwould be many times slower. I'm not surprisedutf8prefers lists. Honestly, this is fine. I wouldn't even leave a TODO.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.
That's probably true for dart2js since raw
Listare basically JS arrays under the hood (IIUC). But is it the same for wasm?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's not the same for wasm,
Listis definitely polymorphic. A while back I actually did try making a subclass ofList<int>that reads from an ffi pointer, and it actually was slightly slower. I think I'll just remove this TODO.