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

Side by Side Diff: third_party/WebKit/Source/core/events/MouseEvent.cpp

Issue 1654653002: Canvas2d: Implement rerouting event by hit region's control. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix bot errors 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
1 /* 1 /*
2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 bool isMouseEnterOrLeave = eventType == EventTypeNames::mouseenter || eventT ype == EventTypeNames::mouseleave; 44 bool isMouseEnterOrLeave = eventType == EventTypeNames::mouseenter || eventT ype == EventTypeNames::mouseleave;
45 bool isCancelable = !isMouseEnterOrLeave; 45 bool isCancelable = !isMouseEnterOrLeave;
46 bool isBubbling = !isMouseEnterOrLeave; 46 bool isBubbling = !isMouseEnterOrLeave;
47 47
48 return MouseEvent::create( 48 return MouseEvent::create(
49 eventType, isBubbling, isCancelable, view, 49 eventType, isBubbling, isCancelable, view,
50 detail, event.globalPosition().x(), event.globalPosition().y(), event.po sition().x(), event.position().y(), 50 detail, event.globalPosition().x(), event.globalPosition().y(), event.po sition().x(), event.position().y(),
51 event.movementDelta().x(), event.movementDelta().y(), 51 event.movementDelta().x(), event.movementDelta().y(),
52 event.getModifiers(), event.button(), 52 event.getModifiers(), event.button(),
53 platformModifiersToButtons(event.getModifiers()), 53 platformModifiersToButtons(event.getModifiers()),
54 relatedTarget, event.timestamp(), event.getSyntheticEventType()); 54 relatedTarget, event.timestamp(), event.getSyntheticEventType(), event.r egion());
55 } 55 }
56 56
57 PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view, 57 PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view,
58 int detail, int screenX, int screenY, int windowX, int windowY, 58 int detail, int screenX, int screenY, int windowX, int windowY,
59 int movementX, int movementY, 59 int movementX, int movementY,
60 PlatformEvent::Modifiers modifiers, 60 PlatformEvent::Modifiers modifiers,
61 short button, unsigned short buttons, 61 short button, unsigned short buttons,
62 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, 62 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget,
63 double platformTimeStamp, 63 double platformTimeStamp,
64 PlatformMouseEvent::SyntheticEventType syntheticEventType) 64 PlatformMouseEvent::SyntheticEventType syntheticEventType,
65 const String& region)
65 { 66 {
66 return adoptRefWillBeNoop(new MouseEvent(type, canBubble, cancelable, view, 67 return adoptRefWillBeNoop(new MouseEvent(type, canBubble, cancelable, view,
67 detail, screenX, screenY, windowX, windowY, 68 detail, screenX, screenY, windowX, windowY,
68 movementX, movementY, 69 movementX, movementY,
69 modifiers, button, buttons, relatedTarget, platformTimeStamp, syntheticE ventType)); 70 modifiers, button, buttons, relatedTarget, platformTimeStamp, syntheticE ventType, region));
70 } 71 }
71 72
72 PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& eventT ype, PassRefPtrWillBeRawPtr<AbstractView> view, PassRefPtrWillBeRawPtr<Event> un derlyingEvent, SimulatedClickCreationScope creationScope) 73 PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& eventT ype, PassRefPtrWillBeRawPtr<AbstractView> view, PassRefPtrWillBeRawPtr<Event> un derlyingEvent, SimulatedClickCreationScope creationScope)
73 { 74 {
74 PlatformEvent::Modifiers modifiers = PlatformEvent::NoModifiers; 75 PlatformEvent::Modifiers modifiers = PlatformEvent::NoModifiers;
75 if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEve nt.get())) { 76 if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEve nt.get())) {
76 modifiers = keyStateEvent->modifiers(); 77 modifiers = keyStateEvent->modifiers();
77 } 78 }
78 79
79 PlatformMouseEvent::SyntheticEventType syntheticType = PlatformMouseEvent::P ositionless; 80 PlatformMouseEvent::SyntheticEventType syntheticType = PlatformMouseEvent::P ositionless;
80 int screenX = 0; 81 int screenX = 0;
81 int screenY = 0; 82 int screenY = 0;
82 if (underlyingEvent && underlyingEvent->isMouseEvent()) { 83 if (underlyingEvent && underlyingEvent->isMouseEvent()) {
83 syntheticType = PlatformMouseEvent::RealOrIndistinguishable; 84 syntheticType = PlatformMouseEvent::RealOrIndistinguishable;
84 MouseEvent* mouseEvent = toMouseEvent(underlyingEvent.get()); 85 MouseEvent* mouseEvent = toMouseEvent(underlyingEvent.get());
85 screenX = mouseEvent->screenLocation().x(); 86 screenX = mouseEvent->screenLocation().x();
86 screenY = mouseEvent->screenLocation().y(); 87 screenY = mouseEvent->screenLocation().y();
87 } 88 }
88 89
89 double timestamp = underlyingEvent ? underlyingEvent->platformTimeStamp() : monotonicallyIncreasingTime(); 90 double timestamp = underlyingEvent ? underlyingEvent->platformTimeStamp() : monotonicallyIncreasingTime();
90 RefPtrWillBeRawPtr<MouseEvent> createdEvent = MouseEvent::create(eventType, true, true, view, 91 RefPtrWillBeRawPtr<MouseEvent> createdEvent = MouseEvent::create(eventType, true, true, view,
91 0, screenX, screenY, 0, 0, 0, 0, modifiers, 0, 0, nullptr, 92 0, screenX, screenY, 0, 0, 0, 0, modifiers, 0, 0, nullptr,
92 timestamp, syntheticType); 93 timestamp, syntheticType, String());
93 94
94 createdEvent->setTrusted(creationScope == SimulatedClickCreationScope::FromU serAgent); 95 createdEvent->setTrusted(creationScope == SimulatedClickCreationScope::FromU serAgent);
95 createdEvent->setUnderlyingEvent(underlyingEvent); 96 createdEvent->setUnderlyingEvent(underlyingEvent);
96 if (syntheticType == PlatformMouseEvent::RealOrIndistinguishable) { 97 if (syntheticType == PlatformMouseEvent::RealOrIndistinguishable) {
97 MouseEvent* mouseEvent = toMouseEvent(createdEvent->underlyingEvent()); 98 MouseEvent* mouseEvent = toMouseEvent(createdEvent->underlyingEvent());
98 createdEvent->initCoordinates(mouseEvent->clientLocation()); 99 createdEvent->initCoordinates(mouseEvent->clientLocation());
99 } 100 }
100 101
101 return createdEvent.release(); 102 return createdEvent.release();
102 } 103 }
103 104
104 MouseEvent::MouseEvent() 105 MouseEvent::MouseEvent()
105 : m_button(0) 106 : m_button(0)
106 , m_buttons(0) 107 , m_buttons(0)
107 , m_relatedTarget(nullptr) 108 , m_relatedTarget(nullptr)
108 , m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable) 109 , m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable)
109 { 110 {
110 } 111 }
111 112
112 MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cance lable, PassRefPtrWillBeRawPtr<AbstractView> view, 113 MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cance lable, PassRefPtrWillBeRawPtr<AbstractView> view,
113 int detail, int screenX, int screenY, int windowX, int windowY, 114 int detail, int screenX, int screenY, int windowX, int windowY,
114 int movementX, int movementY, 115 int movementX, int movementY,
115 PlatformEvent::Modifiers modifiers, 116 PlatformEvent::Modifiers modifiers,
116 short button, unsigned short buttons, 117 short button, unsigned short buttons,
117 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, 118 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget,
118 double platformTimeStamp, 119 double platformTimeStamp,
119 PlatformMouseEvent::SyntheticEventType syntheticEventType) 120 PlatformMouseEvent::SyntheticEventType syntheticEventType,
121 const String& region)
120 : MouseRelatedEvent(eventType, canBubble, cancelable, view, detail, IntPoint (screenX, screenY), 122 : MouseRelatedEvent(eventType, canBubble, cancelable, view, detail, IntPoint (screenX, screenY),
121 IntPoint(windowX, windowY), IntPoint(movementX, movementY), modifiers, 123 IntPoint(windowX, windowY), IntPoint(movementX, movementY), modifiers,
122 platformTimeStamp, 124 platformTimeStamp,
123 syntheticEventType == PlatformMouseEvent::Positionless ? PositionType::P ositionless : PositionType::Position, 125 syntheticEventType == PlatformMouseEvent::Positionless ? PositionType::P ositionless : PositionType::Position,
124 syntheticEventType == PlatformMouseEvent::FromTouch ? InputDeviceCapabil ities::firesTouchEventsSourceCapabilities() : InputDeviceCapabilities::doesntFir eTouchEventsSourceCapabilities()) 126 syntheticEventType == PlatformMouseEvent::FromTouch ? InputDeviceCapabil ities::firesTouchEventsSourceCapabilities() : InputDeviceCapabilities::doesntFir eTouchEventsSourceCapabilities())
125 , m_button(button) 127 , m_button(button)
126 , m_buttons(buttons) 128 , m_buttons(buttons)
127 , m_relatedTarget(relatedTarget) 129 , m_relatedTarget(relatedTarget)
128 , m_syntheticEventType(syntheticEventType) 130 , m_syntheticEventType(syntheticEventType)
131 , m_region(region)
129 { 132 {
130 } 133 }
131 134
132 MouseEvent::MouseEvent(const AtomicString& eventType, const MouseEventInit& init ializer) 135 MouseEvent::MouseEvent(const AtomicString& eventType, const MouseEventInit& init ializer)
133 : MouseRelatedEvent(eventType, initializer) 136 : MouseRelatedEvent(eventType, initializer)
134 , m_button(initializer.button()) 137 , m_button(initializer.button())
135 , m_buttons(initializer.buttons()) 138 , m_buttons(initializer.buttons())
136 , m_relatedTarget(initializer.relatedTarget()) 139 , m_relatedTarget(initializer.relatedTarget())
137 , m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable) 140 , m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable)
141 , m_region(initializer.region())
138 { 142 {
139 } 143 }
140 144
141 MouseEvent::~MouseEvent() 145 MouseEvent::~MouseEvent()
142 { 146 {
143 } 147 }
144 148
145 unsigned short MouseEvent::platformModifiersToButtons(unsigned modifiers) 149 unsigned short MouseEvent::platformModifiersToButtons(unsigned modifiers)
146 { 150 {
147 unsigned short buttons = 0; 151 unsigned short buttons = 0;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 doubleClickEvent->setTrusted(mouseEvent.isTrusted()); 306 doubleClickEvent->setTrusted(mouseEvent.isTrusted());
303 if (mouseEvent.defaultHandled()) 307 if (mouseEvent.defaultHandled())
304 doubleClickEvent->setDefaultHandled(); 308 doubleClickEvent->setDefaultHandled();
305 DispatchEventResult doubleClickDispatchResult = EventDispatcher::dispatchEve nt(dispatcher.node(), MouseEventDispatchMediator::create(doubleClickEvent)); 309 DispatchEventResult doubleClickDispatchResult = EventDispatcher::dispatchEve nt(dispatcher.node(), MouseEventDispatchMediator::create(doubleClickEvent));
306 if (doubleClickDispatchResult != DispatchEventResult::NotCanceled) 310 if (doubleClickDispatchResult != DispatchEventResult::NotCanceled)
307 return doubleClickDispatchResult; 311 return doubleClickDispatchResult;
308 return dispatchResult; 312 return dispatchResult;
309 } 313 }
310 314
311 } // namespace blink 315 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698