OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 } else { | 1079 } else { |
1080 // The controls are in the same 2D space as the compositing container, so
we can map them into the space of the container. | 1080 // The controls are in the same 2D space as the compositing container, so
we can map them into the space of the container. |
1081 TransformState transformState(TransformState::ApplyTransformDirection, | 1081 TransformState transformState(TransformState::ApplyTransformDirection, |
1082 FloatPoint()); | 1082 FloatPoint()); |
1083 m_owningLayer.layoutObject()->mapLocalToAncestor( | 1083 m_owningLayer.layoutObject()->mapLocalToAncestor( |
1084 compositingStackingContext->layoutObject(), transformState, | 1084 compositingStackingContext->layoutObject(), transformState, |
1085 ApplyContainerFlip); | 1085 ApplyContainerFlip); |
1086 transformState.flatten(); | 1086 transformState.flatten(); |
1087 hostLayerPosition = LayoutPoint(transformState.lastPlanarPoint()); | 1087 hostLayerPosition = LayoutPoint(transformState.lastPlanarPoint()); |
1088 if (PaintLayerScrollableArea* scrollableArea = | 1088 if (PaintLayerScrollableArea* scrollableArea = |
1089 compositingStackingContext->getScrollableArea()) | 1089 compositingStackingContext->getScrollableArea()) { |
1090 hostLayerPosition.move( | 1090 hostLayerPosition.move( |
1091 LayoutSize(scrollableArea->adjustedScrollOffset())); | 1091 LayoutSize(toFloatSize(scrollableArea->scrollPosition()))); |
| 1092 } |
1092 hostLayerPosition.move(-stackingOffsetFromLayoutObject); | 1093 hostLayerPosition.move(-stackingOffsetFromLayoutObject); |
1093 } | 1094 } |
1094 } else { | 1095 } else { |
1095 hostLayerPosition.move(-m_graphicsLayer->offsetFromLayoutObject()); | 1096 hostLayerPosition.move(-m_graphicsLayer->offsetFromLayoutObject()); |
1096 } | 1097 } |
1097 | 1098 |
1098 m_overflowControlsHostLayer->setPosition(FloatPoint(hostLayerPosition)); | 1099 m_overflowControlsHostLayer->setPosition(FloatPoint(hostLayerPosition)); |
1099 | 1100 |
1100 const IntRect borderBox = | 1101 const IntRect borderBox = |
1101 toLayoutBox(m_owningLayer.layoutObject())->pixelSnappedBorderBoxRect(); | 1102 toLayoutBox(m_owningLayer.layoutObject())->pixelSnappedBorderBoxRect(); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 | 1189 |
1189 void CompositedLayerMapping::updateScrollingLayerGeometry( | 1190 void CompositedLayerMapping::updateScrollingLayerGeometry( |
1190 const IntRect& localCompositingBounds) { | 1191 const IntRect& localCompositingBounds) { |
1191 if (!m_scrollingLayer) | 1192 if (!m_scrollingLayer) |
1192 return; | 1193 return; |
1193 | 1194 |
1194 ASSERT(m_scrollingContentsLayer); | 1195 ASSERT(m_scrollingContentsLayer); |
1195 LayoutBox* layoutBox = toLayoutBox(layoutObject()); | 1196 LayoutBox* layoutBox = toLayoutBox(layoutObject()); |
1196 IntRect overflowClipRect = | 1197 IntRect overflowClipRect = |
1197 enclosingIntRect(layoutBox->overflowClipRect(LayoutPoint())); | 1198 enclosingIntRect(layoutBox->overflowClipRect(LayoutPoint())); |
1198 DoubleSize adjustedScrollOffset = | 1199 FloatPoint scrollPosition = |
1199 m_owningLayer.getScrollableArea()->adjustedScrollOffset(); | 1200 m_owningLayer.getScrollableArea()->scrollPosition(); |
1200 m_scrollingLayer->setPosition(FloatPoint( | 1201 m_scrollingLayer->setPosition(FloatPoint( |
1201 overflowClipRect.location() - localCompositingBounds.location() + | 1202 overflowClipRect.location() - localCompositingBounds.location() + |
1202 roundedIntSize(m_owningLayer.subpixelAccumulation()))); | 1203 roundedIntSize(m_owningLayer.subpixelAccumulation()))); |
1203 m_scrollingLayer->setSize(FloatSize(overflowClipRect.size())); | 1204 m_scrollingLayer->setSize(FloatSize(overflowClipRect.size())); |
1204 | 1205 |
1205 IntSize oldScrollingLayerOffset = m_scrollingLayer->offsetFromLayoutObject(); | 1206 IntSize oldScrollingLayerOffset = m_scrollingLayer->offsetFromLayoutObject(); |
1206 m_scrollingLayer->setOffsetFromLayoutObject( | 1207 m_scrollingLayer->setOffsetFromLayoutObject( |
1207 -toIntSize(overflowClipRect.location())); | 1208 -toIntSize(overflowClipRect.location())); |
1208 | 1209 |
1209 if (m_childClippingMaskLayer && !layoutObject()->style()->clipPath()) { | 1210 if (m_childClippingMaskLayer && !layoutObject()->style()->clipPath()) { |
1210 m_childClippingMaskLayer->setPosition(m_scrollingLayer->position()); | 1211 m_childClippingMaskLayer->setPosition(m_scrollingLayer->position()); |
1211 m_childClippingMaskLayer->setSize(m_scrollingLayer->size()); | 1212 m_childClippingMaskLayer->setSize(m_scrollingLayer->size()); |
1212 m_childClippingMaskLayer->setOffsetFromLayoutObject( | 1213 m_childClippingMaskLayer->setOffsetFromLayoutObject( |
1213 toIntSize(overflowClipRect.location())); | 1214 toIntSize(overflowClipRect.location())); |
1214 } | 1215 } |
1215 | 1216 |
1216 bool overflowClipRectOffsetChanged = | 1217 bool overflowClipRectOffsetChanged = |
1217 oldScrollingLayerOffset != m_scrollingLayer->offsetFromLayoutObject(); | 1218 oldScrollingLayerOffset != m_scrollingLayer->offsetFromLayoutObject(); |
1218 | 1219 |
1219 IntSize scrollSize(layoutBox->scrollWidth().toInt(), | 1220 IntSize scrollSize(layoutBox->scrollWidth().toInt(), |
1220 layoutBox->scrollHeight().toInt()); | 1221 layoutBox->scrollHeight().toInt()); |
1221 if (scrollSize != m_scrollingContentsLayer->size() || | 1222 if (scrollSize != m_scrollingContentsLayer->size() || |
1222 overflowClipRectOffsetChanged) | 1223 overflowClipRectOffsetChanged) |
1223 m_scrollingContentsLayer->setNeedsDisplay(); | 1224 m_scrollingContentsLayer->setNeedsDisplay(); |
1224 | 1225 |
1225 DoubleSize scrollingContentsOffset( | 1226 DoubleSize scrollingContentsOffset( |
1226 overflowClipRect.location().x() - adjustedScrollOffset.width(), | 1227 overflowClipRect.location().x() - scrollPosition.x(), |
1227 overflowClipRect.location().y() - adjustedScrollOffset.height()); | 1228 overflowClipRect.location().y() - scrollPosition.y()); |
1228 // The scroll offset change is compared using floating point so that fractiona
l scroll offset | 1229 // The scroll offset change is compared using floating point so that fractiona
l scroll offset |
1229 // change can be propagated to compositor. | 1230 // change can be propagated to compositor. |
1230 if (scrollingContentsOffset != m_scrollingContentsOffset || | 1231 if (scrollingContentsOffset != m_scrollingContentsOffset || |
1231 scrollSize != m_scrollingContentsLayer->size()) { | 1232 scrollSize != m_scrollingContentsLayer->size()) { |
1232 bool coordinatorHandlesOffset = | 1233 bool coordinatorHandlesOffset = |
1233 compositor()->scrollingLayerDidChange(&m_owningLayer); | 1234 compositor()->scrollingLayerDidChange(&m_owningLayer); |
1234 m_scrollingContentsLayer->setPosition( | 1235 m_scrollingContentsLayer->setPosition( |
1235 coordinatorHandlesOffset | 1236 coordinatorHandlesOffset ? FloatPoint() |
1236 ? FloatPoint() | 1237 : FloatPoint(-toFloatSize(scrollPosition))); |
1237 : FloatPoint(-toFloatSize(adjustedScrollOffset))); | |
1238 } | 1238 } |
1239 m_scrollingContentsOffset = scrollingContentsOffset; | 1239 m_scrollingContentsOffset = scrollingContentsOffset; |
1240 | 1240 |
1241 m_scrollingContentsLayer->setSize(FloatSize(scrollSize)); | 1241 m_scrollingContentsLayer->setSize(FloatSize(scrollSize)); |
1242 | 1242 |
1243 IntPoint scrollingContentsLayerOffsetFromLayoutObject; | 1243 IntPoint scrollingContentsLayerOffsetFromLayoutObject; |
1244 if (PaintLayerScrollableArea* scrollableArea = | 1244 if (PaintLayerScrollableArea* scrollableArea = |
1245 m_owningLayer.getScrollableArea()) { | 1245 m_owningLayer.getScrollableArea()) { |
1246 scrollingContentsLayerOffsetFromLayoutObject = | 1246 scrollingContentsLayerOffsetFromLayoutObject = |
1247 -scrollableArea->scrollOrigin(); | 1247 -scrollableArea->scrollOrigin(); |
(...skipping 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2815 } | 2815 } |
2816 | 2816 |
2817 void CompositedLayerMapping::adjustForCompositedScrolling( | 2817 void CompositedLayerMapping::adjustForCompositedScrolling( |
2818 const GraphicsLayer* graphicsLayer, | 2818 const GraphicsLayer* graphicsLayer, |
2819 IntSize& offset) const { | 2819 IntSize& offset) const { |
2820 if (graphicsLayer == m_scrollingContentsLayer.get() || | 2820 if (graphicsLayer == m_scrollingContentsLayer.get() || |
2821 graphicsLayer == m_foregroundLayer.get()) { | 2821 graphicsLayer == m_foregroundLayer.get()) { |
2822 if (PaintLayerScrollableArea* scrollableArea = | 2822 if (PaintLayerScrollableArea* scrollableArea = |
2823 m_owningLayer.getScrollableArea()) { | 2823 m_owningLayer.getScrollableArea()) { |
2824 if (scrollableArea->usesCompositedScrolling()) { | 2824 if (scrollableArea->usesCompositedScrolling()) { |
2825 // Note: this is just the scroll offset, *not* the "adjusted scroll offs
et". Scroll offset | 2825 // Note: this is the offset from the beginning of flow of the block, not
the |
2826 // does not include the origin adjustment. That is instead baked already
into offsetFromLayoutObject. | 2826 // offset from the top/left of the overflow rect. offsetFromLayoutObjec
t adds |
2827 DoubleSize scrollOffset = scrollableArea->scrollOffset(); | 2827 // the origin offset from top/left to the beginning of flow. |
| 2828 ScrollOffset scrollOffset = scrollableArea->scrollOffset(); |
2828 offset.expand(-scrollOffset.width(), -scrollOffset.height()); | 2829 offset.expand(-scrollOffset.width(), -scrollOffset.height()); |
2829 } | 2830 } |
2830 } | 2831 } |
2831 } | 2832 } |
2832 } | 2833 } |
2833 | 2834 |
2834 void CompositedLayerMapping::paintContents( | 2835 void CompositedLayerMapping::paintContents( |
2835 const GraphicsLayer* graphicsLayer, | 2836 const GraphicsLayer* graphicsLayer, |
2836 GraphicsContext& context, | 2837 GraphicsContext& context, |
2837 GraphicsLayerPaintingPhase graphicsLayerPaintingPhase, | 2838 GraphicsLayerPaintingPhase graphicsLayerPaintingPhase, |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3153 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { | 3154 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { |
3154 name = "Scrolling Contents Layer"; | 3155 name = "Scrolling Contents Layer"; |
3155 } else { | 3156 } else { |
3156 ASSERT_NOT_REACHED(); | 3157 ASSERT_NOT_REACHED(); |
3157 } | 3158 } |
3158 | 3159 |
3159 return name; | 3160 return name; |
3160 } | 3161 } |
3161 | 3162 |
3162 } // namespace blink | 3163 } // namespace blink |
OLD | NEW |