OLD | NEW |
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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 return modifiers; | 423 return modifiers; |
424 } | 424 } |
425 | 425 |
426 static IntPoint convertAbsoluteLocationForRenderObject(const LayoutPoint& locati
on, const WebCore::RenderObject& renderObject) | 426 static IntPoint convertAbsoluteLocationForRenderObject(const LayoutPoint& locati
on, const WebCore::RenderObject& renderObject) |
427 { | 427 { |
428 return roundedIntPoint(renderObject.absoluteToLocal(location, UseTransforms)
); | 428 return roundedIntPoint(renderObject.absoluteToLocal(location, UseTransforms)
); |
429 } | 429 } |
430 | 430 |
431 static void updateWebMouseEventFromWebCoreMouseEvent(const MouseRelatedEvent& ev
ent, const Widget& widget, const WebCore::RenderObject& renderObject, WebMouseEv
ent& webEvent) | 431 static void updateWebMouseEventFromWebCoreMouseEvent(const MouseRelatedEvent& ev
ent, const Widget& widget, const WebCore::RenderObject& renderObject, WebMouseEv
ent& webEvent) |
432 { | 432 { |
433 float scale = widgetScaleFactor(&widget); | |
434 webEvent.timeStampSeconds = event.timeStamp() / millisPerSecond; | 433 webEvent.timeStampSeconds = event.timeStamp() / millisPerSecond; |
435 webEvent.modifiers = getWebInputModifiers(event); | 434 webEvent.modifiers = getWebInputModifiers(event); |
436 | 435 |
437 ScrollView* view = widget.root(); | 436 ScrollView* view = widget.root(); |
438 IntPoint windowPoint = view->contentsToWindow(IntPoint(event.absoluteLocatio
n().x(), event.absoluteLocation().y())); | 437 IntPoint windowPoint = view->contentsToWindow(IntPoint(event.absoluteLocatio
n().x(), event.absoluteLocation().y())); |
439 webEvent.globalX = event.screenX(); | 438 webEvent.globalX = event.screenX(); |
440 webEvent.globalY = event.screenY(); | 439 webEvent.globalY = event.screenY(); |
441 webEvent.windowX = windowPoint.x() * scale; | 440 webEvent.windowX = windowPoint.x(); |
442 webEvent.windowY = windowPoint.y() * scale; | 441 webEvent.windowY = windowPoint.y(); |
443 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), renderObject); | 442 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), renderObject); |
444 webEvent.x = localPoint.x() * scale; | 443 webEvent.x = localPoint.x(); |
445 webEvent.y = localPoint.y() * scale; | 444 webEvent.y = localPoint.y(); |
446 } | 445 } |
447 | 446 |
448 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const WebCore::
RenderObject* renderObject, const MouseEvent& event) | 447 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const WebCore::
RenderObject* renderObject, const MouseEvent& event) |
449 { | 448 { |
450 if (event.type() == eventNames().mousemoveEvent) | 449 if (event.type() == eventNames().mousemoveEvent) |
451 type = WebInputEvent::MouseMove; | 450 type = WebInputEvent::MouseMove; |
452 else if (event.type() == eventNames().mouseoutEvent) | 451 else if (event.type() == eventNames().mouseoutEvent) |
453 type = WebInputEvent::MouseLeave; | 452 type = WebInputEvent::MouseLeave; |
454 else if (event.type() == eventNames().mouseoverEvent) | 453 else if (event.type() == eventNames().mouseoverEvent) |
455 type = WebInputEvent::MouseEnter; | 454 type = WebInputEvent::MouseEnter; |
(...skipping 26 matching lines...) Expand all Loading... |
482 break; | 481 break; |
483 case MiddleButton: | 482 case MiddleButton: |
484 modifiers |= WebInputEvent::MiddleButtonDown; | 483 modifiers |= WebInputEvent::MiddleButtonDown; |
485 break; | 484 break; |
486 case RightButton: | 485 case RightButton: |
487 modifiers |= WebInputEvent::RightButtonDown; | 486 modifiers |= WebInputEvent::RightButtonDown; |
488 break; | 487 break; |
489 } | 488 } |
490 } | 489 } |
491 #if ENABLE(POINTER_LOCK) | 490 #if ENABLE(POINTER_LOCK) |
492 float scale = widgetScaleFactor(widget); | 491 movementX = event.webkitMovementX(); |
493 movementX = event.webkitMovementX() * scale; | 492 movementY = event.webkitMovementY(); |
494 movementY = event.webkitMovementY() * scale; | |
495 #endif | 493 #endif |
496 clickCount = event.detail(); | 494 clickCount = event.detail(); |
497 } | 495 } |
498 | 496 |
499 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const WebCore::
RenderObject* renderObject, const TouchEvent& event) | 497 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const WebCore::
RenderObject* renderObject, const TouchEvent& event) |
500 { | 498 { |
501 float scale = widgetScaleFactor(widget); | |
502 if (!event.touches()) | 499 if (!event.touches()) |
503 return; | 500 return; |
504 if (event.touches()->length() != 1) { | 501 if (event.touches()->length() != 1) { |
505 if (event.touches()->length() || event.type() != eventNames().touchendEv
ent || !event.changedTouches() || event.changedTouches()->length() != 1) | 502 if (event.touches()->length() || event.type() != eventNames().touchendEv
ent || !event.changedTouches() || event.changedTouches()->length() != 1) |
506 return; | 503 return; |
507 } | 504 } |
508 | 505 |
509 const Touch* touch = event.touches()->length() == 1 ? event.touches()->item(
0) : event.changedTouches()->item(0); | 506 const Touch* touch = event.touches()->length() == 1 ? event.touches()->item(
0) : event.changedTouches()->item(0); |
510 if (touch->identifier()) | 507 if (touch->identifier()) |
511 return; | 508 return; |
512 | 509 |
513 if (event.type() == eventNames().touchstartEvent) | 510 if (event.type() == eventNames().touchstartEvent) |
514 type = MouseDown; | 511 type = MouseDown; |
515 else if (event.type() == eventNames().touchmoveEvent) | 512 else if (event.type() == eventNames().touchmoveEvent) |
516 type = MouseMove; | 513 type = MouseMove; |
517 else if (event.type() == eventNames().touchendEvent) | 514 else if (event.type() == eventNames().touchendEvent) |
518 type = MouseUp; | 515 type = MouseUp; |
519 else | 516 else |
520 return; | 517 return; |
521 | 518 |
522 updateWebMouseEventFromWebCoreMouseEvent(event, *widget, *renderObject, *thi
s); | 519 updateWebMouseEventFromWebCoreMouseEvent(event, *widget, *renderObject, *thi
s); |
523 | 520 |
524 button = WebMouseEvent::ButtonLeft; | 521 button = WebMouseEvent::ButtonLeft; |
525 modifiers |= WebInputEvent::LeftButtonDown; | 522 modifiers |= WebInputEvent::LeftButtonDown; |
526 clickCount = (type == MouseDown || type == MouseUp); | 523 clickCount = (type == MouseDown || type == MouseUp); |
527 | 524 |
528 IntPoint localPoint = convertAbsoluteLocationForRenderObject(touch->absolute
Location(), *renderObject); | 525 IntPoint localPoint = convertAbsoluteLocationForRenderObject(touch->absolute
Location(), *renderObject); |
529 x = localPoint.x() * scale; | 526 x = localPoint.x(); |
530 y = localPoint.y() * scale; | 527 y = localPoint.y(); |
531 } | 528 } |
532 | 529 |
533 WebMouseWheelEventBuilder::WebMouseWheelEventBuilder(const Widget* widget, const
WebCore::RenderObject* renderObject, const WheelEvent& event) | 530 WebMouseWheelEventBuilder::WebMouseWheelEventBuilder(const Widget* widget, const
WebCore::RenderObject* renderObject, const WheelEvent& event) |
534 { | 531 { |
535 if (event.type() != eventNames().mousewheelEvent) | 532 if (event.type() != eventNames().mousewheelEvent) |
536 return; | 533 return; |
537 type = WebInputEvent::MouseWheel; | 534 type = WebInputEvent::MouseWheel; |
538 updateWebMouseEventFromWebCoreMouseEvent(event, *widget, *renderObject, *thi
s); | 535 updateWebMouseEventFromWebCoreMouseEvent(event, *widget, *renderObject, *thi
s); |
539 deltaX = static_cast<float>(event.rawDeltaX()); | 536 deltaX = static_cast<float>(event.rawDeltaX()); |
540 deltaY = static_cast<float>(event.rawDeltaY()); | 537 deltaY = static_cast<float>(event.rawDeltaY()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 text[i] = event.keyEvent()->text()[i]; | 573 text[i] = event.keyEvent()->text()[i]; |
577 unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i]; | 574 unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i]; |
578 } | 575 } |
579 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), event.keyIdentif
ier().length()); | 576 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), event.keyIdentif
ier().length()); |
580 } | 577 } |
581 | 578 |
582 #if ENABLE(TOUCH_EVENTS) | 579 #if ENABLE(TOUCH_EVENTS) |
583 | 580 |
584 static void addTouchPoints(const Widget* widget, const AtomicString& touchType,
TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsLength, con
st WebCore::RenderObject* renderObject) | 581 static void addTouchPoints(const Widget* widget, const AtomicString& touchType,
TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsLength, con
st WebCore::RenderObject* renderObject) |
585 { | 582 { |
586 float scale = widgetScaleFactor(widget); | |
587 unsigned numberOfTouches = std::min(touches->length(), static_cast<unsigned>
(WebTouchEvent::touchesLengthCap)); | 583 unsigned numberOfTouches = std::min(touches->length(), static_cast<unsigned>
(WebTouchEvent::touchesLengthCap)); |
588 for (unsigned i = 0; i < numberOfTouches; ++i) { | 584 for (unsigned i = 0; i < numberOfTouches; ++i) { |
589 const Touch* touch = touches->item(i); | 585 const Touch* touch = touches->item(i); |
590 | 586 |
591 WebTouchPoint point; | 587 WebTouchPoint point; |
592 point.id = touch->identifier(); | 588 point.id = touch->identifier(); |
593 point.screenPosition = WebPoint(touch->screenX(), touch->screenY()); | 589 point.screenPosition = WebPoint(touch->screenX(), touch->screenY()); |
594 point.position = convertAbsoluteLocationForRenderObject(touch->absoluteL
ocation(), *renderObject); | 590 point.position = convertAbsoluteLocationForRenderObject(touch->absoluteL
ocation(), *renderObject); |
595 point.position.x *= scale; | 591 point.radiusX = touch->webkitRadiusX(); |
596 point.position.y *= scale; | 592 point.radiusY = touch->webkitRadiusY(); |
597 point.radiusX = touch->webkitRadiusX() * scale; | |
598 point.radiusY = touch->webkitRadiusY() * scale; | |
599 point.rotationAngle = touch->webkitRotationAngle(); | 593 point.rotationAngle = touch->webkitRotationAngle(); |
600 point.force = touch->webkitForce(); | 594 point.force = touch->webkitForce(); |
601 point.state = toWebTouchPointState(touchType); | 595 point.state = toWebTouchPointState(touchType); |
602 | 596 |
603 touchPoints[i] = point; | 597 touchPoints[i] = point; |
604 } | 598 } |
605 *touchPointsLength = numberOfTouches; | 599 *touchPointsLength = numberOfTouches; |
606 } | 600 } |
607 | 601 |
608 WebTouchEventBuilder::WebTouchEventBuilder(const Widget* widget, const WebCore::
RenderObject* renderObject, const TouchEvent& event) | 602 WebTouchEventBuilder::WebTouchEventBuilder(const Widget* widget, const WebCore::
RenderObject* renderObject, const TouchEvent& event) |
(...skipping 18 matching lines...) Expand all Loading... |
627 addTouchPoints(widget, event.type(), event.touches(), touches, &touchesLengt
h, renderObject); | 621 addTouchPoints(widget, event.type(), event.touches(), touches, &touchesLengt
h, renderObject); |
628 addTouchPoints(widget, event.type(), event.changedTouches(), changedTouches,
&changedTouchesLength, renderObject); | 622 addTouchPoints(widget, event.type(), event.changedTouches(), changedTouches,
&changedTouchesLength, renderObject); |
629 addTouchPoints(widget, event.type(), event.targetTouches(), targetTouches, &
targetTouchesLength, renderObject); | 623 addTouchPoints(widget, event.type(), event.targetTouches(), targetTouches, &
targetTouchesLength, renderObject); |
630 } | 624 } |
631 | 625 |
632 #endif // ENABLE(TOUCH_EVENTS) | 626 #endif // ENABLE(TOUCH_EVENTS) |
633 | 627 |
634 #if ENABLE(GESTURE_EVENTS) | 628 #if ENABLE(GESTURE_EVENTS) |
635 WebGestureEventBuilder::WebGestureEventBuilder(const Widget* widget, const WebCo
re::RenderObject* renderObject, const GestureEvent& event) | 629 WebGestureEventBuilder::WebGestureEventBuilder(const Widget* widget, const WebCo
re::RenderObject* renderObject, const GestureEvent& event) |
636 { | 630 { |
637 float scale = widgetScaleFactor(widget); | |
638 if (event.type() == eventNames().gesturetapEvent) | 631 if (event.type() == eventNames().gesturetapEvent) |
639 type = GestureTap; | 632 type = GestureTap; |
640 else if (event.type() == eventNames().gesturetapdownEvent) | 633 else if (event.type() == eventNames().gesturetapdownEvent) |
641 type = GestureTapDown; | 634 type = GestureTapDown; |
642 else if (event.type() == eventNames().gesturescrollstartEvent) | 635 else if (event.type() == eventNames().gesturescrollstartEvent) |
643 type = GestureScrollBegin; | 636 type = GestureScrollBegin; |
644 else if (event.type() == eventNames().gesturescrollendEvent) | 637 else if (event.type() == eventNames().gesturescrollendEvent) |
645 type = GestureScrollEnd; | 638 type = GestureScrollEnd; |
646 else if (event.type() == eventNames().gesturescrollupdateEvent) { | 639 else if (event.type() == eventNames().gesturescrollupdateEvent) { |
647 type = GestureScrollUpdate; | 640 type = GestureScrollUpdate; |
648 data.scrollUpdate.deltaX = event.deltaX() * scale; | 641 data.scrollUpdate.deltaX = event.deltaX(); |
649 data.scrollUpdate.deltaY = event.deltaY() * scale; | 642 data.scrollUpdate.deltaY = event.deltaY(); |
650 } | 643 } |
651 | 644 |
652 timeStampSeconds = event.timeStamp() / millisPerSecond; | 645 timeStampSeconds = event.timeStamp() / millisPerSecond; |
653 modifiers = getWebInputModifiers(event); | 646 modifiers = getWebInputModifiers(event); |
654 | 647 |
655 globalX = event.screenX(); | 648 globalX = event.screenX(); |
656 globalY = event.screenY(); | 649 globalY = event.screenY(); |
657 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); | 650 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); |
658 x = localPoint.x() * scale; | 651 x = localPoint.x(); |
659 y = localPoint.y() * scale; | 652 y = localPoint.y(); |
660 } | 653 } |
661 #endif // ENABLE(GESTURE_EVENTS) | 654 #endif // ENABLE(GESTURE_EVENTS) |
662 | 655 |
663 } // namespace WebKit | 656 } // namespace WebKit |
OLD | NEW |