| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 LayoutRect initialLayoutOverflow() | 39 LayoutRect initialLayoutOverflow() |
| 40 { | 40 { |
| 41 return LayoutRect(10, 10, 80, 80); | 41 return LayoutRect(10, 10, 80, 80); |
| 42 } | 42 } |
| 43 | 43 |
| 44 LayoutRect initialVisualOverflow() | 44 LayoutRect initialVisualOverflow() |
| 45 { | 45 { |
| 46 return LayoutRect(0, 0, 100, 100); | 46 return LayoutRect(0, 0, 100, 100); |
| 47 } | 47 } |
| 48 | 48 |
| 49 class SimpleOverflowModelTest : public testing::Test { | 49 class OverflowModelTest : public testing::Test { |
| 50 protected: | 50 protected: |
| 51 SimpleOverflowModelTest() : m_overflow(initialLayoutOverflow(), initialVisua
lOverflow()) { } | 51 OverflowModelTest() : m_overflow(initialLayoutOverflow(), initialVisualOverf
low()) { } |
| 52 SimpleOverflowModel m_overflow; | 52 BoxOverflowModel m_overflow; |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 TEST_F(SimpleOverflowModelTest, InitialOverflowRects) | 55 TEST_F(OverflowModelTest, InitialOverflowRects) |
| 56 { | 56 { |
| 57 EXPECT_EQ(initialLayoutOverflow(), m_overflow.layoutOverflowRect()); | 57 EXPECT_EQ(initialLayoutOverflow(), m_overflow.layoutOverflowRect()); |
| 58 EXPECT_EQ(initialVisualOverflow(), m_overflow.visualOverflowRect()); | 58 EXPECT_EQ(initialVisualOverflow(), m_overflow.selfVisualOverflowRect()); |
| 59 EXPECT_TRUE(m_overflow.contentsVisualOverflowRect().isEmpty()); |
| 59 } | 60 } |
| 60 | 61 |
| 61 TEST_F(SimpleOverflowModelTest, AddLayoutOverflowOutsideExpandsRect) | 62 TEST_F(OverflowModelTest, AddLayoutOverflowOutsideExpandsRect) |
| 62 { | 63 { |
| 63 m_overflow.addLayoutOverflow(LayoutRect(0, 10, 30, 10)); | 64 m_overflow.addLayoutOverflow(LayoutRect(0, 10, 30, 10)); |
| 64 EXPECT_EQ(LayoutRect(0, 10, 90, 80), m_overflow.layoutOverflowRect()); | 65 EXPECT_EQ(LayoutRect(0, 10, 90, 80), m_overflow.layoutOverflowRect()); |
| 65 } | 66 } |
| 66 | 67 |
| 67 TEST_F(SimpleOverflowModelTest, AddLayoutOverflowInsideDoesNotAffectRect) | 68 TEST_F(OverflowModelTest, AddLayoutOverflowInsideDoesNotAffectRect) |
| 68 { | 69 { |
| 69 m_overflow.addLayoutOverflow(LayoutRect(50, 50, 10, 20)); | 70 m_overflow.addLayoutOverflow(LayoutRect(50, 50, 10, 20)); |
| 70 EXPECT_EQ(initialLayoutOverflow(), m_overflow.layoutOverflowRect()); | 71 EXPECT_EQ(initialLayoutOverflow(), m_overflow.layoutOverflowRect()); |
| 71 } | 72 } |
| 72 | 73 |
| 73 TEST_F(SimpleOverflowModelTest, AddLayoutOverflowEmpty) | 74 TEST_F(OverflowModelTest, AddLayoutOverflowEmpty) |
| 74 { | 75 { |
| 75 // This test documents the existing behavior so that we are aware when/if | 76 // This test documents the existing behavior so that we are aware when/if |
| 76 // it changes. It would also be reasonable for addLayoutOverflow to be | 77 // it changes. It would also be reasonable for addLayoutOverflow to be |
| 77 // a no-op in this situation. | 78 // a no-op in this situation. |
| 78 m_overflow.addLayoutOverflow(LayoutRect(200, 200, 0, 0)); | 79 m_overflow.addLayoutOverflow(LayoutRect(200, 200, 0, 0)); |
| 79 EXPECT_EQ(LayoutRect(10, 10, 190, 190), m_overflow.layoutOverflowRect()); | 80 EXPECT_EQ(LayoutRect(10, 10, 190, 190), m_overflow.layoutOverflowRect()); |
| 80 } | 81 } |
| 81 | 82 |
| 82 TEST_F(SimpleOverflowModelTest, AddLayoutOverflowDoesNotAffectVisualOverflow) | 83 TEST_F(OverflowModelTest, AddLayoutOverflowDoesNotAffectVisualOverflow) |
| 83 { | |
| 84 m_overflow.addLayoutOverflow(LayoutRect(300, 300, 300, 300)); | |
| 85 EXPECT_EQ(initialVisualOverflow(), m_overflow.visualOverflowRect()); | |
| 86 } | |
| 87 | |
| 88 TEST_F(SimpleOverflowModelTest, AddVisualOverflowOutsideExpandsRect) | |
| 89 { | |
| 90 m_overflow.addVisualOverflow(LayoutRect(150, -50, 10, 10)); | |
| 91 EXPECT_EQ(LayoutRect(0, -50, 160, 150), m_overflow.visualOverflowRect()); | |
| 92 } | |
| 93 | |
| 94 TEST_F(SimpleOverflowModelTest, AddVisualOverflowInsideDoesNotAffectRect) | |
| 95 { | |
| 96 m_overflow.addVisualOverflow(LayoutRect(0, 10, 90, 90)); | |
| 97 EXPECT_EQ(initialVisualOverflow(), m_overflow.visualOverflowRect()); | |
| 98 } | |
| 99 | |
| 100 TEST_F(SimpleOverflowModelTest, AddVisualOverflowEmpty) | |
| 101 { | |
| 102 m_overflow.setVisualOverflow(LayoutRect(0, 0, 600, 0)); | |
| 103 m_overflow.addVisualOverflow(LayoutRect(100, -50, 100, 100)); | |
| 104 m_overflow.addVisualOverflow(LayoutRect(300, 300, 0, 10000)); | |
| 105 EXPECT_EQ(LayoutRect(100, -50, 100, 100), m_overflow.visualOverflowRect()); | |
| 106 } | |
| 107 | |
| 108 TEST_F(SimpleOverflowModelTest, AddVisualOverflowDoesNotAffectLayoutOverflow) | |
| 109 { | |
| 110 m_overflow.addVisualOverflow(LayoutRect(300, 300, 300, 300)); | |
| 111 EXPECT_EQ(initialLayoutOverflow(), m_overflow.layoutOverflowRect()); | |
| 112 } | |
| 113 | |
| 114 TEST_F(SimpleOverflowModelTest, MoveAffectsLayoutOverflow) | |
| 115 { | |
| 116 m_overflow.move(LayoutUnit(500), LayoutUnit(100)); | |
| 117 EXPECT_EQ(LayoutRect(510, 110, 80, 80), m_overflow.layoutOverflowRect()); | |
| 118 } | |
| 119 | |
| 120 TEST_F(SimpleOverflowModelTest, MoveAffectsVisualOverflow) | |
| 121 { | |
| 122 m_overflow.move(LayoutUnit(500), LayoutUnit(100)); | |
| 123 EXPECT_EQ(LayoutRect(500, 100, 100, 100), m_overflow.visualOverflowRect()); | |
| 124 } | |
| 125 | |
| 126 class BoxOverflowModelTest : public testing::Test { | |
| 127 protected: | |
| 128 BoxOverflowModelTest() : m_overflow(initialLayoutOverflow(), initialVisualOv
erflow()) { } | |
| 129 BoxOverflowModel m_overflow; | |
| 130 }; | |
| 131 | |
| 132 TEST_F(BoxOverflowModelTest, InitialOverflowRects) | |
| 133 { | |
| 134 EXPECT_EQ(initialLayoutOverflow(), m_overflow.layoutOverflowRect()); | |
| 135 EXPECT_EQ(initialVisualOverflow(), m_overflow.selfVisualOverflowRect()); | |
| 136 EXPECT_TRUE(m_overflow.contentsVisualOverflowRect().isEmpty()); | |
| 137 } | |
| 138 | |
| 139 TEST_F(BoxOverflowModelTest, AddLayoutOverflowOutsideExpandsRect) | |
| 140 { | |
| 141 m_overflow.addLayoutOverflow(LayoutRect(0, 10, 30, 10)); | |
| 142 EXPECT_EQ(LayoutRect(0, 10, 90, 80), m_overflow.layoutOverflowRect()); | |
| 143 } | |
| 144 | |
| 145 TEST_F(BoxOverflowModelTest, AddLayoutOverflowInsideDoesNotAffectRect) | |
| 146 { | |
| 147 m_overflow.addLayoutOverflow(LayoutRect(50, 50, 10, 20)); | |
| 148 EXPECT_EQ(initialLayoutOverflow(), m_overflow.layoutOverflowRect()); | |
| 149 } | |
| 150 | |
| 151 TEST_F(BoxOverflowModelTest, AddLayoutOverflowEmpty) | |
| 152 { | |
| 153 // This test documents the existing behavior so that we are aware when/if | |
| 154 // it changes. It would also be reasonable for addLayoutOverflow to be | |
| 155 // a no-op in this situation. | |
| 156 m_overflow.addLayoutOverflow(LayoutRect(200, 200, 0, 0)); | |
| 157 EXPECT_EQ(LayoutRect(10, 10, 190, 190), m_overflow.layoutOverflowRect()); | |
| 158 } | |
| 159 | |
| 160 TEST_F(BoxOverflowModelTest, AddLayoutOverflowDoesNotAffectSelfVisualOverflow) | |
| 161 { | 84 { |
| 162 m_overflow.addLayoutOverflow(LayoutRect(300, 300, 300, 300)); | 85 m_overflow.addLayoutOverflow(LayoutRect(300, 300, 300, 300)); |
| 163 EXPECT_EQ(initialVisualOverflow(), m_overflow.selfVisualOverflowRect()); | 86 EXPECT_EQ(initialVisualOverflow(), m_overflow.selfVisualOverflowRect()); |
| 164 } | 87 } |
| 165 | 88 |
| 166 TEST_F(BoxOverflowModelTest, AddLayoutOverflowDoesNotAffectContentsVisualOverflo
w) | 89 TEST_F(OverflowModelTest, AddLayoutOverflowDoesNotAffectContentsVisualOverflow) |
| 167 { | 90 { |
| 168 m_overflow.addLayoutOverflow(LayoutRect(300, 300, 300, 300)); | 91 m_overflow.addLayoutOverflow(LayoutRect(300, 300, 300, 300)); |
| 169 EXPECT_TRUE(m_overflow.contentsVisualOverflowRect().isEmpty()); | 92 EXPECT_TRUE(m_overflow.contentsVisualOverflowRect().isEmpty()); |
| 170 } | 93 } |
| 171 | 94 |
| 172 TEST_F(BoxOverflowModelTest, AddSelfVisualOverflowOutsideExpandsRect) | 95 TEST_F(OverflowModelTest, AddVisualOverflowOutsideExpandsRect) |
| 173 { | 96 { |
| 174 m_overflow.addSelfVisualOverflow(LayoutRect(150, -50, 10, 10)); | 97 m_overflow.addSelfVisualOverflow(LayoutRect(150, -50, 10, 10)); |
| 175 EXPECT_EQ(LayoutRect(0, -50, 160, 150), m_overflow.selfVisualOverflowRect())
; | 98 EXPECT_EQ(LayoutRect(0, -50, 160, 150), m_overflow.selfVisualOverflowRect())
; |
| 176 } | 99 } |
| 177 | 100 |
| 178 TEST_F(BoxOverflowModelTest, AddSelfVisualOverflowInsideDoesNotAffectRect) | 101 TEST_F(OverflowModelTest, AddVisualOverflowInsideDoesNotAffectRect) |
| 179 { | 102 { |
| 180 m_overflow.addSelfVisualOverflow(LayoutRect(0, 10, 90, 90)); | 103 m_overflow.addSelfVisualOverflow(LayoutRect(0, 10, 90, 90)); |
| 181 EXPECT_EQ(initialVisualOverflow(), m_overflow.selfVisualOverflowRect()); | 104 EXPECT_EQ(initialVisualOverflow(), m_overflow.selfVisualOverflowRect()); |
| 182 } | 105 } |
| 183 | 106 |
| 184 TEST_F(BoxOverflowModelTest, AddSelfVisualOverflowEmpty) | 107 TEST_F(OverflowModelTest, AddVisualOverflowEmpty) |
| 185 { | 108 { |
| 186 BoxOverflowModel overflow(LayoutRect(), LayoutRect(0, 0, 600, 0)); | 109 // This test documents the existing behavior so that we are aware when/if |
| 187 overflow.addSelfVisualOverflow(LayoutRect(100, -50, 100, 100)); | 110 // it changes. It would also be reasonable for addVisualOverflow to be |
| 188 overflow.addSelfVisualOverflow(LayoutRect(300, 300, 0, 10000)); | 111 // a no-op in this situation. |
| 189 EXPECT_EQ(LayoutRect(100, -50, 100, 100), overflow.selfVisualOverflowRect())
; | 112 m_overflow.addSelfVisualOverflow(LayoutRect(200, 200, 0, 0)); |
| 113 EXPECT_EQ(LayoutRect(0, 0, 200, 200), m_overflow.selfVisualOverflowRect()); |
| 190 } | 114 } |
| 191 | 115 |
| 192 TEST_F(BoxOverflowModelTest, AddSelfVisualOverflowDoesNotAffectLayoutOverflow) | 116 TEST_F(OverflowModelTest, AddVisualOverflowDoesNotAffectLayoutOverflow) |
| 193 { | 117 { |
| 194 m_overflow.addSelfVisualOverflow(LayoutRect(300, 300, 300, 300)); | 118 m_overflow.addSelfVisualOverflow(LayoutRect(300, 300, 300, 300)); |
| 195 EXPECT_EQ(initialLayoutOverflow(), m_overflow.layoutOverflowRect()); | 119 EXPECT_EQ(initialLayoutOverflow(), m_overflow.layoutOverflowRect()); |
| 196 } | 120 } |
| 197 | 121 |
| 198 TEST_F(BoxOverflowModelTest, AddSelfVisualOverflowDoesNotAffectContentsVisualOve
rflow) | 122 TEST_F(OverflowModelTest, AddVisualOverflowDoesNotAffectContentsVisualOverflow) |
| 199 { | 123 { |
| 200 m_overflow.addSelfVisualOverflow(LayoutRect(300, 300, 300, 300)); | 124 m_overflow.addSelfVisualOverflow(LayoutRect(300, 300, 300, 300)); |
| 201 EXPECT_TRUE(m_overflow.contentsVisualOverflowRect().isEmpty()); | 125 EXPECT_TRUE(m_overflow.contentsVisualOverflowRect().isEmpty()); |
| 202 } | 126 } |
| 203 | 127 |
| 204 TEST_F(BoxOverflowModelTest, AddContentsVisualOverflowFirstCall) | 128 TEST_F(OverflowModelTest, AddContentsVisualOverflowFirstCall) |
| 205 { | 129 { |
| 206 m_overflow.addContentsVisualOverflow(LayoutRect(0, 0, 10, 10)); | 130 m_overflow.addContentsVisualOverflow(LayoutRect(0, 0, 10, 10)); |
| 207 EXPECT_EQ(LayoutRect(0, 0, 10, 10), m_overflow.contentsVisualOverflowRect())
; | 131 EXPECT_EQ(LayoutRect(0, 0, 10, 10), m_overflow.contentsVisualOverflowRect())
; |
| 208 } | 132 } |
| 209 | 133 |
| 210 TEST_F(BoxOverflowModelTest, AddContentsVisualOverflowUnitesRects) | 134 TEST_F(OverflowModelTest, AddContentsVisualOverflowUnitesRects) |
| 211 { | 135 { |
| 212 m_overflow.addContentsVisualOverflow(LayoutRect(0, 0, 10, 10)); | 136 m_overflow.addContentsVisualOverflow(LayoutRect(0, 0, 10, 10)); |
| 213 m_overflow.addContentsVisualOverflow(LayoutRect(80, 80, 10, 10)); | 137 m_overflow.addContentsVisualOverflow(LayoutRect(80, 80, 10, 10)); |
| 214 EXPECT_EQ(LayoutRect(0, 0, 90, 90), m_overflow.contentsVisualOverflowRect())
; | 138 EXPECT_EQ(LayoutRect(0, 0, 90, 90), m_overflow.contentsVisualOverflowRect())
; |
| 215 } | 139 } |
| 216 | 140 |
| 217 TEST_F(BoxOverflowModelTest, AddContentsVisualOverflowRectWithinRect) | 141 TEST_F(OverflowModelTest, AddContentsVisualOverflowRectWithinRect) |
| 218 { | 142 { |
| 219 m_overflow.addContentsVisualOverflow(LayoutRect(0, 0, 10, 10)); | 143 m_overflow.addContentsVisualOverflow(LayoutRect(0, 0, 10, 10)); |
| 220 m_overflow.addContentsVisualOverflow(LayoutRect(2, 2, 5, 5)); | 144 m_overflow.addContentsVisualOverflow(LayoutRect(2, 2, 5, 5)); |
| 221 EXPECT_EQ(LayoutRect(0, 0, 10, 10), m_overflow.contentsVisualOverflowRect())
; | 145 EXPECT_EQ(LayoutRect(0, 0, 10, 10), m_overflow.contentsVisualOverflowRect())
; |
| 222 } | 146 } |
| 223 | 147 |
| 224 TEST_F(BoxOverflowModelTest, AddContentsVisualOverflowEmpty) | 148 TEST_F(OverflowModelTest, AddContentsVisualOverflowEmpty) |
| 225 { | 149 { |
| 150 // This test documents the existing behavior so that we are aware when/if |
| 151 // it changes. It would also be reasonable for addContentsVisualOverflow to |
| 152 // expand in this situation. |
| 226 m_overflow.addContentsVisualOverflow(LayoutRect(0, 0, 10, 10)); | 153 m_overflow.addContentsVisualOverflow(LayoutRect(0, 0, 10, 10)); |
| 227 m_overflow.addContentsVisualOverflow(LayoutRect(20, 20, 0, 0)); | 154 m_overflow.addContentsVisualOverflow(LayoutRect(20, 20, 0, 0)); |
| 228 EXPECT_EQ(LayoutRect(0, 0, 10, 10), m_overflow.contentsVisualOverflowRect())
; | 155 EXPECT_EQ(LayoutRect(0, 0, 10, 10), m_overflow.contentsVisualOverflowRect())
; |
| 229 } | 156 } |
| 230 | 157 |
| 231 TEST_F(BoxOverflowModelTest, MoveAffectsLayoutOverflow) | 158 TEST_F(OverflowModelTest, MoveAffectsLayoutOverflow) |
| 232 { | 159 { |
| 233 m_overflow.move(LayoutUnit(500), LayoutUnit(100)); | 160 m_overflow.move(LayoutUnit(500), LayoutUnit(100)); |
| 234 EXPECT_EQ(LayoutRect(510, 110, 80, 80), m_overflow.layoutOverflowRect()); | 161 EXPECT_EQ(LayoutRect(510, 110, 80, 80), m_overflow.layoutOverflowRect()); |
| 235 } | 162 } |
| 236 | 163 |
| 237 TEST_F(BoxOverflowModelTest, MoveAffectsSelfVisualOverflow) | 164 TEST_F(OverflowModelTest, MoveAffectsVisualOverflow) |
| 238 { | 165 { |
| 239 m_overflow.move(LayoutUnit(500), LayoutUnit(100)); | 166 m_overflow.move(LayoutUnit(500), LayoutUnit(100)); |
| 240 EXPECT_EQ(LayoutRect(500, 100, 100, 100), m_overflow.selfVisualOverflowRect(
)); | 167 EXPECT_EQ(LayoutRect(500, 100, 100, 100), m_overflow.selfVisualOverflowRect(
)); |
| 241 } | 168 } |
| 242 | 169 |
| 243 TEST_F(BoxOverflowModelTest, MoveAffectsContentsVisualOverflow) | 170 TEST_F(OverflowModelTest, MoveAffectsContentsVisualOverflow) |
| 244 { | 171 { |
| 245 m_overflow.addContentsVisualOverflow(LayoutRect(0, 0, 10, 10)); | 172 m_overflow.addContentsVisualOverflow(LayoutRect(0, 0, 10, 10)); |
| 246 m_overflow.move(LayoutUnit(500), LayoutUnit(100)); | 173 m_overflow.move(LayoutUnit(500), LayoutUnit(100)); |
| 247 EXPECT_EQ(LayoutRect(500, 100, 10, 10), m_overflow.contentsVisualOverflowRec
t()); | 174 EXPECT_EQ(LayoutRect(500, 100, 10, 10), m_overflow.contentsVisualOverflowRec
t()); |
| 248 } | 175 } |
| 249 | 176 |
| 250 } // anonymous namespace | 177 } // anonymous namespace |
| 251 } // namespace blink | 178 } // namespace blink |
| OLD | NEW |