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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayer.cpp

Issue 2716583005: Do not promote position sticky or fixed elements unless they move with scroll. (Closed)
Patch Set: Avoid computing constraints for non-anchored sticky and add/update tests. Created 3 years, 9 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) 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 #include "core/layout/LayoutTreeAsText.h" 62 #include "core/layout/LayoutTreeAsText.h"
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/ScrollingCoordinator.h" 71 #include "core/page/scrolling/ScrollingCoordinator.h"
72 #include "core/page/scrolling/StickyPositionScrollingConstraints.h"
72 #include "core/paint/BoxReflectionUtils.h" 73 #include "core/paint/BoxReflectionUtils.h"
73 #include "core/paint/FilterEffectBuilder.h" 74 #include "core/paint/FilterEffectBuilder.h"
74 #include "core/paint/ObjectPaintInvalidator.h" 75 #include "core/paint/ObjectPaintInvalidator.h"
75 #include "platform/LengthFunctions.h" 76 #include "platform/LengthFunctions.h"
76 #include "platform/RuntimeEnabledFeatures.h" 77 #include "platform/RuntimeEnabledFeatures.h"
77 #include "platform/geometry/FloatPoint3D.h" 78 #include "platform/geometry/FloatPoint3D.h"
78 #include "platform/geometry/FloatRect.h" 79 #include "platform/geometry/FloatRect.h"
79 #include "platform/geometry/TransformState.h" 80 #include "platform/geometry/TransformState.h"
80 #include "platform/graphics/CompositorFilterOperations.h" 81 #include "platform/graphics/CompositorFilterOperations.h"
81 #include "platform/graphics/filters/Filter.h" 82 #include "platform/graphics/filters/Filter.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 // a self-painting descendant in this case, there is no need to dirty our 321 // a self-painting descendant in this case, there is no need to dirty our
321 // ancestors further. 322 // ancestors further.
322 if (layer->isSelfPaintingLayer()) { 323 if (layer->isSelfPaintingLayer()) {
323 DCHECK(!parent() || parent()->m_hasSelfPaintingLayerDescendantDirty || 324 DCHECK(!parent() || parent()->m_hasSelfPaintingLayerDescendantDirty ||
324 parent()->m_hasSelfPaintingLayerDescendant); 325 parent()->m_hasSelfPaintingLayerDescendant);
325 break; 326 break;
326 } 327 }
327 } 328 }
328 } 329 }
329 330
330 bool PaintLayer::sticksToViewport() const { 331 bool PaintLayer::sticksToScroller() const {
331 if (layoutObject().style()->position() != EPosition::kFixed && 332 return layoutObject().style()->position() == EPosition::kSticky &&
332 layoutObject().style()->position() != EPosition::kSticky) 333 ancestorOverflowLayer()
334 ->getScrollableArea()
335 ->stickyConstraintsMap()
336 .at(const_cast<PaintLayer*>(this))
337 .anchorEdges();
338 }
339
340 bool PaintLayer::fixedToViewport() const {
341 if (layoutObject().style()->position() != EPosition::kFixed)
333 return false; 342 return false;
334 343
335 // TODO(pdr): This approach of calculating the nearest scroll node is O(n). 344 // TODO(pdr): This approach of calculating the nearest scroll node is O(n).
336 // An option for improving this is to cache the nearest scroll node in 345 // An option for improving this is to cache the nearest scroll node in
337 // the local border box properties. 346 // the local border box properties.
338 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 347 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
339 const auto* viewProperties = layoutObject().view()->paintProperties(); 348 const auto* viewProperties = layoutObject().view()->paintProperties();
340 const ScrollPaintPropertyNode* ancestorTargetScrollNode; 349 const ScrollPaintPropertyNode* ancestorTargetScrollNode;
341 if (layoutObject().style()->position() == EPosition::kFixed) { 350 ancestorTargetScrollNode = viewProperties->localBorderBoxProperties()
342 ancestorTargetScrollNode = viewProperties->localBorderBoxProperties() 351 ->transform()
343 ->transform() 352 ->findEnclosingScrollNode();
344 ->findEnclosingScrollNode();
345 } else {
346 ancestorTargetScrollNode = viewProperties->contentsProperties()
347 ->transform()
348 ->findEnclosingScrollNode();
349 }
350 353
351 const auto* properties = layoutObject().paintProperties(); 354 const auto* properties = layoutObject().paintProperties();
352 const auto* transform = properties->localBorderBoxProperties()->transform(); 355 const auto* transform = properties->localBorderBoxProperties()->transform();
353 return transform->findEnclosingScrollNode() == ancestorTargetScrollNode; 356 return transform->findEnclosingScrollNode() == ancestorTargetScrollNode;
354 } 357 }
355 358
356 return (layoutObject().style()->position() == EPosition::kFixed && 359 return layoutObject().containerForFixedPosition() == layoutObject().view();
357 layoutObject().containerForFixedPosition() ==
358 layoutObject().view()) ||
359 (layoutObject().style()->position() == EPosition::kSticky &&
360 (!ancestorScrollingLayer() || ancestorScrollingLayer() == root()));
361 } 360 }
362 361
363 bool PaintLayer::scrollsWithRespectTo(const PaintLayer* other) const { 362 bool PaintLayer::scrollsWithRespectTo(const PaintLayer* other) const {
364 if (sticksToViewport() != other->sticksToViewport()) 363 if (fixedToViewport() != other->fixedToViewport())
364 return true;
365 // If either element sticks we cannot trivially determine that the layers do
366 // not scroll with respect to each other.
367 if (sticksToScroller() || other->sticksToScroller())
365 return true; 368 return true;
366 return ancestorScrollingLayer() != other->ancestorScrollingLayer(); 369 return ancestorScrollingLayer() != other->ancestorScrollingLayer();
367 } 370 }
368 371
369 void PaintLayer::updateLayerPositionsAfterOverflowScroll() { 372 void PaintLayer::updateLayerPositionsAfterOverflowScroll() {
370 clipper(PaintLayer::DoNotUseGeometryMapper) 373 clipper(PaintLayer::DoNotUseGeometryMapper)
371 .clearClipRectsIncludingDescendants(); 374 .clearClipRectsIncludingDescendants();
372 updateLayerPositionRecursive(); 375 updateLayerPositionRecursive();
373 } 376 }
374 377
(...skipping 2847 matching lines...) Expand 10 before | Expand all | Expand 10 after
3222 } 3225 }
3223 3226
3224 void showLayerTree(const blink::LayoutObject* layoutObject) { 3227 void showLayerTree(const blink::LayoutObject* layoutObject) {
3225 if (!layoutObject) { 3228 if (!layoutObject) {
3226 LOG(INFO) << "Cannot showLayerTree. Root is (nil)"; 3229 LOG(INFO) << "Cannot showLayerTree. Root is (nil)";
3227 return; 3230 return;
3228 } 3231 }
3229 showLayerTree(layoutObject->enclosingLayer()); 3232 showLayerTree(layoutObject->enclosingLayer());
3230 } 3233 }
3231 #endif 3234 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698