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

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

Issue 1870663002: Reland main thread position sticky implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Only descend into children which have an ancestor overflow layer. Created 4 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) 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 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 #endif 930 #endif
931 931
932 bool ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects(Frame View* frameView) const 932 bool ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects(Frame View* frameView) const
933 { 933 {
934 const FrameView::ViewportConstrainedObjectSet* viewportConstrainedObjects = frameView->viewportConstrainedObjects(); 934 const FrameView::ViewportConstrainedObjectSet* viewportConstrainedObjects = frameView->viewportConstrainedObjects();
935 if (!viewportConstrainedObjects) 935 if (!viewportConstrainedObjects)
936 return false; 936 return false;
937 937
938 for (const LayoutObject* layoutObject : *viewportConstrainedObjects) { 938 for (const LayoutObject* layoutObject : *viewportConstrainedObjects) {
939 ASSERT(layoutObject->isBoxModelObject() && layoutObject->hasLayer()); 939 ASSERT(layoutObject->isBoxModelObject() && layoutObject->hasLayer());
940 ASSERT(layoutObject->style()->position() == FixedPosition); 940 ASSERT(layoutObject->style()->position() == FixedPosition
941 || layoutObject->style()->position() == StickyPosition);
941 PaintLayer* layer = toLayoutBoxModelObject(layoutObject)->layer(); 942 PaintLayer* layer = toLayoutBoxModelObject(layoutObject)->layer();
942 943
943 // Whether the Layer scrolls with the viewport is a tree-depenent 944 // Whether the Layer scrolls with the viewport is a tree-depenent
944 // property and our viewportConstrainedObjects collection is maintained 945 // property and our viewportConstrainedObjects collection is maintained
945 // with only LayoutObject-level information. 946 // with only LayoutObject-level information.
946 if (!layer->scrollsWithViewport()) 947 if (!layer->scrollsWithViewport())
947 continue; 948 continue;
948 949
949 // If the whole subtree is invisible, there's no reason to scroll on 950 // If the whole subtree is invisible, there's no reason to scroll on
950 // the main thread because we don't need to generate invalidations 951 // the main thread because we don't need to generate invalidations
(...skipping 28 matching lines...) Expand all
979 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver seNext()) { 980 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver seNext()) {
980 if (!frame->isLocalFrame()) 981 if (!frame->isLocalFrame())
981 continue; 982 continue;
982 983
983 FrameView* frameView = toLocalFrame(frame)->view(); 984 FrameView* frameView = toLocalFrame(frame)->view();
984 if (!frameView || frameView->shouldThrottleRendering()) 985 if (!frameView || frameView->shouldThrottleRendering())
985 continue; 986 continue;
986 987
987 if (frameView->hasBackgroundAttachmentFixedObjects()) 988 if (frameView->hasBackgroundAttachmentFixedObjects())
988 reasons |= MainThreadScrollingReason::kHasBackgroundAttachmentFixedO bjects; 989 reasons |= MainThreadScrollingReason::kHasBackgroundAttachmentFixedO bjects;
990 if (frameView->hasStickyPositionObjects())
991 reasons |= MainThreadScrollingReason::kHasStickyPositionObjects;
989 FrameView::ScrollingReasons scrollingReasons = frameView->getScrollingRe asons(); 992 FrameView::ScrollingReasons scrollingReasons = frameView->getScrollingRe asons();
990 const bool mayBeScrolledByInput = (scrollingReasons == FrameView::Scroll able); 993 const bool mayBeScrolledByInput = (scrollingReasons == FrameView::Scroll able);
991 const bool mayBeScrolledByScript = mayBeScrolledByInput || (scrollingRea sons == 994 const bool mayBeScrolledByScript = mayBeScrolledByInput || (scrollingRea sons ==
992 FrameView::NotScrollableExplicitlyDisabled); 995 FrameView::NotScrollableExplicitlyDisabled);
993 996
994 // TODO(awoloszyn) Currently crbug.com/304810 will let certain 997 // TODO(awoloszyn) Currently crbug.com/304810 will let certain
995 // overflow:hidden elements scroll on the compositor thread, so we shoul d 998 // overflow:hidden elements scroll on the compositor thread, so we shoul d
996 // not let this move there path as an optimization, when we have slow-re paint 999 // not let this move there path as an optimization, when we have slow-re paint
997 // elements. 1000 // elements.
998 if (mayBeScrolledByScript && hasVisibleSlowRepaintViewportConstrainedObj ects(frameView)) { 1001 if (mayBeScrolledByScript && hasVisibleSlowRepaintViewportConstrainedObj ects(frameView)) {
999 reasons |= MainThreadScrollingReason::kHasNonLayerViewportConstraine dObjects; 1002 reasons |= MainThreadScrollingReason::kHasNonLayerViewportConstraine dObjects;
1000 } 1003 }
1001 } 1004 }
1002 1005
1003 return reasons; 1006 return reasons;
1004 } 1007 }
1005 1008
1006 String ScrollingCoordinator::mainThreadScrollingReasonsAsText(MainThreadScrollin gReasons reasons) 1009 String ScrollingCoordinator::mainThreadScrollingReasonsAsText(MainThreadScrollin gReasons reasons)
1007 { 1010 {
1008 StringBuilder stringBuilder; 1011 StringBuilder stringBuilder;
1009 1012
1010 if (reasons & MainThreadScrollingReason::kHasBackgroundAttachmentFixedObject s) 1013 if (reasons & MainThreadScrollingReason::kHasBackgroundAttachmentFixedObject s)
1011 stringBuilder.appendLiteral("Has background-attachment:fixed, "); 1014 stringBuilder.appendLiteral("Has background-attachment:fixed, ");
1012 if (reasons & MainThreadScrollingReason::kHasNonLayerViewportConstrainedObje cts) 1015 if (reasons & MainThreadScrollingReason::kHasNonLayerViewportConstrainedObje cts)
1013 stringBuilder.appendLiteral("Has non-layer viewport-constrained objects, "); 1016 stringBuilder.appendLiteral("Has non-layer viewport-constrained objects, ");
1017 if (reasons & MainThreadScrollingReason::kHasStickyPositionObjects)
1018 stringBuilder.appendLiteral("Has sticky position objects, ");
1014 if (reasons & MainThreadScrollingReason::kThreadedScrollingDisabled) 1019 if (reasons & MainThreadScrollingReason::kThreadedScrollingDisabled)
1015 stringBuilder.appendLiteral("Threaded scrolling is disabled, "); 1020 stringBuilder.appendLiteral("Threaded scrolling is disabled, ");
1016 if (reasons & MainThreadScrollingReason::kAnimatingScrollOnMainThread) 1021 if (reasons & MainThreadScrollingReason::kAnimatingScrollOnMainThread)
1017 stringBuilder.appendLiteral("Animating scroll on main thread, "); 1022 stringBuilder.appendLiteral("Animating scroll on main thread, ");
1018 1023
1019 if (stringBuilder.length()) 1024 if (stringBuilder.length())
1020 stringBuilder.resize(stringBuilder.length() - 2); 1025 stringBuilder.resize(stringBuilder.length() - 2);
1021 return stringBuilder.toString(); 1026 return stringBuilder.toString();
1022 } 1027 }
1023 1028
(...skipping 12 matching lines...) Expand all
1036 bool frameIsScrollable = frameView && frameView->isScrollable(); 1041 bool frameIsScrollable = frameView && frameView->isScrollable();
1037 if (frameIsScrollable != m_wasFrameScrollable) 1042 if (frameIsScrollable != m_wasFrameScrollable)
1038 return true; 1043 return true;
1039 1044
1040 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll ing()) : nullptr) 1045 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll ing()) : nullptr)
1041 return WebSize(frameView->contentsSize()) != scrollLayer->bounds(); 1046 return WebSize(frameView->contentsSize()) != scrollLayer->bounds();
1042 return false; 1047 return false;
1043 } 1048 }
1044 1049
1045 } // namespace blink 1050 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698