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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayer.cpp

Issue 2543913002: Generalize visible descendant dirty bits to prepare for more properties. (Closed)
Patch Set: none 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
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 compositingReasons(CompositingReasonNone), 124 compositingReasons(CompositingReasonNone),
125 squashingDisallowedReasons(SquashingDisallowedReasonsNone), 125 squashingDisallowedReasons(SquashingDisallowedReasonsNone),
126 groupedMapping(nullptr) {} 126 groupedMapping(nullptr) {}
127 127
128 PaintLayerRareData::~PaintLayerRareData() {} 128 PaintLayerRareData::~PaintLayerRareData() {}
129 129
130 PaintLayer::PaintLayer(LayoutBoxModelObject* layoutObject) 130 PaintLayer::PaintLayer(LayoutBoxModelObject* layoutObject)
131 : m_hasSelfPaintingLayerDescendant(false), 131 : m_hasSelfPaintingLayerDescendant(false),
132 m_hasSelfPaintingLayerDescendantDirty(false), 132 m_hasSelfPaintingLayerDescendantDirty(false),
133 m_isRootLayer(layoutObject->isLayoutView()), 133 m_isRootLayer(layoutObject->isLayoutView()),
134 m_isVisibleContentDirty(true),
135 m_hasVisibleContent(false), 134 m_hasVisibleContent(false),
136 m_isVisibleDescendantDirty(false), 135 m_needsDescendantDependentFlagsUpdate(true),
137 m_hasVisibleDescendant(false), 136 m_hasVisibleDescendant(false),
138 #if DCHECK_IS_ON() 137 #if DCHECK_IS_ON()
139 m_needsPositionUpdate(true), 138 m_needsPositionUpdate(true),
140 #endif 139 #endif
141 m_is3DTransformedDescendantDirty(true), 140 m_is3DTransformedDescendantDirty(true),
142 m_has3DTransformedDescendant(false), 141 m_has3DTransformedDescendant(false),
143 m_containsDirtyOverlayScrollbars(false), 142 m_containsDirtyOverlayScrollbars(false),
144 m_needsAncestorDependentCompositingInputsUpdate(true), 143 m_needsAncestorDependentCompositingInputsUpdate(true),
145 m_needsDescendantDependentCompositingInputsUpdate(true), 144 m_needsDescendantDependentCompositingInputsUpdate(true),
146 m_childNeedsCompositingInputsUpdate(true), 145 m_childNeedsCompositingInputsUpdate(true),
(...skipping 19 matching lines...) Expand all
166 m_next(0), 165 m_next(0),
167 m_first(0), 166 m_first(0),
168 m_last(0), 167 m_last(0),
169 m_staticInlinePosition(0), 168 m_staticInlinePosition(0),
170 m_staticBlockPosition(0), 169 m_staticBlockPosition(0),
171 m_ancestorOverflowLayer(nullptr) { 170 m_ancestorOverflowLayer(nullptr) {
172 updateStackingNode(); 171 updateStackingNode();
173 172
174 m_isSelfPaintingLayer = shouldBeSelfPaintingLayer(); 173 m_isSelfPaintingLayer = shouldBeSelfPaintingLayer();
175 174
176 if (!layoutObject->slowFirstChild() && layoutObject->style()) {
177 m_isVisibleContentDirty = false;
178 m_hasVisibleContent =
179 layoutObject->style()->visibility() == EVisibility::Visible;
180 }
181
182 updateScrollableArea(); 175 updateScrollableArea();
183 } 176 }
184 177
185 PaintLayer::~PaintLayer() { 178 PaintLayer::~PaintLayer() {
186 if (m_rareData && m_rareData->resourceInfo) { 179 if (m_rareData && m_rareData->resourceInfo) {
187 const ComputedStyle& style = layoutObject()->styleRef(); 180 const ComputedStyle& style = layoutObject()->styleRef();
188 if (style.hasFilter()) 181 if (style.hasFilter())
189 style.filter().removeClient(m_rareData->resourceInfo); 182 style.filter().removeClient(m_rareData->resourceInfo);
190 if (isReferenceClipPath(style.clipPath())) { 183 if (isReferenceClipPath(style.clipPath())) {
191 toReferenceClipPathOperation(style.clipPath()) 184 toReferenceClipPathOperation(style.clipPath())
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 297
305 // FIXME(400589): We would like to do this in 298 // FIXME(400589): We would like to do this in
306 // PaintLayerScrollableArea::updateAfterLayout, but it depends on the size 299 // PaintLayerScrollableArea::updateAfterLayout, but it depends on the size
307 // computed by updateLayerPosition. 300 // computed by updateLayerPosition.
308 if (m_scrollableArea) { 301 if (m_scrollableArea) {
309 if (ScrollAnimatorBase* scrollAnimator = 302 if (ScrollAnimatorBase* scrollAnimator =
310 m_scrollableArea->existingScrollAnimator()) 303 m_scrollableArea->existingScrollAnimator())
311 scrollAnimator->updateAfterLayout(); 304 scrollAnimator->updateAfterLayout();
312 } 305 }
313 306
314 // FIXME: We should be able to remove this call because we don't care about
315 // any descendant-dependent flags, but code somewhere else is reading these
316 // flags and depending on us to update them.
317 updateDescendantDependentFlags();
318
319 for (PaintLayer* child = firstChild(); child; child = child->nextSibling()) 307 for (PaintLayer* child = firstChild(); child; child = child->nextSibling())
320 child->updateLayerPositionRecursive(); 308 child->updateLayerPositionRecursive();
321 } 309 }
322 310
323 void PaintLayer::updateHasSelfPaintingLayerDescendant() const { 311 void PaintLayer::updateHasSelfPaintingLayerDescendant() const {
324 DCHECK(m_hasSelfPaintingLayerDescendantDirty); 312 DCHECK(m_hasSelfPaintingLayerDescendantDirty);
325 313
326 m_hasSelfPaintingLayerDescendant = false; 314 m_hasSelfPaintingLayerDescendant = false;
327 315
328 for (PaintLayer* child = firstChild(); child; child = child->nextSibling()) { 316 for (PaintLayer* child = firstChild(); child; child = child->nextSibling()) {
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 // FIXME: remove this special-case code that works around the paint 621 // FIXME: remove this special-case code that works around the paint
634 // invalidation code structure. 622 // invalidation code structure.
635 layoutObject.mapToVisualRectInAncestorSpace(&paintInvalidationContainer, 623 layoutObject.mapToVisualRectInAncestorSpace(&paintInvalidationContainer,
636 rect); 624 rect);
637 625
638 mapRectInPaintInvalidationContainerToBacking(paintInvalidationContainer, 626 mapRectInPaintInvalidationContainerToBacking(paintInvalidationContainer,
639 rect); 627 rect);
640 } 628 }
641 629
642 void PaintLayer::dirtyVisibleContentStatus() { 630 void PaintLayer::dirtyVisibleContentStatus() {
643 m_isVisibleContentDirty = true; 631 markAncestorChainForDescendantDependentFlagsUpdate();
644 if (parent())
645 parent()->dirtyAncestorChainVisibleDescendantStatus();
646 // Non-self-painting layers paint into their ancestor layer, and count as part 632 // Non-self-painting layers paint into their ancestor layer, and count as part
647 // of the "visible contents" of the parent, so we need to dirty it. 633 // of the "visible contents" of the parent, so we need to dirty it.
648 if (!isSelfPaintingLayer()) 634 if (!isSelfPaintingLayer())
649 parent()->dirtyVisibleContentStatus(); 635 parent()->dirtyVisibleContentStatus();
650 } 636 }
651 637
652 void PaintLayer::potentiallyDirtyVisibleContentStatus(EVisibility visibility) { 638 void PaintLayer::markAncestorChainForDescendantDependentFlagsUpdate() {
653 if (m_isVisibleContentDirty)
654 return;
655 if (hasVisibleContent() == (visibility == EVisibility::Visible))
656 return;
657 dirtyVisibleContentStatus();
658 }
659
660 void PaintLayer::dirtyAncestorChainVisibleDescendantStatus() {
661 for (PaintLayer* layer = this; layer; layer = layer->parent()) { 639 for (PaintLayer* layer = this; layer; layer = layer->parent()) {
662 if (layer->m_isVisibleDescendantDirty) 640 if (layer->m_needsDescendantDependentFlagsUpdate)
663 break; 641 break;
664 layer->m_isVisibleDescendantDirty = true; 642 layer->m_needsDescendantDependentFlagsUpdate = true;
665 } 643 }
666 } 644 }
667 645
668 // FIXME: this is quite brute-force. We could be more efficient if we were to 646 // FIXME: this is quite brute-force. We could be more efficient if we were to
669 // track state and update it as appropriate as changes are made in the layout 647 // track state and update it as appropriate as changes are made in the layout
670 // tree. 648 // tree.
671 void PaintLayer::updateScrollingStateAfterCompositingChange() { 649 void PaintLayer::updateScrollingStateAfterCompositingChange() {
672 TRACE_EVENT0("blink", 650 TRACE_EVENT0("blink",
673 "PaintLayer::updateScrollingStateAfterCompositingChange"); 651 "PaintLayer::updateScrollingStateAfterCompositingChange");
674 m_isAllScrollingContentComposited = true; 652 m_isAllScrollingContentComposited = true;
(...skipping 12 matching lines...) Expand all
687 } else if (!child->stackingNode()->isStackingContext()) { 665 } else if (!child->stackingNode()->isStackingContext()) {
688 // If the child is composited, but not a stacking context, it may paint 666 // If the child is composited, but not a stacking context, it may paint
689 // negative z-index descendants into an ancestor's GraphicsLayer. 667 // negative z-index descendants into an ancestor's GraphicsLayer.
690 m_isAllScrollingContentComposited = false; 668 m_isAllScrollingContentComposited = false;
691 return; 669 return;
692 } 670 }
693 } 671 }
694 } 672 }
695 673
696 void PaintLayer::updateDescendantDependentFlags() { 674 void PaintLayer::updateDescendantDependentFlags() {
697 if (m_isVisibleDescendantDirty) { 675 if (m_needsDescendantDependentFlagsUpdate) {
698 m_hasVisibleDescendant = false; 676 m_hasVisibleDescendant = false;
699 677
700 for (PaintLayer* child = firstChild(); child; 678 for (PaintLayer* child = firstChild(); child;
701 child = child->nextSibling()) { 679 child = child->nextSibling()) {
702 child->updateDescendantDependentFlags(); 680 child->updateDescendantDependentFlags();
703 681
704 if (child->m_hasVisibleContent || child->m_hasVisibleDescendant) 682 if (child->m_hasVisibleContent || child->m_hasVisibleDescendant)
705 m_hasVisibleDescendant = true; 683 m_hasVisibleDescendant = true;
706 } 684 }
707 685
708 m_isVisibleDescendantDirty = false; 686 m_needsDescendantDependentFlagsUpdate = false;
709 } 687 }
710 688
711 if (m_isVisibleContentDirty) { 689 bool previouslyHasVisibleContent = m_hasVisibleContent;
712 bool previouslyHasVisibleContent = m_hasVisibleContent; 690 if (layoutObject()->style()->visibility() == EVisibility::Visible) {
713 if (layoutObject()->style()->visibility() == EVisibility::Visible) { 691 m_hasVisibleContent = true;
714 m_hasVisibleContent = true; 692 } else {
715 } else { 693 // layer may be hidden but still have some visible content, check for this
716 // layer may be hidden but still have some visible content, check for this 694 m_hasVisibleContent = false;
717 m_hasVisibleContent = false; 695 LayoutObject* r = layoutObject()->slowFirstChild();
718 LayoutObject* r = layoutObject()->slowFirstChild(); 696 while (r) {
719 while (r) { 697 if (r->style()->visibility() == EVisibility::Visible &&
720 if (r->style()->visibility() == EVisibility::Visible && 698 (!r->hasLayer() || !r->enclosingLayer()->isSelfPaintingLayer())) {
721 (!r->hasLayer() || !r->enclosingLayer()->isSelfPaintingLayer())) { 699 m_hasVisibleContent = true;
722 m_hasVisibleContent = true; 700 break;
723 break; 701 }
724 } 702 LayoutObject* layoutObjectFirstChild = r->slowFirstChild();
725 LayoutObject* layoutObjectFirstChild = r->slowFirstChild(); 703 if (layoutObjectFirstChild &&
726 if (layoutObjectFirstChild && 704 (!r->hasLayer() || !r->enclosingLayer()->isSelfPaintingLayer())) {
727 (!r->hasLayer() || !r->enclosingLayer()->isSelfPaintingLayer())) { 705 r = layoutObjectFirstChild;
728 r = layoutObjectFirstChild; 706 } else if (r->nextSibling()) {
729 } else if (r->nextSibling()) { 707 r = r->nextSibling();
708 } else {
709 do {
710 r = r->parent();
711 if (r == layoutObject())
712 r = 0;
713 } while (r && !r->nextSibling());
714 if (r)
730 r = r->nextSibling(); 715 r = r->nextSibling();
731 } else {
732 do {
733 r = r->parent();
734 if (r == layoutObject())
735 r = 0;
736 } while (r && !r->nextSibling());
737 if (r)
738 r = r->nextSibling();
739 }
740 } 716 }
741 } 717 }
742 m_isVisibleContentDirty = false; 718 }
743 719
744 if (hasVisibleContent() != previouslyHasVisibleContent) { 720 if (hasVisibleContent() != previouslyHasVisibleContent) {
745 setNeedsCompositingInputsUpdate(); 721 setNeedsCompositingInputsUpdate();
746 // We need to tell m_layoutObject to recheck its rect because we 722 // We need to tell m_layoutObject to recheck its rect because we
747 // pretend that invisible LayoutObjects have 0x0 rects. Changing 723 // pretend that invisible LayoutObjects have 0x0 rects. Changing
748 // visibility therefore changes our rect and we need to visit 724 // visibility therefore changes our rect and we need to visit
749 // this LayoutObject during the invalidateTreeIfNeeded walk. 725 // this LayoutObject during the invalidateTreeIfNeeded walk.
750 m_layoutObject->setMayNeedPaintInvalidation(); 726 m_layoutObject->setMayNeedPaintInvalidation();
751 }
752 } 727 }
753 } 728 }
754 729
755 void PaintLayer::dirty3DTransformedDescendantStatus() { 730 void PaintLayer::dirty3DTransformedDescendantStatus() {
756 PaintLayerStackingNode* stackingNode = 731 PaintLayerStackingNode* stackingNode =
757 m_stackingNode->ancestorStackingContextNode(); 732 m_stackingNode->ancestorStackingContextNode();
758 if (!stackingNode) 733 if (!stackingNode)
759 return; 734 return;
760 735
761 stackingNode->layer()->m_is3DTransformedDescendantDirty = true; 736 stackingNode->layer()->m_is3DTransformedDescendantDirty = true;
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 // building up generated content layers. This is ok, since the lists will 1245 // building up generated content layers. This is ok, since the lists will
1271 // start off dirty in that case anyway. 1246 // start off dirty in that case anyway.
1272 child->stackingNode()->dirtyStackingContextZOrderLists(); 1247 child->stackingNode()->dirtyStackingContextZOrderLists();
1273 } 1248 }
1274 1249
1275 // Non-self-painting children paint into this layer, so the visible contents 1250 // Non-self-painting children paint into this layer, so the visible contents
1276 // status of this layer is affected. 1251 // status of this layer is affected.
1277 if (!child->isSelfPaintingLayer()) 1252 if (!child->isSelfPaintingLayer())
1278 dirtyVisibleContentStatus(); 1253 dirtyVisibleContentStatus();
1279 1254
1280 dirtyAncestorChainVisibleDescendantStatus(); 1255 markAncestorChainForDescendantDependentFlagsUpdate();
1281 dirtyAncestorChainHasSelfPaintingLayerDescendantStatus(); 1256 dirtyAncestorChainHasSelfPaintingLayerDescendantStatus();
1282 1257
1283 child->setNeedsRepaint(); 1258 child->setNeedsRepaint();
1284
1285 child->updateDescendantDependentFlags();
1286 } 1259 }
1287 1260
1288 PaintLayer* PaintLayer::removeChild(PaintLayer* oldChild) { 1261 PaintLayer* PaintLayer::removeChild(PaintLayer* oldChild) {
1289 if (oldChild->previousSibling()) 1262 if (oldChild->previousSibling())
1290 oldChild->previousSibling()->setNextSibling(oldChild->nextSibling()); 1263 oldChild->previousSibling()->setNextSibling(oldChild->nextSibling());
1291 if (oldChild->nextSibling()) 1264 if (oldChild->nextSibling())
1292 oldChild->nextSibling()->setPreviousSibling(oldChild->previousSibling()); 1265 oldChild->nextSibling()->setPreviousSibling(oldChild->previousSibling());
1293 1266
1294 if (m_first == oldChild) 1267 if (m_first == oldChild)
1295 m_first = oldChild->nextSibling(); 1268 m_first = oldChild->nextSibling();
(...skipping 18 matching lines...) Expand all
1314 oldChild->setPreviousSibling(0); 1287 oldChild->setPreviousSibling(0);
1315 oldChild->setNextSibling(0); 1288 oldChild->setNextSibling(0);
1316 oldChild->m_parent = 0; 1289 oldChild->m_parent = 0;
1317 1290
1318 // Remove any ancestor overflow layers which descended into the removed child. 1291 // Remove any ancestor overflow layers which descended into the removed child.
1319 if (oldChild->ancestorOverflowLayer()) 1292 if (oldChild->ancestorOverflowLayer())
1320 oldChild->removeAncestorOverflowLayer(oldChild->ancestorOverflowLayer()); 1293 oldChild->removeAncestorOverflowLayer(oldChild->ancestorOverflowLayer());
1321 1294
1322 dirtyAncestorChainHasSelfPaintingLayerDescendantStatus(); 1295 dirtyAncestorChainHasSelfPaintingLayerDescendantStatus();
1323 1296
1324 oldChild->updateDescendantDependentFlags();
1325
1326 if (oldChild->m_hasVisibleContent || oldChild->m_hasVisibleDescendant) 1297 if (oldChild->m_hasVisibleContent || oldChild->m_hasVisibleDescendant)
1327 dirtyAncestorChainVisibleDescendantStatus(); 1298 markAncestorChainForDescendantDependentFlagsUpdate();
1328 1299
1329 if (oldChild->enclosingPaginationLayer()) 1300 if (oldChild->enclosingPaginationLayer())
1330 oldChild->clearPaginationRecursive(); 1301 oldChild->clearPaginationRecursive();
1331 1302
1332 setNeedsRepaint(); 1303 setNeedsRepaint();
1333 1304
1334 return oldChild; 1305 return oldChild;
1335 } 1306 }
1336 1307
1337 void PaintLayer::removeOnlyThisLayerAfterStyleChange() { 1308 void PaintLayer::removeOnlyThisLayerAfterStyleChange() {
(...skipping 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after
2999 2970
3000 m_stackingNode->styleDidChange(oldStyle); 2971 m_stackingNode->styleDidChange(oldStyle);
3001 2972
3002 if (m_scrollableArea) 2973 if (m_scrollableArea)
3003 m_scrollableArea->updateAfterStyleChange(oldStyle); 2974 m_scrollableArea->updateAfterStyleChange(oldStyle);
3004 2975
3005 // Overlay scrollbars can make this layer self-painting so we need 2976 // Overlay scrollbars can make this layer self-painting so we need
3006 // to recompute the bit once scrollbars have been updated. 2977 // to recompute the bit once scrollbars have been updated.
3007 updateSelfPaintingLayer(); 2978 updateSelfPaintingLayer();
3008 2979
3009 updateDescendantDependentFlags();
3010
3011 updateTransform(oldStyle, layoutObject()->styleRef()); 2980 updateTransform(oldStyle, layoutObject()->styleRef());
3012 updateFilters(oldStyle, layoutObject()->styleRef()); 2981 updateFilters(oldStyle, layoutObject()->styleRef());
3013 updateClipPath(oldStyle, layoutObject()->styleRef()); 2982 updateClipPath(oldStyle, layoutObject()->styleRef());
3014 2983
3015 setNeedsCompositingInputsUpdate(); 2984 setNeedsCompositingInputsUpdate();
3016 } 2985 }
3017 2986
3018 bool PaintLayer::scrollsOverflow() const { 2987 bool PaintLayer::scrollsOverflow() const {
3019 if (PaintLayerScrollableArea* scrollableArea = this->getScrollableArea()) 2988 if (PaintLayerScrollableArea* scrollableArea = this->getScrollableArea())
3020 return scrollableArea->scrollsOverflow(); 2989 return scrollableArea->scrollsOverflow();
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
3266 } 3235 }
3267 3236
3268 void showLayerTree(const blink::LayoutObject* layoutObject) { 3237 void showLayerTree(const blink::LayoutObject* layoutObject) {
3269 if (!layoutObject) { 3238 if (!layoutObject) {
3270 LOG(INFO) << "Cannot showLayerTree. Root is (nil)"; 3239 LOG(INFO) << "Cannot showLayerTree. Root is (nil)";
3271 return; 3240 return;
3272 } 3241 }
3273 showLayerTree(layoutObject->enclosingLayer()); 3242 showLayerTree(layoutObject->enclosingLayer());
3274 } 3243 }
3275 #endif 3244 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698