| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de) | 4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de) |
| 5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. | 5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption == | 85 m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption == |
| 86 ShouldPreferPlugInsForImages) {} | 86 ShouldPreferPlugInsForImages) {} |
| 87 | 87 |
| 88 HTMLPlugInElement::~HTMLPlugInElement() { | 88 HTMLPlugInElement::~HTMLPlugInElement() { |
| 89 DCHECK(!m_pluginWrapper); // cleared in detachLayoutTree() | 89 DCHECK(!m_pluginWrapper); // cleared in detachLayoutTree() |
| 90 DCHECK(!m_isDelayingLoadEvent); | 90 DCHECK(!m_isDelayingLoadEvent); |
| 91 } | 91 } |
| 92 | 92 |
| 93 DEFINE_TRACE(HTMLPlugInElement) { | 93 DEFINE_TRACE(HTMLPlugInElement) { |
| 94 visitor->trace(m_imageLoader); | 94 visitor->trace(m_imageLoader); |
| 95 visitor->trace(m_persistedPluginWidget); | 95 visitor->trace(m_persistedPlugin); |
| 96 HTMLFrameOwnerElement::trace(visitor); | 96 HTMLFrameOwnerElement::trace(visitor); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void HTMLPlugInElement::setPersistedPluginWidget(FrameViewBase* frameViewBase) { | 99 // TODO(joelhockey): Move implementation of HTMLFrameOwnerElement |
| 100 if (m_persistedPluginWidget == frameViewBase) | 100 // setWidget/releaseWidget/ownedWidget that relates to plugins to here and |
| 101 // remove inheritance from PluginView to FrameViewBase. |
| 102 void HTMLPlugInElement::setPlugin(PluginView* pluginView) { |
| 103 setWidget(pluginView); |
| 104 } |
| 105 |
| 106 PluginView* HTMLPlugInElement::releasePlugin() { |
| 107 FrameViewBase* plugin = releaseWidget(); |
| 108 return plugin && plugin->isPluginView() ? toPluginView(plugin) : nullptr; |
| 109 } |
| 110 |
| 111 PluginView* HTMLPlugInElement::ownedPlugin() const { |
| 112 FrameViewBase* plugin = ownedWidget(); |
| 113 return plugin && plugin->isPluginView() ? toPluginView(plugin) : nullptr; |
| 114 } |
| 115 |
| 116 void HTMLPlugInElement::setPersistedPlugin(PluginView* plugin) { |
| 117 if (m_persistedPlugin == plugin) |
| 101 return; | 118 return; |
| 102 if (m_persistedPluginWidget) { | 119 if (m_persistedPlugin) { |
| 103 if (m_persistedPluginWidget->isPluginView()) { | 120 m_persistedPlugin->hide(); |
| 104 m_persistedPluginWidget->hide(); | 121 disposeWidgetSoon(m_persistedPlugin.release()); |
| 105 disposeWidgetSoon(m_persistedPluginWidget.release()); | |
| 106 } else { | |
| 107 DCHECK(m_persistedPluginWidget->isFrameView() || | |
| 108 m_persistedPluginWidget->isRemoteFrameView()); | |
| 109 } | |
| 110 } | 122 } |
| 111 m_persistedPluginWidget = frameViewBase; | 123 m_persistedPlugin = plugin; |
| 112 } | 124 } |
| 113 | 125 |
| 114 bool HTMLPlugInElement::requestObjectInternal( | 126 bool HTMLPlugInElement::requestObjectInternal( |
| 115 const String& url, | 127 const String& url, |
| 116 const String& mimeType, | 128 const String& mimeType, |
| 117 const Vector<String>& paramNames, | 129 const Vector<String>& paramNames, |
| 118 const Vector<String>& paramValues) { | 130 const Vector<String>& paramValues) { |
| 119 if (url.isEmpty() && mimeType.isEmpty()) | 131 if (url.isEmpty() && mimeType.isEmpty()) |
| 120 return false; | 132 return false; |
| 121 | 133 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 m_imageLoader->elementDidMoveToNewDocument(); | 181 m_imageLoader->elementDidMoveToNewDocument(); |
| 170 HTMLFrameOwnerElement::didMoveToNewDocument(oldDocument); | 182 HTMLFrameOwnerElement::didMoveToNewDocument(oldDocument); |
| 171 } | 183 } |
| 172 | 184 |
| 173 void HTMLPlugInElement::attachLayoutTree(const AttachContext& context) { | 185 void HTMLPlugInElement::attachLayoutTree(const AttachContext& context) { |
| 174 HTMLFrameOwnerElement::attachLayoutTree(context); | 186 HTMLFrameOwnerElement::attachLayoutTree(context); |
| 175 | 187 |
| 176 if (!layoutObject() || useFallbackContent()) { | 188 if (!layoutObject() || useFallbackContent()) { |
| 177 // If we don't have a layoutObject we have to dispose of any plugins | 189 // If we don't have a layoutObject we have to dispose of any plugins |
| 178 // which we persisted over a reattach. | 190 // which we persisted over a reattach. |
| 179 if (m_persistedPluginWidget) { | 191 if (m_persistedPlugin) { |
| 180 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; | 192 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; |
| 181 setPersistedPluginWidget(nullptr); | 193 setPersistedPlugin(nullptr); |
| 182 } | 194 } |
| 183 return; | 195 return; |
| 184 } | 196 } |
| 185 | 197 |
| 186 if (isImageType()) { | 198 if (isImageType()) { |
| 187 if (!m_imageLoader) | 199 if (!m_imageLoader) |
| 188 m_imageLoader = HTMLImageLoader::create(this); | 200 m_imageLoader = HTMLImageLoader::create(this); |
| 189 m_imageLoader->updateFromElement(); | 201 m_imageLoader->updateFromElement(); |
| 190 } else if (needsPluginUpdate() && !layoutEmbeddedItem().isNull() && | 202 } else if (needsPluginUpdate() && !layoutEmbeddedItem().isNull() && |
| 191 !layoutEmbeddedItem().showsUnavailablePluginIndicator() && | 203 !layoutEmbeddedItem().showsUnavailablePluginIndicator() && |
| 192 !wouldLoadAsNetscapePlugin(m_url, m_serviceType) && | 204 !wouldLoadAsNetscapePlugin(m_url, m_serviceType) && |
| 193 !m_isDelayingLoadEvent) { | 205 !m_isDelayingLoadEvent) { |
| 194 m_isDelayingLoadEvent = true; | 206 m_isDelayingLoadEvent = true; |
| 195 document().incrementLoadEventDelayCount(); | 207 document().incrementLoadEventDelayCount(); |
| 196 document().loadPluginsSoon(); | 208 document().loadPluginsSoon(); |
| 197 } | 209 } |
| 198 } | 210 } |
| 199 | 211 |
| 200 void HTMLPlugInElement::updatePlugin() { | 212 void HTMLPlugInElement::updatePlugin() { |
| 201 updatePluginInternal(); | 213 updatePluginInternal(); |
| 202 if (m_isDelayingLoadEvent) { | 214 if (m_isDelayingLoadEvent) { |
| 203 m_isDelayingLoadEvent = false; | 215 m_isDelayingLoadEvent = false; |
| 204 document().decrementLoadEventDelayCount(); | 216 document().decrementLoadEventDelayCount(); |
| 205 } | 217 } |
| 206 } | 218 } |
| 207 | 219 |
| 208 void HTMLPlugInElement::removedFrom(ContainerNode* insertionPoint) { | 220 void HTMLPlugInElement::removedFrom(ContainerNode* insertionPoint) { |
| 209 // If we've persisted the plugin and we're removed from the tree then | 221 // If we've persisted the plugin and we're removed from the tree then |
| 210 // make sure we cleanup the persistance pointer. | 222 // make sure we cleanup the persistance pointer. |
| 211 if (m_persistedPluginWidget) { | 223 if (m_persistedPlugin) { |
| 212 // TODO(dcheng): This UpdateSuspendScope doesn't seem to provide much; | 224 // TODO(dcheng): This UpdateSuspendScope doesn't seem to provide much; |
| 213 // investigate removing it. | 225 // investigate removing it. |
| 214 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; | 226 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; |
| 215 setPersistedPluginWidget(nullptr); | 227 setPersistedPlugin(nullptr); |
| 216 } | 228 } |
| 217 HTMLFrameOwnerElement::removedFrom(insertionPoint); | 229 HTMLFrameOwnerElement::removedFrom(insertionPoint); |
| 218 } | 230 } |
| 219 | 231 |
| 220 void HTMLPlugInElement::requestPluginCreationWithoutLayoutObjectIfPossible() { | 232 void HTMLPlugInElement::requestPluginCreationWithoutLayoutObjectIfPossible() { |
| 221 if (m_serviceType.isEmpty()) | 233 if (m_serviceType.isEmpty()) |
| 222 return; | 234 return; |
| 223 | 235 |
| 224 if (!document().frame() || | 236 if (!document().frame() || |
| 225 !document().frame()->loader().client()->canCreatePluginWithoutRenderer( | 237 !document().frame()->loader().client()->canCreatePluginWithoutRenderer( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 245 Vector<String> paramValues; | 257 Vector<String> paramValues; |
| 246 | 258 |
| 247 paramNames.push_back("type"); | 259 paramNames.push_back("type"); |
| 248 paramValues.push_back(m_serviceType); | 260 paramValues.push_back(m_serviceType); |
| 249 | 261 |
| 250 bool useFallback = false; | 262 bool useFallback = false; |
| 251 loadPlugin(url, m_serviceType, paramNames, paramValues, useFallback, false); | 263 loadPlugin(url, m_serviceType, paramNames, paramValues, useFallback, false); |
| 252 } | 264 } |
| 253 | 265 |
| 254 bool HTMLPlugInElement::shouldAccelerate() const { | 266 bool HTMLPlugInElement::shouldAccelerate() const { |
| 255 if (FrameViewBase* frameViewBase = ownedWidget()) { | 267 return ownedPlugin() && ownedPlugin()->platformLayer(); |
| 256 return frameViewBase->isPluginView() && | |
| 257 toPluginView(frameViewBase)->platformLayer(); | |
| 258 } | |
| 259 return false; | |
| 260 } | 268 } |
| 261 | 269 |
| 262 void HTMLPlugInElement::detachLayoutTree(const AttachContext& context) { | 270 void HTMLPlugInElement::detachLayoutTree(const AttachContext& context) { |
| 263 // Update the FrameViewBase the next time we attach (detaching destroys the | 271 // Update the FrameViewBase the next time we attach (detaching destroys the |
| 264 // plugin). | 272 // plugin). |
| 265 // FIXME: None of this "needsPluginUpdate" related code looks right. | 273 // FIXME: None of this "needsPluginUpdate" related code looks right. |
| 266 if (layoutObject() && !useFallbackContent()) | 274 if (layoutObject() && !useFallbackContent()) |
| 267 setNeedsPluginUpdate(true); | 275 setNeedsPluginUpdate(true); |
| 268 | 276 |
| 269 if (m_isDelayingLoadEvent) { | 277 if (m_isDelayingLoadEvent) { |
| 270 m_isDelayingLoadEvent = false; | 278 m_isDelayingLoadEvent = false; |
| 271 document().decrementLoadEventDelayCount(); | 279 document().decrementLoadEventDelayCount(); |
| 272 } | 280 } |
| 273 | 281 |
| 274 // Only try to persist a plugin FrameViewBase we actually own. | 282 // Only try to persist a plugin we actually own. |
| 275 FrameViewBase* plugin = ownedWidget(); | 283 PluginView* plugin = ownedPlugin(); |
| 276 if (plugin && context.performingReattach) { | 284 if (plugin && context.performingReattach) { |
| 277 setPersistedPluginWidget(releaseWidget()); | 285 setPersistedPlugin(releasePlugin()); |
| 278 } else { | 286 } else { |
| 279 // Clear the FrameViewBase; will trigger disposal of it with Oilpan. | 287 // Clear the plugin; will trigger disposal of it with Oilpan. |
| 280 setWidget(nullptr); | 288 setPlugin(nullptr); |
| 281 } | 289 } |
| 282 | 290 |
| 283 resetInstance(); | 291 resetInstance(); |
| 284 | 292 |
| 285 HTMLFrameOwnerElement::detachLayoutTree(context); | 293 HTMLFrameOwnerElement::detachLayoutTree(context); |
| 286 } | 294 } |
| 287 | 295 |
| 288 LayoutObject* HTMLPlugInElement::createLayoutObject( | 296 LayoutObject* HTMLPlugInElement::createLayoutObject( |
| 289 const ComputedStyle& style) { | 297 const ComputedStyle& style) { |
| 290 // Fallback content breaks the DOM->layoutObject class relationship of this | 298 // Fallback content breaks the DOM->layoutObject class relationship of this |
| (...skipping 30 matching lines...) Expand all Loading... |
| 321 LocalFrame* frame = document().frame(); | 329 LocalFrame* frame = document().frame(); |
| 322 if (!frame) | 330 if (!frame) |
| 323 return nullptr; | 331 return nullptr; |
| 324 | 332 |
| 325 // If the host dynamically turns off JavaScript (or Java) we will still | 333 // If the host dynamically turns off JavaScript (or Java) we will still |
| 326 // return the cached allocated Bindings::Instance. Not supporting this | 334 // return the cached allocated Bindings::Instance. Not supporting this |
| 327 // edge-case is OK. | 335 // edge-case is OK. |
| 328 if (!m_pluginWrapper) { | 336 if (!m_pluginWrapper) { |
| 329 FrameViewBase* plugin; | 337 FrameViewBase* plugin; |
| 330 | 338 |
| 331 if (m_persistedPluginWidget) | 339 if (m_persistedPlugin) |
| 332 plugin = m_persistedPluginWidget.get(); | 340 plugin = m_persistedPlugin.get(); |
| 333 else | 341 else |
| 334 plugin = pluginWidget(); | 342 plugin = pluginWidget(); |
| 335 | 343 |
| 336 if (plugin) | 344 if (plugin) |
| 337 m_pluginWrapper = frame->script().createPluginWrapper(plugin); | 345 m_pluginWrapper = frame->script().createPluginWrapper(plugin); |
| 338 } | 346 } |
| 339 return m_pluginWrapper.get(); | 347 return m_pluginWrapper.get(); |
| 340 } | 348 } |
| 341 | 349 |
| 342 FrameViewBase* HTMLPlugInElement::pluginWidget() const { | 350 FrameViewBase* HTMLPlugInElement::pluginWidget() const { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 bool HTMLPlugInElement::hasCustomFocusLogic() const { | 431 bool HTMLPlugInElement::hasCustomFocusLogic() const { |
| 424 return !useFallbackContent(); | 432 return !useFallbackContent(); |
| 425 } | 433 } |
| 426 | 434 |
| 427 bool HTMLPlugInElement::isPluginElement() const { | 435 bool HTMLPlugInElement::isPluginElement() const { |
| 428 return true; | 436 return true; |
| 429 } | 437 } |
| 430 | 438 |
| 431 void HTMLPlugInElement::disconnectContentFrame() { | 439 void HTMLPlugInElement::disconnectContentFrame() { |
| 432 HTMLFrameOwnerElement::disconnectContentFrame(); | 440 HTMLFrameOwnerElement::disconnectContentFrame(); |
| 433 setPersistedPluginWidget(nullptr); | 441 setPersistedPlugin(nullptr); |
| 434 } | 442 } |
| 435 | 443 |
| 436 bool HTMLPlugInElement::layoutObjectIsFocusable() const { | 444 bool HTMLPlugInElement::layoutObjectIsFocusable() const { |
| 437 if (HTMLFrameOwnerElement::supportsFocus() && | 445 if (HTMLFrameOwnerElement::supportsFocus() && |
| 438 HTMLFrameOwnerElement::layoutObjectIsFocusable()) | 446 HTMLFrameOwnerElement::layoutObjectIsFocusable()) |
| 439 return true; | 447 return true; |
| 440 | 448 |
| 441 if (useFallbackContent() || !HTMLFrameOwnerElement::layoutObjectIsFocusable()) | 449 if (useFallbackContent() || !HTMLFrameOwnerElement::layoutObjectIsFocusable()) |
| 442 return false; | 450 return false; |
| 443 return m_pluginIsAvailable; | 451 return m_pluginIsAvailable; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 | 525 |
| 518 LayoutEmbeddedItem layoutItem = layoutEmbeddedItem(); | 526 LayoutEmbeddedItem layoutItem = layoutEmbeddedItem(); |
| 519 // FIXME: This code should not depend on layoutObject! | 527 // FIXME: This code should not depend on layoutObject! |
| 520 if ((layoutItem.isNull() && requireLayoutObject) || useFallback) | 528 if ((layoutItem.isNull() && requireLayoutObject) || useFallback) |
| 521 return false; | 529 return false; |
| 522 | 530 |
| 523 VLOG(1) << this << " Plugin URL: " << m_url; | 531 VLOG(1) << this << " Plugin URL: " << m_url; |
| 524 VLOG(1) << "Loaded URL: " << url.getString(); | 532 VLOG(1) << "Loaded URL: " << url.getString(); |
| 525 m_loadedUrl = url; | 533 m_loadedUrl = url; |
| 526 | 534 |
| 527 if (m_persistedPluginWidget) { | 535 if (m_persistedPlugin) { |
| 528 setWidget(m_persistedPluginWidget.release()); | 536 setPlugin(m_persistedPlugin.release()); |
| 529 } else { | 537 } else { |
| 530 bool loadManually = | 538 bool loadManually = |
| 531 document().isPluginDocument() && !document().containsPlugins(); | 539 document().isPluginDocument() && !document().containsPlugins(); |
| 532 LocalFrameClient::DetachedPluginPolicy policy = | 540 LocalFrameClient::DetachedPluginPolicy policy = |
| 533 requireLayoutObject ? LocalFrameClient::FailOnDetachedPlugin | 541 requireLayoutObject ? LocalFrameClient::FailOnDetachedPlugin |
| 534 : LocalFrameClient::AllowDetachedPlugin; | 542 : LocalFrameClient::AllowDetachedPlugin; |
| 535 FrameViewBase* frameViewBase = frame->loader().client()->createPlugin( | 543 PluginView* plugin = frame->loader().client()->createPlugin( |
| 536 this, url, paramNames, paramValues, mimeType, loadManually, policy); | 544 this, url, paramNames, paramValues, mimeType, loadManually, policy); |
| 537 if (!frameViewBase) { | 545 if (!plugin) { |
| 538 if (!layoutItem.isNull() && | 546 if (!layoutItem.isNull() && |
| 539 !layoutItem.showsUnavailablePluginIndicator()) { | 547 !layoutItem.showsUnavailablePluginIndicator()) { |
| 540 m_pluginIsAvailable = false; | 548 m_pluginIsAvailable = false; |
| 541 layoutItem.setPluginAvailability(LayoutEmbeddedObject::PluginMissing); | 549 layoutItem.setPluginAvailability(LayoutEmbeddedObject::PluginMissing); |
| 542 } | 550 } |
| 543 return false; | 551 return false; |
| 544 } | 552 } |
| 545 | 553 |
| 546 if (!layoutItem.isNull()) | 554 if (!layoutItem.isNull()) |
| 547 setWidget(frameViewBase); | 555 setPlugin(plugin); |
| 548 else | 556 else |
| 549 setPersistedPluginWidget(frameViewBase); | 557 setPersistedPlugin(plugin); |
| 550 } | 558 } |
| 551 | 559 |
| 552 document().setContainsPlugins(); | 560 document().setContainsPlugins(); |
| 553 // TODO(esprehn): WebPluginContainerImpl::setWebLayer also schedules a | 561 // TODO(esprehn): WebPluginContainerImpl::setWebLayer also schedules a |
| 554 // compositing update, do we need both? | 562 // compositing update, do we need both? |
| 555 setNeedsCompositingUpdate(); | 563 setNeedsCompositingUpdate(); |
| 556 // Make sure any input event handlers introduced by the plugin are taken into | 564 // Make sure any input event handlers introduced by the plugin are taken into |
| 557 // account. | 565 // account. |
| 558 if (Page* page = document().frame()->page()) { | 566 if (Page* page = document().frame()->page()) { |
| 559 if (ScrollingCoordinator* scrollingCoordinator = | 567 if (ScrollingCoordinator* scrollingCoordinator = |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 } | 653 } |
| 646 | 654 |
| 647 bool HTMLPlugInElement::useFallbackContent() const { | 655 bool HTMLPlugInElement::useFallbackContent() const { |
| 648 return false; | 656 return false; |
| 649 } | 657 } |
| 650 | 658 |
| 651 void HTMLPlugInElement::lazyReattachIfNeeded() { | 659 void HTMLPlugInElement::lazyReattachIfNeeded() { |
| 652 if (!useFallbackContent() && needsPluginUpdate() && layoutObject() && | 660 if (!useFallbackContent() && needsPluginUpdate() && layoutObject() && |
| 653 !isImageType()) { | 661 !isImageType()) { |
| 654 lazyReattachIfAttached(); | 662 lazyReattachIfAttached(); |
| 655 setPersistedPluginWidget(nullptr); | 663 setPersistedPlugin(nullptr); |
| 656 } | 664 } |
| 657 } | 665 } |
| 658 | 666 |
| 659 } // namespace blink | 667 } // namespace blink |
| OLD | NEW |