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 11 matching lines...) Expand all Loading... |
22 | 22 |
23 #include "config.h" | 23 #include "config.h" |
24 #include "core/html/HTMLPlugInElement.h" | 24 #include "core/html/HTMLPlugInElement.h" |
25 | 25 |
26 #include "CSSPropertyNames.h" | 26 #include "CSSPropertyNames.h" |
27 #include "HTMLNames.h" | 27 #include "HTMLNames.h" |
28 #include "bindings/v8/ScriptController.h" | 28 #include "bindings/v8/ScriptController.h" |
29 #include "bindings/v8/npruntime_impl.h" | 29 #include "bindings/v8/npruntime_impl.h" |
30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
31 #include "core/events/Event.h" | 31 #include "core/events/Event.h" |
| 32 #include "core/loader/FrameLoaderClient.h" |
32 #include "core/page/EventHandler.h" | 33 #include "core/page/EventHandler.h" |
33 #include "core/page/Frame.h" | 34 #include "core/page/Frame.h" |
34 #include "core/platform/Widget.h" | 35 #include "core/platform/Widget.h" |
35 #include "core/plugins/PluginView.h" | 36 #include "core/plugins/PluginView.h" |
36 #include "core/rendering/RenderEmbeddedObject.h" | 37 #include "core/rendering/RenderEmbeddedObject.h" |
37 #include "core/rendering/RenderWidget.h" | 38 #include "core/rendering/RenderWidget.h" |
38 #include "wtf/UnusedParam.h" | 39 #include "wtf/UnusedParam.h" |
39 | 40 |
40 | 41 |
41 namespace WebCore { | 42 namespace WebCore { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 82 |
82 void HTMLPlugInElement::removeAllEventListeners() | 83 void HTMLPlugInElement::removeAllEventListeners() |
83 { | 84 { |
84 HTMLFrameOwnerElement::removeAllEventListeners(); | 85 HTMLFrameOwnerElement::removeAllEventListeners(); |
85 if (RenderWidget* renderer = existingRenderWidget()) { | 86 if (RenderWidget* renderer = existingRenderWidget()) { |
86 if (Widget* widget = renderer->widget()) | 87 if (Widget* widget = renderer->widget()) |
87 widget->eventListenersRemoved(); | 88 widget->eventListenersRemoved(); |
88 } | 89 } |
89 } | 90 } |
90 | 91 |
| 92 void HTMLPlugInElement::createPluginWithoutRenderer(const String& mimeType) |
| 93 { |
| 94 if (m_plugin && (mimeType == m_pluginMimeType)) |
| 95 return; |
| 96 |
| 97 Frame* frame = document().frame(); |
| 98 if (!frame->loader()->client()->canCreatePluginWithoutRenderer(mimeType)) |
| 99 return; |
| 100 |
| 101 KURL url; |
| 102 Vector<String> paramNames; |
| 103 Vector<String> paramValues; |
| 104 |
| 105 paramNames.append(String("type")); |
| 106 paramValues.append(mimeType); |
| 107 |
| 108 m_plugin = frame->loader()->client()->createPlugin(IntSize(), this, url, par
amNames, paramValues, mimeType, false, true); |
| 109 |
| 110 // Register the bindings with V8 as a scriptable object; normally this is |
| 111 // done in getInstance(), but that is only called after a renderer has been |
| 112 // assigned. |
| 113 if (m_plugin) { |
| 114 m_pluginMimeType = mimeType; |
| 115 // We require a V8 context in order to be able to create the script |
| 116 // instance, but since this may occur during loading we need to create |
| 117 // one here to ensure it exists. |
| 118 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
| 119 v8::Local<v8::Context> context = ScriptController::mainWorldContext(fram
e); |
| 120 v8::Context::Scope contextScope(context); |
| 121 m_instance = frame->script()->createScriptInstanceForWidget(m_plugin.get
()); |
| 122 } else { |
| 123 m_pluginMimeType = String(); |
| 124 } |
| 125 } |
| 126 |
91 void HTMLPlugInElement::detach(const AttachContext& context) | 127 void HTMLPlugInElement::detach(const AttachContext& context) |
92 { | 128 { |
93 m_instance.clear(); | 129 m_instance.clear(); |
94 | 130 |
95 if (m_isCapturingMouseEvents) { | 131 if (m_isCapturingMouseEvents) { |
96 if (Frame* frame = document().frame()) | 132 if (Frame* frame = document().frame()) |
97 frame->eventHandler()->setCapturingMouseEventsNode(0); | 133 frame->eventHandler()->setCapturingMouseEventsNode(0); |
98 m_isCapturingMouseEvents = false; | 134 m_isCapturingMouseEvents = false; |
99 } | 135 } |
100 | 136 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 } | 279 } |
244 | 280 |
245 NPObject* HTMLPlugInElement::getNPObject() | 281 NPObject* HTMLPlugInElement::getNPObject() |
246 { | 282 { |
247 ASSERT(document().frame()); | 283 ASSERT(document().frame()); |
248 if (!m_NPObject) | 284 if (!m_NPObject) |
249 m_NPObject = document().frame()->script()->createScriptObjectForPluginEl
ement(this); | 285 m_NPObject = document().frame()->script()->createScriptObjectForPluginEl
ement(this); |
250 return m_NPObject; | 286 return m_NPObject; |
251 } | 287 } |
252 | 288 |
| 289 void HTMLPlugInElement::setPlugin(PassRefPtr<Widget> plugin) |
| 290 { |
| 291 m_plugin = plugin; |
253 } | 292 } |
| 293 |
| 294 PassRefPtr<Widget> HTMLPlugInElement::plugin() |
| 295 { |
| 296 return m_plugin; |
| 297 } |
| 298 |
| 299 } |
OLD | NEW |