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

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: skip irrelevant test on mac Created 4 years, 9 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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 { 680 {
681 m_layersWithTouchRects.remove(layer); 681 m_layersWithTouchRects.remove(layer);
682 } 682 }
683 683
684 void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainTh readScrollingReasons mainThreadScrollingReasons) 684 void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainTh readScrollingReasons mainThreadScrollingReasons)
685 { 685 {
686 if (!m_page->mainFrame()->isLocalFrame() || !m_page->deprecatedLocalMainFram e()->view()) 686 if (!m_page->mainFrame()->isLocalFrame() || !m_page->deprecatedLocalMainFram e()->view())
687 return; 687 return;
688 if (WebLayer* scrollLayer = toWebLayer(m_page->deprecatedLocalMainFrame()->v iew()->layerForScrolling())) { 688 if (WebLayer* scrollLayer = toWebLayer(m_page->deprecatedLocalMainFrame()->v iew()->layerForScrolling())) {
689 m_lastMainThreadScrollingReasons = mainThreadScrollingReasons; 689 m_lastMainThreadScrollingReasons = mainThreadScrollingReasons;
690 if (mainThreadScrollingReasons) 690 if (mainThreadScrollingReasons) {
691 scrollLayer->addMainThreadScrollingReasons(mainThreadScrollingReason s); 691 scrollLayer->addMainThreadScrollingReasons(mainThreadScrollingReason s);
692 else 692 } else {
693 scrollLayer->clearMainThreadScrollingReasons(); 693 // Clear all main thread scrolling reasons except the one that's set
694 // if there is a running scroll animation.
695 uint32_t mainThreadScrollingReasonsToClear = ~0u;
696 mainThreadScrollingReasonsToClear &= ~MainThreadScrollingReason::kAn imatingScrollOnMainThread;
697 scrollLayer->clearMainThreadScrollingReasons(mainThreadScrollingReas onsToClear);
698 }
694 } 699 }
695 } 700 }
696 701
697 void ScrollingCoordinator::layerTreeViewInitialized(WebLayerTreeView& layerTreeV iew) 702 void ScrollingCoordinator::layerTreeViewInitialized(WebLayerTreeView& layerTreeV iew)
698 { 703 {
699 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled() && Platfor m::current()->isThreadedAnimationEnabled()) { 704 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled() && Platfor m::current()->isThreadedAnimationEnabled()) {
700 m_programmaticScrollAnimatorTimeline = adoptPtr(CompositorFactory::curre nt().createAnimationTimeline()); 705 m_programmaticScrollAnimatorTimeline = adoptPtr(CompositorFactory::curre nt().createAnimationTimeline());
701 layerTreeView.attachCompositorAnimationTimeline(m_programmaticScrollAnim atorTimeline->animationTimeline()); 706 layerTreeView.attachCompositorAnimationTimeline(m_programmaticScrollAnim atorTimeline->animationTimeline());
702 } 707 }
703 } 708 }
(...skipping 322 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::kAnimatingScrollOnMainThread)
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