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