Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1069)

Side by Side Diff: third_party/WebKit/Source/web/WebPluginContainerImpl.cpp

Issue 2573073003: Collapse the API surface on WebInputEvent via accessor functions. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 703
704 void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) { 704 void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) {
705 DCHECK(parent()->isFrameView()); 705 DCHECK(parent()->isFrameView());
706 706
707 // We cache the parent FrameView here as the plugin widget could be deleted 707 // We cache the parent FrameView here as the plugin widget could be deleted
708 // in the call to HandleEvent. See http://b/issue?id=1362948 708 // in the call to HandleEvent. See http://b/issue?id=1362948
709 FrameView* parentView = toFrameView(parent()); 709 FrameView* parentView = toFrameView(parent());
710 710
711 WebMouseEventBuilder webEvent(this, LayoutItem(m_element->layoutObject()), 711 WebMouseEventBuilder webEvent(this, LayoutItem(m_element->layoutObject()),
712 *event); 712 *event);
713 if (webEvent.type == WebInputEvent::Undefined) 713 if (webEvent.type() == WebInputEvent::Undefined)
714 return; 714 return;
715 715
716 if (event->type() == EventTypeNames::mousedown) 716 if (event->type() == EventTypeNames::mousedown)
717 focusPlugin(); 717 focusPlugin();
718 718
719 WebCursorInfo cursorInfo; 719 WebCursorInfo cursorInfo;
720 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo) != 720 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo) !=
721 WebInputEventResult::NotHandled) 721 WebInputEventResult::NotHandled)
722 event->setDefaultHandled(); 722 event->setDefaultHandled();
723 723
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 WebPoint dragLocation(event->absoluteLocation().x() - location().x(), 755 WebPoint dragLocation(event->absoluteLocation().x() - location().x(),
756 event->absoluteLocation().y() - location().y()); 756 event->absoluteLocation().y() - location().y());
757 757
758 m_webPlugin->handleDragStatusUpdate(dragStatus, dragData, dragOperationMask, 758 m_webPlugin->handleDragStatusUpdate(dragStatus, dragData, dragOperationMask,
759 dragLocation, dragScreenLocation); 759 dragLocation, dragScreenLocation);
760 } 760 }
761 761
762 void WebPluginContainerImpl::handleWheelEvent(WheelEvent* event) { 762 void WebPluginContainerImpl::handleWheelEvent(WheelEvent* event) {
763 WebMouseWheelEventBuilder webEvent( 763 WebMouseWheelEventBuilder webEvent(
764 this, LayoutItem(m_element->layoutObject()), *event); 764 this, LayoutItem(m_element->layoutObject()), *event);
765 if (webEvent.type == WebInputEvent::Undefined) 765 if (webEvent.type() == WebInputEvent::Undefined)
766 return; 766 return;
767 767
768 WebCursorInfo cursorInfo; 768 WebCursorInfo cursorInfo;
769 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo) != 769 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo) !=
770 WebInputEventResult::NotHandled) 770 WebInputEventResult::NotHandled)
771 event->setDefaultHandled(); 771 event->setDefaultHandled();
772 } 772 }
773 773
774 void WebPluginContainerImpl::handleKeyboardEvent(KeyboardEvent* event) { 774 void WebPluginContainerImpl::handleKeyboardEvent(KeyboardEvent* event) {
775 WebKeyboardEventBuilder webEvent(*event); 775 WebKeyboardEventBuilder webEvent(*event);
776 if (webEvent.type == WebInputEvent::Undefined) 776 if (webEvent.type() == WebInputEvent::Undefined)
777 return; 777 return;
778 778
779 if (webEvent.type == WebInputEvent::KeyDown) { 779 if (webEvent.type() == WebInputEvent::KeyDown) {
780 #if OS(MACOSX) 780 #if OS(MACOSX)
781 if ((webEvent.modifiers & WebInputEvent::InputModifiers) == 781 if ((webEvent.modifiers() & WebInputEvent::InputModifiers) ==
782 WebInputEvent::MetaKey 782 WebInputEvent::MetaKey
783 #else 783 #else
784 if ((webEvent.modifiers & WebInputEvent::InputModifiers) == 784 if ((webEvent.modifiers() & WebInputEvent::InputModifiers) ==
785 WebInputEvent::ControlKey 785 WebInputEvent::ControlKey
786 #endif 786 #endif
787 && (webEvent.windowsKeyCode == VKEY_C || 787 && (webEvent.windowsKeyCode == VKEY_C ||
788 webEvent.windowsKeyCode == VKEY_INSERT) 788 webEvent.windowsKeyCode == VKEY_INSERT)
789 // Only copy if there's a selection, so that we only ever do this 789 // Only copy if there's a selection, so that we only ever do this
790 // for Pepper plugins that support copying. Windowless NPAPI 790 // for Pepper plugins that support copying. Windowless NPAPI
791 // plugins will get the event as before. 791 // plugins will get the event as before.
792 && m_webPlugin->hasSelection()) { 792 && m_webPlugin->hasSelection()) {
793 copy(); 793 copy();
794 event->setDefaultHandled(); 794 event->setDefaultHandled();
(...skipping 13 matching lines...) Expand all
808 event->setDefaultHandled(); 808 event->setDefaultHandled();
809 } 809 }
810 810
811 void WebPluginContainerImpl::handleTouchEvent(TouchEvent* event) { 811 void WebPluginContainerImpl::handleTouchEvent(TouchEvent* event) {
812 switch (m_touchEventRequestType) { 812 switch (m_touchEventRequestType) {
813 case TouchEventRequestTypeNone: 813 case TouchEventRequestTypeNone:
814 return; 814 return;
815 case TouchEventRequestTypeRaw: { 815 case TouchEventRequestTypeRaw: {
816 WebTouchEventBuilder webEvent(LayoutItem(m_element->layoutObject()), 816 WebTouchEventBuilder webEvent(LayoutItem(m_element->layoutObject()),
817 *event); 817 *event);
818 if (webEvent.type == WebInputEvent::Undefined) 818 if (webEvent.type() == WebInputEvent::Undefined)
819 return; 819 return;
820 820
821 if (event->type() == EventTypeNames::touchstart) 821 if (event->type() == EventTypeNames::touchstart)
822 focusPlugin(); 822 focusPlugin();
823 823
824 WebCursorInfo cursorInfo; 824 WebCursorInfo cursorInfo;
825 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo) != 825 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo) !=
826 WebInputEventResult::NotHandled) 826 WebInputEventResult::NotHandled)
827 event->setDefaultHandled(); 827 event->setDefaultHandled();
828 // FIXME: Can a plugin change the cursor from a touch-event callback? 828 // FIXME: Can a plugin change the cursor from a touch-event callback?
829 return; 829 return;
830 } 830 }
831 case TouchEventRequestTypeSynthesizedMouse: 831 case TouchEventRequestTypeSynthesizedMouse:
832 synthesizeMouseEventIfPossible(event); 832 synthesizeMouseEventIfPossible(event);
833 return; 833 return;
834 } 834 }
835 } 835 }
836 836
837 void WebPluginContainerImpl::handleGestureEvent(GestureEvent* event) { 837 void WebPluginContainerImpl::handleGestureEvent(GestureEvent* event) {
838 WebGestureEventBuilder webEvent(LayoutItem(m_element->layoutObject()), 838 WebGestureEventBuilder webEvent(LayoutItem(m_element->layoutObject()),
839 *event); 839 *event);
840 if (webEvent.type == WebInputEvent::Undefined) 840 if (webEvent.type() == WebInputEvent::Undefined)
841 return; 841 return;
842 if (event->type() == EventTypeNames::gesturetapdown) 842 if (event->type() == EventTypeNames::gesturetapdown)
843 focusPlugin(); 843 focusPlugin();
844 WebCursorInfo cursorInfo; 844 WebCursorInfo cursorInfo;
845 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo) != 845 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo) !=
846 WebInputEventResult::NotHandled) { 846 WebInputEventResult::NotHandled) {
847 event->setDefaultHandled(); 847 event->setDefaultHandled();
848 return; 848 return;
849 } 849 }
850 850
851 // FIXME: Can a plugin change the cursor from a touch-event callback? 851 // FIXME: Can a plugin change the cursor from a touch-event callback?
852 } 852 }
853 853
854 void WebPluginContainerImpl::synthesizeMouseEventIfPossible(TouchEvent* event) { 854 void WebPluginContainerImpl::synthesizeMouseEventIfPossible(TouchEvent* event) {
855 WebMouseEventBuilder webEvent(this, LayoutItem(m_element->layoutObject()), 855 WebMouseEventBuilder webEvent(this, LayoutItem(m_element->layoutObject()),
856 *event); 856 *event);
857 if (webEvent.type == WebInputEvent::Undefined) 857 if (webEvent.type() == WebInputEvent::Undefined)
858 return; 858 return;
859 859
860 WebCursorInfo cursorInfo; 860 WebCursorInfo cursorInfo;
861 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo) != 861 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo) !=
862 WebInputEventResult::NotHandled) 862 WebInputEventResult::NotHandled)
863 event->setDefaultHandled(); 863 event->setDefaultHandled();
864 } 864 }
865 865
866 void WebPluginContainerImpl::focusPlugin() { 866 void WebPluginContainerImpl::focusPlugin() {
867 LocalFrame& containingFrame = toFrameView(parent())->frame(); 867 LocalFrame& containingFrame = toFrameView(parent())->frame();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 // frame view. 960 // frame view.
961 computeClipRectsForPlugin(m_element, windowRect, clipRect, unobscuredRect); 961 computeClipRectsForPlugin(m_element, windowRect, clipRect, unobscuredRect);
962 } 962 }
963 getPluginOcclusions(m_element, this->parent(), frameRect(), cutOutRects); 963 getPluginOcclusions(m_element, this->parent(), frameRect(), cutOutRects);
964 // Convert to the plugin position. 964 // Convert to the plugin position.
965 for (size_t i = 0; i < cutOutRects.size(); i++) 965 for (size_t i = 0; i < cutOutRects.size(); i++)
966 cutOutRects[i].move(-frameRect().x(), -frameRect().y()); 966 cutOutRects[i].move(-frameRect().x(), -frameRect().y());
967 } 967 }
968 968
969 } // namespace blink 969 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698