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

Side by Side Diff: third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp

Issue 1308273010: Adapt and reland old position sticky implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: WIP - fix on release, still hits CHECK in LayoutGeometryMap.cpp:156 Created 4 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) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 #endif 950 #endif
951 951
952 bool ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects(Frame View* frameView) const 952 bool ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects(Frame View* frameView) const
953 { 953 {
954 const FrameView::ViewportConstrainedObjectSet* viewportConstrainedObjects = frameView->viewportConstrainedObjects(); 954 const FrameView::ViewportConstrainedObjectSet* viewportConstrainedObjects = frameView->viewportConstrainedObjects();
955 if (!viewportConstrainedObjects) 955 if (!viewportConstrainedObjects)
956 return false; 956 return false;
957 957
958 for (const LayoutObject* layoutObject : *viewportConstrainedObjects) { 958 for (const LayoutObject* layoutObject : *viewportConstrainedObjects) {
959 ASSERT(layoutObject->isBoxModelObject() && layoutObject->hasLayer()); 959 ASSERT(layoutObject->isBoxModelObject() && layoutObject->hasLayer());
960 ASSERT(layoutObject->style()->position() == FixedPosition); 960 ASSERT(layoutObject->style()->position() == FixedPosition
961 || layoutObject->style()->position() == StickyPosition);
961 PaintLayer* layer = toLayoutBoxModelObject(layoutObject)->layer(); 962 PaintLayer* layer = toLayoutBoxModelObject(layoutObject)->layer();
962 963
963 // Whether the Layer scrolls with the viewport is a tree-depenent 964 // Whether the Layer scrolls with the viewport is a tree-depenent
964 // property and our viewportConstrainedObjects collection is maintained 965 // property and our viewportConstrainedObjects collection is maintained
965 // with only LayoutObject-level information. 966 // with only LayoutObject-level information.
966 if (!layer->scrollsWithViewport()) 967 if (!layer->scrollsWithViewport())
967 continue; 968 continue;
968 969
969 // If the whole subtree is invisible, there's no reason to scroll on 970 // If the whole subtree is invisible, there's no reason to scroll on
970 // the main thread because we don't need to generate invalidations 971 // the main thread because we don't need to generate invalidations
(...skipping 28 matching lines...) Expand all
999 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver seNext()) { 1000 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver seNext()) {
1000 if (!frame->isLocalFrame()) 1001 if (!frame->isLocalFrame())
1001 continue; 1002 continue;
1002 1003
1003 FrameView* frameView = toLocalFrame(frame)->view(); 1004 FrameView* frameView = toLocalFrame(frame)->view();
1004 if (!frameView) 1005 if (!frameView)
1005 continue; 1006 continue;
1006 1007
1007 if (frameView->hasBackgroundAttachmentFixedObjects()) 1008 if (frameView->hasBackgroundAttachmentFixedObjects())
1008 reasons |= MainThreadScrollingReason::kHasBackgroundAttachmentFixedO bjects; 1009 reasons |= MainThreadScrollingReason::kHasBackgroundAttachmentFixedO bjects;
1010 if (frameView->hasStickyPositionObjects())
1011 reasons |= MainThreadScrollingReason::kHasStickyPositionObjects;
1009 FrameView::ScrollingReasons scrollingReasons = frameView->scrollingReaso ns(); 1012 FrameView::ScrollingReasons scrollingReasons = frameView->scrollingReaso ns();
1010 const bool mayBeScrolledByInput = (scrollingReasons == FrameView::Scroll able); 1013 const bool mayBeScrolledByInput = (scrollingReasons == FrameView::Scroll able);
1011 const bool mayBeScrolledByScript = mayBeScrolledByInput || (scrollingRea sons == 1014 const bool mayBeScrolledByScript = mayBeScrolledByInput || (scrollingRea sons ==
1012 FrameView::NotScrollableExplicitlyDisabled); 1015 FrameView::NotScrollableExplicitlyDisabled);
1013 1016
1014 // TODO(awoloszyn) Currently crbug.com/304810 will let certain 1017 // TODO(awoloszyn) Currently crbug.com/304810 will let certain
1015 // overflow:hidden elements scroll on the compositor thread, so we shoul d 1018 // overflow:hidden elements scroll on the compositor thread, so we shoul d
1016 // not let this move there path as an optimization, when we have slow-re paint 1019 // not let this move there path as an optimization, when we have slow-re paint
1017 // elements. 1020 // elements.
1018 if (mayBeScrolledByScript && hasVisibleSlowRepaintViewportConstrainedObj ects(frameView)) { 1021 if (mayBeScrolledByScript && hasVisibleSlowRepaintViewportConstrainedObj ects(frameView)) {
1019 reasons |= MainThreadScrollingReason::kHasNonLayerViewportConstraine dObjects; 1022 reasons |= MainThreadScrollingReason::kHasNonLayerViewportConstraine dObjects;
1020 } 1023 }
1021 } 1024 }
1022 1025
1023 return reasons; 1026 return reasons;
1024 } 1027 }
1025 1028
1026 String ScrollingCoordinator::mainThreadScrollingReasonsAsText(MainThreadScrollin gReasons reasons) 1029 String ScrollingCoordinator::mainThreadScrollingReasonsAsText(MainThreadScrollin gReasons reasons)
1027 { 1030 {
1028 StringBuilder stringBuilder; 1031 StringBuilder stringBuilder;
1029 1032
1030 if (reasons & MainThreadScrollingReason::kHasBackgroundAttachmentFixedObject s) 1033 if (reasons & MainThreadScrollingReason::kHasBackgroundAttachmentFixedObject s)
1031 stringBuilder.appendLiteral("Has background-attachment:fixed, "); 1034 stringBuilder.appendLiteral("Has background-attachment:fixed, ");
1032 if (reasons & MainThreadScrollingReason::kHasNonLayerViewportConstrainedObje cts) 1035 if (reasons & MainThreadScrollingReason::kHasNonLayerViewportConstrainedObje cts)
1033 stringBuilder.appendLiteral("Has non-layer viewport-constrained objects, "); 1036 stringBuilder.appendLiteral("Has non-layer viewport-constrained objects, ");
1037 if (reasons & MainThreadScrollingReason::kHasStickyPositionObjects)
1038 stringBuilder.appendLiteral("Has sticky position objects, ");
1034 if (reasons & MainThreadScrollingReason::kThreadedScrollingDisabled) 1039 if (reasons & MainThreadScrollingReason::kThreadedScrollingDisabled)
1035 stringBuilder.appendLiteral("Threaded scrolling is disabled, "); 1040 stringBuilder.appendLiteral("Threaded scrolling is disabled, ");
1036 1041
1037 if (stringBuilder.length()) 1042 if (stringBuilder.length())
1038 stringBuilder.resize(stringBuilder.length() - 2); 1043 stringBuilder.resize(stringBuilder.length() - 2);
1039 return stringBuilder.toString(); 1044 return stringBuilder.toString();
1040 } 1045 }
1041 1046
1042 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const 1047 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const
1043 { 1048 {
1044 ASSERT(m_page->deprecatedLocalMainFrame()->document()->lifecycle().state() > = DocumentLifecycle::CompositingClean); 1049 ASSERT(m_page->deprecatedLocalMainFrame()->document()->lifecycle().state() > = DocumentLifecycle::CompositingClean);
1045 return mainThreadScrollingReasonsAsText(m_lastMainThreadScrollingReasons); 1050 return mainThreadScrollingReasonsAsText(m_lastMainThreadScrollingReasons);
1046 } 1051 }
1047 1052
1048 bool ScrollingCoordinator::frameViewIsDirty() const 1053 bool ScrollingCoordinator::frameViewIsDirty() const
1049 { 1054 {
1050 FrameView* frameView = m_page->mainFrame()->isLocalFrame() ? m_page->depreca tedLocalMainFrame()->view() : nullptr; 1055 FrameView* frameView = m_page->mainFrame()->isLocalFrame() ? m_page->depreca tedLocalMainFrame()->view() : nullptr;
1051 bool frameIsScrollable = frameView && frameView->isScrollable(); 1056 bool frameIsScrollable = frameView && frameView->isScrollable();
1052 if (frameIsScrollable != m_wasFrameScrollable) 1057 if (frameIsScrollable != m_wasFrameScrollable)
1053 return true; 1058 return true;
1054 1059
1055 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll ing()) : nullptr) 1060 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll ing()) : nullptr)
1056 return WebSize(frameView->contentsSize()) != scrollLayer->bounds(); 1061 return WebSize(frameView->contentsSize()) != scrollLayer->bounds();
1057 return false; 1062 return false;
1058 } 1063 }
1059 1064
1060 } // namespace blink 1065 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698