Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
| 5 * | 5 * |
| 6 * Other contributors: | 6 * Other contributors: |
| 7 * Robert O'Callahan <roc+@cs.cmu.edu> | 7 * Robert O'Callahan <roc+@cs.cmu.edu> |
| 8 * David Baron <dbaron@fas.harvard.edu> | 8 * David Baron <dbaron@fas.harvard.edu> |
| 9 * Christian Biesinger <cbiesinger@web.de> | 9 * Christian Biesinger <cbiesinger@web.de> |
| 10 * Randall Jesup <rjesup@wgate.com> | 10 * Randall Jesup <rjesup@wgate.com> |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 | 92 |
| 93 namespace blink { | 93 namespace blink { |
| 94 | 94 |
| 95 namespace { | 95 namespace { |
| 96 | 96 |
| 97 static CompositingQueryMode gCompositingQueryMode = | 97 static CompositingQueryMode gCompositingQueryMode = |
| 98 CompositingQueriesAreOnlyAllowedInCertainDocumentLifecyclePhases; | 98 CompositingQueriesAreOnlyAllowedInCertainDocumentLifecyclePhases; |
| 99 | 99 |
| 100 struct SameSizeAsPaintLayer : DisplayItemClient { | 100 struct SameSizeAsPaintLayer : DisplayItemClient { |
| 101 int bitFields; | 101 int bitFields; |
| 102 void* pointers[9]; | 102 void* pointers[10]; |
| 103 LayoutUnit layoutUnits[4]; | 103 LayoutUnit layoutUnits[4]; |
| 104 IntSize size; | 104 IntSize size; |
| 105 OwnPtrWillBePersistent<PaintLayerScrollableArea> scrollableArea; | 105 OwnPtrWillBePersistent<PaintLayerScrollableArea> scrollableArea; |
| 106 struct { | 106 struct { |
| 107 IntRect rect; | 107 IntRect rect; |
| 108 void* pointers[2]; | 108 void* pointers[2]; |
| 109 } ancestorCompositingInputs; | 109 } ancestorCompositingInputs; |
| 110 struct { | 110 struct { |
| 111 IntSize size; | 111 IntSize size; |
| 112 void* pointer; | 112 void* pointer; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 , m_hasNonIsolatedDescendantWithBlendMode(false) | 165 , m_hasNonIsolatedDescendantWithBlendMode(false) |
| 166 , m_hasAncestorWithClipPath(false) | 166 , m_hasAncestorWithClipPath(false) |
| 167 , m_layoutObject(layoutObject) | 167 , m_layoutObject(layoutObject) |
| 168 , m_parent(0) | 168 , m_parent(0) |
| 169 , m_previous(0) | 169 , m_previous(0) |
| 170 , m_next(0) | 170 , m_next(0) |
| 171 , m_first(0) | 171 , m_first(0) |
| 172 , m_last(0) | 172 , m_last(0) |
| 173 , m_staticInlinePosition(0) | 173 , m_staticInlinePosition(0) |
| 174 , m_staticBlockPosition(0) | 174 , m_staticBlockPosition(0) |
| 175 , m_ancestorOverflowLayer(nullptr) | |
| 175 { | 176 { |
| 176 updateStackingNode(); | 177 updateStackingNode(); |
| 177 | 178 |
| 178 m_isSelfPaintingLayer = shouldBeSelfPaintingLayer(); | 179 m_isSelfPaintingLayer = shouldBeSelfPaintingLayer(); |
| 179 | 180 |
| 180 if (!layoutObject->slowFirstChild() && layoutObject->style()) { | 181 if (!layoutObject->slowFirstChild() && layoutObject->style()) { |
| 181 m_visibleContentStatusDirty = false; | 182 m_visibleContentStatusDirty = false; |
| 182 m_hasVisibleContent = layoutObject->style()->visibility() == VISIBLE; | 183 m_hasVisibleContent = layoutObject->style()->visibility() == VISIBLE; |
| 183 } | 184 } |
| 184 | 185 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 // in this case, there is no need to dirty our ancestors further. | 343 // in this case, there is no need to dirty our ancestors further. |
| 343 if (layer->isSelfPaintingLayer()) { | 344 if (layer->isSelfPaintingLayer()) { |
| 344 ASSERT(!parent() || parent()->m_hasSelfPaintingLayerDescendantDirty || parent()->m_hasSelfPaintingLayerDescendant); | 345 ASSERT(!parent() || parent()->m_hasSelfPaintingLayerDescendantDirty || parent()->m_hasSelfPaintingLayerDescendant); |
| 345 break; | 346 break; |
| 346 } | 347 } |
| 347 } | 348 } |
| 348 } | 349 } |
| 349 | 350 |
| 350 bool PaintLayer::scrollsWithViewport() const | 351 bool PaintLayer::scrollsWithViewport() const |
| 351 { | 352 { |
| 352 return layoutObject()->style()->position() == FixedPosition && layoutObject( )->containerForFixedPosition() == layoutObject()->view(); | 353 return (layoutObject()->style()->position() == FixedPosition && layoutObject ()->containerForFixedPosition() == layoutObject()->view()) |
| 354 || (layoutObject()->style()->position() == StickyPosition && !ancestorSc rollingLayer()); | |
| 353 } | 355 } |
| 354 | 356 |
| 355 bool PaintLayer::scrollsWithRespectTo(const PaintLayer* other) const | 357 bool PaintLayer::scrollsWithRespectTo(const PaintLayer* other) const |
| 356 { | 358 { |
| 357 if (scrollsWithViewport() != other->scrollsWithViewport()) | 359 if (scrollsWithViewport() != other->scrollsWithViewport()) |
| 358 return true; | 360 return true; |
| 359 return ancestorScrollingLayer() != other->ancestorScrollingLayer(); | 361 return ancestorScrollingLayer() != other->ancestorScrollingLayer(); |
| 360 } | 362 } |
| 361 | 363 |
| 362 void PaintLayer::updateLayerPositionsAfterOverflowScroll(const DoubleSize& scrol lDelta) | 364 void PaintLayer::updateLayerPositionsAfterOverflowScroll(const DoubleSize& scrol lDelta) |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 740 } | 742 } |
| 741 | 743 |
| 742 // If we live in a 3d hierarchy, then the layer at the root of that hierarch y needs | 744 // If we live in a 3d hierarchy, then the layer at the root of that hierarch y needs |
| 743 // the m_has3DTransformedDescendant set. | 745 // the m_has3DTransformedDescendant set. |
| 744 if (preserves3D()) | 746 if (preserves3D()) |
| 745 return has3DTransform() || m_has3DTransformedDescendant; | 747 return has3DTransform() || m_has3DTransformedDescendant; |
| 746 | 748 |
| 747 return has3DTransform(); | 749 return has3DTransform(); |
| 748 } | 750 } |
| 749 | 751 |
| 750 bool PaintLayer::updateLayerPosition() | 752 void PaintLayer::updateLayerPosition() |
| 751 { | 753 { |
| 752 LayoutPoint localPoint; | 754 LayoutPoint localPoint; |
| 753 LayoutPoint inlineBoundingBoxOffset; // We don't put this into the Layer x/y for inlines, so we need to subtract it out when done. | 755 LayoutPoint inlineBoundingBoxOffset; // We don't put this into the Layer x/y for inlines, so we need to subtract it out when done. |
| 754 | 756 |
| 755 if (layoutObject()->isInline() && layoutObject()->isLayoutInline()) { | 757 if (layoutObject()->isInline() && layoutObject()->isLayoutInline()) { |
| 756 LayoutInline* inlineFlow = toLayoutInline(layoutObject()); | 758 LayoutInline* inlineFlow = toLayoutInline(layoutObject()); |
| 757 IntRect lineBox = inlineFlow->linesBoundingBox(); | 759 IntRect lineBox = inlineFlow->linesBoundingBox(); |
| 758 m_size = lineBox.size(); | 760 m_size = lineBox.size(); |
| 759 inlineBoundingBoxOffset = lineBox.location(); | 761 inlineBoundingBoxOffset = lineBox.location(); |
| 760 localPoint.moveBy(inlineBoundingBoxOffset); | 762 localPoint.moveBy(inlineBoundingBoxOffset); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 791 | 793 |
| 792 if (containingLayer->layoutObject()->isInFlowPositioned() && containingL ayer->layoutObject()->isLayoutInline()) { | 794 if (containingLayer->layoutObject()->isInFlowPositioned() && containingL ayer->layoutObject()->isLayoutInline()) { |
| 793 LayoutSize offset = toLayoutInline(containingLayer->layoutObject())- >offsetForInFlowPositionedInline(*toLayoutBox(layoutObject())); | 795 LayoutSize offset = toLayoutInline(containingLayer->layoutObject())- >offsetForInFlowPositionedInline(*toLayoutBox(layoutObject())); |
| 794 localPoint += offset; | 796 localPoint += offset; |
| 795 } | 797 } |
| 796 } else if (parent() && parent()->layoutObject()->hasOverflowClip()) { | 798 } else if (parent() && parent()->layoutObject()->hasOverflowClip()) { |
| 797 IntSize scrollOffset = parent()->layoutBox()->scrolledContentOffset(); | 799 IntSize scrollOffset = parent()->layoutBox()->scrolledContentOffset(); |
| 798 localPoint -= scrollOffset; | 800 localPoint -= scrollOffset; |
| 799 } | 801 } |
| 800 | 802 |
| 801 bool positionOrOffsetChanged = false; | |
| 802 if (layoutObject()->isInFlowPositioned()) { | 803 if (layoutObject()->isInFlowPositioned()) { |
| 803 LayoutSize newOffset = layoutObject()->offsetForInFlowPosition(); | 804 LayoutSize newOffset = layoutObject()->offsetForInFlowPosition(); |
| 804 positionOrOffsetChanged = newOffset != offsetForInFlowPosition(); | |
| 805 if (m_rareData || !newOffset.isZero()) | 805 if (m_rareData || !newOffset.isZero()) |
| 806 ensureRareData().offsetForInFlowPosition = newOffset; | 806 ensureRareData().offsetForInFlowPosition = newOffset; |
| 807 localPoint.move(newOffset); | 807 localPoint.move(newOffset); |
| 808 } else if (m_rareData) { | 808 } else if (m_rareData) { |
| 809 m_rareData->offsetForInFlowPosition = LayoutSize(); | 809 m_rareData->offsetForInFlowPosition = LayoutSize(); |
| 810 } | 810 } |
| 811 | 811 |
| 812 // FIXME: We'd really like to just get rid of the concept of a layer rectang le and rely on the layoutObjects. | 812 // FIXME: We'd really like to just get rid of the concept of a layer rectang le and rely on the layoutObjects. |
| 813 localPoint.moveBy(-inlineBoundingBoxOffset); | 813 localPoint.moveBy(-inlineBoundingBoxOffset); |
| 814 | 814 |
| 815 if (m_location != localPoint) { | 815 if (m_location != localPoint) { |
| 816 positionOrOffsetChanged = true; | |
| 817 setNeedsRepaint(); | 816 setNeedsRepaint(); |
| 818 } | 817 } |
| 819 m_location = localPoint; | 818 m_location = localPoint; |
| 820 | 819 |
| 821 #if ENABLE(ASSERT) | 820 #if ENABLE(ASSERT) |
| 822 m_needsPositionUpdate = false; | 821 m_needsPositionUpdate = false; |
| 823 #endif | 822 #endif |
| 824 return positionOrOffsetChanged; | |
| 825 } | 823 } |
| 826 | 824 |
| 827 TransformationMatrix PaintLayer::perspectiveTransform() const | 825 TransformationMatrix PaintLayer::perspectiveTransform() const |
| 828 { | 826 { |
| 829 if (!layoutObject()->hasTransformRelatedProperty()) | 827 if (!layoutObject()->hasTransformRelatedProperty()) |
| 830 return TransformationMatrix(); | 828 return TransformationMatrix(); |
| 831 | 829 |
| 832 const ComputedStyle& style = layoutObject()->styleRef(); | 830 const ComputedStyle& style = layoutObject()->styleRef(); |
| 833 if (!style.hasPerspective()) | 831 if (!style.hasPerspective()) |
| 834 return TransformationMatrix(); | 832 return TransformationMatrix(); |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1176 if (beforeChild) { | 1174 if (beforeChild) { |
| 1177 beforeChild->setPreviousSibling(child); | 1175 beforeChild->setPreviousSibling(child); |
| 1178 child->setNextSibling(beforeChild); | 1176 child->setNextSibling(beforeChild); |
| 1179 ASSERT(beforeChild != child); | 1177 ASSERT(beforeChild != child); |
| 1180 } else { | 1178 } else { |
| 1181 setLastChild(child); | 1179 setLastChild(child); |
| 1182 } | 1180 } |
| 1183 | 1181 |
| 1184 child->m_parent = this; | 1182 child->m_parent = this; |
| 1185 | 1183 |
| 1184 // The ancestor overflow layer is calculated during compositing inputs updat e and should not be set yet. | |
| 1185 ASSERT(!child->ancestorOverflowLayer()); | |
| 1186 | |
| 1186 setNeedsCompositingInputsUpdate(); | 1187 setNeedsCompositingInputsUpdate(); |
| 1187 | 1188 |
| 1188 if (!child->stackingNode()->isStacked() && !layoutObject()->documentBeingDes troyed()) | 1189 if (!child->stackingNode()->isStacked() && !layoutObject()->documentBeingDes troyed()) |
| 1189 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); | 1190 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); |
| 1190 | 1191 |
| 1191 if (child->stackingNode()->isStacked() || child->firstChild()) { | 1192 if (child->stackingNode()->isStacked() || child->firstChild()) { |
| 1192 // Dirty the z-order list in which we are contained. The ancestorStackin gContextNode() can be null in the | 1193 // Dirty the z-order list in which we are contained. The ancestorStackin gContextNode() can be null in the |
| 1193 // case where we're building up generated content layers. This is ok, si nce the lists will start | 1194 // case where we're building up generated content layers. This is ok, si nce the lists will start |
| 1194 // off dirty in that case anyway. | 1195 // off dirty in that case anyway. |
| 1195 child->stackingNode()->dirtyStackingContextZOrderLists(); | 1196 child->stackingNode()->dirtyStackingContextZOrderLists(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1229 // |stackingContext| value. | 1230 // |stackingContext| value. |
| 1230 oldChild->stackingNode()->dirtyStackingContextZOrderLists(); | 1231 oldChild->stackingNode()->dirtyStackingContextZOrderLists(); |
| 1231 } | 1232 } |
| 1232 | 1233 |
| 1233 if (layoutObject()->style()->visibility() != VISIBLE) | 1234 if (layoutObject()->style()->visibility() != VISIBLE) |
| 1234 dirtyVisibleContentStatus(); | 1235 dirtyVisibleContentStatus(); |
| 1235 | 1236 |
| 1236 oldChild->setPreviousSibling(0); | 1237 oldChild->setPreviousSibling(0); |
| 1237 oldChild->setNextSibling(0); | 1238 oldChild->setNextSibling(0); |
| 1238 oldChild->m_parent = 0; | 1239 oldChild->m_parent = 0; |
| 1240 if (oldChild->ancestorOverflowLayer()) | |
| 1241 oldChild->ancestorOverflowLayer()->getScrollableArea()->invalidateSticky ConstraintsFor(oldChild); | |
| 1242 oldChild->updateAncestorOverflowLayer(nullptr); | |
|
flackr
2016/04/12 14:26:25
In order to ensure we don't have any stale ancesto
| |
| 1239 | 1243 |
| 1240 dirtyAncestorChainHasSelfPaintingLayerDescendantStatus(); | 1244 dirtyAncestorChainHasSelfPaintingLayerDescendantStatus(); |
| 1241 | 1245 |
| 1242 oldChild->updateDescendantDependentFlags(); | 1246 oldChild->updateDescendantDependentFlags(); |
| 1243 | 1247 |
| 1244 if (oldChild->m_hasVisibleContent || oldChild->m_hasVisibleDescendant) | 1248 if (oldChild->m_hasVisibleContent || oldChild->m_hasVisibleDescendant) |
| 1245 dirtyAncestorChainVisibleDescendantStatus(); | 1249 dirtyAncestorChainVisibleDescendantStatus(); |
| 1246 | 1250 |
| 1247 if (oldChild->enclosingPaginationLayer()) | 1251 if (oldChild->enclosingPaginationLayer()) |
| 1248 oldChild->clearPaginationRecursive(); | 1252 oldChild->clearPaginationRecursive(); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1278 if (PaintLayerReflectionInfo* reflectionInfo = this->reflectionInfo()) | 1282 if (PaintLayerReflectionInfo* reflectionInfo = this->reflectionInfo()) |
| 1279 removeChild(reflectionInfo->reflectionLayer()); | 1283 removeChild(reflectionInfo->reflectionLayer()); |
| 1280 | 1284 |
| 1281 // Now walk our kids and reattach them to our parent. | 1285 // Now walk our kids and reattach them to our parent. |
| 1282 PaintLayer* current = m_first; | 1286 PaintLayer* current = m_first; |
| 1283 while (current) { | 1287 while (current) { |
| 1284 PaintLayer* next = current->nextSibling(); | 1288 PaintLayer* next = current->nextSibling(); |
| 1285 removeChild(current); | 1289 removeChild(current); |
| 1286 m_parent->addChild(current, nextSib); | 1290 m_parent->addChild(current, nextSib); |
| 1287 | 1291 |
| 1292 // Remove ourselves from descendant overflow layers. | |
| 1293 current->removeAncestorOverflowLayer(this); | |
| 1294 | |
| 1288 // FIXME: We should call a specialized version of this function. | 1295 // FIXME: We should call a specialized version of this function. |
| 1289 current->updateLayerPositionsAfterLayout(); | 1296 current->updateLayerPositionsAfterLayout(); |
| 1290 current = next; | 1297 current = next; |
| 1291 } | 1298 } |
| 1292 | 1299 |
| 1293 // Remove us from the parent. | 1300 // Remove us from the parent. |
| 1294 m_parent->removeChild(this); | 1301 m_parent->removeChild(this); |
| 1295 m_layoutObject->destroyLayer(); | 1302 m_layoutObject->destroyLayer(); |
| 1296 } | 1303 } |
| 1297 | 1304 |
| (...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2657 } | 2664 } |
| 2658 | 2665 |
| 2659 PaintLayerFilterInfo& PaintLayer::ensureFilterInfo() | 2666 PaintLayerFilterInfo& PaintLayer::ensureFilterInfo() |
| 2660 { | 2667 { |
| 2661 PaintLayerRareData& rareData = ensureRareData(); | 2668 PaintLayerRareData& rareData = ensureRareData(); |
| 2662 if (!rareData.filterInfo) | 2669 if (!rareData.filterInfo) |
| 2663 rareData.filterInfo = adoptPtr(new PaintLayerFilterInfo(this)); | 2670 rareData.filterInfo = adoptPtr(new PaintLayerFilterInfo(this)); |
| 2664 return *rareData.filterInfo; | 2671 return *rareData.filterInfo; |
| 2665 } | 2672 } |
| 2666 | 2673 |
| 2674 void PaintLayer::removeAncestorOverflowLayer(const PaintLayer* removedLayer) | |
| 2675 { | |
| 2676 // If the current ancestor overflow layer does not match the removed layer | |
| 2677 // the ancestor overflow layer has changed so we can stop searching. | |
| 2678 if (ancestorOverflowLayer() && ancestorOverflowLayer() != removedLayer) | |
| 2679 return; | |
| 2680 | |
| 2681 updateAncestorOverflowLayer(nullptr); | |
| 2682 PaintLayer* current = m_first; | |
| 2683 while (current) { | |
| 2684 current->removeAncestorOverflowLayer(removedLayer); | |
| 2685 current = current->nextSibling(); | |
| 2686 } | |
| 2687 } | |
| 2688 | |
| 2667 void PaintLayer::updateOrRemoveFilterClients() | 2689 void PaintLayer::updateOrRemoveFilterClients() |
| 2668 { | 2690 { |
| 2669 const auto& filter = layoutObject()->style()->filter(); | 2691 const auto& filter = layoutObject()->style()->filter(); |
| 2670 if (filter.isEmpty() && m_rareData) { | 2692 if (filter.isEmpty() && m_rareData) { |
| 2671 m_rareData->filterInfo = nullptr; | 2693 m_rareData->filterInfo = nullptr; |
| 2672 } else if (filter.hasReferenceFilter()) { | 2694 } else if (filter.hasReferenceFilter()) { |
| 2673 ensureFilterInfo().updateReferenceFilterClients(filter); | 2695 ensureFilterInfo().updateReferenceFilterClients(filter); |
| 2674 } else if (filterInfo()) { | 2696 } else if (filterInfo()) { |
| 2675 filterInfo()->clearFilterReferences(); | 2697 filterInfo()->clearFilterReferences(); |
| 2676 } | 2698 } |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2876 | 2898 |
| 2877 void showLayerTree(const blink::LayoutObject* layoutObject) | 2899 void showLayerTree(const blink::LayoutObject* layoutObject) |
| 2878 { | 2900 { |
| 2879 if (!layoutObject) { | 2901 if (!layoutObject) { |
| 2880 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); | 2902 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); |
| 2881 return; | 2903 return; |
| 2882 } | 2904 } |
| 2883 showLayerTree(layoutObject->enclosingLayer()); | 2905 showLayerTree(layoutObject->enclosingLayer()); |
| 2884 } | 2906 } |
| 2885 #endif | 2907 #endif |
| OLD | NEW |