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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 // TODO(crbug.com/694742): We will set the id from low-level OS events | 279 // TODO(crbug.com/694742): We will set the id from low-level OS events |
280 // and enable this DCHECK again. | 280 // and enable this DCHECK again. |
281 // DCHECK_EQ(mouseEvent.id, coalescedMouseEvent.id); | 281 // DCHECK_EQ(mouseEvent.id, coalescedMouseEvent.id); |
282 | 282 |
283 DCHECK_EQ(mouse_event.pointer_type, coalesced_mouse_event.pointer_type); | 283 DCHECK_EQ(mouse_event.pointer_type, coalesced_mouse_event.pointer_type); |
284 PointerEventInit coalesced_event_init = pointer_event_init; | 284 PointerEventInit coalesced_event_init = pointer_event_init; |
285 coalesced_event_init.setCancelable(false); | 285 coalesced_event_init.setCancelable(false); |
286 coalesced_event_init.setBubbles(false); | 286 coalesced_event_init.setBubbles(false); |
287 UpdateMousePointerEventInit(coalesced_mouse_event, view, | 287 UpdateMousePointerEventInit(coalesced_mouse_event, view, |
288 &coalesced_event_init); | 288 &coalesced_event_init); |
289 PointerEvent* event = | 289 PointerEvent* event = PointerEvent::Create( |
290 PointerEvent::Create(pointer_event_name, coalesced_event_init); | 290 pointer_event_name, coalesced_event_init, |
| 291 TimeTicks::FromSeconds(coalesced_mouse_event.TimeStampSeconds())); |
291 // Set the trusted flag for the coalesced events at the creation time | 292 // Set the trusted flag for the coalesced events at the creation time |
292 // as oppose to the normal events which is done at the dispatch time. This | 293 // as oppose to the normal events which is done at the dispatch time. This |
293 // is because we don't want to go over all the coalesced events at every | 294 // is because we don't want to go over all the coalesced events at every |
294 // dispatch and add the implementation complexity while it has no sensible | 295 // dispatch and add the implementation complexity while it has no sensible |
295 // usecase at this time. | 296 // usecase at this time. |
296 event->SetTrusted(true); | 297 event->SetTrusted(true); |
297 coalesced_pointer_events.push_back(event); | 298 coalesced_pointer_events.push_back(event); |
298 } | 299 } |
299 pointer_event_init.setCoalescedEvents(coalesced_pointer_events); | 300 pointer_event_init.setCoalescedEvents(coalesced_pointer_events); |
300 } | 301 } |
301 | 302 |
302 return PointerEvent::Create(pointer_event_name, pointer_event_init); | 303 return PointerEvent::Create( |
| 304 pointer_event_name, pointer_event_init, |
| 305 TimeTicks::FromSeconds(mouse_event.TimeStampSeconds())); |
303 } | 306 } |
304 | 307 |
305 PointerEvent* PointerEventFactory::Create( | 308 PointerEvent* PointerEventFactory::Create( |
306 const WebTouchPoint& touch_point, | 309 const WebTouchPoint& touch_point, |
307 const Vector<WebTouchPoint>& coalesced_points, | 310 const Vector<std::pair<WebTouchPoint, TimeTicks>>& coalesced_points, |
308 WebInputEvent::Modifiers modifiers, | 311 WebInputEvent::Modifiers modifiers, |
| 312 TimeTicks event_platform_time_stamp, |
309 LocalFrame* target_frame, | 313 LocalFrame* target_frame, |
310 DOMWindow* view) { | 314 DOMWindow* view) { |
311 const WebTouchPoint::State point_state = touch_point.state; | 315 const WebTouchPoint::State point_state = touch_point.state; |
312 const AtomicString& type = | 316 const AtomicString& type = |
313 PointerEventNameForTouchPointState(touch_point.state); | 317 PointerEventNameForTouchPointState(touch_point.state); |
314 | 318 |
315 bool pointer_released_or_cancelled = | 319 bool pointer_released_or_cancelled = |
316 point_state == WebTouchPoint::State::kStateReleased || | 320 point_state == WebTouchPoint::State::kStateReleased || |
317 point_state == WebTouchPoint::State::kStateCancelled; | 321 point_state == WebTouchPoint::State::kStateCancelled; |
318 bool pointer_pressed_or_released = | 322 bool pointer_pressed_or_released = |
(...skipping 12 matching lines...) Expand all Loading... |
331 UpdateTouchPointerEventInit(touch_point, target_frame, &pointer_event_init); | 335 UpdateTouchPointerEventInit(touch_point, target_frame, &pointer_event_init); |
332 | 336 |
333 UIEventWithKeyState::SetFromWebInputEventModifiers(pointer_event_init, | 337 UIEventWithKeyState::SetFromWebInputEventModifiers(pointer_event_init, |
334 modifiers); | 338 modifiers); |
335 | 339 |
336 SetEventSpecificFields(pointer_event_init, type); | 340 SetEventSpecificFields(pointer_event_init, type); |
337 | 341 |
338 if (type == EventTypeNames::pointermove) { | 342 if (type == EventTypeNames::pointermove) { |
339 HeapVector<Member<PointerEvent>> coalesced_pointer_events; | 343 HeapVector<Member<PointerEvent>> coalesced_pointer_events; |
340 for (const auto& coalesced_touch_point : coalesced_points) { | 344 for (const auto& coalesced_touch_point : coalesced_points) { |
341 DCHECK_EQ(touch_point.state, coalesced_touch_point.state); | 345 const auto& coalesced_point = coalesced_touch_point.first; |
342 DCHECK_EQ(touch_point.id, coalesced_touch_point.id); | 346 const auto& coalesced_point_time_stamp = coalesced_touch_point.second; |
343 DCHECK_EQ(touch_point.pointer_type, coalesced_touch_point.pointer_type); | 347 DCHECK_EQ(touch_point.state, coalesced_point.state); |
| 348 DCHECK_EQ(touch_point.id, coalesced_point.id); |
| 349 DCHECK_EQ(touch_point.pointer_type, coalesced_point.pointer_type); |
344 PointerEventInit coalesced_event_init = pointer_event_init; | 350 PointerEventInit coalesced_event_init = pointer_event_init; |
345 coalesced_event_init.setCancelable(false); | 351 coalesced_event_init.setCancelable(false); |
346 coalesced_event_init.setBubbles(false); | 352 coalesced_event_init.setBubbles(false); |
347 UpdateTouchPointerEventInit(coalesced_touch_point, target_frame, | 353 UpdateTouchPointerEventInit(coalesced_point, target_frame, |
348 &coalesced_event_init); | 354 &coalesced_event_init); |
349 PointerEvent* event = PointerEvent::Create(type, coalesced_event_init); | 355 PointerEvent* event = PointerEvent::Create(type, coalesced_event_init, |
| 356 coalesced_point_time_stamp); |
350 // Set the trusted flag for the coalesced events at the creation time | 357 // Set the trusted flag for the coalesced events at the creation time |
351 // as oppose to the normal events which is done at the dispatch time. This | 358 // as oppose to the normal events which is done at the dispatch time. This |
352 // is because we don't want to go over all the coalesced events at every | 359 // is because we don't want to go over all the coalesced events at every |
353 // dispatch and add the implementation complexity while it has no sensible | 360 // dispatch and add the implementation complexity while it has no sensible |
354 // usecase at this time. | 361 // usecase at this time. |
355 event->SetTrusted(true); | 362 event->SetTrusted(true); |
356 coalesced_pointer_events.push_back(event); | 363 coalesced_pointer_events.push_back(event); |
357 } | 364 } |
358 pointer_event_init.setCoalescedEvents(coalesced_pointer_events); | 365 pointer_event_init.setCoalescedEvents(coalesced_pointer_events); |
359 } | 366 } |
360 | 367 |
361 return PointerEvent::Create(type, pointer_event_init); | 368 return PointerEvent::Create(type, pointer_event_init, |
| 369 event_platform_time_stamp); |
362 } | 370 } |
363 | 371 |
364 PointerEvent* PointerEventFactory::CreatePointerCancelEvent( | 372 PointerEvent* PointerEventFactory::CreatePointerCancelEvent( |
365 const int pointer_id, | 373 const int pointer_id, |
366 const WebPointerProperties::PointerType pointer_type) { | 374 const WebPointerProperties::PointerType pointer_type, |
| 375 TimeTicks platfrom_time_stamp) { |
367 DCHECK(pointer_id_mapping_.Contains(pointer_id)); | 376 DCHECK(pointer_id_mapping_.Contains(pointer_id)); |
368 pointer_id_mapping_.Set( | 377 pointer_id_mapping_.Set( |
369 pointer_id, | 378 pointer_id, |
370 PointerAttributes(pointer_id_mapping_.at(pointer_id).incoming_id, false)); | 379 PointerAttributes(pointer_id_mapping_.at(pointer_id).incoming_id, false)); |
371 | 380 |
372 PointerEventInit pointer_event_init; | 381 PointerEventInit pointer_event_init; |
373 | 382 |
374 pointer_event_init.setPointerId(pointer_id); | 383 pointer_event_init.setPointerId(pointer_id); |
375 pointer_event_init.setPointerType( | 384 pointer_event_init.setPointerType( |
376 PointerTypeNameForWebPointPointerType(pointer_type)); | 385 PointerTypeNameForWebPointPointerType(pointer_type)); |
377 pointer_event_init.setIsPrimary(IsPrimary(pointer_id)); | 386 pointer_event_init.setIsPrimary(IsPrimary(pointer_id)); |
378 | 387 |
379 SetEventSpecificFields(pointer_event_init, EventTypeNames::pointercancel); | 388 SetEventSpecificFields(pointer_event_init, EventTypeNames::pointercancel); |
380 | 389 |
381 return PointerEvent::Create(EventTypeNames::pointercancel, | 390 return PointerEvent::Create(EventTypeNames::pointercancel, pointer_event_init, |
382 pointer_event_init); | 391 platfrom_time_stamp); |
383 } | 392 } |
384 | 393 |
385 PointerEvent* PointerEventFactory::CreatePointerEventFrom( | 394 PointerEvent* PointerEventFactory::CreatePointerEventFrom( |
386 PointerEvent* pointer_event, | 395 PointerEvent* pointer_event, |
387 const AtomicString& type, | 396 const AtomicString& type, |
388 EventTarget* related_target) { | 397 EventTarget* related_target) { |
389 PointerEventInit pointer_event_init; | 398 PointerEventInit pointer_event_init; |
390 | 399 |
391 pointer_event_init.setPointerId(pointer_event->pointerId()); | 400 pointer_event_init.setPointerId(pointer_event->pointerId()); |
392 pointer_event_init.setPointerType(pointer_event->pointerType()); | 401 pointer_event_init.setPointerType(pointer_event->pointerType()); |
(...skipping 11 matching lines...) Expand all Loading... |
404 pointer_event_init.setTiltY(pointer_event->tiltY()); | 413 pointer_event_init.setTiltY(pointer_event->tiltY()); |
405 pointer_event_init.setTangentialPressure(pointer_event->tangentialPressure()); | 414 pointer_event_init.setTangentialPressure(pointer_event->tangentialPressure()); |
406 pointer_event_init.setTwist(pointer_event->twist()); | 415 pointer_event_init.setTwist(pointer_event->twist()); |
407 pointer_event_init.setView(pointer_event->view()); | 416 pointer_event_init.setView(pointer_event->view()); |
408 | 417 |
409 SetEventSpecificFields(pointer_event_init, type); | 418 SetEventSpecificFields(pointer_event_init, type); |
410 | 419 |
411 if (related_target) | 420 if (related_target) |
412 pointer_event_init.setRelatedTarget(related_target); | 421 pointer_event_init.setRelatedTarget(related_target); |
413 | 422 |
414 return PointerEvent::Create(type, pointer_event_init); | 423 return PointerEvent::Create(type, pointer_event_init, |
| 424 pointer_event->PlatformTimeStamp()); |
415 } | 425 } |
416 | 426 |
417 PointerEvent* PointerEventFactory::CreatePointerCaptureEvent( | 427 PointerEvent* PointerEventFactory::CreatePointerCaptureEvent( |
418 PointerEvent* pointer_event, | 428 PointerEvent* pointer_event, |
419 const AtomicString& type) { | 429 const AtomicString& type) { |
420 DCHECK(type == EventTypeNames::gotpointercapture || | 430 DCHECK(type == EventTypeNames::gotpointercapture || |
421 type == EventTypeNames::lostpointercapture); | 431 type == EventTypeNames::lostpointercapture); |
422 | 432 |
423 return CreatePointerEventFrom(pointer_event, type, | 433 return CreatePointerEventFrom(pointer_event, type, |
424 pointer_event->relatedTarget()); | 434 pointer_event->relatedTarget()); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 const WebPointerProperties& properties) const { | 559 const WebPointerProperties& properties) const { |
550 if (properties.pointer_type == WebPointerProperties::PointerType::kMouse) | 560 if (properties.pointer_type == WebPointerProperties::PointerType::kMouse) |
551 return PointerEventFactory::kMouseId; | 561 return PointerEventFactory::kMouseId; |
552 IncomingId id(properties.pointer_type, properties.id); | 562 IncomingId id(properties.pointer_type, properties.id); |
553 if (pointer_incoming_id_mapping_.Contains(id)) | 563 if (pointer_incoming_id_mapping_.Contains(id)) |
554 return pointer_incoming_id_mapping_.at(id); | 564 return pointer_incoming_id_mapping_.at(id); |
555 return PointerEventFactory::kInvalidId; | 565 return PointerEventFactory::kInvalidId; |
556 } | 566 } |
557 | 567 |
558 } // namespace blink | 568 } // namespace blink |
OLD | NEW |