| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 GetRasterInvalidationTracking()->invalidations; | 195 GetRasterInvalidationTracking()->invalidations; |
| 196 ASSERT_EQ(1u, raster_invalidations.size()); | 196 ASSERT_EQ(1u, raster_invalidations.size()); |
| 197 EXPECT_EQ(PaintInvalidationReason::kNone, | 197 EXPECT_EQ(PaintInvalidationReason::kNone, |
| 198 target->FullPaintInvalidationReason()); | 198 target->FullPaintInvalidationReason()); |
| 199 EXPECT_EQ(IntRect(0, 4000, 100, 100), raster_invalidations[0].rect); | 199 EXPECT_EQ(IntRect(0, 4000, 100, 100), raster_invalidations[0].rect); |
| 200 EXPECT_EQ(PaintInvalidationReason::kFull, raster_invalidations[0].reason); | 200 EXPECT_EQ(PaintInvalidationReason::kFull, raster_invalidations[0].reason); |
| 201 EXPECT_FALSE(target->NeedsPaintOffsetAndVisualRectUpdate()); | 201 EXPECT_FALSE(target->NeedsPaintOffsetAndVisualRectUpdate()); |
| 202 GetDocument().View()->SetTracksPaintInvalidations(false); | 202 GetDocument().View()->SetTracksPaintInvalidations(false); |
| 203 }; | 203 }; |
| 204 | 204 |
| 205 TEST_P(PaintInvalidationTest, SVGHiddenContainer) { |
| 206 EnableCompositing(); |
| 207 SetBodyInnerHTML( |
| 208 "<svg style='position: absolute; top: 100px; left: 100px'>" |
| 209 " <mask id='mask'>" |
| 210 " <g transform='scale(2)'>" |
| 211 " <rect id='mask-rect' x='11' y='22' width='33' height='44'/>" |
| 212 " </g>" |
| 213 " </mask>" |
| 214 " <rect id='real-rect' x='55' y='66' width='7' height='8'" |
| 215 " mask='url(#mask)'/>" |
| 216 "</svg>"); |
| 217 |
| 218 // mask_rect's visual rect is in coordinates of the mask. |
| 219 auto* mask_rect = GetLayoutObjectByElementId("mask-rect"); |
| 220 EXPECT_EQ(LayoutRect(22, 44, 66, 88), mask_rect->VisualRect()); |
| 221 |
| 222 // real_rect's visual rect is in coordinates of its paint invalidation |
| 223 // container (the view). |
| 224 auto* real_rect = GetLayoutObjectByElementId("real-rect"); |
| 225 EXPECT_EQ(LayoutRect(155, 166, 7, 8), real_rect->VisualRect()); |
| 226 |
| 227 GetDocument().View()->SetTracksPaintInvalidations(true); |
| 228 ToElement(mask_rect->GetNode())->setAttribute("x", "20"); |
| 229 GetDocument().View()->UpdateAllLifecyclePhasesExceptPaint(); |
| 230 EXPECT_EQ(LayoutRect(40, 44, 66, 88), mask_rect->VisualRect()); |
| 231 EXPECT_EQ(LayoutRect(155, 166, 7, 8), real_rect->VisualRect()); |
| 232 |
| 233 // Should invalidate raster for real_rect only. |
| 234 const auto& raster_invalidations = |
| 235 GetRasterInvalidationTracking()->invalidations; |
| 236 ASSERT_EQ(1u, raster_invalidations.size()); |
| 237 EXPECT_EQ(IntRect(155, 166, 7, 8), raster_invalidations[0].rect); |
| 238 EXPECT_EQ(PaintInvalidationReason::kFull, raster_invalidations[0].reason); |
| 239 EXPECT_EQ(PaintInvalidationReason::kFull, |
| 240 real_rect->GetPaintInvalidationReason()); |
| 241 |
| 242 // Should still invalidate DisplayItemClient of mask_rect. |
| 243 EXPECT_EQ(PaintInvalidationReason::kFull, |
| 244 mask_rect->GetPaintInvalidationReason()); |
| 245 GetDocument().View()->SetTracksPaintInvalidations(false); |
| 246 } |
| 247 |
| 205 } // namespace | 248 } // namespace |
| 206 | 249 |
| 207 } // namespace blink | 250 } // namespace blink |
| OLD | NEW |