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 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 } | 745 } |
746 curr = curr->parent(); | 746 curr = curr->parent(); |
747 } | 747 } |
748 if (curr->isBox() && curr->isTableRow()) { | 748 if (curr->isBox() && curr->isTableRow()) { |
749 // Put ourselves into the row coordinate space. | 749 // Put ourselves into the row coordinate space. |
750 localPoint.moveBy(-toLayoutBox(curr)->topLeftLocation()); | 750 localPoint.moveBy(-toLayoutBox(curr)->topLeftLocation()); |
751 } | 751 } |
752 } | 752 } |
753 | 753 |
754 // Subtract our parent's scroll offset. | 754 // Subtract our parent's scroll offset. |
755 if (PaintLayer* positionedParent = layoutObject()->isOutOfFlowPositioned() ?
enclosingPositionedAncestor() : nullptr) { | 755 if (PaintLayer* containingLayer = layoutObject()->isOutOfFlowPositioned() ?
containingLayerForOutOfFlowPositioned() : nullptr) { |
756 // For positioned layers, we subtract out the enclosing positioned layer
's scroll offset. | 756 // For positioned layers, we subtract out the enclosing positioned layer
's scroll offset. |
757 if (positionedParent->layoutObject()->hasOverflowClip()) { | 757 if (containingLayer->layoutObject()->hasOverflowClip()) { |
758 IntSize offset = positionedParent->layoutBox()->scrolledContentOffse
t(); | 758 IntSize offset = containingLayer->layoutBox()->scrolledContentOffset
(); |
759 localPoint -= offset; | 759 localPoint -= offset; |
760 } | 760 } |
761 | 761 |
762 if (positionedParent->layoutObject()->isInFlowPositioned() && positioned
Parent->layoutObject()->isLayoutInline()) { | 762 if (containingLayer->layoutObject()->isInFlowPositioned() && containingL
ayer->layoutObject()->isLayoutInline()) { |
763 LayoutSize offset = toLayoutInline(positionedParent->layoutObject())
->offsetForInFlowPositionedInline(*toLayoutBox(layoutObject())); | 763 LayoutSize offset = toLayoutInline(containingLayer->layoutObject())-
>offsetForInFlowPositionedInline(*toLayoutBox(layoutObject())); |
764 localPoint += offset; | 764 localPoint += offset; |
765 } | 765 } |
766 } else if (parent() && parent()->layoutObject()->hasOverflowClip()) { | 766 } else if (parent() && parent()->layoutObject()->hasOverflowClip()) { |
767 IntSize scrollOffset = parent()->layoutBox()->scrolledContentOffset(); | 767 IntSize scrollOffset = parent()->layoutBox()->scrolledContentOffset(); |
768 localPoint -= scrollOffset; | 768 localPoint -= scrollOffset; |
769 } | 769 } |
770 | 770 |
771 bool positionOrOffsetChanged = false; | 771 bool positionOrOffsetChanged = false; |
772 if (layoutObject()->isInFlowPositioned()) { | 772 if (layoutObject()->isInFlowPositioned()) { |
773 LayoutSize newOffset = layoutObject()->offsetForInFlowPosition(); | 773 LayoutSize newOffset = layoutObject()->offsetForInFlowPosition(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 { | 811 { |
812 if (!layoutObject()->hasTransformRelatedProperty()) | 812 if (!layoutObject()->hasTransformRelatedProperty()) |
813 return FloatPoint(); | 813 return FloatPoint(); |
814 | 814 |
815 const LayoutRect borderBox = toLayoutBox(layoutObject())->borderBoxRect(); | 815 const LayoutRect borderBox = toLayoutBox(layoutObject())->borderBoxRect(); |
816 const ComputedStyle& style = layoutObject()->styleRef(); | 816 const ComputedStyle& style = layoutObject()->styleRef(); |
817 | 817 |
818 return FloatPoint(floatValueForLength(style.perspectiveOriginX(), borderBox.
width().toFloat()), floatValueForLength(style.perspectiveOriginY(), borderBox.he
ight().toFloat())); | 818 return FloatPoint(floatValueForLength(style.perspectiveOriginX(), borderBox.
width().toFloat()), floatValueForLength(style.perspectiveOriginY(), borderBox.he
ight().toFloat())); |
819 } | 819 } |
820 | 820 |
821 static inline bool isFixedPositionedContainer(PaintLayer* layer) | 821 static inline bool isContainerForFixedPositioned(PaintLayer* layer) |
822 { | 822 { |
823 return layer->isRootLayer() || layer->hasTransformRelatedProperty(); | 823 return layer->isRootLayer() || layer->hasTransformRelatedProperty(); |
824 } | 824 } |
825 | 825 |
826 PaintLayer* PaintLayer::enclosingPositionedAncestor(const PaintLayer* ancestor,
bool* skippedAncestor) const | 826 static inline bool isContainerForPositioned(PaintLayer* layer) |
| 827 { |
| 828 // FIXME: This is not in sync with containingBlock. |
| 829 // LayoutObject::canContainFixedPositionObjects() should probably be used |
| 830 // instead. |
| 831 LayoutBoxModelObject* layerlayoutObject = layer->layoutObject(); |
| 832 return layer->isRootLayer() || layerlayoutObject->isPositioned() || layer->h
asTransformRelatedProperty() || layerlayoutObject->style()->containsPaint(); |
| 833 } |
| 834 |
| 835 PaintLayer* PaintLayer::containingLayerForOutOfFlowPositioned(const PaintLayer*
ancestor, bool* skippedAncestor) const |
827 { | 836 { |
828 ASSERT(!ancestor || skippedAncestor); // If we have specified an ancestor, s
urely the caller needs to know whether we skipped it. | 837 ASSERT(!ancestor || skippedAncestor); // If we have specified an ancestor, s
urely the caller needs to know whether we skipped it. |
829 if (skippedAncestor) | 838 if (skippedAncestor) |
830 *skippedAncestor = false; | 839 *skippedAncestor = false; |
831 if (layoutObject()->style()->position() == FixedPosition) { | 840 if (layoutObject()->style()->position() == FixedPosition) { |
832 PaintLayer* curr = parent(); | 841 PaintLayer* curr = parent(); |
833 while (curr && !isFixedPositionedContainer(curr)) { | 842 while (curr && !isContainerForFixedPositioned(curr)) { |
834 if (skippedAncestor && curr == ancestor) | 843 if (skippedAncestor && curr == ancestor) |
835 *skippedAncestor = true; | 844 *skippedAncestor = true; |
836 curr = curr->parent(); | 845 curr = curr->parent(); |
837 } | 846 } |
838 | 847 |
839 return curr; | 848 return curr; |
840 } | 849 } |
841 | 850 |
842 PaintLayer* curr = parent(); | 851 PaintLayer* curr = parent(); |
843 while (curr && !curr->isPositionedContainer()) { | 852 while (curr && !isContainerForPositioned(curr)) { |
844 if (skippedAncestor && curr == ancestor) | 853 if (skippedAncestor && curr == ancestor) |
845 *skippedAncestor = true; | 854 *skippedAncestor = true; |
846 curr = curr->parent(); | 855 curr = curr->parent(); |
847 } | 856 } |
848 | 857 |
849 return curr; | 858 return curr; |
850 } | 859 } |
851 | 860 |
852 PaintLayer* PaintLayer::enclosingTransformedAncestor() const | 861 PaintLayer* PaintLayer::enclosingTransformedAncestor() const |
853 { | 862 { |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 // If the fixed layer's container is the root, just add in the offset of
the view. We can obtain this by calling | 1279 // If the fixed layer's container is the root, just add in the offset of
the view. We can obtain this by calling |
1271 // localToAbsolute() on the LayoutView. | 1280 // localToAbsolute() on the LayoutView. |
1272 FloatPoint absPos = layoutObject->localToAbsolute(FloatPoint(), IsFixed)
; | 1281 FloatPoint absPos = layoutObject->localToAbsolute(FloatPoint(), IsFixed)
; |
1273 location += LayoutSize(absPos.x(), absPos.y()); | 1282 location += LayoutSize(absPos.x(), absPos.y()); |
1274 return ancestorLayer; | 1283 return ancestorLayer; |
1275 } | 1284 } |
1276 | 1285 |
1277 PaintLayer* parentLayer; | 1286 PaintLayer* parentLayer; |
1278 if (position == AbsolutePosition || position == FixedPosition) { | 1287 if (position == AbsolutePosition || position == FixedPosition) { |
1279 bool foundAncestorFirst; | 1288 bool foundAncestorFirst; |
1280 parentLayer = layer->enclosingPositionedAncestor(ancestorLayer, &foundAn
cestorFirst); | 1289 parentLayer = layer->containingLayerForOutOfFlowPositioned(ancestorLayer
, &foundAncestorFirst); |
1281 | 1290 |
1282 if (foundAncestorFirst) { | 1291 if (foundAncestorFirst) { |
1283 // Found ancestorLayer before the container of the out-of-flow objec
t, so compute offset | 1292 // Found ancestorLayer before the container of the out-of-flow objec
t, so compute offset |
1284 // of both relative to the container and subtract. | 1293 // of both relative to the container and subtract. |
1285 | 1294 |
1286 LayoutPoint thisCoords; | 1295 LayoutPoint thisCoords; |
1287 layer->convertToLayerCoords(parentLayer, thisCoords); | 1296 layer->convertToLayerCoords(parentLayer, thisCoords); |
1288 | 1297 |
1289 LayoutPoint ancestorCoords; | 1298 LayoutPoint ancestorCoords; |
1290 ancestorLayer->convertToLayerCoords(parentLayer, ancestorCoords); | 1299 ancestorLayer->convertToLayerCoords(parentLayer, ancestorCoords); |
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2364 if (m_stackingNode->zOrderListsDirty()) | 2373 if (m_stackingNode->zOrderListsDirty()) |
2365 return false; | 2374 return false; |
2366 | 2375 |
2367 // FIXME: We currently only check the immediate layoutObject, | 2376 // FIXME: We currently only check the immediate layoutObject, |
2368 // which will miss many cases. | 2377 // which will miss many cases. |
2369 if (layoutObject()->backgroundIsKnownToBeOpaqueInRect(localRect)) | 2378 if (layoutObject()->backgroundIsKnownToBeOpaqueInRect(localRect)) |
2370 return true; | 2379 return true; |
2371 | 2380 |
2372 // We can't consult child layers if we clip, since they might cover | 2381 // We can't consult child layers if we clip, since they might cover |
2373 // parts of the rect that are clipped out. | 2382 // parts of the rect that are clipped out. |
2374 if (layoutObject()->hasOverflowClip()) | 2383 if (layoutObject()->hasOverflowClip() || layoutObject()->style()->containsPa
int()) |
2375 return false; | 2384 return false; |
2376 | 2385 |
2377 return childBackgroundIsKnownToBeOpaqueInRect(localRect); | 2386 return childBackgroundIsKnownToBeOpaqueInRect(localRect); |
2378 } | 2387 } |
2379 | 2388 |
2380 bool PaintLayer::childBackgroundIsKnownToBeOpaqueInRect(const LayoutRect& localR
ect) const | 2389 bool PaintLayer::childBackgroundIsKnownToBeOpaqueInRect(const LayoutRect& localR
ect) const |
2381 { | 2390 { |
2382 PaintLayerStackingNodeReverseIterator revertseIterator(*m_stackingNode, Posi
tiveZOrderChildren | NormalFlowChildren | NegativeZOrderChildren); | 2391 PaintLayerStackingNodeReverseIterator revertseIterator(*m_stackingNode, Posi
tiveZOrderChildren | NormalFlowChildren | NegativeZOrderChildren); |
2383 while (PaintLayerStackingNode* child = revertseIterator.next()) { | 2392 while (PaintLayerStackingNode* child = revertseIterator.next()) { |
2384 const PaintLayer* childLayer = child->layer(); | 2393 const PaintLayer* childLayer = child->layer(); |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2793 | 2802 |
2794 void showLayerTree(const blink::LayoutObject* layoutObject) | 2803 void showLayerTree(const blink::LayoutObject* layoutObject) |
2795 { | 2804 { |
2796 if (!layoutObject) { | 2805 if (!layoutObject) { |
2797 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); | 2806 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); |
2798 return; | 2807 return; |
2799 } | 2808 } |
2800 showLayerTree(layoutObject->enclosingLayer()); | 2809 showLayerTree(layoutObject->enclosingLayer()); |
2801 } | 2810 } |
2802 #endif | 2811 #endif |
OLD | NEW |