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

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: Force main thread scrolling, set experimental status, and address review comments. Created 5 years 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 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 #endif 987 #endif
988 988
989 bool ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects(Frame View* frameView) const 989 bool ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects(Frame View* frameView) const
990 { 990 {
991 const FrameView::ViewportConstrainedObjectSet* viewportConstrainedObjects = frameView->viewportConstrainedObjects(); 991 const FrameView::ViewportConstrainedObjectSet* viewportConstrainedObjects = frameView->viewportConstrainedObjects();
992 if (!viewportConstrainedObjects) 992 if (!viewportConstrainedObjects)
993 return false; 993 return false;
994 994
995 for (const LayoutObject* layoutObject : *viewportConstrainedObjects) { 995 for (const LayoutObject* layoutObject : *viewportConstrainedObjects) {
996 ASSERT(layoutObject->isBoxModelObject() && layoutObject->hasLayer()); 996 ASSERT(layoutObject->isBoxModelObject() && layoutObject->hasLayer());
997 ASSERT(layoutObject->style()->position() == FixedPosition); 997 ASSERT(layoutObject->style()->position() == FixedPosition
998 || layoutObject->style()->position() == StickyPosition);
998 PaintLayer* layer = toLayoutBoxModelObject(layoutObject)->layer(); 999 PaintLayer* layer = toLayoutBoxModelObject(layoutObject)->layer();
999 1000
1000 // Whether the Layer scrolls with the viewport is a tree-depenent 1001 // Whether the Layer scrolls with the viewport is a tree-depenent
1001 // property and our viewportConstrainedObjects collection is maintained 1002 // property and our viewportConstrainedObjects collection is maintained
1002 // with only LayoutObject-level information. 1003 // with only LayoutObject-level information.
1003 if (!layer->scrollsWithViewport()) 1004 if (!layer->scrollsWithViewport())
1004 continue; 1005 continue;
1005 1006
1006 // If the whole subtree is invisible, there's no reason to scroll on 1007 // If the whole subtree is invisible, there's no reason to scroll on
1007 // the main thread because we don't need to generate invalidations 1008 // the main thread because we don't need to generate invalidations
(...skipping 20 matching lines...) Expand all
1028 reasons |= ThreadedScrollingDisabled; 1029 reasons |= ThreadedScrollingDisabled;
1029 1030
1030 if (!m_page->mainFrame()->isLocalFrame()) 1031 if (!m_page->mainFrame()->isLocalFrame())
1031 return reasons; 1032 return reasons;
1032 FrameView* frameView = m_page->deprecatedLocalMainFrame()->view(); 1033 FrameView* frameView = m_page->deprecatedLocalMainFrame()->view();
1033 if (!frameView) 1034 if (!frameView)
1034 return reasons; 1035 return reasons;
1035 1036
1036 if (frameView->hasBackgroundAttachmentFixedObjects()) 1037 if (frameView->hasBackgroundAttachmentFixedObjects())
1037 reasons |= HasBackgroundAttachmentFixedObjects; 1038 reasons |= HasBackgroundAttachmentFixedObjects;
1039 if (frameView->hasStickyPositionObjects())
1040 reasons |= HasStickyPositionObjects;
1038 FrameView::ScrollingReasons scrollingReasons = frameView->scrollingReasons() ; 1041 FrameView::ScrollingReasons scrollingReasons = frameView->scrollingReasons() ;
1039 const bool mayBeScrolledByInput = (scrollingReasons == FrameView::Scrollable ); 1042 const bool mayBeScrolledByInput = (scrollingReasons == FrameView::Scrollable );
1040 const bool mayBeScrolledByScript = mayBeScrolledByInput || (scrollingReasons == 1043 const bool mayBeScrolledByScript = mayBeScrolledByInput || (scrollingReasons ==
1041 FrameView::NotScrollableExplicitlyDisabled); 1044 FrameView::NotScrollableExplicitlyDisabled);
1042 1045
1043 // TODO(awoloszyn) Currently crbug.com/304810 will let certain 1046 // TODO(awoloszyn) Currently crbug.com/304810 will let certain
1044 // overflow:hidden elements scroll on the compositor thread, so we should 1047 // overflow:hidden elements scroll on the compositor thread, so we should
1045 // not let this move there path as an optimization, when we have slow-repain t 1048 // not let this move there path as an optimization, when we have slow-repain t
1046 // elements. 1049 // elements.
1047 if (mayBeScrolledByScript && hasVisibleSlowRepaintViewportConstrainedObjects (frameView)) { 1050 if (mayBeScrolledByScript && hasVisibleSlowRepaintViewportConstrainedObjects (frameView)) {
1048 reasons |= HasNonLayerViewportConstrainedObjects; 1051 reasons |= HasNonLayerViewportConstrainedObjects;
1049 } 1052 }
1050 1053
1051 return reasons; 1054 return reasons;
1052 } 1055 }
1053 1056
1054 String ScrollingCoordinator::mainThreadScrollingReasonsAsText(MainThreadScrollin gReasons reasons) 1057 String ScrollingCoordinator::mainThreadScrollingReasonsAsText(MainThreadScrollin gReasons reasons)
1055 { 1058 {
1056 StringBuilder stringBuilder; 1059 StringBuilder stringBuilder;
1057 1060
1058 if (reasons & ScrollingCoordinator::HasBackgroundAttachmentFixedObjects) 1061 if (reasons & ScrollingCoordinator::HasBackgroundAttachmentFixedObjects)
1059 stringBuilder.appendLiteral("Has background-attachment:fixed, "); 1062 stringBuilder.appendLiteral("Has background-attachment:fixed, ");
1060 if (reasons & ScrollingCoordinator::HasNonLayerViewportConstrainedObjects) 1063 if (reasons & ScrollingCoordinator::HasNonLayerViewportConstrainedObjects)
1061 stringBuilder.appendLiteral("Has non-layer viewport-constrained objects, "); 1064 stringBuilder.appendLiteral("Has non-layer viewport-constrained objects, ");
1065 if (reasons & ScrollingCoordinator::HasStickyPositionObjects)
1066 stringBuilder.appendLiteral("Has sticky position objects, ");
1062 if (reasons & ScrollingCoordinator::ThreadedScrollingDisabled) 1067 if (reasons & ScrollingCoordinator::ThreadedScrollingDisabled)
1063 stringBuilder.appendLiteral("Threaded scrolling is disabled, "); 1068 stringBuilder.appendLiteral("Threaded scrolling is disabled, ");
1064 1069
1065 if (stringBuilder.length()) 1070 if (stringBuilder.length())
1066 stringBuilder.resize(stringBuilder.length() - 2); 1071 stringBuilder.resize(stringBuilder.length() - 2);
1067 return stringBuilder.toString(); 1072 return stringBuilder.toString();
1068 } 1073 }
1069 1074
1070 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const 1075 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const
1071 { 1076 {
1072 ASSERT(m_page->deprecatedLocalMainFrame()->document()->lifecycle().state() > = DocumentLifecycle::CompositingClean); 1077 ASSERT(m_page->deprecatedLocalMainFrame()->document()->lifecycle().state() > = DocumentLifecycle::CompositingClean);
1073 return mainThreadScrollingReasonsAsText(m_lastMainThreadScrollingReasons); 1078 return mainThreadScrollingReasonsAsText(m_lastMainThreadScrollingReasons);
1074 } 1079 }
1075 1080
1076 bool ScrollingCoordinator::frameViewIsDirty() const 1081 bool ScrollingCoordinator::frameViewIsDirty() const
1077 { 1082 {
1078 FrameView* frameView = m_page->mainFrame()->isLocalFrame() ? m_page->depreca tedLocalMainFrame()->view() : nullptr; 1083 FrameView* frameView = m_page->mainFrame()->isLocalFrame() ? m_page->depreca tedLocalMainFrame()->view() : nullptr;
1079 bool frameIsScrollable = frameView && frameView->isScrollable(); 1084 bool frameIsScrollable = frameView && frameView->isScrollable();
1080 if (frameIsScrollable != m_wasFrameScrollable) 1085 if (frameIsScrollable != m_wasFrameScrollable)
1081 return true; 1086 return true;
1082 1087
1083 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll ing()) : nullptr) 1088 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll ing()) : nullptr)
1084 return WebSize(frameView->contentsSize()) != scrollLayer->bounds(); 1089 return WebSize(frameView->contentsSize()) != scrollLayer->bounds();
1085 return false; 1090 return false;
1086 } 1091 }
1087 1092
1088 } // namespace blink 1093 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698