 Chromium Code Reviews
 Chromium Code Reviews Issue 2931433002:
  Disable hover state change for touch event on page with viewport meta and mobile.  (Closed)
    
  
    Issue 2931433002:
  Disable hover state change for touch event on page with viewport meta and mobile.  (Closed) 
  | OLD | NEW | 
|---|---|
| 1 /* | 1 /* | 
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google 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 are | 5 * modification, are permitted provided that the following conditions are | 
| 6 * met: | 6 * met: | 
| 7 * | 7 * | 
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright | 
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. | 
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above | 
| (...skipping 11636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11647 EXPECT_EQ(scrollbar->HoveredPart(), ScrollbarPart::kNoPart); | 11647 EXPECT_EQ(scrollbar->HoveredPart(), ScrollbarPart::kNoPart); | 
| 11648 | 11648 | 
| 11649 // Mouse moved over the scrollbar. | 11649 // Mouse moved over the scrollbar. | 
| 11650 WebMouseEvent mouse_move_over_scrollbar( | 11650 WebMouseEvent mouse_move_over_scrollbar( | 
| 11651 WebInputEvent::kMouseMove, WebFloatPoint(175, 1), WebFloatPoint(175, 1), | 11651 WebInputEvent::kMouseMove, WebFloatPoint(175, 1), WebFloatPoint(175, 1), | 
| 11652 WebPointerProperties::Button::kNoButton, 0, WebInputEvent::kNoModifiers, | 11652 WebPointerProperties::Button::kNoButton, 0, WebInputEvent::kNoModifiers, | 
| 11653 TimeTicks::Now().InSeconds()); | 11653 TimeTicks::Now().InSeconds()); | 
| 11654 mouse_move_over_scrollbar.SetFrameScale(1); | 11654 mouse_move_over_scrollbar.SetFrameScale(1); | 
| 11655 document->GetFrame()->GetEventHandler().HandleMouseMoveEvent( | 11655 document->GetFrame()->GetEventHandler().HandleMouseMoveEvent( | 
| 11656 mouse_move_over_scrollbar, Vector<WebMouseEvent>()); | 11656 mouse_move_over_scrollbar, Vector<WebMouseEvent>()); | 
| 11657 HitTestResult hit_test_result = | |
| 11658 web_view->CoreHitTestResultAt(WebPoint(175, 1)); | |
| 
bokan
2017/06/09 16:21:09
Why this change? What was this doing before?
 
chaopeng
2017/06/09 19:19:31
This hit_test_result is unused var now. hit_test_r
 | |
| 11659 EXPECT_EQ(scrollbar->PressedPart(), ScrollbarPart::kNoPart); | 11657 EXPECT_EQ(scrollbar->PressedPart(), ScrollbarPart::kNoPart); | 
| 11660 EXPECT_EQ(scrollbar->HoveredPart(), ScrollbarPart::kThumbPart); | 11658 EXPECT_EQ(scrollbar->HoveredPart(), ScrollbarPart::kThumbPart); | 
| 11661 | 11659 | 
| 11662 // Mouse pressed. | 11660 // Mouse pressed. | 
| 11663 WebMouseEvent mouse_press_event( | 11661 WebMouseEvent mouse_press_event( | 
| 11664 WebInputEvent::kMouseDown, WebFloatPoint(175, 1), WebFloatPoint(175, 1), | 11662 WebInputEvent::kMouseDown, WebFloatPoint(175, 1), WebFloatPoint(175, 1), | 
| 11665 WebPointerProperties::Button::kLeft, 0, | 11663 WebPointerProperties::Button::kLeft, 0, | 
| 11666 WebInputEvent::Modifiers::kLeftButtonDown, TimeTicks::Now().InSeconds()); | 11664 WebInputEvent::Modifiers::kLeftButtonDown, TimeTicks::Now().InSeconds()); | 
| 11667 mouse_press_event.SetFrameScale(1); | 11665 mouse_press_event.SetFrameScale(1); | 
| 11668 document->GetFrame()->GetEventHandler().HandleMousePressEvent( | 11666 document->GetFrame()->GetEventHandler().HandleMousePressEvent( | 
| (...skipping 17 matching lines...) Expand all Loading... | |
| 11686 WebInputEvent::kMouseUp, WebFloatPoint(1, 1), WebFloatPoint(1, 1), | 11684 WebInputEvent::kMouseUp, WebFloatPoint(1, 1), WebFloatPoint(1, 1), | 
| 11687 WebPointerProperties::Button::kLeft, 0, | 11685 WebPointerProperties::Button::kLeft, 0, | 
| 11688 WebInputEvent::Modifiers::kLeftButtonDown, TimeTicks::Now().InSeconds()); | 11686 WebInputEvent::Modifiers::kLeftButtonDown, TimeTicks::Now().InSeconds()); | 
| 11689 mouse_release_event.SetFrameScale(1); | 11687 mouse_release_event.SetFrameScale(1); | 
| 11690 document->GetFrame()->GetEventHandler().HandleMouseReleaseEvent( | 11688 document->GetFrame()->GetEventHandler().HandleMouseReleaseEvent( | 
| 11691 mouse_release_event); | 11689 mouse_release_event); | 
| 11692 EXPECT_EQ(scrollbar->PressedPart(), ScrollbarPart::kNoPart); | 11690 EXPECT_EQ(scrollbar->PressedPart(), ScrollbarPart::kNoPart); | 
| 11693 EXPECT_EQ(scrollbar->HoveredPart(), ScrollbarPart::kNoPart); | 11691 EXPECT_EQ(scrollbar->HoveredPart(), ScrollbarPart::kNoPart); | 
| 11694 } | 11692 } | 
| 11695 | 11693 | 
| 11694 class TapChangeHoverStateTest : public WebFrameTest { | |
| 11695 public: | |
| 11696 void RunTest(bool on_mobile, bool should_change_hover_state) { | |
| 11697 std::string test_page = "viewport-2-div.html"; | |
| 11698 | |
| 11699 FakeCompositingWebViewClient client; | |
| 11700 RegisterMockedHttpURLLoad(test_page); | |
| 11701 FrameTestHelpers::WebViewHelper web_view_helper; | |
| 11702 WebViewBase* web_view; | |
| 11703 if (on_mobile) { | |
| 
bokan
2017/06/09 16:21:09
The difference isn't whether we're on mobile or no
 | |
| 11704 web_view = web_view_helper.InitializeAndLoad(base_url_ + test_page, false, | |
| 11705 nullptr, &client, nullptr, | |
| 11706 ConfigureAndroid); | |
| 11707 } else { | |
| 11708 web_view = web_view_helper.InitializeAndLoad(base_url_ + test_page); | |
| 11709 } | |
| 11710 web_view_helper.Resize(WebSize(250, 250)); | |
| 11711 | |
| 11712 Document* document = | |
| 11713 ToLocalFrame(web_view->GetPage()->MainFrame())->GetDocument(); | |
| 11714 | |
| 11715 Element* div1 = document->getElementById("div1"); | |
| 11716 Element* div2 = document->getElementById("div2"); | |
| 11717 | |
| 11718 // Move mouse over div1 should hover div1. | |
| 11719 WebMouseEvent mouse_move_over_div1( | |
| 11720 WebInputEvent::kMouseMove, WebFloatPoint(10, 10), WebFloatPoint(10, 10), | |
| 11721 WebPointerProperties::Button::kNoButton, 0, WebInputEvent::kNoModifiers, | |
| 11722 TimeTicks::Now().InSeconds()); | |
| 11723 mouse_move_over_div1.SetFrameScale(1); | |
| 11724 document->GetFrame()->GetEventHandler().HandleMouseMoveEvent( | |
| 11725 mouse_move_over_div1, Vector<WebMouseEvent>()); | |
| 11726 | |
| 11727 DCHECK(document->HoverElement() == div1); | |
| 11728 | |
| 11729 // Tap on div2. | |
| 11730 WebGestureEvent tap_on_div2(WebInputEvent::kGestureTap, | |
| 11731 WebInputEvent::kNoModifiers, | |
| 11732 WebInputEvent::kTimeStampForTesting); | |
| 11733 tap_on_div2.SetFrameScale(1); | |
| 11734 tap_on_div2.x = tap_on_div2.global_x = 10; | |
| 11735 tap_on_div2.y = tap_on_div2.global_y = 110; | |
| 11736 tap_on_div2.source_device = kWebGestureDeviceTouchscreen; | |
| 11737 web_view_helper.WebView() | |
| 11738 ->MainFrameImpl() | |
| 11739 ->GetFrame() | |
| 11740 ->GetEventHandler() | |
| 11741 .HandleGestureEvent(tap_on_div2); | |
| 11742 | |
| 11743 Element* expected_hover_element = should_change_hover_state ? div2 : div1; | |
| 11744 EXPECT_EQ(expected_hover_element, document->HoverElement()); | |
| 11745 } | |
| 11746 }; | |
| 11747 | |
| 11748 TEST_F(TapChangeHoverStateTest, TapNotChangeHoverStateOnMobile) { | |
| 11749 RunTest(true, false); | |
| 11750 } | |
| 11751 | |
| 11752 TEST_F(TapChangeHoverStateTest, TapChangeHoverStateOnDesktop) { | |
| 11753 RunTest(false, true); | |
| 11754 } | |
| 11755 | |
| 11696 TEST_F(WebFrameTest, | 11756 TEST_F(WebFrameTest, | 
| 11697 CustomScrollbarInOverlayScrollbarThemeWillNotCauseDCHECKFails) { | 11757 CustomScrollbarInOverlayScrollbarThemeWillNotCauseDCHECKFails) { | 
| 11698 RegisterMockedHttpURLLoad( | 11758 RegisterMockedHttpURLLoad( | 
| 11699 "custom-scrollbar-dcheck-failed-when-paint-scroll-corner.html"); | 11759 "custom-scrollbar-dcheck-failed-when-paint-scroll-corner.html"); | 
| 11700 FrameTestHelpers::WebViewHelper web_view_helper; | 11760 FrameTestHelpers::WebViewHelper web_view_helper; | 
| 11701 WebViewBase* web_view = web_view_helper.InitializeAndLoad( | 11761 WebViewBase* web_view = web_view_helper.InitializeAndLoad( | 
| 11702 base_url_ + | 11762 base_url_ + | 
| 11703 "custom-scrollbar-dcheck-failed-when-paint-scroll-corner.html"); | 11763 "custom-scrollbar-dcheck-failed-when-paint-scroll-corner.html"); | 
| 11704 | 11764 | 
| 11705 web_view_helper.Resize(WebSize(200, 200)); | 11765 web_view_helper.Resize(WebSize(200, 200)); | 
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12217 if (obj->IsText()) { | 12277 if (obj->IsText()) { | 
| 12218 LayoutText* layout_text = ToLayoutText(obj); | 12278 LayoutText* layout_text = ToLayoutText(obj); | 
| 12219 text = layout_text->GetText(); | 12279 text = layout_text->GetText(); | 
| 12220 break; | 12280 break; | 
| 12221 } | 12281 } | 
| 12222 } | 12282 } | 
| 12223 EXPECT_EQ("foo alt", text.Utf8()); | 12283 EXPECT_EQ("foo alt", text.Utf8()); | 
| 12224 } | 12284 } | 
| 12225 | 12285 | 
| 12226 } // namespace blink | 12286 } // namespace blink | 
| OLD | NEW |