| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2014 Opera Software ASA. All rights reserved. | 3 * Copyright (C) 2014 Opera Software ASA. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 | 701 |
| 702 void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) { | 702 void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) { |
| 703 DCHECK(parent()->isFrameView()); | 703 DCHECK(parent()->isFrameView()); |
| 704 | 704 |
| 705 // We cache the parent FrameView here as the plugin widget could be deleted | 705 // We cache the parent FrameView here as the plugin widget could be deleted |
| 706 // in the call to HandleEvent. See http://b/issue?id=1362948 | 706 // in the call to HandleEvent. See http://b/issue?id=1362948 |
| 707 FrameView* parentView = toFrameView(parent()); | 707 FrameView* parentView = toFrameView(parent()); |
| 708 | 708 |
| 709 WebMouseEventBuilder webEvent(this, LayoutItem(m_element->layoutObject()), | 709 WebMouseEventBuilder webEvent(this, LayoutItem(m_element->layoutObject()), |
| 710 *event); | 710 *event); |
| 711 if (webEvent.type == WebInputEvent::Undefined) | 711 if (webEvent.type() == WebInputEvent::Undefined) |
| 712 return; | 712 return; |
| 713 | 713 |
| 714 if (event->type() == EventTypeNames::mousedown) | 714 if (event->type() == EventTypeNames::mousedown) |
| 715 focusPlugin(); | 715 focusPlugin(); |
| 716 | 716 |
| 717 WebCursorInfo cursorInfo; | 717 WebCursorInfo cursorInfo; |
| 718 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo) != | 718 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo) != |
| 719 WebInputEventResult::NotHandled) | 719 WebInputEventResult::NotHandled) |
| 720 event->setDefaultHandled(); | 720 event->setDefaultHandled(); |
| 721 | 721 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 translatedEvent.y = localPoint.y(); | 768 translatedEvent.y = localPoint.y(); |
| 769 | 769 |
| 770 WebCursorInfo cursorInfo; | 770 WebCursorInfo cursorInfo; |
| 771 if (m_webPlugin->handleInputEvent(translatedEvent, cursorInfo) != | 771 if (m_webPlugin->handleInputEvent(translatedEvent, cursorInfo) != |
| 772 WebInputEventResult::NotHandled) | 772 WebInputEventResult::NotHandled) |
| 773 event->setDefaultHandled(); | 773 event->setDefaultHandled(); |
| 774 } | 774 } |
| 775 | 775 |
| 776 void WebPluginContainerImpl::handleKeyboardEvent(KeyboardEvent* event) { | 776 void WebPluginContainerImpl::handleKeyboardEvent(KeyboardEvent* event) { |
| 777 WebKeyboardEventBuilder webEvent(*event); | 777 WebKeyboardEventBuilder webEvent(*event); |
| 778 if (webEvent.type == WebInputEvent::Undefined) | 778 if (webEvent.type() == WebInputEvent::Undefined) |
| 779 return; | 779 return; |
| 780 | 780 |
| 781 if (webEvent.type == WebInputEvent::KeyDown) { | 781 if (webEvent.type() == WebInputEvent::KeyDown) { |
| 782 #if OS(MACOSX) | 782 #if OS(MACOSX) |
| 783 if ((webEvent.modifiers & WebInputEvent::InputModifiers) == | 783 if ((webEvent.modifiers() & WebInputEvent::InputModifiers) == |
| 784 WebInputEvent::MetaKey | 784 WebInputEvent::MetaKey |
| 785 #else | 785 #else |
| 786 if ((webEvent.modifiers & WebInputEvent::InputModifiers) == | 786 if ((webEvent.modifiers() & WebInputEvent::InputModifiers) == |
| 787 WebInputEvent::ControlKey | 787 WebInputEvent::ControlKey |
| 788 #endif | 788 #endif |
| 789 && (webEvent.windowsKeyCode == VKEY_C || | 789 && (webEvent.windowsKeyCode == VKEY_C || |
| 790 webEvent.windowsKeyCode == VKEY_INSERT) | 790 webEvent.windowsKeyCode == VKEY_INSERT) |
| 791 // Only copy if there's a selection, so that we only ever do this | 791 // Only copy if there's a selection, so that we only ever do this |
| 792 // for Pepper plugins that support copying. Windowless NPAPI | 792 // for Pepper plugins that support copying. Windowless NPAPI |
| 793 // plugins will get the event as before. | 793 // plugins will get the event as before. |
| 794 && m_webPlugin->hasSelection()) { | 794 && m_webPlugin->hasSelection()) { |
| 795 copy(); | 795 copy(); |
| 796 event->setDefaultHandled(); | 796 event->setDefaultHandled(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 810 event->setDefaultHandled(); | 810 event->setDefaultHandled(); |
| 811 } | 811 } |
| 812 | 812 |
| 813 void WebPluginContainerImpl::handleTouchEvent(TouchEvent* event) { | 813 void WebPluginContainerImpl::handleTouchEvent(TouchEvent* event) { |
| 814 switch (m_touchEventRequestType) { | 814 switch (m_touchEventRequestType) { |
| 815 case TouchEventRequestTypeNone: | 815 case TouchEventRequestTypeNone: |
| 816 return; | 816 return; |
| 817 case TouchEventRequestTypeRaw: { | 817 case TouchEventRequestTypeRaw: { |
| 818 WebTouchEventBuilder webEvent(LayoutItem(m_element->layoutObject()), | 818 WebTouchEventBuilder webEvent(LayoutItem(m_element->layoutObject()), |
| 819 *event); | 819 *event); |
| 820 if (webEvent.type == WebInputEvent::Undefined) | 820 if (webEvent.type() == WebInputEvent::Undefined) |
| 821 return; | 821 return; |
| 822 | 822 |
| 823 if (event->type() == EventTypeNames::touchstart) | 823 if (event->type() == EventTypeNames::touchstart) |
| 824 focusPlugin(); | 824 focusPlugin(); |
| 825 | 825 |
| 826 WebCursorInfo cursorInfo; | 826 WebCursorInfo cursorInfo; |
| 827 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo) != | 827 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo) != |
| 828 WebInputEventResult::NotHandled) | 828 WebInputEventResult::NotHandled) |
| 829 event->setDefaultHandled(); | 829 event->setDefaultHandled(); |
| 830 // FIXME: Can a plugin change the cursor from a touch-event callback? | 830 // FIXME: Can a plugin change the cursor from a touch-event callback? |
| 831 return; | 831 return; |
| 832 } | 832 } |
| 833 case TouchEventRequestTypeSynthesizedMouse: | 833 case TouchEventRequestTypeSynthesizedMouse: |
| 834 synthesizeMouseEventIfPossible(event); | 834 synthesizeMouseEventIfPossible(event); |
| 835 return; | 835 return; |
| 836 } | 836 } |
| 837 } | 837 } |
| 838 | 838 |
| 839 void WebPluginContainerImpl::handleGestureEvent(GestureEvent* event) { | 839 void WebPluginContainerImpl::handleGestureEvent(GestureEvent* event) { |
| 840 if (event->nativeEvent().type == WebInputEvent::Undefined) | 840 if (event->nativeEvent().type() == WebInputEvent::Undefined) |
| 841 return; | 841 return; |
| 842 if (event->nativeEvent().type == WebInputEvent::GestureTapDown) | 842 if (event->nativeEvent().type() == WebInputEvent::GestureTapDown) |
| 843 focusPlugin(); | 843 focusPlugin(); |
| 844 | 844 |
| 845 // Take a copy of the event and translate it into the coordinate | 845 // Take a copy of the event and translate it into the coordinate |
| 846 // system of the plugin. | 846 // system of the plugin. |
| 847 WebGestureEvent translatedEvent = event->nativeEvent(); | 847 WebGestureEvent translatedEvent = event->nativeEvent(); |
| 848 WebFloatPoint absoluteRootFrameLocation = | 848 WebFloatPoint absoluteRootFrameLocation = |
| 849 event->nativeEvent().positionInRootFrame(); | 849 event->nativeEvent().positionInRootFrame(); |
| 850 IntPoint localPoint = | 850 IntPoint localPoint = |
| 851 roundedIntPoint(m_element->layoutObject()->absoluteToLocal( | 851 roundedIntPoint(m_element->layoutObject()->absoluteToLocal( |
| 852 absoluteRootFrameLocation, UseTransforms)); | 852 absoluteRootFrameLocation, UseTransforms)); |
| 853 translatedEvent.flattenTransform(); | 853 translatedEvent.flattenTransform(); |
| 854 translatedEvent.x = localPoint.x(); | 854 translatedEvent.x = localPoint.x(); |
| 855 translatedEvent.y = localPoint.y(); | 855 translatedEvent.y = localPoint.y(); |
| 856 | 856 |
| 857 WebCursorInfo cursorInfo; | 857 WebCursorInfo cursorInfo; |
| 858 if (m_webPlugin->handleInputEvent(translatedEvent, cursorInfo) != | 858 if (m_webPlugin->handleInputEvent(translatedEvent, cursorInfo) != |
| 859 WebInputEventResult::NotHandled) { | 859 WebInputEventResult::NotHandled) { |
| 860 event->setDefaultHandled(); | 860 event->setDefaultHandled(); |
| 861 return; | 861 return; |
| 862 } | 862 } |
| 863 | 863 |
| 864 // FIXME: Can a plugin change the cursor from a touch-event callback? | 864 // FIXME: Can a plugin change the cursor from a touch-event callback? |
| 865 } | 865 } |
| 866 | 866 |
| 867 void WebPluginContainerImpl::synthesizeMouseEventIfPossible(TouchEvent* event) { | 867 void WebPluginContainerImpl::synthesizeMouseEventIfPossible(TouchEvent* event) { |
| 868 WebMouseEventBuilder webEvent(this, LayoutItem(m_element->layoutObject()), | 868 WebMouseEventBuilder webEvent(this, LayoutItem(m_element->layoutObject()), |
| 869 *event); | 869 *event); |
| 870 if (webEvent.type == WebInputEvent::Undefined) | 870 if (webEvent.type() == WebInputEvent::Undefined) |
| 871 return; | 871 return; |
| 872 | 872 |
| 873 WebCursorInfo cursorInfo; | 873 WebCursorInfo cursorInfo; |
| 874 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo) != | 874 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo) != |
| 875 WebInputEventResult::NotHandled) | 875 WebInputEventResult::NotHandled) |
| 876 event->setDefaultHandled(); | 876 event->setDefaultHandled(); |
| 877 } | 877 } |
| 878 | 878 |
| 879 void WebPluginContainerImpl::focusPlugin() { | 879 void WebPluginContainerImpl::focusPlugin() { |
| 880 LocalFrame& containingFrame = toFrameView(parent())->frame(); | 880 LocalFrame& containingFrame = toFrameView(parent())->frame(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 // frame view. | 973 // frame view. |
| 974 computeClipRectsForPlugin(m_element, windowRect, clipRect, unobscuredRect); | 974 computeClipRectsForPlugin(m_element, windowRect, clipRect, unobscuredRect); |
| 975 } | 975 } |
| 976 getPluginOcclusions(m_element, this->parent(), frameRect(), cutOutRects); | 976 getPluginOcclusions(m_element, this->parent(), frameRect(), cutOutRects); |
| 977 // Convert to the plugin position. | 977 // Convert to the plugin position. |
| 978 for (size_t i = 0; i < cutOutRects.size(); i++) | 978 for (size_t i = 0; i < cutOutRects.size(); i++) |
| 979 cutOutRects[i].move(-frameRect().x(), -frameRect().y()); | 979 cutOutRects[i].move(-frameRect().x(), -frameRect().y()); |
| 980 } | 980 } |
| 981 | 981 |
| 982 } // namespace blink | 982 } // namespace blink |
| OLD | NEW |