| 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. |
| 11 * | 11 * |
| 12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
| 16 * | 16 * |
| 17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
| 18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
| 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #include "core/html/HTMLPlugInElement.h" | 23 #include "core/html/HTMLPlugInElement.h" |
| 24 | 24 |
| 25 #include "bindings/core/v8/ScriptController.h" | 25 #include "bindings/core/v8/ScriptController.h" |
| 26 #include "bindings/core/v8/npruntime_impl.h" | |
| 27 #include "core/CSSPropertyNames.h" | 26 #include "core/CSSPropertyNames.h" |
| 28 #include "core/HTMLNames.h" | 27 #include "core/HTMLNames.h" |
| 29 #include "core/dom/Document.h" | 28 #include "core/dom/Document.h" |
| 30 #include "core/dom/Node.h" | 29 #include "core/dom/Node.h" |
| 31 #include "core/dom/shadow/ShadowRoot.h" | 30 #include "core/dom/shadow/ShadowRoot.h" |
| 32 #include "core/events/Event.h" | 31 #include "core/events/Event.h" |
| 33 #include "core/frame/FrameView.h" | 32 #include "core/frame/FrameView.h" |
| 34 #include "core/frame/LocalFrame.h" | 33 #include "core/frame/LocalFrame.h" |
| 35 #include "core/frame/Settings.h" | 34 #include "core/frame/Settings.h" |
| 36 #include "core/frame/csp/ContentSecurityPolicy.h" | 35 #include "core/frame/csp/ContentSecurityPolicy.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 54 #include "platform/plugins/PluginData.h" | 53 #include "platform/plugins/PluginData.h" |
| 55 #include "public/platform/WebURLRequest.h" | 54 #include "public/platform/WebURLRequest.h" |
| 56 | 55 |
| 57 namespace blink { | 56 namespace blink { |
| 58 | 57 |
| 59 using namespace HTMLNames; | 58 using namespace HTMLNames; |
| 60 | 59 |
| 61 HTMLPlugInElement::HTMLPlugInElement(const QualifiedName& tagName, Document& doc
, bool createdByParser, PreferPlugInsForImagesOption preferPlugInsForImagesOptio
n) | 60 HTMLPlugInElement::HTMLPlugInElement(const QualifiedName& tagName, Document& doc
, bool createdByParser, PreferPlugInsForImagesOption preferPlugInsForImagesOptio
n) |
| 62 : HTMLFrameOwnerElement(tagName, doc) | 61 : HTMLFrameOwnerElement(tagName, doc) |
| 63 , m_isDelayingLoadEvent(false) | 62 , m_isDelayingLoadEvent(false) |
| 64 , m_NPObject(0) | |
| 65 // m_needsWidgetUpdate(!createdByParser) allows HTMLObjectElement to delay | 63 // m_needsWidgetUpdate(!createdByParser) allows HTMLObjectElement to delay |
| 66 // widget updates until after all children are parsed. For HTMLEmbedElement | 64 // widget updates until after all children are parsed. For HTMLEmbedElement |
| 67 // this delay is unnecessary, but it is simpler to make both classes share | 65 // this delay is unnecessary, but it is simpler to make both classes share |
| 68 // the same codepath in this class. | 66 // the same codepath in this class. |
| 69 , m_needsWidgetUpdate(!createdByParser) | 67 , m_needsWidgetUpdate(!createdByParser) |
| 70 , m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption == ShouldPrefe
rPlugInsForImages) | 68 , m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption == ShouldPrefe
rPlugInsForImages) |
| 71 { | 69 { |
| 72 } | 70 } |
| 73 | 71 |
| 74 HTMLPlugInElement::~HTMLPlugInElement() | 72 HTMLPlugInElement::~HTMLPlugInElement() |
| 75 { | 73 { |
| 76 ASSERT(!m_pluginWrapper); // cleared in detach() | 74 ASSERT(!m_pluginWrapper); // cleared in detach() |
| 77 ASSERT(!m_isDelayingLoadEvent); | 75 ASSERT(!m_isDelayingLoadEvent); |
| 78 | |
| 79 if (m_NPObject) { | |
| 80 _NPN_ReleaseObject(m_NPObject); | |
| 81 m_NPObject = 0; | |
| 82 } | |
| 83 } | 76 } |
| 84 | 77 |
| 85 DEFINE_TRACE(HTMLPlugInElement) | 78 DEFINE_TRACE(HTMLPlugInElement) |
| 86 { | 79 { |
| 87 visitor->trace(m_imageLoader); | 80 visitor->trace(m_imageLoader); |
| 88 visitor->trace(m_persistedPluginWidget); | 81 visitor->trace(m_persistedPluginWidget); |
| 89 HTMLFrameOwnerElement::trace(visitor); | 82 HTMLFrameOwnerElement::trace(visitor); |
| 90 } | 83 } |
| 91 | 84 |
| 92 void HTMLPlugInElement::setPersistedPluginWidget(Widget* widget) | 85 void HTMLPlugInElement::setPersistedPluginWidget(Widget* widget) |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 Widget* plugin = ownedWidget(); | 230 Widget* plugin = ownedWidget(); |
| 238 if (plugin && context.performingReattach) { | 231 if (plugin && context.performingReattach) { |
| 239 setPersistedPluginWidget(releaseWidget().get()); | 232 setPersistedPluginWidget(releaseWidget().get()); |
| 240 } else { | 233 } else { |
| 241 // Clear the widget; will trigger disposal of it with Oilpan. | 234 // Clear the widget; will trigger disposal of it with Oilpan. |
| 242 setWidget(nullptr); | 235 setWidget(nullptr); |
| 243 } | 236 } |
| 244 | 237 |
| 245 resetInstance(); | 238 resetInstance(); |
| 246 | 239 |
| 247 if (m_NPObject) { | |
| 248 _NPN_ReleaseObject(m_NPObject); | |
| 249 m_NPObject = 0; | |
| 250 } | |
| 251 | |
| 252 HTMLFrameOwnerElement::detach(context); | 240 HTMLFrameOwnerElement::detach(context); |
| 253 } | 241 } |
| 254 | 242 |
| 255 LayoutObject* HTMLPlugInElement::createLayoutObject(const ComputedStyle& style) | 243 LayoutObject* HTMLPlugInElement::createLayoutObject(const ComputedStyle& style) |
| 256 { | 244 { |
| 257 // Fallback content breaks the DOM->layoutObject class relationship of this | 245 // Fallback content breaks the DOM->layoutObject class relationship of this |
| 258 // class and all superclasses because createObject won't necessarily return | 246 // class and all superclasses because createObject won't necessarily return |
| 259 // a LayoutEmbeddedObject or LayoutPart. | 247 // a LayoutEmbeddedObject or LayoutPart. |
| 260 if (useFallbackContent()) | 248 if (useFallbackContent()) |
| 261 return LayoutObject::createObject(this, style); | 249 return LayoutObject::createObject(this, style); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 bool HTMLPlugInElement::layoutObjectIsFocusable() const | 387 bool HTMLPlugInElement::layoutObjectIsFocusable() const |
| 400 { | 388 { |
| 401 if (HTMLFrameOwnerElement::supportsFocus() && HTMLFrameOwnerElement::layoutO
bjectIsFocusable()) | 389 if (HTMLFrameOwnerElement::supportsFocus() && HTMLFrameOwnerElement::layoutO
bjectIsFocusable()) |
| 402 return true; | 390 return true; |
| 403 | 391 |
| 404 if (useFallbackContent() || !layoutObject() || !layoutObject()->isEmbeddedOb
ject()) | 392 if (useFallbackContent() || !layoutObject() || !layoutObject()->isEmbeddedOb
ject()) |
| 405 return false; | 393 return false; |
| 406 return !toLayoutEmbeddedObject(layoutObject())->showsUnavailablePluginIndica
tor(); | 394 return !toLayoutEmbeddedObject(layoutObject())->showsUnavailablePluginIndica
tor(); |
| 407 } | 395 } |
| 408 | 396 |
| 409 NPObject* HTMLPlugInElement::getNPObject() | |
| 410 { | |
| 411 ASSERT(document().frame()); | |
| 412 if (!m_NPObject) | |
| 413 m_NPObject = document().frame()->script().createScriptObjectForPluginEle
ment(this); | |
| 414 return m_NPObject; | |
| 415 } | |
| 416 | |
| 417 void HTMLPlugInElement::setPluginFocus(bool focused) | 397 void HTMLPlugInElement::setPluginFocus(bool focused) |
| 418 { | 398 { |
| 419 // NPAPI flash requires to receive messages when web contents focus changes. | 399 // NPAPI flash requires to receive messages when web contents focus changes. |
| 420 if (getNPObject() && pluginWidget() && pluginWidget()->isPluginView()) | 400 if (pluginWidget() && pluginWidget()->isPluginView()) |
| 421 toPluginView(pluginWidget())->setFocus(focused, WebFocusTypeNone); | 401 toPluginView(pluginWidget())->setFocus(focused, WebFocusTypeNone); |
| 422 } | 402 } |
| 423 | 403 |
| 424 bool HTMLPlugInElement::isImageType() | 404 bool HTMLPlugInElement::isImageType() |
| 425 { | 405 { |
| 426 if (m_serviceType.isEmpty() && protocolIs(m_url, "data")) | 406 if (m_serviceType.isEmpty() && protocolIs(m_url, "data")) |
| 427 m_serviceType = mimeTypeFromDataURL(m_url); | 407 m_serviceType = mimeTypeFromDataURL(m_url); |
| 428 | 408 |
| 429 if (LocalFrame* frame = document().frame()) { | 409 if (LocalFrame* frame = document().frame()) { |
| 430 KURL completedURL = document().completeURL(m_url); | 410 KURL completedURL = document().completeURL(m_url); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 return openShadowRoot(); | 594 return openShadowRoot(); |
| 615 } | 595 } |
| 616 | 596 |
| 617 void HTMLPlugInElement::lazyReattachIfNeeded() | 597 void HTMLPlugInElement::lazyReattachIfNeeded() |
| 618 { | 598 { |
| 619 if (!useFallbackContent() && needsWidgetUpdate() && layoutObject() && !isIma
geType()) | 599 if (!useFallbackContent() && needsWidgetUpdate() && layoutObject() && !isIma
geType()) |
| 620 lazyReattachIfAttached(); | 600 lazyReattachIfAttached(); |
| 621 } | 601 } |
| 622 | 602 |
| 623 } | 603 } |
| OLD | NEW |