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

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

Issue 2776563003: Only automatically promote sticky position elements which move with scroll. (Closed)
Patch Set: Merge with master Created 3 years, 8 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* viewBorderBoxProperties = 348 const auto* viewBorderBoxProperties =
340 layoutObject().view()->localBorderBoxProperties(); 349 layoutObject().view()->localBorderBoxProperties();
341 const ScrollPaintPropertyNode* ancestorTargetScrollNode; 350 const ScrollPaintPropertyNode* ancestorTargetScrollNode;
342 if (layoutObject().style()->position() == EPosition::kFixed) { 351 ancestorTargetScrollNode =
343 ancestorTargetScrollNode = 352 viewBorderBoxProperties->transform()->findEnclosingScrollNode();
344 viewBorderBoxProperties->transform()->findEnclosingScrollNode();
345 } else {
346 ancestorTargetScrollNode = layoutObject()
347 .view()
348 ->contentsProperties()
349 ->transform()
350 ->findEnclosingScrollNode();
351 }
352 353
353 const auto* transform = 354 const auto* transform =
354 layoutObject().localBorderBoxProperties()->transform(); 355 layoutObject().localBorderBoxProperties()->transform();
355 return transform->findEnclosingScrollNode() == ancestorTargetScrollNode; 356 return transform->findEnclosingScrollNode() == ancestorTargetScrollNode;
356 } 357 }
357 358
358 return (layoutObject().style()->position() == EPosition::kFixed && 359 return layoutObject().containerForFixedPosition() == layoutObject().view();
359 layoutObject().containerForFixedPosition() ==
360 layoutObject().view()) ||
361 (layoutObject().style()->position() == EPosition::kSticky &&
362 (!ancestorScrollingLayer() || ancestorScrollingLayer() == root()));
363 } 360 }
364 361
365 bool PaintLayer::scrollsWithRespectTo(const PaintLayer* other) const { 362 bool PaintLayer::scrollsWithRespectTo(const PaintLayer* other) const {
366 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())
367 return true; 368 return true;
368 return ancestorScrollingLayer() != other->ancestorScrollingLayer(); 369 return ancestorScrollingLayer() != other->ancestorScrollingLayer();
369 } 370 }
370 371
371 void PaintLayer::updateLayerPositionsAfterOverflowScroll() { 372 void PaintLayer::updateLayerPositionsAfterOverflowScroll() {
372 clipper(PaintLayer::DoNotUseGeometryMapper) 373 clipper(PaintLayer::DoNotUseGeometryMapper)
373 .clearClipRectsIncludingDescendants(); 374 .clearClipRectsIncludingDescendants();
374 updateLayerPositionRecursive(); 375 updateLayerPositionRecursive();
375 } 376 }
376 377
(...skipping 2861 matching lines...) Expand 10 before | Expand all | Expand 10 after
3238 } 3239 }
3239 3240
3240 void showLayerTree(const blink::LayoutObject* layoutObject) { 3241 void showLayerTree(const blink::LayoutObject* layoutObject) {
3241 if (!layoutObject) { 3242 if (!layoutObject) {
3242 LOG(INFO) << "Cannot showLayerTree. Root is (nil)"; 3243 LOG(INFO) << "Cannot showLayerTree. Root is (nil)";
3243 return; 3244 return;
3244 } 3245 }
3245 showLayerTree(layoutObject->enclosingLayer()); 3246 showLayerTree(layoutObject->enclosingLayer());
3246 } 3247 }
3247 #endif 3248 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.h ('k') | third_party/WebKit/Source/core/paint/PaintLayerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698