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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 if (sticky) { | 301 if (sticky) { |
302 if (!ancestorOverflowLayer->isRootLayer()) { | 302 if (!ancestorOverflowLayer->isRootLayer()) { |
303 sticky = ancestorOverflowLayer->needsCompositedScrolling(); | 303 sticky = ancestorOverflowLayer->needsCompositedScrolling(); |
304 } else { | 304 } else { |
305 sticky = layoutObject().view()->frameView()->isScrollable(); | 305 sticky = layoutObject().view()->frameView()->isScrollable(); |
306 } | 306 } |
307 } | 307 } |
308 | 308 |
309 WebLayerStickyPositionConstraint webConstraint; | 309 WebLayerStickyPositionConstraint webConstraint; |
310 if (sticky) { | 310 if (sticky) { |
| 311 const StickyConstraintsMap& constraintsMap = |
| 312 ancestorOverflowLayer->getScrollableArea()->stickyConstraintsMap(); |
311 const StickyPositionScrollingConstraints& constraints = | 313 const StickyPositionScrollingConstraints& constraints = |
312 ancestorOverflowLayer->getScrollableArea()->stickyConstraintsMap().at( | 314 constraintsMap.at(&m_owningLayer); |
313 &m_owningLayer); | |
314 | 315 |
315 // Find the layout offset of the unshifted sticky box within its | 316 // Find the layout offset of the unshifted sticky box within its parent |
316 // compositingContainer. If the enclosing layer is not the scroller, then | 317 // composited layer. This information is used by the compositor side to |
317 // the offset must be adjusted to include the scroll offset to keep it | 318 // compute the additional offset required to keep the element stuck under |
318 // relative to compositingContainer. | 319 // compositor scrolling. |
| 320 // |
| 321 // Starting from the scroll container relative location, removing the |
| 322 // enclosing layer's offset and the content offset in the composited layer |
| 323 // results in the parent-layer relative offset. |
| 324 FloatPoint parentRelativeStickyBoxOffset = |
| 325 constraints.scrollContainerRelativeStickyBoxRect().location(); |
| 326 |
| 327 // The enclosing layers offset returned from |convertToLayerCoords| must be |
| 328 // adjusted for both scroll and ancestor sticky elements. |
319 LayoutPoint enclosingLayerOffset; | 329 LayoutPoint enclosingLayerOffset; |
320 compositingContainer->convertToLayerCoords(ancestorOverflowLayer, | 330 compositingContainer->convertToLayerCoords(ancestorOverflowLayer, |
321 enclosingLayerOffset); | 331 enclosingLayerOffset); |
322 if (compositingContainer != ancestorOverflowLayer) { | 332 if (compositingContainer != ancestorOverflowLayer) { |
323 enclosingLayerOffset += LayoutSize( | 333 enclosingLayerOffset += LayoutSize( |
324 ancestorOverflowLayer->getScrollableArea()->getScrollOffset()); | 334 ancestorOverflowLayer->getScrollableArea()->getScrollOffset()); |
325 } | 335 } |
| 336 // TODO(smcgruer): Until http://crbug.com/702229 is fixed, the nearest |
| 337 // sticky ancestor may be non-composited which will make this offset wrong. |
| 338 if (const LayoutBoxModelObject* ancestor = |
| 339 constraints.nearestStickyAncestor()) { |
| 340 enclosingLayerOffset -= |
| 341 roundedIntSize(constraintsMap.at(ancestor->layer()) |
| 342 .getTotalContainingBlockStickyOffset()); |
| 343 } |
326 | 344 |
327 FloatPoint stickyBoxOffset = | |
328 constraints.scrollContainerRelativeStickyBoxRect().location(); | |
329 DCHECK(!m_contentOffsetInCompositingLayerDirty); | 345 DCHECK(!m_contentOffsetInCompositingLayerDirty); |
330 stickyBoxOffset.moveBy(FloatPoint(-enclosingLayerOffset) - | 346 parentRelativeStickyBoxOffset.moveBy( |
331 FloatSize(contentOffsetInCompositingLayer())); | 347 FloatPoint(-enclosingLayerOffset) - |
| 348 FloatSize(contentOffsetInCompositingLayer())); |
332 | 349 |
333 webConstraint.isSticky = true; | 350 webConstraint.isSticky = true; |
334 webConstraint.isAnchoredLeft = | 351 webConstraint.isAnchoredLeft = |
335 constraints.anchorEdges() & | 352 constraints.anchorEdges() & |
336 StickyPositionScrollingConstraints::AnchorEdgeLeft; | 353 StickyPositionScrollingConstraints::AnchorEdgeLeft; |
337 webConstraint.isAnchoredRight = | 354 webConstraint.isAnchoredRight = |
338 constraints.anchorEdges() & | 355 constraints.anchorEdges() & |
339 StickyPositionScrollingConstraints::AnchorEdgeRight; | 356 StickyPositionScrollingConstraints::AnchorEdgeRight; |
340 webConstraint.isAnchoredTop = | 357 webConstraint.isAnchoredTop = |
341 constraints.anchorEdges() & | 358 constraints.anchorEdges() & |
342 StickyPositionScrollingConstraints::AnchorEdgeTop; | 359 StickyPositionScrollingConstraints::AnchorEdgeTop; |
343 webConstraint.isAnchoredBottom = | 360 webConstraint.isAnchoredBottom = |
344 constraints.anchorEdges() & | 361 constraints.anchorEdges() & |
345 StickyPositionScrollingConstraints::AnchorEdgeBottom; | 362 StickyPositionScrollingConstraints::AnchorEdgeBottom; |
346 webConstraint.leftOffset = constraints.leftOffset(); | 363 webConstraint.leftOffset = constraints.leftOffset(); |
347 webConstraint.rightOffset = constraints.rightOffset(); | 364 webConstraint.rightOffset = constraints.rightOffset(); |
348 webConstraint.topOffset = constraints.topOffset(); | 365 webConstraint.topOffset = constraints.topOffset(); |
349 webConstraint.bottomOffset = constraints.bottomOffset(); | 366 webConstraint.bottomOffset = constraints.bottomOffset(); |
350 webConstraint.parentRelativeStickyBoxOffset = | 367 webConstraint.parentRelativeStickyBoxOffset = |
351 roundedIntPoint(stickyBoxOffset); | 368 roundedIntPoint(parentRelativeStickyBoxOffset); |
352 webConstraint.scrollContainerRelativeStickyBoxRect = | 369 webConstraint.scrollContainerRelativeStickyBoxRect = |
353 enclosingIntRect(constraints.scrollContainerRelativeStickyBoxRect()); | 370 enclosingIntRect(constraints.scrollContainerRelativeStickyBoxRect()); |
354 webConstraint.scrollContainerRelativeContainingBlockRect = enclosingIntRect( | 371 webConstraint.scrollContainerRelativeContainingBlockRect = enclosingIntRect( |
355 constraints.scrollContainerRelativeContainingBlockRect()); | 372 constraints.scrollContainerRelativeContainingBlockRect()); |
356 // TODO(smcgruer): Copy fields for nested sticky in cc (crbug.com/672710) | 373 // TODO(smcgruer): Until http://crbug.com/702229 is fixed, the nearest |
| 374 // sticky layers may not be composited and we may incorrectly end up with |
| 375 // invalid layer IDs. |
| 376 LayoutBoxModelObject* stickyBoxShiftingAncestor = |
| 377 constraints.nearestStickyBoxShiftingStickyBox(); |
| 378 if (stickyBoxShiftingAncestor && |
| 379 stickyBoxShiftingAncestor->layer()->compositedLayerMapping()) { |
| 380 webConstraint.nearestLayerShiftingStickyBox = |
| 381 stickyBoxShiftingAncestor->layer() |
| 382 ->compositedLayerMapping() |
| 383 ->mainGraphicsLayer() |
| 384 ->platformLayer() |
| 385 ->id(); |
| 386 } |
| 387 LayoutBoxModelObject* containingBlockShiftingAncestor = |
| 388 constraints.nearestStickyBoxShiftingContainingBlock(); |
| 389 if (containingBlockShiftingAncestor && |
| 390 containingBlockShiftingAncestor->layer()->compositedLayerMapping()) { |
| 391 webConstraint.nearestLayerShiftingContainingBlock = |
| 392 containingBlockShiftingAncestor->layer() |
| 393 ->compositedLayerMapping() |
| 394 ->mainGraphicsLayer() |
| 395 ->platformLayer() |
| 396 ->id(); |
| 397 } |
357 } | 398 } |
358 | 399 |
359 m_graphicsLayer->setStickyPositionConstraint(webConstraint); | 400 m_graphicsLayer->setStickyPositionConstraint(webConstraint); |
360 } | 401 } |
361 | 402 |
362 void CompositedLayerMapping::updateLayerBlendMode(const ComputedStyle& style) { | 403 void CompositedLayerMapping::updateLayerBlendMode(const ComputedStyle& style) { |
363 setBlendMode(style.blendMode()); | 404 setBlendMode(style.blendMode()); |
364 } | 405 } |
365 | 406 |
366 void CompositedLayerMapping::updateIsRootForIsolatedGroup() { | 407 void CompositedLayerMapping::updateIsRootForIsolatedGroup() { |
(...skipping 3131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3498 } else if (graphicsLayer == m_decorationOutlineLayer.get()) { | 3539 } else if (graphicsLayer == m_decorationOutlineLayer.get()) { |
3499 name = "Decoration Layer"; | 3540 name = "Decoration Layer"; |
3500 } else { | 3541 } else { |
3501 ASSERT_NOT_REACHED(); | 3542 ASSERT_NOT_REACHED(); |
3502 } | 3543 } |
3503 | 3544 |
3504 return name; | 3545 return name; |
3505 } | 3546 } |
3506 | 3547 |
3507 } // namespace blink | 3548 } // namespace blink |
OLD | NEW |