| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * | 4 * |
| 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
| 6 * | 6 * |
| 7 * Other contributors: | 7 * Other contributors: |
| 8 * Robert O'Callahan <roc+@cs.cmu.edu> | 8 * Robert O'Callahan <roc+@cs.cmu.edu> |
| 9 * David Baron <dbaron@fas.harvard.edu> | 9 * David Baron <dbaron@fas.harvard.edu> |
| 10 * Christian Biesinger <cbiesinger@web.de> | 10 * Christian Biesinger <cbiesinger@web.de> |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 if (clip_rect == LayoutRect(LayoutRect::InfiniteIntRect())) | 257 if (clip_rect == LayoutRect(LayoutRect::InfiniteIntRect())) |
| 258 return clip_rect; | 258 return clip_rect; |
| 259 | 259 |
| 260 LayoutPoint clipping_root_offset; | 260 LayoutPoint clipping_root_offset; |
| 261 layer_.ConvertToLayerCoords(&clipping_root_layer, clipping_root_offset); | 261 layer_.ConvertToLayerCoords(&clipping_root_layer, clipping_root_offset); |
| 262 clip_rect.MoveBy(-clipping_root_offset); | 262 clip_rect.MoveBy(-clipping_root_offset); |
| 263 | 263 |
| 264 return clip_rect; | 264 return clip_rect; |
| 265 } | 265 } |
| 266 | 266 |
| 267 #ifdef CHECK_CLIP_RECTS | |
| 268 #define CHECK_RECTS_EQ(expected, actual) \ | |
| 269 do { \ | |
| 270 bool matches = \ | |
| 271 (expected.isEmpty() && actual.isEmpty()) || expected == actual; \ | |
| 272 if (!matches) { \ | |
| 273 LOG(ERROR) << "Rects don't match for m_layer=" \ | |
| 274 << m_layer.layoutObject()->debugName() \ | |
| 275 << " expected=" << expected.toString() \ | |
| 276 << " actual=" << actual.toString(); \ | |
| 277 } \ | |
| 278 } while (false); | |
| 279 #endif | |
| 280 | |
| 281 void PaintLayerClipper::CalculateRectsWithGeometryMapper( | 267 void PaintLayerClipper::CalculateRectsWithGeometryMapper( |
| 282 const ClipRectsContext& context, | 268 const ClipRectsContext& context, |
| 283 const LayoutRect& paint_dirty_rect, | 269 const LayoutRect& paint_dirty_rect, |
| 284 LayoutRect& layer_bounds, | 270 LayoutRect& layer_bounds, |
| 285 ClipRect& background_rect, | 271 ClipRect& background_rect, |
| 286 ClipRect& foreground_rect, | 272 ClipRect& foreground_rect, |
| 287 const LayoutPoint* offset_from_root) const { | 273 const LayoutPoint* offset_from_root) const { |
| 288 LayoutPoint offset(context.sub_pixel_accumulation); | 274 LayoutPoint offset(context.sub_pixel_accumulation); |
| 289 if (offset_from_root) | 275 if (offset_from_root) |
| 290 offset = *offset_from_root; | 276 offset = *offset_from_root; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 312 if (ShouldClipOverflow(context)) { | 298 if (ShouldClipOverflow(context)) { |
| 313 LayoutRect overflow_and_clip_rect = | 299 LayoutRect overflow_and_clip_rect = |
| 314 ToLayoutBox(layout_object) | 300 ToLayoutBox(layout_object) |
| 315 .OverflowClipRect(offset, | 301 .OverflowClipRect(offset, |
| 316 context.overlay_scrollbar_clip_behavior); | 302 context.overlay_scrollbar_clip_behavior); |
| 317 foreground_rect.Intersect(overflow_and_clip_rect); | 303 foreground_rect.Intersect(overflow_and_clip_rect); |
| 318 if (layout_object.StyleRef().HasBorderRadius()) | 304 if (layout_object.StyleRef().HasBorderRadius()) |
| 319 foreground_rect.SetHasRadius(true); | 305 foreground_rect.SetHasRadius(true); |
| 320 } | 306 } |
| 321 } | 307 } |
| 322 | |
| 323 #ifdef CHECK_CLIP_RECTS | |
| 324 ClipRect testBackgroundRect, testForegroundRect; | |
| 325 LayoutRect testLayerBounds; | |
| 326 PaintLayerClipper(m_layer, nullptr) | |
| 327 .calculateRects(context, paintDirtyRect, testLayerBounds, | |
| 328 testBackgroundRect, testForegroundRect, offsetFromRoot); | |
| 329 CHECK_RECTS_EQ(testBackgroundRect, backgroundRect); | |
| 330 CHECK_RECTS_EQ(testForegroundRect, foregroundRect); | |
| 331 CHECK_RECTS_EQ(testLayerBounds, layerBounds); | |
| 332 #endif | |
| 333 } | 308 } |
| 334 | 309 |
| 335 void PaintLayerClipper::CalculateRects( | 310 void PaintLayerClipper::CalculateRects( |
| 336 const ClipRectsContext& context, | 311 const ClipRectsContext& context, |
| 337 const LayoutRect& paint_dirty_rect, | 312 const LayoutRect& paint_dirty_rect, |
| 338 LayoutRect& layer_bounds, | 313 LayoutRect& layer_bounds, |
| 339 ClipRect& background_rect, | 314 ClipRect& background_rect, |
| 340 ClipRect& foreground_rect, | 315 ClipRect& foreground_rect, |
| 341 const LayoutPoint* offset_from_root) const { | 316 const LayoutPoint* offset_from_root) const { |
| 342 if (use_geometry_mapper_) { | 317 if (use_geometry_mapper_) { |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 ClipRect& output) const { | 532 ClipRect& output) const { |
| 558 if (use_geometry_mapper_) { | 533 if (use_geometry_mapper_) { |
| 559 // TODO(chrishtr): fix the underlying bug that causes this situation. | 534 // TODO(chrishtr): fix the underlying bug that causes this situation. |
| 560 if (!layer_.GetLayoutObject().PaintProperties() && | 535 if (!layer_.GetLayoutObject().PaintProperties() && |
| 561 !layer_.GetLayoutObject().LocalBorderBoxProperties()) { | 536 !layer_.GetLayoutObject().LocalBorderBoxProperties()) { |
| 562 output.SetRect(FloatClipRect()); | 537 output.SetRect(FloatClipRect()); |
| 563 return; | 538 return; |
| 564 } | 539 } |
| 565 | 540 |
| 566 CalculateBackgroundClipRectWithGeometryMapper(context, output); | 541 CalculateBackgroundClipRectWithGeometryMapper(context, output); |
| 567 #ifdef CHECK_CLIP_RECTS | |
| 568 ClipRect testBackgroundClipRect = | |
| 569 PaintLayerClipper(m_layer, nullptr).backgroundClipRect(context); | |
| 570 CHECK_RECTS_EQ(testBackgroundClipRect, output); | |
| 571 #endif | |
| 572 return; | 542 return; |
| 573 } | 543 } |
| 574 DCHECK(layer_.Parent()); | 544 DCHECK(layer_.Parent()); |
| 575 LayoutView* layout_view = layer_.GetLayoutObject().View(); | 545 LayoutView* layout_view = layer_.GetLayoutObject().View(); |
| 576 DCHECK(layout_view); | 546 DCHECK(layout_view); |
| 577 | 547 |
| 578 RefPtr<ClipRects> parent_clip_rects = ClipRects::Create(); | 548 RefPtr<ClipRects> parent_clip_rects = ClipRects::Create(); |
| 579 if (&layer_ == context.root_layer) { | 549 if (&layer_ == context.root_layer) { |
| 580 parent_clip_rects->Reset(LayoutRect(LayoutRect::InfiniteIntRect())); | 550 parent_clip_rects->Reset(LayoutRect(LayoutRect::InfiniteIntRect())); |
| 581 } else { | 551 } else { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 DCHECK(!use_geometry_mapper_); | 588 DCHECK(!use_geometry_mapper_); |
| 619 ClipRectsContext context(root_layer, kPaintingClipRects, | 589 ClipRectsContext context(root_layer, kPaintingClipRects, |
| 620 kIgnorePlatformOverlayScrollbarSize, | 590 kIgnorePlatformOverlayScrollbarSize, |
| 621 subpixel_accumulation); | 591 subpixel_accumulation); |
| 622 if (respect_overflow_clip == kIgnoreOverflowClip) | 592 if (respect_overflow_clip == kIgnoreOverflowClip) |
| 623 context.SetIgnoreOverflowClip(); | 593 context.SetIgnoreOverflowClip(); |
| 624 return GetClipRects(context); | 594 return GetClipRects(context); |
| 625 } | 595 } |
| 626 | 596 |
| 627 } // namespace blink | 597 } // namespace blink |
| OLD | NEW |