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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 m_webPlugin->paint(canvas, windowRect); | 129 m_webPlugin->paint(canvas, windowRect); |
130 | 130 |
131 gc->restore(); | 131 gc->restore(); |
132 } | 132 } |
133 | 133 |
134 void WebPluginContainerImpl::invalidateRect(const IntRect& rect) | 134 void WebPluginContainerImpl::invalidateRect(const IntRect& rect) |
135 { | 135 { |
136 if (!parent()) | 136 if (!parent()) |
137 return; | 137 return; |
138 | 138 |
139 LayoutBox* renderer = toLayoutBox(m_element->renderer()); | 139 LayoutBox* renderer = toLayoutBox(m_element->layoutObject()); |
140 if (!renderer) | 140 if (!renderer) |
141 return; | 141 return; |
142 | 142 |
143 IntRect dirtyRect = rect; | 143 IntRect dirtyRect = rect; |
144 dirtyRect.move(renderer->borderLeft() + renderer->paddingLeft(), | 144 dirtyRect.move(renderer->borderLeft() + renderer->paddingLeft(), |
145 renderer->borderTop() + renderer->paddingTop()); | 145 renderer->borderTop() + renderer->paddingTop()); |
146 | 146 |
147 // For querying Layer::compositingState(). | 147 // For querying Layer::compositingState(). |
148 // This code should be correct. | 148 // This code should be correct. |
149 DisableCompositingQueryAsserts disabler; | 149 DisableCompositingQueryAsserts disabler; |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 } | 392 } |
393 | 393 |
394 void WebPluginContainerImpl::scrollRect(const WebRect& rect) | 394 void WebPluginContainerImpl::scrollRect(const WebRect& rect) |
395 { | 395 { |
396 invalidateRect(rect); | 396 invalidateRect(rect); |
397 } | 397 } |
398 | 398 |
399 void WebPluginContainerImpl::reportGeometry() | 399 void WebPluginContainerImpl::reportGeometry() |
400 { | 400 { |
401 // We cannot compute geometry without a parent or renderer. | 401 // We cannot compute geometry without a parent or renderer. |
402 if (!parent() || !m_element->renderer()) | 402 if (!parent() || !m_element->layoutObject()) |
403 return; | 403 return; |
404 | 404 |
405 IntRect windowRect, clipRect; | 405 IntRect windowRect, clipRect; |
406 Vector<IntRect> cutOutRects; | 406 Vector<IntRect> cutOutRects; |
407 calculateGeometry(frameRect(), windowRect, clipRect, cutOutRects); | 407 calculateGeometry(frameRect(), windowRect, clipRect, cutOutRects); |
408 | 408 |
409 m_webPlugin->updateGeometry(windowRect, clipRect, cutOutRects, isVisible()); | 409 m_webPlugin->updateGeometry(windowRect, clipRect, cutOutRects, isVisible()); |
410 | 410 |
411 if (m_scrollbarGroup) { | 411 if (m_scrollbarGroup) { |
412 m_scrollbarGroup->scrollAnimator()->contentsResized(); | 412 m_scrollbarGroup->scrollAnimator()->contentsResized(); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 } | 545 } |
546 } | 546 } |
547 } | 547 } |
548 | 548 |
549 WebPoint WebPluginContainerImpl::windowToLocalPoint(const WebPoint& point) | 549 WebPoint WebPluginContainerImpl::windowToLocalPoint(const WebPoint& point) |
550 { | 550 { |
551 FrameView* view = toFrameView(parent()); | 551 FrameView* view = toFrameView(parent()); |
552 if (!view) | 552 if (!view) |
553 return point; | 553 return point; |
554 WebPoint windowPoint = view->windowToContents(point); | 554 WebPoint windowPoint = view->windowToContents(point); |
555 return roundedIntPoint(m_element->renderer()->absoluteToLocal(FloatPoint(win
dowPoint), UseTransforms)); | 555 return roundedIntPoint(m_element->layoutObject()->absoluteToLocal(FloatPoint
(windowPoint), UseTransforms)); |
556 } | 556 } |
557 | 557 |
558 WebPoint WebPluginContainerImpl::localToWindowPoint(const WebPoint& point) | 558 WebPoint WebPluginContainerImpl::localToWindowPoint(const WebPoint& point) |
559 { | 559 { |
560 FrameView* view = toFrameView(parent()); | 560 FrameView* view = toFrameView(parent()); |
561 if (!view) | 561 if (!view) |
562 return point; | 562 return point; |
563 IntPoint absolutePoint = roundedIntPoint(m_element->renderer()->localToAbsol
ute(FloatPoint(point), UseTransforms)); | 563 IntPoint absolutePoint = roundedIntPoint(m_element->layoutObject()->localToA
bsolute(FloatPoint(point), UseTransforms)); |
564 return view->contentsToWindow(absolutePoint); | 564 return view->contentsToWindow(absolutePoint); |
565 } | 565 } |
566 | 566 |
567 void WebPluginContainerImpl::didReceiveResponse(const ResourceResponse& response
) | 567 void WebPluginContainerImpl::didReceiveResponse(const ResourceResponse& response
) |
568 { | 568 { |
569 // Make sure that the plugin receives window geometry before data, or else | 569 // Make sure that the plugin receives window geometry before data, or else |
570 // plugins misbehave. | 570 // plugins misbehave. |
571 frameRectsChanged(); | 571 frameRectsChanged(); |
572 | 572 |
573 WrappedResourceResponse urlResponse(response); | 573 WrappedResourceResponse urlResponse(response); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 if (event->isDragEvent()) { | 764 if (event->isDragEvent()) { |
765 if (m_webPlugin->canProcessDrag()) | 765 if (m_webPlugin->canProcessDrag()) |
766 handleDragEvent(event); | 766 handleDragEvent(event); |
767 return; | 767 return; |
768 } | 768 } |
769 | 769 |
770 // We cache the parent FrameView here as the plugin widget could be deleted | 770 // We cache the parent FrameView here as the plugin widget could be deleted |
771 // in the call to HandleEvent. See http://b/issue?id=1362948 | 771 // in the call to HandleEvent. See http://b/issue?id=1362948 |
772 FrameView* parentView = toFrameView(parent()); | 772 FrameView* parentView = toFrameView(parent()); |
773 | 773 |
774 WebMouseEventBuilder webEvent(this, m_element->renderer(), *event); | 774 WebMouseEventBuilder webEvent(this, m_element->layoutObject(), *event); |
775 if (webEvent.type == WebInputEvent::Undefined) | 775 if (webEvent.type == WebInputEvent::Undefined) |
776 return; | 776 return; |
777 | 777 |
778 if (event->type() == EventTypeNames::mousedown) | 778 if (event->type() == EventTypeNames::mousedown) |
779 focusPlugin(); | 779 focusPlugin(); |
780 | 780 |
781 if (m_scrollbarGroup) { | 781 if (m_scrollbarGroup) { |
782 // This needs to be set before the other callbacks in this scope, since | 782 // This needs to be set before the other callbacks in this scope, since |
783 // the scroll animator class might query the position in response. | 783 // the scroll animator class might query the position in response. |
784 m_scrollbarGroup->setLastMousePosition(IntPoint(event->x(), event->y()))
; | 784 m_scrollbarGroup->setLastMousePosition(IntPoint(event->x(), event->y()))
; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 WebDragData dragData = dataTransfer->dataObject()->toWebDragData(); | 824 WebDragData dragData = dataTransfer->dataObject()->toWebDragData(); |
825 WebDragOperationsMask dragOperationMask = static_cast<WebDragOperationsMask>
(dataTransfer->sourceOperation()); | 825 WebDragOperationsMask dragOperationMask = static_cast<WebDragOperationsMask>
(dataTransfer->sourceOperation()); |
826 WebPoint dragScreenLocation(event->screenX(), event->screenY()); | 826 WebPoint dragScreenLocation(event->screenX(), event->screenY()); |
827 WebPoint dragLocation(event->absoluteLocation().x() - location().x(), event-
>absoluteLocation().y() - location().y()); | 827 WebPoint dragLocation(event->absoluteLocation().x() - location().x(), event-
>absoluteLocation().y() - location().y()); |
828 | 828 |
829 m_webPlugin->handleDragStatusUpdate(dragStatus, dragData, dragOperationMask,
dragLocation, dragScreenLocation); | 829 m_webPlugin->handleDragStatusUpdate(dragStatus, dragData, dragOperationMask,
dragLocation, dragScreenLocation); |
830 } | 830 } |
831 | 831 |
832 void WebPluginContainerImpl::handleWheelEvent(WheelEvent* event) | 832 void WebPluginContainerImpl::handleWheelEvent(WheelEvent* event) |
833 { | 833 { |
834 WebMouseWheelEventBuilder webEvent(this, m_element->renderer(), *event); | 834 WebMouseWheelEventBuilder webEvent(this, m_element->layoutObject(), *event); |
835 if (webEvent.type == WebInputEvent::Undefined) | 835 if (webEvent.type == WebInputEvent::Undefined) |
836 return; | 836 return; |
837 | 837 |
838 WebCursorInfo cursorInfo; | 838 WebCursorInfo cursorInfo; |
839 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo)) | 839 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo)) |
840 event->setDefaultHandled(); | 840 event->setDefaultHandled(); |
841 } | 841 } |
842 | 842 |
843 void WebPluginContainerImpl::handleKeyboardEvent(KeyboardEvent* event) | 843 void WebPluginContainerImpl::handleKeyboardEvent(KeyboardEvent* event) |
844 { | 844 { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo)) | 882 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo)) |
883 event->setDefaultHandled(); | 883 event->setDefaultHandled(); |
884 } | 884 } |
885 | 885 |
886 void WebPluginContainerImpl::handleTouchEvent(TouchEvent* event) | 886 void WebPluginContainerImpl::handleTouchEvent(TouchEvent* event) |
887 { | 887 { |
888 switch (m_touchEventRequestType) { | 888 switch (m_touchEventRequestType) { |
889 case TouchEventRequestTypeNone: | 889 case TouchEventRequestTypeNone: |
890 return; | 890 return; |
891 case TouchEventRequestTypeRaw: { | 891 case TouchEventRequestTypeRaw: { |
892 WebTouchEventBuilder webEvent(this, m_element->renderer(), *event); | 892 WebTouchEventBuilder webEvent(this, m_element->layoutObject(), *event); |
893 if (webEvent.type == WebInputEvent::Undefined) | 893 if (webEvent.type == WebInputEvent::Undefined) |
894 return; | 894 return; |
895 | 895 |
896 if (event->type() == EventTypeNames::touchstart) | 896 if (event->type() == EventTypeNames::touchstart) |
897 focusPlugin(); | 897 focusPlugin(); |
898 | 898 |
899 WebCursorInfo cursorInfo; | 899 WebCursorInfo cursorInfo; |
900 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo)) | 900 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo)) |
901 event->setDefaultHandled(); | 901 event->setDefaultHandled(); |
902 // FIXME: Can a plugin change the cursor from a touch-event callback? | 902 // FIXME: Can a plugin change the cursor from a touch-event callback? |
903 return; | 903 return; |
904 } | 904 } |
905 case TouchEventRequestTypeSynthesizedMouse: | 905 case TouchEventRequestTypeSynthesizedMouse: |
906 synthesizeMouseEventIfPossible(event); | 906 synthesizeMouseEventIfPossible(event); |
907 return; | 907 return; |
908 } | 908 } |
909 } | 909 } |
910 | 910 |
911 static inline bool gestureScrollHelper(ScrollbarGroup* scrollbarGroup, ScrollDir
ection positiveDirection, ScrollDirection negativeDirection, float delta) | 911 static inline bool gestureScrollHelper(ScrollbarGroup* scrollbarGroup, ScrollDir
ection positiveDirection, ScrollDirection negativeDirection, float delta) |
912 { | 912 { |
913 if (!delta) | 913 if (!delta) |
914 return false; | 914 return false; |
915 float absDelta = delta > 0 ? delta : -delta; | 915 float absDelta = delta > 0 ? delta : -delta; |
916 return scrollbarGroup->scroll(delta < 0 ? negativeDirection : positiveDirect
ion, ScrollByPrecisePixel, absDelta); | 916 return scrollbarGroup->scroll(delta < 0 ? negativeDirection : positiveDirect
ion, ScrollByPrecisePixel, absDelta); |
917 } | 917 } |
918 | 918 |
919 void WebPluginContainerImpl::handleGestureEvent(GestureEvent* event) | 919 void WebPluginContainerImpl::handleGestureEvent(GestureEvent* event) |
920 { | 920 { |
921 WebGestureEventBuilder webEvent(this, m_element->renderer(), *event); | 921 WebGestureEventBuilder webEvent(this, m_element->layoutObject(), *event); |
922 if (webEvent.type == WebInputEvent::Undefined) | 922 if (webEvent.type == WebInputEvent::Undefined) |
923 return; | 923 return; |
924 if (event->type() == EventTypeNames::gesturetapdown) | 924 if (event->type() == EventTypeNames::gesturetapdown) |
925 focusPlugin(); | 925 focusPlugin(); |
926 WebCursorInfo cursorInfo; | 926 WebCursorInfo cursorInfo; |
927 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo)) { | 927 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo)) { |
928 event->setDefaultHandled(); | 928 event->setDefaultHandled(); |
929 return; | 929 return; |
930 } | 930 } |
931 | 931 |
932 if (webEvent.type == WebInputEvent::GestureScrollUpdate) { | 932 if (webEvent.type == WebInputEvent::GestureScrollUpdate) { |
933 if (!m_scrollbarGroup) | 933 if (!m_scrollbarGroup) |
934 return; | 934 return; |
935 if (gestureScrollHelper(m_scrollbarGroup.get(), ScrollLeft, ScrollRight,
webEvent.data.scrollUpdate.deltaX)) | 935 if (gestureScrollHelper(m_scrollbarGroup.get(), ScrollLeft, ScrollRight,
webEvent.data.scrollUpdate.deltaX)) |
936 event->setDefaultHandled(); | 936 event->setDefaultHandled(); |
937 if (gestureScrollHelper(m_scrollbarGroup.get(), ScrollUp, ScrollDown, we
bEvent.data.scrollUpdate.deltaY)) | 937 if (gestureScrollHelper(m_scrollbarGroup.get(), ScrollUp, ScrollDown, we
bEvent.data.scrollUpdate.deltaY)) |
938 event->setDefaultHandled(); | 938 event->setDefaultHandled(); |
939 } | 939 } |
940 // FIXME: Can a plugin change the cursor from a touch-event callback? | 940 // FIXME: Can a plugin change the cursor from a touch-event callback? |
941 } | 941 } |
942 | 942 |
943 void WebPluginContainerImpl::synthesizeMouseEventIfPossible(TouchEvent* event) | 943 void WebPluginContainerImpl::synthesizeMouseEventIfPossible(TouchEvent* event) |
944 { | 944 { |
945 WebMouseEventBuilder webEvent(this, m_element->renderer(), *event); | 945 WebMouseEventBuilder webEvent(this, m_element->layoutObject(), *event); |
946 if (webEvent.type == WebInputEvent::Undefined) | 946 if (webEvent.type == WebInputEvent::Undefined) |
947 return; | 947 return; |
948 | 948 |
949 WebCursorInfo cursorInfo; | 949 WebCursorInfo cursorInfo; |
950 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo)) | 950 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo)) |
951 event->setDefaultHandled(); | 951 event->setDefaultHandled(); |
952 } | 952 } |
953 | 953 |
954 void WebPluginContainerImpl::focusPlugin() | 954 void WebPluginContainerImpl::focusPlugin() |
955 { | 955 { |
(...skipping 23 matching lines...) Expand all Loading... |
979 | 979 |
980 IntRect WebPluginContainerImpl::windowClipRect() const | 980 IntRect WebPluginContainerImpl::windowClipRect() const |
981 { | 981 { |
982 // Start by clipping to our bounds. | 982 // Start by clipping to our bounds. |
983 IntRect clipRect = | 983 IntRect clipRect = |
984 convertToContainingWindow(IntRect(0, 0, width(), height())); | 984 convertToContainingWindow(IntRect(0, 0, width(), height())); |
985 | 985 |
986 // document().layoutView() can be 0 when we receive messages from the | 986 // document().layoutView() can be 0 when we receive messages from the |
987 // plugins while we are destroying a frame. | 987 // plugins while we are destroying a frame. |
988 // FIXME: Can we just check m_element->document().isActive() ? | 988 // FIXME: Can we just check m_element->document().isActive() ? |
989 if (m_element->renderer()->document().layoutView()) { | 989 if (m_element->layoutObject()->document().layoutView()) { |
990 // Take our element and get the clip rect from the enclosing layer and | 990 // Take our element and get the clip rect from the enclosing layer and |
991 // frame view. | 991 // frame view. |
992 clipRect.intersect( | 992 clipRect.intersect( |
993 m_element->document().view()->windowClipRectForFrameOwner(m_element)
); | 993 m_element->document().view()->windowClipRectForFrameOwner(m_element)
); |
994 } | 994 } |
995 | 995 |
996 return clipRect; | 996 return clipRect; |
997 } | 997 } |
998 | 998 |
999 bool WebPluginContainerImpl::pluginShouldPersist() const | 999 bool WebPluginContainerImpl::pluginShouldPersist() const |
1000 { | 1000 { |
1001 return m_webPlugin->shouldPersist(); | 1001 return m_webPlugin->shouldPersist(); |
1002 } | 1002 } |
1003 | 1003 |
1004 } // namespace blink | 1004 } // namespace blink |
OLD | NEW |