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

Side by Side Diff: third_party/WebKit/Source/web/WebInputEventConversion.cpp

Issue 2573073003: Collapse the API surface on WebInputEvent via accessor functions. (Closed)
Patch Set: Created 4 years 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 // TODO(mustaq): Add tests for this. 194 // TODO(mustaq): Add tests for this.
195 PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, 195 PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget,
196 const WebMouseEvent& e) { 196 const WebMouseEvent& e) {
197 // FIXME: Widget is always toplevel, unless it's a popup. We may be able 197 // FIXME: Widget is always toplevel, unless it's a popup. We may be able
198 // to get rid of this once we abstract popups into a WebKit API. 198 // to get rid of this once we abstract popups into a WebKit API.
199 m_position = widget->convertFromRootFrame( 199 m_position = widget->convertFromRootFrame(
200 flooredIntPoint(convertHitPointToRootFrame(widget, IntPoint(e.x, e.y)))); 200 flooredIntPoint(convertHitPointToRootFrame(widget, IntPoint(e.x, e.y))));
201 m_globalPosition = IntPoint(e.globalX, e.globalY); 201 m_globalPosition = IntPoint(e.globalX, e.globalY);
202 m_movementDelta = IntPoint(scaleDeltaToWindow(widget, e.movementX), 202 m_movementDelta = IntPoint(scaleDeltaToWindow(widget, e.movementX),
203 scaleDeltaToWindow(widget, e.movementY)); 203 scaleDeltaToWindow(widget, e.movementY));
204 m_modifiers = e.modifiers; 204 m_modifiers = e.modifiers();
205 205
206 m_timestamp = e.timeStampSeconds; 206 m_timestamp = e.timeStampSeconds();
207 m_clickCount = e.clickCount; 207 m_clickCount = e.clickCount;
208 208
209 m_pointerProperties = static_cast<WebPointerProperties>(e); 209 m_pointerProperties = static_cast<WebPointerProperties>(e);
210 210
211 switch (e.type) { 211 switch (e.type()) {
212 case WebInputEvent::MouseMove: 212 case WebInputEvent::MouseMove:
213 case WebInputEvent::MouseEnter: // synthesize a move event 213 case WebInputEvent::MouseEnter: // synthesize a move event
214 case WebInputEvent::MouseLeave: // synthesize a move event 214 case WebInputEvent::MouseLeave: // synthesize a move event
215 m_type = PlatformEvent::MouseMoved; 215 m_type = PlatformEvent::MouseMoved;
216 break; 216 break;
217 217
218 case WebInputEvent::MouseDown: 218 case WebInputEvent::MouseDown:
219 m_type = PlatformEvent::MousePressed; 219 m_type = PlatformEvent::MousePressed;
220 break; 220 break;
221 221
(...skipping 22 matching lines...) Expand all
244 m_globalPosition = IntPoint(e.globalX, e.globalY); 244 m_globalPosition = IntPoint(e.globalX, e.globalY);
245 m_deltaX = scaleDeltaToWindow(widget, e.deltaX); 245 m_deltaX = scaleDeltaToWindow(widget, e.deltaX);
246 m_deltaY = scaleDeltaToWindow(widget, e.deltaY); 246 m_deltaY = scaleDeltaToWindow(widget, e.deltaY);
247 m_wheelTicksX = e.wheelTicksX; 247 m_wheelTicksX = e.wheelTicksX;
248 m_wheelTicksY = e.wheelTicksY; 248 m_wheelTicksY = e.wheelTicksY;
249 m_granularity = 249 m_granularity =
250 e.scrollByPage ? ScrollByPageWheelEvent : ScrollByPixelWheelEvent; 250 e.scrollByPage ? ScrollByPageWheelEvent : ScrollByPixelWheelEvent;
251 251
252 m_type = PlatformEvent::Wheel; 252 m_type = PlatformEvent::Wheel;
253 253
254 m_timestamp = e.timeStampSeconds; 254 m_timestamp = e.timeStampSeconds();
255 m_modifiers = e.modifiers; 255 m_modifiers = e.modifiers();
256 m_dispatchType = toPlatformDispatchType(e.dispatchType); 256 m_dispatchType = toPlatformDispatchType(e.dispatchType);
257 257
258 m_hasPreciseScrollingDeltas = e.hasPreciseScrollingDeltas; 258 m_hasPreciseScrollingDeltas = e.hasPreciseScrollingDeltas;
259 m_resendingPluginId = e.resendingPluginId; 259 m_resendingPluginId = e.resendingPluginId;
260 m_railsMode = static_cast<PlatformEvent::RailsMode>(e.railsMode); 260 m_railsMode = static_cast<PlatformEvent::RailsMode>(e.railsMode);
261 #if OS(MACOSX) 261 #if OS(MACOSX)
262 m_phase = static_cast<PlatformWheelEventPhase>(e.phase); 262 m_phase = static_cast<PlatformWheelEventPhase>(e.phase);
263 m_momentumPhase = static_cast<PlatformWheelEventPhase>(e.momentumPhase); 263 m_momentumPhase = static_cast<PlatformWheelEventPhase>(e.momentumPhase);
264 #endif 264 #endif
265 } 265 }
266 266
267 // PlatformGestureEventBuilder ----------------------------------------------- 267 // PlatformGestureEventBuilder -----------------------------------------------
268 268
269 PlatformGestureEventBuilder::PlatformGestureEventBuilder( 269 PlatformGestureEventBuilder::PlatformGestureEventBuilder(
270 Widget* widget, 270 Widget* widget,
271 const WebGestureEvent& e) { 271 const WebGestureEvent& e) {
272 switch (e.type) { 272 switch (e.type()) {
273 case WebInputEvent::GestureScrollBegin: 273 case WebInputEvent::GestureScrollBegin:
274 m_type = PlatformEvent::GestureScrollBegin; 274 m_type = PlatformEvent::GestureScrollBegin;
275 m_data.m_scroll.m_resendingPluginId = e.resendingPluginId; 275 m_data.m_scroll.m_resendingPluginId = e.resendingPluginId;
276 m_data.m_scroll.m_deltaX = e.data.scrollBegin.deltaXHint; 276 m_data.m_scroll.m_deltaX = e.data.scrollBegin.deltaXHint;
277 m_data.m_scroll.m_deltaY = e.data.scrollBegin.deltaYHint; 277 m_data.m_scroll.m_deltaY = e.data.scrollBegin.deltaYHint;
278 m_data.m_scroll.m_deltaUnits = 278 m_data.m_scroll.m_deltaUnits =
279 toPlatformScrollGranularity(e.data.scrollBegin.deltaHintUnits); 279 toPlatformScrollGranularity(e.data.scrollBegin.deltaHintUnits);
280 m_data.m_scroll.m_inertialPhase = 280 m_data.m_scroll.m_inertialPhase =
281 toPlatformScrollInertialPhase(e.data.scrollBegin.inertialPhase); 281 toPlatformScrollInertialPhase(e.data.scrollBegin.inertialPhase);
282 m_data.m_scroll.m_synthetic = e.data.scrollBegin.synthetic; 282 m_data.m_scroll.m_synthetic = e.data.scrollBegin.synthetic;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 case WebInputEvent::GesturePinchUpdate: 368 case WebInputEvent::GesturePinchUpdate:
369 m_type = PlatformEvent::GesturePinchUpdate; 369 m_type = PlatformEvent::GesturePinchUpdate;
370 m_data.m_pinchUpdate.m_scale = e.data.pinchUpdate.scale; 370 m_data.m_pinchUpdate.m_scale = e.data.pinchUpdate.scale;
371 break; 371 break;
372 default: 372 default:
373 NOTREACHED(); 373 NOTREACHED();
374 } 374 }
375 m_position = widget->convertFromRootFrame(flooredIntPoint( 375 m_position = widget->convertFromRootFrame(flooredIntPoint(
376 convertHitPointToRootFrame(widget, FloatPoint(e.x, e.y)))); 376 convertHitPointToRootFrame(widget, FloatPoint(e.x, e.y))));
377 m_globalPosition = IntPoint(e.globalX, e.globalY); 377 m_globalPosition = IntPoint(e.globalX, e.globalY);
378 m_timestamp = e.timeStampSeconds; 378 m_timestamp = e.timeStampSeconds();
379 m_modifiers = e.modifiers; 379 m_modifiers = e.modifiers();
380 switch (e.sourceDevice) { 380 switch (e.sourceDevice) {
381 case WebGestureDeviceTouchpad: 381 case WebGestureDeviceTouchpad:
382 m_source = PlatformGestureSourceTouchpad; 382 m_source = PlatformGestureSourceTouchpad;
383 break; 383 break;
384 case WebGestureDeviceTouchscreen: 384 case WebGestureDeviceTouchscreen:
385 m_source = PlatformGestureSourceTouchscreen; 385 m_source = PlatformGestureSourceTouchscreen;
386 break; 386 break;
387 case WebGestureDeviceUninitialized: 387 case WebGestureDeviceUninitialized:
388 NOTREACHED(); 388 NOTREACHED();
389 } 389 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 widget->convertFromRootFrame(flooredPoint) + (floatPos - flooredPoint); 454 widget->convertFromRootFrame(flooredPoint) + (floatPos - flooredPoint);
455 455
456 m_screenPos = FloatPoint(point.screenPosition.x, point.screenPosition.y); 456 m_screenPos = FloatPoint(point.screenPosition.x, point.screenPosition.y);
457 m_radius = scaleSizeToWindow(widget, FloatSize(point.radiusX, point.radiusY)); 457 m_radius = scaleSizeToWindow(widget, FloatSize(point.radiusX, point.radiusY));
458 m_rotationAngle = point.rotationAngle; 458 m_rotationAngle = point.rotationAngle;
459 } 459 }
460 460
461 PlatformTouchEventBuilder::PlatformTouchEventBuilder( 461 PlatformTouchEventBuilder::PlatformTouchEventBuilder(
462 Widget* widget, 462 Widget* widget,
463 const WebTouchEvent& event) { 463 const WebTouchEvent& event) {
464 m_type = toPlatformTouchEventType(event.type); 464 m_type = toPlatformTouchEventType(event.type());
465 m_modifiers = event.modifiers; 465 m_modifiers = event.modifiers();
466 m_timestamp = event.timeStampSeconds; 466 m_timestamp = event.timeStampSeconds();
467 m_causesScrollingIfUncanceled = event.movedBeyondSlopRegion; 467 m_causesScrollingIfUncanceled = event.movedBeyondSlopRegion;
468 m_touchStartOrFirstTouchMove = event.touchStartOrFirstTouchMove; 468 m_touchStartOrFirstTouchMove = event.touchStartOrFirstTouchMove;
469 469
470 for (unsigned i = 0; i < event.touchesLength; ++i) 470 for (unsigned i = 0; i < event.touchesLength; ++i)
471 m_touchPoints.append(PlatformTouchPointBuilder(widget, event.touches[i])); 471 m_touchPoints.append(PlatformTouchPointBuilder(widget, event.touches[i]));
472 472
473 m_dispatchType = toPlatformDispatchType(event.dispatchType); 473 m_dispatchType = toPlatformDispatchType(event.dispatchType);
474 m_uniqueTouchEventId = event.uniqueTouchEventId; 474 m_uniqueTouchEventId = event.uniqueTouchEventId;
475 } 475 }
476 476
(...skipping 10 matching lines...) Expand all
487 convertAbsoluteLocationForLayoutObjectFloat(location, layoutItem)); 487 convertAbsoluteLocationForLayoutObjectFloat(location, layoutItem));
488 } 488 }
489 489
490 // FIXME: Change |widget| to const Widget& after RemoteFrames get 490 // FIXME: Change |widget| to const Widget& after RemoteFrames get
491 // RemoteFrameViews. 491 // RemoteFrameViews.
492 static void updateWebMouseEventFromCoreMouseEvent( 492 static void updateWebMouseEventFromCoreMouseEvent(
493 const MouseRelatedEvent& event, 493 const MouseRelatedEvent& event,
494 const Widget* widget, 494 const Widget* widget,
495 const LayoutItem layoutItem, 495 const LayoutItem layoutItem,
496 WebMouseEvent& webEvent) { 496 WebMouseEvent& webEvent) {
497 webEvent.timeStampSeconds = event.platformTimeStamp();
498 webEvent.modifiers = event.modifiers();
499
500 FrameView* view = widget ? toFrameView(widget->parent()) : 0; 497 FrameView* view = widget ? toFrameView(widget->parent()) : 0;
501 // TODO(bokan): If view == nullptr, pointInRootFrame will really be 498 // TODO(bokan): If view == nullptr, pointInRootFrame will really be
502 // pointInRootContent. 499 // pointInRootContent.
503 IntPoint pointInRootFrame(event.absoluteLocation().x(), 500 IntPoint pointInRootFrame(event.absoluteLocation().x(),
504 event.absoluteLocation().y()); 501 event.absoluteLocation().y());
505 if (view) 502 if (view)
506 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); 503 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame);
507 webEvent.globalX = event.screenX(); 504 webEvent.globalX = event.screenX();
508 webEvent.globalY = event.screenY(); 505 webEvent.globalY = event.screenY();
509 webEvent.windowX = pointInRootFrame.x(); 506 webEvent.windowX = pointInRootFrame.x();
510 webEvent.windowY = pointInRootFrame.y(); 507 webEvent.windowY = pointInRootFrame.y();
511 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt( 508 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt(
512 event.absoluteLocation(), layoutItem); 509 event.absoluteLocation(), layoutItem);
513 webEvent.x = localPoint.x(); 510 webEvent.x = localPoint.x();
514 webEvent.y = localPoint.y(); 511 webEvent.y = localPoint.y();
515 } 512 }
516 513
517 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, 514 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget,
518 const LayoutItem layoutItem, 515 const LayoutItem layoutItem,
519 const MouseEvent& event) { 516 const MouseEvent& event) {
520 if (event.type() == EventTypeNames::mousemove) 517 if (event.type() == EventTypeNames::mousemove)
521 type = WebInputEvent::MouseMove; 518 m_type = WebInputEvent::MouseMove;
522 else if (event.type() == EventTypeNames::mouseout) 519 else if (event.type() == EventTypeNames::mouseout)
523 type = WebInputEvent::MouseLeave; 520 m_type = WebInputEvent::MouseLeave;
524 else if (event.type() == EventTypeNames::mouseover) 521 else if (event.type() == EventTypeNames::mouseover)
525 type = WebInputEvent::MouseEnter; 522 m_type = WebInputEvent::MouseEnter;
526 else if (event.type() == EventTypeNames::mousedown) 523 else if (event.type() == EventTypeNames::mousedown)
527 type = WebInputEvent::MouseDown; 524 m_type = WebInputEvent::MouseDown;
528 else if (event.type() == EventTypeNames::mouseup) 525 else if (event.type() == EventTypeNames::mouseup)
529 type = WebInputEvent::MouseUp; 526 m_type = WebInputEvent::MouseUp;
530 else if (event.type() == EventTypeNames::contextmenu) 527 else if (event.type() == EventTypeNames::contextmenu)
531 type = WebInputEvent::ContextMenu; 528 m_type = WebInputEvent::ContextMenu;
532 else 529 else
533 return; // Skip all other mouse events. 530 return; // Skip all other mouse events.
534 531
532 m_timeStampSeconds = event.platformTimeStamp();
533 m_modifiers = event.modifiers();
535 updateWebMouseEventFromCoreMouseEvent(event, widget, layoutItem, *this); 534 updateWebMouseEventFromCoreMouseEvent(event, widget, layoutItem, *this);
536 535
537 switch (event.button()) { 536 switch (event.button()) {
538 case short(WebPointerProperties::Button::Left): 537 case short(WebPointerProperties::Button::Left):
539 button = WebMouseEvent::Button::Left; 538 button = WebMouseEvent::Button::Left;
540 break; 539 break;
541 case short(WebPointerProperties::Button::Middle): 540 case short(WebPointerProperties::Button::Middle):
542 button = WebMouseEvent::Button::Middle; 541 button = WebMouseEvent::Button::Middle;
543 break; 542 break;
544 case short(WebPointerProperties::Button::Right): 543 case short(WebPointerProperties::Button::Right):
545 button = WebMouseEvent::Button::Right; 544 button = WebMouseEvent::Button::Right;
546 break; 545 break;
547 } 546 }
548 if (event.buttonDown()) { 547 if (event.buttonDown()) {
549 switch (event.button()) { 548 switch (event.button()) {
550 case short(WebPointerProperties::Button::Left): 549 case short(WebPointerProperties::Button::Left):
551 modifiers |= WebInputEvent::LeftButtonDown; 550 m_modifiers |= WebInputEvent::LeftButtonDown;
552 break; 551 break;
553 case short(WebPointerProperties::Button::Middle): 552 case short(WebPointerProperties::Button::Middle):
554 modifiers |= WebInputEvent::MiddleButtonDown; 553 m_modifiers |= WebInputEvent::MiddleButtonDown;
555 break; 554 break;
556 case short(WebPointerProperties::Button::Right): 555 case short(WebPointerProperties::Button::Right):
557 modifiers |= WebInputEvent::RightButtonDown; 556 m_modifiers |= WebInputEvent::RightButtonDown;
558 break; 557 break;
559 } 558 }
560 } else { 559 } else {
561 button = WebMouseEvent::Button::NoButton; 560 button = WebMouseEvent::Button::NoButton;
562 } 561 }
563 movementX = event.movementX(); 562 movementX = event.movementX();
564 movementY = event.movementY(); 563 movementY = event.movementY();
565 clickCount = event.detail(); 564 clickCount = event.detail();
566 565
567 pointerType = WebPointerProperties::PointerType::Mouse; 566 pointerType = WebPointerProperties::PointerType::Mouse;
(...skipping 14 matching lines...) Expand all
582 return; 581 return;
583 } 582 }
584 583
585 const Touch* touch = event.touches()->length() == 1 584 const Touch* touch = event.touches()->length() == 1
586 ? event.touches()->item(0) 585 ? event.touches()->item(0)
587 : event.changedTouches()->item(0); 586 : event.changedTouches()->item(0);
588 if (touch->identifier()) 587 if (touch->identifier())
589 return; 588 return;
590 589
591 if (event.type() == EventTypeNames::touchstart) 590 if (event.type() == EventTypeNames::touchstart)
592 type = MouseDown; 591 m_type = MouseDown;
593 else if (event.type() == EventTypeNames::touchmove) 592 else if (event.type() == EventTypeNames::touchmove)
594 type = MouseMove; 593 m_type = MouseMove;
595 else if (event.type() == EventTypeNames::touchend) 594 else if (event.type() == EventTypeNames::touchend)
596 type = MouseUp; 595 m_type = MouseUp;
597 else 596 else
598 return; 597 return;
599 598
600 timeStampSeconds = event.platformTimeStamp(); 599 m_timeStampSeconds = event.platformTimeStamp();
601 modifiers = event.modifiers(); 600 m_modifiers = event.modifiers();
602 601
603 // The mouse event co-ordinates should be generated from the co-ordinates of 602 // The mouse event co-ordinates should be generated from the co-ordinates of
604 // the touch point. 603 // the touch point.
605 FrameView* view = toFrameView(widget->parent()); 604 FrameView* view = toFrameView(widget->parent());
606 // FIXME: if view == nullptr, pointInRootFrame will really be 605 // FIXME: if view == nullptr, pointInRootFrame will really be
607 // pointInRootContent. 606 // pointInRootContent.
608 IntPoint pointInRootFrame = roundedIntPoint(touch->absoluteLocation()); 607 IntPoint pointInRootFrame = roundedIntPoint(touch->absoluteLocation());
609 if (view) 608 if (view)
610 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); 609 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame);
611 IntPoint screenPoint = roundedIntPoint(touch->screenLocation()); 610 IntPoint screenPoint = roundedIntPoint(touch->screenLocation());
612 globalX = screenPoint.x(); 611 globalX = screenPoint.x();
613 globalY = screenPoint.y(); 612 globalY = screenPoint.y();
614 windowX = pointInRootFrame.x(); 613 windowX = pointInRootFrame.x();
615 windowY = pointInRootFrame.y(); 614 windowY = pointInRootFrame.y();
616 615
617 button = WebMouseEvent::Button::Left; 616 button = WebMouseEvent::Button::Left;
618 modifiers |= WebInputEvent::LeftButtonDown; 617 m_modifiers |= WebInputEvent::LeftButtonDown;
619 clickCount = (type == MouseDown || type == MouseUp); 618 clickCount = (m_type == MouseDown || m_type == MouseUp);
620 619
621 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt( 620 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt(
622 DoublePoint(touch->absoluteLocation()), layoutItem); 621 DoublePoint(touch->absoluteLocation()), layoutItem);
623 x = localPoint.x(); 622 x = localPoint.x();
624 y = localPoint.y(); 623 y = localPoint.y();
625 624
626 pointerType = WebPointerProperties::PointerType::Touch; 625 pointerType = WebPointerProperties::PointerType::Touch;
627 } 626 }
628 627
629 WebMouseWheelEventBuilder::WebMouseWheelEventBuilder( 628 WebMouseWheelEventBuilder::WebMouseWheelEventBuilder(
630 const Widget* widget, 629 const Widget* widget,
631 const LayoutItem layoutItem, 630 const LayoutItem layoutItem,
632 const WheelEvent& event) { 631 const WheelEvent& event) {
633 if (event.type() != EventTypeNames::wheel && 632 if (event.type() != EventTypeNames::wheel &&
634 event.type() != EventTypeNames::mousewheel) 633 event.type() != EventTypeNames::mousewheel)
635 return; 634 return;
636 type = WebInputEvent::MouseWheel; 635 m_type = WebInputEvent::MouseWheel;
636 m_timeStampSeconds = event.platformTimeStamp();
637 m_modifiers = event.modifiers();
637 updateWebMouseEventFromCoreMouseEvent(event, widget, layoutItem, *this); 638 updateWebMouseEventFromCoreMouseEvent(event, widget, layoutItem, *this);
638 deltaX = -event.deltaX(); 639 deltaX = -event.deltaX();
639 deltaY = -event.deltaY(); 640 deltaY = -event.deltaY();
640 wheelTicksX = event.ticksX(); 641 wheelTicksX = event.ticksX();
641 wheelTicksY = event.ticksY(); 642 wheelTicksY = event.ticksY();
642 scrollByPage = event.deltaMode() == WheelEvent::kDomDeltaPage; 643 scrollByPage = event.deltaMode() == WheelEvent::kDomDeltaPage;
643 resendingPluginId = event.resendingPluginId(); 644 resendingPluginId = event.resendingPluginId();
644 railsMode = static_cast<RailsMode>(event.getRailsMode()); 645 railsMode = static_cast<RailsMode>(event.getRailsMode());
645 hasPreciseScrollingDeltas = event.hasPreciseScrollingDeltas(); 646 hasPreciseScrollingDeltas = event.hasPreciseScrollingDeltas();
646 dispatchType = event.cancelable() ? WebInputEvent::Blocking 647 dispatchType = event.cancelable() ? WebInputEvent::Blocking
647 : WebInputEvent::EventNonBlocking; 648 : WebInputEvent::EventNonBlocking;
648 #if OS(MACOSX) 649 #if OS(MACOSX)
649 phase = static_cast<Phase>(event.phase()); 650 phase = static_cast<Phase>(event.phase());
650 momentumPhase = static_cast<Phase>(event.momentumPhase()); 651 momentumPhase = static_cast<Phase>(event.momentumPhase());
651 #endif 652 #endif
652 } 653 }
653 654
654 WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event) { 655 WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event) {
655 if (const WebKeyboardEvent* webEvent = event.keyEvent()) { 656 if (const WebKeyboardEvent* webEvent = event.keyEvent()) {
656 *static_cast<WebKeyboardEvent*>(this) = *webEvent; 657 *static_cast<WebKeyboardEvent*>(this) = *webEvent;
657 658
658 // TODO(dtapuska): DOM KeyboardEvents converted back to WebInputEvents 659 // TODO(dtapuska): DOM KeyboardEvents converted back to WebInputEvents
659 // drop the Raw behaviour. Figure out if this is actually really needed. 660 // drop the Raw behaviour. Figure out if this is actually really needed.
660 if (type == RawKeyDown) 661 if (m_type == RawKeyDown)
661 type = KeyDown; 662 m_type = KeyDown;
662 return; 663 return;
663 } 664 }
664 665
665 if (event.type() == EventTypeNames::keydown) 666 if (event.type() == EventTypeNames::keydown)
666 type = KeyDown; 667 m_type = KeyDown;
667 else if (event.type() == EventTypeNames::keyup) 668 else if (event.type() == EventTypeNames::keyup)
668 type = WebInputEvent::KeyUp; 669 m_type = WebInputEvent::KeyUp;
669 else if (event.type() == EventTypeNames::keypress) 670 else if (event.type() == EventTypeNames::keypress)
670 type = WebInputEvent::Char; 671 m_type = WebInputEvent::Char;
671 else 672 else
672 return; // Skip all other keyboard events. 673 return; // Skip all other keyboard events.
673 674
674 modifiers = event.modifiers(); 675 m_modifiers = event.modifiers();
675 timeStampSeconds = event.platformTimeStamp(); 676 m_timeStampSeconds = event.platformTimeStamp();
676 windowsKeyCode = event.keyCode(); 677 windowsKeyCode = event.keyCode();
677 } 678 }
678 679
679 static WebTouchPoint toWebTouchPoint(const Touch* touch, 680 static WebTouchPoint toWebTouchPoint(const Touch* touch,
680 const LayoutItem layoutItem, 681 const LayoutItem layoutItem,
681 WebTouchPoint::State state, 682 WebTouchPoint::State state,
682 WebPointerProperties::PointerType type) { 683 WebPointerProperties::PointerType type) {
683 WebTouchPoint point; 684 WebTouchPoint point;
684 point.pointerType = type; 685 point.pointerType = type;
685 point.id = touch->identifier(); 686 point.id = touch->identifier();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 touchPoints[pointIndex] = 727 touchPoints[pointIndex] =
727 toWebTouchPoint(touch, layoutItem, state, pointerType); 728 toWebTouchPoint(touch, layoutItem, state, pointerType);
728 ++(*touchPointsLength); 729 ++(*touchPointsLength);
729 } 730 }
730 } 731 }
731 } 732 }
732 733
733 WebTouchEventBuilder::WebTouchEventBuilder(const LayoutItem layoutItem, 734 WebTouchEventBuilder::WebTouchEventBuilder(const LayoutItem layoutItem,
734 const TouchEvent& event) { 735 const TouchEvent& event) {
735 if (event.type() == EventTypeNames::touchstart) 736 if (event.type() == EventTypeNames::touchstart)
736 type = TouchStart; 737 m_type = TouchStart;
737 else if (event.type() == EventTypeNames::touchmove) 738 else if (event.type() == EventTypeNames::touchmove)
738 type = TouchMove; 739 m_type = TouchMove;
739 else if (event.type() == EventTypeNames::touchend) 740 else if (event.type() == EventTypeNames::touchend)
740 type = TouchEnd; 741 m_type = TouchEnd;
741 else if (event.type() == EventTypeNames::touchcancel) 742 else if (event.type() == EventTypeNames::touchcancel)
742 type = TouchCancel; 743 m_type = TouchCancel;
743 else { 744 else {
744 NOTREACHED(); 745 NOTREACHED();
745 type = Undefined; 746 m_type = Undefined;
746 return; 747 return;
747 } 748 }
748 749
749 timeStampSeconds = event.platformTimeStamp(); 750 m_timeStampSeconds = event.platformTimeStamp();
750 modifiers = event.modifiers(); 751 m_modifiers = event.modifiers();
751 dispatchType = event.cancelable() ? WebInputEvent::Blocking 752 dispatchType = event.cancelable() ? WebInputEvent::Blocking
752 : WebInputEvent::EventNonBlocking; 753 : WebInputEvent::EventNonBlocking;
753 movedBeyondSlopRegion = event.causesScrollingIfUncanceled(); 754 movedBeyondSlopRegion = event.causesScrollingIfUncanceled();
754 755
755 // Currently touches[] is empty, add stationary points as-is. 756 // Currently touches[] is empty, add stationary points as-is.
756 for (unsigned i = 0; 757 for (unsigned i = 0;
757 i < event.touches()->length() && 758 i < event.touches()->length() &&
758 i < static_cast<unsigned>(WebTouchEvent::kTouchesLengthCap); 759 i < static_cast<unsigned>(WebTouchEvent::kTouchesLengthCap);
759 ++i) { 760 ++i) {
760 touches[i] = 761 touches[i] =
761 toWebTouchPoint(event.touches()->item(i), layoutItem, 762 toWebTouchPoint(event.touches()->item(i), layoutItem,
762 WebTouchPoint::StateStationary, event.pointerType()); 763 WebTouchPoint::StateStationary, event.pointerType());
763 ++touchesLength; 764 ++touchesLength;
764 } 765 }
765 // If any existing points are also in the change list, we should update 766 // If any existing points are also in the change list, we should update
766 // their state, otherwise just add the new points. 767 // their state, otherwise just add the new points.
767 addTouchPointsUpdateStateIfNecessary( 768 addTouchPointsUpdateStateIfNecessary(
768 toWebTouchPointState(event.type()), event.changedTouches(), touches, 769 toWebTouchPointState(event.type()), event.changedTouches(), touches,
769 &touchesLength, layoutItem, event.pointerType()); 770 &touchesLength, layoutItem, event.pointerType());
770 } 771 }
771 772
772 WebGestureEventBuilder::WebGestureEventBuilder(const LayoutItem layoutItem, 773 WebGestureEventBuilder::WebGestureEventBuilder(const LayoutItem layoutItem,
773 const GestureEvent& event) { 774 const GestureEvent& event) {
774 if (event.type() == EventTypeNames::gestureshowpress) { 775 if (event.type() == EventTypeNames::gestureshowpress) {
775 type = GestureShowPress; 776 m_type = GestureShowPress;
776 } else if (event.type() == EventTypeNames::gesturelongpress) { 777 } else if (event.type() == EventTypeNames::gesturelongpress) {
777 type = GestureLongPress; 778 m_type = GestureLongPress;
778 } else if (event.type() == EventTypeNames::gesturetapdown) { 779 } else if (event.type() == EventTypeNames::gesturetapdown) {
779 type = GestureTapDown; 780 m_type = GestureTapDown;
780 } else if (event.type() == EventTypeNames::gesturescrollstart) { 781 } else if (event.type() == EventTypeNames::gesturescrollstart) {
781 type = GestureScrollBegin; 782 m_type = GestureScrollBegin;
782 resendingPluginId = event.resendingPluginId(); 783 resendingPluginId = event.resendingPluginId();
783 data.scrollBegin.deltaXHint = event.deltaX(); 784 data.scrollBegin.deltaXHint = event.deltaX();
784 data.scrollBegin.deltaYHint = event.deltaY(); 785 data.scrollBegin.deltaYHint = event.deltaY();
785 data.scrollBegin.deltaHintUnits = 786 data.scrollBegin.deltaHintUnits =
786 toWebGestureScrollUnits(event.deltaUnits()); 787 toWebGestureScrollUnits(event.deltaUnits());
787 data.scrollBegin.inertialPhase = 788 data.scrollBegin.inertialPhase =
788 toWebGestureInertialPhaseState(event.inertialPhase()); 789 toWebGestureInertialPhaseState(event.inertialPhase());
789 data.scrollBegin.synthetic = event.synthetic(); 790 data.scrollBegin.synthetic = event.synthetic();
790 } else if (event.type() == EventTypeNames::gesturescrollend) { 791 } else if (event.type() == EventTypeNames::gesturescrollend) {
791 type = GestureScrollEnd; 792 m_type = GestureScrollEnd;
792 resendingPluginId = event.resendingPluginId(); 793 resendingPluginId = event.resendingPluginId();
793 data.scrollEnd.deltaUnits = toWebGestureScrollUnits(event.deltaUnits()); 794 data.scrollEnd.deltaUnits = toWebGestureScrollUnits(event.deltaUnits());
794 data.scrollEnd.inertialPhase = 795 data.scrollEnd.inertialPhase =
795 toWebGestureInertialPhaseState(event.inertialPhase()); 796 toWebGestureInertialPhaseState(event.inertialPhase());
796 data.scrollEnd.synthetic = event.synthetic(); 797 data.scrollEnd.synthetic = event.synthetic();
797 } else if (event.type() == EventTypeNames::gesturescrollupdate) { 798 } else if (event.type() == EventTypeNames::gesturescrollupdate) {
798 type = GestureScrollUpdate; 799 m_type = GestureScrollUpdate;
799 data.scrollUpdate.deltaUnits = toWebGestureScrollUnits(event.deltaUnits()); 800 data.scrollUpdate.deltaUnits = toWebGestureScrollUnits(event.deltaUnits());
800 data.scrollUpdate.deltaX = event.deltaX(); 801 data.scrollUpdate.deltaX = event.deltaX();
801 data.scrollUpdate.deltaY = event.deltaY(); 802 data.scrollUpdate.deltaY = event.deltaY();
802 data.scrollUpdate.inertialPhase = 803 data.scrollUpdate.inertialPhase =
803 toWebGestureInertialPhaseState(event.inertialPhase()); 804 toWebGestureInertialPhaseState(event.inertialPhase());
804 resendingPluginId = event.resendingPluginId(); 805 resendingPluginId = event.resendingPluginId();
805 } else if (event.type() == EventTypeNames::gestureflingstart) { 806 } else if (event.type() == EventTypeNames::gestureflingstart) {
806 type = GestureFlingStart; 807 m_type = GestureFlingStart;
807 data.flingStart.velocityX = event.velocityX(); 808 data.flingStart.velocityX = event.velocityX();
808 data.flingStart.velocityY = event.velocityY(); 809 data.flingStart.velocityY = event.velocityY();
809 } else if (event.type() == EventTypeNames::gesturetap) { 810 } else if (event.type() == EventTypeNames::gesturetap) {
810 type = GestureTap; 811 m_type = GestureTap;
811 data.tap.tapCount = 1; 812 data.tap.tapCount = 1;
812 } 813 }
813 814
814 timeStampSeconds = event.platformTimeStamp(); 815 m_timeStampSeconds = event.platformTimeStamp();
815 modifiers = event.modifiers(); 816 m_modifiers = event.modifiers();
816 817
817 globalX = event.screenX(); 818 globalX = event.screenX();
818 globalY = event.screenY(); 819 globalY = event.screenY();
819 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt( 820 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt(
820 event.absoluteLocation(), layoutItem); 821 event.absoluteLocation(), layoutItem);
821 x = localPoint.x(); 822 x = localPoint.x();
822 y = localPoint.y(); 823 y = localPoint.y();
823 824
824 switch (event.source()) { 825 switch (event.source()) {
825 case GestureSourceTouchpad: 826 case GestureSourceTouchpad:
826 sourceDevice = WebGestureDeviceTouchpad; 827 sourceDevice = WebGestureDeviceTouchpad;
827 break; 828 break;
828 case GestureSourceTouchscreen: 829 case GestureSourceTouchscreen:
829 sourceDevice = WebGestureDeviceTouchscreen; 830 sourceDevice = WebGestureDeviceTouchscreen;
830 break; 831 break;
831 case GestureSourceUninitialized: 832 case GestureSourceUninitialized:
832 NOTREACHED(); 833 NOTREACHED();
833 } 834 }
834 } 835 }
835 836
836 Vector<PlatformMouseEvent> createPlatformMouseEventVector( 837 Vector<PlatformMouseEvent> createPlatformMouseEventVector(
837 Widget* widget, 838 Widget* widget,
838 const std::vector<const WebInputEvent*>& coalescedEvents) { 839 const std::vector<const WebInputEvent*>& coalescedEvents) {
839 Vector<PlatformMouseEvent> result; 840 Vector<PlatformMouseEvent> result;
840 for (const auto& event : coalescedEvents) { 841 for (const auto& event : coalescedEvents) {
841 DCHECK(WebInputEvent::isMouseEventType(event->type)); 842 DCHECK(WebInputEvent::isMouseEventType(event->type()));
842 result.append(PlatformMouseEventBuilder( 843 result.append(PlatformMouseEventBuilder(
843 widget, static_cast<const WebMouseEvent&>(*event))); 844 widget, static_cast<const WebMouseEvent&>(*event)));
844 } 845 }
845 return result; 846 return result;
846 } 847 }
847 848
848 Vector<PlatformTouchEvent> createPlatformTouchEventVector( 849 Vector<PlatformTouchEvent> createPlatformTouchEventVector(
849 Widget* widget, 850 Widget* widget,
850 const std::vector<const WebInputEvent*>& coalescedEvents) { 851 const std::vector<const WebInputEvent*>& coalescedEvents) {
851 Vector<PlatformTouchEvent> result; 852 Vector<PlatformTouchEvent> result;
852 for (const auto& event : coalescedEvents) { 853 for (const auto& event : coalescedEvents) {
853 DCHECK(WebInputEvent::isTouchEventType(event->type)); 854 DCHECK(WebInputEvent::isTouchEventType(event->type()));
854 result.append(PlatformTouchEventBuilder( 855 result.append(PlatformTouchEventBuilder(
855 widget, static_cast<const WebTouchEvent&>(*event))); 856 widget, static_cast<const WebTouchEvent&>(*event)));
856 } 857 }
857 return result; 858 return result;
858 } 859 }
859 860
860 } // namespace blink 861 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698