-
Notifications
You must be signed in to change notification settings - Fork 6k
[web] Implement Paragraph.getLineBoundary #14479
Conversation
gspencergoog
left a comment
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.
|
|
||
| // "One single line".length == 15 | ||
| for (int i = 0; i < 15; i++) { | ||
| expect( |
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.
Add a reason: to this expect that tells what i is, so that it's easier to debug.
For example:
reason: 'failed at offset $i'
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.
Nice pro-tip! Thanks I'll add it.
|
|
||
| // "First line\n".length == 11 | ||
| for (int i = 0; i < 11; i++) { | ||
| expect( |
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.
Add a reason:
|
|
||
| // "Second line\n".length == 12 | ||
| for (int i = 11; i < 23; i++) { | ||
| expect( |
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.
Add a reason:
|
|
||
| // "Third line".length == 10 | ||
| for (int i = 23; i < 33; i++) { | ||
| expect( |
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.
Add a reason:
| if (lines != null) { | ||
| final int offset = position.offset; | ||
|
|
||
| for (int i = 0; i < lines.length; i++) { |
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.
Would binary search be overkill in this 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.
Yes :)
Most paragraphs are 1-4 lines.
| /// The index in the text where this line begins. | ||
| final int startIndex; | ||
|
|
||
| /// The index in the text where this line ends. |
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.
Age-old question: is that the index of the last character or +1 from that? :)
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 [start, end[
i.e. start is inclusive, end is exclusive.
I'll clarify it in the comment.
* c260057 Roll src/third_party/dart fe9f30c3896e..8ad8abfb7463 (19 commits) (flutter/engine#14480) * 47c1dde Roll src/third_party/skia d0840ecf5831..ea47b0e65802 (9 commits) (flutter/engine#14481) * 35adf37 [web] Implement Paragraph.getLineBoundary (flutter/engine#14479) * 00cbfd3 [web] Remove Paragraph._lines which isn't necessary anymore (flutter/engine#14485) * d6172fd libtxt: cache fallback fonts found by a Minikin font collection (flutter/engine#14482) * 1912478 adding firefox unit tests to font loading (flutter/engine#14487) * 6c71f89 Introduce an auto-deletable SkiaObject; make SkPaint a SkiaObject (flutter/engine#14486) * 2026b83 Roll src/third_party/dart 8ad8abfb7463..83eeab1e63d9 (13 commits) (flutter/engine#14488) * b43d3fe Roll src/third_party/skia ea47b0e65802..cd9ad409a90d (7 commits) (flutter/engine#14490) * 3c85b82 Roll fuchsia/sdk/core/linux-amd64 from QZVxo... to q0tup... (flutter/engine#14494) * 3e3eb9c Roll src/third_party/dart 83eeab1e63d9..6c99171686be (5 commits) (flutter/engine#14492) * cbe0e6c Roll src/third_party/skia cd9ad409a90d..cf0e3c63fd22 (1 commits) (flutter/engine#14495) * a653bd8 Roll fuchsia/sdk/core/mac-amd64 from 5t09i... to esDH2... (flutter/engine#14493) * 17d8882 Roll src/third_party/dart 6c99171686be..09a0b040dd9b (1 commits) (flutter/engine#14497) * be9c7c9 Roll src/third_party/skia cf0e3c63fd22..9e7199561fc8 (1 commits) (flutter/engine#14499) * c504b8f Roll src/third_party/skia 9e7199561fc8..ef363a9ce692 (1 commits) (flutter/engine#14500) * cf20f87 Roll src/third_party/dart 09a0b040dd9b..ae3973da4023 (1 commits) (flutter/engine#14501) * bb3166b Roll src/third_party/dart ae3973da4023..24b99838f433 (3 commits) (flutter/engine#14502) * 87c1110 Roll src/third_party/skia ef363a9ce692..187cd367d388 (1 commits) (flutter/engine#14503) * 45c6c3a Roll src/third_party/skia 187cd367d388..706eb5788e8b (1 commits) (flutter/engine#14505) * d292380 Fix comments of iOS status bar height constant (flutter/engine#14496) * 1ed7247 Roll src/third_party/dart 24b99838f433..2e1dd98e5e7f (1 commits) (flutter/engine#14507) * 8712461 Allow custom embedders to post low memory notifications. (flutter/engine#14506) * 1d1eae2 Roll fuchsia/sdk/core/linux-amd64 from q0tup... to O6ELR... (flutter/engine#14512) * 8b47886 Roll src/third_party/dart c5c469088697..44ba80053396 (1 commits) (flutter/engine#14510) * ca799fa Roll src/third_party/skia 706eb5788e8b..9b59953e77b9 (3 commits) (flutter/engine#14511) * 8456411 Roll src/third_party/dart 44ba80053396..2eba06d26f71 (32 commits) (flutter/engine#14515) * 46d76eb Roll src/third_party/skia 9b59953e77b9..d78a9b45b9e5 (23 commits) (flutter/engine#14516) * 5f9e558 Forward low memory notifications from the shell to DartVM. (flutter/engine#14517) * dc59758 Apply SmoothPointerDataDispatcher to Fuchsia (flutter/engine#14514) * 9556f2c Roll src/third_party/dart 2eba06d26f71..b1afe2d0ebc1 (6 commits) (flutter/engine#14523) * e829384 Roll fuchsia/sdk/core/linux-amd64 from O6ELR... to ZHhOi... (flutter/engine#14525) * 0fbdeb8 Roll src/third_party/dart b1afe2d0ebc1..2d332ee1d3f1 (1 commits) (flutter/engine#14526) * 500f9ce Roll src/third_party/skia 6153165d78f2..fdb2b7d53038 (2 commits) (flutter/engine#14528)

Fixes flutter/flutter#44381