OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/LayoutBox.h" | 5 #include "core/layout/LayoutBox.h" |
6 | 6 |
7 #include "core/html/HTMLElement.h" | 7 #include "core/html/HTMLElement.h" |
8 #include "core/layout/ImageQualityController.h" | 8 #include "core/layout/ImageQualityController.h" |
9 #include "core/layout/LayoutTestHelper.h" | 9 #include "core/layout/LayoutTestHelper.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // Because it can scroll due to local attachment, the opaque local background
in #target6 | 93 // Because it can scroll due to local attachment, the opaque local background
in #target6 |
94 // is treated as padding box for the clip rect, but remains the content box fo
r the known | 94 // is treated as padding box for the clip rect, but remains the content box fo
r the known |
95 // opaque rect. | 95 // opaque rect. |
96 layoutBox = toLayoutBox(getLayoutObjectByElementId("target6")); | 96 layoutBox = toLayoutBox(getLayoutObjectByElementId("target6")); |
97 EXPECT_EQ(LayoutRect(20, 20, 100, 100), | 97 EXPECT_EQ(LayoutRect(20, 20, 100, 100), |
98 layoutBox->backgroundRect(BackgroundKnownOpaqueRect)); | 98 layoutBox->backgroundRect(BackgroundKnownOpaqueRect)); |
99 EXPECT_EQ(LayoutRect(10, 10, 120, 120), | 99 EXPECT_EQ(LayoutRect(10, 10, 120, 120), |
100 layoutBox->backgroundRect(BackgroundClipRect)); | 100 layoutBox->backgroundRect(BackgroundClipRect)); |
101 } | 101 } |
102 | 102 |
| 103 TEST_F(LayoutBoxTest, TopLeftLocationFlipped) { |
| 104 setBodyInnerHTML( |
| 105 "<div style='width: 600px; height: 200px; writing-mode: vertical-rl'>" |
| 106 " <div id='box1' style='width: 100px'></div>" |
| 107 " <div id='box2' style='width: 200px'></div>" |
| 108 "</div>"); |
| 109 |
| 110 const LayoutBox* box1 = toLayoutBox(getLayoutObjectByElementId("box1")); |
| 111 EXPECT_EQ(LayoutPoint(0, 0), box1->location()); |
| 112 EXPECT_EQ(LayoutPoint(500, 0), box1->topLeftLocation()); |
| 113 |
| 114 const LayoutBox* box2 = toLayoutBox(getLayoutObjectByElementId("box2")); |
| 115 EXPECT_EQ(LayoutPoint(100, 0), box2->location()); |
| 116 EXPECT_EQ(LayoutPoint(300, 0), box2->topLeftLocation()); |
| 117 } |
| 118 |
| 119 TEST_F(LayoutBoxTest, TableRowCellTopLeftLocationFlipped) { |
| 120 setBodyInnerHTML( |
| 121 "<div style='writing-mode: vertical-rl'>" |
| 122 " <table style='border-spacing: 0'>" |
| 123 " <thead><tr><td style='width: 50px'></td></tr></thead>" |
| 124 " <tbody>" |
| 125 " <tr id='row1'>" |
| 126 " <td id='cell1' style='width: 100px; height: 80px'></td>" |
| 127 " </tr>" |
| 128 " <tr id='row2'>" |
| 129 " <td id='cell2' style='width: 300px; height: 80px'></td>" |
| 130 " </tr>" |
| 131 " </tbody>" |
| 132 " </table>" |
| 133 "</div>"); |
| 134 |
| 135 // location and topLeftLocation of a table row or a table cell should be |
| 136 // relative to the containing section. |
| 137 |
| 138 const LayoutBox* row1 = toLayoutBox(getLayoutObjectByElementId("row1")); |
| 139 EXPECT_EQ(LayoutPoint(0, 0), row1->location()); |
| 140 EXPECT_EQ(LayoutPoint(300, 0), row1->topLeftLocation()); |
| 141 |
| 142 const LayoutBox* cell1 = toLayoutBox(getLayoutObjectByElementId("cell1")); |
| 143 EXPECT_EQ(LayoutPoint(0, 0), cell1->location()); |
| 144 EXPECT_EQ(LayoutPoint(300, 0), cell1->topLeftLocation()); |
| 145 |
| 146 const LayoutBox* row2 = toLayoutBox(getLayoutObjectByElementId("row2")); |
| 147 // TODO(crbug.com/652496): LayoutTableRow's location is in logical coordinates |
| 148 // of the containing section, and topLeftLocation() is incorrect. |
| 149 // This should be (100, 0). |
| 150 EXPECT_EQ(LayoutPoint(0, 100), row2->location()); |
| 151 // This should be (0, 0). |
| 152 EXPECT_EQ(LayoutPoint(100, 100), row2->topLeftLocation()); |
| 153 |
| 154 const LayoutBox* cell2 = toLayoutBox(getLayoutObjectByElementId("cell2")); |
| 155 EXPECT_EQ(LayoutPoint(100, 0), cell2->location()); |
| 156 EXPECT_EQ(LayoutPoint(0, 0), cell2->topLeftLocation()); |
| 157 } |
| 158 |
103 } // namespace blink | 159 } // namespace blink |
OLD | NEW |