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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 return WebTouchPoint::StateCancelled; | 417 return WebTouchPoint::StateCancelled; |
418 if (type == EventTypeNames::touchstart) | 418 if (type == EventTypeNames::touchstart) |
419 return WebTouchPoint::StatePressed; | 419 return WebTouchPoint::StatePressed; |
420 if (type == EventTypeNames::touchmove) | 420 if (type == EventTypeNames::touchmove) |
421 return WebTouchPoint::StateMoved; | 421 return WebTouchPoint::StateMoved; |
422 return WebTouchPoint::StateUndefined; | 422 return WebTouchPoint::StateUndefined; |
423 } | 423 } |
424 | 424 |
425 PlatformTouchPointBuilder::PlatformTouchPointBuilder(Widget* widget, const WebTo
uchPoint& point) | 425 PlatformTouchPointBuilder::PlatformTouchPointBuilder(Widget* widget, const WebTo
uchPoint& point) |
426 { | 426 { |
427 float scale = widgetInputEventsScaleFactor(widget); | 427 float scale = 1.0f / widgetInputEventsScaleFactor(widget); |
428 IntSize offset = widgetInputEventsOffset(widget); | 428 IntSize offset = widgetInputEventsOffset(widget); |
429 IntPoint pinchViewport = pinchViewportOffset(widget); | 429 IntPoint pinchViewport = pinchViewportOffset(widget); |
430 m_id = point.id; | 430 m_id = point.id; |
431 m_state = toPlatformTouchPointState(point.state); | 431 m_state = toPlatformTouchPointState(point.state); |
432 m_pos = widget->convertFromContainingWindow(IntPoint( | 432 FloatPoint pos = (point.position - offset).scaledBy(scale); |
433 (point.position.x - offset.width()) / scale + pinchViewport.x(), | 433 pos.moveBy(pinchViewport); |
434 (point.position.y - offset.height()) / scale + pinchViewport.y())); | 434 IntPoint flooredPoint = flooredIntPoint(pos); |
435 m_screenPos = IntPoint(point.screenPosition.x, point.screenPosition.y); | 435 // This assumes convertFromContainingWindow does only translations, not scal
es. |
436 m_radiusY = point.radiusY / scale; | 436 m_pos = widget->convertFromContainingWindow(flooredPoint) + (pos - flooredPo
int); |
437 m_radiusX = point.radiusX / scale; | 437 m_screenPos = FloatPoint(point.screenPosition.x, point.screenPosition.y); |
| 438 m_radius = FloatSize(point.radiusX, point.radiusY).scaledBy(scale); |
438 m_rotationAngle = point.rotationAngle; | 439 m_rotationAngle = point.rotationAngle; |
439 m_force = point.force; | 440 m_force = point.force; |
440 } | 441 } |
441 | 442 |
442 PlatformTouchEventBuilder::PlatformTouchEventBuilder(Widget* widget, const WebTo
uchEvent& event) | 443 PlatformTouchEventBuilder::PlatformTouchEventBuilder(Widget* widget, const WebTo
uchEvent& event) |
443 { | 444 { |
444 m_type = toPlatformTouchEventType(event.type); | 445 m_type = toPlatformTouchEventType(event.type); |
445 | 446 |
446 m_modifiers = 0; | 447 m_modifiers = 0; |
447 if (event.modifiers & WebInputEvent::ShiftKey) | 448 if (event.modifiers & WebInputEvent::ShiftKey) |
(...skipping 20 matching lines...) Expand all Loading... |
468 modifiers |= WebInputEvent::ControlKey; | 469 modifiers |= WebInputEvent::ControlKey; |
469 if (event.shiftKey()) | 470 if (event.shiftKey()) |
470 modifiers |= WebInputEvent::ShiftKey; | 471 modifiers |= WebInputEvent::ShiftKey; |
471 if (event.altKey()) | 472 if (event.altKey()) |
472 modifiers |= WebInputEvent::AltKey; | 473 modifiers |= WebInputEvent::AltKey; |
473 if (event.metaKey()) | 474 if (event.metaKey()) |
474 modifiers |= WebInputEvent::MetaKey; | 475 modifiers |= WebInputEvent::MetaKey; |
475 return modifiers; | 476 return modifiers; |
476 } | 477 } |
477 | 478 |
| 479 static FloatPoint convertAbsoluteLocationForRenderObjectFloat(const LayoutPoint&
location, const WebCore::RenderObject& renderObject) |
| 480 { |
| 481 return renderObject.absoluteToLocal(location, UseTransforms); |
| 482 } |
| 483 |
478 static IntPoint convertAbsoluteLocationForRenderObject(const LayoutPoint& locati
on, const WebCore::RenderObject& renderObject) | 484 static IntPoint convertAbsoluteLocationForRenderObject(const LayoutPoint& locati
on, const WebCore::RenderObject& renderObject) |
479 { | 485 { |
480 return roundedIntPoint(renderObject.absoluteToLocal(location, UseTransforms)
); | 486 return roundedIntPoint(convertAbsoluteLocationForRenderObjectFloat(location,
renderObject)); |
481 } | 487 } |
482 | 488 |
483 static void updateWebMouseEventFromWebCoreMouseEvent(const MouseRelatedEvent& ev
ent, const Widget& widget, const WebCore::RenderObject& renderObject, WebMouseEv
ent& webEvent) | 489 static void updateWebMouseEventFromWebCoreMouseEvent(const MouseRelatedEvent& ev
ent, const Widget& widget, const WebCore::RenderObject& renderObject, WebMouseEv
ent& webEvent) |
484 { | 490 { |
485 webEvent.timeStampSeconds = event.timeStamp() / millisPerSecond; | 491 webEvent.timeStampSeconds = event.timeStamp() / millisPerSecond; |
486 webEvent.modifiers = getWebInputModifiers(event); | 492 webEvent.modifiers = getWebInputModifiers(event); |
487 | 493 |
488 ScrollView* view = toScrollView(widget.parent()); | 494 ScrollView* view = toScrollView(widget.parent()); |
489 IntPoint windowPoint = IntPoint(event.absoluteLocation().x(), event.absolute
Location().y()); | 495 IntPoint windowPoint = IntPoint(event.absoluteLocation().x(), event.absolute
Location().y()); |
490 if (view) | 496 if (view) |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 else if (event.type() == EventTypeNames::touchend) | 575 else if (event.type() == EventTypeNames::touchend) |
570 type = MouseUp; | 576 type = MouseUp; |
571 else | 577 else |
572 return; | 578 return; |
573 | 579 |
574 timeStampSeconds = event.timeStamp() / millisPerSecond; | 580 timeStampSeconds = event.timeStamp() / millisPerSecond; |
575 modifiers = getWebInputModifiers(event); | 581 modifiers = getWebInputModifiers(event); |
576 | 582 |
577 // The mouse event co-ordinates should be generated from the co-ordinates of
the touch point. | 583 // The mouse event co-ordinates should be generated from the co-ordinates of
the touch point. |
578 ScrollView* view = toScrollView(widget->parent()); | 584 ScrollView* view = toScrollView(widget->parent()); |
579 IntPoint windowPoint = IntPoint(touch->absoluteLocation().x(), touch->absolu
teLocation().y()); | 585 IntPoint windowPoint = roundedIntPoint(touch->absoluteLocation()); |
580 if (view) | 586 if (view) |
581 windowPoint = view->contentsToWindow(windowPoint); | 587 windowPoint = view->contentsToWindow(windowPoint); |
582 globalX = touch->screenX(); | 588 IntPoint screenPoint = roundedIntPoint(touch->screenLocation()); |
583 globalY = touch->screenY(); | 589 globalX = screenPoint.x(); |
| 590 globalY = screenPoint.y(); |
584 windowX = windowPoint.x(); | 591 windowX = windowPoint.x(); |
585 windowY = windowPoint.y(); | 592 windowY = windowPoint.y(); |
586 | 593 |
587 button = WebMouseEvent::ButtonLeft; | 594 button = WebMouseEvent::ButtonLeft; |
588 modifiers |= WebInputEvent::LeftButtonDown; | 595 modifiers |= WebInputEvent::LeftButtonDown; |
589 clickCount = (type == MouseDown || type == MouseUp); | 596 clickCount = (type == MouseDown || type == MouseUp); |
590 | 597 |
591 IntPoint localPoint = convertAbsoluteLocationForRenderObject(touch->absolute
Location(), *renderObject); | 598 IntPoint localPoint = convertAbsoluteLocationForRenderObject(touch->absolute
Location(), *renderObject); |
592 x = localPoint.x(); | 599 x = localPoint.x(); |
593 y = localPoint.y(); | 600 y = localPoint.y(); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 } | 744 } |
738 | 745 |
739 static void addTouchPoints(const Widget* widget, const AtomicString& touchType,
TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsLength, con
st WebCore::RenderObject* renderObject) | 746 static void addTouchPoints(const Widget* widget, const AtomicString& touchType,
TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsLength, con
st WebCore::RenderObject* renderObject) |
740 { | 747 { |
741 unsigned numberOfTouches = std::min(touches->length(), static_cast<unsigned>
(WebTouchEvent::touchesLengthCap)); | 748 unsigned numberOfTouches = std::min(touches->length(), static_cast<unsigned>
(WebTouchEvent::touchesLengthCap)); |
742 for (unsigned i = 0; i < numberOfTouches; ++i) { | 749 for (unsigned i = 0; i < numberOfTouches; ++i) { |
743 const Touch* touch = touches->item(i); | 750 const Touch* touch = touches->item(i); |
744 | 751 |
745 WebTouchPoint point; | 752 WebTouchPoint point; |
746 point.id = touch->identifier(); | 753 point.id = touch->identifier(); |
747 point.screenPosition = WebFloatPoint(touch->screenX(), touch->screenY())
; | 754 point.screenPosition = touch->screenLocation(); |
748 point.position = convertAbsoluteLocationForRenderObject(touch->absoluteL
ocation(), *renderObject); | 755 point.position = convertAbsoluteLocationForRenderObjectFloat(touch->abso
luteLocation(), *renderObject); |
749 point.radiusX = touch->webkitRadiusX(); | 756 point.radiusX = touch->webkitRadiusX(); |
750 point.radiusY = touch->webkitRadiusY(); | 757 point.radiusY = touch->webkitRadiusY(); |
751 point.rotationAngle = touch->webkitRotationAngle(); | 758 point.rotationAngle = touch->webkitRotationAngle(); |
752 point.force = touch->webkitForce(); | 759 point.force = touch->webkitForce(); |
753 point.state = toWebTouchPointState(touchType); | 760 point.state = toWebTouchPointState(touchType); |
754 | 761 |
755 touchPoints[i] = point; | 762 touchPoints[i] = point; |
756 } | 763 } |
757 *touchPointsLength = numberOfTouches; | 764 *touchPointsLength = numberOfTouches; |
758 } | 765 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 modifiers = getWebInputModifiers(event); | 812 modifiers = getWebInputModifiers(event); |
806 | 813 |
807 globalX = event.screenX(); | 814 globalX = event.screenX(); |
808 globalY = event.screenY(); | 815 globalY = event.screenY(); |
809 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); | 816 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); |
810 x = localPoint.x(); | 817 x = localPoint.x(); |
811 y = localPoint.y(); | 818 y = localPoint.y(); |
812 } | 819 } |
813 | 820 |
814 } // namespace blink | 821 } // namespace blink |
OLD | NEW |