Chromium Code Reviews| Index: Source/core/html/HTMLPlugInElement.cpp |
| diff --git a/Source/core/html/HTMLPlugInElement.cpp b/Source/core/html/HTMLPlugInElement.cpp |
| index 4b9d597b145adc29ed8c8b965f3111df689daf81..417061cf7b7dd110c0725bbd42919e0c14d71f1f 100644 |
| --- a/Source/core/html/HTMLPlugInElement.cpp |
| +++ b/Source/core/html/HTMLPlugInElement.cpp |
| @@ -86,9 +86,50 @@ HTMLPlugInElement::~HTMLPlugInElement() |
| void HTMLPlugInElement::trace(Visitor* visitor) |
| { |
| visitor->trace(m_imageLoader); |
| + visitor->trace(m_persistedPluginWidget); |
| HTMLFrameOwnerElement::trace(visitor); |
| } |
| +#if ENABLE(OILPAN) |
| +void HTMLPlugInElement::disconnectContentFrame() |
| +{ |
| + if (m_persistedPluginWidget) { |
| + m_persistedPluginWidget->dispose(); |
| + m_persistedPluginWidget = nullptr; |
| + } |
| + HTMLFrameOwnerElement::disconnectContentFrame(); |
| +} |
| + |
| +void HTMLPlugInElement::setIsAllowedToDisposePlugin() |
|
haraken
2014/10/10 02:50:32
setIsAllowedToDisposePlugin => shouldDisposePlugin
sof
2014/10/10 08:40:55
That's a better verb to use, thanks. disposal isn'
|
| +{ |
| + if (m_persistedPluginWidget && m_persistedPluginWidget->isPluginView()) { |
| + PluginView* plugin = toPluginView(m_persistedPluginWidget.get()); |
| + plugin->setIsAllowedToDisposePlugin(); |
| + } |
| +} |
| +#endif |
| + |
| +void HTMLPlugInElement::setPersistedPluginWidget(Widget* widget) |
| +{ |
| +#if ENABLE(OILPAN) |
| + if (m_persistedPluginWidget && m_persistedPluginWidget != widget) { |
| + if (m_persistedPluginWidget->isPluginView()) { |
| + PluginView* oldPlugin = toPluginView(m_persistedPluginWidget.get()); |
| + if (LocalFrame* frame = oldPlugin->pluginFrame()) { |
|
haraken
2014/10/10 02:50:32
Help me understand: In a case where oldPlugin->plu
sof
2014/10/10 05:22:19
The condition cannot happen (see below.)
|
| + frame->unregisterPluginElement(this); |
| + } |
| + } |
| + } |
| + if (widget && widget->isPluginView()) { |
| + PluginView* plugin = toPluginView(widget); |
| + if (LocalFrame* frame = plugin->pluginFrame()) { |
|
haraken
2014/10/10 02:50:32
Help me understand: Who calls dispose() for a plug
sof
2014/10/10 05:22:18
I don't think any such plugins exist. i.e., WebPlu
|
| + frame->registerPluginElement(this); |
| + } |
| + } |
| +#endif |
| + m_persistedPluginWidget = widget; |
| +} |
| + |
| bool HTMLPlugInElement::canProcessDrag() const |
| { |
| return pluginWidget() && pluginWidget()->isPluginView() && toPluginView(pluginWidget())->canProcessDrag(); |
| @@ -201,13 +242,10 @@ void HTMLPlugInElement::detach(const AttachContext& context) |
| // Only try to persist a plugin widget we actually own. |
| Widget* plugin = ownedWidget(); |
| if (plugin && plugin->pluginShouldPersist()) |
| - m_persistedPluginWidget = plugin; |
| -#if ENABLE(OILPAN) |
| - else if (plugin) |
| - plugin->detach(); |
| -#endif |
| + setPersistedPluginWidget(plugin); |
| + |
| resetInstance(); |
| - // FIXME - is this next line necessary? |
| + // Clear the widget; will trigger disposal of it with Oilpan. |
| setWidget(nullptr); |
| if (m_isCapturingMouseEvents) { |
| @@ -335,7 +373,7 @@ void HTMLPlugInElement::defaultEventHandler(Event* event) |
| if (toRenderEmbeddedObject(r)->showsUnavailablePluginIndicator()) |
| return; |
| } |
| - RefPtr<Widget> widget = toRenderWidget(r)->widget(); |
| + RefPtrWillBeRawPtr<Widget> widget = toRenderWidget(r)->widget(); |
| if (!widget) |
| return; |
| widget->handleEvent(event); |
| @@ -478,7 +516,7 @@ bool HTMLPlugInElement::loadPlugin(const KURL& url, const String& mimeType, cons |
| WTF_LOG(Plugins, " Loaded URL: %s", url.string().utf8().data()); |
| m_loadedUrl = url; |
| - RefPtr<Widget> widget = m_persistedPluginWidget; |
| + RefPtrWillBeRawPtr<Widget> widget = m_persistedPluginWidget; |
| if (!widget) { |
| bool loadManually = document().isPluginDocument() && !document().containsPlugins(); |
| FrameLoaderClient::DetachedPluginPolicy policy = requireRenderer ? FrameLoaderClient::FailOnDetachedPlugin : FrameLoaderClient::AllowDetachedPlugin; |
| @@ -493,9 +531,9 @@ bool HTMLPlugInElement::loadPlugin(const KURL& url, const String& mimeType, cons |
| if (renderer) { |
| setWidget(widget); |
| - m_persistedPluginWidget = nullptr; |
| + setPersistedPluginWidget(nullptr); |
| } else if (widget != m_persistedPluginWidget) { |
| - m_persistedPluginWidget = widget; |
| + setPersistedPluginWidget(widget.get()); |
| } |
| document().setContainsPlugins(); |
| scheduleSVGFilterLayerUpdateHack(); |