Commit 65019782 authored by chaopeng's avatar chaopeng Committed by Commit Bot

Mouse cursor should be pointer when hover scrollbars.

In this patch, we move the hit test result scrollbar check for mouse
cursor from SelectAutoCursor to SelectCursor to ensure it does not
override by the scrollbar's owner element.

Bug: 290466
Change-Id: I72f721deadde3da9329c43f9e216b2ac3db08e7e
Reviewed-on: https://chromium-review.googlesource.com/598887
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491545}
parent 513ac8fd
......@@ -11127,6 +11127,43 @@ TEST_P(ParameterizedWebFrameTest, MouseOverDifferntNodeClearsTooltip) {
document->GetFrame()->GetChromeClient().LastSetTooltipNodeForTesting());
}
// Ensure mouse curosr should be pointer when hover scrollbar.
TEST_P(ParameterizedWebFrameTest, MouseOverScrollbarInCustomCursorElement) {
RegisterMockedHttpURLLoad("scrollbar-in-custom-cursor-element.html");
FrameTestHelpers::WebViewHelper web_view_helper;
WebViewBase* web_view = web_view_helper.InitializeAndLoad(
base_url_ + "scrollbar-in-custom-cursor-element.html");
web_view_helper.Resize(WebSize(250, 250));
web_view->UpdateAllLifecyclePhases();
Document* document =
ToLocalFrame(web_view->GetPage()->MainFrame())->GetDocument();
Element* div = document->getElementById("d1");
// Ensure hittest has DIV and scrollbar.
HitTestResult hit_test_result =
web_view->CoreHitTestResultAt(WebPoint(195, 5));
EXPECT_EQ(hit_test_result.InnerElement(), div);
EXPECT_TRUE(hit_test_result.GetScrollbar());
WebMouseEvent mouse_over_scrollbar(
WebInputEvent::kMouseMove, WebFloatPoint(195, 5), WebFloatPoint(195, 5),
WebPointerProperties::Button::kNoButton, 0, WebInputEvent::kNoModifiers,
TimeTicks::Now().InSeconds());
mouse_over_scrollbar.SetFrameScale(1);
document->GetFrame()->GetEventHandler().HandleMouseMoveEvent(
mouse_over_scrollbar, Vector<WebMouseEvent>());
EXPECT_EQ(Cursor::Type::kPointer, document->GetFrame()
->GetChromeClient()
.LastSetCursorForTesting()
.GetType());
}
// Makes sure that mouse hover over an overlay scrollbar doesn't activate
// elements below(except the Element that owns the scrollbar) unless the
// scrollbar is faded out.
......
......@@ -414,6 +414,9 @@ OptionalCursor EventHandler::SelectCursor(const HitTestResult& result) {
if (scroll_manager_->MiddleClickAutoscrollInProgress())
return kNoCursorChange;
if (result.GetScrollbar())
return PointerCursor();
Node* node = result.InnerPossiblyPseudoNode();
if (!node)
return SelectAutoCursor(result, node, IBeamCursor());
......@@ -550,9 +553,6 @@ OptionalCursor EventHandler::SelectCursor(const HitTestResult& result) {
OptionalCursor EventHandler::SelectAutoCursor(const HitTestResult& result,
Node* node,
const Cursor& i_beam) {
if (result.GetScrollbar())
return PointerCursor();
const bool is_over_link =
!GetSelectionController().MouseDownMayStartSelect() &&
result.IsOverLink();
......
<!DOCTYPE html>
<style>
body {
margin: 0;
}
#d1 {
width: 200px;
height: 200px;
overflow: auto;
cursor: move;
}
#d2 {
height: 400px;
}
</style>
<div id='d1'>
<div id='d2'></div>
</div>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment