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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 2708883005: Handle nested position:sticky elements correctly (main thread) (Closed)
Patch Set: Address reviewer comments Created 3 years, 10 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 1939 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 void FrameView::didScrollTimerFired(TimerBase*) { 1950 void FrameView::didScrollTimerFired(TimerBase*) {
1951 if (m_frame->document() && !m_frame->document()->layoutViewItem().isNull()) 1951 if (m_frame->document() && !m_frame->document()->layoutViewItem().isNull())
1952 m_frame->document()->fetcher()->updateAllImageResourcePriorities(); 1952 m_frame->document()->fetcher()->updateAllImageResourcePriorities();
1953 } 1953 }
1954 1954
1955 void FrameView::updateLayersAndCompositingAfterScrollIfNeeded() { 1955 void FrameView::updateLayersAndCompositingAfterScrollIfNeeded() {
1956 // Nothing to do after scrolling if there are no fixed position elements. 1956 // Nothing to do after scrolling if there are no fixed position elements.
1957 if (!hasViewportConstrainedObjects()) 1957 if (!hasViewportConstrainedObjects())
1958 return; 1958 return;
1959 1959
1960 // Update sticky position objects which are stuck to the viewport. 1960 // Update sticky position objects which are stuck to the viewport. In order to
1961 // correctly compute the sticky position offsets the layers must be visited
1962 // top-down, so start at the 'root' sticky elements and recurse downwards.
1961 for (const auto& viewportConstrainedObject : *m_viewportConstrainedObjects) { 1963 for (const auto& viewportConstrainedObject : *m_viewportConstrainedObjects) {
1962 LayoutObject* layoutObject = viewportConstrainedObject; 1964 LayoutObject* layoutObject = viewportConstrainedObject;
1965 if (layoutObject->style()->position() != EPosition::kSticky)
1966 continue;
1967
1963 PaintLayer* layer = toLayoutBoxModelObject(layoutObject)->layer(); 1968 PaintLayer* layer = toLayoutBoxModelObject(layoutObject)->layer();
1964 if (layoutObject->style()->position() == EPosition::kSticky) { 1969 StickyConstraintsMap constraintsMap = layer->ancestorOverflowLayer()
1970 ->getScrollableArea()
1971 ->stickyConstraintsMap();
1972 if (constraintsMap.contains(layer) &&
1973 !constraintsMap.get(layer).hasAncestorStickyElement()) {
1965 // TODO(skobes): Resolve circular dependency between scroll offset and 1974 // TODO(skobes): Resolve circular dependency between scroll offset and
1966 // compositing state, and remove this disabler. https://crbug.com/420741 1975 // compositing state, and remove this disabler. https://crbug.com/420741
1967 DisableCompositingQueryAsserts disabler; 1976 DisableCompositingQueryAsserts disabler;
1968 layer->updateLayerPositionsAfterOverflowScroll(); 1977 layer->updateLayerPositionsAfterOverflowScroll();
1969 layoutObject->setMayNeedPaintInvalidationSubtree(); 1978 layoutObject->setMayNeedPaintInvalidationSubtree();
1970 } 1979 }
1971 } 1980 }
1972 1981
1973 // If there fixed position elements, scrolling may cause compositing layers to 1982 // If there fixed position elements, scrolling may cause compositing layers to
1974 // change. Update widget and layer positions after scrolling, but only if 1983 // change. Update widget and layer positions after scrolling, but only if
(...skipping 3210 matching lines...) Expand 10 before | Expand all | Expand 10 after
5185 void FrameView::setAnimationHost( 5194 void FrameView::setAnimationHost(
5186 std::unique_ptr<CompositorAnimationHost> host) { 5195 std::unique_ptr<CompositorAnimationHost> host) {
5187 m_animationHost = std::move(host); 5196 m_animationHost = std::move(host);
5188 } 5197 }
5189 5198
5190 LayoutUnit FrameView::caretWidth() const { 5199 LayoutUnit FrameView::caretWidth() const {
5191 return LayoutUnit(getHostWindow()->windowToViewportScalar(1)); 5200 return LayoutUnit(getHostWindow()->windowToViewportScalar(1));
5192 } 5201 }
5193 5202
5194 } // namespace blink 5203 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698