| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/input/EventHandler.h" | 5 #include "core/input/EventHandler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/dom/Range.h" | 9 #include "core/dom/Range.h" |
| 10 #include "core/editing/Editor.h" | 10 #include "core/editing/Editor.h" |
| 11 #include "core/editing/FrameSelection.h" | 11 #include "core/editing/FrameSelection.h" |
| 12 #include "core/editing/SelectionController.h" |
| 12 #include "core/frame/FrameView.h" | 13 #include "core/frame/FrameView.h" |
| 13 #include "core/frame/LocalFrame.h" | 14 #include "core/frame/LocalFrame.h" |
| 14 #include "core/frame/Settings.h" | 15 #include "core/frame/Settings.h" |
| 15 #include "core/loader/EmptyClients.h" | 16 #include "core/loader/EmptyClients.h" |
| 16 #include "core/page/AutoscrollController.h" | 17 #include "core/page/AutoscrollController.h" |
| 17 #include "core/page/Page.h" | 18 #include "core/page/Page.h" |
| 18 #include "core/testing/DummyPageHolder.h" | 19 #include "core/testing/DummyPageHolder.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 21 |
| 21 namespace blink { | 22 namespace blink { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 111 |
| 111 WebMouseEvent mouse_down_event(WebInputEvent::kMouseDown, WebFloatPoint(0, 0), | 112 WebMouseEvent mouse_down_event(WebInputEvent::kMouseDown, WebFloatPoint(0, 0), |
| 112 WebFloatPoint(100, 200), | 113 WebFloatPoint(100, 200), |
| 113 WebPointerProperties::Button::kLeft, 1, | 114 WebPointerProperties::Button::kLeft, 1, |
| 114 WebInputEvent::Modifiers::kLeftButtonDown, | 115 WebInputEvent::Modifiers::kLeftButtonDown, |
| 115 WebInputEvent::kTimeStampForTesting); | 116 WebInputEvent::kTimeStampForTesting); |
| 116 mouse_down_event.SetFrameScale(1); | 117 mouse_down_event.SetFrameScale(1); |
| 117 GetDocument().GetFrame()->GetEventHandler().HandleMousePressEvent( | 118 GetDocument().GetFrame()->GetEventHandler().HandleMousePressEvent( |
| 118 mouse_down_event); | 119 mouse_down_event); |
| 119 | 120 |
| 121 ASSERT_TRUE(GetDocument() |
| 122 .GetFrame() |
| 123 ->GetEventHandler() |
| 124 .GetSelectionController() |
| 125 .MouseDownMayStartSelect()); |
| 126 |
| 120 WebMouseEvent mouse_move_event( | 127 WebMouseEvent mouse_move_event( |
| 121 WebInputEvent::kMouseMove, WebFloatPoint(100, 50), | 128 WebInputEvent::kMouseMove, WebFloatPoint(100, 50), |
| 122 WebFloatPoint(200, 250), WebPointerProperties::Button::kLeft, 1, | 129 WebFloatPoint(200, 250), WebPointerProperties::Button::kLeft, 1, |
| 123 WebInputEvent::Modifiers::kLeftButtonDown, | 130 WebInputEvent::Modifiers::kLeftButtonDown, |
| 124 WebInputEvent::kTimeStampForTesting); | 131 WebInputEvent::kTimeStampForTesting); |
| 125 mouse_move_event.SetFrameScale(1); | 132 mouse_move_event.SetFrameScale(1); |
| 126 GetDocument().GetFrame()->GetEventHandler().HandleMouseMoveEvent( | 133 GetDocument().GetFrame()->GetEventHandler().HandleMouseMoveEvent( |
| 127 mouse_move_event, Vector<WebMouseEvent>()); | 134 mouse_move_event, Vector<WebMouseEvent>()); |
| 128 | 135 |
| 129 GetPage().GetAutoscrollController().Animate( | 136 GetPage().GetAutoscrollController().Animate( |
| 130 WTF::MonotonicallyIncreasingTime()); | 137 WTF::MonotonicallyIncreasingTime()); |
| 131 GetPage().Animator().ServiceScriptedAnimations( | 138 GetPage().Animator().ServiceScriptedAnimations( |
| 132 WTF::MonotonicallyIncreasingTime()); | 139 WTF::MonotonicallyIncreasingTime()); |
| 133 | 140 |
| 134 WebMouseEvent mouse_up_event( | 141 WebMouseEvent mouse_up_event( |
| 135 WebMouseEvent::kMouseUp, WebFloatPoint(100, 50), WebFloatPoint(200, 250), | 142 WebMouseEvent::kMouseUp, WebFloatPoint(100, 50), WebFloatPoint(200, 250), |
| 136 WebPointerProperties::Button::kLeft, 1, WebInputEvent::kNoModifiers, | 143 WebPointerProperties::Button::kLeft, 1, WebInputEvent::kNoModifiers, |
| 137 WebInputEvent::kTimeStampForTesting); | 144 WebInputEvent::kTimeStampForTesting); |
| 138 mouse_up_event.SetFrameScale(1); | 145 mouse_up_event.SetFrameScale(1); |
| 139 GetDocument().GetFrame()->GetEventHandler().HandleMouseReleaseEvent( | 146 GetDocument().GetFrame()->GetEventHandler().HandleMouseReleaseEvent( |
| 140 mouse_up_event); | 147 mouse_up_event); |
| 141 | 148 |
| 149 ASSERT_FALSE(GetDocument() |
| 150 .GetFrame() |
| 151 ->GetEventHandler() |
| 152 .GetSelectionController() |
| 153 .MouseDownMayStartSelect()); |
| 154 |
| 142 ASSERT_TRUE( | 155 ASSERT_TRUE( |
| 143 Selection().ComputeVisibleSelectionInDOMTreeDeprecated().IsRange()); | 156 Selection().ComputeVisibleSelectionInDOMTreeDeprecated().IsRange()); |
| 144 Range* range = CreateRange(Selection() | 157 Range* range = CreateRange(Selection() |
| 145 .ComputeVisibleSelectionInDOMTreeDeprecated() | 158 .ComputeVisibleSelectionInDOMTreeDeprecated() |
| 146 .ToNormalizedEphemeralRange()); | 159 .ToNormalizedEphemeralRange()); |
| 147 ASSERT_TRUE(range); | 160 ASSERT_TRUE(range); |
| 148 EXPECT_EQ("Line 1\nLine 2", range->GetText()); | 161 EXPECT_EQ("Line 1\nLine 2", range->GetText()); |
| 149 } | 162 } |
| 150 | 163 |
| 151 TEST_F(EventHandlerTest, multiClickSelectionFromTap) { | 164 TEST_F(EventHandlerTest, multiClickSelectionFromTap) { |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 WebPointerProperties::Button::kNoButton, 0, WebInputEvent::kNoModifiers, | 554 WebPointerProperties::Button::kNoButton, 0, WebInputEvent::kNoModifiers, |
| 542 TimeTicks::Now().InSeconds()); | 555 TimeTicks::Now().InSeconds()); |
| 543 mouse_leave_event.SetFrameScale(1); | 556 mouse_leave_event.SetFrameScale(1); |
| 544 GetDocument().GetFrame()->GetEventHandler().HandleMouseLeaveEvent( | 557 GetDocument().GetFrame()->GetEventHandler().HandleMouseLeaveEvent( |
| 545 mouse_leave_event); | 558 mouse_leave_event); |
| 546 | 559 |
| 547 EXPECT_EQ(WTF::String(), LastToolTip()); | 560 EXPECT_EQ(WTF::String(), LastToolTip()); |
| 548 } | 561 } |
| 549 | 562 |
| 550 } // namespace blink | 563 } // namespace blink |
| OLD | NEW |