Skip to content

Commit

Permalink
Correct method naming in ScrollbarAnimationController
Browse files Browse the repository at this point in the history
In this patch, we rename mouse_is_over_scrollbar, mouse_is_near_scrollbar and
mouse_is_near_any_scrollbar to CamelCase since they are not inline method in
header file any more.

BUG=
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel

Review-Url: https://codereview.chromium.org/2728673002
Cr-Commit-Position: refs/heads/master@{#454597}
  • Loading branch information
chaopeng authored and Commit bot committed Mar 3, 2017
1 parent 6c8bec1 commit b41df0b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 60 deletions.
14 changes: 7 additions & 7 deletions cc/input/scrollbar_animation_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void ScrollbarAnimationController::DidScrollUpdate(bool on_resize) {
if (!currently_scrolling_) {
// We don't fade out scrollbar if they need thinning animation and mouse is
// near.
if (!need_thinning_animation_ || !mouse_is_near_any_scrollbar())
if (!need_thinning_animation_ || !MouseIsNearAnyScrollbar())
PostDelayedFadeOut(on_resize);
} else {
scroll_gesture_has_scrolled_ = true;
Expand All @@ -210,7 +210,7 @@ void ScrollbarAnimationController::DidScrollEnd() {

// We don't fade out scrollbar if they need thinning animation and mouse is
// near.
if (need_thinning_animation_ && mouse_is_near_any_scrollbar())
if (need_thinning_animation_ && MouseIsNearAnyScrollbar())
return;

if (has_scrolled)
Expand All @@ -232,7 +232,7 @@ void ScrollbarAnimationController::DidMouseUp() {
vertical_controller_->DidMouseUp();
horizontal_controller_->DidMouseUp();

if (!mouse_is_near_any_scrollbar())
if (!MouseIsNearAnyScrollbar())
PostDelayedFadeOut(false);
}

Expand Down Expand Up @@ -274,7 +274,7 @@ void ScrollbarAnimationController::DidMouseMoveNear(
}
}
} else {
if (mouse_is_near_any_scrollbar()) {
if (MouseIsNearAnyScrollbar()) {
Show();
StopAnimation();
} else if (!is_animating_) {
Expand Down Expand Up @@ -304,19 +304,19 @@ bool ScrollbarAnimationController::CalcNeedTriggerScrollbarShow(
return false;
}

bool ScrollbarAnimationController::mouse_is_over_scrollbar(
bool ScrollbarAnimationController::MouseIsOverScrollbar(
ScrollbarOrientation orientation) const {
DCHECK(need_thinning_animation_);
return GetScrollbarAnimationController(orientation).mouse_is_over_scrollbar();
}

bool ScrollbarAnimationController::mouse_is_near_scrollbar(
bool ScrollbarAnimationController::MouseIsNearScrollbar(
ScrollbarOrientation orientation) const {
DCHECK(need_thinning_animation_);
return GetScrollbarAnimationController(orientation).mouse_is_near_scrollbar();
}

bool ScrollbarAnimationController::mouse_is_near_any_scrollbar() const {
bool ScrollbarAnimationController::MouseIsNearAnyScrollbar() const {
DCHECK(need_thinning_animation_);
return vertical_controller_->mouse_is_near_scrollbar() ||
horizontal_controller_->mouse_is_near_scrollbar();
Expand Down
6 changes: 3 additions & 3 deletions cc/input/scrollbar_animation_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ class CC_EXPORT ScrollbarAnimationController {
void DidMouseLeave();
void DidMouseMoveNear(ScrollbarOrientation, float);

bool mouse_is_over_scrollbar(ScrollbarOrientation orientation) const;
bool mouse_is_near_scrollbar(ScrollbarOrientation orientation) const;
bool mouse_is_near_any_scrollbar() const;
bool MouseIsOverScrollbar(ScrollbarOrientation orientation) const;
bool MouseIsNearScrollbar(ScrollbarOrientation orientation) const;
bool MouseIsNearAnyScrollbar() const;

static constexpr float kMouseMoveDistanceToTriggerShow = 30.0f;

Expand Down
83 changes: 33 additions & 50 deletions cc/trees/layer_tree_host_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3290,31 +3290,24 @@ void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale(

host_impl_->MouseMoveAt(
gfx::Point(15 + kMouseDistanceToTriggerAnimation * 2, 1));
EXPECT_FALSE(
scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL));
EXPECT_FALSE(scrollbar_animation_controller->MouseIsNearScrollbar(VERTICAL));

host_impl_->MouseMoveAt(
gfx::Point(15 + kMouseDistanceToTriggerAnimation - 1, 50));
EXPECT_TRUE(
scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL));
EXPECT_TRUE(scrollbar_animation_controller->MouseIsNearScrollbar(VERTICAL));

host_impl_->MouseMoveAt(
gfx::Point(15 + kMouseDistanceToTriggerAnimation, 100));
EXPECT_FALSE(
scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL));
EXPECT_FALSE(scrollbar_animation_controller->MouseIsNearScrollbar(VERTICAL));

did_request_redraw_ = false;
EXPECT_FALSE(
scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL));
EXPECT_FALSE(scrollbar_animation_controller->MouseIsOverScrollbar(VERTICAL));
host_impl_->MouseMoveAt(gfx::Point(10, 100));
EXPECT_TRUE(
scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL));
EXPECT_TRUE(scrollbar_animation_controller->MouseIsOverScrollbar(VERTICAL));
host_impl_->MouseMoveAt(gfx::Point(10, 120));
EXPECT_TRUE(
scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL));
EXPECT_TRUE(scrollbar_animation_controller->MouseIsOverScrollbar(VERTICAL));
host_impl_->MouseMoveAt(gfx::Point(150, 120));
EXPECT_FALSE(
scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL));
EXPECT_FALSE(scrollbar_animation_controller->MouseIsOverScrollbar(VERTICAL));
}

TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf1) {
Expand Down Expand Up @@ -11770,32 +11763,28 @@ void LayerTreeHostImplTest::SetupMouseMoveAtTestScrollbarStates(
host_impl_->MouseMoveAt(
gfx::Point(15 + kMouseDistanceToTriggerAnimation, 150));
EXPECT_FALSE(
scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
EXPECT_FALSE(
scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL));
host_impl_->MouseMoveAt(
gfx::Point(14 + kMouseDistanceToTriggerAnimation, 150));
EXPECT_TRUE(
scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
EXPECT_FALSE(
scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL));
host_impl_->MouseMoveAt(gfx::Point(10, 150));
EXPECT_TRUE(
scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
EXPECT_TRUE(
scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL));
host_impl_->MouseMoveAt(
gfx::Point(14 + kMouseDistanceToTriggerAnimation, 150));
EXPECT_TRUE(
scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
EXPECT_FALSE(
scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL));
host_impl_->MouseMoveAt(
gfx::Point(15 + kMouseDistanceToTriggerAnimation, 150));
EXPECT_FALSE(
scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
EXPECT_FALSE(
scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL));

// scrollbar_2 on child.
std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_2 =
Expand Down Expand Up @@ -11835,42 +11824,36 @@ void LayerTreeHostImplTest::SetupMouseMoveAtTestScrollbarStates(
// scrollbar_1, goes over scrollbar_1.
host_impl_->MouseMoveAt(gfx::Point(60, 150));
EXPECT_FALSE(
scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
EXPECT_FALSE(
scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
EXPECT_TRUE(
scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL));
EXPECT_TRUE(
scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL));
scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL));
EXPECT_TRUE(scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL));
EXPECT_TRUE(scrollbar_2_animation_controller->MouseIsOverScrollbar(VERTICAL));
host_impl_->MouseMoveAt(
gfx::Point(64 + kMouseDistanceToTriggerAnimation, 150));
EXPECT_FALSE(
scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
EXPECT_FALSE(
scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
EXPECT_TRUE(
scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL));
scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL));
EXPECT_TRUE(scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL));
EXPECT_FALSE(
scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL));
scrollbar_2_animation_controller->MouseIsOverScrollbar(VERTICAL));
host_impl_->MouseMoveAt(
gfx::Point(14 + kMouseDistanceToTriggerAnimation, 150));
EXPECT_TRUE(
scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
EXPECT_FALSE(
scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL));
EXPECT_FALSE(
scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL));
scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL));
EXPECT_FALSE(
scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL));
scrollbar_2_animation_controller->MouseIsOverScrollbar(VERTICAL));
host_impl_->MouseMoveAt(gfx::Point(10, 150));
EXPECT_TRUE(
scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
EXPECT_TRUE(
scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL));
EXPECT_FALSE(
scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL));
scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL));
EXPECT_FALSE(
scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL));
scrollbar_2_animation_controller->MouseIsOverScrollbar(VERTICAL));

// Capture scrollbar_1, then move mouse to scrollbar_2's layer, should post an
// event to fade out scrollbar_1.
Expand Down

0 comments on commit b41df0b

Please sign in to comment.