| 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 21 matching lines...) Expand all Loading... |
| 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) |
| 37 { | 37 { |
| 38 PointerEventInit pointerEventInit; | 38 PointerEventInit pointerEventInit; |
| 39 | 39 |
| 40 // TODO(crbug.com/537319): Define a constant somewhere for mouse id. | 40 // TODO(crbug.com/537319): Define a constant somewhere for mouse id. |
| 41 pointerEventInit.setPointerId(0); | 41 pointerEventInit.setPointerId(0); |
| 42 | 42 pointerEventInit.setPointerType( |
| 43 pointerEventInit.setPointerType(pointerTypeNameForWebPointPointerType(WebPoi
nterProperties::PointerType::Mouse)); | 43 pointerTypeNameForWebPointPointerType(mouseEvent.pointerProperties().poi
nterType)); |
| 44 pointerEventInit.setIsPrimary(true); | 44 pointerEventInit.setIsPrimary(true); |
| 45 | 45 |
| 46 pointerEventInit.setScreenX(mouseEvent.globalPosition().x()); | 46 pointerEventInit.setScreenX(mouseEvent.globalPosition().x()); |
| 47 pointerEventInit.setScreenY(mouseEvent.globalPosition().y()); | 47 pointerEventInit.setScreenY(mouseEvent.globalPosition().y()); |
| 48 pointerEventInit.setClientX(mouseEvent.position().x()); | 48 pointerEventInit.setClientX(mouseEvent.position().x()); |
| 49 pointerEventInit.setClientY(mouseEvent.position().y()); | 49 pointerEventInit.setClientY(mouseEvent.position().y()); |
| 50 | 50 |
| 51 pointerEventInit.setButton(mouseEvent.button()); | 51 pointerEventInit.setButton(mouseEvent.button()); |
| 52 pointerEventInit.setButtons(MouseEvent::platformModifiersToButtons(mouseEven
t.modifiers())); | 52 pointerEventInit.setButtons(MouseEvent::platformModifiersToButtons(mouseEven
t.modifiers())); |
| 53 | 53 |
| 54 pointerEventInit.setPressure(mouseEvent.pointerProperties().force); |
| 55 pointerEventInit.setTiltX(mouseEvent.pointerProperties().tiltX); |
| 56 pointerEventInit.setTiltY(mouseEvent.pointerProperties().tiltY); |
| 57 |
| 54 UIEventWithKeyState::setFromPlatformModifiers(pointerEventInit, mouseEvent.m
odifiers()); | 58 UIEventWithKeyState::setFromPlatformModifiers(pointerEventInit, mouseEvent.m
odifiers()); |
| 55 | 59 |
| 56 pointerEventInit.setBubbles(type != EventTypeNames::pointerenter | 60 pointerEventInit.setBubbles(type != EventTypeNames::pointerenter |
| 57 && type != EventTypeNames::pointerleave); | 61 && type != EventTypeNames::pointerleave); |
| 58 pointerEventInit.setCancelable(type != EventTypeNames::pointerenter | 62 pointerEventInit.setCancelable(type != EventTypeNames::pointerenter |
| 59 && type != EventTypeNames::pointerleave && type != EventTypeNames::point
ercancel); | 63 && type != EventTypeNames::pointerleave && type != EventTypeNames::point
ercancel); |
| 60 | 64 |
| 61 pointerEventInit.setView(view); | 65 pointerEventInit.setView(view); |
| 62 if (relatedTarget) | 66 if (relatedTarget) |
| 63 pointerEventInit.setRelatedTarget(relatedTarget); | 67 pointerEventInit.setRelatedTarget(relatedTarget); |
| 64 | 68 |
| 65 return PointerEvent::create(type, pointerEventInit); | 69 return PointerEvent::create(type, pointerEventInit); |
| 66 } | 70 } |
| 67 | 71 |
| 68 PassRefPtrWillBeRawPtr<PointerEvent> PointerEvent::create(const AtomicString& ty
pe, | 72 PassRefPtrWillBeRawPtr<PointerEvent> PointerEvent::create(const AtomicString& ty
pe, |
| 69 const bool isPrimary, const PlatformTouchPoint& touchPoint, | 73 const bool isPrimary, const PlatformTouchPoint& touchPoint, |
| 70 PlatformEvent::Modifiers modifiers, | 74 PlatformEvent::Modifiers modifiers, |
| 71 const double width, const double height, | 75 const double width, const double height, |
| 72 const double clientX, const double clientY) | 76 const double clientX, const double clientY) |
| 73 { | 77 { |
| 74 const unsigned& pointerId = touchPoint.id(); | 78 const unsigned& pointerId = touchPoint.id(); |
| 75 const PlatformTouchPoint::State pointState = touchPoint.state(); | 79 const PlatformTouchPoint::State pointState = touchPoint.state(); |
| 76 | 80 |
| 77 bool pointerReleasedOrCancelled = pointState == PlatformTouchPoint::TouchRel
eased | 81 bool pointerReleasedOrCancelled = pointState == PlatformTouchPoint::TouchRel
eased |
| 78 || pointState == PlatformTouchPoint::TouchCancelled; | 82 || pointState == PlatformTouchPoint::TouchCancelled; |
| 79 const WebPointerProperties::PointerType pointerType = touchPoint.pointerProp
erties().pointerType; | |
| 80 const String& pointerTypeStr = pointerTypeNameForWebPointPointerType(pointer
Type); | |
| 81 | 83 |
| 82 bool isEnterOrLeave = false; | 84 bool isEnterOrLeave = false; |
| 83 | 85 |
| 84 PointerEventInit pointerEventInit; | 86 PointerEventInit pointerEventInit; |
| 85 pointerEventInit.setPointerId(pointerId); | 87 pointerEventInit.setPointerId(pointerId); |
| 88 pointerEventInit.setPointerType( |
| 89 pointerTypeNameForWebPointPointerType(touchPoint.pointerProperties().poi
nterType)); |
| 90 pointerEventInit.setIsPrimary(isPrimary); |
| 91 |
| 86 pointerEventInit.setWidth(width); | 92 pointerEventInit.setWidth(width); |
| 87 pointerEventInit.setHeight(height); | 93 pointerEventInit.setHeight(height); |
| 88 pointerEventInit.setPressure(touchPoint.force()); | 94 pointerEventInit.setPressure(touchPoint.force()); |
| 89 pointerEventInit.setTiltX(touchPoint.pointerProperties().tiltX); | 95 pointerEventInit.setTiltX(touchPoint.pointerProperties().tiltX); |
| 90 pointerEventInit.setTiltY(touchPoint.pointerProperties().tiltY); | 96 pointerEventInit.setTiltY(touchPoint.pointerProperties().tiltY); |
| 91 pointerEventInit.setPointerType(pointerTypeStr); | |
| 92 pointerEventInit.setIsPrimary(isPrimary); | |
| 93 pointerEventInit.setScreenX(touchPoint.screenPos().x()); | 97 pointerEventInit.setScreenX(touchPoint.screenPos().x()); |
| 94 pointerEventInit.setScreenY(touchPoint.screenPos().y()); | 98 pointerEventInit.setScreenY(touchPoint.screenPos().y()); |
| 95 pointerEventInit.setClientX(clientX); | 99 pointerEventInit.setClientX(clientX); |
| 96 pointerEventInit.setClientY(clientY); | 100 pointerEventInit.setClientY(clientY); |
| 97 pointerEventInit.setButton(0); | 101 pointerEventInit.setButton(0); |
| 98 pointerEventInit.setButtons(pointerReleasedOrCancelled ? 0 : 1); | 102 pointerEventInit.setButtons(pointerReleasedOrCancelled ? 0 : 1); |
| 99 | 103 |
| 100 UIEventWithKeyState::setFromPlatformModifiers(pointerEventInit, modifiers); | 104 UIEventWithKeyState::setFromPlatformModifiers(pointerEventInit, modifiers); |
| 101 | 105 |
| 102 pointerEventInit.setBubbles(!isEnterOrLeave); | 106 pointerEventInit.setBubbles(!isEnterOrLeave); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 ASSERT(!event().target() || event().target() != event().relatedTarget()); | 194 ASSERT(!event().target() || event().target() != event().relatedTarget()); |
| 191 | 195 |
| 192 EventTarget* relatedTarget = event().relatedTarget(); | 196 EventTarget* relatedTarget = event().relatedTarget(); |
| 193 event().eventPath().adjustForRelatedTarget(dispatcher.node(), relatedTarget)
; | 197 event().eventPath().adjustForRelatedTarget(dispatcher.node(), relatedTarget)
; |
| 194 | 198 |
| 195 dispatcher.dispatch(); | 199 dispatcher.dispatch(); |
| 196 return !event().defaultHandled() && !event().defaultPrevented(); | 200 return !event().defaultHandled() && !event().defaultPrevented(); |
| 197 } | 201 } |
| 198 | 202 |
| 199 } // namespace blink | 203 } // namespace blink |
| OLD | NEW |