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

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

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

Powered by Google App Engine
This is Rietveld 408576698