diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-02-13 16:23:34 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-02-14 10:37:21 +0000 |
commit | 38a9a29f4f9436cace7f0e7abf9c586057df8a4e (patch) | |
tree | c4e8c458dc595bc0ddb435708fa2229edfd00bd4 /chromium/cc/input | |
parent | e684a3455bcc29a6e3e66a004e352dea4e1141e7 (diff) | |
download | qtwebengine-chromium-38a9a29f4f9436cace7f0e7abf9c586057df8a4e.tar.gz |
BASELINE: Update Chromium to 73.0.3683.37
Change-Id: I08c9af2948b645f671e5d933aca1f7a90ea372f2
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/cc/input')
14 files changed, 186 insertions, 69 deletions
diff --git a/chromium/cc/input/layer_selection_bound.cc b/chromium/cc/input/layer_selection_bound.cc index 521cd653f59..55f2e3a5fb4 100644 --- a/chromium/cc/input/layer_selection_bound.cc +++ b/chromium/cc/input/layer_selection_bound.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/logging.h" +#include "base/strings/stringprintf.h" #include "cc/input/layer_selection_bound.h" namespace cc { @@ -22,4 +23,10 @@ bool LayerSelectionBound::operator!=(const LayerSelectionBound& other) const { return !(*this == other); } +std::string LayerSelectionBound::ToString() const { + return base::StringPrintf("LayerSelectionBound(%s, %s, %d)", + edge_top.ToString().c_str(), + edge_bottom.ToString().c_str(), hidden); +} + } // namespace cc diff --git a/chromium/cc/input/layer_selection_bound.h b/chromium/cc/input/layer_selection_bound.h index 5174341909b..a2a2583c143 100644 --- a/chromium/cc/input/layer_selection_bound.h +++ b/chromium/cc/input/layer_selection_bound.h @@ -26,6 +26,8 @@ struct CC_EXPORT LayerSelectionBound { // content of the layer (as opposed to being outside of the layer's bounds). bool hidden; + std::string ToString() const; + bool operator==(const LayerSelectionBound& other) const; bool operator!=(const LayerSelectionBound& other) const; }; diff --git a/chromium/cc/input/main_thread_scrolling_reason.cc b/chromium/cc/input/main_thread_scrolling_reason.cc index 728708ce776..5d1a6b9c5a9 100644 --- a/chromium/cc/input/main_thread_scrolling_reason.cc +++ b/chromium/cc/input/main_thread_scrolling_reason.cc @@ -35,8 +35,8 @@ void MainThreadScrollingReason::AddToTracedValue( traced_value.AppendString("Threaded scrolling is disabled"); if (reasons & kScrollbarScrolling) traced_value.AppendString("Scrollbar scrolling"); - if (reasons & kPageOverlay) - traced_value.AppendString("Page overlay"); + if (reasons & kFrameOverlay) + traced_value.AppendString("Frame overlay"); if (reasons & kHandlingScrollFromMainThread) traced_value.AppendString("Handling scroll from main thread"); if (reasons & kCustomScrollbarScrolling) diff --git a/chromium/cc/input/main_thread_scrolling_reason.h b/chromium/cc/input/main_thread_scrolling_reason.h index 732c3fa904b..6878928bfe7 100644 --- a/chromium/cc/input/main_thread_scrolling_reason.h +++ b/chromium/cc/input/main_thread_scrolling_reason.h @@ -28,7 +28,7 @@ struct CC_EXPORT MainThreadScrollingReason { kHasNonLayerViewportConstrainedObjects = 1 << 1, kThreadedScrollingDisabled = 1 << 2, kScrollbarScrolling = 1 << 3, - kPageOverlay = 1 << 4, + kFrameOverlay = 1 << 4, // This bit is set when any of the other main thread scrolling reasons cause // an input event to be handled on the main thread, and the main thread @@ -80,7 +80,7 @@ struct CC_EXPORT MainThreadScrollingReason { uint32_t reasons_set_by_main_thread = kNotScrollingOnMain | kHasBackgroundAttachmentFixedObjects | kHasNonLayerViewportConstrainedObjects | kThreadedScrollingDisabled | - kScrollbarScrolling | kPageOverlay | kHandlingScrollFromMainThread | + kScrollbarScrolling | kFrameOverlay | kHandlingScrollFromMainThread | kCustomScrollbarScrolling; return (reasons & reasons_set_by_main_thread) == reasons; } diff --git a/chromium/cc/input/main_thread_scrolling_reason_unittest.cc b/chromium/cc/input/main_thread_scrolling_reason_unittest.cc index 7560dda71d9..c6ab9e4a61f 100644 --- a/chromium/cc/input/main_thread_scrolling_reason_unittest.cc +++ b/chromium/cc/input/main_thread_scrolling_reason_unittest.cc @@ -17,7 +17,7 @@ TEST_F(MainThreadScrollingReasonTest, AsText) { "Has non-layer viewport-constrained objects," "Threaded scrolling is disabled," "Scrollbar scrolling," - "Page overlay," + "Frame overlay," "Handling scroll from main thread," "Custom scrollbar scrolling," "Has opacity and LCD text," diff --git a/chromium/cc/input/scroll_snap_data.cc b/chromium/cc/input/scroll_snap_data.cc index 3fc17474fc7..3d4ad87e1ba 100644 --- a/chromium/cc/input/scroll_snap_data.cc +++ b/chromium/cc/input/scroll_snap_data.cc @@ -153,24 +153,42 @@ base::Optional<SnapSearchResult> SnapContainerData::FindClosestValidArea( SearchAxis axis, const SnapSelectionStrategy& strategy, const SnapSearchResult& cros_axis_snap_result) const { + base::Optional<SnapSearchResult> result = + FindClosestValidAreaInternal(axis, strategy, cros_axis_snap_result); + // Our current direction based strategies are too strict ignoring the other + // directions even when we have no candidate in the given direction. This is + // particularly problematic with mandatory snap points and for fling + // gestures. To counteract this, if the direction based strategy finds no + // candidates, we do a second search ignoring the direction (this is + // implemented by using an equivalent EndPosition strategy). + if (result.has_value() || + scroll_snap_type_.strictness == SnapStrictness::kProximity || + !strategy.HasIntendedDirection()) + return result; + + std::unique_ptr<SnapSelectionStrategy> relaxed_strategy = + SnapSelectionStrategy::CreateForEndPosition(strategy.current_position(), + strategy.ShouldSnapOnX(), + strategy.ShouldSnapOnY()); + return FindClosestValidAreaInternal(axis, *relaxed_strategy, + cros_axis_snap_result); +} + +base::Optional<SnapSearchResult> +SnapContainerData::FindClosestValidAreaInternal( + SearchAxis axis, + const SnapSelectionStrategy& strategy, + const SnapSearchResult& cros_axis_snap_result) const { // The search result from the snap area that's closest to the search origin. base::Optional<SnapSearchResult> closest; // The search result with the intended position if it makes a snap area cover // the snapport. base::Optional<SnapSearchResult> covering; - // The search result with the current position as a backup in case no other - // valid snap position exists. - base::Optional<SnapSearchResult> current; // The valid snap positions immediately before and after the current position. float prev = std::numeric_limits<float>::lowest(); float next = std::numeric_limits<float>::max(); - // The current position before the scroll or snap happens. If no other snap - // position exists, this would become a backup option. - float current_position = axis == SearchAxis::kX - ? strategy.current_position().x() - : strategy.current_position().y(); // The intended position of the scroll operation if there's no snap. This // scroll position becomes the covering candidate if there is a snap area that // fully covers the snapport if this position is scrolled to. @@ -203,24 +221,22 @@ base::Optional<SnapSearchResult> SnapContainerData::FindClosestValidArea( } if (!IsMutualVisible(candidate, cros_axis_snap_result)) continue; - if (!strategy.IsValidSnapPosition(axis, candidate.snap_offset())) { - if (candidate.snap_offset() == current_position && - scroll_snap_type_.strictness == SnapStrictness::kMandatory) { - SetOrUpdateResult(candidate, ¤t); - } - continue; - } + float distance = std::abs(candidate.snap_offset() - base_position); - if (distance < smallest_distance) { - smallest_distance = distance; - closest = candidate; + if (strategy.IsValidSnapPosition(axis, candidate.snap_offset())) { + if (distance < smallest_distance) { + smallest_distance = distance; + closest = candidate; + } } if (candidate.snap_offset() < intended_position && - candidate.snap_offset() > prev) + candidate.snap_offset() > prev) { prev = candidate.snap_offset(); + } if (candidate.snap_offset() > intended_position && - candidate.snap_offset() < next) + candidate.snap_offset() < next) { next = candidate.snap_offset(); + } } // According to the spec [1], if the snap area is covering the snapport, the // scroll position is a valid snap position only if the distance between the @@ -235,7 +251,7 @@ base::Optional<SnapSearchResult> SnapContainerData::FindClosestValidArea( const base::Optional<SnapSearchResult>& picked = strategy.PickBestResult(closest, covering); - return picked.has_value() ? picked : current; + return picked; } SnapSearchResult SnapContainerData::GetSnapSearchResult( diff --git a/chromium/cc/input/scroll_snap_data.h b/chromium/cc/input/scroll_snap_data.h index 3057acf339e..3a8da213404 100644 --- a/chromium/cc/input/scroll_snap_data.h +++ b/chromium/cc/input/scroll_snap_data.h @@ -218,6 +218,15 @@ class CC_EXPORT SnapContainerData { // or the original scroll offset if this is the first iteration of search. // Returns the candidate as SnapSearchResult that includes the area's // |snap_offset| and its visible range on the cross axis. + base::Optional<SnapSearchResult> FindClosestValidAreaInternal( + SearchAxis axis, + const SnapSelectionStrategy& strategy, + const SnapSearchResult& cross_axis_snap_result) const; + + // A wrapper of FindClosestValidAreaInternal(). If + // FindClosestValidAreaInternal() doesn't return a valid result when the snap + // type is mandatory and the strategy has an intended direction, we relax the + // strategy to ignore the direction and find again. base::Optional<SnapSearchResult> FindClosestValidArea( SearchAxis axis, const SnapSelectionStrategy& strategy, diff --git a/chromium/cc/input/scroll_snap_data_unittest.cc b/chromium/cc/input/scroll_snap_data_unittest.cc index 6f994d543a0..3d95014f51f 100644 --- a/chromium/cc/input/scroll_snap_data_unittest.cc +++ b/chromium/cc/input/scroll_snap_data_unittest.cc @@ -229,4 +229,82 @@ TEST_F(ScrollSnapDataTest, DoesNotSnapToPositionsOutsideProximityRange) { EXPECT_EQ(100, snap_position.y()); } +TEST_F(ScrollSnapDataTest, MandatoryReturnsToCurrentIfNoValidAreaForward) { + SnapContainerData container( + ScrollSnapType(false, SnapAxis::kBoth, SnapStrictness::kMandatory), + gfx::RectF(0, 0, 200, 200), gfx::ScrollOffset(2000, 2000)); + SnapAreaData area(ScrollSnapAlign(SnapAlignment::kStart), + gfx::RectF(600, 0, 100, 100), false); + container.AddSnapAreaData(area); + gfx::ScrollOffset snap_position; + + std::unique_ptr<SnapSelectionStrategy> direction_strategy = + SnapSelectionStrategy::CreateForDirection(gfx::ScrollOffset(600, 0), + gfx::ScrollOffset(5, 0)); + EXPECT_TRUE(container.FindSnapPosition(*direction_strategy, &snap_position)); + // The snap direction is right. However, there is no valid snap position on + // that direction. So we have to stay at the current snap position of 600 as + // the snap type is mandatory. + EXPECT_EQ(600, snap_position.x()); + EXPECT_EQ(0, snap_position.y()); + + std::unique_ptr<SnapSelectionStrategy> end_direction_strategy = + SnapSelectionStrategy::CreateForEndAndDirection( + gfx::ScrollOffset(600, 0), gfx::ScrollOffset(15, 15)); + EXPECT_TRUE( + container.FindSnapPosition(*end_direction_strategy, &snap_position)); + // The snap direction is down and right. However, there is no valid snap + // position on that direction. So we have to stay at the current snap position + // of (600, 0) as the snap type is mandatory. + EXPECT_EQ(600, snap_position.x()); + EXPECT_EQ(0, snap_position.y()); + + // If the scroll-snap-type is proximity, we wouldn't consider the current + // snap area valid even if there is no snap area forward. + container.set_scroll_snap_type( + ScrollSnapType(false, SnapAxis::kBoth, SnapStrictness::kProximity)); + EXPECT_FALSE(container.FindSnapPosition(*direction_strategy, &snap_position)); + EXPECT_FALSE( + container.FindSnapPosition(*end_direction_strategy, &snap_position)); +} + +TEST_F(ScrollSnapDataTest, MandatorySnapsBackwardIfNoValidAreaForward) { + SnapContainerData container( + ScrollSnapType(false, SnapAxis::kBoth, SnapStrictness::kMandatory), + gfx::RectF(0, 0, 200, 200), gfx::ScrollOffset(2000, 2000)); + SnapAreaData area(ScrollSnapAlign(SnapAlignment::kStart), + gfx::RectF(600, 0, 100, 100), false); + container.AddSnapAreaData(area); + gfx::ScrollOffset snap_position; + + std::unique_ptr<SnapSelectionStrategy> direction_strategy = + SnapSelectionStrategy::CreateForDirection(gfx::ScrollOffset(650, 0), + gfx::ScrollOffset(5, 0)); + EXPECT_TRUE(container.FindSnapPosition(*direction_strategy, &snap_position)); + // The snap direction is right. However, there is no valid snap position on + // that direction. So we have to scroll back to the snap position of 600 as + // the snap type is mandatory. + EXPECT_EQ(600, snap_position.x()); + EXPECT_EQ(0, snap_position.y()); + + std::unique_ptr<SnapSelectionStrategy> end_direction_strategy = + SnapSelectionStrategy::CreateForEndAndDirection( + gfx::ScrollOffset(650, 10), gfx::ScrollOffset(15, 15)); + EXPECT_TRUE( + container.FindSnapPosition(*end_direction_strategy, &snap_position)); + // The snap direction is down and right. However, there is no valid snap + // position on that direction. So we have to scroll back to the snap position + // of (600, 0) as the snap type is mandatory. + EXPECT_EQ(600, snap_position.x()); + EXPECT_EQ(0, snap_position.y()); + + // If the scroll-snap-type is proximity, we wouldn't consider the backward + // snap area valid even if there is no snap area forward. + container.set_scroll_snap_type( + ScrollSnapType(false, SnapAxis::kBoth, SnapStrictness::kProximity)); + EXPECT_FALSE(container.FindSnapPosition(*direction_strategy, &snap_position)); + EXPECT_FALSE( + container.FindSnapPosition(*end_direction_strategy, &snap_position)); +} + } // namespace cc diff --git a/chromium/cc/input/scrollbar_animation_controller.cc b/chromium/cc/input/scrollbar_animation_controller.cc index 55f97f09d1f..0e57be6414b 100644 --- a/chromium/cc/input/scrollbar_animation_controller.cc +++ b/chromium/cc/input/scrollbar_animation_controller.cc @@ -124,8 +124,8 @@ void ScrollbarAnimationController::PostDelayedAnimation( animation_change_ = animation_change; delayed_scrollbar_animation_.Cancel(); delayed_scrollbar_animation_.Reset( - base::Bind(&ScrollbarAnimationController::StartAnimation, - weak_factory_.GetWeakPtr())); + base::BindOnce(&ScrollbarAnimationController::StartAnimation, + weak_factory_.GetWeakPtr())); client_->PostDelayedScrollbarAnimationTask( delayed_scrollbar_animation_.callback(), fade_delay_); } diff --git a/chromium/cc/input/scrollbar_animation_controller.h b/chromium/cc/input/scrollbar_animation_controller.h index 9473b416bf8..f7a26c523f4 100644 --- a/chromium/cc/input/scrollbar_animation_controller.h +++ b/chromium/cc/input/scrollbar_animation_controller.h @@ -18,7 +18,7 @@ namespace cc { class CC_EXPORT ScrollbarAnimationControllerClient { public: - virtual void PostDelayedScrollbarAnimationTask(const base::Closure& task, + virtual void PostDelayedScrollbarAnimationTask(base::OnceClosure task, base::TimeDelta delay) = 0; virtual void SetNeedsRedrawForScrollbarAnimation() = 0; virtual void SetNeedsAnimateForScrollbarAnimation() = 0; @@ -153,7 +153,7 @@ class CC_EXPORT ScrollbarAnimationController { bool currently_scrolling_; bool show_in_fast_scroll_; - base::CancelableClosure delayed_scrollbar_animation_; + base::CancelableOnceClosure delayed_scrollbar_animation_; float opacity_; diff --git a/chromium/cc/input/scrollbar_animation_controller_unittest.cc b/chromium/cc/input/scrollbar_animation_controller_unittest.cc index e9f336ff695..0836aeb1afa 100644 --- a/chromium/cc/input/scrollbar_animation_controller_unittest.cc +++ b/chromium/cc/input/scrollbar_animation_controller_unittest.cc @@ -37,9 +37,9 @@ class MockScrollbarAnimationControllerClient : host_impl_(host_impl) {} ~MockScrollbarAnimationControllerClient() override = default; - void PostDelayedScrollbarAnimationTask(const base::Closure& start_fade, + void PostDelayedScrollbarAnimationTask(base::OnceClosure start_fade, base::TimeDelta delay) override { - start_fade_ = start_fade; + start_fade_ = std::move(start_fade); delay_ = delay; } void SetNeedsRedrawForScrollbarAnimation() override {} @@ -49,11 +49,11 @@ class MockScrollbarAnimationControllerClient } MOCK_METHOD0(DidChangeScrollbarVisibility, void()); - base::Closure& start_fade() { return start_fade_; } + base::OnceClosure& start_fade() { return start_fade_; } base::TimeDelta& delay() { return delay_; } private: - base::Closure start_fade_; + base::OnceClosure start_fade_; base::TimeDelta delay_; LayerTreeHostImpl* host_impl_; }; @@ -108,12 +108,12 @@ class ScrollbarAnimationControllerAuraOverlayTest : public testing::Test { host_impl_.active_tree()->SetRootLayerForTesting(std::move(clip)); v_scrollbar_layer_->SetBounds(gfx::Size(kThumbThickness, kTrackLength)); - v_scrollbar_layer_->SetPosition(gfx::PointF(90, 0)); + v_scrollbar_layer_->test_properties()->position = gfx::PointF(90, 0); v_scrollbar_layer_->SetScrollElementId(scroll_layer_ptr->element_id()); v_scrollbar_layer_->test_properties()->opacity_can_animate = true; h_scrollbar_layer_->SetBounds(gfx::Size(kTrackLength, kThumbThickness)); - h_scrollbar_layer_->SetPosition(gfx::PointF(0, 90)); + h_scrollbar_layer_->test_properties()->position = gfx::PointF(0, 90); h_scrollbar_layer_->SetScrollElementId(scroll_layer_ptr->element_id()); h_scrollbar_layer_->test_properties()->opacity_can_animate = true; @@ -261,7 +261,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicAppearAndFadeOut) { // An fade out animation should have been enqueued. EXPECT_EQ(kFadeDelay, client_.delay()); EXPECT_FALSE(client_.start_fade().is_null()); - client_.start_fade().Run(); + std::move(client_.start_fade()).Run(); // Scrollbar should fade out over kFadeDuration. scrollbar_controller_->Animate(time); @@ -290,7 +290,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, // An fade out animation should have been enqueued. EXPECT_EQ(kFadeDelay, client_.delay()); EXPECT_FALSE(client_.start_fade().is_null()); - client_.start_fade().Run(); + std::move(client_.start_fade()).Run(); // Scrollbar should fade out over kFadeDuration. scrollbar_controller_->Animate(time); @@ -651,7 +651,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, // A fade out animation should have been enqueued. Start it. EXPECT_EQ(kFadeDelay, client_.delay()); EXPECT_FALSE(client_.start_fade().is_null()); - client_.start_fade().Run(); + std::move(client_.start_fade()).Run(); scrollbar_controller_->Animate(time); ExpectScrollbarsOpacity(1); @@ -691,7 +691,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, TestCantCaptureWhenFaded) { EXPECT_EQ(kFadeDelay, client_.delay()); EXPECT_FALSE(client_.start_fade().is_null()); EXPECT_FALSE(client_.start_fade().IsCancelled()); - client_.start_fade().Run(); + std::move(client_.start_fade()).Run(); scrollbar_controller_->Animate(time); ExpectScrollbarsOpacity(1); @@ -736,8 +736,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, TestCantCaptureWhenFaded) { EXPECT_EQ(kFadeDelay, client_.delay()); // Play the delay animation. - client_.start_fade().Run(); - EXPECT_TRUE(client_.start_fade().IsCancelled()); + std::move(client_.start_fade()).Run(); scrollbar_controller_->Animate(time); time += kFadeDuration; @@ -831,7 +830,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, FadeAnimated) { // An fade out animation should have been enqueued. EXPECT_EQ(kFadeDelay, client_.delay()); EXPECT_FALSE(client_.start_fade().is_null()); - client_.start_fade().Run(); + std::move(client_.start_fade()).Run(); // Test that at half the fade duration time, the opacity is at half. scrollbar_controller_->Animate(time); @@ -865,7 +864,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, NotifyChangedVisibility) { // to) notify during the animation that the scrollbars are still visible. EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(0); ASSERT_FALSE(client_.start_fade().is_null()); - client_.start_fade().Run(); + std::move(client_.start_fade()).Run(); scrollbar_controller_->Animate(time); time += kFadeDuration / 4; EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); @@ -1123,8 +1122,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicMouseHoverFadeIn) { EXPECT_EQ(kFadeDelay, client_.delay()); // Play the delay animation. - client_.start_fade().Run(); - EXPECT_TRUE(client_.start_fade().IsCancelled()); + std::move(client_.start_fade()).Run(); scrollbar_controller_->Animate(time); time += kFadeDuration / 2; @@ -1156,13 +1154,13 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, EXPECT_FALSE(client_.start_fade().IsCancelled()); EXPECT_EQ(kFadeDelay, client_.delay()); - base::Closure& fade = client_.start_fade(); + client_.start_fade().Reset(); // Move mouse still hover the fade in region of scrollbar should not // post a new fade in. scrollbar_controller_->DidMouseMove( NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 2, 0)); - EXPECT_TRUE(fade.Equals(client_.start_fade())); + EXPECT_TRUE(client_.start_fade().is_null()); } // Scrollbars should cancel delay fade in when mouse hover hidden scrollbar then @@ -1220,8 +1218,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, EXPECT_EQ(kFadeDelay, client_.delay()); // Play the delay animation. - client_.start_fade().Run(); - EXPECT_TRUE(client_.start_fade().IsCancelled()); + std::move(client_.start_fade()).Run(); scrollbar_controller_->Animate(time); time += kFadeDuration; @@ -1269,8 +1266,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, EXPECT_EQ(kFadeDelay, client_.delay()); // Play the delay animation. - client_.start_fade().Run(); - EXPECT_TRUE(client_.start_fade().IsCancelled()); + std::move(client_.start_fade()).Run(); scrollbar_controller_->Animate(time); time += kFadeDuration; @@ -1375,9 +1371,9 @@ class ScrollbarAnimationControllerAndroidTest did_request_redraw_(false), did_request_animate_(false) {} - void PostDelayedScrollbarAnimationTask(const base::Closure& start_fade, + void PostDelayedScrollbarAnimationTask(base::OnceClosure start_fade, base::TimeDelta delay) override { - start_fade_ = start_fade; + start_fade_ = std::move(start_fade); delay_ = delay; } void SetNeedsRedrawForScrollbarAnimation() override { @@ -1438,7 +1434,7 @@ class ScrollbarAnimationControllerAndroidTest std::unique_ptr<ScrollbarAnimationController> scrollbar_controller_; SolidColorScrollbarLayerImpl* scrollbar_layer_; - base::Closure start_fade_; + base::OnceClosure start_fade_; base::TimeDelta delay_; bool did_request_redraw_; bool did_request_animate_; @@ -1467,7 +1463,7 @@ TEST_F(ScrollbarAnimationControllerAndroidTest, EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); scrollbar_controller_->DidScrollEnd(); - EXPECT_TRUE(start_fade_.Equals(base::Closure())); + EXPECT_TRUE(start_fade_.is_null()); time += base::TimeDelta::FromSeconds(100); scrollbar_controller_->Animate(time); @@ -1490,7 +1486,7 @@ TEST_F(ScrollbarAnimationControllerAndroidTest, EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); // No fade out animation should have been enqueued. - EXPECT_TRUE(start_fade_.Equals(base::Closure())); + EXPECT_TRUE(start_fade_.is_null()); } TEST_F(ScrollbarAnimationControllerAndroidTest, HideOnResize) { @@ -1626,7 +1622,7 @@ TEST_F(ScrollbarAnimationControllerAndroidTest, AwakenByScrollingGesture) { EXPECT_FALSE(did_request_animate_); EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); - EXPECT_TRUE(start_fade_.Equals(base::Closure())); + EXPECT_TRUE(start_fade_.is_null()); time += base::TimeDelta::FromSeconds(100); @@ -1635,7 +1631,7 @@ TEST_F(ScrollbarAnimationControllerAndroidTest, AwakenByScrollingGesture) { EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); scrollbar_controller_->DidScrollEnd(); EXPECT_FALSE(did_request_animate_); - start_fade_.Run(); + std::move(start_fade_).Run(); EXPECT_TRUE(did_request_animate_); did_request_animate_ = false; @@ -1663,7 +1659,7 @@ TEST_F(ScrollbarAnimationControllerAndroidTest, AwakenByScrollingGesture) { scrollbar_controller_->DidScrollUpdate(); scrollbar_controller_->DidScrollEnd(); - start_fade_.Run(); + std::move(start_fade_).Run(); EXPECT_TRUE(did_request_animate_); did_request_animate_ = false; @@ -1697,7 +1693,7 @@ TEST_F(ScrollbarAnimationControllerAndroidTest, AwakenByProgrammaticScroll) { scrollbar_controller_->DidScrollUpdate(); EXPECT_FALSE(did_request_animate_); - start_fade_.Run(); + std::move(start_fade_).Run(); EXPECT_TRUE(did_request_animate_); did_request_animate_ = false; scrollbar_controller_->Animate(time); @@ -1713,7 +1709,7 @@ TEST_F(ScrollbarAnimationControllerAndroidTest, AwakenByProgrammaticScroll) { scrollbar_controller_->DidScrollUpdate(); EXPECT_FALSE(did_request_animate_); - start_fade_.Run(); + std::move(start_fade_).Run(); EXPECT_TRUE(did_request_animate_); did_request_animate_ = false; time += base::TimeDelta::FromSeconds(2); @@ -1736,7 +1732,7 @@ TEST_F(ScrollbarAnimationControllerAndroidTest, AwakenByProgrammaticScroll) { time += base::TimeDelta::FromSeconds(1); scrollbar_controller_->DidScrollUpdate(); - start_fade_.Run(); + std::move(start_fade_).Run(); time += base::TimeDelta::FromSeconds(1); scrollbar_controller_->Animate(time); EXPECT_TRUE(did_request_animate_); @@ -1766,7 +1762,7 @@ TEST_F(ScrollbarAnimationControllerAndroidTest, base::TimeTicks time; time += base::TimeDelta::FromSeconds(1); scrollbar_controller_->DidScrollUpdate(); - start_fade_.Run(); + std::move(start_fade_).Run(); EXPECT_TRUE(did_request_animate_); did_request_animate_ = false; scrollbar_controller_->Animate(time); @@ -1806,7 +1802,7 @@ TEST_F(ScrollbarAnimationControllerAndroidTest, time += base::TimeDelta::FromSeconds(1); scrollbar_controller_->DidScrollUpdate(); EXPECT_FALSE(did_request_animate_); - start_fade_.Run(); + std::move(start_fade_).Run(); EXPECT_TRUE(did_request_animate_); did_request_animate_ = false; scrollbar_controller_->Animate(time); diff --git a/chromium/cc/input/single_scrollbar_animation_controller_thinning_unittest.cc b/chromium/cc/input/single_scrollbar_animation_controller_thinning_unittest.cc index 08ba96d79b5..a08e6aa8838 100644 --- a/chromium/cc/input/single_scrollbar_animation_controller_thinning_unittest.cc +++ b/chromium/cc/input/single_scrollbar_animation_controller_thinning_unittest.cc @@ -42,12 +42,10 @@ class MockSingleScrollbarAnimationControllerClient } MOCK_METHOD2(PostDelayedScrollbarAnimationTask, - void(const base::Closure& start_fade, base::TimeDelta delay)); + void(base::OnceClosure start_fade, base::TimeDelta delay)); MOCK_METHOD0(SetNeedsRedrawForScrollbarAnimation, void()); MOCK_METHOD0(SetNeedsAnimateForScrollbarAnimation, void()); MOCK_METHOD0(DidChangeScrollbarVisibility, void()); - MOCK_METHOD0(start_fade, base::Closure()); - MOCK_METHOD0(delay, base::TimeDelta()); private: LayerTreeHostImpl* host_impl_; @@ -90,7 +88,7 @@ class SingleScrollbarAnimationControllerThinningTest : public testing::Test { host_impl_.active_tree()->SetRootLayerForTesting(std::move(clip)); scrollbar_layer_->SetBounds(gfx::Size(kThumbThickness, kTrackLength)); - scrollbar_layer_->SetPosition(gfx::PointF(90, 0)); + scrollbar_layer_->test_properties()->position = gfx::PointF(90, 0); scrollbar_layer_->SetScrollElementId(scroll_layer_ptr->element_id()); scrollbar_layer_->test_properties()->opacity_can_animate = true; clip_layer_->SetBounds(gfx::Size(100, 100)); diff --git a/chromium/cc/input/snap_selection_strategy.cc b/chromium/cc/input/snap_selection_strategy.cc index ce0f2655ecf..8803cce22f1 100644 --- a/chromium/cc/input/snap_selection_strategy.cc +++ b/chromium/cc/input/snap_selection_strategy.cc @@ -29,6 +29,10 @@ SnapSelectionStrategy::CreateForEndAndDirection( displacement); } +bool SnapSelectionStrategy::HasIntendedDirection() const { + return true; +} + bool EndPositionStrategy::ShouldSnapOnX() const { return scrolled_x_; } @@ -52,6 +56,10 @@ bool EndPositionStrategy::IsValidSnapPosition(SearchAxis axis, (scrolled_y_ && axis == SearchAxis::kY); } +bool EndPositionStrategy::HasIntendedDirection() const { + return false; +} + const base::Optional<SnapSearchResult>& EndPositionStrategy::PickBestResult( const base::Optional<SnapSearchResult>& closest, const base::Optional<SnapSearchResult>& covering) const { diff --git a/chromium/cc/input/snap_selection_strategy.h b/chromium/cc/input/snap_selection_strategy.h index cebc63e96b5..ef6b00baa7a 100644 --- a/chromium/cc/input/snap_selection_strategy.h +++ b/chromium/cc/input/snap_selection_strategy.h @@ -48,6 +48,8 @@ class CC_EXPORT SnapSelectionStrategy { // valid for the current axis. virtual bool IsValidSnapPosition(SearchAxis axis, float position) const = 0; + virtual bool HasIntendedDirection() const; + // Returns the best result according to snap selection strategy. This method // is called at the end of selection process to make the final decision. // @@ -91,6 +93,7 @@ class EndPositionStrategy : public SnapSelectionStrategy { gfx::ScrollOffset base_position() const override; bool IsValidSnapPosition(SearchAxis axis, float position) const override; + bool HasIntendedDirection() const override; const base::Optional<SnapSearchResult>& PickBestResult( const base::Optional<SnapSearchResult>& closest, |