Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp

Issue 2194273002: Fix border radius on composited children. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update the comment on why we say an empty div can paint Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010, 2011 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 PaintLayer* oldSquashedLayer = m_squashedLayers[i].paintLayer; 195 PaintLayer* oldSquashedLayer = m_squashedLayers[i].paintLayer;
196 // Assert on incorrect mappings between layers and groups 196 // Assert on incorrect mappings between layers and groups
197 ASSERT(oldSquashedLayer->groupedMapping() == this); 197 ASSERT(oldSquashedLayer->groupedMapping() == this);
198 if (oldSquashedLayer->groupedMapping() == this) { 198 if (oldSquashedLayer->groupedMapping() == this) {
199 oldSquashedLayer->setGroupedMapping( 199 oldSquashedLayer->setGroupedMapping(
200 0, PaintLayer::DoNotInvalidateLayerAndRemoveFromMapping); 200 0, PaintLayer::DoNotInvalidateLayerAndRemoveFromMapping);
201 oldSquashedLayer->setLostGroupedMapping(true); 201 oldSquashedLayer->setLostGroupedMapping(true);
202 } 202 }
203 } 203 }
204 204
205 updateClippingLayers(false, false); 205 updateClippingLayers(false, false, false);
206 updateOverflowControlsLayers(false, false, false, false); 206 updateOverflowControlsLayers(false, false, false, false);
207 updateChildTransformLayer(false); 207 updateChildTransformLayer(false);
208 updateForegroundLayer(false); 208 updateForegroundLayer(false);
209 updateBackgroundLayer(false); 209 updateBackgroundLayer(false);
210 updateMaskLayer(false); 210 updateMaskLayer(false);
211 updateChildClippingMaskLayer(false); 211 updateChildClippingMaskLayer(false);
212 updateScrollingLayers(false); 212 updateScrollingLayers(false);
213 updateSquashingLayers(false); 213 updateSquashingLayers(false);
214 destroyGraphicsLayers(); 214 destroyGraphicsLayers();
215 } 215 }
(...skipping 23 matching lines...) Expand all
239 updateStickyConstraints(layoutObject()->styleRef()); 239 updateStickyConstraints(layoutObject()->styleRef());
240 updateLayerBlendMode(layoutObject()->styleRef()); 240 updateLayerBlendMode(layoutObject()->styleRef());
241 updateIsRootForIsolatedGroup(); 241 updateIsRootForIsolatedGroup();
242 } 242 }
243 243
244 void CompositedLayerMapping::destroyGraphicsLayers() { 244 void CompositedLayerMapping::destroyGraphicsLayers() {
245 if (m_graphicsLayer) 245 if (m_graphicsLayer)
246 m_graphicsLayer->removeFromParent(); 246 m_graphicsLayer->removeFromParent();
247 247
248 m_ancestorClippingLayer = nullptr; 248 m_ancestorClippingLayer = nullptr;
249 m_ancestorClippingMaskLayer = nullptr;
249 m_graphicsLayer = nullptr; 250 m_graphicsLayer = nullptr;
250 m_foregroundLayer = nullptr; 251 m_foregroundLayer = nullptr;
251 m_backgroundLayer = nullptr; 252 m_backgroundLayer = nullptr;
252 m_childContainmentLayer = nullptr; 253 m_childContainmentLayer = nullptr;
253 m_childTransformLayer = nullptr; 254 m_childTransformLayer = nullptr;
254 m_maskLayer = nullptr; 255 m_maskLayer = nullptr;
255 m_childClippingMaskLayer = nullptr; 256 m_childClippingMaskLayer = nullptr;
256 257
257 m_scrollingLayer = nullptr; 258 m_scrollingLayer = nullptr;
258 m_scrollingContentsLayer = nullptr; 259 m_scrollingContentsLayer = nullptr;
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 } 466 }
466 467
467 void CompositedLayerMapping::updateCompositingReasons() { 468 void CompositedLayerMapping::updateCompositingReasons() {
468 // All other layers owned by this mapping will have the same compositing 469 // All other layers owned by this mapping will have the same compositing
469 // reason for their lifetime, so they are initialized only when created. 470 // reason for their lifetime, so they are initialized only when created.
470 m_graphicsLayer->setCompositingReasons(m_owningLayer.getCompositingReasons()); 471 m_graphicsLayer->setCompositingReasons(m_owningLayer.getCompositingReasons());
471 m_graphicsLayer->setSquashingDisallowedReasons( 472 m_graphicsLayer->setSquashingDisallowedReasons(
472 m_owningLayer.getSquashingDisallowedReasons()); 473 m_owningLayer.getSquashingDisallowedReasons());
473 } 474 }
474 475
475 bool CompositedLayerMapping:: 476 void CompositedLayerMapping::
476 owningLayerClippedByLayerNotAboveCompositedAncestor( 477 owningLayerClippedOrMaskedByLayerNotAboveCompositedAncestor(
477 const PaintLayer* scrollParent) { 478 const PaintLayer* scrollParent,
479 bool& owningLayerIsClipped,
480 bool& owningLayerIsMasked) {
481 owningLayerIsClipped = false;
482 owningLayerIsMasked = false;
483
478 if (!m_owningLayer.parent()) 484 if (!m_owningLayer.parent())
479 return false; 485 return;
480 486
481 const PaintLayer* compositingAncestor = 487 const PaintLayer* compositingAncestor =
482 m_owningLayer.enclosingLayerWithCompositedLayerMapping(ExcludeSelf); 488 m_owningLayer.enclosingLayerWithCompositedLayerMapping(ExcludeSelf);
483 if (!compositingAncestor) 489 if (!compositingAncestor)
484 return false; 490 return;
485 491
486 const LayoutObject* clippingContainer = m_owningLayer.clippingContainer(); 492 const LayoutObject* clippingContainer = m_owningLayer.clippingContainer();
487 if (!clippingContainer) 493 if (!clippingContainer)
488 return false; 494 return;
489 495
490 if (clippingContainer->enclosingLayer() == scrollParent) 496 if (clippingContainer->enclosingLayer() == scrollParent)
491 return false; 497 return;
492 498
493 if (clippingContainer->enclosingLayer()->hasRootScrollerAsDescendant()) 499 if (clippingContainer->enclosingLayer()->hasRootScrollerAsDescendant())
494 return false; 500 return;
495 501
496 if (compositingAncestor->layoutObject()->isDescendantOf(clippingContainer)) 502 if (compositingAncestor->layoutObject()->isDescendantOf(clippingContainer))
497 return false; 503 return;
498 504
499 // We ignore overflow clip here; we want composited overflow content to 505 // We ignore overflow clip here; we want composited overflow content to
500 // behave as if it lives in an unclipped universe so it can prepaint, etc. 506 // behave as if it lives in an unclipped universe so it can prepaint, etc.
501 // This means that we need to check if we are actually clipped before 507 // This means that we need to check if we are actually clipped before
502 // setting up m_ancestorClippingLayer otherwise 508 // setting up m_ancestorClippingLayer otherwise
503 // updateAncestorClippingLayerGeometry will fail as the clip rect will be 509 // updateAncestorClippingLayerGeometry will fail as the clip rect will be
504 // infinite. 510 // infinite.
505 // FIXME: this should use cached clip rects, but this sometimes give 511 // FIXME: this should use cached clip rects, but this sometimes give
506 // inaccurate results (and trips the ASSERTS in PaintLayerClipper). 512 // inaccurate results (and trips the ASSERTS in PaintLayerClipper).
507 ClipRectsContext clipRectsContext(compositingAncestor, UncachedClipRects, 513 ClipRectsContext clipRectsContext(compositingAncestor, UncachedClipRects,
508 IgnoreOverlayScrollbarSize); 514 IgnoreOverlayScrollbarSize);
509 clipRectsContext.setIgnoreOverflowClip(); 515 clipRectsContext.setIgnoreOverflowClip();
510 IntRect parentClipRect = pixelSnappedIntRect( 516 IntRect parentClipRect = pixelSnappedIntRect(
511 m_owningLayer.clipper().backgroundClipRect(clipRectsContext).rect()); 517 m_owningLayer.clipper().backgroundClipRect(clipRectsContext).rect());
512 return parentClipRect != LayoutRect::infiniteIntRect(); 518 owningLayerIsClipped = parentClipRect != LayoutRect::infiniteIntRect();
519
520 // TODO(schenney): CSS clips are not applied to composited children, and
521 // should be via mask or by compositing the parent too.
522 // https://bugs.chromium.org/p/chromium/issues/detail?id=615870
523 DCHECK(clippingContainer->style());
524 owningLayerIsMasked =
525 owningLayerIsClipped && clippingContainer->style()->hasBorderRadius();
513 } 526 }
514 527
515 const PaintLayer* CompositedLayerMapping::scrollParent() { 528 const PaintLayer* CompositedLayerMapping::scrollParent() {
516 const PaintLayer* scrollParent = m_owningLayer.scrollParent(); 529 const PaintLayer* scrollParent = m_owningLayer.scrollParent();
517 if (scrollParent && !scrollParent->needsCompositedScrolling()) 530 if (scrollParent && !scrollParent->needsCompositedScrolling())
518 return nullptr; 531 return nullptr;
519 return scrollParent; 532 return scrollParent;
520 } 533 }
521 534
522 bool CompositedLayerMapping::updateGraphicsLayerConfiguration() { 535 bool CompositedLayerMapping::updateGraphicsLayerConfiguration() {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 needsDescendantsClippingLayer = false; 571 needsDescendantsClippingLayer = false;
559 572
560 const PaintLayer* scrollParent = this->scrollParent(); 573 const PaintLayer* scrollParent = this->scrollParent();
561 574
562 // This is required because compositing layers are parented according to the 575 // This is required because compositing layers are parented according to the
563 // z-order hierarchy, yet clipping goes down the layoutObject hierarchy. Thus, 576 // z-order hierarchy, yet clipping goes down the layoutObject hierarchy. Thus,
564 // a PaintLayer can be clipped by a PaintLayer that is an ancestor in the 577 // a PaintLayer can be clipped by a PaintLayer that is an ancestor in the
565 // layoutObject hierarchy, but a sibling in the z-order hierarchy. Further, 578 // layoutObject hierarchy, but a sibling in the z-order hierarchy. Further,
566 // that sibling need not be composited at all. In such scenarios, an ancestor 579 // that sibling need not be composited at all. In such scenarios, an ancestor
567 // clipping layer is necessary to apply the composited clip for this layer. 580 // clipping layer is necessary to apply the composited clip for this layer.
568 bool needsAncestorClip = 581 bool needsAncestorClip = false;
569 owningLayerClippedByLayerNotAboveCompositedAncestor(scrollParent); 582 bool needsAncestorClippingMask = false;
570 583 owningLayerClippedOrMaskedByLayerNotAboveCompositedAncestor(
571 if (updateClippingLayers(needsAncestorClip, needsDescendantsClippingLayer)) 584 scrollParent, needsAncestorClip, needsAncestorClippingMask);
585 if (updateClippingLayers(needsAncestorClip, needsAncestorClippingMask,
586 needsDescendantsClippingLayer))
572 layerConfigChanged = true; 587 layerConfigChanged = true;
573 588
574 bool scrollingConfigChanged = false; 589 bool scrollingConfigChanged = false;
575 if (updateScrollingLayers(m_owningLayer.needsCompositedScrolling())) { 590 if (updateScrollingLayers(m_owningLayer.needsCompositedScrolling())) {
576 layerConfigChanged = true; 591 layerConfigChanged = true;
577 scrollingConfigChanged = true; 592 scrollingConfigChanged = true;
578 } 593 }
579 594
580 // If the outline needs to draw over the composited scrolling contents layer 595 // If the outline needs to draw over the composited scrolling contents layer
581 // or scrollbar layers it needs to be drawn into a separate layer. 596 // or scrollbar layers it needs to be drawn into a separate layer.
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 m_ancestorClippingLayer->setPosition( 1108 m_ancestorClippingLayer->setPosition(
1094 FloatPoint(parentClipRect.location() - graphicsLayerParentLocation)); 1109 FloatPoint(parentClipRect.location() - graphicsLayerParentLocation));
1095 m_ancestorClippingLayer->setSize(FloatSize(parentClipRect.size())); 1110 m_ancestorClippingLayer->setSize(FloatSize(parentClipRect.size()));
1096 1111
1097 // backgroundRect is relative to compositingContainer, so subtract 1112 // backgroundRect is relative to compositingContainer, so subtract
1098 // snappedOffsetFromCompositedAncestor.X/snappedOffsetFromCompositedAncestor.Y 1113 // snappedOffsetFromCompositedAncestor.X/snappedOffsetFromCompositedAncestor.Y
1099 // to get back to local coords. 1114 // to get back to local coords.
1100 m_ancestorClippingLayer->setOffsetFromLayoutObject( 1115 m_ancestorClippingLayer->setOffsetFromLayoutObject(
1101 parentClipRect.location() - snappedOffsetFromCompositedAncestor); 1116 parentClipRect.location() - snappedOffsetFromCompositedAncestor);
1102 1117
1118 if (m_ancestorClippingMaskLayer) {
1119 m_ancestorClippingMaskLayer->setOffsetFromLayoutObject(
1120 m_ancestorClippingLayer->offsetFromLayoutObject());
1121 m_ancestorClippingMaskLayer->setSize(m_ancestorClippingLayer->size());
1122 m_ancestorClippingMaskLayer->setNeedsDisplay();
1123 }
1124
1103 // The primary layer is then parented in, and positioned relative to this 1125 // The primary layer is then parented in, and positioned relative to this
1104 // clipping layer. 1126 // clipping layer.
1105 graphicsLayerParentLocation = parentClipRect.location(); 1127 graphicsLayerParentLocation = parentClipRect.location();
1106 } 1128 }
1107 1129
1108 void CompositedLayerMapping::updateOverflowControlsHostLayerGeometry( 1130 void CompositedLayerMapping::updateOverflowControlsHostLayerGeometry(
1109 const PaintLayer* compositingStackingContext, 1131 const PaintLayer* compositingStackingContext,
1110 const PaintLayer* compositingContainer, 1132 const PaintLayer* compositingContainer,
1111 IntPoint graphicsLayerParentLocation) { 1133 IntPoint graphicsLayerParentLocation) {
1112 if (!m_overflowControlsHostLayer) 1134 if (!m_overflowControlsHostLayer)
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 // layer (i.e. if there is nothing actually drawn into the 1666 // layer (i.e. if there is nothing actually drawn into the
1645 // background anymore.) 1667 // background anymore.)
1646 // "hasPaintedContent" should be calculated in a way that does not take the 1668 // "hasPaintedContent" should be calculated in a way that does not take the
1647 // outline into consideration. 1669 // outline into consideration.
1648 if (m_backgroundLayer) 1670 if (m_backgroundLayer)
1649 m_backgroundLayer->setDrawsContent(hasPaintedContent); 1671 m_backgroundLayer->setDrawsContent(hasPaintedContent);
1650 1672
1651 if (m_decorationOutlineLayer) 1673 if (m_decorationOutlineLayer)
1652 m_decorationOutlineLayer->setDrawsContent(true); 1674 m_decorationOutlineLayer->setDrawsContent(true);
1653 1675
1676 if (m_ancestorClippingMaskLayer)
1677 m_ancestorClippingMaskLayer->setDrawsContent(true);
1678
1654 if (m_maskLayer) 1679 if (m_maskLayer)
1655 m_maskLayer->setDrawsContent(true); 1680 m_maskLayer->setDrawsContent(true);
1656 1681
1657 if (m_childClippingMaskLayer) 1682 if (m_childClippingMaskLayer)
1658 m_childClippingMaskLayer->setDrawsContent(true); 1683 m_childClippingMaskLayer->setDrawsContent(true);
1659 } 1684 }
1660 1685
1661 void CompositedLayerMapping::updateChildrenTransform() { 1686 void CompositedLayerMapping::updateChildrenTransform() {
1662 if (GraphicsLayer* childTransformLayer = this->childTransformLayer()) { 1687 if (GraphicsLayer* childTransformLayer = this->childTransformLayer()) {
1663 childTransformLayer->setTransform(owningLayer().perspectiveTransform()); 1688 childTransformLayer->setTransform(owningLayer().perspectiveTransform());
1664 childTransformLayer->setTransformOrigin(owningLayer().perspectiveOrigin()); 1689 childTransformLayer->setTransformOrigin(owningLayer().perspectiveOrigin());
1665 } 1690 }
1666 1691
1667 updateShouldFlattenTransform(); 1692 updateShouldFlattenTransform();
1668 } 1693 }
1669 1694
1670 // Return true if the layers changed. 1695 // Return true if the layers changed.
1671 bool CompositedLayerMapping::updateClippingLayers(bool needsAncestorClip, 1696 bool CompositedLayerMapping::updateClippingLayers(
1672 bool needsDescendantClip) { 1697 bool needsAncestorClip,
1698 bool needsAncestorClippingMask,
1699 bool needsDescendantClip) {
1673 bool layersChanged = false; 1700 bool layersChanged = false;
1674 1701
1675 if (needsAncestorClip) { 1702 if (needsAncestorClip) {
1676 if (!m_ancestorClippingLayer) { 1703 if (!m_ancestorClippingLayer) {
1677 m_ancestorClippingLayer = 1704 m_ancestorClippingLayer =
1678 createGraphicsLayer(CompositingReasonLayerForAncestorClip); 1705 createGraphicsLayer(CompositingReasonLayerForAncestorClip);
1679 m_ancestorClippingLayer->setMasksToBounds(true); 1706 m_ancestorClippingLayer->setMasksToBounds(true);
1680 m_ancestorClippingLayer->setShouldFlattenTransform(false); 1707 m_ancestorClippingLayer->setShouldFlattenTransform(false);
1681 layersChanged = true; 1708 layersChanged = true;
1682 } 1709 }
1683 } else if (m_ancestorClippingLayer) { 1710 } else if (m_ancestorClippingLayer) {
1711 if (m_ancestorClippingMaskLayer) {
1712 m_ancestorClippingMaskLayer->removeFromParent();
1713 m_ancestorClippingMaskLayer = nullptr;
1714 }
1684 m_ancestorClippingLayer->removeFromParent(); 1715 m_ancestorClippingLayer->removeFromParent();
1685 m_ancestorClippingLayer = nullptr; 1716 m_ancestorClippingLayer = nullptr;
1686 layersChanged = true; 1717 layersChanged = true;
1687 } 1718 }
1688 1719
1720 if (needsAncestorClippingMask) {
1721 DCHECK(m_ancestorClippingLayer);
1722 if (!m_ancestorClippingMaskLayer) {
1723 m_ancestorClippingMaskLayer =
1724 createGraphicsLayer(CompositingReasonLayerForAncestorClippingMask);
1725 m_ancestorClippingMaskLayer->setPaintingPhase(
1726 GraphicsLayerPaintAncestorClippingMask);
1727 m_ancestorClippingLayer->setMaskLayer(m_ancestorClippingMaskLayer.get());
1728 layersChanged = true;
1729 }
1730 } else if (m_ancestorClippingMaskLayer) {
1731 m_ancestorClippingMaskLayer->removeFromParent();
1732 m_ancestorClippingMaskLayer = nullptr;
1733 m_ancestorClippingLayer->setMaskLayer(nullptr);
1734 layersChanged = true;
1735 }
1736
1689 if (needsDescendantClip) { 1737 if (needsDescendantClip) {
1690 // We don't need a child containment layer if we're the main frame layout 1738 // We don't need a child containment layer if we're the main frame layout
1691 // view layer. It's redundant as the frame clip above us will handle this 1739 // view layer. It's redundant as the frame clip above us will handle this
1692 // clipping. 1740 // clipping.
1693 if (!m_childContainmentLayer && !m_isMainFrameLayoutViewLayer) { 1741 if (!m_childContainmentLayer && !m_isMainFrameLayoutViewLayer) {
1694 m_childContainmentLayer = 1742 m_childContainmentLayer =
1695 createGraphicsLayer(CompositingReasonLayerForDescendantClip); 1743 createGraphicsLayer(CompositingReasonLayerForDescendantClip);
1696 m_childContainmentLayer->setMasksToBounds(true); 1744 m_childContainmentLayer->setMasksToBounds(true);
1697 layersChanged = true; 1745 layersChanged = true;
1698 } 1746 }
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 f(mapping->squashingLayer()); 1956 f(mapping->squashingLayer());
1909 1957
1910 if (((mode & ApplyToMaskLayers) || (mode & ApplyToContentLayers) || 1958 if (((mode & ApplyToMaskLayers) || (mode & ApplyToContentLayers) ||
1911 (mode & ApplyToNonScrollingContentLayers)) && 1959 (mode & ApplyToNonScrollingContentLayers)) &&
1912 mapping->maskLayer()) 1960 mapping->maskLayer())
1913 f(mapping->maskLayer()); 1961 f(mapping->maskLayer());
1914 if (((mode & ApplyToMaskLayers) || (mode & ApplyToContentLayers) || 1962 if (((mode & ApplyToMaskLayers) || (mode & ApplyToContentLayers) ||
1915 (mode & ApplyToNonScrollingContentLayers)) && 1963 (mode & ApplyToNonScrollingContentLayers)) &&
1916 mapping->childClippingMaskLayer()) 1964 mapping->childClippingMaskLayer())
1917 f(mapping->childClippingMaskLayer()); 1965 f(mapping->childClippingMaskLayer());
1966 if (((mode & ApplyToMaskLayers) || (mode & ApplyToContentLayers) ||
1967 (mode & ApplyToNonScrollingContentLayers)) &&
1968 mapping->ancestorClippingMaskLayer())
1969 f(mapping->ancestorClippingMaskLayer());
1918 1970
1919 if (((mode & ApplyToBackgroundLayer) || (mode & ApplyToContentLayers) || 1971 if (((mode & ApplyToBackgroundLayer) || (mode & ApplyToContentLayers) ||
1920 (mode & ApplyToNonScrollingContentLayers)) && 1972 (mode & ApplyToNonScrollingContentLayers)) &&
1921 mapping->backgroundLayer()) 1973 mapping->backgroundLayer())
1922 f(mapping->backgroundLayer()); 1974 f(mapping->backgroundLayer());
1923 1975
1924 if ((mode & ApplyToScrollbarLayers) && mapping->layerForHorizontalScrollbar()) 1976 if ((mode & ApplyToScrollbarLayers) && mapping->layerForHorizontalScrollbar())
1925 f(mapping->layerForHorizontalScrollbar()); 1977 f(mapping->layerForHorizontalScrollbar());
1926 if ((mode & ApplyToScrollbarLayers) && mapping->layerForVerticalScrollbar()) 1978 if ((mode & ApplyToScrollbarLayers) && mapping->layerForVerticalScrollbar())
1927 f(mapping->layerForVerticalScrollbar()); 1979 f(mapping->layerForVerticalScrollbar());
(...skipping 15 matching lines...) Expand all
1943 1995
1944 void CompositedLayerMapping::updateRenderingContext() { 1996 void CompositedLayerMapping::updateRenderingContext() {
1945 // All layers but the squashing layer (which contains 'alien' content) should 1997 // All layers but the squashing layer (which contains 'alien' content) should
1946 // be included in this rendering context. 1998 // be included in this rendering context.
1947 int id = 0; 1999 int id = 0;
1948 2000
1949 // NB, it is illegal at this point to query an ancestor's compositing state. 2001 // NB, it is illegal at this point to query an ancestor's compositing state.
1950 // Some compositing reasons depend on the compositing state of ancestors. So 2002 // Some compositing reasons depend on the compositing state of ancestors. So
1951 // if we want a rendering context id for the context root, we cannot ask for 2003 // if we want a rendering context id for the context root, we cannot ask for
1952 // the id of its associated WebLayer now; it may not have one yet. We could do 2004 // the id of its associated WebLayer now; it may not have one yet. We could do
1953 // a second past after doing the compositing updates to get these ids, but 2005 // a second pass after doing the compositing updates to get these ids, but
1954 // this would actually be harmful. We do not want to attach any semantic 2006 // this would actually be harmful. We do not want to attach any semantic
1955 // meaning to the context id other than the fact that they group a number of 2007 // meaning to the context id other than the fact that they group a number of
1956 // layers together for the sake of 3d sorting. So instead we will ask the 2008 // layers together for the sake of 3d sorting. So instead we will ask the
1957 // compositor to vend us an arbitrary, but consistent id. 2009 // compositor to vend us an arbitrary, but consistent id.
1958 if (PaintLayer* root = m_owningLayer.renderingContextRoot()) { 2010 if (PaintLayer* root = m_owningLayer.renderingContextRoot()) {
1959 if (Node* node = root->layoutObject()->node()) 2011 if (Node* node = root->layoutObject()->node())
1960 id = static_cast<int>(PtrHash<Node>::hash(node)); 2012 id = static_cast<int>(PtrHash<Node>::hash(node));
1961 } 2013 }
1962 2014
1963 UpdateRenderingContextFunctor functor = {id}; 2015 UpdateRenderingContextFunctor functor = {id};
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
2247 // Only the topmost layer has a scroll parent. All other layers have a null 2299 // Only the topmost layer has a scroll parent. All other layers have a null
2248 // scroll parent. 2300 // scroll parent.
2249 if (layer != topmostLayer) 2301 if (layer != topmostLayer)
2250 clipParent = 0; 2302 clipParent = 0;
2251 2303
2252 scrollingCoordinator->updateClipParentForGraphicsLayer(layer, clipParent); 2304 scrollingCoordinator->updateClipParentForGraphicsLayer(layer, clipParent);
2253 } 2305 }
2254 2306
2255 void CompositedLayerMapping::updateClipParent(const PaintLayer* scrollParent) { 2307 void CompositedLayerMapping::updateClipParent(const PaintLayer* scrollParent) {
2256 const PaintLayer* clipParent = nullptr; 2308 const PaintLayer* clipParent = nullptr;
2257 if (!owningLayerClippedByLayerNotAboveCompositedAncestor(scrollParent)) { 2309 bool haveAncestorClipLayer = false;
2310 bool haveAncestorMaskLayer = false;
2311 owningLayerClippedOrMaskedByLayerNotAboveCompositedAncestor(
2312 scrollParent, haveAncestorClipLayer, haveAncestorMaskLayer);
2313 if (!haveAncestorClipLayer) {
2258 clipParent = m_owningLayer.clipParent(); 2314 clipParent = m_owningLayer.clipParent();
2259 if (clipParent) 2315 if (clipParent)
2260 clipParent = 2316 clipParent =
2261 clipParent->enclosingLayerWithCompositedLayerMapping(IncludeSelf); 2317 clipParent->enclosingLayerWithCompositedLayerMapping(IncludeSelf);
2262 } 2318 }
2263 2319
2264 if (ScrollingCoordinator* scrollingCoordinator = 2320 if (ScrollingCoordinator* scrollingCoordinator =
2265 scrollingCoordinatorFromLayer(m_owningLayer)) { 2321 scrollingCoordinatorFromLayer(m_owningLayer)) {
2266 GraphicsLayer* topmostLayer = childForSuperlayers(); 2322 GraphicsLayer* topmostLayer = childForSuperlayers();
2267 updateClipParentForGraphicsLayer(m_squashingContainmentLayer.get(), 2323 updateClipParentForGraphicsLayer(m_squashingContainmentLayer.get(),
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
2787 translation.translate(-offset.width(), -offset.height()); 2843 translation.translate(-offset.width(), -offset.height());
2788 TransformRecorder transformRecorder(context, graphicsLayer, translation); 2844 TransformRecorder transformRecorder(context, graphicsLayer, translation);
2789 2845
2790 // The dirtyRect is in the coords of the painting root. 2846 // The dirtyRect is in the coords of the painting root.
2791 IntRect dirtyRect(clip); 2847 IntRect dirtyRect(clip);
2792 dirtyRect.move(offset); 2848 dirtyRect.move(offset);
2793 2849
2794 if (!(paintLayerFlags & PaintLayerPaintingOverflowContents)) { 2850 if (!(paintLayerFlags & PaintLayerPaintingOverflowContents)) {
2795 LayoutRect bounds = paintInfo.compositedBounds; 2851 LayoutRect bounds = paintInfo.compositedBounds;
2796 bounds.move(paintInfo.paintLayer->subpixelAccumulation()); 2852 bounds.move(paintInfo.paintLayer->subpixelAccumulation());
2853 if (paintLayerFlags & PaintLayerPaintingAncestorClippingMaskPhase)
2854 bounds.move(offset);
2797 dirtyRect.intersect(pixelSnappedIntRect(bounds)); 2855 dirtyRect.intersect(pixelSnappedIntRect(bounds));
2798 } else { 2856 } else {
2799 dirtyRect.move( 2857 dirtyRect.move(
2800 roundedIntSize(paintInfo.paintLayer->subpixelAccumulation())); 2858 roundedIntSize(paintInfo.paintLayer->subpixelAccumulation()));
2801 } 2859 }
2802 2860
2803 #if DCHECK_IS_ON() 2861 #if DCHECK_IS_ON()
2804 if (!layoutObject()->view()->frame() || 2862 if (!layoutObject()->view()->frame() ||
2805 !layoutObject()->view()->frame()->shouldThrottleRendering()) 2863 !layoutObject()->view()->frame()->shouldThrottleRendering())
2806 paintInfo.paintLayer->layoutObject()->assertSubtreeIsLaidOut(); 2864 paintInfo.paintLayer->layoutObject()->assertSubtreeIsLaidOut();
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
3064 if (graphicsLayerPaintingPhase & GraphicsLayerPaintBackground) 3122 if (graphicsLayerPaintingPhase & GraphicsLayerPaintBackground)
3065 paintLayerFlags |= PaintLayerPaintingCompositingBackgroundPhase; 3123 paintLayerFlags |= PaintLayerPaintingCompositingBackgroundPhase;
3066 else 3124 else
3067 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; 3125 paintLayerFlags |= PaintLayerPaintingSkipRootBackground;
3068 if (graphicsLayerPaintingPhase & GraphicsLayerPaintForeground) 3126 if (graphicsLayerPaintingPhase & GraphicsLayerPaintForeground)
3069 paintLayerFlags |= PaintLayerPaintingCompositingForegroundPhase; 3127 paintLayerFlags |= PaintLayerPaintingCompositingForegroundPhase;
3070 if (graphicsLayerPaintingPhase & GraphicsLayerPaintMask) 3128 if (graphicsLayerPaintingPhase & GraphicsLayerPaintMask)
3071 paintLayerFlags |= PaintLayerPaintingCompositingMaskPhase; 3129 paintLayerFlags |= PaintLayerPaintingCompositingMaskPhase;
3072 if (graphicsLayerPaintingPhase & GraphicsLayerPaintChildClippingMask) 3130 if (graphicsLayerPaintingPhase & GraphicsLayerPaintChildClippingMask)
3073 paintLayerFlags |= PaintLayerPaintingChildClippingMaskPhase; 3131 paintLayerFlags |= PaintLayerPaintingChildClippingMaskPhase;
3132 if (graphicsLayerPaintingPhase & GraphicsLayerPaintAncestorClippingMask)
3133 paintLayerFlags |= PaintLayerPaintingAncestorClippingMaskPhase;
3074 if (graphicsLayerPaintingPhase & GraphicsLayerPaintOverflowContents) 3134 if (graphicsLayerPaintingPhase & GraphicsLayerPaintOverflowContents)
3075 paintLayerFlags |= PaintLayerPaintingOverflowContents; 3135 paintLayerFlags |= PaintLayerPaintingOverflowContents;
3076 if (graphicsLayerPaintingPhase & GraphicsLayerPaintCompositedScroll) 3136 if (graphicsLayerPaintingPhase & GraphicsLayerPaintCompositedScroll)
3077 paintLayerFlags |= PaintLayerPaintingCompositingScrollingPhase; 3137 paintLayerFlags |= PaintLayerPaintingCompositingScrollingPhase;
3078 if (graphicsLayerPaintingPhase & GraphicsLayerPaintDecoration) 3138 if (graphicsLayerPaintingPhase & GraphicsLayerPaintDecoration)
3079 paintLayerFlags |= PaintLayerPaintingCompositingDecorationPhase; 3139 paintLayerFlags |= PaintLayerPaintingCompositingDecorationPhase;
3080 3140
3081 if (graphicsLayer == m_backgroundLayer.get()) 3141 if (graphicsLayer == m_backgroundLayer.get())
3082 paintLayerFlags |= PaintLayerPaintingRootBackgroundOnly; 3142 paintLayerFlags |= PaintLayerPaintingRootBackgroundOnly;
3083 else if (compositor()->fixedRootBackgroundLayer() && 3143 else if (compositor()->fixedRootBackgroundLayer() &&
3084 m_owningLayer.isRootLayer()) 3144 m_owningLayer.isRootLayer())
3085 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; 3145 paintLayerFlags |= PaintLayerPaintingSkipRootBackground;
3086 3146
3087 if (graphicsLayer == m_graphicsLayer.get() || 3147 if (graphicsLayer == m_graphicsLayer.get() ||
3088 graphicsLayer == m_foregroundLayer.get() || 3148 graphicsLayer == m_foregroundLayer.get() ||
3089 graphicsLayer == m_backgroundLayer.get() || 3149 graphicsLayer == m_backgroundLayer.get() ||
3090 graphicsLayer == m_maskLayer.get() || 3150 graphicsLayer == m_maskLayer.get() ||
3091 graphicsLayer == m_childClippingMaskLayer.get() || 3151 graphicsLayer == m_childClippingMaskLayer.get() ||
3092 graphicsLayer == m_scrollingContentsLayer.get() || 3152 graphicsLayer == m_scrollingContentsLayer.get() ||
3093 graphicsLayer == m_decorationOutlineLayer.get()) { 3153 graphicsLayer == m_decorationOutlineLayer.get() ||
3154 graphicsLayer == m_ancestorClippingMaskLayer.get()) {
3094 bool paintRootBackgroundOntoScrollingContentsLayer = 3155 bool paintRootBackgroundOntoScrollingContentsLayer =
3095 m_backgroundPaintsOntoScrollingContentsLayer; 3156 m_backgroundPaintsOntoScrollingContentsLayer;
3096 DCHECK(!paintRootBackgroundOntoScrollingContentsLayer || 3157 DCHECK(!paintRootBackgroundOntoScrollingContentsLayer ||
3097 (!m_backgroundLayer && !m_foregroundLayer)); 3158 (!m_backgroundLayer && !m_foregroundLayer));
3098 if (paintRootBackgroundOntoScrollingContentsLayer) { 3159 if (paintRootBackgroundOntoScrollingContentsLayer) {
3099 if (graphicsLayer == m_scrollingContentsLayer.get()) 3160 if (graphicsLayer == m_scrollingContentsLayer.get())
3100 paintLayerFlags &= ~PaintLayerPaintingSkipRootBackground; 3161 paintLayerFlags &= ~PaintLayerPaintingSkipRootBackground;
3101 else if (!m_backgroundPaintsOntoGraphicsLayer) 3162 else if (!m_backgroundPaintsOntoGraphicsLayer)
3102 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; 3163 paintLayerFlags |= PaintLayerPaintingSkipRootBackground;
3103 } 3164 }
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
3338 } else if (graphicsLayer == m_squashingContainmentLayer.get()) { 3399 } else if (graphicsLayer == m_squashingContainmentLayer.get()) {
3339 name = "Squashing Containment Layer"; 3400 name = "Squashing Containment Layer";
3340 } else if (graphicsLayer == m_squashingLayer.get()) { 3401 } else if (graphicsLayer == m_squashingLayer.get()) {
3341 name = "Squashing Layer (first squashed layer: " + 3402 name = "Squashing Layer (first squashed layer: " +
3342 (m_squashedLayers.size() > 0 3403 (m_squashedLayers.size() > 0
3343 ? m_squashedLayers[0].paintLayer->debugName() 3404 ? m_squashedLayers[0].paintLayer->debugName()
3344 : "") + 3405 : "") +
3345 ")"; 3406 ")";
3346 } else if (graphicsLayer == m_ancestorClippingLayer.get()) { 3407 } else if (graphicsLayer == m_ancestorClippingLayer.get()) {
3347 name = "Ancestor Clipping Layer"; 3408 name = "Ancestor Clipping Layer";
3409 } else if (graphicsLayer == m_ancestorClippingMaskLayer.get()) {
3410 name = "Ancestor Clipping Mask Layer";
3348 } else if (graphicsLayer == m_foregroundLayer.get()) { 3411 } else if (graphicsLayer == m_foregroundLayer.get()) {
3349 name = m_owningLayer.debugName() + " (foreground) Layer"; 3412 name = m_owningLayer.debugName() + " (foreground) Layer";
3350 } else if (graphicsLayer == m_backgroundLayer.get()) { 3413 } else if (graphicsLayer == m_backgroundLayer.get()) {
3351 name = m_owningLayer.debugName() + " (background) Layer"; 3414 name = m_owningLayer.debugName() + " (background) Layer";
3352 } else if (graphicsLayer == m_childContainmentLayer.get()) { 3415 } else if (graphicsLayer == m_childContainmentLayer.get()) {
3353 name = "Child Containment Layer"; 3416 name = "Child Containment Layer";
3354 } else if (graphicsLayer == m_childTransformLayer.get()) { 3417 } else if (graphicsLayer == m_childTransformLayer.get()) {
3355 name = "Child Transform Layer"; 3418 name = "Child Transform Layer";
3356 } else if (graphicsLayer == m_maskLayer.get()) { 3419 } else if (graphicsLayer == m_maskLayer.get()) {
3357 name = "Mask Layer"; 3420 name = "Mask Layer";
(...skipping 16 matching lines...) Expand all
3374 } else if (graphicsLayer == m_decorationOutlineLayer.get()) { 3437 } else if (graphicsLayer == m_decorationOutlineLayer.get()) {
3375 name = "Decoration Layer"; 3438 name = "Decoration Layer";
3376 } else { 3439 } else {
3377 ASSERT_NOT_REACHED(); 3440 ASSERT_NOT_REACHED();
3378 } 3441 }
3379 3442
3380 return name; 3443 return name;
3381 } 3444 }
3382 3445
3383 } // namespace blink 3446 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698