Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * | 4 * |
| 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
| 6 * | 6 * |
| 7 * Other contributors: | 7 * Other contributors: |
| 8 * Robert O'Callahan <roc+@cs.cmu.edu> | 8 * Robert O'Callahan <roc+@cs.cmu.edu> |
| 9 * David Baron <dbaron@fas.harvard.edu> | 9 * David Baron <dbaron@fas.harvard.edu> |
| 10 * Christian Biesinger <cbiesinger@web.de> | 10 * Christian Biesinger <cbiesinger@web.de> |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 #include "core/layout/LayoutView.h" | 63 #include "core/layout/LayoutView.h" |
| 64 #include "core/layout/api/LayoutPartItem.h" | 64 #include "core/layout/api/LayoutPartItem.h" |
| 65 #include "core/layout/api/LayoutViewItem.h" | 65 #include "core/layout/api/LayoutViewItem.h" |
| 66 #include "core/layout/compositing/CompositedLayerMapping.h" | 66 #include "core/layout/compositing/CompositedLayerMapping.h" |
| 67 #include "core/layout/compositing/PaintLayerCompositor.h" | 67 #include "core/layout/compositing/PaintLayerCompositor.h" |
| 68 #include "core/layout/svg/LayoutSVGResourceClipper.h" | 68 #include "core/layout/svg/LayoutSVGResourceClipper.h" |
| 69 #include "core/layout/svg/LayoutSVGRoot.h" | 69 #include "core/layout/svg/LayoutSVGRoot.h" |
| 70 #include "core/page/Page.h" | 70 #include "core/page/Page.h" |
| 71 #include "core/page/scrolling/RootScrollerController.h" | 71 #include "core/page/scrolling/RootScrollerController.h" |
| 72 #include "core/page/scrolling/ScrollingCoordinator.h" | 72 #include "core/page/scrolling/ScrollingCoordinator.h" |
| 73 #include "core/page/scrolling/StickyPositionScrollingConstraints.h" | |
| 73 #include "core/paint/BoxReflectionUtils.h" | 74 #include "core/paint/BoxReflectionUtils.h" |
| 74 #include "core/paint/FilterEffectBuilder.h" | 75 #include "core/paint/FilterEffectBuilder.h" |
| 75 #include "core/paint/ObjectPaintInvalidator.h" | 76 #include "core/paint/ObjectPaintInvalidator.h" |
| 76 #include "platform/LengthFunctions.h" | 77 #include "platform/LengthFunctions.h" |
| 77 #include "platform/RuntimeEnabledFeatures.h" | 78 #include "platform/RuntimeEnabledFeatures.h" |
| 78 #include "platform/geometry/FloatPoint3D.h" | 79 #include "platform/geometry/FloatPoint3D.h" |
| 79 #include "platform/geometry/FloatRect.h" | 80 #include "platform/geometry/FloatRect.h" |
| 80 #include "platform/geometry/TransformState.h" | 81 #include "platform/geometry/TransformState.h" |
| 81 #include "platform/graphics/CompositorFilterOperations.h" | 82 #include "platform/graphics/CompositorFilterOperations.h" |
| 82 #include "platform/graphics/filters/Filter.h" | 83 #include "platform/graphics/filters/Filter.h" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 322 // a self-painting descendant in this case, there is no need to dirty our | 323 // a self-painting descendant in this case, there is no need to dirty our |
| 323 // ancestors further. | 324 // ancestors further. |
| 324 if (layer->isSelfPaintingLayer()) { | 325 if (layer->isSelfPaintingLayer()) { |
| 325 DCHECK(!parent() || parent()->m_hasSelfPaintingLayerDescendantDirty || | 326 DCHECK(!parent() || parent()->m_hasSelfPaintingLayerDescendantDirty || |
| 326 parent()->m_hasSelfPaintingLayerDescendant); | 327 parent()->m_hasSelfPaintingLayerDescendant); |
| 327 break; | 328 break; |
| 328 } | 329 } |
| 329 } | 330 } |
| 330 } | 331 } |
| 331 | 332 |
| 332 bool PaintLayer::sticksToViewport() const { | 333 bool PaintLayer::sticksToScroller() const { |
| 333 if (layoutObject().style()->position() != EPosition::kFixed && | 334 return layoutObject().style()->position() == EPosition::kSticky && |
| 334 layoutObject().style()->position() != EPosition::kSticky) | 335 ancestorOverflowLayer() |
| 336 ->getScrollableArea() | |
| 337 ->stickyConstraintsMap() | |
| 338 .at(const_cast<PaintLayer*>(this)) | |
| 339 .anchorEdges(); | |
| 340 } | |
| 341 | |
| 342 bool PaintLayer::fixedToViewport() const { | |
| 343 if (layoutObject().style()->position() != EPosition::kFixed) | |
| 335 return false; | 344 return false; |
| 336 | 345 |
| 337 // TODO(pdr): This approach of calculating the nearest scroll node is O(n). | 346 // TODO(pdr): This approach of calculating the nearest scroll node is O(n). |
| 338 // An option for improving this is to cache the nearest scroll node in | 347 // An option for improving this is to cache the nearest scroll node in |
| 339 // the local border box properties. | 348 // the local border box properties. |
| 340 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 349 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 341 const auto* viewProperties = layoutObject().view()->paintProperties(); | 350 const auto* viewProperties = layoutObject().view()->paintProperties(); |
| 342 const ScrollPaintPropertyNode* ancestorTargetScrollNode; | 351 const ScrollPaintPropertyNode* ancestorTargetScrollNode; |
| 343 if (layoutObject().style()->position() == EPosition::kFixed) { | 352 ancestorTargetScrollNode = viewProperties->localBorderBoxProperties() |
| 344 ancestorTargetScrollNode = viewProperties->localBorderBoxProperties() | 353 ->transform() |
| 345 ->transform() | 354 ->findEnclosingScrollNode(); |
| 346 ->findEnclosingScrollNode(); | |
| 347 } else { | |
| 348 ancestorTargetScrollNode = viewProperties->contentsProperties() | |
| 349 ->transform() | |
| 350 ->findEnclosingScrollNode(); | |
|
flackr
2017/02/24 22:59:44
Do we still need to something like this for sticks
| |
| 351 } | |
| 352 | 355 |
| 353 const auto* properties = layoutObject().paintProperties(); | 356 const auto* properties = layoutObject().paintProperties(); |
| 354 const auto* transform = properties->localBorderBoxProperties()->transform(); | 357 const auto* transform = properties->localBorderBoxProperties()->transform(); |
| 355 return transform->findEnclosingScrollNode() == ancestorTargetScrollNode; | 358 return transform->findEnclosingScrollNode() == ancestorTargetScrollNode; |
| 356 } | 359 } |
| 357 | 360 |
| 358 return (layoutObject().style()->position() == EPosition::kFixed && | 361 return layoutObject().containerForFixedPosition() == layoutObject().view(); |
| 359 layoutObject().containerForFixedPosition() == | |
| 360 layoutObject().view()) || | |
| 361 (layoutObject().style()->position() == EPosition::kSticky && | |
| 362 (!ancestorScrollingLayer() || ancestorScrollingLayer() == root())); | |
|
flackr
2017/02/24 22:59:44
ancestorScrollingLayer was not the correct "scroll
| |
| 363 } | 362 } |
| 364 | 363 |
| 365 bool PaintLayer::scrollsWithRespectTo(const PaintLayer* other) const { | 364 bool PaintLayer::scrollsWithRespectTo(const PaintLayer* other) const { |
| 366 if (sticksToViewport() != other->sticksToViewport()) | 365 if (fixedToViewport() != other->fixedToViewport()) |
| 366 return true; | |
| 367 // If either element sticks we cannot trivially determine that the layers do | |
| 368 // not scroll with respect to each other. | |
| 369 if (sticksToScroller() || other->sticksToScroller()) | |
| 367 return true; | 370 return true; |
| 368 return ancestorScrollingLayer() != other->ancestorScrollingLayer(); | 371 return ancestorScrollingLayer() != other->ancestorScrollingLayer(); |
| 369 } | 372 } |
| 370 | 373 |
| 371 void PaintLayer::updateLayerPositionsAfterOverflowScroll() { | 374 void PaintLayer::updateLayerPositionsAfterOverflowScroll() { |
| 372 clipper(PaintLayer::DoNotUseGeometryMapper) | 375 clipper(PaintLayer::DoNotUseGeometryMapper) |
| 373 .clearClipRectsIncludingDescendants(); | 376 .clearClipRectsIncludingDescendants(); |
| 374 updateLayerPositionRecursive(); | 377 updateLayerPositionRecursive(); |
| 375 } | 378 } |
| 376 | 379 |
| (...skipping 2850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3227 } | 3230 } |
| 3228 | 3231 |
| 3229 void showLayerTree(const blink::LayoutObject* layoutObject) { | 3232 void showLayerTree(const blink::LayoutObject* layoutObject) { |
| 3230 if (!layoutObject) { | 3233 if (!layoutObject) { |
| 3231 LOG(INFO) << "Cannot showLayerTree. Root is (nil)"; | 3234 LOG(INFO) << "Cannot showLayerTree. Root is (nil)"; |
| 3232 return; | 3235 return; |
| 3233 } | 3236 } |
| 3234 showLayerTree(layoutObject->enclosingLayer()); | 3237 showLayerTree(layoutObject->enclosingLayer()); |
| 3235 } | 3238 } |
| 3236 #endif | 3239 #endif |
| OLD | NEW |