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

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp

Issue 2387883002: Use float for scroll offset. (Closed)
Patch Set: Created 4 years, 2 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) 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
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(LayoutSize(scrollableArea->offsetFromOrigin())); 1090 hostLayerPosition.move(
1091 LayoutSize(toFloatSize(scrollableArea->absolutePosition())));
1092 }
1091 hostLayerPosition.move(-stackingOffsetFromLayoutObject); 1093 hostLayerPosition.move(-stackingOffsetFromLayoutObject);
1092 } 1094 }
1093 } else { 1095 } else {
1094 hostLayerPosition.move(-m_graphicsLayer->offsetFromLayoutObject()); 1096 hostLayerPosition.move(-m_graphicsLayer->offsetFromLayoutObject());
1095 } 1097 }
1096 1098
1097 m_overflowControlsHostLayer->setPosition(FloatPoint(hostLayerPosition)); 1099 m_overflowControlsHostLayer->setPosition(FloatPoint(hostLayerPosition));
1098 1100
1099 const IntRect borderBox = 1101 const IntRect borderBox =
1100 toLayoutBox(m_owningLayer.layoutObject())->pixelSnappedBorderBoxRect(); 1102 toLayoutBox(m_owningLayer.layoutObject())->pixelSnappedBorderBoxRect();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 1189
1188 void CompositedLayerMapping::updateScrollingLayerGeometry( 1190 void CompositedLayerMapping::updateScrollingLayerGeometry(
1189 const IntRect& localCompositingBounds) { 1191 const IntRect& localCompositingBounds) {
1190 if (!m_scrollingLayer) 1192 if (!m_scrollingLayer)
1191 return; 1193 return;
1192 1194
1193 ASSERT(m_scrollingContentsLayer); 1195 ASSERT(m_scrollingContentsLayer);
1194 LayoutBox* layoutBox = toLayoutBox(layoutObject()); 1196 LayoutBox* layoutBox = toLayoutBox(layoutObject());
1195 IntRect overflowClipRect = 1197 IntRect overflowClipRect =
1196 enclosingIntRect(layoutBox->overflowClipRect(LayoutPoint())); 1198 enclosingIntRect(layoutBox->overflowClipRect(LayoutPoint()));
1197 DoubleSize scrollOffsetFromOrigin = 1199 FloatPoint scrollPosition =
1198 m_owningLayer.getScrollableArea()->offsetFromOrigin(); 1200 m_owningLayer.getScrollableArea()->absolutePosition();
1199 m_scrollingLayer->setPosition(FloatPoint( 1201 m_scrollingLayer->setPosition(FloatPoint(
1200 overflowClipRect.location() - localCompositingBounds.location() + 1202 overflowClipRect.location() - localCompositingBounds.location() +
1201 roundedIntSize(m_owningLayer.subpixelAccumulation()))); 1203 roundedIntSize(m_owningLayer.subpixelAccumulation())));
1202 m_scrollingLayer->setSize(FloatSize(overflowClipRect.size())); 1204 m_scrollingLayer->setSize(FloatSize(overflowClipRect.size()));
1203 1205
1204 IntSize oldScrollingLayerOffset = m_scrollingLayer->offsetFromLayoutObject(); 1206 IntSize oldScrollingLayerOffset = m_scrollingLayer->offsetFromLayoutObject();
1205 m_scrollingLayer->setOffsetFromLayoutObject( 1207 m_scrollingLayer->setOffsetFromLayoutObject(
1206 -toIntSize(overflowClipRect.location())); 1208 -toIntSize(overflowClipRect.location()));
1207 1209
1208 if (m_childClippingMaskLayer && !layoutObject()->style()->clipPath()) { 1210 if (m_childClippingMaskLayer && !layoutObject()->style()->clipPath()) {
1209 m_childClippingMaskLayer->setPosition(m_scrollingLayer->position()); 1211 m_childClippingMaskLayer->setPosition(m_scrollingLayer->position());
1210 m_childClippingMaskLayer->setSize(m_scrollingLayer->size()); 1212 m_childClippingMaskLayer->setSize(m_scrollingLayer->size());
1211 m_childClippingMaskLayer->setOffsetFromLayoutObject( 1213 m_childClippingMaskLayer->setOffsetFromLayoutObject(
1212 toIntSize(overflowClipRect.location())); 1214 toIntSize(overflowClipRect.location()));
1213 } 1215 }
1214 1216
1215 bool overflowClipRectOffsetChanged = 1217 bool overflowClipRectOffsetChanged =
1216 oldScrollingLayerOffset != m_scrollingLayer->offsetFromLayoutObject(); 1218 oldScrollingLayerOffset != m_scrollingLayer->offsetFromLayoutObject();
1217 1219
1218 IntSize scrollSize(layoutBox->scrollWidth().toInt(), 1220 IntSize scrollSize(layoutBox->scrollWidth().toInt(),
1219 layoutBox->scrollHeight().toInt()); 1221 layoutBox->scrollHeight().toInt());
1220 if (scrollSize != m_scrollingContentsLayer->size() || 1222 if (scrollSize != m_scrollingContentsLayer->size() ||
1221 overflowClipRectOffsetChanged) 1223 overflowClipRectOffsetChanged)
1222 m_scrollingContentsLayer->setNeedsDisplay(); 1224 m_scrollingContentsLayer->setNeedsDisplay();
1223 1225
1224 DoubleSize scrollingContentsOffset( 1226 DoubleSize scrollingContentsOffset(
1225 overflowClipRect.location().x() - scrollOffsetFromOrigin.width(), 1227 overflowClipRect.location().x() - scrollPosition.x(),
1226 overflowClipRect.location().y() - scrollOffsetFromOrigin.height()); 1228 overflowClipRect.location().y() - scrollPosition.y());
1227 // 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
1228 // change can be propagated to compositor. 1230 // change can be propagated to compositor.
1229 if (scrollingContentsOffset != m_scrollingContentsOffset || 1231 if (scrollingContentsOffset != m_scrollingContentsOffset ||
1230 scrollSize != m_scrollingContentsLayer->size()) { 1232 scrollSize != m_scrollingContentsLayer->size()) {
1231 bool coordinatorHandlesOffset = 1233 bool coordinatorHandlesOffset =
1232 compositor()->scrollingLayerDidChange(&m_owningLayer); 1234 compositor()->scrollingLayerDidChange(&m_owningLayer);
1233 m_scrollingContentsLayer->setPosition( 1235 m_scrollingContentsLayer->setPosition(
1234 coordinatorHandlesOffset 1236 coordinatorHandlesOffset ? FloatPoint()
1235 ? FloatPoint() 1237 : FloatPoint(-toFloatSize(scrollPosition)));
1236 : FloatPoint(-toFloatSize(scrollOffsetFromOrigin)));
1237 } 1238 }
1238 m_scrollingContentsOffset = scrollingContentsOffset; 1239 m_scrollingContentsOffset = scrollingContentsOffset;
1239 1240
1240 m_scrollingContentsLayer->setSize(FloatSize(scrollSize)); 1241 m_scrollingContentsLayer->setSize(FloatSize(scrollSize));
1241 1242
1242 IntPoint scrollingContentsLayerOffsetFromLayoutObject; 1243 IntPoint scrollingContentsLayerOffsetFromLayoutObject;
1243 if (PaintLayerScrollableArea* scrollableArea = 1244 if (PaintLayerScrollableArea* scrollableArea =
1244 m_owningLayer.getScrollableArea()) { 1245 m_owningLayer.getScrollableArea()) {
1245 scrollingContentsLayerOffsetFromLayoutObject = 1246 scrollingContentsLayerOffsetFromLayoutObject =
1246 -scrollableArea->scrollOrigin(); 1247 -scrollableArea->scrollOrigin();
(...skipping 1569 matching lines...) Expand 10 before | Expand all | Expand 10 after
2816 void CompositedLayerMapping::adjustForCompositedScrolling( 2817 void CompositedLayerMapping::adjustForCompositedScrolling(
2817 const GraphicsLayer* graphicsLayer, 2818 const GraphicsLayer* graphicsLayer,
2818 IntSize& offset) const { 2819 IntSize& offset) const {
2819 if (graphicsLayer == m_scrollingContentsLayer.get() || 2820 if (graphicsLayer == m_scrollingContentsLayer.get() ||
2820 graphicsLayer == m_foregroundLayer.get()) { 2821 graphicsLayer == m_foregroundLayer.get()) {
2821 if (PaintLayerScrollableArea* scrollableArea = 2822 if (PaintLayerScrollableArea* scrollableArea =
2822 m_owningLayer.getScrollableArea()) { 2823 m_owningLayer.getScrollableArea()) {
2823 if (scrollableArea->usesCompositedScrolling()) { 2824 if (scrollableArea->usesCompositedScrolling()) {
2824 // Note: this is just the scroll offset, *not* the "adjusted scroll offs et". Scroll offset 2825 // Note: this is just the scroll offset, *not* the "adjusted scroll offs et". Scroll offset
2825 // does not include the origin adjustment. That is instead baked already into offsetFromLayoutObject. 2826 // does not include the origin adjustment. That is instead baked already into offsetFromLayoutObject.
2826 IntPoint scrollPosition = scrollableArea->scrollPosition(); 2827 ScrollOffset scrollOffset = scrollableArea->scrollOffset();
2827 offset.expand(-scrollPosition.x(), -scrollPosition.y()); 2828 offset.expand(-scrollOffset.width(), -scrollOffset.height());
2828 } 2829 }
2829 } 2830 }
2830 } 2831 }
2831 } 2832 }
2832 2833
2833 void CompositedLayerMapping::paintContents( 2834 void CompositedLayerMapping::paintContents(
2834 const GraphicsLayer* graphicsLayer, 2835 const GraphicsLayer* graphicsLayer,
2835 GraphicsContext& context, 2836 GraphicsContext& context,
2836 GraphicsLayerPaintingPhase graphicsLayerPaintingPhase, 2837 GraphicsLayerPaintingPhase graphicsLayerPaintingPhase,
2837 const IntRect& interestRect) const { 2838 const IntRect& interestRect) const {
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
3152 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { 3153 } else if (graphicsLayer == m_scrollingContentsLayer.get()) {
3153 name = "Scrolling Contents Layer"; 3154 name = "Scrolling Contents Layer";
3154 } else { 3155 } else {
3155 ASSERT_NOT_REACHED(); 3156 ASSERT_NOT_REACHED();
3156 } 3157 }
3157 3158
3158 return name; 3159 return name;
3159 } 3160 }
3160 3161
3161 } // namespace blink 3162 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698