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 "config.h" | 5 #include "config.h" |
6 #include "core/events/PointerEvent.h" | 6 #include "core/events/PointerEvent.h" |
7 | 7 |
8 #include "core/dom/Element.h" | 8 #include "core/dom/Element.h" |
9 #include "core/events/EventDispatcher.h" | 9 #include "core/events/EventDispatcher.h" |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 } | 26 } |
27 ASSERT_NOT_REACHED(); | 27 ASSERT_NOT_REACHED(); |
28 return ""; | 28 return ""; |
29 } | 29 } |
30 | 30 |
31 } | 31 } |
32 | 32 |
33 PassRefPtrWillBeRawPtr<PointerEvent> PointerEvent::create(const AtomicString& ty
pe, | 33 PassRefPtrWillBeRawPtr<PointerEvent> PointerEvent::create(const AtomicString& ty
pe, |
34 const bool isPrimary, const PlatformMouseEvent& mouseEvent, | 34 const bool isPrimary, const PlatformMouseEvent& mouseEvent, |
35 PassRefPtrWillBeRawPtr<Node> relatedTarget, | 35 PassRefPtrWillBeRawPtr<Node> relatedTarget, |
36 PassRefPtrWillBeRawPtr<AbstractView> view) | 36 PassRefPtrWillBeRawPtr<AbstractView> view, const unsigned pointerId) |
37 { | 37 { |
38 PointerEventInit pointerEventInit; | 38 PointerEventInit pointerEventInit; |
39 | 39 |
40 // TODO(crbug.com/537319): Define a constant somewhere for mouse id. | 40 pointerEventInit.setPointerId(pointerId); |
41 pointerEventInit.setPointerId(0); | |
42 | |
43 pointerEventInit.setPointerType(pointerTypeNameForWebPointPointerType(WebPoi
nterProperties::PointerType::Mouse)); | 41 pointerEventInit.setPointerType(pointerTypeNameForWebPointPointerType(WebPoi
nterProperties::PointerType::Mouse)); |
44 pointerEventInit.setIsPrimary(true); | 42 pointerEventInit.setIsPrimary(isPrimary); |
45 | 43 |
46 pointerEventInit.setScreenX(mouseEvent.globalPosition().x()); | 44 pointerEventInit.setScreenX(mouseEvent.globalPosition().x()); |
47 pointerEventInit.setScreenY(mouseEvent.globalPosition().y()); | 45 pointerEventInit.setScreenY(mouseEvent.globalPosition().y()); |
48 pointerEventInit.setClientX(mouseEvent.position().x()); | 46 pointerEventInit.setClientX(mouseEvent.position().x()); |
49 pointerEventInit.setClientY(mouseEvent.position().y()); | 47 pointerEventInit.setClientY(mouseEvent.position().y()); |
50 | 48 |
51 pointerEventInit.setButton(mouseEvent.button()); | 49 pointerEventInit.setButton(mouseEvent.button()); |
52 pointerEventInit.setButtons(MouseEvent::platformModifiersToButtons(mouseEven
t.modifiers())); | 50 pointerEventInit.setButtons(MouseEvent::platformModifiersToButtons(mouseEven
t.modifiers())); |
53 | 51 |
54 UIEventWithKeyState::setFromPlatformModifiers(pointerEventInit, mouseEvent.m
odifiers()); | 52 UIEventWithKeyState::setFromPlatformModifiers(pointerEventInit, mouseEvent.m
odifiers()); |
55 | 53 |
56 pointerEventInit.setBubbles(type != EventTypeNames::pointerenter | 54 pointerEventInit.setBubbles(type != EventTypeNames::pointerenter |
57 && type != EventTypeNames::pointerleave); | 55 && type != EventTypeNames::pointerleave); |
58 pointerEventInit.setCancelable(type != EventTypeNames::pointerenter | 56 pointerEventInit.setCancelable(type != EventTypeNames::pointerenter |
59 && type != EventTypeNames::pointerleave && type != EventTypeNames::point
ercancel); | 57 && type != EventTypeNames::pointerleave && type != EventTypeNames::point
ercancel); |
60 | 58 |
61 pointerEventInit.setView(view); | 59 pointerEventInit.setView(view); |
62 if (relatedTarget) | 60 if (relatedTarget) |
63 pointerEventInit.setRelatedTarget(relatedTarget); | 61 pointerEventInit.setRelatedTarget(relatedTarget); |
64 | 62 |
65 return PointerEvent::create(type, pointerEventInit); | 63 return PointerEvent::create(type, pointerEventInit); |
66 } | 64 } |
67 | 65 |
68 PassRefPtrWillBeRawPtr<PointerEvent> PointerEvent::create(const AtomicString& ty
pe, | 66 PassRefPtrWillBeRawPtr<PointerEvent> PointerEvent::create(const AtomicString& ty
pe, |
69 const bool isPrimary, const PlatformTouchPoint& touchPoint, | 67 const bool isPrimary, const PlatformTouchPoint& touchPoint, |
70 PlatformEvent::Modifiers modifiers, | 68 PlatformEvent::Modifiers modifiers, |
71 const double width, const double height, | 69 const double width, const double height, |
72 const double clientX, const double clientY) | 70 const double clientX, const double clientY, |
| 71 const unsigned pointerId) |
73 { | 72 { |
74 const unsigned& pointerId = touchPoint.id(); | |
75 const PlatformTouchPoint::State pointState = touchPoint.state(); | 73 const PlatformTouchPoint::State pointState = touchPoint.state(); |
76 | 74 |
77 bool pointerReleasedOrCancelled = pointState == PlatformTouchPoint::TouchRel
eased | 75 bool pointerReleasedOrCancelled = pointState == PlatformTouchPoint::TouchRel
eased |
78 || pointState == PlatformTouchPoint::TouchCancelled; | 76 || pointState == PlatformTouchPoint::TouchCancelled; |
79 const WebPointerProperties::PointerType pointerType = touchPoint.pointerProp
erties().pointerType; | 77 const WebPointerProperties::PointerType pointerType = touchPoint.pointerProp
erties().pointerType; |
80 const String& pointerTypeStr = pointerTypeNameForWebPointPointerType(pointer
Type); | 78 const String& pointerTypeStr = pointerTypeNameForWebPointPointerType(pointer
Type); |
81 | 79 |
82 bool isEnterOrLeave = false; | 80 bool isEnterOrLeave = false; |
83 | 81 |
84 PointerEventInit pointerEventInit; | 82 PointerEventInit pointerEventInit; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 ASSERT(!event().target() || event().target() != event().relatedTarget()); | 188 ASSERT(!event().target() || event().target() != event().relatedTarget()); |
191 | 189 |
192 EventTarget* relatedTarget = event().relatedTarget(); | 190 EventTarget* relatedTarget = event().relatedTarget(); |
193 event().eventPath().adjustForRelatedTarget(dispatcher.node(), relatedTarget)
; | 191 event().eventPath().adjustForRelatedTarget(dispatcher.node(), relatedTarget)
; |
194 | 192 |
195 dispatcher.dispatch(); | 193 dispatcher.dispatch(); |
196 return !event().defaultHandled() && !event().defaultPrevented(); | 194 return !event().defaultHandled() && !event().defaultPrevented(); |
197 } | 195 } |
198 | 196 |
199 } // namespace blink | 197 } // namespace blink |
OLD | NEW |