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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 layer = layer->NextSibling()) | 198 layer = layer->NextSibling()) |
199 layers.push(layer); | 199 layers.push(layer); |
200 } | 200 } |
201 } | 201 } |
202 | 202 |
203 LayoutRect PaintLayerClipper::LocalClipRect( | 203 LayoutRect PaintLayerClipper::LocalClipRect( |
204 const PaintLayer& clipping_root_layer) const { | 204 const PaintLayer& clipping_root_layer) const { |
205 ClipRectsContext context(&clipping_root_layer, kPaintingClipRects); | 205 ClipRectsContext context(&clipping_root_layer, kPaintingClipRects); |
206 if (use_geometry_mapper_) { | 206 if (use_geometry_mapper_) { |
207 ClipRect clip_rect; | 207 ClipRect clip_rect; |
208 CalculateBackgroundClipRectWithGeometryMapper(context, clip_rect); | 208 CalculateBackgroundClipRectWithGeometryMapper(context, clip_rect, |
| 209 ShouldClipOverflow(context)); |
209 LayoutRect premapped_rect = clip_rect.Rect(); | 210 LayoutRect premapped_rect = clip_rect.Rect(); |
210 | 211 |
211 // The rect now needs to be transformed to the local space of this | 212 // The rect now needs to be transformed to the local space of this |
212 // PaintLayer. | 213 // PaintLayer. |
213 premapped_rect.MoveBy(context.root_layer->GetLayoutObject().PaintOffset()); | 214 premapped_rect.MoveBy(context.root_layer->GetLayoutObject().PaintOffset()); |
214 | 215 |
215 const auto* clip_root_layer_transform = | 216 const auto* clip_root_layer_transform = |
216 clipping_root_layer.GetLayoutObject() | 217 clipping_root_layer.GetLayoutObject() |
217 .LocalBorderBoxProperties() | 218 .LocalBorderBoxProperties() |
218 ->Transform(); | 219 ->Transform(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 else | 273 else |
273 layer_.ConvertToLayerCoords(context.root_layer, offset); | 274 layer_.ConvertToLayerCoords(context.root_layer, offset); |
274 layer_bounds = LayoutRect(offset, LayoutSize(layer_.size())); | 275 layer_bounds = LayoutRect(offset, LayoutSize(layer_.size())); |
275 | 276 |
276 // TODO(chrishtr): fix the underlying bug that causes this situation. | 277 // TODO(chrishtr): fix the underlying bug that causes this situation. |
277 if (!layer_.GetLayoutObject().PaintProperties() && | 278 if (!layer_.GetLayoutObject().PaintProperties() && |
278 !layer_.GetLayoutObject().LocalBorderBoxProperties()) { | 279 !layer_.GetLayoutObject().LocalBorderBoxProperties()) { |
279 background_rect = ClipRect(LayoutRect(LayoutRect::InfiniteIntRect())); | 280 background_rect = ClipRect(LayoutRect(LayoutRect::InfiniteIntRect())); |
280 foreground_rect = ClipRect(LayoutRect(LayoutRect::InfiniteIntRect())); | 281 foreground_rect = ClipRect(LayoutRect(LayoutRect::InfiniteIntRect())); |
281 } else { | 282 } else { |
282 CalculateBackgroundClipRectWithGeometryMapper(context, background_rect); | 283 CalculateBackgroundClipRectWithGeometryMapper(context, background_rect, |
| 284 ShouldClipOverflow(context)); |
283 background_rect.Move(context.sub_pixel_accumulation); | 285 background_rect.Move(context.sub_pixel_accumulation); |
284 background_rect.Intersect(paint_dirty_rect); | 286 background_rect.Intersect(paint_dirty_rect); |
285 | 287 |
286 foreground_rect = background_rect; | 288 foreground_rect = background_rect; |
287 | 289 |
288 LayoutBoxModelObject& layout_object = layer_.GetLayoutObject(); | 290 LayoutBoxModelObject& layout_object = layer_.GetLayoutObject(); |
289 if (layout_object.HasClip()) { | 291 if (layout_object.HasClip()) { |
290 LayoutRect new_pos_clip = ToLayoutBox(layout_object).ClipRect(offset); | 292 LayoutRect new_pos_clip = ToLayoutBox(layout_object).ClipRect(offset); |
291 foreground_rect.Intersect(new_pos_clip); | 293 foreground_rect.Intersect(new_pos_clip); |
292 } | 294 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 return parent_rects.FixedClipRect(); | 421 return parent_rects.FixedClipRect(); |
420 | 422 |
421 if (position == EPosition::kAbsolute) | 423 if (position == EPosition::kAbsolute) |
422 return parent_rects.PosClipRect(); | 424 return parent_rects.PosClipRect(); |
423 | 425 |
424 return parent_rects.OverflowClipRect(); | 426 return parent_rects.OverflowClipRect(); |
425 } | 427 } |
426 | 428 |
427 void PaintLayerClipper::CalculateBackgroundClipRectWithGeometryMapper( | 429 void PaintLayerClipper::CalculateBackgroundClipRectWithGeometryMapper( |
428 const ClipRectsContext& context, | 430 const ClipRectsContext& context, |
429 ClipRect& output) const { | 431 ClipRect& output, |
| 432 bool should_clip_to_visual_overflow) const { |
430 DCHECK(use_geometry_mapper_); | 433 DCHECK(use_geometry_mapper_); |
431 PropertyTreeState source_property_tree_state(nullptr, nullptr, nullptr); | 434 PropertyTreeState source_property_tree_state(nullptr, nullptr, nullptr); |
432 PropertyTreeState destination_property_tree_state(nullptr, nullptr, nullptr); | 435 PropertyTreeState destination_property_tree_state(nullptr, nullptr, nullptr); |
433 InitializeCommonClipRectState(context, source_property_tree_state, | 436 InitializeCommonClipRectState(context, source_property_tree_state, |
434 destination_property_tree_state); | 437 destination_property_tree_state); |
435 | 438 |
436 if (&layer_ != context.root_layer) { | 439 if (&layer_ != context.root_layer) { |
437 auto* ancestor_properties = | 440 auto* ancestor_properties = |
438 context.root_layer->GetLayoutObject().PaintProperties(); | 441 context.root_layer->GetLayoutObject().PaintProperties(); |
439 const auto* ancestor_overflow_clip = | 442 const auto* ancestor_overflow_clip = |
(...skipping 10 matching lines...) Expand all Loading... |
450 // of m_layer, because nothing in m_layer or its children within the clip can | 453 // of m_layer, because nothing in m_layer or its children within the clip can |
451 // paint outside of those bounds. | 454 // paint outside of those bounds. |
452 // The total painting bounds includes any visual overflow (such as shadow) and | 455 // The total painting bounds includes any visual overflow (such as shadow) and |
453 // filter bounds. | 456 // filter bounds. |
454 // | 457 // |
455 // TODO(chrishtr): sourceToDestinationVisualRect and | 458 // TODO(chrishtr): sourceToDestinationVisualRect and |
456 // sourceToDestinationClipRect may not compute tight results in the presence | 459 // sourceToDestinationClipRect may not compute tight results in the presence |
457 // of transforms. Tight results are required for most use cases of these | 460 // of transforms. Tight results are required for most use cases of these |
458 // rects, so we should add methods to GeometryMapper that guarantee there | 461 // rects, so we should add methods to GeometryMapper that guarantee there |
459 // are tight results, or else signal an error. | 462 // are tight results, or else signal an error. |
460 if (ShouldClipOverflow(context)) { | 463 if (should_clip_to_visual_overflow) { |
461 FloatClipRect clip_rect((FloatRect(LocalVisualRect()))); | 464 FloatClipRect clip_rect((FloatRect(LocalVisualRect()))); |
462 clip_rect.MoveBy(FloatPoint(layer_.GetLayoutObject().PaintOffset())); | 465 clip_rect.MoveBy(FloatPoint(layer_.GetLayoutObject().PaintOffset())); |
463 GeometryMapper::SourceToDestinationVisualRect( | 466 GeometryMapper::SourceToDestinationVisualRect( |
464 source_property_tree_state, destination_property_tree_state, clip_rect); | 467 source_property_tree_state, destination_property_tree_state, clip_rect); |
465 output.SetRect(clip_rect); | 468 output.SetRect(clip_rect); |
466 } else { | 469 } else { |
467 const FloatClipRect& clipped_rect_in_root_layer_space = | 470 const FloatClipRect& clipped_rect_in_root_layer_space = |
468 GeometryMapper::SourceToDestinationClipRect( | 471 GeometryMapper::SourceToDestinationClipRect( |
469 source_property_tree_state, destination_property_tree_state); | 472 source_property_tree_state, destination_property_tree_state); |
470 output.SetRect(clipped_rect_in_root_layer_space); | 473 output.SetRect(clipped_rect_in_root_layer_space); |
| 474 if (clipped_rect_in_root_layer_space.IsInfinite()) |
| 475 return; |
471 } | 476 } |
472 | 477 |
473 output.MoveBy(-context.root_layer->GetLayoutObject().PaintOffset()); | 478 output.MoveBy(-context.root_layer->GetLayoutObject().PaintOffset()); |
474 } | 479 } |
475 | 480 |
476 void PaintLayerClipper::InitializeCommonClipRectState( | 481 void PaintLayerClipper::InitializeCommonClipRectState( |
477 const ClipRectsContext& context, | 482 const ClipRectsContext& context, |
478 PropertyTreeState& source_property_tree_state, | 483 PropertyTreeState& source_property_tree_state, |
479 PropertyTreeState& destination_property_tree_state) const { | 484 PropertyTreeState& destination_property_tree_state) const { |
480 DCHECK(use_geometry_mapper_); | 485 DCHECK(use_geometry_mapper_); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 const ClipRectsContext& context, | 527 const ClipRectsContext& context, |
523 ClipRect& output) const { | 528 ClipRect& output) const { |
524 if (use_geometry_mapper_) { | 529 if (use_geometry_mapper_) { |
525 // TODO(chrishtr): fix the underlying bug that causes this situation. | 530 // TODO(chrishtr): fix the underlying bug that causes this situation. |
526 if (!layer_.GetLayoutObject().PaintProperties() && | 531 if (!layer_.GetLayoutObject().PaintProperties() && |
527 !layer_.GetLayoutObject().LocalBorderBoxProperties()) { | 532 !layer_.GetLayoutObject().LocalBorderBoxProperties()) { |
528 output.SetRect(FloatClipRect()); | 533 output.SetRect(FloatClipRect()); |
529 return; | 534 return; |
530 } | 535 } |
531 | 536 |
532 CalculateBackgroundClipRectWithGeometryMapper(context, output); | 537 CalculateBackgroundClipRectWithGeometryMapper(context, output, false); |
533 #ifdef CHECK_CLIP_RECTS | 538 #ifdef CHECK_CLIP_RECTS |
534 ClipRect testBackgroundClipRect = | 539 ClipRect testBackgroundClipRect = |
535 PaintLayerClipper(m_layer, nullptr).backgroundClipRect(context); | 540 PaintLayerClipper(m_layer, nullptr).backgroundClipRect(context); |
536 CHECK_RECTS_EQ(testBackgroundClipRect, output); | 541 CHECK_RECTS_EQ(testBackgroundClipRect, output); |
537 #endif | 542 #endif |
538 return; | 543 return; |
539 } | 544 } |
540 DCHECK(layer_.Parent()); | 545 DCHECK(layer_.Parent()); |
541 LayoutView* layout_view = layer_.GetLayoutObject().View(); | 546 LayoutView* layout_view = layer_.GetLayoutObject().View(); |
542 DCHECK(layout_view); | 547 DCHECK(layout_view); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 DCHECK(!use_geometry_mapper_); | 609 DCHECK(!use_geometry_mapper_); |
605 ClipRectsContext context(root_layer, kPaintingClipRects, | 610 ClipRectsContext context(root_layer, kPaintingClipRects, |
606 kIgnorePlatformOverlayScrollbarSize, | 611 kIgnorePlatformOverlayScrollbarSize, |
607 subpixel_accumulation); | 612 subpixel_accumulation); |
608 if (respect_overflow_clip == kIgnoreOverflowClip) | 613 if (respect_overflow_clip == kIgnoreOverflowClip) |
609 context.SetIgnoreOverflowClip(); | 614 context.SetIgnoreOverflowClip(); |
610 return GetClipRects(context); | 615 return GetClipRects(context); |
611 } | 616 } |
612 | 617 |
613 } // namespace blink | 618 } // namespace blink |
OLD | NEW |