Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/events/PointerEventFactory.h" | 5 #include "core/events/PointerEventFactory.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "platform/geometry/FloatSize.h" | 8 #include "platform/geometry/FloatSize.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 const AtomicString& mouseEventName, | 212 const AtomicString& mouseEventName, |
| 213 const PlatformMouseEvent& mouseEvent, | 213 const PlatformMouseEvent& mouseEvent, |
| 214 const Vector<PlatformMouseEvent>& coalescedMouseEvents, | 214 const Vector<PlatformMouseEvent>& coalescedMouseEvents, |
| 215 LocalDOMWindow* view) { | 215 LocalDOMWindow* view) { |
| 216 DCHECK(mouseEventName == EventTypeNames::mousemove || | 216 DCHECK(mouseEventName == EventTypeNames::mousemove || |
| 217 mouseEventName == EventTypeNames::mousedown || | 217 mouseEventName == EventTypeNames::mousedown || |
| 218 mouseEventName == EventTypeNames::mouseup); | 218 mouseEventName == EventTypeNames::mouseup); |
| 219 | 219 |
| 220 AtomicString pointerEventName = | 220 AtomicString pointerEventName = |
| 221 pointerEventNameForMouseEventName(mouseEventName); | 221 pointerEventNameForMouseEventName(mouseEventName); |
| 222 DCHECK(pointerEventName == EventTypeNames::pointermove || | |
| 223 coalescedMouseEvents.isEmpty()); | |
| 224 | 222 |
| 225 unsigned buttons = | 223 unsigned buttons = |
| 226 MouseEvent::platformModifiersToButtons(mouseEvent.getModifiers()); | 224 MouseEvent::platformModifiersToButtons(mouseEvent.getModifiers()); |
| 227 PointerEventInit pointerEventInit; | 225 PointerEventInit pointerEventInit; |
| 228 | 226 |
| 229 setIdTypeButtons(pointerEventInit, mouseEvent.pointerProperties(), buttons); | 227 setIdTypeButtons(pointerEventInit, mouseEvent.pointerProperties(), buttons); |
| 230 setEventSpecificFields(pointerEventInit, pointerEventName); | 228 setEventSpecificFields(pointerEventInit, pointerEventName); |
| 231 | 229 |
| 232 if (pointerEventName == EventTypeNames::pointerdown || | 230 if (pointerEventName == EventTypeNames::pointerdown || |
| 233 pointerEventName == EventTypeNames::pointerup) { | 231 pointerEventName == EventTypeNames::pointerup) { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 252 (buttons & | 250 (buttons & |
| 253 ~buttonToButtonsBitfield(mouseEvent.pointerProperties().button)) != | 251 ~buttonToButtonsBitfield(mouseEvent.pointerProperties().button)) != |
| 254 0) || | 252 0) || |
| 255 (pointerEventName == EventTypeNames::pointerup && buttons != 0)) | 253 (pointerEventName == EventTypeNames::pointerup && buttons != 0)) |
| 256 pointerEventName = EventTypeNames::pointermove; | 254 pointerEventName = EventTypeNames::pointermove; |
| 257 | 255 |
| 258 pointerEventInit.setView(view); | 256 pointerEventInit.setView(view); |
| 259 | 257 |
| 260 updateMousePointerEventInit(mouseEvent, view, &pointerEventInit); | 258 updateMousePointerEventInit(mouseEvent, view, &pointerEventInit); |
| 261 | 259 |
| 262 // Created coalesced events init structure | 260 // Create coalesced events init structure only for pointermove. |
| 263 HeapVector<Member<PointerEvent>> coalescedPointerEvents; | 261 if (pointerEventName == EventTypeNames::pointermove) { |
| 264 for (const auto& coalescedMouseEvent : coalescedMouseEvents) { | 262 HeapVector<Member<PointerEvent>> coalescedPointerEvents; |
| 265 DCHECK_EQ(mouseEvent.pointerProperties().id, | 263 for (const auto& coalescedMouseEvent : coalescedMouseEvents) { |
| 266 coalescedMouseEvent.pointerProperties().id); | 264 DCHECK_EQ(mouseEvent.pointerProperties().id, |
| 267 DCHECK_EQ(mouseEvent.pointerProperties().pointerType, | 265 coalescedMouseEvent.pointerProperties().id); |
| 268 coalescedMouseEvent.pointerProperties().pointerType); | 266 DCHECK_EQ(mouseEvent.pointerProperties().pointerType, |
|
foolip
2017/01/24 04:56:26
Filed https://bugs.chromium.org/p/chromium/issues/
| |
| 269 PointerEventInit coalescedEventInit = pointerEventInit; | 267 coalescedMouseEvent.pointerProperties().pointerType); |
| 270 updateMousePointerEventInit(coalescedMouseEvent, view, &coalescedEventInit); | 268 PointerEventInit coalescedEventInit = pointerEventInit; |
| 271 coalescedPointerEvents.push_back( | 269 updateMousePointerEventInit(coalescedMouseEvent, view, |
| 272 PointerEvent::create(pointerEventName, coalescedEventInit)); | 270 &coalescedEventInit); |
| 271 coalescedPointerEvents.push_back( | |
| 272 PointerEvent::create(pointerEventName, coalescedEventInit)); | |
| 273 } | |
| 274 pointerEventInit.setCoalescedEvents(coalescedPointerEvents); | |
| 273 } | 275 } |
| 274 pointerEventInit.setCoalescedEvents(coalescedPointerEvents); | |
| 275 | 276 |
| 276 return PointerEvent::create(pointerEventName, pointerEventInit); | 277 return PointerEvent::create(pointerEventName, pointerEventInit); |
| 277 } | 278 } |
| 278 | 279 |
| 279 PointerEvent* PointerEventFactory::create( | 280 PointerEvent* PointerEventFactory::create( |
| 280 const PlatformTouchPoint& touchPoint, | 281 const PlatformTouchPoint& touchPoint, |
| 281 const Vector<PlatformTouchPoint>& coalescedPoints, | 282 const Vector<PlatformTouchPoint>& coalescedPoints, |
| 282 PlatformEvent::Modifiers modifiers, | 283 PlatformEvent::Modifiers modifiers, |
| 283 LocalFrame* targetFrame, | 284 LocalFrame* targetFrame, |
| 284 DOMWindow* view) { | 285 DOMWindow* view) { |
| 285 const PlatformTouchPoint::TouchState pointState = touchPoint.state(); | 286 const PlatformTouchPoint::TouchState pointState = touchPoint.state(); |
| 286 const AtomicString& type = | 287 const AtomicString& type = |
| 287 pointerEventNameForTouchPointState(touchPoint.state()); | 288 pointerEventNameForTouchPointState(touchPoint.state()); |
| 288 | 289 |
| 289 DCHECK(type == EventTypeNames::pointermove || coalescedPoints.isEmpty()); | |
| 290 | |
| 291 bool pointerReleasedOrCancelled = | 290 bool pointerReleasedOrCancelled = |
| 292 pointState == PlatformTouchPoint::TouchReleased || | 291 pointState == PlatformTouchPoint::TouchReleased || |
| 293 pointState == PlatformTouchPoint::TouchCancelled; | 292 pointState == PlatformTouchPoint::TouchCancelled; |
| 294 bool pointerPressedOrReleased = | 293 bool pointerPressedOrReleased = |
| 295 pointState == PlatformTouchPoint::TouchPressed || | 294 pointState == PlatformTouchPoint::TouchPressed || |
| 296 pointState == PlatformTouchPoint::TouchReleased; | 295 pointState == PlatformTouchPoint::TouchReleased; |
| 297 | 296 |
| 298 PointerEventInit pointerEventInit; | 297 PointerEventInit pointerEventInit; |
| 299 | 298 |
| 300 setIdTypeButtons(pointerEventInit, touchPoint.pointerProperties(), | 299 setIdTypeButtons(pointerEventInit, touchPoint.pointerProperties(), |
| 301 pointerReleasedOrCancelled ? 0 : 1); | 300 pointerReleasedOrCancelled ? 0 : 1); |
| 302 pointerEventInit.setButton(static_cast<int>( | 301 pointerEventInit.setButton(static_cast<int>( |
| 303 pointerPressedOrReleased ? WebPointerProperties::Button::Left | 302 pointerPressedOrReleased ? WebPointerProperties::Button::Left |
| 304 : WebPointerProperties::Button::NoButton)); | 303 : WebPointerProperties::Button::NoButton)); |
| 305 | 304 |
| 306 pointerEventInit.setView(view); | 305 pointerEventInit.setView(view); |
| 307 updateTouchPointerEventInit(touchPoint, targetFrame, &pointerEventInit); | 306 updateTouchPointerEventInit(touchPoint, targetFrame, &pointerEventInit); |
| 308 | 307 |
| 309 UIEventWithKeyState::setFromPlatformModifiers(pointerEventInit, modifiers); | 308 UIEventWithKeyState::setFromPlatformModifiers(pointerEventInit, modifiers); |
| 310 | 309 |
| 311 setEventSpecificFields(pointerEventInit, type); | 310 setEventSpecificFields(pointerEventInit, type); |
| 312 | 311 |
| 313 // Created coalesced events init structure | 312 if (type == EventTypeNames::pointermove) { |
| 314 HeapVector<Member<PointerEvent>> coalescedPointerEvents; | 313 HeapVector<Member<PointerEvent>> coalescedPointerEvents; |
| 315 for (const auto& coalescedTouchPoint : coalescedPoints) { | 314 for (const auto& coalescedTouchPoint : coalescedPoints) { |
| 316 DCHECK_EQ(touchPoint.state(), coalescedTouchPoint.state()); | 315 DCHECK_EQ(touchPoint.state(), coalescedTouchPoint.state()); |
| 317 DCHECK_EQ(touchPoint.pointerProperties().id, | 316 DCHECK_EQ(touchPoint.pointerProperties().id, |
| 318 coalescedTouchPoint.pointerProperties().id); | 317 coalescedTouchPoint.pointerProperties().id); |
| 319 DCHECK_EQ(touchPoint.pointerProperties().pointerType, | 318 DCHECK_EQ(touchPoint.pointerProperties().pointerType, |
| 320 coalescedTouchPoint.pointerProperties().pointerType); | 319 coalescedTouchPoint.pointerProperties().pointerType); |
| 321 PointerEventInit coalescedEventInit = pointerEventInit; | 320 PointerEventInit coalescedEventInit = pointerEventInit; |
| 322 updateTouchPointerEventInit(coalescedTouchPoint, targetFrame, | 321 updateTouchPointerEventInit(coalescedTouchPoint, targetFrame, |
| 323 &coalescedEventInit); | 322 &coalescedEventInit); |
| 324 coalescedPointerEvents.push_back( | 323 coalescedPointerEvents.push_back( |
| 325 PointerEvent::create(type, coalescedEventInit)); | 324 PointerEvent::create(type, coalescedEventInit)); |
| 325 } | |
| 326 pointerEventInit.setCoalescedEvents(coalescedPointerEvents); | |
| 326 } | 327 } |
| 327 pointerEventInit.setCoalescedEvents(coalescedPointerEvents); | |
| 328 | 328 |
| 329 return PointerEvent::create(type, pointerEventInit); | 329 return PointerEvent::create(type, pointerEventInit); |
| 330 } | 330 } |
| 331 | 331 |
| 332 PointerEvent* PointerEventFactory::createPointerCancelEvent( | 332 PointerEvent* PointerEventFactory::createPointerCancelEvent( |
| 333 const int pointerId, | 333 const int pointerId, |
| 334 const WebPointerProperties::PointerType pointerType) { | 334 const WebPointerProperties::PointerType pointerType) { |
| 335 DCHECK(m_pointerIdMapping.contains(pointerId)); | 335 DCHECK(m_pointerIdMapping.contains(pointerId)); |
| 336 m_pointerIdMapping.set( | 336 m_pointerIdMapping.set( |
| 337 pointerId, | 337 pointerId, |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 513 const WebPointerProperties& properties) const { | 513 const WebPointerProperties& properties) const { |
| 514 if (properties.pointerType == WebPointerProperties::PointerType::Mouse) | 514 if (properties.pointerType == WebPointerProperties::PointerType::Mouse) |
| 515 return PointerEventFactory::s_mouseId; | 515 return PointerEventFactory::s_mouseId; |
| 516 IncomingId id(properties.pointerType, properties.id); | 516 IncomingId id(properties.pointerType, properties.id); |
| 517 if (m_pointerIncomingIdMapping.contains(id)) | 517 if (m_pointerIncomingIdMapping.contains(id)) |
| 518 return m_pointerIncomingIdMapping.get(id); | 518 return m_pointerIncomingIdMapping.get(id); |
| 519 return PointerEventFactory::s_invalidId; | 519 return PointerEventFactory::s_invalidId; |
| 520 } | 520 } |
| 521 | 521 |
| 522 } // namespace blink | 522 } // namespace blink |
| OLD | NEW |