Commit 61abc770 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[LayoutNG] Fix line width when trailing space at block end has kerning

ShapingLineBreaker handles trailing spaces at the end of
wrapped lines. But when the line ends with hard break or at
the end of a block, NGLineBreaker needs to remove the
trailing spaces.

When the trailing space is not safe-to-break; e.g., the font
has kerning pairs between the last non-space character and
the trailing spaces, this patch ensures that the line width
is correct by reshaping the end.

Not doing so caused min-content and max-content differ when
there are no break opportunities, because trailing spaces for
min-content is handled by ShapingLineBreaker while for max-
content is handled by NGLineBreaker.

Bug: 636993
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: If8c810b7e4cfccfd7a35f6dd48d15ce67b98c036
Reviewed-on: https://chromium-review.googlesource.com/1111749
Commit-Queue: Emil A Eklund <eae@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570061}
parent ab67f37a
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x178
LayoutNGBlockFlow {HTML} at (0,0) size 800x178
LayoutNGBlockFlow {BODY} at (8,16) size 784x146
LayoutNGBlockFlow {P} at (0,0) size 784x20
LayoutText {#text} at (0,0) size 448x19
text run at (0,0) width 448: "The three boxes below should have progressively thinner right borders."
LayoutNGBlockFlow {P} at (0,36) size 784x26 [border: (3px solid #000000) (5px solid #000000) (3px solid #000000)]
LayoutText {#text} at (3,3) size 11x19
text run at (3,3) width 11: "A"
LayoutNGBlockFlow {P} at (0,78) size 784x26 [border: (3px solid #000000)]
LayoutText {#text} at (3,3) size 11x19
text run at (3,3) width 11: "B"
LayoutNGBlockFlow {P} at (0,120) size 784x26 [border: (3px solid #000000) (1px solid #000000) (3px solid #000000)]
LayoutText {#text} at (3,3) size 11x19
text run at (3,3) width 11: "C"
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x178
LayoutNGBlockFlow {HTML} at (0,0) size 800x178
LayoutNGBlockFlow {BODY} at (8,16) size 784x146
LayoutNGBlockFlow {P} at (0,0) size 784x20
LayoutText {#text} at (0,0) size 439x19
text run at (0,0) width 439: "The three boxes below should have progressively thinner left borders."
LayoutNGBlockFlow {P} at (0,36) size 784x26 [border: (3px solid #000000) (5px solid #000000)]
LayoutText {#text} at (5,3) size 11x19
text run at (5,3) width 11: "A"
LayoutNGBlockFlow {P} at (0,78) size 784x26 [border: (3px solid #000000)]
LayoutText {#text} at (3,3) size 11x19
text run at (3,3) width 11: "B"
LayoutNGBlockFlow {P} at (0,120) size 784x26 [border: (3px solid #000000) (1px solid #000000)]
LayoutText {#text} at (1,3) size 11x19
text run at (1,3) width 11: "C"
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x178
LayoutNGBlockFlow {HTML} at (0,0) size 800x178
LayoutNGBlockFlow {BODY} at (8,16) size 784x146
LayoutNGBlockFlow {P} at (0,0) size 784x20
LayoutText {#text} at (0,0) size 415x19
text run at (0,0) width 415: "The three boxes below should have progressively thinner borders."
LayoutNGBlockFlow {P} at (0,36) size 784x30 [border: (5px solid #000000)]
LayoutText {#text} at (5,5) size 11x19
text run at (5,5) width 11: "A"
LayoutNGBlockFlow {P} at (0,82) size 784x26 [border: (3px solid #000000)]
LayoutText {#text} at (3,3) size 11x19
text run at (3,3) width 11: "B"
LayoutNGBlockFlow {P} at (0,124) size 784x22 [border: (1px solid #000000)]
LayoutText {#text} at (1,1) size 11x19
text run at (1,1) width 11: "C"
...@@ -29,5 +29,5 @@ layer at (0,0) size 800x288 ...@@ -29,5 +29,5 @@ layer at (0,0) size 800x288
text run at (0,200) width 588: "FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL" text run at (0,200) width 588: "FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL"
text run at (0,220) width 588: "FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL" text run at (0,220) width 588: "FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL"
text run at (0,240) width 588: "FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL" text run at (0,240) width 588: "FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL"
text run at (0,260) width 148: "FAIL FAIL FAIL FAIL" text run at (0,260) width 149: "FAIL FAIL FAIL FAIL"
LayoutText {#text} at (0,0) size 0x0 LayoutText {#text} at (0,0) size 0x0
...@@ -79,5 +79,5 @@ layer at (0,0) size 800x100 ...@@ -79,5 +79,5 @@ layer at (0,0) size 800x100
text run at (155,0) width 9: "L" text run at (155,0) width 9: "L"
LayoutText {#text} at (0,0) size 0x0 LayoutText {#text} at (0,0) size 0x0
LayoutNGBlockFlow {DIV} at (0,56) size 784x20 LayoutNGBlockFlow {DIV} at (0,56) size 784x20
LayoutText {#text} at (0,0) size 164x19 LayoutText {#text} at (0,0) size 165x19
text run at (0,0) width 164: "A B C D E F G H I J K L" text run at (0,0) width 165: "A B C D E F G H I J K L"
...@@ -79,5 +79,5 @@ layer at (0,0) size 800x100 ...@@ -79,5 +79,5 @@ layer at (0,0) size 800x100
text run at (155,0) width 9: "L" text run at (155,0) width 9: "L"
LayoutText {#text} at (0,0) size 0x0 LayoutText {#text} at (0,0) size 0x0
LayoutNGBlockFlow {DIV} at (0,56) size 784x20 LayoutNGBlockFlow {DIV} at (0,56) size 784x20
LayoutText {#text} at (0,0) size 164x19 LayoutText {#text} at (0,0) size 165x19
text run at (0,0) width 164: "A B C D E F G H I J K L" text run at (0,0) width 165: "A B C D E F G H I J K L"
...@@ -79,5 +79,5 @@ layer at (0,0) size 800x100 ...@@ -79,5 +79,5 @@ layer at (0,0) size 800x100
text run at (320,0) width 25: "A.L" text run at (320,0) width 25: "A.L"
LayoutText {#text} at (0,0) size 0x0 LayoutText {#text} at (0,0) size 0x0
LayoutNGBlockFlow {DIV} at (0,56) size 784x20 LayoutNGBlockFlow {DIV} at (0,56) size 784x20
LayoutText {#text} at (0,0) size 345x19 LayoutText {#text} at (0,0) size 346x19
text run at (0,0) width 345: "A.A A.B A.C A.D A.E A.F A.G A.H A.I A.J A.K A.L" text run at (0,0) width 346: "A.A A.B A.C A.D A.E A.F A.G A.H A.I A.J A.K A.L"
...@@ -79,5 +79,5 @@ layer at (0,0) size 800x100 ...@@ -79,5 +79,5 @@ layer at (0,0) size 800x100
text run at (320,0) width 25: "A.L" text run at (320,0) width 25: "A.L"
LayoutText {#text} at (0,0) size 0x0 LayoutText {#text} at (0,0) size 0x0
LayoutNGBlockFlow {DIV} at (0,56) size 784x20 LayoutNGBlockFlow {DIV} at (0,56) size 784x20
LayoutText {#text} at (0,0) size 345x19 LayoutText {#text} at (0,0) size 346x19
text run at (0,0) width 345: "A.A A.B A.C A.D A.E A.F A.G A.H A.I A.J A.K A.L" text run at (0,0) width 346: "A.A A.B A.C A.D A.E A.F A.G A.H A.I A.J A.K A.L"
...@@ -4,8 +4,8 @@ layer at (0,0) size 800x600 ...@@ -4,8 +4,8 @@ layer at (0,0) size 800x600
LayoutNGBlockFlow {HTML} at (0,0) size 800x600 LayoutNGBlockFlow {HTML} at (0,0) size 800x600
LayoutNGBlockFlow {BODY} at (8,8) size 784x568 LayoutNGBlockFlow {BODY} at (8,8) size 784x568
LayoutNGBlockFlow {H1} at (0,0) size 784x57 LayoutNGBlockFlow {H1} at (0,0) size 784x57
LayoutText {#text} at (0,1) size 772x55 LayoutText {#text} at (0,1) size 773x55
text run at (0,1) width 772: "Inheritance bug for floated first-letter" text run at (0,1) width 773: "Inheritance bug for floated first-letter"
LayoutNGBlockFlow {P} at (0,89.16) size 784x172 [bgcolor=#EEEEEE] [border: (1px solid #000000)] LayoutNGBlockFlow {P} at (0,89.16) size 784x172 [bgcolor=#EEEEEE] [border: (1px solid #000000)]
LayoutInline {<pseudo:first-letter>} at (0,0) size 54x86 [color=#008000] [border: (1px dashed #008000)] LayoutInline {<pseudo:first-letter>} at (0,0) size 54x86 [color=#008000] [border: (1px dashed #008000)]
LayoutTextFragment (anonymous) at (2,2) size 52x84 LayoutTextFragment (anonymous) at (2,2) size 52x84
......
...@@ -18,14 +18,14 @@ layer at (0,0) size 800x600 ...@@ -18,14 +18,14 @@ layer at (0,0) size 800x600
LayoutText {#text} at (0,0) size 29x19 LayoutText {#text} at (0,0) size 29x19
text run at (0,0) width 29: "DIV" text run at (0,0) width 29: "DIV"
LayoutNGBlockFlow {P} at (11,46) size 747x20 LayoutNGBlockFlow {P} at (11,46) size 747x20
LayoutText {#text} at (0,0) size 8x19 LayoutText {#text} at (0,0) size 9x19
text run at (0,0) width 8: "P" text run at (0,0) width 9: "P"
LayoutNGBlockFlow {DIV} at (6,66) size 752x20 [color=#FF0000] [bgcolor=#9999FF] LayoutNGBlockFlow {DIV} at (6,66) size 752x20 [color=#FF0000] [bgcolor=#9999FF]
LayoutText {#text} at (0,0) size 131x19 LayoutText {#text} at (0,0) size 131x19
text run at (0,0) width 131: "DIV red text blue bg" text run at (0,0) width 131: "DIV red text blue bg"
LayoutNGBlockFlow {P} at (11,86) size 747x20 LayoutNGBlockFlow {P} at (11,86) size 747x20
LayoutText {#text} at (0,0) size 8x19 LayoutText {#text} at (0,0) size 9x19
text run at (0,0) width 8: "P" text run at (0,0) width 9: "P"
LayoutNGBlockFlow {DIV} at (6,106) size 752x20 LayoutNGBlockFlow {DIV} at (6,106) size 752x20
LayoutText {#text} at (0,0) size 29x19 LayoutText {#text} at (0,0) size 29x19
text run at (0,0) width 29: "DIV" text run at (0,0) width 29: "DIV"
...@@ -36,14 +36,14 @@ layer at (0,0) size 800x600 ...@@ -36,14 +36,14 @@ layer at (0,0) size 800x600
LayoutText {#text} at (0,0) size 29x19 LayoutText {#text} at (0,0) size 29x19
text run at (0,0) width 29: "DIV" text run at (0,0) width 29: "DIV"
LayoutNGBlockFlow {P} at (11,166) size 747x20 LayoutNGBlockFlow {P} at (11,166) size 747x20
LayoutText {#text} at (0,0) size 8x19 LayoutText {#text} at (0,0) size 9x19
text run at (0,0) width 8: "P" text run at (0,0) width 9: "P"
LayoutNGBlockFlow {DIV} at (6,186) size 752x20 [color=#FF0000] LayoutNGBlockFlow {DIV} at (6,186) size 752x20 [color=#FF0000]
LayoutText {#text} at (0,0) size 80x19 LayoutText {#text} at (0,0) size 80x19
text run at (0,0) width 80: "DIV red text" text run at (0,0) width 80: "DIV red text"
LayoutNGBlockFlow {P} at (11,206) size 747x20 LayoutNGBlockFlow {P} at (11,206) size 747x20
LayoutText {#text} at (0,0) size 8x19 LayoutText {#text} at (0,0) size 9x19
text run at (0,0) width 8: "P" text run at (0,0) width 9: "P"
LayoutNGBlockFlow {DIV} at (10,314) size 764x252 [border: (1px solid #000000)] LayoutNGBlockFlow {DIV} at (10,314) size 764x252 [border: (1px solid #000000)]
LayoutText {#text} at (6,6) size 261x19 LayoutText {#text} at (6,6) size 261x19
text run at (6,6) width 261: "child 0: PASS: found color rgb(255, 0, 0)" text run at (6,6) width 261: "child 0: PASS: found color rgb(255, 0, 0)"
......
...@@ -7,5 +7,5 @@ layer at (0,0) size 800x600 ...@@ -7,5 +7,5 @@ layer at (0,0) size 800x600
LayoutImage {IMG} at (0,0) size 300x300 LayoutImage {IMG} at (0,0) size 300x300
LayoutText {#text} at (300,285) size 4x19 LayoutText {#text} at (300,285) size 4x19
text run at (300,285) width 4: " " text run at (300,285) width 4: " "
LayoutText {#text} at (304,285) size 442x19 LayoutText {#text} at (304,285) size 443x19
text run at (304,285) width 442: "The element at position (100, 100) should be the body. Result: BODY" text run at (304,285) width 443: "The element at position (100, 100) should be the body. Result: BODY"
...@@ -7,8 +7,8 @@ layer at (0,0) size 1600x356 ...@@ -7,8 +7,8 @@ layer at (0,0) size 1600x356
LayoutText {#text} at (0,0) size 58x36 LayoutText {#text} at (0,0) size 58x36
text run at (0,0) width 58: "LTR" text run at (0,0) width 58: "LTR"
LayoutNGBlockFlow (anonymous) at (0,81) size 1568x37 LayoutNGBlockFlow (anonymous) at (0,81) size 1568x37
LayoutText {#text} at (0,0) size 58x36 LayoutText {#text} at (0,0) size 59x36
text run at (0,0) width 58: "RTL" text run at (0,0) width 59: "RTL"
LayoutNGBlockFlow (anonymous) at (0,162) size 1568x37 LayoutNGBlockFlow (anonymous) at (0,162) size 1568x37
LayoutText {#text} at (0,0) size 367x36 LayoutText {#text} at (0,0) size 367x36
text run at (0,0) width 367: "LTR (text-overflow:ellipses)" text run at (0,0) width 367: "LTR (text-overflow:ellipses)"
......
...@@ -7,8 +7,8 @@ layer at (0,0) size 1600x356 ...@@ -7,8 +7,8 @@ layer at (0,0) size 1600x356
LayoutText {#text} at (0,0) size 58x36 LayoutText {#text} at (0,0) size 58x36
text run at (0,0) width 58: "LTR" text run at (0,0) width 58: "LTR"
LayoutNGBlockFlow (anonymous) at (0,81) size 1568x37 LayoutNGBlockFlow (anonymous) at (0,81) size 1568x37
LayoutText {#text} at (0,0) size 58x36 LayoutText {#text} at (0,0) size 59x36
text run at (0,0) width 58: "RTL" text run at (0,0) width 59: "RTL"
LayoutNGBlockFlow (anonymous) at (0,162) size 1568x37 LayoutNGBlockFlow (anonymous) at (0,162) size 1568x37
LayoutText {#text} at (0,0) size 367x36 LayoutText {#text} at (0,0) size 367x36
text run at (0,0) width 367: "LTR (text-overflow:ellipses)" text run at (0,0) width 367: "LTR (text-overflow:ellipses)"
......
...@@ -7,8 +7,8 @@ layer at (0,0) size 800x184 ...@@ -7,8 +7,8 @@ layer at (0,0) size 800x184
LayoutText {#text} at (0,0) size 30x19 LayoutText {#text} at (0,0) size 30x19
text run at (0,0) width 30: "LTR" text run at (0,0) width 30: "LTR"
LayoutNGBlockFlow (anonymous) at (0,42) size 784x20 LayoutNGBlockFlow (anonymous) at (0,42) size 784x20
LayoutText {#text} at (0,0) size 29x19 LayoutText {#text} at (0,0) size 30x19
text run at (0,0) width 29: "RTL" text run at (0,0) width 30: "RTL"
LayoutNGBlockFlow (anonymous) at (0,84) size 784x20 LayoutNGBlockFlow (anonymous) at (0,84) size 784x20
LayoutText {#text} at (0,0) size 183x19 LayoutText {#text} at (0,0) size 183x19
text run at (0,0) width 183: "LTR (text-overflow:ellipses):" text run at (0,0) width 183: "LTR (text-overflow:ellipses):"
......
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x465
LayoutNGBlockFlow {html} at (0,0) size 800x465
LayoutNGBlockFlow {body} at (8,16) size 784x441
LayoutNGBlockFlow {p} at (0,0) size 784x20 [color=#000080]
LayoutText {#text} at (0,0) size 405x19
text run at (0,0) width 405: "There should be a blue circle with the word \"TEST\" in it below."
LayoutNGBlockFlow (anonymous) at (0,36) size 784x405
LayoutSVGRoot {svg} at (0,0) size 400x400
LayoutSVGRect {rect} at (0,0) size 400x400 [fill={[type=SOLID] [color=#0000FF]}] [x=0.00] [y=0.00] [width=400.00] [height=400.00]
LayoutSVGEllipse {circle} at (0,0) size 400x400 [fill={[type=SOLID] [color=#000080]}] [cx=200.00] [cy=200.00] [r=200.00]
LayoutSVGForeignObject {foreignObject} at (0,175) size 400x50 [color=#FFFFFF]
LayoutNGBlockFlow {div} at (0,0) size 400x59
LayoutText {#text} at (140,1) size 120x57
text run at (140,1) width 120: "TEST"
LayoutText {#text} at (0,0) size 0x0
layer at (8,227) size 400x50 scrollHeight 59
LayoutSVGForeignObject {foreignObject} at (0,175) size 400x50 [color=#FFFFFF]
LayoutNGBlockFlow {div} at (0,0) size 400x59
LayoutText {#text} at (140,1) size 120x57
text run at (140,1) width 120: "TEST"
layer at (0,0) size 800x600 clip at (0,0) size 785x600 scrollHeight 668
LayoutView at (0,0) size 800x600
layer at (0,0) size 785x668 backgroundClip at (0,0) size 785x600 clip at (0,0) size 785x600
LayoutNGBlockFlow {html} at (0,0) size 785x667.58
LayoutNGBlockFlow {body} at (11.52,23.03) size 761.97x633.03
LayoutNGBlockFlow {p} at (0,0) size 761.97x27 [color=#000080]
LayoutText {#text} at (0,0) size 594x26
text run at (0,0) width 594: "There should be a blue circle with the word \"TEST\" in it below."
LayoutNGBlockFlow (anonymous) at (0,50.03) size 761.97x583
LayoutSVGRoot {svg} at (0,0) size 576x576
LayoutSVGRect {rect} at (0,0) size 400x400 [fill={[type=SOLID] [color=#0000FF]}] [x=0.00] [y=0.00] [width=400.00] [height=400.00]
LayoutSVGEllipse {circle} at (0,0) size 400x400 [fill={[type=SOLID] [color=#000080]}] [cx=200.00] [cy=200.00] [r=200.00]
LayoutSVGForeignObject {foreignObject} at (0,175) size 400x50 [color=#FFFFFF]
LayoutNGBlockFlow {div} at (0,0) size 400x59
LayoutText {#text} at (140,1) size 120x57
text run at (140,1) width 120: "TEST"
LayoutText {#text} at (0,0) size 0x0
layer at (12,248) size 400x50 backgroundClip at (12,325) size 576x72 clip at (0,0) size 0x0 scrollHeight 59
LayoutSVGForeignObject {foreignObject} at (0,175) size 400x50 [color=#FFFFFF]
LayoutNGBlockFlow {div} at (0,0) size 400x59
LayoutText {#text} at (140,1) size 120x57
text run at (140,1) width 120: "TEST"
...@@ -147,7 +147,7 @@ layer at (0,0) size 1046x2264 backgroundClip at (0,0) size 800x600 clip at (0,0) ...@@ -147,7 +147,7 @@ layer at (0,0) size 1046x2264 backgroundClip at (0,0) size 800x600 clip at (0,0)
LayoutTableSection {TFOOT} at (0,2094) size 138x54 LayoutTableSection {TFOOT} at (0,2094) size 138x54
LayoutTableRow {TR} at (0,0) size 138x52 LayoutTableRow {TR} at (0,0) size 138x52
LayoutNGTableCell {TH} at (2,0) size 134x52 [r=0 c=0 rs=1 cs=1] LayoutNGTableCell {TH} at (2,0) size 134x52 [r=0 c=0 rs=1 cs=1]
LayoutSVGRoot {svg} at (6.50,6) size 30x30 LayoutSVGRoot {svg} at (6,6) size 30x30
LayoutSVGEllipse {circle} at (0,0) size 30x30 [fill={[type=SOLID] [color=#FF0000]}] [cx=15.00] [cy=15.00] [r=15.00] LayoutSVGEllipse {circle} at (0,0) size 30x30 [fill={[type=SOLID] [color=#FF0000]}] [cx=15.00] [cy=15.00] [r=15.00]
LayoutText {#text} at (36,8) size 92x35 LayoutText {#text} at (36,8) size 92x35
text run at (36,8) width 92: " Footer" text run at (36,8) width 92: " Footer"
...@@ -148,7 +148,7 @@ layer at (0,0) size 1046x4376 backgroundClip at (0,0) size 800x600 clip at (0,0) ...@@ -148,7 +148,7 @@ layer at (0,0) size 1046x4376 backgroundClip at (0,0) size 800x600 clip at (0,0)
LayoutTableSection {TFOOT} at (0,2206) size 138x54 LayoutTableSection {TFOOT} at (0,2206) size 138x54
LayoutTableRow {TR} at (0,0) size 138x52 LayoutTableRow {TR} at (0,0) size 138x52
LayoutNGTableCell {TH} at (2,0) size 134x52 [r=0 c=0 rs=1 cs=1] LayoutNGTableCell {TH} at (2,0) size 134x52 [r=0 c=0 rs=1 cs=1]
LayoutSVGRoot {svg} at (6.50,6) size 30x30 LayoutSVGRoot {svg} at (6,6) size 30x30
LayoutSVGEllipse {circle} at (0,0) size 30x30 [fill={[type=SOLID] [color=#FF0000]}] [cx=15.00] [cy=15.00] [r=15.00] LayoutSVGEllipse {circle} at (0,0) size 30x30 [fill={[type=SOLID] [color=#FF0000]}] [cx=15.00] [cy=15.00] [r=15.00]
LayoutText {#text} at (36,8) size 92x35 LayoutText {#text} at (36,8) size 92x35
text run at (36,8) width 92: " Footer" text run at (36,8) width 92: " Footer"
......
...@@ -147,7 +147,7 @@ layer at (0,0) size 1046x2264 backgroundClip at (0,0) size 800x600 clip at (0,0) ...@@ -147,7 +147,7 @@ layer at (0,0) size 1046x2264 backgroundClip at (0,0) size 800x600 clip at (0,0)
LayoutTableSection {TFOOT} at (0,2094) size 139x54 LayoutTableSection {TFOOT} at (0,2094) size 139x54
LayoutTableRow {TR} at (0,0) size 139x52 LayoutTableRow {TR} at (0,0) size 139x52
LayoutNGTableCell {TH} at (2,0) size 135x52 [r=0 c=0 rs=1 cs=1] LayoutNGTableCell {TH} at (2,0) size 135x52 [r=0 c=0 rs=1 cs=1]
LayoutSVGRoot {svg} at (6.53,6) size 30x30 LayoutSVGRoot {svg} at (6.27,6) size 30x30
LayoutSVGEllipse {circle} at (0,0) size 30x30 [fill={[type=SOLID] [color=#FF0000]}] [cx=15.00] [cy=15.00] [r=15.00] LayoutSVGEllipse {circle} at (0,0) size 30x30 [fill={[type=SOLID] [color=#FF0000]}] [cx=15.00] [cy=15.00] [r=15.00]
LayoutText {#text} at (36,8) size 93x36 LayoutText {#text} at (36,8) size 93x36
text run at (36,8) width 93: " Footer" text run at (36,8) width 93: " Footer"
...@@ -148,7 +148,7 @@ layer at (0,0) size 1046x4376 backgroundClip at (0,0) size 800x600 clip at (0,0) ...@@ -148,7 +148,7 @@ layer at (0,0) size 1046x4376 backgroundClip at (0,0) size 800x600 clip at (0,0)
LayoutTableSection {TFOOT} at (0,2206) size 139x54 LayoutTableSection {TFOOT} at (0,2206) size 139x54
LayoutTableRow {TR} at (0,0) size 139x52 LayoutTableRow {TR} at (0,0) size 139x52
LayoutNGTableCell {TH} at (2,0) size 135x52 [r=0 c=0 rs=1 cs=1] LayoutNGTableCell {TH} at (2,0) size 135x52 [r=0 c=0 rs=1 cs=1]
LayoutSVGRoot {svg} at (6.53,6) size 30x30 LayoutSVGRoot {svg} at (6.27,6) size 30x30
LayoutSVGEllipse {circle} at (0,0) size 30x30 [fill={[type=SOLID] [color=#FF0000]}] [cx=15.00] [cy=15.00] [r=15.00] LayoutSVGEllipse {circle} at (0,0) size 30x30 [fill={[type=SOLID] [color=#FF0000]}] [cx=15.00] [cy=15.00] [r=15.00]
LayoutText {#text} at (36,8) size 93x36 LayoutText {#text} at (36,8) size 93x36
text run at (36,8) width 93: " Footer" text run at (36,8) width 93: " Footer"
......
...@@ -147,7 +147,7 @@ layer at (0,0) size 1046x2264 backgroundClip at (0,0) size 800x600 clip at (0,0) ...@@ -147,7 +147,7 @@ layer at (0,0) size 1046x2264 backgroundClip at (0,0) size 800x600 clip at (0,0)
LayoutTableSection {TFOOT} at (0,2094) size 136x54 LayoutTableSection {TFOOT} at (0,2094) size 136x54
LayoutTableRow {TR} at (0,0) size 136x52 LayoutTableRow {TR} at (0,0) size 136x52
LayoutNGTableCell {TH} at (2,0) size 132x52 [r=0 c=0 rs=1 cs=1] LayoutNGTableCell {TH} at (2,0) size 132x52 [r=0 c=0 rs=1 cs=1]
LayoutSVGRoot {svg} at (5.50,6) size 30x30 LayoutSVGRoot {svg} at (5,6) size 30x30
LayoutSVGEllipse {circle} at (0,0) size 30x30 [fill={[type=SOLID] [color=#FF0000]}] [cx=15.00] [cy=15.00] [r=15.00] LayoutSVGEllipse {circle} at (0,0) size 30x30 [fill={[type=SOLID] [color=#FF0000]}] [cx=15.00] [cy=15.00] [r=15.00]
LayoutText {#text} at (35,8) size 92x35 LayoutText {#text} at (35,8) size 92x35
text run at (35,8) width 92: " Footer" text run at (35,8) width 92: " Footer"
...@@ -148,7 +148,7 @@ layer at (0,0) size 1046x4376 backgroundClip at (0,0) size 800x600 clip at (0,0) ...@@ -148,7 +148,7 @@ layer at (0,0) size 1046x4376 backgroundClip at (0,0) size 800x600 clip at (0,0)
LayoutTableSection {TFOOT} at (0,2206) size 136x54 LayoutTableSection {TFOOT} at (0,2206) size 136x54
LayoutTableRow {TR} at (0,0) size 136x52 LayoutTableRow {TR} at (0,0) size 136x52
LayoutNGTableCell {TH} at (2,0) size 132x52 [r=0 c=0 rs=1 cs=1] LayoutNGTableCell {TH} at (2,0) size 132x52 [r=0 c=0 rs=1 cs=1]
LayoutSVGRoot {svg} at (5.50,6) size 30x30 LayoutSVGRoot {svg} at (5,6) size 30x30
LayoutSVGEllipse {circle} at (0,0) size 30x30 [fill={[type=SOLID] [color=#FF0000]}] [cx=15.00] [cy=15.00] [r=15.00] LayoutSVGEllipse {circle} at (0,0) size 30x30 [fill={[type=SOLID] [color=#FF0000]}] [cx=15.00] [cy=15.00] [r=15.00]
LayoutText {#text} at (35,8) size 92x35 LayoutText {#text} at (35,8) size 92x35
text run at (35,8) width 92: " Footer" text run at (35,8) width 92: " Footer"
......
...@@ -460,6 +460,49 @@ void NGLineBreaker::BreakText(NGInlineItemResult* item_result, ...@@ -460,6 +460,49 @@ void NGLineBreaker::BreakText(NGInlineItemResult* item_result,
} }
} }
// Re-shape the specified range of |NGInlineItem|.
scoped_refptr<ShapeResult> NGLineBreaker::ShapeText(const NGInlineItem& item,
unsigned start,
unsigned end) {
RunSegmenter::RunSegmenterRange segment_range =
item.CreateRunSegmenterRange();
scoped_refptr<ShapeResult> result = shaper_.Shape(
&item.Style()->GetFont(), item.TextShapeResult()->Direction(), start, end,
&segment_range);
if (UNLIKELY(spacing_.HasSpacing()))
result->ApplySpacing(spacing_);
return result;
}
// Truncate the end of |ShapeResult|. The |ShapeResult| is supposed to be at the
// end of the line, and thus this function makes sure the end is safe-to-break.
void NGLineBreaker::TruncateTextEnd(NGInlineItemResult* item_result) {
DCHECK(item_result);
DCHECK(item_result->item);
DCHECK(item_result->shape_result);
const ShapeResult& source_result = *item_result->shape_result;
const unsigned start_offset = item_result->start_offset;
const unsigned end_offset = item_result->end_offset;
scoped_refptr<ShapeResult> new_result;
unsigned last_safe = source_result.PreviousSafeToBreakOffset(end_offset);
DCHECK_LE(last_safe, end_offset);
if (last_safe > start_offset)
new_result = source_result.SubRange(start_offset, last_safe);
if (last_safe < end_offset) {
scoped_refptr<ShapeResult> end_result = ShapeText(
*item_result->item, std::max(last_safe, start_offset), end_offset);
if (new_result)
end_result->CopyRange(0, end_offset, new_result.get());
else
new_result = std::move(end_result);
}
DCHECK(new_result);
item_result->shape_result = std::move(new_result);
item_result->inline_size = item_result->shape_result->SnappedWidth();
}
NGLineBreaker::LineBreakState NGLineBreaker::HandleTrailingSpaces( NGLineBreaker::LineBreakState NGLineBreaker::HandleTrailingSpaces(
const NGInlineItem& item, const NGInlineItem& item,
NGLineInfo* line_info) { NGLineInfo* line_info) {
...@@ -492,9 +535,8 @@ NGLineBreaker::LineBreakState NGLineBreaker::HandleTrailingSpaces( ...@@ -492,9 +535,8 @@ NGLineBreaker::LineBreakState NGLineBreaker::HandleTrailingSpaces(
NGInlineItemResult* item_result = AddItem(item, end, item_results); NGInlineItemResult* item_result = AddItem(item, end, item_results);
item_result->has_only_trailing_spaces = true; item_result->has_only_trailing_spaces = true;
// TODO(kojii): Should reshape if it's not safe to break. item_result->shape_result = item.TextShapeResult();
item_result->shape_result = item.TextShapeResult()->SubRange(offset_, end); TruncateTextEnd(item_result);
item_result->inline_size = item_result->shape_result->SnappedWidth();
line_.position += item_result->inline_size; line_.position += item_result->inline_size;
item_result->can_break_after = item_result->can_break_after =
end < text.length() && !IsBreakableSpace(text[end]); end < text.length() && !IsBreakableSpace(text[end]);
...@@ -538,10 +580,7 @@ void NGLineBreaker::RemoveTrailingCollapsibleSpace(NGLineInfo* line_info) { ...@@ -538,10 +580,7 @@ void NGLineBreaker::RemoveTrailingCollapsibleSpace(NGLineInfo* line_info) {
unsigned index = std::distance(item_results->begin(), &item_result); unsigned index = std::distance(item_results->begin(), &item_result);
item_results->EraseAt(index); item_results->EraseAt(index);
} else { } else {
// TODO(kojii): Should reshape if it's not safe to break. TruncateTextEnd(&item_result);
item_result.shape_result = item_result.shape_result->SubRange(
item_result.start_offset, item_result.end_offset);
item_result.inline_size = item_result.shape_result->SnappedWidth();
line_.position += item_result.inline_size; line_.position += item_result.inline_size;
} }
return; return;
......
...@@ -138,6 +138,10 @@ class CORE_EXPORT NGLineBreaker { ...@@ -138,6 +138,10 @@ class CORE_EXPORT NGLineBreaker {
const NGInlineItem&, const NGInlineItem&,
LayoutUnit available_width, LayoutUnit available_width,
NGLineInfo*); NGLineInfo*);
void TruncateTextEnd(NGInlineItemResult*);
scoped_refptr<ShapeResult> ShapeText(const NGInlineItem& item,
unsigned start,
unsigned end);
LineBreakState HandleTrailingSpaces(const NGInlineItem&, NGLineInfo*); LineBreakState HandleTrailingSpaces(const NGInlineItem&, NGLineInfo*);
void RemoveTrailingCollapsibleSpace(NGLineInfo*); void RemoveTrailingCollapsibleSpace(NGLineInfo*);
void AppendHyphen(const NGInlineItem& item, NGLineInfo*); void AppendHyphen(const NGInlineItem& item, NGLineInfo*);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment