| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 // in this case, there is no need to dirty our ancestors further. | 244 // in this case, there is no need to dirty our ancestors further. |
| 245 if (layer->isSelfPaintingLayer()) { | 245 if (layer->isSelfPaintingLayer()) { |
| 246 ASSERT(!parent() || parent()->m_hasSelfPaintingLayerDescendantDirty
|| parent()->m_hasSelfPaintingLayerDescendant); | 246 ASSERT(!parent() || parent()->m_hasSelfPaintingLayerDescendantDirty
|| parent()->m_hasSelfPaintingLayerDescendant); |
| 247 break; | 247 break; |
| 248 } | 248 } |
| 249 } | 249 } |
| 250 } | 250 } |
| 251 | 251 |
| 252 bool RenderLayer::scrollsWithViewport() const | 252 bool RenderLayer::scrollsWithViewport() const |
| 253 { | 253 { |
| 254 return renderer()->style()->position() == FixedPosition && renderer()->conta
inerForFixedPosition() == renderer()->view(); | 254 // FIXME(sky): Remove |
| 255 return false; |
| 255 } | 256 } |
| 256 | 257 |
| 257 bool RenderLayer::scrollsWithRespectTo(const RenderLayer* other) const | 258 bool RenderLayer::scrollsWithRespectTo(const RenderLayer* other) const |
| 258 { | 259 { |
| 259 if (scrollsWithViewport() != other->scrollsWithViewport()) | 260 if (scrollsWithViewport() != other->scrollsWithViewport()) |
| 260 return true; | 261 return true; |
| 261 return ancestorScrollingLayer() != other->ancestorScrollingLayer(); | 262 return ancestorScrollingLayer() != other->ancestorScrollingLayer(); |
| 262 } | 263 } |
| 263 | 264 |
| 264 void RenderLayer::updateTransformationMatrix() | 265 void RenderLayer::updateTransformationMatrix() |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 { | 596 { |
| 596 if (!renderer()->hasTransform()) | 597 if (!renderer()->hasTransform()) |
| 597 return FloatPoint(); | 598 return FloatPoint(); |
| 598 | 599 |
| 599 const LayoutRect borderBox = toRenderBox(renderer())->borderBoxRect(); | 600 const LayoutRect borderBox = toRenderBox(renderer())->borderBoxRect(); |
| 600 RenderStyle* style = renderer()->style(); | 601 RenderStyle* style = renderer()->style(); |
| 601 | 602 |
| 602 return FloatPoint(floatValueForLength(style->perspectiveOriginX(), borderBox
.width().toFloat()), floatValueForLength(style->perspectiveOriginY(), borderBox.
height().toFloat())); | 603 return FloatPoint(floatValueForLength(style->perspectiveOriginX(), borderBox
.width().toFloat()), floatValueForLength(style->perspectiveOriginY(), borderBox.
height().toFloat())); |
| 603 } | 604 } |
| 604 | 605 |
| 605 static inline bool isFixedPositionedContainer(RenderLayer* layer) | |
| 606 { | |
| 607 return layer->isRootLayer() || layer->hasTransform(); | |
| 608 } | |
| 609 | |
| 610 RenderLayer* RenderLayer::enclosingPositionedAncestor() const | 606 RenderLayer* RenderLayer::enclosingPositionedAncestor() const |
| 611 { | 607 { |
| 612 RenderLayer* curr = parent(); | 608 RenderLayer* curr = parent(); |
| 613 while (curr && !curr->isPositionedContainer()) | 609 while (curr && !curr->isPositionedContainer()) |
| 614 curr = curr->parent(); | 610 curr = curr->parent(); |
| 615 | 611 |
| 616 return curr; | 612 return curr; |
| 617 } | 613 } |
| 618 | 614 |
| 619 RenderLayer* RenderLayer::enclosingTransformedAncestor() const | 615 RenderLayer* RenderLayer::enclosingTransformedAncestor() const |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 } | 1006 } |
| 1011 | 1007 |
| 1012 // Returns the layer reached on the walk up towards the ancestor. | 1008 // Returns the layer reached on the walk up towards the ancestor. |
| 1013 static inline const RenderLayer* accumulateOffsetTowardsAncestor(const RenderLay
er* layer, const RenderLayer* ancestorLayer, LayoutPoint& location) | 1009 static inline const RenderLayer* accumulateOffsetTowardsAncestor(const RenderLay
er* layer, const RenderLayer* ancestorLayer, LayoutPoint& location) |
| 1014 { | 1010 { |
| 1015 ASSERT(ancestorLayer != layer); | 1011 ASSERT(ancestorLayer != layer); |
| 1016 | 1012 |
| 1017 const RenderLayerModelObject* renderer = layer->renderer(); | 1013 const RenderLayerModelObject* renderer = layer->renderer(); |
| 1018 EPosition position = renderer->style()->position(); | 1014 EPosition position = renderer->style()->position(); |
| 1019 | 1015 |
| 1020 // FIXME: Positioning of out-of-flow(fixed, absolute) elements collected in
a RenderFlowThread | |
| 1021 // may need to be revisited in a future patch. | |
| 1022 // If the fixed renderer is inside a RenderFlowThread, we should not compute
location using localToAbsolute, | |
| 1023 // since localToAbsolute maps the coordinates from flow thread to regions co
ordinates and regions can be | |
| 1024 // positioned in a completely different place in the viewport (RenderView). | |
| 1025 if (position == FixedPosition && (!ancestorLayer || ancestorLayer == rendere
r->view()->layer())) { | |
| 1026 // If the fixed layer's container is the root, just add in the offset of
the view. We can obtain this by calling | |
| 1027 // localToAbsolute() on the RenderView. | |
| 1028 FloatPoint absPos = renderer->localToAbsolute(FloatPoint(), IsFixed); | |
| 1029 location += LayoutSize(absPos.x(), absPos.y()); | |
| 1030 return ancestorLayer; | |
| 1031 } | |
| 1032 | |
| 1033 // For the fixed positioned elements inside a render flow thread, we should
also skip the code path below | |
| 1034 // Otherwise, for the case of ancestorLayer == rootLayer and fixed positione
d element child of a transformed | |
| 1035 // element in render flow thread, we will hit the fixed positioned container
before hitting the ancestor layer. | |
| 1036 if (position == FixedPosition) { | |
| 1037 // For a fixed layers, we need to walk up to the root to see if there's
a fixed position container | |
| 1038 // (e.g. a transformed layer). It's an error to call convertToLayerCoord
s() across a layer with a transform, | |
| 1039 // so we should always find the ancestor at or before we find the fixed
position container. | |
| 1040 RenderLayer* fixedPositionContainerLayer = 0; | |
| 1041 bool foundAncestor = false; | |
| 1042 for (RenderLayer* currLayer = layer->parent(); currLayer; currLayer = cu
rrLayer->parent()) { | |
| 1043 if (currLayer == ancestorLayer) | |
| 1044 foundAncestor = true; | |
| 1045 | |
| 1046 if (isFixedPositionedContainer(currLayer)) { | |
| 1047 fixedPositionContainerLayer = currLayer; | |
| 1048 ASSERT_UNUSED(foundAncestor, foundAncestor); | |
| 1049 break; | |
| 1050 } | |
| 1051 } | |
| 1052 | |
| 1053 ASSERT(fixedPositionContainerLayer); // We should have hit the RenderVie
w's layer at least. | |
| 1054 | |
| 1055 if (fixedPositionContainerLayer != ancestorLayer) { | |
| 1056 LayoutPoint fixedContainerCoords; | |
| 1057 layer->convertToLayerCoords(fixedPositionContainerLayer, fixedContai
nerCoords); | |
| 1058 | |
| 1059 LayoutPoint ancestorCoords; | |
| 1060 ancestorLayer->convertToLayerCoords(fixedPositionContainerLayer, anc
estorCoords); | |
| 1061 | |
| 1062 location += (fixedContainerCoords - ancestorCoords); | |
| 1063 } else { | |
| 1064 location += toSize(layer->location()); | |
| 1065 } | |
| 1066 return ancestorLayer; | |
| 1067 } | |
| 1068 | |
| 1069 RenderLayer* parentLayer; | 1016 RenderLayer* parentLayer; |
| 1070 if (position == AbsolutePosition || position == FixedPosition) { | 1017 if (position == AbsolutePosition) { |
| 1071 // Do what enclosingPositionedAncestor() does, but check for ancestorLay
er along the way. | 1018 // Do what enclosingPositionedAncestor() does, but check for ancestorLay
er along the way. |
| 1072 parentLayer = layer->parent(); | 1019 parentLayer = layer->parent(); |
| 1073 bool foundAncestorFirst = false; | 1020 bool foundAncestorFirst = false; |
| 1074 while (parentLayer) { | 1021 while (parentLayer) { |
| 1075 // RenderFlowThread is a positioned container, child of RenderView,
positioned at (0,0). | 1022 // RenderFlowThread is a positioned container, child of RenderView,
positioned at (0,0). |
| 1076 // This implies that, for out-of-flow positioned elements inside a R
enderFlowThread, | 1023 // This implies that, for out-of-flow positioned elements inside a R
enderFlowThread, |
| 1077 // we are bailing out before reaching root layer. | 1024 // we are bailing out before reaching root layer. |
| 1078 if (parentLayer->isPositionedContainer()) | 1025 if (parentLayer->isPositionedContainer()) |
| 1079 break; | 1026 break; |
| 1080 | 1027 |
| (...skipping 1763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2844 } | 2791 } |
| 2845 } | 2792 } |
| 2846 | 2793 |
| 2847 void showLayerTree(const blink::RenderObject* renderer) | 2794 void showLayerTree(const blink::RenderObject* renderer) |
| 2848 { | 2795 { |
| 2849 if (!renderer) | 2796 if (!renderer) |
| 2850 return; | 2797 return; |
| 2851 showLayerTree(renderer->enclosingLayer()); | 2798 showLayerTree(renderer->enclosingLayer()); |
| 2852 } | 2799 } |
| 2853 #endif | 2800 #endif |
| OLD | NEW |