| 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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 UserGestureIndicator gestureIndicator(popupsAllowed ? DefinitelyProcessingNe
wUserGesture : PossiblyProcessingUserGesture); | 493 UserGestureIndicator gestureIndicator(popupsAllowed ? DefinitelyProcessingNe
wUserGesture : PossiblyProcessingUserGesture); |
| 494 v8::HandleScope handleScope(toIsolate(frame)); | 494 v8::HandleScope handleScope(toIsolate(frame)); |
| 495 v8::Local<v8::Value> result = frame->script().executeScriptInMainWorldAndRet
urnValue(ScriptSourceCode(script)); | 495 v8::Local<v8::Value> result = frame->script().executeScriptInMainWorldAndRet
urnValue(ScriptSourceCode(script)); |
| 496 | 496 |
| 497 // Failure is reported as a null string. | 497 // Failure is reported as a null string. |
| 498 if (result.IsEmpty() || !result->IsString()) | 498 if (result.IsEmpty() || !result->IsString()) |
| 499 return WebString(); | 499 return WebString(); |
| 500 return toCoreString(v8::Local<v8::String>::Cast(result)); | 500 return toCoreString(v8::Local<v8::String>::Cast(result)); |
| 501 } | 501 } |
| 502 | 502 |
| 503 void WebPluginContainerImpl::loadFrameRequest(const WebURLRequest& request, cons
t WebString& target, bool notifyNeeded, void* notifyData) | 503 void WebPluginContainerImpl::loadFrameRequest(const WebURLRequest& request, cons
t WebString& target) |
| 504 { | 504 { |
| 505 LocalFrame* frame = m_element->document().frame(); | 505 LocalFrame* frame = m_element->document().frame(); |
| 506 if (!frame || !frame->loader().documentLoader()) | 506 if (!frame || !frame->loader().documentLoader()) |
| 507 return; // FIXME: send a notification in this case? | 507 return; // FIXME: send a notification in this case? |
| 508 | 508 |
| 509 if (notifyNeeded) { | |
| 510 // FIXME: This is a bit of hack to allow us to observe completion of | |
| 511 // our frame request. It would be better to evolve FrameLoader to | |
| 512 // support a completion callback instead. | |
| 513 OwnPtrWillBeRawPtr<WebPluginLoadObserver> observer = WebPluginLoadObserv
er::create(this, request.url(), notifyData); | |
| 514 #if !ENABLE(OILPAN) | |
| 515 m_pluginLoadObservers.append(observer.get()); | |
| 516 #endif | |
| 517 WebDataSourceImpl::setNextPluginLoadObserver(observer.release()); | |
| 518 } | |
| 519 | |
| 520 FrameLoadRequest frameRequest(frame->document(), request.toResourceRequest()
, target); | 509 FrameLoadRequest frameRequest(frame->document(), request.toResourceRequest()
, target); |
| 521 frame->loader().load(frameRequest); | 510 frame->loader().load(frameRequest); |
| 522 } | 511 } |
| 523 | 512 |
| 524 bool WebPluginContainerImpl::isRectTopmost(const WebRect& rect) | 513 bool WebPluginContainerImpl::isRectTopmost(const WebRect& rect) |
| 525 { | 514 { |
| 526 // Disallow access to the frame during dispose(), because it is not guarante
ed to | 515 // Disallow access to the frame during dispose(), because it is not guarante
ed to |
| 527 // be valid memory once this object has started disposal. In particular, we
might be being | 516 // be valid memory once this object has started disposal. In particular, we
might be being |
| 528 // disposed because the frame has already be deleted and then something else
dropped the | 517 // disposed because the frame has already be deleted and then something else
dropped the |
| 529 // last reference to the this object. | 518 // last reference to the this object. |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 bool WebPluginContainerImpl::canProcessDrag() const | 675 bool WebPluginContainerImpl::canProcessDrag() const |
| 687 { | 676 { |
| 688 return m_webPlugin->canProcessDrag(); | 677 return m_webPlugin->canProcessDrag(); |
| 689 } | 678 } |
| 690 | 679 |
| 691 bool WebPluginContainerImpl::wantsWheelEvents() | 680 bool WebPluginContainerImpl::wantsWheelEvents() |
| 692 { | 681 { |
| 693 return m_wantsWheelEvents; | 682 return m_wantsWheelEvents; |
| 694 } | 683 } |
| 695 | 684 |
| 696 #if !ENABLE(OILPAN) | |
| 697 void WebPluginContainerImpl::willDestroyPluginLoadObserver(WebPluginLoadObserver
* observer) | |
| 698 { | |
| 699 size_t pos = m_pluginLoadObservers.find(observer); | |
| 700 if (pos == kNotFound) | |
| 701 return; | |
| 702 m_pluginLoadObservers.remove(pos); | |
| 703 } | |
| 704 #endif | |
| 705 | |
| 706 // Private methods ------------------------------------------------------------- | 685 // Private methods ------------------------------------------------------------- |
| 707 | 686 |
| 708 WebPluginContainerImpl::WebPluginContainerImpl(HTMLPlugInElement* element, WebPl
ugin* webPlugin) | 687 WebPluginContainerImpl::WebPluginContainerImpl(HTMLPlugInElement* element, WebPl
ugin* webPlugin) |
| 709 : LocalFrameLifecycleObserver(element->document().frame()) | 688 : LocalFrameLifecycleObserver(element->document().frame()) |
| 710 , m_element(element) | 689 , m_element(element) |
| 711 , m_webPlugin(webPlugin) | 690 , m_webPlugin(webPlugin) |
| 712 , m_webLayer(nullptr) | 691 , m_webLayer(nullptr) |
| 713 , m_touchEventRequestType(TouchEventRequestTypeNone) | 692 , m_touchEventRequestType(TouchEventRequestTypeNone) |
| 714 , m_wantsWheelEvents(false) | 693 , m_wantsWheelEvents(false) |
| 715 , m_inDispose(false) | 694 , m_inDispose(false) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 731 #endif | 710 #endif |
| 732 } | 711 } |
| 733 | 712 |
| 734 void WebPluginContainerImpl::dispose() | 713 void WebPluginContainerImpl::dispose() |
| 735 { | 714 { |
| 736 m_inDispose = true; | 715 m_inDispose = true; |
| 737 | 716 |
| 738 if (m_element && m_touchEventRequestType != TouchEventRequestTypeNone && m_e
lement->document().frameHost()) | 717 if (m_element && m_touchEventRequestType != TouchEventRequestTypeNone && m_e
lement->document().frameHost()) |
| 739 m_element->document().frameHost()->eventHandlerRegistry().didRemoveEvent
Handler(*m_element, EventHandlerRegistry::TouchEvent); | 718 m_element->document().frameHost()->eventHandlerRegistry().didRemoveEvent
Handler(*m_element, EventHandlerRegistry::TouchEvent); |
| 740 | 719 |
| 741 #if !ENABLE(OILPAN) | |
| 742 for (const auto& observer : m_pluginLoadObservers) | |
| 743 observer->clearPluginContainer(); | |
| 744 #endif | |
| 745 | |
| 746 if (m_webPlugin) { | 720 if (m_webPlugin) { |
| 747 RELEASE_ASSERT(!m_webPlugin->container() || m_webPlugin->container() ==
this); | 721 RELEASE_ASSERT(!m_webPlugin->container() || m_webPlugin->container() ==
this); |
| 748 m_webPlugin->destroy(); | 722 m_webPlugin->destroy(); |
| 749 m_webPlugin = nullptr; | 723 m_webPlugin = nullptr; |
| 750 } | 724 } |
| 751 | 725 |
| 752 if (m_webLayer) { | 726 if (m_webLayer) { |
| 753 GraphicsLayer::unregisterContentsLayer(m_webLayer); | 727 GraphicsLayer::unregisterContentsLayer(m_webLayer); |
| 754 m_webLayer = nullptr; | 728 m_webLayer = nullptr; |
| 755 } | 729 } |
| 756 | 730 |
| 757 #if !ENABLE(OILPAN) | |
| 758 m_pluginLoadObservers.clear(); | |
| 759 #endif | |
| 760 m_element = nullptr; | 731 m_element = nullptr; |
| 761 } | 732 } |
| 762 | 733 |
| 763 #if ENABLE(OILPAN) | 734 #if ENABLE(OILPAN) |
| 764 void WebPluginContainerImpl::shouldDisposePlugin() | 735 void WebPluginContainerImpl::shouldDisposePlugin() |
| 765 { | 736 { |
| 766 // If the LocalFrame is still alive, but the plugin element isn't, the | 737 // If the LocalFrame is still alive, but the plugin element isn't, the |
| 767 // LocalFrame will set m_shouldDisposePlugin via its weak pointer | 738 // LocalFrame will set m_shouldDisposePlugin via its weak pointer |
| 768 // callback. This is a signal that the plugin container | 739 // callback. This is a signal that the plugin container |
| 769 // must dispose of its plugin when finalizing. The LocalFrame and | 740 // must dispose of its plugin when finalizing. The LocalFrame and |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 // frame view. | 980 // frame view. |
| 1010 computeClipRectsForPlugin(m_element, windowRect, clipRect, unobscuredRec
t); | 981 computeClipRectsForPlugin(m_element, windowRect, clipRect, unobscuredRec
t); |
| 1011 } | 982 } |
| 1012 getPluginOcclusions(m_element, this->parent(), frameRect(), cutOutRects); | 983 getPluginOcclusions(m_element, this->parent(), frameRect(), cutOutRects); |
| 1013 // Convert to the plugin position. | 984 // Convert to the plugin position. |
| 1014 for (size_t i = 0; i < cutOutRects.size(); i++) | 985 for (size_t i = 0; i < cutOutRects.size(); i++) |
| 1015 cutOutRects[i].move(-frameRect().x(), -frameRect().y()); | 986 cutOutRects[i].move(-frameRect().x(), -frameRect().y()); |
| 1016 } | 987 } |
| 1017 | 988 |
| 1018 } // namespace blinkf | 989 } // namespace blinkf |
| OLD | NEW |