OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 EXPECT_FALSE(HasEndBorderAdjoiningTable(cell22)); | 238 EXPECT_FALSE(HasEndBorderAdjoiningTable(cell22)); |
239 EXPECT_TRUE(HasStartBorderAdjoiningTable(cell23)); | 239 EXPECT_TRUE(HasStartBorderAdjoiningTable(cell23)); |
240 EXPECT_FALSE(HasEndBorderAdjoiningTable(cell23)); | 240 EXPECT_FALSE(HasEndBorderAdjoiningTable(cell23)); |
241 | 241 |
242 EXPECT_FALSE(HasStartBorderAdjoiningTable(cell31)); | 242 EXPECT_FALSE(HasStartBorderAdjoiningTable(cell31)); |
243 EXPECT_FALSE(HasEndBorderAdjoiningTable(cell31)); | 243 EXPECT_FALSE(HasEndBorderAdjoiningTable(cell31)); |
244 EXPECT_FALSE(HasStartBorderAdjoiningTable(cell32)); | 244 EXPECT_FALSE(HasStartBorderAdjoiningTable(cell32)); |
245 EXPECT_FALSE(HasEndBorderAdjoiningTable(cell32)); | 245 EXPECT_FALSE(HasEndBorderAdjoiningTable(cell32)); |
246 } | 246 } |
247 | 247 |
| 248 TEST_F(LayoutTableCellTest, EffectiveColumnIndex) { |
| 249 SetBodyInnerHTML( |
| 250 "<table id='table'>" |
| 251 " <tr>" |
| 252 " <td id='cell11' colspan='2000'></td>" |
| 253 " <td id='cell12'></td>" |
| 254 " <td id='cell13'></td>" |
| 255 " </tr>" |
| 256 " <tr>" |
| 257 " <td id='cell21' rowspan='2'></td>" |
| 258 " <td id='cell22'></td>" |
| 259 " <td id='cell23' colspan='2000'></td>" |
| 260 " </tr>" |
| 261 " <tr>" |
| 262 " <td id='cell31'></td>" |
| 263 " <td id='cell32'></td>" |
| 264 " </tr>" |
| 265 "</table>"); |
| 266 |
| 267 // Effective column spans of absolute columns: |
| 268 // 1 1 1 1997 1 1 |
| 269 // +-------------------+---+---+ |
| 270 // | 4 (2000) | 1 | 1 | |
| 271 // |-------+-----------+---+---+ |
| 272 // | | 1 | 4 (2000) | |
| 273 // | 1 |---+---+---------------| |
| 274 // | | 1 | 1 | |
| 275 // +---+---+---+ |
| 276 // Each number not in () is the span of effective columns of the cell. |
| 277 // Each number in () is the span of absolute columns of the cell if it's |
| 278 // different from the span of effective columns. |
| 279 |
| 280 const auto* cell11 = GetCellByElementId("cell11"); |
| 281 EXPECT_EQ(6u, cell11->Table()->NumEffectiveColumns()); |
| 282 EXPECT_EQ(0u, cell11->EffectiveColumnIndex()); |
| 283 EXPECT_EQ(0u, cell11->AbsoluteColumnIndex()); |
| 284 EXPECT_EQ(4u, cell11->EffectiveColumnIndexOfCellAfter()); |
| 285 |
| 286 const auto* cell12 = GetCellByElementId("cell12"); |
| 287 EXPECT_EQ(4u, cell12->EffectiveColumnIndex()); |
| 288 EXPECT_EQ(2000u, cell12->AbsoluteColumnIndex()); |
| 289 EXPECT_EQ(5u, cell12->EffectiveColumnIndexOfCellAfter()); |
| 290 |
| 291 const auto* cell13 = GetCellByElementId("cell13"); |
| 292 EXPECT_EQ(5u, cell13->EffectiveColumnIndex()); |
| 293 EXPECT_EQ(2001u, cell13->AbsoluteColumnIndex()); |
| 294 EXPECT_EQ(6u, cell13->EffectiveColumnIndexOfCellAfter()); |
| 295 |
| 296 const auto* cell21 = GetCellByElementId("cell21"); |
| 297 EXPECT_EQ(0u, cell21->EffectiveColumnIndex()); |
| 298 EXPECT_EQ(0u, cell21->AbsoluteColumnIndex()); |
| 299 EXPECT_EQ(1u, cell21->EffectiveColumnIndexOfCellAfter()); |
| 300 |
| 301 const auto* cell22 = GetCellByElementId("cell22"); |
| 302 EXPECT_EQ(1u, cell22->EffectiveColumnIndex()); |
| 303 EXPECT_EQ(1u, cell22->AbsoluteColumnIndex()); |
| 304 EXPECT_EQ(2u, cell22->EffectiveColumnIndexOfCellAfter()); |
| 305 |
| 306 const auto* cell23 = GetCellByElementId("cell23"); |
| 307 EXPECT_EQ(2u, cell23->EffectiveColumnIndex()); |
| 308 EXPECT_EQ(2u, cell23->AbsoluteColumnIndex()); |
| 309 EXPECT_EQ(6u, cell23->EffectiveColumnIndexOfCellAfter()); |
| 310 |
| 311 const auto* cell31 = GetCellByElementId("cell31"); |
| 312 EXPECT_EQ(1u, cell31->EffectiveColumnIndex()); |
| 313 EXPECT_EQ(1u, cell31->AbsoluteColumnIndex()); |
| 314 EXPECT_EQ(2u, cell31->EffectiveColumnIndexOfCellAfter()); |
| 315 |
| 316 const auto* cell32 = GetCellByElementId("cell32"); |
| 317 EXPECT_EQ(2u, cell32->EffectiveColumnIndex()); |
| 318 EXPECT_EQ(2u, cell32->AbsoluteColumnIndex()); |
| 319 EXPECT_EQ(3u, cell32->EffectiveColumnIndexOfCellAfter()); |
| 320 } |
| 321 |
248 TEST_F(LayoutTableCellTest, LocalVisualRectWithCollapsedBorders) { | 322 TEST_F(LayoutTableCellTest, LocalVisualRectWithCollapsedBorders) { |
249 SetBodyInnerHTML( | 323 SetBodyInnerHTML( |
250 "<style>" | 324 "<style>" |
251 " table { border-collapse: collapse }" | 325 " table { border-collapse: collapse }" |
252 " td { border: 0px solid blue; padding: 0 }" | 326 " td { border: 0px solid blue; padding: 0 }" |
253 " div { width: 100px; height: 100px }" | 327 " div { width: 100px; height: 100px }" |
254 "</style>" | 328 "</style>" |
255 "<table>" | 329 "<table>" |
256 " <tr>" | 330 " <tr>" |
257 " <td id='cell1' style='border-bottom-width: 10px;" | 331 " <td id='cell1' style='border-bottom-width: 10px;" |
(...skipping 24 matching lines...) Expand all Loading... |
282 LayoutRect expected_visual_rect2 = cell2->BorderBoxRect(); | 356 LayoutRect expected_visual_rect2 = cell2->BorderBoxRect(); |
283 // Expand outer half border width at each side. For the bottom side, expand | 357 // Expand outer half border width at each side. For the bottom side, expand |
284 // more because the left border is lengthened to cover the joint with the | 358 // more because the left border is lengthened to cover the joint with the |
285 // bottom border of the cell to the left. | 359 // bottom border of the cell to the left. |
286 expected_visual_rect2.ExpandEdges(LayoutUnit(1), LayoutUnit(8), LayoutUnit(5), | 360 expected_visual_rect2.ExpandEdges(LayoutUnit(1), LayoutUnit(8), LayoutUnit(5), |
287 LayoutUnit(7)); | 361 LayoutUnit(7)); |
288 EXPECT_EQ(expected_visual_rect2, LocalVisualRect(cell2)); | 362 EXPECT_EQ(expected_visual_rect2, LocalVisualRect(cell2)); |
289 } | 363 } |
290 | 364 |
291 } // namespace blink | 365 } // namespace blink |
OLD | NEW |