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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 | 744 |
739 static void addTouchPoints(const Widget* widget, const AtomicString& touchType,
TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsLength, con
st WebCore::RenderObject* renderObject) | 745 static void addTouchPoints(const Widget* widget, const AtomicString& touchType,
TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsLength, con
st WebCore::RenderObject* renderObject) |
740 { | 746 { |
741 unsigned numberOfTouches = std::min(touches->length(), static_cast<unsigned>
(WebTouchEvent::touchesLengthCap)); | 747 unsigned numberOfTouches = std::min(touches->length(), static_cast<unsigned>
(WebTouchEvent::touchesLengthCap)); |
742 for (unsigned i = 0; i < numberOfTouches; ++i) { | 748 for (unsigned i = 0; i < numberOfTouches; ++i) { |
743 const Touch* touch = touches->item(i); | 749 const Touch* touch = touches->item(i); |
744 | 750 |
745 WebTouchPoint point; | 751 WebTouchPoint point; |
746 point.id = touch->identifier(); | 752 point.id = touch->identifier(); |
747 point.screenPosition = WebFloatPoint(touch->screenX(), touch->screenY())
; | 753 point.screenPosition = WebFloatPoint(touch->screenX(), touch->screenY())
; |
748 point.position = convertAbsoluteLocationForRenderObject(touch->absoluteL
ocation(), *renderObject); | 754 point.position = convertAbsoluteLocationForRenderObjectFloat(touch->abso
luteLocation(), *renderObject); |
749 point.radiusX = touch->webkitRadiusX(); | 755 point.radiusX = touch->webkitRadiusX(); |
750 point.radiusY = touch->webkitRadiusY(); | 756 point.radiusY = touch->webkitRadiusY(); |
751 point.rotationAngle = touch->webkitRotationAngle(); | 757 point.rotationAngle = touch->webkitRotationAngle(); |
752 point.force = touch->webkitForce(); | 758 point.force = touch->webkitForce(); |
753 point.state = toWebTouchPointState(touchType); | 759 point.state = toWebTouchPointState(touchType); |
754 | 760 |
755 touchPoints[i] = point; | 761 touchPoints[i] = point; |
756 } | 762 } |
757 *touchPointsLength = numberOfTouches; | 763 *touchPointsLength = numberOfTouches; |
758 } | 764 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 modifiers = getWebInputModifiers(event); | 811 modifiers = getWebInputModifiers(event); |
806 | 812 |
807 globalX = event.screenX(); | 813 globalX = event.screenX(); |
808 globalY = event.screenY(); | 814 globalY = event.screenY(); |
809 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); | 815 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); |
810 x = localPoint.x(); | 816 x = localPoint.x(); |
811 y = localPoint.y(); | 817 y = localPoint.y(); |
812 } | 818 } |
813 | 819 |
814 } // namespace blink | 820 } // namespace blink |
OLD | NEW |