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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 Widget* plugin = ownedWidget(); | 234 Widget* plugin = ownedWidget(); |
242 if (plugin && context.performingReattach) { | 235 if (plugin && context.performingReattach) { |
243 setPersistedPluginWidget(releaseWidget().get()); | 236 setPersistedPluginWidget(releaseWidget().get()); |
244 } else { | 237 } else { |
245 // Clear the widget; will trigger disposal of it with Oilpan. | 238 // Clear the widget; will trigger disposal of it with Oilpan. |
246 setWidget(nullptr); | 239 setWidget(nullptr); |
247 } | 240 } |
248 | 241 |
249 resetInstance(); | 242 resetInstance(); |
250 | 243 |
251 if (m_NPObject) { | |
252 _NPN_ReleaseObject(m_NPObject); | |
253 m_NPObject = 0; | |
254 } | |
255 | |
256 HTMLFrameOwnerElement::detach(context); | 244 HTMLFrameOwnerElement::detach(context); |
257 } | 245 } |
258 | 246 |
259 LayoutObject* HTMLPlugInElement::createLayoutObject(const ComputedStyle& style) | 247 LayoutObject* HTMLPlugInElement::createLayoutObject(const ComputedStyle& style) |
260 { | 248 { |
261 // Fallback content breaks the DOM->layoutObject class relationship of this | 249 // Fallback content breaks the DOM->layoutObject class relationship of this |
262 // class and all superclasses because createObject won't necessarily return | 250 // class and all superclasses because createObject won't necessarily return |
263 // a LayoutEmbeddedObject or LayoutPart. | 251 // a LayoutEmbeddedObject or LayoutPart. |
264 if (useFallbackContent()) | 252 if (useFallbackContent()) |
265 return LayoutObject::createObject(this, style); | 253 return LayoutObject::createObject(this, style); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 bool HTMLPlugInElement::layoutObjectIsFocusable() const | 391 bool HTMLPlugInElement::layoutObjectIsFocusable() const |
404 { | 392 { |
405 if (HTMLFrameOwnerElement::supportsFocus() && HTMLFrameOwnerElement::layoutO
bjectIsFocusable()) | 393 if (HTMLFrameOwnerElement::supportsFocus() && HTMLFrameOwnerElement::layoutO
bjectIsFocusable()) |
406 return true; | 394 return true; |
407 | 395 |
408 if (useFallbackContent() || !HTMLFrameOwnerElement::layoutObjectIsFocusable(
)) | 396 if (useFallbackContent() || !HTMLFrameOwnerElement::layoutObjectIsFocusable(
)) |
409 return false; | 397 return false; |
410 return layoutObject() && layoutObject()->isEmbeddedObject() && !layoutEmbedd
edItem().showsUnavailablePluginIndicator(); | 398 return layoutObject() && layoutObject()->isEmbeddedObject() && !layoutEmbedd
edItem().showsUnavailablePluginIndicator(); |
411 } | 399 } |
412 | 400 |
413 NPObject* HTMLPlugInElement::getNPObject() | |
414 { | |
415 ASSERT(document().frame()); | |
416 if (!m_NPObject) | |
417 m_NPObject = document().frame()->script().createScriptObjectForPluginEle
ment(this); | |
418 return m_NPObject; | |
419 } | |
420 | |
421 void HTMLPlugInElement::setPluginFocus(bool focused) | |
422 { | |
423 // NPAPI flash requires to receive messages when web contents focus changes. | |
424 if (getNPObject() && pluginWidget() && pluginWidget()->isPluginView()) | |
425 toPluginView(pluginWidget())->setFocus(focused, WebFocusTypeNone); | |
426 } | |
427 | |
428 bool HTMLPlugInElement::isImageType() | 401 bool HTMLPlugInElement::isImageType() |
429 { | 402 { |
430 if (m_serviceType.isEmpty() && protocolIs(m_url, "data")) | 403 if (m_serviceType.isEmpty() && protocolIs(m_url, "data")) |
431 m_serviceType = mimeTypeFromDataURL(m_url); | 404 m_serviceType = mimeTypeFromDataURL(m_url); |
432 | 405 |
433 if (LocalFrame* frame = document().frame()) { | 406 if (LocalFrame* frame = document().frame()) { |
434 KURL completedURL = document().completeURL(m_url); | 407 KURL completedURL = document().completeURL(m_url); |
435 return frame->loader().client()->getObjectContentType(completedURL, m_se
rviceType, shouldPreferPlugInsForImages()) == ObjectContentImage; | 408 return frame->loader().client()->getObjectContentType(completedURL, m_se
rviceType, shouldPreferPlugInsForImages()) == ObjectContentImage; |
436 } | 409 } |
437 | 410 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 return openShadowRoot(); | 604 return openShadowRoot(); |
632 } | 605 } |
633 | 606 |
634 void HTMLPlugInElement::lazyReattachIfNeeded() | 607 void HTMLPlugInElement::lazyReattachIfNeeded() |
635 { | 608 { |
636 if (!useFallbackContent() && needsWidgetUpdate() && layoutObject() && !isIma
geType()) | 609 if (!useFallbackContent() && needsWidgetUpdate() && layoutObject() && !isIma
geType()) |
637 lazyReattachIfAttached(); | 610 lazyReattachIfAttached(); |
638 } | 611 } |
639 | 612 |
640 } // namespace blink | 613 } // namespace blink |
OLD | NEW |