Commit 5fdd4523 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[LayoutNG] Properly reset text metrics for new line in quirks mode

When lines are wrapped, line-height quirks mode requires each
line not to have a strut by default. LayoutNG does this by
resetting |text_metrics|, but it forgot to reset |text_top|
and |text_height|, two derived variables from |text_metrics|.

This results in slightly different geometry for LayoutBR
when the layout was paused and restarted from a break token
(such as reusing unchanged lineboxes or an inline formatting
context was fragmented) from when we layout from top to bottom.

This patch properly resets these values so that the layout
result is consistent in such cases. Also the changes match
better to legacy.

Bug: 636993
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I76cdb57daf68833639fc454862af1e296a89d4cd
Reviewed-on: https://chromium-review.googlesource.com/c/1260743Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596642}
parent 8f77ddb3
......@@ -19,12 +19,12 @@ layer at (0,0) size 800x600
LayoutText {#text} at (0,20) size 221x19
text run at (0,20) width 221: "This sentence should be backward."
LayoutText {#text} at (0,0) size 0x0
LayoutBR {BR} at (221,20) size 0x19
LayoutBR {BR} at (221,35) size 0x0
LayoutInline {BDO} at (0,0) size 209x19
LayoutText {#text} at (0,40) size 209x19
text run at (0,40) width 209: "This sentence should be forward."
LayoutText {#text} at (0,0) size 0x0
LayoutBR {BR} at (209,40) size 0x19
LayoutBR {BR} at (209,55) size 0x0
LayoutInline {BDO} at (0,0) size 0x0
LayoutText {#text} at (0,0) size 0x0
LayoutBR {BR} at (0,60) size 0x19
......@@ -32,7 +32,7 @@ layer at (0,0) size 800x600
LayoutText {#text} at (0,80) size 12x19
text run at (0,80) width 12: "A"
LayoutText {#text} at (0,0) size 0x0
LayoutBR {BR} at (12,80) size 0x19
LayoutBR {BR} at (12,95) size 0x0
LayoutInline {BDO} at (0,0) size 290x19
LayoutText {#text} at (0,100) size 26x19
text run at (0,100) width 26: "My "
......
......@@ -11,13 +11,13 @@ layer at (0,0) size 800x600
LayoutText (anonymous) at (4,1) size 297x16
text run at (4,1) width 297: "This text should be centered vertically in the button"
LayoutText {#text} at (0,0) size 0x0
LayoutBR {BR} at (319,20) size 0x19
LayoutBR {BR} at (319,35) size 0x0
LayoutButton {INPUT} at (0,40) size 313x22 [bgcolor=#C0C0C0] [border: (2px outset #C0C0C0)]
LayoutBlockFlow (anonymous) at (8,3) size 297x16
LayoutText {#text} at (0,0) size 297x16
text run at (0,0) width 297: "This text should be centered vertically in the button"
LayoutText {#text} at (0,0) size 0x0
LayoutBR {BR} at (313,41) size 0x19
LayoutBR {BR} at (313,56) size 0x0
LayoutTextControl {INPUT} at (0,62) size 183x22 [bgcolor=#FFFFFF] [border: (2px inset #EEEEEE)]
LayoutFlexibleBox {DIV} at (3,3) size 177x16
LayoutBlockFlow {DIV} at (0,0) size 164x16
......
......@@ -12,7 +12,7 @@ layer at (0,0) size 800x600
text run at (0,0) width 86: "TEXTAREA"
LayoutBR {BR} at (86,0) size 0x19
LayoutText {#text} at (0,0) size 0x0
LayoutBR {BR} at (400,205) size 0x19
LayoutBR {BR} at (400,220) size 0x0
LayoutBR {BR} at (0,220) size 0x19
layer at (8,64) size 400x200 clip at (9,65) size 398x198
LayoutTextControl {TEXTAREA} at (0,20) size 400x200 [bgcolor=#FFFFFF] [border: (1px dotted #C0C0C0)]
......
......@@ -10,7 +10,7 @@ layer at (0,0) size 800x600
LayoutBlockFlow (anonymous) at (1,1) size 20x18
LayoutText (anonymous) at (4,1) size 22x16
text run at (4,1) width 22: "test"
LayoutBR {BR} at (2,20) size 0x19
LayoutBR {BR} at (2,35) size 0x0
LayoutMenuList {SELECT} at (0,40) size 2x20 [bgcolor=#0000FF] [border: (1px solid #A9A9A9)]
LayoutBlockFlow (anonymous) at (1,1) size 20x18
LayoutText (anonymous) at (4,1) size 22x16
......
......@@ -11,7 +11,7 @@ layer at (0,0) size 800x600
LayoutText (anonymous) at (4,1) size 22x16
text run at (4,1) width 22: "test"
LayoutText {#text} at (0,0) size 0x0
LayoutBR {BR} at (44,20) size 0x19
LayoutBR {BR} at (44,35) size 0x0
LayoutText {#text} at (0,40) size 528x19
text run at (0,40) width 528: "This tests that background color is white by default regardless of the parent element."
LayoutBR {BR} at (528,40) size 0x19
......@@ -23,7 +23,7 @@ layer at (0,0) size 800x600
text run at (4,1) width 22: "test"
LayoutText {#text} at (0,0) size 0x0
LayoutText {#text} at (0,0) size 0x0
LayoutBR {BR} at (54,60) size 0x19
LayoutBR {BR} at (54,75) size 0x0
LayoutText {#text} at (0,80) size 625x19
text run at (0,80) width 625: "This tests that background color is inherited from the parent if background-color:inherit is specified."
LayoutBR {BR} at (625,80) size 0x19
......@@ -35,7 +35,7 @@ layer at (0,0) size 800x600
text run at (4,1) width 22: "test"
LayoutText {#text} at (0,0) size 0x0
LayoutText {#text} at (0,0) size 0x0
LayoutBR {BR} at (54,100) size 0x19
LayoutBR {BR} at (54,115) size 0x0
LayoutText {#text} at (0,120) size 637x19
text run at (0,120) width 637: "This tests that background color is the same as the parent if background-color:transparent is specified."
LayoutBR {BR} at (637,120) size 0x19
......@@ -47,7 +47,7 @@ layer at (0,0) size 800x600
text run at (4,1) width 22: "test"
LayoutText {#text} at (0,0) size 0x0
LayoutText {#text} at (0,0) size 0x0
LayoutBR {BR} at (54,140) size 0x19
LayoutBR {BR} at (54,155) size 0x0
LayoutText {#text} at (0,160) size 498x19
text run at (0,160) width 498: "This tests that background is white if only background-image:none is specified."
LayoutBR {BR} at (498,160) size 0x19
......@@ -56,7 +56,7 @@ layer at (0,0) size 800x600
LayoutText (anonymous) at (4,1) size 22x16
text run at (4,1) width 22: "test"
LayoutText {#text} at (0,0) size 0x0
LayoutBR {BR} at (44,180) size 0x19
LayoutBR {BR} at (44,195) size 0x0
LayoutText {#text} at (0,200) size 418x19
text run at (0,200) width 418: "This tests that the image specified for background-image is visible."
LayoutBR {BR} at (418,200) size 0x19
......
......@@ -8,7 +8,7 @@ layer at (0,0) size 800x600
LayoutBR {BR} at (564,0) size 0x19
LayoutTextControl {INPUT} at (0,20) size 181x22 [bgcolor=#FFC0CB] [border: (2px inset #EEEEEE)]
LayoutText {#text} at (0,0) size 0x0
LayoutBR {BR} at (181,21) size 0x19
LayoutBR {BR} at (181,36) size 0x0
LayoutTextControl {INPUT} at (0,42) size 181x22 [bgcolor=#FFFFFF] [border: (2px inset #EEEEEE)]
LayoutText {#text} at (0,0) size 0x0
layer at (10,31) size 177x16
......
......@@ -7,15 +7,15 @@ layer at (0,0) size 800x600
text run at (0,0) width 344: "This tests that the new text fields use the correct width."
LayoutBR {BR} at (344,0) size 0x19
LayoutTextControl {INPUT} at (0,20) size 181x22 [bgcolor=#FFFFFF] [border: (2px inset #EEEEEE)]
LayoutBR {BR} at (181,21) size 0x19
LayoutBR {BR} at (181,36) size 0x0
LayoutTextControl {INPUT} at (0,42) size 200x22 [bgcolor=#FFFFFF] [border: (2px inset #EEEEEE)]
LayoutBR {BR} at (200,43) size 0x19
LayoutBR {BR} at (200,58) size 0x0
LayoutTextControl {INPUT} at (0,64) size 421x22 [bgcolor=#FFFFFF] [border: (2px inset #EEEEEE)]
LayoutBR {BR} at (421,65) size 0x19
LayoutBR {BR} at (421,80) size 0x0
LayoutTextControl {INPUT} at (0,86) size 200x22 [bgcolor=#FFFFFF] [border: (2px inset #EEEEEE)]
LayoutBR {BR} at (200,87) size 0x19
LayoutBR {BR} at (200,102) size 0x0
LayoutTextControl {INPUT} at (0,108) size 101x22 [bgcolor=#FFFFFF] [border: (2px inset #EEEEEE)]
LayoutBR {BR} at (101,109) size 0x19
LayoutBR {BR} at (101,124) size 0x0
layer at (10,31) size 177x16
LayoutBlockFlow {DIV} at (2,3) size 177x16
layer at (10,53) size 196x16
......
......@@ -8,7 +8,7 @@ layer at (0,0) size 800x600
text run at (0,0) width 502: "This tests that typing in a scrolled textarea does not cause unnecessary scrolling."
LayoutBR {BR} at (502,0) size 0x19
LayoutText {#text} at (0,0) size 0x0
LayoutBR {BR} at (179,121) size 0x19
LayoutBR {BR} at (179,136) size 0x0
LayoutNGBlockFlow {DIV} at (0,136) size 784x0
layer at (8,28) size 179x116 clip at (9,29) size 162x114 scrollY 224.00 scrollHeight 338
LayoutTextControl {TEXTAREA} at (0,20) size 179x116 [bgcolor=#FFFFFF] [border: (1px solid #A9A9A9)]
......
......@@ -9,7 +9,7 @@ layer at (0,0) size 800x600
text run at (0,40) width 564: "have a LayoutBlockFlow and LayoutBlockFlow below it in the dump of the RenderTree."
LayoutBR {BR} at (564,40) size 0x19
LayoutText {#text} at (0,0) size 0x0
LayoutBR {BR} at (788,59) size 0x19
LayoutBR {BR} at (788,74) size 0x0
LayoutBR {BR} at (0,74) size 0x19
LayoutText {#text} at (0,0) size 0x0
layer at (8,68) size 788x14
......
......@@ -9,7 +9,7 @@ layer at (0,0) size 800x600
LayoutNGBlockFlow (anonymous) at (0,36) size 784x168
LayoutBR {BR} at (300,54) size 0x0
LayoutBR {BR} at (0,54) size 0x19
LayoutBR {BR} at (320,113) size 0x19
LayoutBR {BR} at (320,128) size 0x0
LayoutBR {BR} at (0,128) size 0x19
LayoutBR {BR} at (0,148) size 0x19
layer at (8,44) size 300x54
......
......@@ -9,7 +9,7 @@ layer at (0,0) size 800x600
LayoutNGBlockFlow (anonymous) at (0,36) size 784x168
LayoutBR {BR} at (300,54) size 0x0
LayoutBR {BR} at (0,54) size 0x19
LayoutBR {BR} at (320,113) size 0x19
LayoutBR {BR} at (320,128) size 0x0
LayoutBR {BR} at (0,128) size 0x19
LayoutBR {BR} at (0,148) size 0x19
layer at (8,44) size 300x54
......
......@@ -56,6 +56,11 @@ void NGInlineBoxState::ComputeTextMetrics(const ComputedStyle& style,
include_used_fonts = style.LineHeight().IsNegative();
}
void NGInlineBoxState::ResetTextMetrics() {
metrics = text_metrics = NGLineHeightMetrics();
text_top = text_height = LayoutUnit();
}
void NGInlineBoxState::EnsureTextMetrics(const ComputedStyle& style,
FontBaseline baseline_type) {
if (text_metrics.IsEmpty())
......@@ -116,7 +121,7 @@ NGInlineBoxState* NGInlineLayoutStateStack::OnBeginPlaceItems(
if (!line_height_quirk)
box.metrics = box.text_metrics;
else
box.metrics = box.text_metrics = NGLineHeightMetrics();
box.ResetTextMetrics();
if (box.needs_box_fragment) {
// Existing box states are wrapped before they were closed, and hence
// they do not have start edges, unless 'box-decoration-break: clone'.
......
......@@ -84,6 +84,7 @@ struct NGInlineBoxState {
void ComputeTextMetrics(const ComputedStyle& style,
FontBaseline baseline_type);
void EnsureTextMetrics(const ComputedStyle&, FontBaseline);
void ResetTextMetrics();
void AccumulateUsedFonts(const ShapeResult*, FontBaseline);
......
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