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

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

Issue 2604973002: Move computation of 3D descendants to the descendant-dependent flags walk. (Closed)
Patch Set: none 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) 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 PaintLayer::PaintLayer(LayoutBoxModelObject* layoutObject) 131 PaintLayer::PaintLayer(LayoutBoxModelObject* layoutObject)
132 : m_hasSelfPaintingLayerDescendant(false), 132 : m_hasSelfPaintingLayerDescendant(false),
133 m_hasSelfPaintingLayerDescendantDirty(false), 133 m_hasSelfPaintingLayerDescendantDirty(false),
134 m_isRootLayer(layoutObject->isLayoutView()), 134 m_isRootLayer(layoutObject->isLayoutView()),
135 m_hasVisibleContent(false), 135 m_hasVisibleContent(false),
136 m_needsDescendantDependentFlagsUpdate(true), 136 m_needsDescendantDependentFlagsUpdate(true),
137 m_hasVisibleDescendant(false), 137 m_hasVisibleDescendant(false),
138 #if DCHECK_IS_ON() 138 #if DCHECK_IS_ON()
139 m_needsPositionUpdate(true), 139 m_needsPositionUpdate(true),
140 #endif 140 #endif
141 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_childNeedsCompositingInputsUpdate(true), 144 m_childNeedsCompositingInputsUpdate(true),
146 m_hasCompositingDescendant(false), 145 m_hasCompositingDescendant(false),
147 m_isAllScrollingContentComposited(false), 146 m_isAllScrollingContentComposited(false),
148 m_shouldIsolateCompositedDescendants(false), 147 m_shouldIsolateCompositedDescendants(false),
149 m_lostGroupedMapping(false), 148 m_lostGroupedMapping(false),
150 m_needsRepaint(false), 149 m_needsRepaint(false),
151 m_previousPaintResult(FullyPainted), 150 m_previousPaintResult(FullyPainted),
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 // PaintLayers with transforms act as clip rects roots, so clear the cached 407 // PaintLayers with transforms act as clip rects roots, so clear the cached
409 // clip rects here. 408 // clip rects here.
410 clipper().clearClipRectsIncludingDescendants(); 409 clipper().clearClipRectsIncludingDescendants();
411 } else if (hasTransform) { 410 } else if (hasTransform) {
412 clipper().clearClipRectsIncludingDescendants(AbsoluteClipRects); 411 clipper().clearClipRectsIncludingDescendants(AbsoluteClipRects);
413 } 412 }
414 413
415 updateTransformationMatrix(); 414 updateTransformationMatrix();
416 415
417 if (had3DTransform != has3DTransform()) 416 if (had3DTransform != has3DTransform())
418 dirty3DTransformedDescendantStatus(); 417 markAncestorChainForDescendantDependentFlagsUpdate();
419 418
420 if (FrameView* frameView = layoutObject()->document().view()) 419 if (FrameView* frameView = layoutObject()->document().view())
421 frameView->setNeedsUpdateWidgetGeometries(); 420 frameView->setNeedsUpdateWidgetGeometries();
422 } 421 }
423 422
424 static PaintLayer* enclosingLayerForContainingBlock(PaintLayer* layer) { 423 static PaintLayer* enclosingLayerForContainingBlock(PaintLayer* layer) {
425 if (LayoutObject* containingBlock = layer->layoutObject()->containingBlock()) 424 if (LayoutObject* containingBlock = layer->layoutObject()->containingBlock())
426 return containingBlock->enclosingLayer(); 425 return containingBlock->enclosingLayer();
427 return 0; 426 return 0;
428 } 427 }
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 } 732 }
734 733
735 if (hasVisibleContent() != previouslyHasVisibleContent) { 734 if (hasVisibleContent() != previouslyHasVisibleContent) {
736 setNeedsCompositingInputsUpdateInternal(); 735 setNeedsCompositingInputsUpdateInternal();
737 // We need to tell m_layoutObject to recheck its rect because we 736 // We need to tell m_layoutObject to recheck its rect because we
738 // pretend that invisible LayoutObjects have 0x0 rects. Changing 737 // pretend that invisible LayoutObjects have 0x0 rects. Changing
739 // visibility therefore changes our rect and we need to visit 738 // visibility therefore changes our rect and we need to visit
740 // this LayoutObject during the invalidateTreeIfNeeded walk. 739 // this LayoutObject during the invalidateTreeIfNeeded walk.
741 m_layoutObject->setMayNeedPaintInvalidation(); 740 m_layoutObject->setMayNeedPaintInvalidation();
742 } 741 }
742
743 update3DTransformedDescendantStatus();
743 } 744 }
744 745
745 void PaintLayer::dirty3DTransformedDescendantStatus() { 746 void PaintLayer::update3DTransformedDescendantStatus() {
746 PaintLayerStackingNode* stackingNode = 747 m_has3DTransformedDescendant = false;
747 m_stackingNode->ancestorStackingContextNode();
748 if (!stackingNode)
749 return;
750 748
751 stackingNode->layer()->m_is3DTransformedDescendantDirty = true; 749 m_stackingNode->updateZOrderLists();
752 750
753 // This propagates up through preserve-3d hierarchies to the enclosing 751 // Transformed or preserve-3d descendants can only be in the z-order lists,
754 // flattening layer. Note that preserves3D() creates stacking context, so we 752 // not in the normal flow list, so we only need to check those.
755 // can just run up the stacking containers. 753 PaintLayerStackingNodeIterator iterator(
756 while (stackingNode && stackingNode->layer()->preserves3D()) { 754 *m_stackingNode.get(), PositiveZOrderChildren | NegativeZOrderChildren);
757 stackingNode->layer()->m_is3DTransformedDescendantDirty = true; 755 while (PaintLayerStackingNode* node = iterator.next()) {
758 stackingNode = stackingNode->ancestorStackingContextNode(); 756 const PaintLayer& childLayer = *node->layer();
757 bool childHas3D = false;
758 // If the child lives in a 3d hierarchy, then the layer at the root of
759 // that hierarchy needs the m_has3DTransformedDescendant set.
760 if (childLayer.preserves3D() && (childLayer.has3DTransform() ||
761 childLayer.has3DTransformedDescendant()))
762 childHas3D = true;
763 else if (childLayer.has3DTransform())
764 childHas3D = true;
765
766 m_has3DTransformedDescendant = m_has3DTransformedDescendant || childHas3D;
Xianzhu 2016/12/28 18:56:33 Nit: Would the following look better: if (child
chrishtr 2016/12/28 19:01:00 Done.
767
768 if (m_has3DTransformedDescendant)
769 break;
759 } 770 }
760 } 771 }
761 772
762 // Return true if this layer or any preserve-3d descendants have 3d.
763 bool PaintLayer::update3DTransformedDescendantStatus() {
764 if (m_is3DTransformedDescendantDirty) {
765 m_has3DTransformedDescendant = false;
766
767 m_stackingNode->updateZOrderLists();
768
769 // Transformed or preserve-3d descendants can only be in the z-order lists,
770 // not in the normal flow list, so we only need to check those.
771 PaintLayerStackingNodeIterator iterator(
772 *m_stackingNode.get(), PositiveZOrderChildren | NegativeZOrderChildren);
773 while (PaintLayerStackingNode* node = iterator.next())
774 m_has3DTransformedDescendant |=
775 node->layer()->update3DTransformedDescendantStatus();
776
777 m_is3DTransformedDescendantDirty = false;
778 }
779
780 // If we live in a 3d hierarchy, then the layer at the root of that hierarchy
781 // needs the m_has3DTransformedDescendant set.
782 if (preserves3D())
783 return has3DTransform() || m_has3DTransformedDescendant;
784
785 return has3DTransform();
786 }
787
788 void PaintLayer::updateLayerPosition() { 773 void PaintLayer::updateLayerPosition() {
789 LayoutPoint localPoint; 774 LayoutPoint localPoint;
790 775
791 bool didResize = false; 776 bool didResize = false;
792 if (layoutObject()->isInline() && layoutObject()->isLayoutInline()) { 777 if (layoutObject()->isInline() && layoutObject()->isLayoutInline()) {
793 LayoutInline* inlineFlow = toLayoutInline(layoutObject()); 778 LayoutInline* inlineFlow = toLayoutInline(layoutObject());
794 IntRect lineBox = enclosingIntRect(inlineFlow->linesBoundingBox()); 779 IntRect lineBox = enclosingIntRect(inlineFlow->linesBoundingBox());
795 m_size = lineBox.size(); 780 m_size = lineBox.size();
796 } else if (LayoutBox* box = layoutBox()) { 781 } else if (LayoutBox* box = layoutBox()) {
797 IntSize newSize = pixelSnappedIntSize(box->size(), box->location()); 782 IntSize newSize = pixelSnappedIntSize(box->size(), box->location());
(...skipping 2456 matching lines...) Expand 10 before | Expand all | Expand 10 after
3254 } 3239 }
3255 3240
3256 void showLayerTree(const blink::LayoutObject* layoutObject) { 3241 void showLayerTree(const blink::LayoutObject* layoutObject) {
3257 if (!layoutObject) { 3242 if (!layoutObject) {
3258 LOG(INFO) << "Cannot showLayerTree. Root is (nil)"; 3243 LOG(INFO) << "Cannot showLayerTree. Root is (nil)";
3259 return; 3244 return;
3260 } 3245 }
3261 showLayerTree(layoutObject->enclosingLayer()); 3246 showLayerTree(layoutObject->enclosingLayer());
3262 } 3247 }
3263 #endif 3248 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.h ('k') | third_party/WebKit/Source/core/paint/PaintLayerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698