Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutTableSectionTest.cpp

Issue 2783953002: Fix spanning cell painting background from wrong row (Closed)
Patch Set: Remove non-const version and use faster implementation Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/LayoutTableSection.h" 5 #include "core/layout/LayoutTableSection.h"
6 6
7 #include "core/layout/LayoutTableCell.h"
7 #include "core/layout/LayoutTestHelper.h" 8 #include "core/layout/LayoutTestHelper.h"
8 9
9 namespace blink { 10 namespace blink {
10 11
11 namespace { 12 namespace {
12 13
13 using LayoutTableSectionTest = RenderingTest; 14 using LayoutTableSectionTest = RenderingTest;
14 15
15 TEST_F(LayoutTableSectionTest, 16 TEST_F(LayoutTableSectionTest,
16 BackgroundIsKnownToBeOpaqueWithLayerAndCollapsedBorder) { 17 BackgroundIsKnownToBeOpaqueWithLayerAndCollapsedBorder) {
17 setBodyInnerHTML( 18 setBodyInnerHTML(
18 "<table style='border-collapse: collapse'>" 19 "<table style='border-collapse: collapse'>"
19 " <thead id='section' style='will-change: transform; background-color: " 20 " <thead id='section' style='will-change: transform;"
20 "blue'>" 21 " background-color: blue'>"
21 " <tr><td>Cell</td></tr>" 22 " <tr><td>Cell</td></tr>"
22 " </thead>" 23 " </thead>"
23 "</table>"); 24 "</table>");
24 25
25 LayoutTableSection* section = 26 LayoutTableSection* section =
26 toLayoutTableSection(getLayoutObjectByElementId("section")); 27 toLayoutTableSection(getLayoutObjectByElementId("section"));
27 EXPECT_TRUE(section); 28 EXPECT_TRUE(section);
28 EXPECT_FALSE( 29 EXPECT_FALSE(
29 section->backgroundIsKnownToBeOpaqueInRect(LayoutRect(0, 0, 1, 1))); 30 section->backgroundIsKnownToBeOpaqueInRect(LayoutRect(0, 0, 1, 1)));
30 } 31 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 toLayoutTableSection(getLayoutObjectByElementId("section")); 85 toLayoutTableSection(getLayoutObjectByElementId("section"));
85 EXPECT_TRUE(section); 86 EXPECT_TRUE(section);
86 CellSpan cellSpan = 87 CellSpan cellSpan =
87 section->dirtiedEffectiveColumns(LayoutRect(50, 50, 100, 100)); 88 section->dirtiedEffectiveColumns(LayoutRect(50, 50, 100, 100));
88 // The table has at least 1 column even if there is no cell. 89 // The table has at least 1 column even if there is no cell.
89 EXPECT_EQ(1u, section->table()->numEffectiveColumns()); 90 EXPECT_EQ(1u, section->table()->numEffectiveColumns());
90 EXPECT_EQ(1u, cellSpan.start()); 91 EXPECT_EQ(1u, cellSpan.start());
91 EXPECT_EQ(1u, cellSpan.end()); 92 EXPECT_EQ(1u, cellSpan.end());
92 } 93 }
93 94
95 TEST_F(LayoutTableSectionTest, PrimaryCellAtAndOriginatingCellAt) {
96 setBodyInnerHTML(
97 "<table>"
98 " <tbody id='section'>"
99 " <tr>"
100 " <td id='cell00'></td>"
101 " <td id='cell01' rowspan='2'></td>"
102 " </tr>"
103 " <tr>"
104 " <td id='cell10' colspan='2'></td>"
105 " </tr>"
106 " </tbody>"
107 "</table>");
108
109 // x,yO: A cell originates from this grid slot.
110 // x,yS: A cell originating from x,y spans into this slot.
111 // 0 1
112 // 0 0,0(O) 0,1(O)
113 // 1 1,0(O) 1,0/0,1(S)
114 auto* section = toLayoutTableSection(getLayoutObjectByElementId("section"));
115 auto* cell00 = getLayoutObjectByElementId("cell00");
116 auto* cell01 = getLayoutObjectByElementId("cell01");
117 auto* cell10 = getLayoutObjectByElementId("cell10");
118
119 EXPECT_EQ(cell00, section->primaryCellAt(0, 0));
120 EXPECT_EQ(cell01, section->primaryCellAt(0, 1));
121 EXPECT_EQ(cell10, section->primaryCellAt(1, 0));
122 EXPECT_EQ(cell10, section->primaryCellAt(1, 1));
123 EXPECT_EQ(cell00, section->originatingCellAt(0, 0));
124 EXPECT_EQ(cell01, section->originatingCellAt(0, 1));
125 EXPECT_EQ(cell10, section->originatingCellAt(1, 0));
126 EXPECT_EQ(nullptr, section->originatingCellAt(1, 1));
127 }
128
129 TEST_F(LayoutTableSectionTest, DirtiedRowsAndDirtiedEffectiveColumnsWithSpans) {
130 setBodyInnerHTML(
131 "<style>"
132 " td { width: 100px; height: 100px; padding: 0 }"
133 " table { border-spacing: 0 }"
134 "</style>"
135 "<table>"
136 " <tbody id='section'>"
137 " <tr>"
138 " <td></td>"
139 " <td rowspan='2'></td>"
140 " <td rowspan='2'></td>"
141 " </tr>"
142 " <tr>"
143 " <td colspan='2'></td>"
144 " </tr>"
145 " <tr>"
146 " <td colspan='3'></td>"
147 " </tr>"
148 " </tbody>"
149 "</table>");
150
151 // x,yO: A cell originates from this grid slot.
152 // x,yS: A cell originating from x,y spans into this slot.
153 // 0 1 2
154 // 0 0,0(O) 0,1(O) 0,2(O)
155 // 1 1,0(O) 1,0/0,1(S) 0,2(S)
156 // 2 2,0(O) 2,0(S) 2,0(S)
157 auto* section = toLayoutTableSection(getLayoutObjectByElementId("section"));
158
159 // Cell 0,0 only.
160 auto span = section->dirtiedRows(LayoutRect(5, 5, 90, 90));
161 EXPECT_EQ(0u, span.start());
162 EXPECT_EQ(1u, span.end());
163 span = section->dirtiedEffectiveColumns(LayoutRect(5, 5, 90, 90));
164 EXPECT_EQ(0u, span.start());
165 EXPECT_EQ(1u, span.end());
166
167 // Rect intersects the first row and all originating primary cells.
168 span = section->dirtiedRows(LayoutRect(5, 5, 290, 90));
169 EXPECT_EQ(0u, span.start());
170 EXPECT_EQ(1u, span.end());
171 span = section->dirtiedEffectiveColumns(LayoutRect(5, 5, 290, 90));
172 EXPECT_EQ(0u, span.start());
173 EXPECT_EQ(3u, span.end());
174
175 // Rect intersects (1,2). Dirtied rows also cover the first row to cover the
176 // primary cell's originating slot.
177 span = section->dirtiedRows(LayoutRect(205, 105, 90, 90));
178 EXPECT_EQ(0u, span.start());
179 EXPECT_EQ(2u, span.end());
180 span = section->dirtiedEffectiveColumns(LayoutRect(205, 105, 90, 90));
181 EXPECT_EQ(2u, span.start());
182 EXPECT_EQ(3u, span.end());
183
184 // Rect intersects (1,1) which has multiple levels of cells (originating from
185 // (1,0) and (0,1), in which (1,0) is the primary cell).
186 // Dirtied columns also cover the first column to cover the primary cell's
187 // originating grid slot.
188 span = section->dirtiedRows(LayoutRect(105, 105, 90, 90));
189 EXPECT_EQ(1u, span.start());
190 EXPECT_EQ(2u, span.end());
191 span = section->dirtiedEffectiveColumns(LayoutRect(105, 105, 90, 90));
192 EXPECT_EQ(0u, span.start());
193 EXPECT_EQ(2u, span.end());
194
195 // Rect intersects (1,1) and (1,2). Dirtied rows also cover the first row.
196 // Dirtied columns also cover the first column.
197 span = section->dirtiedRows(LayoutRect(105, 105, 190, 90));
198 EXPECT_EQ(0u, span.start());
199 EXPECT_EQ(2u, span.end());
200 span = section->dirtiedEffectiveColumns(LayoutRect(105, 105, 190, 90));
201 EXPECT_EQ(0u, span.start());
202 EXPECT_EQ(3u, span.end());
203
204 // Rect intersects (1,2) and (2,2). Dirtied rows and dirtied columns cover all
205 // rows and columns.
206 span = section->dirtiedRows(LayoutRect(205, 105, 90, 190));
207 EXPECT_EQ(0u, span.start());
208 EXPECT_EQ(3u, span.end());
209 span = section->dirtiedEffectiveColumns(LayoutRect(205, 105, 90, 190));
210 EXPECT_EQ(0u, span.start());
211 EXPECT_EQ(3u, span.end());
212 }
213
94 } // anonymous namespace 214 } // anonymous namespace
95 215
96 } // namespace blink 216 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698