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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 static FloatPoint convertAbsoluteLocationForRenderObjectFloat(const LayoutPoint&
location, const RenderObject& renderObject) | 477 static FloatPoint convertAbsoluteLocationForRenderObjectFloat(const LayoutPoint&
location, const RenderObject& renderObject) |
478 { | 478 { |
479 return renderObject.absoluteToLocal(location, UseTransforms); | 479 return renderObject.absoluteToLocal(location, UseTransforms); |
480 } | 480 } |
481 | 481 |
482 static IntPoint convertAbsoluteLocationForRenderObject(const LayoutPoint& locati
on, const RenderObject& renderObject) | 482 static IntPoint convertAbsoluteLocationForRenderObject(const LayoutPoint& locati
on, const RenderObject& renderObject) |
483 { | 483 { |
484 return roundedIntPoint(convertAbsoluteLocationForRenderObjectFloat(location,
renderObject)); | 484 return roundedIntPoint(convertAbsoluteLocationForRenderObjectFloat(location,
renderObject)); |
485 } | 485 } |
486 | 486 |
487 static void updateWebMouseEventFromCoreMouseEvent(const MouseRelatedEvent& event
, const Widget& widget, const RenderObject& renderObject, WebMouseEvent& webEven
t) | 487 // FIXME: Change |widget| to const Widget& after RemoteFrames get |
| 488 // RemoteFrameViews. When this happens, check widget.isScrollView(), because |
| 489 // RemoteFrameView is a Widget but not a ScrollView. |
| 490 static void updateWebMouseEventFromCoreMouseEvent(const MouseRelatedEvent& event
, const Widget* widget, const RenderObject& renderObject, WebMouseEvent& webEven
t) |
488 { | 491 { |
489 webEvent.timeStampSeconds = event.timeStamp() / millisPerSecond; | 492 webEvent.timeStampSeconds = event.timeStamp() / millisPerSecond; |
490 webEvent.modifiers = getWebInputModifiers(event); | 493 webEvent.modifiers = getWebInputModifiers(event); |
491 | 494 |
492 ScrollView* view = toScrollView(widget.parent()); | 495 ScrollView* view = widget ? toScrollView(widget->parent()) : 0; |
493 IntPoint windowPoint = IntPoint(event.absoluteLocation().x(), event.absolute
Location().y()); | 496 IntPoint windowPoint = IntPoint(event.absoluteLocation().x(), event.absolute
Location().y()); |
494 if (view) | 497 if (view) |
495 windowPoint = view->contentsToWindow(windowPoint); | 498 windowPoint = view->contentsToWindow(windowPoint); |
496 webEvent.globalX = event.screenX(); | 499 webEvent.globalX = event.screenX(); |
497 webEvent.globalY = event.screenY(); | 500 webEvent.globalY = event.screenY(); |
498 webEvent.windowX = windowPoint.x(); | 501 webEvent.windowX = windowPoint.x(); |
499 webEvent.windowY = windowPoint.y(); | 502 webEvent.windowY = windowPoint.y(); |
500 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), renderObject); | 503 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), renderObject); |
501 webEvent.x = localPoint.x(); | 504 webEvent.x = localPoint.x(); |
502 webEvent.y = localPoint.y(); | 505 webEvent.y = localPoint.y(); |
503 } | 506 } |
504 | 507 |
505 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const RenderObj
ect* renderObject, const MouseEvent& event) | 508 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const RenderObj
ect* renderObject, const MouseEvent& event) |
506 { | 509 { |
507 if (event.type() == EventTypeNames::mousemove) | 510 if (event.type() == EventTypeNames::mousemove) |
508 type = WebInputEvent::MouseMove; | 511 type = WebInputEvent::MouseMove; |
509 else if (event.type() == EventTypeNames::mouseout) | 512 else if (event.type() == EventTypeNames::mouseout) |
510 type = WebInputEvent::MouseLeave; | 513 type = WebInputEvent::MouseLeave; |
511 else if (event.type() == EventTypeNames::mouseover) | 514 else if (event.type() == EventTypeNames::mouseover) |
512 type = WebInputEvent::MouseEnter; | 515 type = WebInputEvent::MouseEnter; |
513 else if (event.type() == EventTypeNames::mousedown) | 516 else if (event.type() == EventTypeNames::mousedown) |
514 type = WebInputEvent::MouseDown; | 517 type = WebInputEvent::MouseDown; |
515 else if (event.type() == EventTypeNames::mouseup) | 518 else if (event.type() == EventTypeNames::mouseup) |
516 type = WebInputEvent::MouseUp; | 519 type = WebInputEvent::MouseUp; |
517 else if (event.type() == EventTypeNames::contextmenu) | 520 else if (event.type() == EventTypeNames::contextmenu) |
518 type = WebInputEvent::ContextMenu; | 521 type = WebInputEvent::ContextMenu; |
519 else | 522 else |
520 return; // Skip all other mouse events. | 523 return; // Skip all other mouse events. |
521 | 524 |
522 updateWebMouseEventFromCoreMouseEvent(event, *widget, *renderObject, *this); | 525 updateWebMouseEventFromCoreMouseEvent(event, widget, *renderObject, *this); |
523 | 526 |
524 switch (event.button()) { | 527 switch (event.button()) { |
525 case LeftButton: | 528 case LeftButton: |
526 button = WebMouseEvent::ButtonLeft; | 529 button = WebMouseEvent::ButtonLeft; |
527 break; | 530 break; |
528 case MiddleButton: | 531 case MiddleButton: |
529 button = WebMouseEvent::ButtonMiddle; | 532 button = WebMouseEvent::ButtonMiddle; |
530 break; | 533 break; |
531 case RightButton: | 534 case RightButton: |
532 button = WebMouseEvent::ButtonRight; | 535 button = WebMouseEvent::ButtonRight; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 | 645 |
643 button = static_cast<Button>(event.button()); | 646 button = static_cast<Button>(event.button()); |
644 clickCount = event.clickCount(); | 647 clickCount = event.clickCount(); |
645 } | 648 } |
646 | 649 |
647 WebMouseWheelEventBuilder::WebMouseWheelEventBuilder(const Widget* widget, const
RenderObject* renderObject, const WheelEvent& event) | 650 WebMouseWheelEventBuilder::WebMouseWheelEventBuilder(const Widget* widget, const
RenderObject* renderObject, const WheelEvent& event) |
648 { | 651 { |
649 if (event.type() != EventTypeNames::wheel && event.type() != EventTypeNames:
:mousewheel) | 652 if (event.type() != EventTypeNames::wheel && event.type() != EventTypeNames:
:mousewheel) |
650 return; | 653 return; |
651 type = WebInputEvent::MouseWheel; | 654 type = WebInputEvent::MouseWheel; |
652 updateWebMouseEventFromCoreMouseEvent(event, *widget, *renderObject, *this); | 655 updateWebMouseEventFromCoreMouseEvent(event, widget, *renderObject, *this); |
653 deltaX = -event.deltaX(); | 656 deltaX = -event.deltaX(); |
654 deltaY = -event.deltaY(); | 657 deltaY = -event.deltaY(); |
655 wheelTicksX = event.ticksX(); | 658 wheelTicksX = event.ticksX(); |
656 wheelTicksY = event.ticksY(); | 659 wheelTicksY = event.ticksY(); |
657 scrollByPage = event.deltaMode() == WheelEvent::DOM_DELTA_PAGE; | 660 scrollByPage = event.deltaMode() == WheelEvent::DOM_DELTA_PAGE; |
658 } | 661 } |
659 | 662 |
660 WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event) | 663 WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event) |
661 { | 664 { |
662 if (event.type() == EventTypeNames::keydown) | 665 if (event.type() == EventTypeNames::keydown) |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 modifiers = getWebInputModifiers(event); | 831 modifiers = getWebInputModifiers(event); |
829 | 832 |
830 globalX = event.screenX(); | 833 globalX = event.screenX(); |
831 globalY = event.screenY(); | 834 globalY = event.screenY(); |
832 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); | 835 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); |
833 x = localPoint.x(); | 836 x = localPoint.x(); |
834 y = localPoint.y(); | 837 y = localPoint.y(); |
835 } | 838 } |
836 | 839 |
837 } // namespace blink | 840 } // namespace blink |
OLD | NEW |