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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameView.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) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 1726 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 return true; 1737 return true;
1738 } 1738 }
1739 return false; 1739 return false;
1740 } 1740 }
1741 1741
1742 bool FrameView::invalidateViewportConstrainedObjects() { 1742 bool FrameView::invalidateViewportConstrainedObjects() {
1743 bool fastPathAllowed = true; 1743 bool fastPathAllowed = true;
1744 for (const auto& viewportConstrainedObject : *m_viewportConstrainedObjects) { 1744 for (const auto& viewportConstrainedObject : *m_viewportConstrainedObjects) {
1745 LayoutObject* layoutObject = viewportConstrainedObject; 1745 LayoutObject* layoutObject = viewportConstrainedObject;
1746 LayoutItem layoutItem = LayoutItem(layoutObject); 1746 LayoutItem layoutItem = LayoutItem(layoutObject);
1747 ASSERT(layoutItem.style()->hasViewportConstrainedPosition()); 1747 DCHECK(layoutItem.style()->hasViewportConstrainedPosition() ||
1748 layoutItem.style()->hasStickyConstrainedPosition());
1748 ASSERT(layoutItem.hasLayer()); 1749 ASSERT(layoutItem.hasLayer());
1749 PaintLayer* layer = LayoutBoxModel(layoutItem).layer(); 1750 PaintLayer* layer = LayoutBoxModel(layoutItem).layer();
1750 1751
1751 if (layer->isPaintInvalidationContainer()) 1752 if (layer->isPaintInvalidationContainer())
1752 continue; 1753 continue;
1753 1754
1754 if (layer->subtreeIsInvisible()) 1755 if (layer->subtreeIsInvisible())
1755 continue; 1756 continue;
1756 1757
1757 // invalidate even if there is an ancestor with a filter that moves pixels. 1758 // invalidate even if there is an ancestor with a filter that moves pixels.
(...skipping 3253 matching lines...) Expand 10 before | Expand all | Expand 10 after
5011 5012
5012 for (const LayoutObject* layoutObject : *viewportConstrainedObjects()) { 5013 for (const LayoutObject* layoutObject : *viewportConstrainedObjects()) {
5013 DCHECK(layoutObject->isBoxModelObject() && layoutObject->hasLayer()); 5014 DCHECK(layoutObject->isBoxModelObject() && layoutObject->hasLayer());
5014 DCHECK(layoutObject->style()->position() == EPosition::kFixed || 5015 DCHECK(layoutObject->style()->position() == EPosition::kFixed ||
5015 layoutObject->style()->position() == EPosition::kSticky); 5016 layoutObject->style()->position() == EPosition::kSticky);
5016 PaintLayer* layer = toLayoutBoxModelObject(layoutObject)->layer(); 5017 PaintLayer* layer = toLayoutBoxModelObject(layoutObject)->layer();
5017 5018
5018 // Whether the Layer sticks to the viewport is a tree-depenent 5019 // Whether the Layer sticks to the viewport is a tree-depenent
5019 // property and our viewportConstrainedObjects collection is maintained 5020 // property and our viewportConstrainedObjects collection is maintained
5020 // with only LayoutObject-level information. 5021 // with only LayoutObject-level information.
5021 if (!layer->sticksToViewport()) 5022 if (!layer->fixedToViewport() && !layer->sticksToScroller())
5022 continue; 5023 continue;
5023 5024
5024 // If the whole subtree is invisible, there's no reason to scroll on 5025 // If the whole subtree is invisible, there's no reason to scroll on
5025 // the main thread because we don't need to generate invalidations 5026 // the main thread because we don't need to generate invalidations
5026 // for invisible content. 5027 // for invisible content.
5027 if (layer->subtreeIsInvisible()) 5028 if (layer->subtreeIsInvisible())
5028 continue; 5029 continue;
5029 5030
5030 // We're only smart enough to scroll viewport-constrainted objects 5031 // We're only smart enough to scroll viewport-constrainted objects
5031 // in the compositor if they have their own backing or they paint 5032 // in the compositor if they have their own backing or they paint
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
5261 void FrameView::setAnimationHost( 5262 void FrameView::setAnimationHost(
5262 std::unique_ptr<CompositorAnimationHost> host) { 5263 std::unique_ptr<CompositorAnimationHost> host) {
5263 m_animationHost = std::move(host); 5264 m_animationHost = std::move(host);
5264 } 5265 }
5265 5266
5266 LayoutUnit FrameView::caretWidth() const { 5267 LayoutUnit FrameView::caretWidth() const {
5267 return LayoutUnit(getHostWindow()->windowToViewportScalar(1)); 5268 return LayoutUnit(getHostWindow()->windowToViewportScalar(1));
5268 } 5269 }
5269 5270
5270 } // namespace blink 5271 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698