Chromium Code Reviews| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 #endif | 72 #endif |
| 73 | 73 |
| 74 class LayoutTableCellTest : public RenderingTest { | 74 class LayoutTableCellTest : public RenderingTest { |
| 75 protected: | 75 protected: |
| 76 bool HasStartBorderAdjoiningTable(const LayoutTableCell* cell) { | 76 bool HasStartBorderAdjoiningTable(const LayoutTableCell* cell) { |
| 77 return cell->HasStartBorderAdjoiningTable(); | 77 return cell->HasStartBorderAdjoiningTable(); |
| 78 } | 78 } |
| 79 bool HasEndBorderAdjoiningTable(const LayoutTableCell* cell) { | 79 bool HasEndBorderAdjoiningTable(const LayoutTableCell* cell) { |
| 80 return cell->HasEndBorderAdjoiningTable(); | 80 return cell->HasEndBorderAdjoiningTable(); |
| 81 } | 81 } |
| 82 LayoutRect LocalVisualRect(const LayoutTableCell* cell) { | |
| 83 return cell->LocalVisualRect(); | |
| 84 } | |
| 82 | 85 |
| 83 LayoutTableCell* GetCellByElementId(const char* id) { | 86 LayoutTableCell* GetCellByElementId(const char* id) { |
| 84 return ToLayoutTableCell(GetLayoutObjectByElementId(id)); | 87 return ToLayoutTableCell(GetLayoutObjectByElementId(id)); |
| 85 } | 88 } |
| 86 }; | 89 }; |
| 87 | 90 |
| 88 TEST_F(LayoutTableCellTest, AbsoluteColumnIndex) { | 91 TEST_F(LayoutTableCellTest, AbsoluteColumnIndex) { |
| 89 auto* cell = LayoutTableCell::CreateAnonymous(&GetDocument()); | 92 auto* cell = LayoutTableCell::CreateAnonymous(&GetDocument()); |
| 90 EXPECT_FALSE(cell->HasSetAbsoluteColumnIndex()); | 93 EXPECT_FALSE(cell->HasSetAbsoluteColumnIndex()); |
| 91 cell->SetAbsoluteColumnIndex(kMaxColumnIndex); | 94 cell->SetAbsoluteColumnIndex(kMaxColumnIndex); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 EXPECT_FALSE(HasEndBorderAdjoiningTable(cell22)); | 247 EXPECT_FALSE(HasEndBorderAdjoiningTable(cell22)); |
| 245 EXPECT_TRUE(HasStartBorderAdjoiningTable(cell23)); | 248 EXPECT_TRUE(HasStartBorderAdjoiningTable(cell23)); |
| 246 EXPECT_FALSE(HasEndBorderAdjoiningTable(cell23)); | 249 EXPECT_FALSE(HasEndBorderAdjoiningTable(cell23)); |
| 247 | 250 |
| 248 EXPECT_FALSE(HasStartBorderAdjoiningTable(cell31)); | 251 EXPECT_FALSE(HasStartBorderAdjoiningTable(cell31)); |
| 249 EXPECT_FALSE(HasEndBorderAdjoiningTable(cell31)); | 252 EXPECT_FALSE(HasEndBorderAdjoiningTable(cell31)); |
| 250 EXPECT_FALSE(HasStartBorderAdjoiningTable(cell32)); | 253 EXPECT_FALSE(HasStartBorderAdjoiningTable(cell32)); |
| 251 EXPECT_FALSE(HasEndBorderAdjoiningTable(cell32)); | 254 EXPECT_FALSE(HasEndBorderAdjoiningTable(cell32)); |
| 252 } | 255 } |
| 253 | 256 |
| 257 TEST_F(LayoutTableCellTest, LocalVisualRectWithCollapedBorders) { | |
|
wkorman
2017/05/08 17:51:23
Collaped -> Collapsed
Xianzhu
2017/05/09 03:55:42
Done.
| |
| 258 SetBodyInnerHTML( | |
| 259 "<style>" | |
| 260 " table { border-collapse: collapse }" | |
| 261 " td { border: 0px solid blue; padding: 0 }" | |
| 262 " div { width: 100px; height: 100px }" | |
| 263 "</style>" | |
| 264 "<table>" | |
| 265 " <tr>" | |
| 266 " <td id='cell1' style='border-bottom-width: 10px;" | |
| 267 " outline: 3px solid blue'><div></div></td>" | |
| 268 " <td id='cell2' style='border-width: 3px 15px'><div></div></td>" | |
| 269 " </tr>" | |
| 270 "</table>"); | |
| 271 | |
| 272 auto* cell1 = GetCellByElementId("cell1"); | |
| 273 auto* cell2 = GetCellByElementId("cell2"); | |
| 274 EXPECT_TRUE(cell1->Table()->ShouldCollapseBorders()); | |
| 275 | |
| 276 EXPECT_EQ(0, cell1->BorderLeft()); | |
| 277 EXPECT_EQ(7, cell1->BorderRight()); | |
| 278 EXPECT_EQ(0, cell1->BorderTop()); | |
| 279 EXPECT_EQ(5, cell1->BorderBottom()); | |
| 280 EXPECT_EQ(8, cell2->BorderLeft()); | |
| 281 EXPECT_EQ(7, cell2->BorderRight()); | |
| 282 EXPECT_EQ(2, cell2->BorderTop()); | |
| 283 EXPECT_EQ(1, cell2->BorderBottom()); | |
| 284 | |
| 285 LayoutRect expected_visual_rect1 = cell1->BorderBoxRect(); | |
| 286 // Expand top, left for outline, right and bottom for collapsed border. | |
| 287 expected_visual_rect1.ExpandEdges(LayoutUnit(3), LayoutUnit(8), LayoutUnit(5), | |
| 288 LayoutUnit(3)); | |
| 289 EXPECT_EQ(expected_visual_rect1, LocalVisualRect(cell1)); | |
| 290 | |
| 291 LayoutRect expected_visual_rect2 = cell2->BorderBoxRect(); | |
| 292 // Expand outer half border width at each side. For the bottom side, expand | |
| 293 // more because the left border is lengthened to cover the joint with the | |
| 294 // bottom border of the cell to the left. | |
| 295 expected_visual_rect2.ExpandEdges(LayoutUnit(1), LayoutUnit(8), LayoutUnit(5), | |
| 296 LayoutUnit(7)); | |
| 297 EXPECT_EQ(expected_visual_rect2, LocalVisualRect(cell2)); | |
| 298 } | |
| 299 | |
| 254 } // namespace blink | 300 } // namespace blink |
| OLD | NEW |