@@ -127,10 +127,6 @@ List<LineBreakFragment> _computeLineBreakFragments(String text) {
127
127
int ? codePoint = getCodePoint (text, 0 );
128
128
LineCharProperty ? curr = lineLookup.findForChar (codePoint);
129
129
130
- // When there's a sequence of spaces, this variable contains the base property
131
- // i.e. the property of the character preceding the sequence.
132
- LineCharProperty baseOfSpaceSequence = LineCharProperty .WJ ;
133
-
134
130
// When there's a sequence of combining marks, this variable contains the base
135
131
// property i.e. the property of the character preceding the sequence.
136
132
LineCharProperty baseOfCombiningMarks = LineCharProperty .AL ;
@@ -146,6 +142,9 @@ List<LineBreakFragment> _computeLineBreakFragments(String text) {
146
142
type == LineBreakType .endOfText ? text.length : index;
147
143
assert (fragmentEnd >= fragmentStart);
148
144
145
+ // Uncomment the following line to help debug line breaking.
146
+ // print('{$fragmentStart:$fragmentEnd} [$debugRuleNumber] -- $type');
147
+
149
148
if (prev1 == LineCharProperty .SP ) {
150
149
trailingSpaces++ ;
151
150
} else if (_isHardBreak (prev1) || prev1 == LineCharProperty .CR ) {
@@ -244,13 +243,6 @@ List<LineBreakFragment> _computeLineBreakFragments(String text) {
244
243
break ;
245
244
}
246
245
247
- // Establish the base for the space sequence.
248
- if (prev1 != LineCharProperty .SP ) {
249
- // When the text/line starts with SP, we should treat the beginning of text/line
250
- // as if it were a WJ (word joiner).
251
- baseOfSpaceSequence = prev1 ?? LineCharProperty .WJ ;
252
- }
253
-
254
246
// Do not break before spaces or zero width space.
255
247
// LB7: × SP
256
248
// × ZW
@@ -259,11 +251,17 @@ List<LineBreakFragment> _computeLineBreakFragments(String text) {
259
251
continue ;
260
252
}
261
253
254
+ // Break after spaces.
255
+ // LB18: SP ÷
256
+ if (prev1 == LineCharProperty .SP ) {
257
+ setBreak (LineBreakType .opportunity, 18 );
258
+ continue ;
259
+ }
260
+
262
261
// Break before any character following a zero-width space, even if one or
263
262
// more spaces intervene.
264
263
// LB8: ZW SP* ÷
265
- if (prev1 == LineCharProperty .ZW ||
266
- baseOfSpaceSequence == LineCharProperty .ZW ) {
264
+ if (prev1 == LineCharProperty .ZW ) {
267
265
setBreak (LineBreakType .opportunity, 8 );
268
266
continue ;
269
267
}
@@ -343,6 +341,8 @@ List<LineBreakFragment> _computeLineBreakFragments(String text) {
343
341
// The above is a quote from unicode.org. In our implementation, we did the
344
342
// following modification: When there are spaces present, we consider it a
345
343
// line break opportunity.
344
+ //
345
+ // We made this modification to match the browser behavior.
346
346
if (prev1 != LineCharProperty .SP &&
347
347
(curr == LineCharProperty .CL ||
348
348
curr == LineCharProperty .CP ||
@@ -358,6 +358,8 @@ List<LineBreakFragment> _computeLineBreakFragments(String text) {
358
358
//
359
359
// The above is a quote from unicode.org. In our implementation, we did the
360
360
// following modification: Allow breaks when there are spaces.
361
+ //
362
+ // We made this modification to match the browser behavior.
361
363
if (prev1 == LineCharProperty .OP ) {
362
364
setBreak (LineBreakType .prohibited, 14 );
363
365
continue ;
@@ -368,6 +370,8 @@ List<LineBreakFragment> _computeLineBreakFragments(String text) {
368
370
//
369
371
// The above is a quote from unicode.org. In our implementation, we did the
370
372
// following modification: Allow breaks when there are spaces.
373
+ //
374
+ // We made this modification to match the browser behavior.
371
375
if (prev1 == LineCharProperty .QU && curr == LineCharProperty .OP ) {
372
376
setBreak (LineBreakType .prohibited, 15 );
373
377
continue ;
@@ -376,31 +380,29 @@ List<LineBreakFragment> _computeLineBreakFragments(String text) {
376
380
// Do not break between closing punctuation and a nonstarter, even with
377
381
// intervening spaces.
378
382
// LB16: (CL | CP) SP* × NS
379
- if ((prev1 == LineCharProperty .CL ||
380
- baseOfSpaceSequence == LineCharProperty .CL ||
381
- prev1 == LineCharProperty .CP ||
382
- baseOfSpaceSequence == LineCharProperty .CP ) &&
383
+ //
384
+ // The above is a quote from unicode.org. In our implementation, we did the
385
+ // following modification: Allow breaks when there are spaces.
386
+ //
387
+ // We made this modification to match the browser behavior.
388
+ if ((prev1 == LineCharProperty .CL || prev1 == LineCharProperty .CP ) &&
383
389
curr == LineCharProperty .NS ) {
384
390
setBreak (LineBreakType .prohibited, 16 );
385
391
continue ;
386
392
}
387
393
388
394
// Do not break within ‘——’, even with intervening spaces.
389
395
// LB17: B2 SP* × B2
390
- if ((prev1 == LineCharProperty .B2 ||
391
- baseOfSpaceSequence == LineCharProperty .B2 ) &&
392
- curr == LineCharProperty .B2 ) {
396
+ //
397
+ // The above is a quote from unicode.org. In our implementation, we did the
398
+ // following modification: Allow breaks when there are spaces.
399
+ //
400
+ // We made this modification to match the browser behavior.
401
+ if (prev1 == LineCharProperty .B2 && curr == LineCharProperty .B2 ) {
393
402
setBreak (LineBreakType .prohibited, 17 );
394
403
continue ;
395
404
}
396
405
397
- // Break after spaces.
398
- // LB18: SP ÷
399
- if (prev1 == LineCharProperty .SP ) {
400
- setBreak (LineBreakType .opportunity, 18 );
401
- continue ;
402
- }
403
-
404
406
// Do not break before or after quotation marks, such as ‘”’.
405
407
// LB19: × QU
406
408
// QU ×
0 commit comments