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

Side by Side Diff: third_party/WebKit/Source/core/input/MouseEventManager.cpp

Issue 2650403006: Remove PlatformMouseEvent and use WebMouseEvent instead (Closed)
Patch Set: Fix nits Created 3 years, 10 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/MouseEventManager.h" 5 #include "core/input/MouseEventManager.h"
6 6
7 #include "core/clipboard/DataObject.h" 7 #include "core/clipboard/DataObject.h"
8 #include "core/clipboard/DataTransfer.h" 8 #include "core/clipboard/DataTransfer.h"
9 #include "core/dom/Element.h" 9 #include "core/dom/Element.h"
10 #include "core/dom/ElementTraversal.h" 10 #include "core/dom/ElementTraversal.h"
(...skipping 17 matching lines...) Expand all
28 #include "core/page/DragState.h" 28 #include "core/page/DragState.h"
29 #include "core/page/FocusController.h" 29 #include "core/page/FocusController.h"
30 #include "core/paint/PaintLayer.h" 30 #include "core/paint/PaintLayer.h"
31 #include "core/svg/SVGDocumentExtensions.h" 31 #include "core/svg/SVGDocumentExtensions.h"
32 #include "platform/geometry/FloatQuad.h" 32 #include "platform/geometry/FloatQuad.h"
33 33
34 namespace blink { 34 namespace blink {
35 35
36 namespace { 36 namespace {
37 37
38 PlatformMouseEvent mouseEventWithRegion(Node* node, 38 String canvasRegionId(Node* node, const WebMouseEvent& mouseEvent) {
39 const PlatformMouseEvent& mouseEvent) {
40 if (!node->isElementNode()) 39 if (!node->isElementNode())
41 return mouseEvent; 40 return String();
42 41
43 Element* element = toElement(node); 42 Element* element = toElement(node);
44 if (!element->isInCanvasSubtree()) 43 if (!element->isInCanvasSubtree())
45 return mouseEvent; 44 return String();
46 45
47 HTMLCanvasElement* canvas = 46 HTMLCanvasElement* canvas =
48 Traversal<HTMLCanvasElement>::firstAncestorOrSelf(*element); 47 Traversal<HTMLCanvasElement>::firstAncestorOrSelf(*element);
49 // In this case, the event target is canvas and mouse rerouting doesn't 48 // In this case, the event target is canvas and mouse rerouting doesn't
50 // happen. 49 // happen.
51 if (canvas == element) 50 if (canvas == element)
52 return mouseEvent; 51 return String();
53 String region = canvas->getIdFromControl(element); 52 return canvas->getIdFromControl(element);
54 PlatformMouseEvent newMouseEvent = mouseEvent;
55 newMouseEvent.setRegion(region);
56 return newMouseEvent;
57 } 53 }
58 54
59 // The amount of time to wait before sending a fake mouse event triggered 55 // The amount of time to wait before sending a fake mouse event triggered
60 // during a scroll. 56 // during a scroll.
61 const double kFakeMouseMoveInterval = 0.1; 57 const double kFakeMouseMoveInterval = 0.1;
62 58
63 // TODO(crbug.com/653490): Read these values from the OS. 59 // TODO(crbug.com/653490): Read these values from the OS.
64 #if OS(MACOSX) 60 #if OS(MACOSX)
65 const int kDragThresholdX = 3; 61 const int kDragThresholdX = 3;
66 const int kDragThresholdY = 3; 62 const int kDragThresholdY = 3;
(...skipping 26 matching lines...) Expand all
93 m_mouseDownMayStartDrag = false; 89 m_mouseDownMayStartDrag = false;
94 m_capturesDragging = false; 90 m_capturesDragging = false;
95 m_isMousePositionUnknown = true; 91 m_isMousePositionUnknown = true;
96 m_lastKnownMousePosition = IntPoint(); 92 m_lastKnownMousePosition = IntPoint();
97 m_lastKnownMouseGlobalPosition = IntPoint(); 93 m_lastKnownMouseGlobalPosition = IntPoint();
98 m_mousePressed = false; 94 m_mousePressed = false;
99 m_clickCount = 0; 95 m_clickCount = 0;
100 m_clickNode = nullptr; 96 m_clickNode = nullptr;
101 m_mouseDownPos = IntPoint(); 97 m_mouseDownPos = IntPoint();
102 m_mouseDownTimestamp = TimeTicks(); 98 m_mouseDownTimestamp = TimeTicks();
103 m_mouseDown = PlatformMouseEvent(); 99 m_mouseDown = WebMouseEvent();
104 m_svgPan = false; 100 m_svgPan = false;
105 m_dragStartPos = LayoutPoint(); 101 m_dragStartPos = LayoutPoint();
106 m_fakeMouseMoveEventTimer.stop(); 102 m_fakeMouseMoveEventTimer.stop();
107 } 103 }
108 104
109 MouseEventManager::~MouseEventManager() = default; 105 MouseEventManager::~MouseEventManager() = default;
110 106
111 DEFINE_TRACE(MouseEventManager) { 107 DEFINE_TRACE(MouseEventManager) {
112 visitor->trace(m_frame); 108 visitor->trace(m_frame);
113 visitor->trace(m_scrollManager); 109 visitor->trace(m_scrollManager);
114 visitor->trace(m_nodeUnderMouse); 110 visitor->trace(m_nodeUnderMouse);
115 visitor->trace(m_mousePressNode); 111 visitor->trace(m_mousePressNode);
116 visitor->trace(m_clickNode); 112 visitor->trace(m_clickNode);
117 SynchronousMutationObserver::trace(visitor); 113 SynchronousMutationObserver::trace(visitor);
118 } 114 }
119 115
120 MouseEventManager::MouseEventBoundaryEventDispatcher:: 116 MouseEventManager::MouseEventBoundaryEventDispatcher::
121 MouseEventBoundaryEventDispatcher( 117 MouseEventBoundaryEventDispatcher(MouseEventManager* mouseEventManager,
122 MouseEventManager* mouseEventManager, 118 const WebMouseEvent* webMouseEvent,
123 const PlatformMouseEvent* platformMouseEvent, 119 EventTarget* exitedTarget,
124 EventTarget* exitedTarget) 120 const String& canvasRegionId)
125 : m_mouseEventManager(mouseEventManager), 121 : m_mouseEventManager(mouseEventManager),
126 m_platformMouseEvent(platformMouseEvent), 122 m_webMouseEvent(webMouseEvent),
127 m_exitedTarget(exitedTarget) {} 123 m_exitedTarget(exitedTarget),
124 m_canvasRegionId(canvasRegionId) {}
128 125
129 void MouseEventManager::MouseEventBoundaryEventDispatcher::dispatchOut( 126 void MouseEventManager::MouseEventBoundaryEventDispatcher::dispatchOut(
130 EventTarget* target, 127 EventTarget* target,
131 EventTarget* relatedTarget) { 128 EventTarget* relatedTarget) {
132 dispatch( 129 dispatch(target, relatedTarget, EventTypeNames::mouseout,
133 target, relatedTarget, EventTypeNames::mouseout, 130 canvasRegionId(m_exitedTarget->toNode(), *m_webMouseEvent),
134 mouseEventWithRegion(m_exitedTarget->toNode(), *m_platformMouseEvent), 131 *m_webMouseEvent, false);
135 false);
136 } 132 }
137 133
138 void MouseEventManager::MouseEventBoundaryEventDispatcher::dispatchOver( 134 void MouseEventManager::MouseEventBoundaryEventDispatcher::dispatchOver(
139 EventTarget* target, 135 EventTarget* target,
140 EventTarget* relatedTarget) { 136 EventTarget* relatedTarget) {
141 dispatch(target, relatedTarget, EventTypeNames::mouseover, 137 dispatch(target, relatedTarget, EventTypeNames::mouseover, m_canvasRegionId,
142 *m_platformMouseEvent, false); 138 *m_webMouseEvent, false);
143 } 139 }
144 140
145 void MouseEventManager::MouseEventBoundaryEventDispatcher::dispatchLeave( 141 void MouseEventManager::MouseEventBoundaryEventDispatcher::dispatchLeave(
146 EventTarget* target, 142 EventTarget* target,
147 EventTarget* relatedTarget, 143 EventTarget* relatedTarget,
148 bool checkForListener) { 144 bool checkForListener) {
149 dispatch( 145 dispatch(target, relatedTarget, EventTypeNames::mouseleave,
150 target, relatedTarget, EventTypeNames::mouseleave, 146 canvasRegionId(m_exitedTarget->toNode(), *m_webMouseEvent),
151 mouseEventWithRegion(m_exitedTarget->toNode(), *m_platformMouseEvent), 147 *m_webMouseEvent, checkForListener);
152 checkForListener);
153 } 148 }
154 149
155 void MouseEventManager::MouseEventBoundaryEventDispatcher::dispatchEnter( 150 void MouseEventManager::MouseEventBoundaryEventDispatcher::dispatchEnter(
156 EventTarget* target, 151 EventTarget* target,
157 EventTarget* relatedTarget, 152 EventTarget* relatedTarget,
158 bool checkForListener) { 153 bool checkForListener) {
159 dispatch(target, relatedTarget, EventTypeNames::mouseenter, 154 dispatch(target, relatedTarget, EventTypeNames::mouseenter, m_canvasRegionId,
160 *m_platformMouseEvent, checkForListener); 155 *m_webMouseEvent, checkForListener);
161 } 156 }
162 157
163 AtomicString 158 AtomicString
164 MouseEventManager::MouseEventBoundaryEventDispatcher::getLeaveEvent() { 159 MouseEventManager::MouseEventBoundaryEventDispatcher::getLeaveEvent() {
165 return EventTypeNames::mouseleave; 160 return EventTypeNames::mouseleave;
166 } 161 }
167 162
168 AtomicString 163 AtomicString
169 MouseEventManager::MouseEventBoundaryEventDispatcher::getEnterEvent() { 164 MouseEventManager::MouseEventBoundaryEventDispatcher::getEnterEvent() {
170 return EventTypeNames::mouseenter; 165 return EventTypeNames::mouseenter;
171 } 166 }
172 167
173 void MouseEventManager::MouseEventBoundaryEventDispatcher::dispatch( 168 void MouseEventManager::MouseEventBoundaryEventDispatcher::dispatch(
174 EventTarget* target, 169 EventTarget* target,
175 EventTarget* relatedTarget, 170 EventTarget* relatedTarget,
176 const AtomicString& type, 171 const AtomicString& type,
177 const PlatformMouseEvent& platformMouseEvent, 172 const String& canvasRegionId,
173 const WebMouseEvent& webMouseEvent,
178 bool checkForListener) { 174 bool checkForListener) {
179 m_mouseEventManager->dispatchMouseEvent(target, type, platformMouseEvent, 175 m_mouseEventManager->dispatchMouseEvent(target, type, webMouseEvent,
180 relatedTarget, checkForListener); 176 canvasRegionId, relatedTarget,
177 checkForListener);
181 } 178 }
182 179
183 void MouseEventManager::sendBoundaryEvents( 180 void MouseEventManager::sendBoundaryEvents(EventTarget* exitedTarget,
184 EventTarget* exitedTarget, 181 EventTarget* enteredTarget,
185 EventTarget* enteredTarget, 182 const String& canvasRegionId,
186 const PlatformMouseEvent& mousePlatformEvent) { 183 const WebMouseEvent& mouseEvent) {
187 MouseEventBoundaryEventDispatcher boundaryEventDispatcher( 184 MouseEventBoundaryEventDispatcher boundaryEventDispatcher(
188 this, &mousePlatformEvent, exitedTarget); 185 this, &mouseEvent, exitedTarget, canvasRegionId);
189 boundaryEventDispatcher.sendBoundaryEvents(exitedTarget, enteredTarget); 186 boundaryEventDispatcher.sendBoundaryEvents(exitedTarget, enteredTarget);
190 } 187 }
191 188
192 WebInputEventResult MouseEventManager::dispatchMouseEvent( 189 WebInputEventResult MouseEventManager::dispatchMouseEvent(
193 EventTarget* target, 190 EventTarget* target,
194 const AtomicString& mouseEventType, 191 const AtomicString& mouseEventType,
195 const PlatformMouseEvent& mouseEvent, 192 const WebMouseEvent& mouseEvent,
193 const String& canvasRegionId,
196 EventTarget* relatedTarget, 194 EventTarget* relatedTarget,
197 bool checkForListener) { 195 bool checkForListener) {
198 if (target && target->toNode() && 196 if (target && target->toNode() &&
199 (!checkForListener || target->hasEventListeners(mouseEventType))) { 197 (!checkForListener || target->hasEventListeners(mouseEventType))) {
200 Node* targetNode = target->toNode(); 198 Node* targetNode = target->toNode();
201 int clickCount = 0; 199 int clickCount = 0;
202 if (mouseEventType == EventTypeNames::mouseup || 200 if (mouseEventType == EventTypeNames::mouseup ||
203 mouseEventType == EventTypeNames::mousedown || 201 mouseEventType == EventTypeNames::mousedown ||
204 mouseEventType == EventTypeNames::click || 202 mouseEventType == EventTypeNames::click ||
205 mouseEventType == EventTypeNames::auxclick || 203 mouseEventType == EventTypeNames::auxclick ||
206 mouseEventType == EventTypeNames::dblclick) { 204 mouseEventType == EventTypeNames::dblclick) {
207 clickCount = m_clickCount; 205 clickCount = m_clickCount;
208 } 206 }
209 MouseEvent* event = MouseEvent::create( 207 MouseEvent* event =
210 mouseEventType, targetNode->document().domWindow(), mouseEvent, 208 MouseEvent::create(mouseEventType, targetNode->document().domWindow(),
211 clickCount, relatedTarget ? relatedTarget->toNode() : nullptr); 209 mouseEvent, clickCount, canvasRegionId,
210 relatedTarget ? relatedTarget->toNode() : nullptr);
212 DispatchEventResult dispatchResult = target->dispatchEvent(event); 211 DispatchEventResult dispatchResult = target->dispatchEvent(event);
213 return EventHandlingUtil::toWebInputEventResult(dispatchResult); 212 return EventHandlingUtil::toWebInputEventResult(dispatchResult);
214 } 213 }
215 return WebInputEventResult::NotHandled; 214 return WebInputEventResult::NotHandled;
216 } 215 }
217 216
218 WebInputEventResult MouseEventManager::setMousePositionAndDispatchMouseEvent( 217 WebInputEventResult MouseEventManager::setMousePositionAndDispatchMouseEvent(
219 Node* targetNode, 218 Node* targetNode,
219 const String& canvasRegionId,
220 const AtomicString& eventType, 220 const AtomicString& eventType,
221 const PlatformMouseEvent& platformMouseEvent) { 221 const WebMouseEvent& webMouseEvent) {
222 // If the target node is a text node, dispatch on the parent node. 222 // If the target node is a text node, dispatch on the parent node.
223 if (targetNode && targetNode->isTextNode()) 223 if (targetNode && targetNode->isTextNode())
224 targetNode = FlatTreeTraversal::parent(*targetNode); 224 targetNode = FlatTreeTraversal::parent(*targetNode);
225 225
226 setNodeUnderMouse(targetNode, platformMouseEvent); 226 setNodeUnderMouse(targetNode, canvasRegionId, webMouseEvent);
227 227
228 return dispatchMouseEvent(m_nodeUnderMouse, eventType, platformMouseEvent, 228 return dispatchMouseEvent(m_nodeUnderMouse, eventType, webMouseEvent,
229 nullptr); 229 canvasRegionId, nullptr);
230 } 230 }
231 231
232 WebInputEventResult MouseEventManager::dispatchMouseClickIfNeeded( 232 WebInputEventResult MouseEventManager::dispatchMouseClickIfNeeded(
233 const MouseEventWithHitTestResults& mev) { 233 const MouseEventWithHitTestResults& mev) {
234 // We only prevent click event when the click may cause contextmenu to popup. 234 // We only prevent click event when the click may cause contextmenu to popup.
235 // However, we always send auxclick. 235 // However, we always send auxclick.
236 bool contextMenuEvent = !RuntimeEnabledFeatures::auxclickEnabled() && 236 bool contextMenuEvent =
237 mev.event().pointerProperties().button == 237 !RuntimeEnabledFeatures::auxclickEnabled() &&
238 WebPointerProperties::Button::Right; 238 mev.event().button == WebPointerProperties::Button::Right;
239 #if OS(MACOSX) 239 #if OS(MACOSX)
240 // FIXME: The Mac port achieves the same behavior by checking whether the 240 // FIXME: The Mac port achieves the same behavior by checking whether the
241 // context menu is currently open in WebPage::mouseEvent(). Consider merging 241 // context menu is currently open in WebPage::mouseEvent(). Consider merging
242 // the implementations. 242 // the implementations.
243 if (mev.event().pointerProperties().button == 243 if (mev.event().button == WebPointerProperties::Button::Left &&
244 WebPointerProperties::Button::Left && 244 mev.event().modifiers() & WebInputEvent::Modifiers::ControlKey)
245 mev.event().getModifiers() & PlatformEvent::CtrlKey)
246 contextMenuEvent = true; 245 contextMenuEvent = true;
247 #endif 246 #endif
248 247
249 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled; 248 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled;
250 const bool shouldDispatchClickEvent = 249 const bool shouldDispatchClickEvent =
251 m_clickCount > 0 && !contextMenuEvent && mev.innerNode() && m_clickNode && 250 m_clickCount > 0 && !contextMenuEvent && mev.innerNode() && m_clickNode &&
252 mev.innerNode()->canParticipateInFlatTree() && 251 mev.innerNode()->canParticipateInFlatTree() &&
253 m_clickNode->canParticipateInFlatTree() && 252 m_clickNode->canParticipateInFlatTree() &&
254 !(m_frame->eventHandler().selectionController().hasExtendedSelection() && 253 !(m_frame->eventHandler().selectionController().hasExtendedSelection() &&
255 isLinkSelection(mev)); 254 isLinkSelection(mev));
256 if (shouldDispatchClickEvent) { 255 if (shouldDispatchClickEvent) {
257 Node* clickTargetNode = nullptr; 256 Node* clickTargetNode = nullptr;
258 // Updates distribution because a 'mouseup' event listener can make the 257 // Updates distribution because a 'mouseup' event listener can make the
259 // tree dirty at dispatchMouseEvent() invocation above. 258 // tree dirty at dispatchMouseEvent() invocation above.
260 // Unless distribution is updated, commonAncestor would hit ASSERT. 259 // Unless distribution is updated, commonAncestor would hit ASSERT.
261 if (m_clickNode == mev.innerNode()) { 260 if (m_clickNode == mev.innerNode()) {
262 clickTargetNode = m_clickNode; 261 clickTargetNode = m_clickNode;
263 clickTargetNode->updateDistribution(); 262 clickTargetNode->updateDistribution();
264 } else if (m_clickNode->document() == mev.innerNode()->document()) { 263 } else if (m_clickNode->document() == mev.innerNode()->document()) {
265 m_clickNode->updateDistribution(); 264 m_clickNode->updateDistribution();
266 mev.innerNode()->updateDistribution(); 265 mev.innerNode()->updateDistribution();
267 clickTargetNode = mev.innerNode()->commonAncestor( 266 clickTargetNode = mev.innerNode()->commonAncestor(
268 *m_clickNode, EventHandlingUtil::parentForClickEvent); 267 *m_clickNode, EventHandlingUtil::parentForClickEvent);
269 } 268 }
270 if (clickTargetNode) { 269 if (clickTargetNode) {
271 clickEventResult = dispatchMouseEvent( 270 clickEventResult = dispatchMouseEvent(
272 clickTargetNode, !RuntimeEnabledFeatures::auxclickEnabled() || 271 clickTargetNode,
273 (mev.event().pointerProperties().button == 272 !RuntimeEnabledFeatures::auxclickEnabled() ||
274 WebPointerProperties::Button::Left) 273 (mev.event().button == WebPointerProperties::Button::Left)
275 ? EventTypeNames::click 274 ? EventTypeNames::click
276 : EventTypeNames::auxclick, 275 : EventTypeNames::auxclick,
277 mev.event(), nullptr); 276 mev.event(), mev.canvasRegionId(), nullptr);
278 } 277 }
279 } 278 }
280 return clickEventResult; 279 return clickEventResult;
281 } 280 }
282 281
283 void MouseEventManager::fakeMouseMoveEventTimerFired(TimerBase* timer) { 282 void MouseEventManager::fakeMouseMoveEventTimerFired(TimerBase* timer) {
284 TRACE_EVENT0("input", "MouseEventManager::fakeMouseMoveEventTimerFired"); 283 TRACE_EVENT0("input", "MouseEventManager::fakeMouseMoveEventTimerFired");
285 DCHECK(timer == &m_fakeMouseMoveEventTimer); 284 DCHECK(timer == &m_fakeMouseMoveEventTimer);
286 DCHECK(!m_mousePressed); 285 DCHECK(!m_mousePressed);
287 286
288 if (m_isMousePositionUnknown) 287 if (m_isMousePositionUnknown)
289 return; 288 return;
290 289
291 FrameView* view = m_frame->view(); 290 FrameView* view = m_frame->view();
292 if (!view) 291 if (!view)
293 return; 292 return;
294 293
295 if (!m_frame->page() || !m_frame->page()->focusController().isActive()) 294 if (!m_frame->page() || !m_frame->page()->focusController().isActive())
296 return; 295 return;
297 296
298 // Don't dispatch a synthetic mouse move event if the mouse cursor is not 297 // Don't dispatch a synthetic mouse move event if the mouse cursor is not
299 // visible to the user. 298 // visible to the user.
300 if (!m_frame->page()->isCursorVisible()) 299 if (!m_frame->page()->isCursorVisible())
301 return; 300 return;
302 301
303 PlatformMouseEvent fakeMouseMoveEvent( 302 WebMouseEvent fakeMouseMoveEvent(
304 m_lastKnownMousePosition, m_lastKnownMouseGlobalPosition, 303 WebInputEvent::MouseMove,
305 WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 0, 304 WebFloatPoint(m_lastKnownMousePosition.x(), m_lastKnownMousePosition.y()),
306 static_cast<PlatformEvent::Modifiers>( 305 WebFloatPoint(m_lastKnownMouseGlobalPosition.x(),
307 KeyboardEventManager::getCurrentModifierState()), 306 m_lastKnownMouseGlobalPosition.y()),
308 PlatformMouseEvent::RealOrIndistinguishable, TimeTicks::Now(), 307 WebPointerProperties::Button::NoButton, 0,
309 WebPointerProperties::PointerType::Mouse); 308 KeyboardEventManager::getCurrentModifierState(),
310 Vector<PlatformMouseEvent> coalescedEvents; 309 TimeTicks::Now().InSeconds());
310 // TODO(dtapuska): Update m_lastKnowMousePosition to be viewport coordinates.
311 fakeMouseMoveEvent.setFrameScale(1);
312 Vector<WebMouseEvent> coalescedEvents;
311 m_frame->eventHandler().handleMouseMoveEvent(fakeMouseMoveEvent, 313 m_frame->eventHandler().handleMouseMoveEvent(fakeMouseMoveEvent,
312 coalescedEvents); 314 coalescedEvents);
313 } 315 }
314 316
315 void MouseEventManager::cancelFakeMouseMoveEvent() { 317 void MouseEventManager::cancelFakeMouseMoveEvent() {
316 m_fakeMouseMoveEventTimer.stop(); 318 m_fakeMouseMoveEventTimer.stop();
317 } 319 }
318 320
319 void MouseEventManager::setNodeUnderMouse( 321 void MouseEventManager::setNodeUnderMouse(Node* target,
320 Node* target, 322 const String& canvasRegionId,
321 const PlatformMouseEvent& platformMouseEvent) { 323 const WebMouseEvent& webMouseEvent) {
322 Node* lastNodeUnderMouse = m_nodeUnderMouse; 324 Node* lastNodeUnderMouse = m_nodeUnderMouse;
323 m_nodeUnderMouse = target; 325 m_nodeUnderMouse = target;
324 326
325 PaintLayer* layerForLastNode = 327 PaintLayer* layerForLastNode =
326 EventHandlingUtil::layerForNode(lastNodeUnderMouse); 328 EventHandlingUtil::layerForNode(lastNodeUnderMouse);
327 PaintLayer* layerForNodeUnderMouse = 329 PaintLayer* layerForNodeUnderMouse =
328 EventHandlingUtil::layerForNode(m_nodeUnderMouse.get()); 330 EventHandlingUtil::layerForNode(m_nodeUnderMouse.get());
329 Page* page = m_frame->page(); 331 Page* page = m_frame->page();
330 332
331 if (lastNodeUnderMouse && 333 if (lastNodeUnderMouse &&
(...skipping 28 matching lines...) Expand all
360 if (ScrollableArea* scrollableAreaForNodeUnderMouse = 362 if (ScrollableArea* scrollableAreaForNodeUnderMouse =
361 EventHandlingUtil::associatedScrollableArea(layerForNodeUnderMouse)) 363 EventHandlingUtil::associatedScrollableArea(layerForNodeUnderMouse))
362 scrollableAreaForNodeUnderMouse->mouseEnteredContentArea(); 364 scrollableAreaForNodeUnderMouse->mouseEnteredContentArea();
363 } 365 }
364 366
365 if (lastNodeUnderMouse && 367 if (lastNodeUnderMouse &&
366 lastNodeUnderMouse->document() != m_frame->document()) { 368 lastNodeUnderMouse->document() != m_frame->document()) {
367 lastNodeUnderMouse = nullptr; 369 lastNodeUnderMouse = nullptr;
368 } 370 }
369 371
370 sendBoundaryEvents(lastNodeUnderMouse, m_nodeUnderMouse, platformMouseEvent); 372 sendBoundaryEvents(lastNodeUnderMouse, m_nodeUnderMouse, canvasRegionId,
373 webMouseEvent);
371 } 374 }
372 375
373 void MouseEventManager::nodeChildrenWillBeRemoved(ContainerNode& container) { 376 void MouseEventManager::nodeChildrenWillBeRemoved(ContainerNode& container) {
374 if (container == m_clickNode) 377 if (container == m_clickNode)
375 return; 378 return;
376 if (!container.isShadowIncludingInclusiveAncestorOf(m_clickNode.get())) 379 if (!container.isShadowIncludingInclusiveAncestorOf(m_clickNode.get()))
377 return; 380 return;
378 m_clickNode = nullptr; 381 m_clickNode = nullptr;
379 } 382 }
380 383
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 // focus has slided. 489 // focus has slided.
487 found->focus(FocusParams(SelectionBehaviorOnFocus::Reset, 490 found->focus(FocusParams(SelectionBehaviorOnFocus::Reset,
488 WebFocusTypeForward, nullptr)); 491 WebFocusTypeForward, nullptr));
489 return true; 492 return true;
490 } 493 }
491 } 494 }
492 return false; 495 return false;
493 } 496 }
494 497
495 void MouseEventManager::handleMousePressEventUpdateStates( 498 void MouseEventManager::handleMousePressEventUpdateStates(
496 const PlatformMouseEvent& mouseEvent) { 499 const WebMouseEvent& mouseEvent) {
497 cancelFakeMouseMoveEvent(); 500 cancelFakeMouseMoveEvent();
498 m_mousePressed = true; 501 m_mousePressed = true;
499 m_capturesDragging = true; 502 m_capturesDragging = true;
500 setLastKnownMousePosition(mouseEvent); 503 setLastKnownMousePosition(mouseEvent);
501 m_mouseDownMayStartDrag = false; 504 m_mouseDownMayStartDrag = false;
502 m_mouseDownMayStartAutoscroll = false; 505 m_mouseDownMayStartAutoscroll = false;
503 m_mouseDownTimestamp = mouseEvent.timestamp(); 506 m_mouseDownTimestamp = TimeTicks::FromSeconds(mouseEvent.timeStampSeconds());
504 507
505 if (FrameView* view = m_frame->view()) { 508 if (FrameView* view = m_frame->view()) {
506 m_mouseDownPos = view->rootFrameToContents(mouseEvent.position()); 509 m_mouseDownPos = view->rootFrameToContents(
510 flooredIntPoint(mouseEvent.positionInRootFrame()));
507 } else { 511 } else {
508 invalidateClick(); 512 invalidateClick();
509 } 513 }
510 } 514 }
511 515
512 bool MouseEventManager::isMousePositionUnknown() { 516 bool MouseEventManager::isMousePositionUnknown() {
513 return m_isMousePositionUnknown; 517 return m_isMousePositionUnknown;
514 } 518 }
515 519
516 IntPoint MouseEventManager::lastKnownMousePosition() { 520 IntPoint MouseEventManager::lastKnownMousePosition() {
517 return m_lastKnownMousePosition; 521 return m_lastKnownMousePosition;
518 } 522 }
519 523
520 void MouseEventManager::setLastKnownMousePosition( 524 void MouseEventManager::setLastKnownMousePosition(const WebMouseEvent& event) {
521 const PlatformMouseEvent& event) {
522 m_isMousePositionUnknown = false; 525 m_isMousePositionUnknown = false;
523 m_lastKnownMousePosition = event.position(); 526 m_lastKnownMousePosition = flooredIntPoint(event.positionInRootFrame());
524 m_lastKnownMouseGlobalPosition = event.globalPosition(); 527 m_lastKnownMouseGlobalPosition = IntPoint(event.globalX, event.globalY);
525 } 528 }
526 529
527 void MouseEventManager::dispatchFakeMouseMoveEventSoon() { 530 void MouseEventManager::dispatchFakeMouseMoveEventSoon() {
528 if (m_mousePressed) 531 if (m_mousePressed)
529 return; 532 return;
530 533
531 if (m_isMousePositionUnknown) 534 if (m_isMousePositionUnknown)
532 return; 535 return;
533 536
534 // Reschedule the timer, to prevent dispatching mouse move events 537 // Reschedule the timer, to prevent dispatching mouse move events
(...skipping 19 matching lines...) Expand all
554 TRACE_EVENT0("blink", "MouseEventManager::handleMousePressEvent"); 557 TRACE_EVENT0("blink", "MouseEventManager::handleMousePressEvent");
555 558
556 // Reset drag state. 559 // Reset drag state.
557 dragState().m_dragSrc = nullptr; 560 dragState().m_dragSrc = nullptr;
558 561
559 cancelFakeMouseMoveEvent(); 562 cancelFakeMouseMoveEvent();
560 563
561 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 564 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
562 565
563 if (FrameView* frameView = m_frame->view()) { 566 if (FrameView* frameView = m_frame->view()) {
564 if (frameView->isPointInScrollbarCorner(event.event().position())) 567 if (frameView->isPointInScrollbarCorner(
568 flooredIntPoint(event.event().positionInRootFrame())))
565 return WebInputEventResult::NotHandled; 569 return WebInputEventResult::NotHandled;
566 } 570 }
567 571
568 bool singleClick = event.event().clickCount() <= 1; 572 bool singleClick = event.event().clickCount <= 1;
569 573
570 m_mouseDownMayStartDrag = 574 m_mouseDownMayStartDrag =
571 singleClick && !isLinkSelection(event) && !isExtendingSelection(event); 575 singleClick && !isLinkSelection(event) && !isExtendingSelection(event);
572 576
573 m_frame->eventHandler().selectionController().handleMousePressEvent(event); 577 m_frame->eventHandler().selectionController().handleMousePressEvent(event);
574 578
575 m_mouseDown = event.event(); 579 m_mouseDown = event.event();
576 580
577 if (m_frame->document()->isSVGDocument() && 581 if (m_frame->document()->isSVGDocument() &&
578 m_frame->document()->accessSVGExtensions().zoomAndPanEnabled()) { 582 m_frame->document()->accessSVGExtensions().zoomAndPanEnabled()) {
579 if (event.event().shiftKey() && singleClick) { 583 if ((event.event().modifiers() & WebInputEvent::Modifiers::ShiftKey) &&
584 singleClick) {
580 m_svgPan = true; 585 m_svgPan = true;
581 m_frame->document()->accessSVGExtensions().startPan( 586 m_frame->document()->accessSVGExtensions().startPan(
582 m_frame->view()->rootFrameToContents(event.event().position())); 587 m_frame->view()->rootFrameToContents(
588 flooredIntPoint(event.event().positionInRootFrame())));
583 return WebInputEventResult::HandledSystem; 589 return WebInputEventResult::HandledSystem;
584 } 590 }
585 } 591 }
586 592
587 // We don't do this at the start of mouse down handling, 593 // We don't do this at the start of mouse down handling,
588 // because we don't want to do it until we know we didn't hit a widget. 594 // because we don't want to do it until we know we didn't hit a widget.
589 if (singleClick) 595 if (singleClick)
590 focusDocumentView(); 596 focusDocumentView();
591 597
592 Node* innerNode = event.innerNode(); 598 Node* innerNode = event.innerNode();
593 599
594 m_mousePressNode = innerNode; 600 m_mousePressNode = innerNode;
595 m_frame->document()->setSequentialFocusNavigationStartingPoint(innerNode); 601 m_frame->document()->setSequentialFocusNavigationStartingPoint(innerNode);
596 m_dragStartPos = event.event().position(); 602 m_dragStartPos = flooredIntPoint(event.event().positionInRootFrame());
597 603
598 bool swallowEvent = false; 604 bool swallowEvent = false;
599 m_mousePressed = true; 605 m_mousePressed = true;
600 606
601 if (event.event().clickCount() == 2) { 607 if (event.event().clickCount == 2) {
602 swallowEvent = m_frame->eventHandler() 608 swallowEvent = m_frame->eventHandler()
603 .selectionController() 609 .selectionController()
604 .handleMousePressEventDoubleClick(event); 610 .handleMousePressEventDoubleClick(event);
605 } else if (event.event().clickCount() >= 3) { 611 } else if (event.event().clickCount >= 3) {
606 swallowEvent = m_frame->eventHandler() 612 swallowEvent = m_frame->eventHandler()
607 .selectionController() 613 .selectionController()
608 .handleMousePressEventTripleClick(event); 614 .handleMousePressEventTripleClick(event);
609 } else { 615 } else {
610 swallowEvent = m_frame->eventHandler() 616 swallowEvent = m_frame->eventHandler()
611 .selectionController() 617 .selectionController()
612 .handleMousePressEventSingleClick(event); 618 .handleMousePressEventSingleClick(event);
613 } 619 }
614 620
615 m_mouseDownMayStartAutoscroll = 621 m_mouseDownMayStartAutoscroll =
(...skipping 24 matching lines...) Expand all
640 646
641 bool MouseEventManager::handleDragDropIfPossible( 647 bool MouseEventManager::handleDragDropIfPossible(
642 const GestureEventWithHitTestResults& targetedEvent) { 648 const GestureEventWithHitTestResults& targetedEvent) {
643 if (m_frame->settings() && m_frame->settings()->getTouchDragDropEnabled() && 649 if (m_frame->settings() && m_frame->settings()->getTouchDragDropEnabled() &&
644 m_frame->view()) { 650 m_frame->view()) {
645 const WebGestureEvent& gestureEvent = targetedEvent.event(); 651 const WebGestureEvent& gestureEvent = targetedEvent.event();
646 unsigned modifiers = gestureEvent.modifiers(); 652 unsigned modifiers = gestureEvent.modifiers();
647 653
648 // TODO(mustaq): Suppressing long-tap MouseEvents could break 654 // TODO(mustaq): Suppressing long-tap MouseEvents could break
649 // drag-drop. Will do separately because of the risk. crbug.com/606938. 655 // drag-drop. Will do separately because of the risk. crbug.com/606938.
650 PlatformMouseEvent mouseDownEvent( 656 WebMouseEvent mouseDownEvent(
651 gestureEvent, WebPointerProperties::Button::Left, 657 WebInputEvent::MouseDown, gestureEvent,
652 PlatformEvent::MousePressed, 1, 658 WebPointerProperties::Button::Left, 1,
653 static_cast<PlatformEvent::Modifiers>(modifiers | 659 modifiers | WebInputEvent::Modifiers::LeftButtonDown |
654 PlatformEvent::LeftButtonDown), 660 WebInputEvent::Modifiers::IsCompatibilityEventForTouch,
655 PlatformMouseEvent::FromTouch, TimeTicks::Now(), 661 TimeTicks::Now().InSeconds());
656 WebPointerProperties::PointerType::Mouse);
657 m_mouseDown = mouseDownEvent; 662 m_mouseDown = mouseDownEvent;
658 663
659 PlatformMouseEvent mouseDragEvent( 664 WebMouseEvent mouseDragEvent(
660 gestureEvent, WebPointerProperties::Button::Left, 665 WebInputEvent::MouseMove, gestureEvent,
661 PlatformEvent::MouseMoved, 1, 666 WebPointerProperties::Button::Left, 1,
662 static_cast<PlatformEvent::Modifiers>(modifiers | 667 modifiers | WebInputEvent::Modifiers::LeftButtonDown |
663 PlatformEvent::LeftButtonDown), 668 WebInputEvent::Modifiers::IsCompatibilityEventForTouch,
664 PlatformMouseEvent::FromTouch, TimeTicks::Now(), 669 TimeTicks::Now().InSeconds());
665 WebPointerProperties::PointerType::Mouse);
666 HitTestRequest request(HitTestRequest::ReadOnly); 670 HitTestRequest request(HitTestRequest::ReadOnly);
667 MouseEventWithHitTestResults mev = 671 MouseEventWithHitTestResults mev =
668 EventHandlingUtil::performMouseEventHitTest(m_frame, request, 672 EventHandlingUtil::performMouseEventHitTest(m_frame, request,
669 mouseDragEvent); 673 mouseDragEvent);
670 m_mouseDownMayStartDrag = true; 674 m_mouseDownMayStartDrag = true;
671 dragState().m_dragSrc = nullptr; 675 dragState().m_dragSrc = nullptr;
672 m_mouseDownPos = 676 m_mouseDownPos = m_frame->view()->rootFrameToContents(
673 m_frame->view()->rootFrameToContents(mouseDragEvent.position()); 677 flooredIntPoint(mouseDragEvent.positionInRootFrame()));
674 return handleDrag(mev, DragInitiator::Touch); 678 return handleDrag(mev, DragInitiator::Touch);
675 } 679 }
676 return false; 680 return false;
677 } 681 }
678 682
679 void MouseEventManager::focusDocumentView() { 683 void MouseEventManager::focusDocumentView() {
680 Page* page = m_frame->page(); 684 Page* page = m_frame->page();
681 if (!page) 685 if (!page)
682 return; 686 return;
683 page->focusController().focusDocumentView(m_frame); 687 page->focusController().focusDocumentView(m_frame);
(...skipping 10 matching lines...) Expand all
694 // is on a mouse press. The problem is the <embed> node only starts 698 // is on a mouse press. The problem is the <embed> node only starts
695 // capturing mouse events *after* m_mousePressed for the containing frame 699 // capturing mouse events *after* m_mousePressed for the containing frame
696 // has already been set to true. As a result, the frame's EventHandler 700 // has already been set to true. As a result, the frame's EventHandler
697 // never sees the mouse release event, which is supposed to reset 701 // never sees the mouse release event, which is supposed to reset
698 // m_mousePressed... so m_mousePressed ends up remaining true until the 702 // m_mousePressed... so m_mousePressed ends up remaining true until the
699 // event handler finally gets another mouse released event. Oops. 703 // event handler finally gets another mouse released event. Oops.
700 // 2. Dragging doesn't start until after a mouse press event, but a drag 704 // 2. Dragging doesn't start until after a mouse press event, but a drag
701 // that ends as a result of a mouse release does not send a mouse release 705 // that ends as a result of a mouse release does not send a mouse release
702 // event. As a result, m_mousePressed also ends up remaining true until 706 // event. As a result, m_mousePressed also ends up remaining true until
703 // the next mouse release event seen by the EventHandler. 707 // the next mouse release event seen by the EventHandler.
704 if (event.event().pointerProperties().button != 708 if (event.event().button != WebPointerProperties::Button::Left)
705 WebPointerProperties::Button::Left)
706 m_mousePressed = false; 709 m_mousePressed = false;
707 710
708 if (!m_mousePressed) 711 if (!m_mousePressed)
709 return WebInputEventResult::NotHandled; 712 return WebInputEventResult::NotHandled;
710 713
711 if (handleDrag(event, DragInitiator::Mouse)) 714 if (handleDrag(event, DragInitiator::Mouse))
712 return WebInputEventResult::HandledSystem; 715 return WebInputEventResult::HandledSystem;
713 716
714 Node* targetNode = event.innerNode(); 717 Node* targetNode = event.innerNode();
715 if (!targetNode) 718 if (!targetNode)
(...skipping 28 matching lines...) Expand all
744 controller->startAutoscrollForSelection(layoutObject); 747 controller->startAutoscrollForSelection(layoutObject);
745 m_mouseDownMayStartAutoscroll = false; 748 m_mouseDownMayStartAutoscroll = false;
746 } 749 }
747 } 750 }
748 751
749 return WebInputEventResult::HandledSystem; 752 return WebInputEventResult::HandledSystem;
750 } 753 }
751 754
752 bool MouseEventManager::handleDrag(const MouseEventWithHitTestResults& event, 755 bool MouseEventManager::handleDrag(const MouseEventWithHitTestResults& event,
753 DragInitiator initiator) { 756 DragInitiator initiator) {
754 DCHECK(event.event().type() == PlatformEvent::MouseMoved); 757 DCHECK(event.event().type() == WebInputEvent::MouseMove);
755 // Callers must protect the reference to FrameView, since this function may 758 // Callers must protect the reference to FrameView, since this function may
756 // dispatch DOM events, causing page/FrameView to go away. 759 // dispatch DOM events, causing page/FrameView to go away.
757 DCHECK(m_frame); 760 DCHECK(m_frame);
758 DCHECK(m_frame->view()); 761 DCHECK(m_frame->view());
759 if (!m_frame->page()) 762 if (!m_frame->page())
760 return false; 763 return false;
761 764
762 if (m_mouseDownMayStartDrag) { 765 if (m_mouseDownMayStartDrag) {
763 HitTestRequest request(HitTestRequest::ReadOnly); 766 HitTestRequest request(HitTestRequest::ReadOnly);
764 HitTestResult result(request, m_mouseDownPos); 767 HitTestResult result(request, m_mouseDownPos);
765 m_frame->contentLayoutItem().hitTest(result); 768 m_frame->contentLayoutItem().hitTest(result);
766 Node* node = result.innerNode(); 769 Node* node = result.innerNode();
767 if (node) { 770 if (node) {
768 DragController::SelectionDragPolicy selectionDragPolicy = 771 DragController::SelectionDragPolicy selectionDragPolicy =
769 event.event().timestamp() - m_mouseDownTimestamp < kTextDragDelay 772 TimeTicks::FromSeconds(event.event().timeStampSeconds()) -
773 m_mouseDownTimestamp <
774 kTextDragDelay
770 ? DragController::DelayedSelectionDragResolution 775 ? DragController::DelayedSelectionDragResolution
771 : DragController::ImmediateSelectionDragResolution; 776 : DragController::ImmediateSelectionDragResolution;
772 dragState().m_dragSrc = m_frame->page()->dragController().draggableNode( 777 dragState().m_dragSrc = m_frame->page()->dragController().draggableNode(
773 m_frame, node, m_mouseDownPos, selectionDragPolicy, 778 m_frame, node, m_mouseDownPos, selectionDragPolicy,
774 dragState().m_dragType); 779 dragState().m_dragType);
775 } else { 780 } else {
776 dragState().m_dragSrc = nullptr; 781 dragState().m_dragSrc = nullptr;
777 } 782 }
778 783
779 if (!dragState().m_dragSrc) 784 if (!dragState().m_dragSrc)
780 m_mouseDownMayStartDrag = false; // no element is draggable 785 m_mouseDownMayStartDrag = false; // no element is draggable
781 } 786 }
782 787
783 if (!m_mouseDownMayStartDrag) { 788 if (!m_mouseDownMayStartDrag) {
784 return initiator == DragInitiator::Mouse && 789 return initiator == DragInitiator::Mouse &&
785 !m_frame->eventHandler() 790 !m_frame->eventHandler()
786 .selectionController() 791 .selectionController()
787 .mouseDownMayStartSelect() && 792 .mouseDownMayStartSelect() &&
788 !m_mouseDownMayStartAutoscroll; 793 !m_mouseDownMayStartAutoscroll;
789 } 794 }
790 795
791 // We are starting a text/image/url drag, so the cursor should be an arrow 796 // We are starting a text/image/url drag, so the cursor should be an arrow
792 // FIXME <rdar://7577595>: Custom cursors aren't supported during drag and 797 // FIXME <rdar://7577595>: Custom cursors aren't supported during drag and
793 // drop (default to pointer). 798 // drop (default to pointer).
794 m_frame->view()->setCursor(pointerCursor()); 799 m_frame->view()->setCursor(pointerCursor());
795 800
796 if (initiator == DragInitiator::Mouse && 801 if (initiator == DragInitiator::Mouse &&
797 !dragThresholdExceeded(event.event().position())) { 802 !dragThresholdExceeded(
803 flooredIntPoint(event.event().positionInRootFrame()))) {
798 dragState().m_dragSrc = nullptr; 804 dragState().m_dragSrc = nullptr;
799 return true; 805 return true;
800 } 806 }
801 807
802 // Once we're past the drag threshold, we don't want to treat this gesture as 808 // Once we're past the drag threshold, we don't want to treat this gesture as
803 // a click. 809 // a click.
804 invalidateClick(); 810 invalidateClick();
805 811
806 if (!tryStartDrag(event)) { 812 if (!tryStartDrag(event)) {
807 // Something failed to start the drag, clean up. 813 // Something failed to start the drag, clean up.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 dispatchDragSrcEvent(EventTypeNames::dragend, event.event()); 866 dispatchDragSrcEvent(EventTypeNames::dragend, event.event());
861 } 867 }
862 868
863 return false; 869 return false;
864 } 870 }
865 871
866 // Returns if we should continue "default processing", i.e., whether 872 // Returns if we should continue "default processing", i.e., whether
867 // eventhandler canceled. 873 // eventhandler canceled.
868 WebInputEventResult MouseEventManager::dispatchDragSrcEvent( 874 WebInputEventResult MouseEventManager::dispatchDragSrcEvent(
869 const AtomicString& eventType, 875 const AtomicString& eventType,
870 const PlatformMouseEvent& event) { 876 const WebMouseEvent& event) {
871 return dispatchDragEvent(eventType, dragState().m_dragSrc.get(), event, 877 return dispatchDragEvent(eventType, dragState().m_dragSrc.get(), event,
872 dragState().m_dragDataTransfer.get()); 878 dragState().m_dragDataTransfer.get());
873 } 879 }
874 880
875 WebInputEventResult MouseEventManager::dispatchDragEvent( 881 WebInputEventResult MouseEventManager::dispatchDragEvent(
876 const AtomicString& eventType, 882 const AtomicString& eventType,
877 Node* dragTarget, 883 Node* dragTarget,
878 const PlatformMouseEvent& event, 884 const WebMouseEvent& event,
879 DataTransfer* dataTransfer) { 885 DataTransfer* dataTransfer) {
880 FrameView* view = m_frame->view(); 886 FrameView* view = m_frame->view();
881 887
882 // FIXME: We might want to dispatch a dragleave even if the view is gone. 888 // FIXME: We might want to dispatch a dragleave even if the view is gone.
883 if (!view) 889 if (!view)
884 return WebInputEventResult::NotHandled; 890 return WebInputEventResult::NotHandled;
885 891
886 const bool cancelable = eventType != EventTypeNames::dragleave && 892 const bool cancelable = eventType != EventTypeNames::dragleave &&
887 eventType != EventTypeNames::dragend; 893 eventType != EventTypeNames::dragend;
888 894
895 IntPoint position = flooredIntPoint(event.positionInRootFrame());
896 IntPoint movement = flooredIntPoint(event.movementInRootFrame());
889 DragEvent* me = DragEvent::create( 897 DragEvent* me = DragEvent::create(
890 eventType, true, cancelable, m_frame->document()->domWindow(), 0, 898 eventType, true, cancelable, m_frame->document()->domWindow(), 0,
891 event.globalPosition().x(), event.globalPosition().y(), 899 event.globalX, event.globalY, position.x(), position.y(), movement.x(),
892 event.position().x(), event.position().y(), event.movementDelta().x(), 900 movement.y(), static_cast<PlatformEvent::Modifiers>(event.modifiers()), 0,
893 event.movementDelta().y(), event.getModifiers(), 0, 901 MouseEvent::platformModifiersToButtons(event.modifiers()), nullptr,
894 MouseEvent::platformModifiersToButtons(event.getModifiers()), nullptr, 902 TimeTicks::FromSeconds(event.timeStampSeconds()), dataTransfer,
895 event.timestamp(), dataTransfer, event.getSyntheticEventType()); 903 event.fromTouch() ? MouseEvent::FromTouch
904 : MouseEvent::RealOrIndistinguishable);
896 905
897 return EventHandlingUtil::toWebInputEventResult( 906 return EventHandlingUtil::toWebInputEventResult(
898 dragTarget->dispatchEvent(me)); 907 dragTarget->dispatchEvent(me));
899 } 908 }
900 909
901 void MouseEventManager::clearDragDataTransfer() { 910 void MouseEventManager::clearDragDataTransfer() {
902 if (dragState().m_dragDataTransfer) { 911 if (dragState().m_dragDataTransfer) {
903 dragState().m_dragDataTransfer->clearDragImage(); 912 dragState().m_dragDataTransfer->clearDragImage();
904 dragState().m_dragDataTransfer->setAccessPolicy(DataTransferNumb); 913 dragState().m_dragDataTransfer->setAccessPolicy(DataTransferNumb);
905 } 914 }
906 } 915 }
907 916
908 void MouseEventManager::dragSourceEndedAt(const PlatformMouseEvent& event, 917 void MouseEventManager::dragSourceEndedAt(const WebMouseEvent& event,
909 DragOperation operation) { 918 DragOperation operation) {
910 if (dragState().m_dragSrc) { 919 if (dragState().m_dragSrc) {
911 dragState().m_dragDataTransfer->setDestinationOperation(operation); 920 dragState().m_dragDataTransfer->setDestinationOperation(operation);
912 // The return value is ignored because dragend is not cancelable. 921 // The return value is ignored because dragend is not cancelable.
913 dispatchDragSrcEvent(EventTypeNames::dragend, event); 922 dispatchDragSrcEvent(EventTypeNames::dragend, event);
914 } 923 }
915 clearDragDataTransfer(); 924 clearDragDataTransfer();
916 dragState().m_dragSrc = nullptr; 925 dragState().m_dragSrc = nullptr;
917 // In case the drag was ended due to an escape key press we need to ensure 926 // In case the drag was ended due to an escape key press we need to ensure
918 // that consecutive mousemove events don't reinitiate the drag and drop. 927 // that consecutive mousemove events don't reinitiate the drag and drop.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 1003
995 void MouseEventManager::setClickCount(int clickCount) { 1004 void MouseEventManager::setClickCount(int clickCount) {
996 m_clickCount = clickCount; 1005 m_clickCount = clickCount;
997 } 1006 }
998 1007
999 bool MouseEventManager::mouseDownMayStartDrag() { 1008 bool MouseEventManager::mouseDownMayStartDrag() {
1000 return m_mouseDownMayStartDrag; 1009 return m_mouseDownMayStartDrag;
1001 } 1010 }
1002 1011
1003 } // namespace blink 1012 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/MouseEventManager.h ('k') | third_party/WebKit/Source/core/input/PointerEventManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698