| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 #include "public/platform/WebURL.h" | 81 #include "public/platform/WebURL.h" |
| 82 #include "public/platform/WebURLError.h" | 82 #include "public/platform/WebURLError.h" |
| 83 #include "public/platform/WebURLRequest.h" | 83 #include "public/platform/WebURLRequest.h" |
| 84 #include "public/web/WebElement.h" | 84 #include "public/web/WebElement.h" |
| 85 #include "public/web/WebInputEvent.h" | 85 #include "public/web/WebInputEvent.h" |
| 86 #include "public/web/WebPlugin.h" | 86 #include "public/web/WebPlugin.h" |
| 87 #include "public/web/WebPrintParams.h" | 87 #include "public/web/WebPrintParams.h" |
| 88 #include "public/web/WebPrintPresetOptions.h" | 88 #include "public/web/WebPrintPresetOptions.h" |
| 89 #include "public/web/WebViewClient.h" | 89 #include "public/web/WebViewClient.h" |
| 90 #include "web/ChromeClientImpl.h" | 90 #include "web/ChromeClientImpl.h" |
| 91 #include "web/ScrollbarGroup.h" | |
| 92 #include "web/WebDataSourceImpl.h" | 91 #include "web/WebDataSourceImpl.h" |
| 93 #include "web/WebInputEventConversion.h" | 92 #include "web/WebInputEventConversion.h" |
| 94 #include "web/WebViewImpl.h" | 93 #include "web/WebViewImpl.h" |
| 95 #include "wtf/Assertions.h" | 94 #include "wtf/Assertions.h" |
| 96 | 95 |
| 97 #include <base/debug/stack_trace.h> | 96 #include <base/debug/stack_trace.h> |
| 98 | 97 |
| 99 namespace blink { | 98 namespace blink { |
| 100 | 99 |
| 101 // Public methods -------------------------------------------------------------- | 100 // Public methods -------------------------------------------------------------- |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 { | 416 { |
| 418 // We cannot compute geometry without a parent or layoutObject. | 417 // We cannot compute geometry without a parent or layoutObject. |
| 419 if (!parent() || !m_element || !m_element->layoutObject()) | 418 if (!parent() || !m_element || !m_element->layoutObject()) |
| 420 return; | 419 return; |
| 421 | 420 |
| 422 IntRect windowRect, clipRect, unobscuredRect; | 421 IntRect windowRect, clipRect, unobscuredRect; |
| 423 Vector<IntRect> cutOutRects; | 422 Vector<IntRect> cutOutRects; |
| 424 calculateGeometry(windowRect, clipRect, unobscuredRect, cutOutRects); | 423 calculateGeometry(windowRect, clipRect, unobscuredRect, cutOutRects); |
| 425 | 424 |
| 426 m_webPlugin->updateGeometry(windowRect, clipRect, unobscuredRect, cutOutRect
s, isVisible()); | 425 m_webPlugin->updateGeometry(windowRect, clipRect, unobscuredRect, cutOutRect
s, isVisible()); |
| 427 | |
| 428 if (m_scrollbarGroup) { | |
| 429 m_scrollbarGroup->scrollAnimator()->contentsResized(); | |
| 430 m_scrollbarGroup->setFrameRect(frameRect()); | |
| 431 } | |
| 432 } | 426 } |
| 433 | 427 |
| 434 void WebPluginContainerImpl::allowScriptObjects() | 428 void WebPluginContainerImpl::allowScriptObjects() |
| 435 { | 429 { |
| 436 } | 430 } |
| 437 | 431 |
| 438 void WebPluginContainerImpl::clearScriptObjects() | 432 void WebPluginContainerImpl::clearScriptObjects() |
| 439 { | 433 { |
| 440 if (!frame()) | 434 if (!frame()) |
| 441 return; | 435 return; |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 } | 671 } |
| 678 | 672 |
| 679 void WebPluginContainerImpl::willDestroyPluginLoadObserver(WebPluginLoadObserver
* observer) | 673 void WebPluginContainerImpl::willDestroyPluginLoadObserver(WebPluginLoadObserver
* observer) |
| 680 { | 674 { |
| 681 size_t pos = m_pluginLoadObservers.find(observer); | 675 size_t pos = m_pluginLoadObservers.find(observer); |
| 682 if (pos == kNotFound) | 676 if (pos == kNotFound) |
| 683 return; | 677 return; |
| 684 m_pluginLoadObservers.remove(pos); | 678 m_pluginLoadObservers.remove(pos); |
| 685 } | 679 } |
| 686 | 680 |
| 687 ScrollbarGroup* WebPluginContainerImpl::scrollbarGroup() | |
| 688 { | |
| 689 if (!m_scrollbarGroup) | |
| 690 m_scrollbarGroup = adoptPtr(new ScrollbarGroup(m_element->document().fra
me()->view(), frameRect())); | |
| 691 return m_scrollbarGroup.get(); | |
| 692 } | |
| 693 | |
| 694 void WebPluginContainerImpl::willStartLiveResize() | |
| 695 { | |
| 696 if (m_scrollbarGroup) | |
| 697 m_scrollbarGroup->willStartLiveResize(); | |
| 698 } | |
| 699 | |
| 700 void WebPluginContainerImpl::willEndLiveResize() | |
| 701 { | |
| 702 if (m_scrollbarGroup) | |
| 703 m_scrollbarGroup->willEndLiveResize(); | |
| 704 } | |
| 705 | |
| 706 // Private methods ------------------------------------------------------------- | 681 // Private methods ------------------------------------------------------------- |
| 707 | 682 |
| 708 WebPluginContainerImpl::WebPluginContainerImpl(HTMLPlugInElement* element, WebPl
ugin* webPlugin) | 683 WebPluginContainerImpl::WebPluginContainerImpl(HTMLPlugInElement* element, WebPl
ugin* webPlugin) |
| 709 : LocalFrameLifecycleObserver(element->document().frame()) | 684 : LocalFrameLifecycleObserver(element->document().frame()) |
| 710 , m_element(element) | 685 , m_element(element) |
| 711 , m_webPlugin(webPlugin) | 686 , m_webPlugin(webPlugin) |
| 712 , m_webLayer(nullptr) | 687 , m_webLayer(nullptr) |
| 713 , m_isInPaint(false) | 688 , m_isInPaint(false) |
| 714 , m_touchEventRequestType(TouchEventRequestTypeNone) | 689 , m_touchEventRequestType(TouchEventRequestTypeNone) |
| 715 , m_wantsWheelEvents(false) | 690 , m_wantsWheelEvents(false) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 738 | 713 |
| 739 for (size_t i = 0; i < m_pluginLoadObservers.size(); ++i) | 714 for (size_t i = 0; i < m_pluginLoadObservers.size(); ++i) |
| 740 m_pluginLoadObservers[i]->clearPluginContainer(); | 715 m_pluginLoadObservers[i]->clearPluginContainer(); |
| 741 m_webPlugin->destroy(); | 716 m_webPlugin->destroy(); |
| 742 m_webPlugin = nullptr; | 717 m_webPlugin = nullptr; |
| 743 | 718 |
| 744 if (m_webLayer) | 719 if (m_webLayer) |
| 745 GraphicsLayer::unregisterContentsLayer(m_webLayer); | 720 GraphicsLayer::unregisterContentsLayer(m_webLayer); |
| 746 | 721 |
| 747 m_pluginLoadObservers.clear(); | 722 m_pluginLoadObservers.clear(); |
| 748 m_scrollbarGroup.clear(); | |
| 749 m_element = nullptr; | 723 m_element = nullptr; |
| 750 } | 724 } |
| 751 | 725 |
| 752 #if ENABLE(OILPAN) | 726 #if ENABLE(OILPAN) |
| 753 void WebPluginContainerImpl::shouldDisposePlugin() | 727 void WebPluginContainerImpl::shouldDisposePlugin() |
| 754 { | 728 { |
| 755 // If the LocalFrame is still alive, but the plugin element isn't, the | 729 // If the LocalFrame is still alive, but the plugin element isn't, the |
| 756 // LocalFrame will set m_shouldDisposePlugin via its weak pointer | 730 // LocalFrame will set m_shouldDisposePlugin via its weak pointer |
| 757 // callback. This is a signal that the plugin container | 731 // callback. This is a signal that the plugin container |
| 758 // must dispose of its plugin when finalizing. The LocalFrame and | 732 // must dispose of its plugin when finalizing. The LocalFrame and |
| (...skipping 26 matching lines...) Expand all Loading... |
| 785 // in the call to HandleEvent. See http://b/issue?id=1362948 | 759 // in the call to HandleEvent. See http://b/issue?id=1362948 |
| 786 FrameView* parentView = toFrameView(parent()); | 760 FrameView* parentView = toFrameView(parent()); |
| 787 | 761 |
| 788 WebMouseEventBuilder webEvent(this, m_element->layoutObject(), *event); | 762 WebMouseEventBuilder webEvent(this, m_element->layoutObject(), *event); |
| 789 if (webEvent.type == WebInputEvent::Undefined) | 763 if (webEvent.type == WebInputEvent::Undefined) |
| 790 return; | 764 return; |
| 791 | 765 |
| 792 if (event->type() == EventTypeNames::mousedown) | 766 if (event->type() == EventTypeNames::mousedown) |
| 793 focusPlugin(); | 767 focusPlugin(); |
| 794 | 768 |
| 795 if (m_scrollbarGroup) { | |
| 796 // This needs to be set before the other callbacks in this scope, since | |
| 797 // the scroll animator class might query the position in response. | |
| 798 m_scrollbarGroup->setLastMousePosition(IntPoint(event->x(), event->y()))
; | |
| 799 if (event->type() == EventTypeNames::mousemove) | |
| 800 m_scrollbarGroup->scrollAnimator()->mouseMovedInContentArea(); | |
| 801 else if (event->type() == EventTypeNames::mouseover) | |
| 802 m_scrollbarGroup->scrollAnimator()->mouseEnteredContentArea(); | |
| 803 else if (event->type() == EventTypeNames::mouseout) | |
| 804 m_scrollbarGroup->scrollAnimator()->mouseExitedContentArea(); | |
| 805 } | |
| 806 | |
| 807 WebCursorInfo cursorInfo; | 769 WebCursorInfo cursorInfo; |
| 808 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo)) | 770 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo)) |
| 809 event->setDefaultHandled(); | 771 event->setDefaultHandled(); |
| 810 | 772 |
| 811 // A windowless plugin can change the cursor in response to a mouse move | 773 // A windowless plugin can change the cursor in response to a mouse move |
| 812 // event. We need to reflect the changed cursor in the frame view as the | 774 // event. We need to reflect the changed cursor in the frame view as the |
| 813 // mouse is moved in the boundaries of the windowless plugin. | 775 // mouse is moved in the boundaries of the windowless plugin. |
| 814 Page* page = parentView->frame().page(); | 776 Page* page = parentView->frame().page(); |
| 815 if (!page) | 777 if (!page) |
| 816 return; | 778 return; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 event->setDefaultHandled(); | 877 event->setDefaultHandled(); |
| 916 // FIXME: Can a plugin change the cursor from a touch-event callback? | 878 // FIXME: Can a plugin change the cursor from a touch-event callback? |
| 917 return; | 879 return; |
| 918 } | 880 } |
| 919 case TouchEventRequestTypeSynthesizedMouse: | 881 case TouchEventRequestTypeSynthesizedMouse: |
| 920 synthesizeMouseEventIfPossible(event); | 882 synthesizeMouseEventIfPossible(event); |
| 921 return; | 883 return; |
| 922 } | 884 } |
| 923 } | 885 } |
| 924 | 886 |
| 925 static inline bool gestureScrollHelper(ScrollbarGroup* scrollbarGroup, ScrollDir
ectionPhysical positiveDirection, ScrollDirectionPhysical negativeDirection, flo
at delta) | |
| 926 { | |
| 927 if (!delta) | |
| 928 return false; | |
| 929 float absDelta = delta > 0 ? delta : -delta; | |
| 930 return scrollbarGroup->scroll(delta < 0 ? negativeDirection : positiveDirect
ion, ScrollByPrecisePixel, absDelta); | |
| 931 } | |
| 932 | |
| 933 void WebPluginContainerImpl::handleGestureEvent(GestureEvent* event) | 887 void WebPluginContainerImpl::handleGestureEvent(GestureEvent* event) |
| 934 { | 888 { |
| 935 WebGestureEventBuilder webEvent(m_element->layoutObject(), *event); | 889 WebGestureEventBuilder webEvent(m_element->layoutObject(), *event); |
| 936 if (webEvent.type == WebInputEvent::Undefined) | 890 if (webEvent.type == WebInputEvent::Undefined) |
| 937 return; | 891 return; |
| 938 if (event->type() == EventTypeNames::gesturetapdown) | 892 if (event->type() == EventTypeNames::gesturetapdown) |
| 939 focusPlugin(); | 893 focusPlugin(); |
| 940 WebCursorInfo cursorInfo; | 894 WebCursorInfo cursorInfo; |
| 941 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo)) { | 895 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo)) { |
| 942 event->setDefaultHandled(); | 896 event->setDefaultHandled(); |
| 943 return; | 897 return; |
| 944 } | 898 } |
| 945 | 899 |
| 946 if (webEvent.type == WebInputEvent::GestureScrollUpdate) { | |
| 947 if (!m_scrollbarGroup) | |
| 948 return; | |
| 949 if (gestureScrollHelper(m_scrollbarGroup.get(), ScrollLeft, ScrollRight,
webEvent.data.scrollUpdate.deltaX)) | |
| 950 event->setDefaultHandled(); | |
| 951 if (gestureScrollHelper(m_scrollbarGroup.get(), ScrollUp, ScrollDown, we
bEvent.data.scrollUpdate.deltaY)) | |
| 952 event->setDefaultHandled(); | |
| 953 } | |
| 954 // FIXME: Can a plugin change the cursor from a touch-event callback? | 900 // FIXME: Can a plugin change the cursor from a touch-event callback? |
| 955 } | 901 } |
| 956 | 902 |
| 957 void WebPluginContainerImpl::synthesizeMouseEventIfPossible(TouchEvent* event) | 903 void WebPluginContainerImpl::synthesizeMouseEventIfPossible(TouchEvent* event) |
| 958 { | 904 { |
| 959 WebMouseEventBuilder webEvent(this, m_element->layoutObject(), *event); | 905 WebMouseEventBuilder webEvent(this, m_element->layoutObject(), *event); |
| 960 if (webEvent.type == WebInputEvent::Undefined) | 906 if (webEvent.type == WebInputEvent::Undefined) |
| 961 return; | 907 return; |
| 962 | 908 |
| 963 WebCursorInfo cursorInfo; | 909 WebCursorInfo cursorInfo; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 for (size_t i = 0; i < cutOutRects.size(); i++) | 961 for (size_t i = 0; i < cutOutRects.size(); i++) |
| 1016 cutOutRects[i].move(-frameRect().x(), -frameRect().y()); | 962 cutOutRects[i].move(-frameRect().x(), -frameRect().y()); |
| 1017 } | 963 } |
| 1018 | 964 |
| 1019 bool WebPluginContainerImpl::pluginShouldPersist() const | 965 bool WebPluginContainerImpl::pluginShouldPersist() const |
| 1020 { | 966 { |
| 1021 return m_webPlugin->shouldPersist(); | 967 return m_webPlugin->shouldPersist(); |
| 1022 } | 968 } |
| 1023 | 969 |
| 1024 } // namespace blink | 970 } // namespace blink |
| OLD | NEW |