OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/frame/FrameView.h" | 5 #include "core/frame/FrameView.h" |
6 #include "core/layout/LayoutTestHelper.h" | 6 #include "core/layout/LayoutTestHelper.h" |
7 #include "core/layout/LayoutView.h" | 7 #include "core/layout/LayoutView.h" |
8 #include "core/paint/PaintLayer.h" | 8 #include "core/paint/PaintLayer.h" |
9 #include "platform/graphics/GraphicsLayer.h" | 9 #include "platform/graphics/GraphicsLayer.h" |
10 #include "platform/graphics/paint/RasterInvalidationTracking.h" | 10 #include "platform/graphics/paint/RasterInvalidationTracking.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 " <g transform='scale(2)'>" | 210 " <g transform='scale(2)'>" |
211 " <rect id='mask-rect' x='11' y='22' width='33' height='44'/>" | 211 " <rect id='mask-rect' x='11' y='22' width='33' height='44'/>" |
212 " </g>" | 212 " </g>" |
213 " </mask>" | 213 " </mask>" |
214 " <rect id='real-rect' x='55' y='66' width='7' height='8'" | 214 " <rect id='real-rect' x='55' y='66' width='7' height='8'" |
215 " mask='url(#mask)'/>" | 215 " mask='url(#mask)'/>" |
216 "</svg>"); | 216 "</svg>"); |
217 | 217 |
218 // mask_rect's visual rect is in coordinates of the mask. | 218 // mask_rect's visual rect is in coordinates of the mask. |
219 auto* mask_rect = GetLayoutObjectByElementId("mask-rect"); | 219 auto* mask_rect = GetLayoutObjectByElementId("mask-rect"); |
220 EXPECT_EQ(LayoutRect(22, 44, 66, 88), mask_rect->VisualRect()); | 220 EXPECT_EQ(LayoutRect(), mask_rect->VisualRect()); |
221 | 221 |
222 // real_rect's visual rect is in coordinates of its paint invalidation | 222 // real_rect's visual rect is in coordinates of its paint invalidation |
223 // container (the view). | 223 // container (the view). |
224 auto* real_rect = GetLayoutObjectByElementId("real-rect"); | 224 auto* real_rect = GetLayoutObjectByElementId("real-rect"); |
225 EXPECT_EQ(LayoutRect(155, 166, 7, 8), real_rect->VisualRect()); | 225 EXPECT_EQ(LayoutRect(155, 166, 7, 8), real_rect->VisualRect()); |
226 | 226 |
227 GetDocument().View()->SetTracksPaintInvalidations(true); | 227 GetDocument().View()->SetTracksPaintInvalidations(true); |
228 ToElement(mask_rect->GetNode())->setAttribute("x", "20"); | 228 ToElement(mask_rect->GetNode())->setAttribute("x", "20"); |
229 GetDocument().View()->UpdateAllLifecyclePhasesExceptPaint(); | 229 GetDocument().View()->UpdateAllLifecyclePhasesExceptPaint(); |
230 EXPECT_EQ(LayoutRect(40, 44, 66, 88), mask_rect->VisualRect()); | 230 EXPECT_EQ(LayoutRect(), mask_rect->VisualRect()); |
231 EXPECT_EQ(LayoutRect(155, 166, 7, 8), real_rect->VisualRect()); | 231 EXPECT_EQ(LayoutRect(155, 166, 7, 8), real_rect->VisualRect()); |
232 | 232 |
233 // Should invalidate raster for real_rect only. | 233 // Should invalidate raster for real_rect only. |
234 const auto& raster_invalidations = | 234 const auto& raster_invalidations = |
235 GetRasterInvalidationTracking()->invalidations; | 235 GetRasterInvalidationTracking()->invalidations; |
236 ASSERT_EQ(1u, raster_invalidations.size()); | 236 ASSERT_EQ(1u, raster_invalidations.size()); |
237 EXPECT_EQ(IntRect(155, 166, 7, 8), raster_invalidations[0].rect); | 237 EXPECT_EQ(IntRect(155, 166, 7, 8), raster_invalidations[0].rect); |
238 EXPECT_EQ(PaintInvalidationReason::kFull, raster_invalidations[0].reason); | 238 EXPECT_EQ(PaintInvalidationReason::kFull, raster_invalidations[0].reason); |
239 EXPECT_EQ(PaintInvalidationReason::kFull, | 239 EXPECT_EQ(PaintInvalidationReason::kFull, |
240 real_rect->GetPaintInvalidationReason()); | 240 real_rect->GetPaintInvalidationReason()); |
241 | 241 |
242 // Should still invalidate DisplayItemClient of mask_rect. | 242 // Should not invalidate DisplayItemClient of mask_rect. |
243 EXPECT_EQ(PaintInvalidationReason::kFull, | 243 EXPECT_EQ(PaintInvalidationReason::kNone, |
244 mask_rect->GetPaintInvalidationReason()); | 244 mask_rect->GetPaintInvalidationReason()); |
| 245 |
245 GetDocument().View()->SetTracksPaintInvalidations(false); | 246 GetDocument().View()->SetTracksPaintInvalidations(false); |
246 } | 247 } |
247 | 248 |
248 } // namespace | 249 } // namespace |
249 | 250 |
250 } // namespace blink | 251 } // namespace blink |
OLD | NEW |