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

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

Issue 2588853002: Fix border radius on composited children. (Closed)
Patch Set: New baselines Created 3 years, 11 months 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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 // layer (i.e. if there is nothing actually drawn into the 1673 // layer (i.e. if there is nothing actually drawn into the
1652 // background anymore.) 1674 // background anymore.)
1653 // "hasPaintedContent" should be calculated in a way that does not take the 1675 // "hasPaintedContent" should be calculated in a way that does not take the
1654 // outline into consideration. 1676 // outline into consideration.
1655 if (m_backgroundLayer) 1677 if (m_backgroundLayer)
1656 m_backgroundLayer->setDrawsContent(hasPaintedContent); 1678 m_backgroundLayer->setDrawsContent(hasPaintedContent);
1657 1679
1658 if (m_decorationOutlineLayer) 1680 if (m_decorationOutlineLayer)
1659 m_decorationOutlineLayer->setDrawsContent(true); 1681 m_decorationOutlineLayer->setDrawsContent(true);
1660 1682
1683 if (m_ancestorClippingMaskLayer)
1684 m_ancestorClippingMaskLayer->setDrawsContent(true);
1685
1661 if (m_maskLayer) 1686 if (m_maskLayer)
1662 m_maskLayer->setDrawsContent(true); 1687 m_maskLayer->setDrawsContent(true);
1663 1688
1664 if (m_childClippingMaskLayer) 1689 if (m_childClippingMaskLayer)
1665 m_childClippingMaskLayer->setDrawsContent(true); 1690 m_childClippingMaskLayer->setDrawsContent(true);
1666 } 1691 }
1667 1692
1668 void CompositedLayerMapping::updateChildrenTransform() { 1693 void CompositedLayerMapping::updateChildrenTransform() {
1669 if (GraphicsLayer* childTransformLayer = this->childTransformLayer()) { 1694 if (GraphicsLayer* childTransformLayer = this->childTransformLayer()) {
1670 childTransformLayer->setTransform(owningLayer().perspectiveTransform()); 1695 childTransformLayer->setTransform(owningLayer().perspectiveTransform());
1671 childTransformLayer->setTransformOrigin(owningLayer().perspectiveOrigin()); 1696 childTransformLayer->setTransformOrigin(owningLayer().perspectiveOrigin());
1672 } 1697 }
1673 1698
1674 updateShouldFlattenTransform(); 1699 updateShouldFlattenTransform();
1675 } 1700 }
1676 1701
1677 // Return true if the layers changed. 1702 // Return true if the layers changed.
1678 bool CompositedLayerMapping::updateClippingLayers(bool needsAncestorClip, 1703 bool CompositedLayerMapping::updateClippingLayers(
1679 bool needsDescendantClip) { 1704 bool needsAncestorClip,
1705 bool needsAncestorClippingMask,
1706 bool needsDescendantClip) {
1680 bool layersChanged = false; 1707 bool layersChanged = false;
1681 1708
1682 if (needsAncestorClip) { 1709 if (needsAncestorClip) {
1683 if (!m_ancestorClippingLayer) { 1710 if (!m_ancestorClippingLayer) {
1684 m_ancestorClippingLayer = 1711 m_ancestorClippingLayer =
1685 createGraphicsLayer(CompositingReasonLayerForAncestorClip); 1712 createGraphicsLayer(CompositingReasonLayerForAncestorClip);
1686 m_ancestorClippingLayer->setMasksToBounds(true); 1713 m_ancestorClippingLayer->setMasksToBounds(true);
1687 m_ancestorClippingLayer->setShouldFlattenTransform(false); 1714 m_ancestorClippingLayer->setShouldFlattenTransform(false);
1688 layersChanged = true; 1715 layersChanged = true;
1689 } 1716 }
1690 } else if (m_ancestorClippingLayer) { 1717 } else if (m_ancestorClippingLayer) {
1718 if (m_ancestorClippingMaskLayer) {
1719 m_ancestorClippingMaskLayer->removeFromParent();
1720 m_ancestorClippingMaskLayer = nullptr;
1721 }
1691 m_ancestorClippingLayer->removeFromParent(); 1722 m_ancestorClippingLayer->removeFromParent();
1692 m_ancestorClippingLayer = nullptr; 1723 m_ancestorClippingLayer = nullptr;
1693 layersChanged = true; 1724 layersChanged = true;
1694 } 1725 }
1695 1726
1727 if (needsAncestorClippingMask) {
1728 DCHECK(m_ancestorClippingLayer);
1729 if (!m_ancestorClippingMaskLayer) {
1730 m_ancestorClippingMaskLayer =
1731 createGraphicsLayer(CompositingReasonLayerForAncestorClippingMask);
1732 m_ancestorClippingMaskLayer->setPaintingPhase(
1733 GraphicsLayerPaintAncestorClippingMask);
1734 m_ancestorClippingLayer->setMaskLayer(m_ancestorClippingMaskLayer.get());
1735 layersChanged = true;
1736 }
1737 } else if (m_ancestorClippingMaskLayer) {
1738 m_ancestorClippingMaskLayer->removeFromParent();
1739 m_ancestorClippingMaskLayer = nullptr;
1740 m_ancestorClippingLayer->setMaskLayer(nullptr);
1741 layersChanged = true;
1742 }
1743
1696 if (needsDescendantClip) { 1744 if (needsDescendantClip) {
1697 // We don't need a child containment layer if we're the main frame layout 1745 // We don't need a child containment layer if we're the main frame layout
1698 // view layer. It's redundant as the frame clip above us will handle this 1746 // view layer. It's redundant as the frame clip above us will handle this
1699 // clipping. 1747 // clipping.
1700 if (!m_childContainmentLayer && !m_isMainFrameLayoutViewLayer) { 1748 if (!m_childContainmentLayer && !m_isMainFrameLayoutViewLayer) {
1701 m_childContainmentLayer = 1749 m_childContainmentLayer =
1702 createGraphicsLayer(CompositingReasonLayerForDescendantClip); 1750 createGraphicsLayer(CompositingReasonLayerForDescendantClip);
1703 m_childContainmentLayer->setMasksToBounds(true); 1751 m_childContainmentLayer->setMasksToBounds(true);
1704 layersChanged = true; 1752 layersChanged = true;
1705 } 1753 }
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 f(mapping->squashingLayer()); 1963 f(mapping->squashingLayer());
1916 1964
1917 if (((mode & ApplyToMaskLayers) || (mode & ApplyToContentLayers) || 1965 if (((mode & ApplyToMaskLayers) || (mode & ApplyToContentLayers) ||
1918 (mode & ApplyToNonScrollingContentLayers)) && 1966 (mode & ApplyToNonScrollingContentLayers)) &&
1919 mapping->maskLayer()) 1967 mapping->maskLayer())
1920 f(mapping->maskLayer()); 1968 f(mapping->maskLayer());
1921 if (((mode & ApplyToMaskLayers) || (mode & ApplyToContentLayers) || 1969 if (((mode & ApplyToMaskLayers) || (mode & ApplyToContentLayers) ||
1922 (mode & ApplyToNonScrollingContentLayers)) && 1970 (mode & ApplyToNonScrollingContentLayers)) &&
1923 mapping->childClippingMaskLayer()) 1971 mapping->childClippingMaskLayer())
1924 f(mapping->childClippingMaskLayer()); 1972 f(mapping->childClippingMaskLayer());
1973 if (((mode & ApplyToMaskLayers) || (mode & ApplyToContentLayers) ||
1974 (mode & ApplyToNonScrollingContentLayers)) &&
1975 mapping->ancestorClippingMaskLayer())
1976 f(mapping->ancestorClippingMaskLayer());
1925 1977
1926 if (((mode & ApplyToBackgroundLayer) || (mode & ApplyToContentLayers) || 1978 if (((mode & ApplyToBackgroundLayer) || (mode & ApplyToContentLayers) ||
1927 (mode & ApplyToNonScrollingContentLayers)) && 1979 (mode & ApplyToNonScrollingContentLayers)) &&
1928 mapping->backgroundLayer()) 1980 mapping->backgroundLayer())
1929 f(mapping->backgroundLayer()); 1981 f(mapping->backgroundLayer());
1930 1982
1931 if ((mode & ApplyToScrollbarLayers) && mapping->layerForHorizontalScrollbar()) 1983 if ((mode & ApplyToScrollbarLayers) && mapping->layerForHorizontalScrollbar())
1932 f(mapping->layerForHorizontalScrollbar()); 1984 f(mapping->layerForHorizontalScrollbar());
1933 if ((mode & ApplyToScrollbarLayers) && mapping->layerForVerticalScrollbar()) 1985 if ((mode & ApplyToScrollbarLayers) && mapping->layerForVerticalScrollbar())
1934 f(mapping->layerForVerticalScrollbar()); 1986 f(mapping->layerForVerticalScrollbar());
(...skipping 15 matching lines...) Expand all
1950 2002
1951 void CompositedLayerMapping::updateRenderingContext() { 2003 void CompositedLayerMapping::updateRenderingContext() {
1952 // All layers but the squashing layer (which contains 'alien' content) should 2004 // All layers but the squashing layer (which contains 'alien' content) should
1953 // be included in this rendering context. 2005 // be included in this rendering context.
1954 int id = 0; 2006 int id = 0;
1955 2007
1956 // NB, it is illegal at this point to query an ancestor's compositing state. 2008 // NB, it is illegal at this point to query an ancestor's compositing state.
1957 // Some compositing reasons depend on the compositing state of ancestors. So 2009 // Some compositing reasons depend on the compositing state of ancestors. So
1958 // if we want a rendering context id for the context root, we cannot ask for 2010 // if we want a rendering context id for the context root, we cannot ask for
1959 // the id of its associated WebLayer now; it may not have one yet. We could do 2011 // the id of its associated WebLayer now; it may not have one yet. We could do
1960 // a second past after doing the compositing updates to get these ids, but 2012 // a second pass after doing the compositing updates to get these ids, but
1961 // this would actually be harmful. We do not want to attach any semantic 2013 // this would actually be harmful. We do not want to attach any semantic
1962 // meaning to the context id other than the fact that they group a number of 2014 // meaning to the context id other than the fact that they group a number of
1963 // layers together for the sake of 3d sorting. So instead we will ask the 2015 // layers together for the sake of 3d sorting. So instead we will ask the
1964 // compositor to vend us an arbitrary, but consistent id. 2016 // compositor to vend us an arbitrary, but consistent id.
1965 if (PaintLayer* root = m_owningLayer.renderingContextRoot()) { 2017 if (PaintLayer* root = m_owningLayer.renderingContextRoot()) {
1966 if (Node* node = root->layoutObject()->node()) 2018 if (Node* node = root->layoutObject()->node())
1967 id = static_cast<int>(PtrHash<Node>::hash(node)); 2019 id = static_cast<int>(PtrHash<Node>::hash(node));
1968 } 2020 }
1969 2021
1970 UpdateRenderingContextFunctor functor = {id}; 2022 UpdateRenderingContextFunctor functor = {id};
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 // Only the topmost layer has a scroll parent. All other layers have a null 2306 // Only the topmost layer has a scroll parent. All other layers have a null
2255 // scroll parent. 2307 // scroll parent.
2256 if (layer != topmostLayer) 2308 if (layer != topmostLayer)
2257 clipParent = 0; 2309 clipParent = 0;
2258 2310
2259 scrollingCoordinator->updateClipParentForGraphicsLayer(layer, clipParent); 2311 scrollingCoordinator->updateClipParentForGraphicsLayer(layer, clipParent);
2260 } 2312 }
2261 2313
2262 void CompositedLayerMapping::updateClipParent(const PaintLayer* scrollParent) { 2314 void CompositedLayerMapping::updateClipParent(const PaintLayer* scrollParent) {
2263 const PaintLayer* clipParent = nullptr; 2315 const PaintLayer* clipParent = nullptr;
2264 if (!owningLayerClippedByLayerNotAboveCompositedAncestor(scrollParent)) { 2316 bool haveAncestorClipLayer = false;
2317 bool haveAncestorMaskLayer = false;
2318 owningLayerClippedOrMaskedByLayerNotAboveCompositedAncestor(
2319 scrollParent, haveAncestorClipLayer, haveAncestorMaskLayer);
2320 if (!haveAncestorClipLayer) {
2265 clipParent = m_owningLayer.clipParent(); 2321 clipParent = m_owningLayer.clipParent();
2266 if (clipParent) 2322 if (clipParent)
2267 clipParent = 2323 clipParent =
2268 clipParent->enclosingLayerWithCompositedLayerMapping(IncludeSelf); 2324 clipParent->enclosingLayerWithCompositedLayerMapping(IncludeSelf);
2269 } 2325 }
2270 2326
2271 if (ScrollingCoordinator* scrollingCoordinator = 2327 if (ScrollingCoordinator* scrollingCoordinator =
2272 scrollingCoordinatorFromLayer(m_owningLayer)) { 2328 scrollingCoordinatorFromLayer(m_owningLayer)) {
2273 GraphicsLayer* topmostLayer = childForSuperlayers(); 2329 GraphicsLayer* topmostLayer = childForSuperlayers();
2274 updateClipParentForGraphicsLayer(m_squashingContainmentLayer.get(), 2330 updateClipParentForGraphicsLayer(m_squashingContainmentLayer.get(),
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
2791 2847
2792 IntSize offset = paintInfo.offsetFromLayoutObject; 2848 IntSize offset = paintInfo.offsetFromLayoutObject;
2793 AffineTransform translation; 2849 AffineTransform translation;
2794 translation.translate(-offset.width(), -offset.height()); 2850 translation.translate(-offset.width(), -offset.height());
2795 TransformRecorder transformRecorder(context, graphicsLayer, translation); 2851 TransformRecorder transformRecorder(context, graphicsLayer, translation);
2796 2852
2797 // The dirtyRect is in the coords of the painting root. 2853 // The dirtyRect is in the coords of the painting root.
2798 IntRect dirtyRect(clip); 2854 IntRect dirtyRect(clip);
2799 dirtyRect.move(offset); 2855 dirtyRect.move(offset);
2800 2856
2801 if (!(paintLayerFlags & PaintLayerPaintingOverflowContents)) { 2857 if (paintLayerFlags & (PaintLayerPaintingOverflowContents |
2858 PaintLayerPaintingAncestorClippingMaskPhase)) {
2859 dirtyRect.move(
2860 roundedIntSize(paintInfo.paintLayer->subpixelAccumulation()));
Stephen Chennney 2017/01/04 19:22:46 This change is necessary to keep the dirty paint r
2861 } else {
2802 LayoutRect bounds = paintInfo.compositedBounds; 2862 LayoutRect bounds = paintInfo.compositedBounds;
2803 bounds.move(paintInfo.paintLayer->subpixelAccumulation()); 2863 bounds.move(paintInfo.paintLayer->subpixelAccumulation());
2804 dirtyRect.intersect(pixelSnappedIntRect(bounds)); 2864 dirtyRect.intersect(pixelSnappedIntRect(bounds));
2805 } else {
2806 dirtyRect.move(
2807 roundedIntSize(paintInfo.paintLayer->subpixelAccumulation()));
2808 } 2865 }
2809 2866
2810 #if DCHECK_IS_ON() 2867 #if DCHECK_IS_ON()
2811 if (!layoutObject()->view()->frame() || 2868 if (!layoutObject()->view()->frame() ||
2812 !layoutObject()->view()->frame()->shouldThrottleRendering()) 2869 !layoutObject()->view()->frame()->shouldThrottleRendering())
2813 paintInfo.paintLayer->layoutObject()->assertSubtreeIsLaidOut(); 2870 paintInfo.paintLayer->layoutObject()->assertSubtreeIsLaidOut();
2814 #endif 2871 #endif
2815 2872
2816 float deviceScaleFactor = 2873 float deviceScaleFactor =
2817 blink::deviceScaleFactor(paintInfo.paintLayer->layoutObject()->frame()); 2874 blink::deviceScaleFactor(paintInfo.paintLayer->layoutObject()->frame());
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
3071 if (graphicsLayerPaintingPhase & GraphicsLayerPaintBackground) 3128 if (graphicsLayerPaintingPhase & GraphicsLayerPaintBackground)
3072 paintLayerFlags |= PaintLayerPaintingCompositingBackgroundPhase; 3129 paintLayerFlags |= PaintLayerPaintingCompositingBackgroundPhase;
3073 else 3130 else
3074 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; 3131 paintLayerFlags |= PaintLayerPaintingSkipRootBackground;
3075 if (graphicsLayerPaintingPhase & GraphicsLayerPaintForeground) 3132 if (graphicsLayerPaintingPhase & GraphicsLayerPaintForeground)
3076 paintLayerFlags |= PaintLayerPaintingCompositingForegroundPhase; 3133 paintLayerFlags |= PaintLayerPaintingCompositingForegroundPhase;
3077 if (graphicsLayerPaintingPhase & GraphicsLayerPaintMask) 3134 if (graphicsLayerPaintingPhase & GraphicsLayerPaintMask)
3078 paintLayerFlags |= PaintLayerPaintingCompositingMaskPhase; 3135 paintLayerFlags |= PaintLayerPaintingCompositingMaskPhase;
3079 if (graphicsLayerPaintingPhase & GraphicsLayerPaintChildClippingMask) 3136 if (graphicsLayerPaintingPhase & GraphicsLayerPaintChildClippingMask)
3080 paintLayerFlags |= PaintLayerPaintingChildClippingMaskPhase; 3137 paintLayerFlags |= PaintLayerPaintingChildClippingMaskPhase;
3138 if (graphicsLayerPaintingPhase & GraphicsLayerPaintAncestorClippingMask)
3139 paintLayerFlags |= PaintLayerPaintingAncestorClippingMaskPhase;
3081 if (graphicsLayerPaintingPhase & GraphicsLayerPaintOverflowContents) 3140 if (graphicsLayerPaintingPhase & GraphicsLayerPaintOverflowContents)
3082 paintLayerFlags |= PaintLayerPaintingOverflowContents; 3141 paintLayerFlags |= PaintLayerPaintingOverflowContents;
3083 if (graphicsLayerPaintingPhase & GraphicsLayerPaintCompositedScroll) 3142 if (graphicsLayerPaintingPhase & GraphicsLayerPaintCompositedScroll)
3084 paintLayerFlags |= PaintLayerPaintingCompositingScrollingPhase; 3143 paintLayerFlags |= PaintLayerPaintingCompositingScrollingPhase;
3085 if (graphicsLayerPaintingPhase & GraphicsLayerPaintDecoration) 3144 if (graphicsLayerPaintingPhase & GraphicsLayerPaintDecoration)
3086 paintLayerFlags |= PaintLayerPaintingCompositingDecorationPhase; 3145 paintLayerFlags |= PaintLayerPaintingCompositingDecorationPhase;
3087 3146
3088 if (graphicsLayer == m_backgroundLayer.get()) 3147 if (graphicsLayer == m_backgroundLayer.get())
3089 paintLayerFlags |= PaintLayerPaintingRootBackgroundOnly; 3148 paintLayerFlags |= PaintLayerPaintingRootBackgroundOnly;
3090 else if (compositor()->fixedRootBackgroundLayer() && 3149 else if (compositor()->fixedRootBackgroundLayer() &&
3091 m_owningLayer.isRootLayer()) 3150 m_owningLayer.isRootLayer())
3092 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; 3151 paintLayerFlags |= PaintLayerPaintingSkipRootBackground;
3093 3152
3094 if (graphicsLayer == m_graphicsLayer.get() || 3153 if (graphicsLayer == m_graphicsLayer.get() ||
3095 graphicsLayer == m_foregroundLayer.get() || 3154 graphicsLayer == m_foregroundLayer.get() ||
3096 graphicsLayer == m_backgroundLayer.get() || 3155 graphicsLayer == m_backgroundLayer.get() ||
3097 graphicsLayer == m_maskLayer.get() || 3156 graphicsLayer == m_maskLayer.get() ||
3098 graphicsLayer == m_childClippingMaskLayer.get() || 3157 graphicsLayer == m_childClippingMaskLayer.get() ||
3099 graphicsLayer == m_scrollingContentsLayer.get() || 3158 graphicsLayer == m_scrollingContentsLayer.get() ||
3100 graphicsLayer == m_decorationOutlineLayer.get()) { 3159 graphicsLayer == m_decorationOutlineLayer.get() ||
3160 graphicsLayer == m_ancestorClippingMaskLayer.get()) {
3101 bool paintRootBackgroundOntoScrollingContentsLayer = 3161 bool paintRootBackgroundOntoScrollingContentsLayer =
3102 m_backgroundPaintsOntoScrollingContentsLayer; 3162 m_backgroundPaintsOntoScrollingContentsLayer;
3103 DCHECK(!paintRootBackgroundOntoScrollingContentsLayer || 3163 DCHECK(!paintRootBackgroundOntoScrollingContentsLayer ||
3104 (!m_backgroundLayer && !m_foregroundLayer)); 3164 (!m_backgroundLayer && !m_foregroundLayer));
3105 if (paintRootBackgroundOntoScrollingContentsLayer) { 3165 if (paintRootBackgroundOntoScrollingContentsLayer) {
3106 if (graphicsLayer == m_scrollingContentsLayer.get()) 3166 if (graphicsLayer == m_scrollingContentsLayer.get())
3107 paintLayerFlags &= ~PaintLayerPaintingSkipRootBackground; 3167 paintLayerFlags &= ~PaintLayerPaintingSkipRootBackground;
3108 else if (!m_backgroundPaintsOntoGraphicsLayer) 3168 else if (!m_backgroundPaintsOntoGraphicsLayer)
3109 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; 3169 paintLayerFlags |= PaintLayerPaintingSkipRootBackground;
3110 } 3170 }
3171
3111 GraphicsLayerPaintInfo paintInfo; 3172 GraphicsLayerPaintInfo paintInfo;
3112 paintInfo.paintLayer = &m_owningLayer; 3173 paintInfo.paintLayer = &m_owningLayer;
3113 paintInfo.compositedBounds = compositedBounds(); 3174 paintInfo.compositedBounds = compositedBounds();
3114 paintInfo.offsetFromLayoutObject = graphicsLayer->offsetFromLayoutObject(); 3175 paintInfo.offsetFromLayoutObject = graphicsLayer->offsetFromLayoutObject();
3115 adjustForCompositedScrolling(graphicsLayer, 3176 adjustForCompositedScrolling(graphicsLayer,
3116 paintInfo.offsetFromLayoutObject); 3177 paintInfo.offsetFromLayoutObject);
3117 3178
3118 // We have to use the same root as for hit testing, because both methods can 3179 // We have to use the same root as for hit testing, because both methods can
3119 // compute and cache clipRects. 3180 // compute and cache clipRects.
3120 doPaintTask(paintInfo, *graphicsLayer, paintLayerFlags, context, 3181 doPaintTask(paintInfo, *graphicsLayer, paintLayerFlags, context,
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
3345 } else if (graphicsLayer == m_squashingContainmentLayer.get()) { 3406 } else if (graphicsLayer == m_squashingContainmentLayer.get()) {
3346 name = "Squashing Containment Layer"; 3407 name = "Squashing Containment Layer";
3347 } else if (graphicsLayer == m_squashingLayer.get()) { 3408 } else if (graphicsLayer == m_squashingLayer.get()) {
3348 name = "Squashing Layer (first squashed layer: " + 3409 name = "Squashing Layer (first squashed layer: " +
3349 (m_squashedLayers.size() > 0 3410 (m_squashedLayers.size() > 0
3350 ? m_squashedLayers[0].paintLayer->debugName() 3411 ? m_squashedLayers[0].paintLayer->debugName()
3351 : "") + 3412 : "") +
3352 ")"; 3413 ")";
3353 } else if (graphicsLayer == m_ancestorClippingLayer.get()) { 3414 } else if (graphicsLayer == m_ancestorClippingLayer.get()) {
3354 name = "Ancestor Clipping Layer"; 3415 name = "Ancestor Clipping Layer";
3416 } else if (graphicsLayer == m_ancestorClippingMaskLayer.get()) {
3417 name = "Ancestor Clipping Mask Layer";
3355 } else if (graphicsLayer == m_foregroundLayer.get()) { 3418 } else if (graphicsLayer == m_foregroundLayer.get()) {
3356 name = m_owningLayer.debugName() + " (foreground) Layer"; 3419 name = m_owningLayer.debugName() + " (foreground) Layer";
3357 } else if (graphicsLayer == m_backgroundLayer.get()) { 3420 } else if (graphicsLayer == m_backgroundLayer.get()) {
3358 name = m_owningLayer.debugName() + " (background) Layer"; 3421 name = m_owningLayer.debugName() + " (background) Layer";
3359 } else if (graphicsLayer == m_childContainmentLayer.get()) { 3422 } else if (graphicsLayer == m_childContainmentLayer.get()) {
3360 name = "Child Containment Layer"; 3423 name = "Child Containment Layer";
3361 } else if (graphicsLayer == m_childTransformLayer.get()) { 3424 } else if (graphicsLayer == m_childTransformLayer.get()) {
3362 name = "Child Transform Layer"; 3425 name = "Child Transform Layer";
3363 } else if (graphicsLayer == m_maskLayer.get()) { 3426 } else if (graphicsLayer == m_maskLayer.get()) {
3364 name = "Mask Layer"; 3427 name = "Mask Layer";
(...skipping 16 matching lines...) Expand all
3381 } else if (graphicsLayer == m_decorationOutlineLayer.get()) { 3444 } else if (graphicsLayer == m_decorationOutlineLayer.get()) {
3382 name = "Decoration Layer"; 3445 name = "Decoration Layer";
3383 } else { 3446 } else {
3384 ASSERT_NOT_REACHED(); 3447 ASSERT_NOT_REACHED();
3385 } 3448 }
3386 3449
3387 return name; 3450 return name;
3388 } 3451 }
3389 3452
3390 } // namespace blink 3453 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698