 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 11638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11649 EXPECT_EQ(scrollbar->HoveredPart(), ScrollbarPart::kNoPart); | 11649 EXPECT_EQ(scrollbar->HoveredPart(), ScrollbarPart::kNoPart); | 
| 11650 | 11650 | 
| 11651 // Mouse moved over the scrollbar. | 11651 // Mouse moved over the scrollbar. | 
| 11652 WebMouseEvent mouse_move_over_scrollbar( | 11652 WebMouseEvent mouse_move_over_scrollbar( | 
| 11653 WebInputEvent::kMouseMove, WebFloatPoint(175, 1), WebFloatPoint(175, 1), | 11653 WebInputEvent::kMouseMove, WebFloatPoint(175, 1), WebFloatPoint(175, 1), | 
| 11654 WebPointerProperties::Button::kNoButton, 0, WebInputEvent::kNoModifiers, | 11654 WebPointerProperties::Button::kNoButton, 0, WebInputEvent::kNoModifiers, | 
| 11655 TimeTicks::Now().InSeconds()); | 11655 TimeTicks::Now().InSeconds()); | 
| 11656 mouse_move_over_scrollbar.SetFrameScale(1); | 11656 mouse_move_over_scrollbar.SetFrameScale(1); | 
| 11657 document->GetFrame()->GetEventHandler().HandleMouseMoveEvent( | 11657 document->GetFrame()->GetEventHandler().HandleMouseMoveEvent( | 
| 11658 mouse_move_over_scrollbar, Vector<WebMouseEvent>()); | 11658 mouse_move_over_scrollbar, Vector<WebMouseEvent>()); | 
| 11659 HitTestResult hit_test_result = | |
| 11660 web_view->CoreHitTestResultAt(WebPoint(175, 1)); | |
| 11661 EXPECT_EQ(scrollbar->PressedPart(), ScrollbarPart::kNoPart); | 11659 EXPECT_EQ(scrollbar->PressedPart(), ScrollbarPart::kNoPart); | 
| 11662 EXPECT_EQ(scrollbar->HoveredPart(), ScrollbarPart::kThumbPart); | 11660 EXPECT_EQ(scrollbar->HoveredPart(), ScrollbarPart::kThumbPart); | 
| 11663 | 11661 | 
| 11664 // Mouse pressed. | 11662 // Mouse pressed. | 
| 11665 WebMouseEvent mouse_press_event( | 11663 WebMouseEvent mouse_press_event( | 
| 11666 WebInputEvent::kMouseDown, WebFloatPoint(175, 1), WebFloatPoint(175, 1), | 11664 WebInputEvent::kMouseDown, WebFloatPoint(175, 1), WebFloatPoint(175, 1), | 
| 11667 WebPointerProperties::Button::kLeft, 0, | 11665 WebPointerProperties::Button::kLeft, 0, | 
| 11668 WebInputEvent::Modifiers::kLeftButtonDown, TimeTicks::Now().InSeconds()); | 11666 WebInputEvent::Modifiers::kLeftButtonDown, TimeTicks::Now().InSeconds()); | 
| 11669 mouse_press_event.SetFrameScale(1); | 11667 mouse_press_event.SetFrameScale(1); | 
| 11670 document->GetFrame()->GetEventHandler().HandleMousePressEvent( | 11668 document->GetFrame()->GetEventHandler().HandleMousePressEvent( | 
| (...skipping 17 matching lines...) Expand all Loading... | |
| 11688 WebInputEvent::kMouseUp, WebFloatPoint(1, 1), WebFloatPoint(1, 1), | 11686 WebInputEvent::kMouseUp, WebFloatPoint(1, 1), WebFloatPoint(1, 1), | 
| 11689 WebPointerProperties::Button::kLeft, 0, | 11687 WebPointerProperties::Button::kLeft, 0, | 
| 11690 WebInputEvent::Modifiers::kLeftButtonDown, TimeTicks::Now().InSeconds()); | 11688 WebInputEvent::Modifiers::kLeftButtonDown, TimeTicks::Now().InSeconds()); | 
| 11691 mouse_release_event.SetFrameScale(1); | 11689 mouse_release_event.SetFrameScale(1); | 
| 11692 document->GetFrame()->GetEventHandler().HandleMouseReleaseEvent( | 11690 document->GetFrame()->GetEventHandler().HandleMouseReleaseEvent( | 
| 11693 mouse_release_event); | 11691 mouse_release_event); | 
| 11694 EXPECT_EQ(scrollbar->PressedPart(), ScrollbarPart::kNoPart); | 11692 EXPECT_EQ(scrollbar->PressedPart(), ScrollbarPart::kNoPart); | 
| 11695 EXPECT_EQ(scrollbar->HoveredPart(), ScrollbarPart::kNoPart); | 11693 EXPECT_EQ(scrollbar->HoveredPart(), ScrollbarPart::kNoPart); | 
| 11696 } | 11694 } | 
| 11697 | 11695 | 
| 11696 class TapChangeHoverStateTest : public WebFrameTest { | |
| 11697 public: | |
| 11698 void RunTest(bool viewport_enabled, | |
| 11699 bool viewport_meta, | |
| 11700 bool should_change_hover_state) { | |
| 11701 std::string test_page = | |
| 11702 viewport_meta ? "viewport-2-div.html" : "noviewport-2-div.html"; | |
| 11703 | |
| 11704 FakeCompositingWebViewClient client; | |
| 11705 RegisterMockedHttpURLLoad(test_page); | |
| 11706 FrameTestHelpers::WebViewHelper web_view_helper; | |
| 11707 WebViewBase* web_view; | |
| 11708 if (viewport_enabled) { | |
| 11709 web_view = web_view_helper.InitializeAndLoad(base_url_ + test_page, false, | |
| 11710 nullptr, &client, nullptr, | |
| 11711 ConfigureAndroid); | |
| 11712 ApplyViewportStyleOverride(&web_view_helper); | |
| 
bokan
2017/06/09 19:27:55
Lets avoid this since it uses DevTools emulation s
 | |
| 11713 } else { | |
| 11714 web_view = web_view_helper.InitializeAndLoad(base_url_ + test_page); | |
| 11715 } | |
| 11716 web_view_helper.Resize(WebSize(250, 250)); | |
| 11717 | |
| 11718 Document* document = | |
| 11719 ToLocalFrame(web_view->GetPage()->MainFrame())->GetDocument(); | |
| 11720 | |
| 11721 Element* div1 = document->getElementById("div1"); | |
| 11722 Element* div2 = document->getElementById("div2"); | |
| 11723 | |
| 11724 // Move mouse over div1 should hover div1. | |
| 11725 WebMouseEvent mouse_move_over_div1( | |
| 11726 WebInputEvent::kMouseMove, WebFloatPoint(10, 10), WebFloatPoint(10, 10), | |
| 11727 WebPointerProperties::Button::kNoButton, 0, WebInputEvent::kNoModifiers, | |
| 11728 TimeTicks::Now().InSeconds()); | |
| 11729 mouse_move_over_div1.SetFrameScale(1); | |
| 11730 document->GetFrame()->GetEventHandler().HandleMouseMoveEvent( | |
| 11731 mouse_move_over_div1, Vector<WebMouseEvent>()); | |
| 11732 | |
| 11733 DCHECK(document->HoverElement() == div1); | |
| 11734 | |
| 11735 // Tap on div2. | |
| 11736 WebGestureEvent tap_on_div2(WebInputEvent::kGestureTap, | |
| 11737 WebInputEvent::kNoModifiers, | |
| 11738 WebInputEvent::kTimeStampForTesting); | |
| 11739 tap_on_div2.SetFrameScale(1); | |
| 11740 tap_on_div2.x = tap_on_div2.global_x = 10; | |
| 11741 tap_on_div2.y = tap_on_div2.global_y = 110; | |
| 11742 tap_on_div2.source_device = kWebGestureDeviceTouchscreen; | |
| 11743 web_view_helper.WebView() | |
| 11744 ->MainFrameImpl() | |
| 11745 ->GetFrame() | |
| 11746 ->GetEventHandler() | |
| 11747 .HandleGestureEvent(tap_on_div2); | |
| 11748 | |
| 11749 Element* expected_hover_element = should_change_hover_state ? div2 : div1; | |
| 11750 EXPECT_EQ(expected_hover_element, document->HoverElement()); | |
| 11751 } | |
| 11752 }; | |
| 11753 | |
| 11754 TEST_F(TapChangeHoverStateTest, TapNotChangeHoverStateOnViewportMetaAndMobile) { | |
| 11755 RunTest(true, true, false); | |
| 11756 } | |
| 11757 | |
| 11758 TEST_F(TapChangeHoverStateTest, TapChangeHoverStateOnNoViewportMetaAndMobile) { | |
| 11759 RunTest(true, false, true); | |
| 11760 } | |
| 11761 | |
| 11762 TEST_F(TapChangeHoverStateTest, TapChangeHoverStateOnViewportMetaAndDesktop) { | |
| 11763 RunTest(false, true, true); | |
| 11764 } | |
| 11765 | |
| 11698 TEST_F(WebFrameTest, | 11766 TEST_F(WebFrameTest, | 
| 11699 CustomScrollbarInOverlayScrollbarThemeWillNotCauseDCHECKFails) { | 11767 CustomScrollbarInOverlayScrollbarThemeWillNotCauseDCHECKFails) { | 
| 11700 RegisterMockedHttpURLLoad( | 11768 RegisterMockedHttpURLLoad( | 
| 11701 "custom-scrollbar-dcheck-failed-when-paint-scroll-corner.html"); | 11769 "custom-scrollbar-dcheck-failed-when-paint-scroll-corner.html"); | 
| 11702 FrameTestHelpers::WebViewHelper web_view_helper; | 11770 FrameTestHelpers::WebViewHelper web_view_helper; | 
| 11703 WebViewBase* web_view = web_view_helper.InitializeAndLoad( | 11771 WebViewBase* web_view = web_view_helper.InitializeAndLoad( | 
| 11704 base_url_ + | 11772 base_url_ + | 
| 11705 "custom-scrollbar-dcheck-failed-when-paint-scroll-corner.html"); | 11773 "custom-scrollbar-dcheck-failed-when-paint-scroll-corner.html"); | 
| 11706 | 11774 | 
| 11707 web_view_helper.Resize(WebSize(200, 200)); | 11775 web_view_helper.Resize(WebSize(200, 200)); | 
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12239 if (obj->IsText()) { | 12307 if (obj->IsText()) { | 
| 12240 LayoutText* layout_text = ToLayoutText(obj); | 12308 LayoutText* layout_text = ToLayoutText(obj); | 
| 12241 text = layout_text->GetText(); | 12309 text = layout_text->GetText(); | 
| 12242 break; | 12310 break; | 
| 12243 } | 12311 } | 
| 12244 } | 12312 } | 
| 12245 EXPECT_EQ("foo alt", text.Utf8()); | 12313 EXPECT_EQ("foo alt", text.Utf8()); | 
| 12246 } | 12314 } | 
| 12247 | 12315 | 
| 12248 } // namespace blink | 12316 } // namespace blink | 
| OLD | NEW |