Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: third_party/WebKit/Source/web/tests/SelectionTestBase.cpp

Issue 1774123006: Implement link selection on alt+mouse drag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "web/tests/SelectionTestBase.h"
6
7 #include "web/WebLocalFrameImpl.h"
8
9 namespace blink {
10 namespace {
11 IntSize scaled(IntSize p, float scale)
12 {
13 p.scale(scale, scale);
14 return p;
15 }
16 } // namespace
17
18 void SelectionTestBase::emulateMouseDrag(const IntPoint& downPoint, const IntPoi nt& upPoint, int modifiers,
19 bool sendDownEvent, bool sendUpEvent)
20 {
21 if (sendDownEvent) {
22 const auto& downEvent = FrameTestHelpers::createMouseEvent(WebMouseEvent ::MouseDown, WebMouseEvent::ButtonLeft, downPoint, modifiers);
23 m_webView->handleInputEvent(downEvent);
24 }
25
26 static const int kMoveEventsNumber = 10;
27 static const float kMoveIncrementFraction = 1. / kMoveEventsNumber;
28 const auto& upDownVector = upPoint - downPoint;
29 for (int i = 0; i < kMoveEventsNumber; ++i) {
30 const auto& movePoint = downPoint + scaled(upDownVector, i * kMoveIncrem entFraction);
31 const auto& moveEvent = FrameTestHelpers::createMouseEvent(WebMouseEvent ::MouseMove, WebMouseEvent::ButtonLeft, movePoint, modifiers);
32 m_webView->handleInputEvent(moveEvent);
33 }
34
35 if (sendUpEvent) {
36 const auto& upEvent = FrameTestHelpers::createMouseEvent(WebMouseEvent:: MouseUp, WebMouseEvent::ButtonLeft, upPoint, modifiers);
37 m_webView->handleInputEvent(upEvent);
38 }
39 }
40
41 void SelectionTestBase::emulateMouseClick(const IntPoint& clickPoint, WebMouseEv ent::Button button, int modifiers, int count)
42 {
43 auto event = FrameTestHelpers::createMouseEvent(WebMouseEvent::MouseDown, bu tton, clickPoint, modifiers);
44 event.clickCount = count;
45 m_webView->handleInputEvent(event);
46 event.type = WebMouseEvent::MouseUp;
47 m_webView->handleInputEvent(event);
48 }
49
50 void SelectionTestBase::emulateMouseDown(const IntPoint& clickPoint, WebMouseEve nt::Button button, int modifiers, int count)
51 {
52 auto event = FrameTestHelpers::createMouseEvent(WebMouseEvent::MouseDown, bu tton, clickPoint, modifiers);
53 event.clickCount = count;
54 m_webView->handleInputEvent(event);
55 }
56
57 std::string SelectionTestBase::getSelectionText()
58 {
59 return m_mainFrame->selectionAsText().utf8();
60 }
61 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698