| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 layoutObject->isVideo(); | 163 layoutObject->isVideo(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 // Get the scrolling coordinator in a way that works inside | 166 // Get the scrolling coordinator in a way that works inside |
| 167 // CompositedLayerMapping's destructor. | 167 // CompositedLayerMapping's destructor. |
| 168 static ScrollingCoordinator* scrollingCoordinatorFromLayer(PaintLayer& layer) { | 168 static ScrollingCoordinator* scrollingCoordinatorFromLayer(PaintLayer& layer) { |
| 169 Page* page = layer.layoutObject()->frame()->page(); | 169 Page* page = layer.layoutObject()->frame()->page(); |
| 170 return (!page) ? nullptr : page->scrollingCoordinator(); | 170 return (!page) ? nullptr : page->scrollingCoordinator(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 static WebLayer* nearestCompositedStickyLayer( |
| 174 const StickyConstraintsMap& constraintsMap, |
| 175 LayoutBoxModelObject* obj) { |
| 176 while (obj && obj->compositingState() == NotComposited) { |
| 177 DCHECK(constraintsMap.contains(obj->layer())); |
| 178 const StickyPositionScrollingConstraints constraints = |
| 179 constraintsMap.get(obj->layer()); |
| 180 obj = constraints.nearestStickyElementShiftingStickyBox() |
| 181 ? constraints.nearestStickyElementShiftingStickyBox() |
| 182 : constraints.nearestStickyElementShiftingContainingBlock(); |
| 183 } |
| 184 |
| 185 if (!obj) |
| 186 return nullptr; |
| 187 |
| 188 return obj->layer() |
| 189 ->compositedLayerMapping() |
| 190 ->mainGraphicsLayer() |
| 191 ->platformLayer(); |
| 192 } |
| 193 |
| 173 CompositedLayerMapping::CompositedLayerMapping(PaintLayer& layer) | 194 CompositedLayerMapping::CompositedLayerMapping(PaintLayer& layer) |
| 174 : m_owningLayer(layer), | 195 : m_owningLayer(layer), |
| 175 m_contentOffsetInCompositingLayerDirty(false), | 196 m_contentOffsetInCompositingLayerDirty(false), |
| 176 m_pendingUpdateScope(GraphicsLayerUpdateNone), | 197 m_pendingUpdateScope(GraphicsLayerUpdateNone), |
| 177 m_isMainFrameLayoutViewLayer(false), | 198 m_isMainFrameLayoutViewLayer(false), |
| 178 m_backgroundLayerPaintsFixedRootBackground(false), | 199 m_backgroundLayerPaintsFixedRootBackground(false), |
| 179 m_scrollingContentsAreEmpty(false), | 200 m_scrollingContentsAreEmpty(false), |
| 180 m_backgroundPaintsOntoScrollingContentsLayer(false), | 201 m_backgroundPaintsOntoScrollingContentsLayer(false), |
| 181 m_backgroundPaintsOntoGraphicsLayer(false) { | 202 m_backgroundPaintsOntoGraphicsLayer(false) { |
| 182 if (layer.isRootLayer() && layoutObject()->frame()->isMainFrame()) | 203 if (layer.isRootLayer() && layoutObject()->frame()->isMainFrame()) |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 if (sticky) { | 317 if (sticky) { |
| 297 if (!ancestorOverflowLayer->isRootLayer()) { | 318 if (!ancestorOverflowLayer->isRootLayer()) { |
| 298 sticky = ancestorOverflowLayer->needsCompositedScrolling(); | 319 sticky = ancestorOverflowLayer->needsCompositedScrolling(); |
| 299 } else { | 320 } else { |
| 300 sticky = layoutObject()->view()->frameView()->isScrollable(); | 321 sticky = layoutObject()->view()->frameView()->isScrollable(); |
| 301 } | 322 } |
| 302 } | 323 } |
| 303 | 324 |
| 304 WebLayerStickyPositionConstraint webConstraint; | 325 WebLayerStickyPositionConstraint webConstraint; |
| 305 if (sticky) { | 326 if (sticky) { |
| 327 const StickyConstraintsMap& constraintsMap = |
| 328 ancestorOverflowLayer->getScrollableArea()->stickyConstraintsMap(); |
| 306 const StickyPositionScrollingConstraints& constraints = | 329 const StickyPositionScrollingConstraints& constraints = |
| 307 ancestorOverflowLayer->getScrollableArea()->stickyConstraintsMap().get( | 330 constraintsMap.get(&m_owningLayer); |
| 308 &m_owningLayer); | |
| 309 | 331 |
| 310 // Find the layout offset of the unshifted sticky box within its enclosing | 332 // Find the layout offset of the unshifted sticky box within its enclosing |
| 311 // layer. | 333 // layer. |
| 312 LayoutPoint enclosingLayerOffset; | 334 LayoutPoint enclosingLayerOffset; |
| 313 m_owningLayer.enclosingLayerWithCompositedLayerMapping(ExcludeSelf) | 335 m_owningLayer.enclosingLayerWithCompositedLayerMapping(ExcludeSelf) |
| 314 ->convertToLayerCoords(m_owningLayer.ancestorOverflowLayer(), | 336 ->convertToLayerCoords(m_owningLayer.ancestorOverflowLayer(), |
| 315 enclosingLayerOffset); | 337 enclosingLayerOffset); |
| 338 |
| 316 FloatPoint stickyBoxOffset = | 339 FloatPoint stickyBoxOffset = |
| 317 constraints.scrollContainerRelativeStickyBoxRect().location(); | 340 constraints.scrollContainerRelativeStickyBoxRect().location(); |
| 318 DCHECK(!m_contentOffsetInCompositingLayerDirty); | 341 DCHECK(!m_contentOffsetInCompositingLayerDirty); |
| 319 stickyBoxOffset.moveBy(FloatPoint(-enclosingLayerOffset) - | 342 stickyBoxOffset.moveBy(FloatPoint(-enclosingLayerOffset) - |
| 320 FloatSize(contentOffsetInCompositingLayer())); | 343 FloatSize(contentOffsetInCompositingLayer())); |
| 321 | 344 |
| 322 webConstraint.isSticky = true; | 345 webConstraint.isSticky = true; |
| 323 webConstraint.isAnchoredLeft = | 346 webConstraint.isAnchoredLeft = |
| 324 constraints.anchorEdges() & | 347 constraints.anchorEdges() & |
| 325 StickyPositionScrollingConstraints::AnchorEdgeLeft; | 348 StickyPositionScrollingConstraints::AnchorEdgeLeft; |
| 326 webConstraint.isAnchoredRight = | 349 webConstraint.isAnchoredRight = |
| 327 constraints.anchorEdges() & | 350 constraints.anchorEdges() & |
| 328 StickyPositionScrollingConstraints::AnchorEdgeRight; | 351 StickyPositionScrollingConstraints::AnchorEdgeRight; |
| 329 webConstraint.isAnchoredTop = | 352 webConstraint.isAnchoredTop = |
| 330 constraints.anchorEdges() & | 353 constraints.anchorEdges() & |
| 331 StickyPositionScrollingConstraints::AnchorEdgeTop; | 354 StickyPositionScrollingConstraints::AnchorEdgeTop; |
| 332 webConstraint.isAnchoredBottom = | 355 webConstraint.isAnchoredBottom = |
| 333 constraints.anchorEdges() & | 356 constraints.anchorEdges() & |
| 334 StickyPositionScrollingConstraints::AnchorEdgeBottom; | 357 StickyPositionScrollingConstraints::AnchorEdgeBottom; |
| 335 webConstraint.leftOffset = constraints.leftOffset(); | 358 webConstraint.leftOffset = constraints.leftOffset(); |
| 336 webConstraint.rightOffset = constraints.rightOffset(); | 359 webConstraint.rightOffset = constraints.rightOffset(); |
| 337 webConstraint.topOffset = constraints.topOffset(); | 360 webConstraint.topOffset = constraints.topOffset(); |
| 338 webConstraint.bottomOffset = constraints.bottomOffset(); | 361 webConstraint.bottomOffset = constraints.bottomOffset(); |
| 339 webConstraint.parentRelativeStickyBoxOffset = | 362 webConstraint.parentRelativeStickyBoxOffset = |
| 340 roundedIntPoint(stickyBoxOffset); | 363 roundedIntPoint(stickyBoxOffset); |
| 341 webConstraint.scrollContainerRelativeStickyBoxRect = | 364 webConstraint.scrollContainerRelativeStickyBoxRect = |
| 342 enclosingIntRect(constraints.scrollContainerRelativeStickyBoxRect()); | 365 enclosingIntRect(constraints.scrollContainerRelativeStickyBoxRect()); |
| 343 webConstraint.scrollContainerRelativeContainingBlockRect = enclosingIntRect( | 366 webConstraint.scrollContainerRelativeContainingBlockRect = enclosingIntRect( |
| 344 constraints.scrollContainerRelativeContainingBlockRect()); | 367 constraints.scrollContainerRelativeContainingBlockRect()); |
| 368 webConstraint.nearestLayerShiftingStickyBox = nearestCompositedStickyLayer( |
| 369 constraintsMap, constraints.nearestStickyElementShiftingStickyBox()); |
| 370 webConstraint.nearestLayerShiftingContainingBlock = |
| 371 nearestCompositedStickyLayer( |
| 372 constraintsMap, |
| 373 constraints.nearestStickyElementShiftingContainingBlock()); |
| 374 webConstraint.cachedComputedStickyOffset = |
| 375 constraints.getCachedComputedStickyOffset(); |
| 345 } | 376 } |
| 346 | 377 |
| 347 m_graphicsLayer->setStickyPositionConstraint(webConstraint); | 378 m_graphicsLayer->setStickyPositionConstraint(webConstraint); |
| 348 } | 379 } |
| 349 | 380 |
| 350 void CompositedLayerMapping::updateLayerBlendMode(const ComputedStyle& style) { | 381 void CompositedLayerMapping::updateLayerBlendMode(const ComputedStyle& style) { |
| 351 setBlendMode(style.blendMode()); | 382 setBlendMode(style.blendMode()); |
| 352 } | 383 } |
| 353 | 384 |
| 354 void CompositedLayerMapping::updateIsRootForIsolatedGroup() { | 385 void CompositedLayerMapping::updateIsRootForIsolatedGroup() { |
| (...skipping 3123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3478 } else if (graphicsLayer == m_decorationOutlineLayer.get()) { | 3509 } else if (graphicsLayer == m_decorationOutlineLayer.get()) { |
| 3479 name = "Decoration Layer"; | 3510 name = "Decoration Layer"; |
| 3480 } else { | 3511 } else { |
| 3481 ASSERT_NOT_REACHED(); | 3512 ASSERT_NOT_REACHED(); |
| 3482 } | 3513 } |
| 3483 | 3514 |
| 3484 return name; | 3515 return name; |
| 3485 } | 3516 } |
| 3486 | 3517 |
| 3487 } // namespace blink | 3518 } // namespace blink |
| OLD | NEW |