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

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

Issue 1648293003: Fix smooth scroll jump when switching scroll handling between MT and CC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: todo + nit 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 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 { 679 {
680 m_layersWithTouchRects.remove(layer); 680 m_layersWithTouchRects.remove(layer);
681 } 681 }
682 682
683 void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainTh readScrollingReasons mainThreadScrollingReasons) 683 void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainTh readScrollingReasons mainThreadScrollingReasons)
684 { 684 {
685 if (!m_page->mainFrame()->isLocalFrame() || !m_page->deprecatedLocalMainFram e()->view()) 685 if (!m_page->mainFrame()->isLocalFrame() || !m_page->deprecatedLocalMainFram e()->view())
686 return; 686 return;
687 if (WebLayer* scrollLayer = toWebLayer(m_page->deprecatedLocalMainFrame()->v iew()->layerForScrolling())) { 687 if (WebLayer* scrollLayer = toWebLayer(m_page->deprecatedLocalMainFrame()->v iew()->layerForScrolling())) {
688 m_lastMainThreadScrollingReasons = mainThreadScrollingReasons; 688 m_lastMainThreadScrollingReasons = mainThreadScrollingReasons;
689 if (mainThreadScrollingReasons) 689 if (mainThreadScrollingReasons) {
690 scrollLayer->addMainThreadScrollingReasons(mainThreadScrollingReason s); 690 scrollLayer->addMainThreadScrollingReasons(mainThreadScrollingReason s);
691 else 691 } else {
692 scrollLayer->clearMainThreadScrollingReasons(); 692 // Clear all main thread scrolling reasons except the one that's set
693 // if there is a running scroll animation.
694 uint32_t mainThreadScrollingReasonsToClear = ~0u;
695 mainThreadScrollingReasonsToClear &= ~MainThreadScrollingReason::kAn imatingScollOnMainThread;
696 scrollLayer->clearMainThreadScrollingReasons(mainThreadScrollingReas onsToClear);
697 }
693 } 698 }
694 } 699 }
695 700
696 void ScrollingCoordinator::layerTreeViewInitialized(WebLayerTreeView& layerTreeV iew) 701 void ScrollingCoordinator::layerTreeViewInitialized(WebLayerTreeView& layerTreeV iew)
697 { 702 {
698 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled() && Platfor m::current()->isThreadedAnimationEnabled()) { 703 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled() && Platfor m::current()->isThreadedAnimationEnabled()) {
699 ASSERT(Platform::current()->compositorSupport()); 704 ASSERT(Platform::current()->compositorSupport());
700 m_programmaticScrollAnimatorTimeline = adoptPtr(Platform::current()->com positorSupport()->createAnimationTimeline()); 705 m_programmaticScrollAnimatorTimeline = adoptPtr(Platform::current()->com positorSupport()->createAnimationTimeline());
701 layerTreeView.attachCompositorAnimationTimeline(m_programmaticScrollAnim atorTimeline.get()); 706 layerTreeView.attachCompositorAnimationTimeline(m_programmaticScrollAnim atorTimeline.get());
702 } 707 }
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 String ScrollingCoordinator::mainThreadScrollingReasonsAsText(MainThreadScrollin gReasons reasons) 1031 String ScrollingCoordinator::mainThreadScrollingReasonsAsText(MainThreadScrollin gReasons reasons)
1027 { 1032 {
1028 StringBuilder stringBuilder; 1033 StringBuilder stringBuilder;
1029 1034
1030 if (reasons & MainThreadScrollingReason::kHasBackgroundAttachmentFixedObject s) 1035 if (reasons & MainThreadScrollingReason::kHasBackgroundAttachmentFixedObject s)
1031 stringBuilder.appendLiteral("Has background-attachment:fixed, "); 1036 stringBuilder.appendLiteral("Has background-attachment:fixed, ");
1032 if (reasons & MainThreadScrollingReason::kHasNonLayerViewportConstrainedObje cts) 1037 if (reasons & MainThreadScrollingReason::kHasNonLayerViewportConstrainedObje cts)
1033 stringBuilder.appendLiteral("Has non-layer viewport-constrained objects, "); 1038 stringBuilder.appendLiteral("Has non-layer viewport-constrained 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, ");
1041 if (reasons & MainThreadScrollingReason::kAnimatingScollOnMainThread)
1042 stringBuilder.appendLiteral("Animating scroll on main thread, ");
1036 1043
1037 if (stringBuilder.length()) 1044 if (stringBuilder.length())
1038 stringBuilder.resize(stringBuilder.length() - 2); 1045 stringBuilder.resize(stringBuilder.length() - 2);
1039 return stringBuilder.toString(); 1046 return stringBuilder.toString();
1040 } 1047 }
1041 1048
1042 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const 1049 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const
1043 { 1050 {
1044 ASSERT(m_page->deprecatedLocalMainFrame()->document()->lifecycle().state() > = DocumentLifecycle::CompositingClean); 1051 ASSERT(m_page->deprecatedLocalMainFrame()->document()->lifecycle().state() > = DocumentLifecycle::CompositingClean);
1052 if (WebLayer* scrollLayer = toWebLayer(m_page->deprecatedLocalMainFrame()->v iew()->layerForScrolling()))
1053 return mainThreadScrollingReasonsAsText(scrollLayer->mainThreadScrolling Reasons());
1054
1045 return mainThreadScrollingReasonsAsText(m_lastMainThreadScrollingReasons); 1055 return mainThreadScrollingReasonsAsText(m_lastMainThreadScrollingReasons);
1046 } 1056 }
1047 1057
1048 bool ScrollingCoordinator::frameViewIsDirty() const 1058 bool ScrollingCoordinator::frameViewIsDirty() const
1049 { 1059 {
1050 FrameView* frameView = m_page->mainFrame()->isLocalFrame() ? m_page->depreca tedLocalMainFrame()->view() : nullptr; 1060 FrameView* frameView = m_page->mainFrame()->isLocalFrame() ? m_page->depreca tedLocalMainFrame()->view() : nullptr;
1051 bool frameIsScrollable = frameView && frameView->isScrollable(); 1061 bool frameIsScrollable = frameView && frameView->isScrollable();
1052 if (frameIsScrollable != m_wasFrameScrollable) 1062 if (frameIsScrollable != m_wasFrameScrollable)
1053 return true; 1063 return true;
1054 1064
1055 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll ing()) : nullptr) 1065 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll ing()) : nullptr)
1056 return WebSize(frameView->contentsSize()) != scrollLayer->bounds(); 1066 return WebSize(frameView->contentsSize()) != scrollLayer->bounds();
1057 return false; 1067 return false;
1058 } 1068 }
1059 1069
1060 } // namespace blink 1070 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698