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_plugin); | |
95 visitor->trace(m_persistedPlugin); | 96 visitor->trace(m_persistedPlugin); |
96 HTMLFrameOwnerElement::trace(visitor); | 97 HTMLFrameOwnerElement::trace(visitor); |
97 } | 98 } |
98 | 99 |
99 // TODO(joelhockey): Move implementation of HTMLFrameOwnerElement | 100 void HTMLPlugInElement::setPlugin(PluginView* plugin) { |
100 // setWidget/releaseWidget/ownedWidget that relates to plugins to here and | 101 if (plugin == m_plugin) |
101 // remove inheritance from PluginView to FrameViewBase. | 102 return; |
102 void HTMLPlugInElement::setPlugin(PluginView* pluginView) { | 103 |
103 setWidget(pluginView); | 104 // Remove and dispose the old plugin if we had one. |
105 if (m_plugin) { | |
106 document().view()->removePlugin(m_plugin); | |
107 disposeWidgetSoon(m_plugin); | |
108 } | |
109 m_plugin = plugin; | |
110 | |
111 // TODO(joelhockey): I copied the rest of this method from | |
112 // HTMLFrameOwnerElement. There may be parts that can be removed | |
113 // such as the layoutPartItem.isNull check and DCHECKs. | |
114 // Once widget tree is removed (FrameView::m_children), try to unify | |
115 // this code with HTMLFrameOwnerElement::setWidget. | |
116 LayoutPart* layoutPart = toLayoutPart(layoutObject()); | |
117 LayoutPartItem layoutPartItem = LayoutPartItem(layoutPart); | |
118 if (layoutPartItem.isNull()) | |
119 return; | |
120 | |
121 // Update layout and frame with new plugin. | |
122 if (m_plugin) { | |
123 layoutPartItem.updateOnWidgetChange(); | |
124 | |
125 DCHECK_EQ(document().view(), layoutPartItem.frameView()); | |
126 DCHECK(layoutPartItem.frameView()); | |
127 document().view()->addPlugin(plugin); | |
128 } | |
129 | |
130 // Apparently accessibility objects might have been modified if plugin | |
131 // was removed. | |
132 if (AXObjectCache* cache = document().existingAXObjectCache()) | |
133 cache->childrenChanged(layoutPart); | |
104 } | 134 } |
105 | 135 |
106 PluginView* HTMLPlugInElement::releasePlugin() { | 136 PluginView* HTMLPlugInElement::releasePlugin() { |
107 FrameViewBase* plugin = releaseWidget(); | 137 if (!m_plugin) |
108 return plugin && plugin->isPluginView() ? toPluginView(plugin) : nullptr; | 138 return nullptr; |
109 } | 139 document().view()->removePlugin(m_plugin); |
haraken
2017/04/05 12:34:00
Not related to this CL, do you know why we don't n
joelhockey
2017/04/05 22:10:31
You are right that we do not dispose plugin here.
| |
110 | 140 LayoutPart* layoutPart = toLayoutPart(layoutObject()); |
111 PluginView* HTMLPlugInElement::ownedPlugin() const { | 141 if (layoutPart) { |
112 FrameViewBase* plugin = ownedWidget(); | 142 if (AXObjectCache* cache = document().existingAXObjectCache()) |
113 return plugin && plugin->isPluginView() ? toPluginView(plugin) : nullptr; | 143 cache->childrenChanged(layoutPart); |
144 } | |
145 return m_plugin.release(); | |
114 } | 146 } |
115 | 147 |
116 void HTMLPlugInElement::setPersistedPlugin(PluginView* plugin) { | 148 void HTMLPlugInElement::setPersistedPlugin(PluginView* plugin) { |
117 if (m_persistedPlugin == plugin) | 149 if (m_persistedPlugin == plugin) |
118 return; | 150 return; |
119 if (m_persistedPlugin) { | 151 if (m_persistedPlugin) { |
120 m_persistedPlugin->hide(); | 152 m_persistedPlugin->hide(); |
121 disposeWidgetSoon(m_persistedPlugin.release()); | 153 disposeWidgetSoon(m_persistedPlugin.release()); |
122 } | 154 } |
123 m_persistedPlugin = plugin; | 155 m_persistedPlugin = plugin; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 | 194 |
163 bool HTMLPlugInElement::willRespondToMouseClickEvents() { | 195 bool HTMLPlugInElement::willRespondToMouseClickEvents() { |
164 if (isDisabledFormControl()) | 196 if (isDisabledFormControl()) |
165 return false; | 197 return false; |
166 LayoutObject* r = layoutObject(); | 198 LayoutObject* r = layoutObject(); |
167 return r && (r->isEmbeddedObject() || r->isLayoutPart()); | 199 return r && (r->isEmbeddedObject() || r->isLayoutPart()); |
168 } | 200 } |
169 | 201 |
170 void HTMLPlugInElement::removeAllEventListeners() { | 202 void HTMLPlugInElement::removeAllEventListeners() { |
171 HTMLFrameOwnerElement::removeAllEventListeners(); | 203 HTMLFrameOwnerElement::removeAllEventListeners(); |
172 if (LayoutPart* layoutObject = existingLayoutPart()) { | 204 if (m_plugin) { |
173 if (FrameViewBase* frameViewBase = layoutObject->frameViewBase()) | 205 m_plugin->eventListenersRemoved(); |
174 frameViewBase->eventListenersRemoved(); | |
175 } | 206 } |
176 } | 207 } |
177 | 208 |
178 void HTMLPlugInElement::didMoveToNewDocument(Document& oldDocument) { | 209 void HTMLPlugInElement::didMoveToNewDocument(Document& oldDocument) { |
179 if (m_imageLoader) | 210 if (m_imageLoader) |
180 m_imageLoader->elementDidMoveToNewDocument(); | 211 m_imageLoader->elementDidMoveToNewDocument(); |
181 HTMLFrameOwnerElement::didMoveToNewDocument(oldDocument); | 212 HTMLFrameOwnerElement::didMoveToNewDocument(oldDocument); |
182 } | 213 } |
183 | 214 |
184 void HTMLPlugInElement::attachLayoutTree(const AttachContext& context) { | 215 void HTMLPlugInElement::attachLayoutTree(const AttachContext& context) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
256 Vector<String> paramValues; | 287 Vector<String> paramValues; |
257 | 288 |
258 paramNames.push_back("type"); | 289 paramNames.push_back("type"); |
259 paramValues.push_back(m_serviceType); | 290 paramValues.push_back(m_serviceType); |
260 | 291 |
261 bool useFallback = false; | 292 bool useFallback = false; |
262 loadPlugin(url, m_serviceType, paramNames, paramValues, useFallback, false); | 293 loadPlugin(url, m_serviceType, paramNames, paramValues, useFallback, false); |
263 } | 294 } |
264 | 295 |
265 bool HTMLPlugInElement::shouldAccelerate() const { | 296 bool HTMLPlugInElement::shouldAccelerate() const { |
266 return ownedPlugin() && ownedPlugin()->platformLayer(); | 297 return m_plugin && m_plugin->platformLayer(); |
267 } | 298 } |
268 | 299 |
269 void HTMLPlugInElement::detachLayoutTree(const AttachContext& context) { | 300 void HTMLPlugInElement::detachLayoutTree(const AttachContext& context) { |
270 // Update the FrameViewBase the next time we attach (detaching destroys the | 301 // Update the FrameViewBase the next time we attach (detaching destroys the |
271 // plugin). | 302 // plugin). |
272 // FIXME: None of this "needsPluginUpdate" related code looks right. | 303 // FIXME: None of this "needsPluginUpdate" related code looks right. |
273 if (layoutObject() && !useFallbackContent()) | 304 if (layoutObject() && !useFallbackContent()) |
274 setNeedsPluginUpdate(true); | 305 setNeedsPluginUpdate(true); |
275 | 306 |
276 if (m_isDelayingLoadEvent) { | 307 if (m_isDelayingLoadEvent) { |
277 m_isDelayingLoadEvent = false; | 308 m_isDelayingLoadEvent = false; |
278 document().decrementLoadEventDelayCount(); | 309 document().decrementLoadEventDelayCount(); |
279 } | 310 } |
280 | 311 |
281 // Only try to persist a plugin we actually own. | 312 // Only try to persist a plugin we actually own. |
282 PluginView* plugin = ownedPlugin(); | 313 if (m_plugin && context.performingReattach) { |
283 if (plugin && context.performingReattach) { | |
284 setPersistedPlugin(releasePlugin()); | 314 setPersistedPlugin(releasePlugin()); |
285 } else { | 315 } else { |
286 // Clear the plugin; will trigger disposal of it with Oilpan. | 316 // Clear the plugin; will trigger disposal of it with Oilpan. |
287 setPlugin(nullptr); | 317 setPlugin(nullptr); |
288 } | 318 } |
289 | 319 |
290 resetInstance(); | 320 resetInstance(); |
291 | 321 |
292 HTMLFrameOwnerElement::detachLayoutTree(context); | 322 HTMLFrameOwnerElement::detachLayoutTree(context); |
293 } | 323 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
340 else | 370 else |
341 plugin = pluginWidget(); | 371 plugin = pluginWidget(); |
342 | 372 |
343 if (plugin) | 373 if (plugin) |
344 m_pluginWrapper = frame->script().createPluginWrapper(*plugin); | 374 m_pluginWrapper = frame->script().createPluginWrapper(*plugin); |
345 } | 375 } |
346 return m_pluginWrapper.get(); | 376 return m_pluginWrapper.get(); |
347 } | 377 } |
348 | 378 |
349 PluginView* HTMLPlugInElement::pluginWidget() const { | 379 PluginView* HTMLPlugInElement::pluginWidget() const { |
350 LayoutPart* layoutPart = layoutPartForJSBindings(); | 380 if (LayoutPart* layoutPart = layoutPartForJSBindings()) |
351 if (layoutPart && layoutPart->frameViewBase() && | 381 return layoutPart->plugin(); |
352 layoutPart->frameViewBase()->isPluginView()) | |
353 return toPluginView(layoutPart->frameViewBase()); | |
354 return nullptr; | 382 return nullptr; |
355 } | 383 } |
356 | 384 |
385 PluginView* HTMLPlugInElement::plugin() const { | |
386 return m_plugin.get(); | |
387 } | |
388 | |
357 bool HTMLPlugInElement::isPresentationAttribute( | 389 bool HTMLPlugInElement::isPresentationAttribute( |
358 const QualifiedName& name) const { | 390 const QualifiedName& name) const { |
359 if (name == widthAttr || name == heightAttr || name == vspaceAttr || | 391 if (name == widthAttr || name == heightAttr || name == vspaceAttr || |
360 name == hspaceAttr || name == alignAttr) | 392 name == hspaceAttr || name == alignAttr) |
361 return true; | 393 return true; |
362 return HTMLFrameOwnerElement::isPresentationAttribute(name); | 394 return HTMLFrameOwnerElement::isPresentationAttribute(name); |
363 } | 395 } |
364 | 396 |
365 void HTMLPlugInElement::collectStyleForPresentationAttribute( | 397 void HTMLPlugInElement::collectStyleForPresentationAttribute( |
366 const QualifiedName& name, | 398 const QualifiedName& name, |
(...skipping 29 matching lines...) Expand all Loading... | |
396 // code in EventHandler; these code paths should be united. | 428 // code in EventHandler; these code paths should be united. |
397 | 429 |
398 LayoutObject* r = layoutObject(); | 430 LayoutObject* r = layoutObject(); |
399 if (!r || !r->isLayoutPart()) | 431 if (!r || !r->isLayoutPart()) |
400 return; | 432 return; |
401 if (r->isEmbeddedObject()) { | 433 if (r->isEmbeddedObject()) { |
402 if (LayoutEmbeddedItem(toLayoutEmbeddedObject(r)) | 434 if (LayoutEmbeddedItem(toLayoutEmbeddedObject(r)) |
403 .showsUnavailablePluginIndicator()) | 435 .showsUnavailablePluginIndicator()) |
404 return; | 436 return; |
405 } | 437 } |
406 FrameViewBase* frameViewBase = toLayoutPart(r)->frameViewBase(); | 438 if (!m_plugin) |
407 if (!frameViewBase) | |
408 return; | 439 return; |
409 frameViewBase->handleEvent(event); | 440 m_plugin->handleEvent(event); |
410 if (event->defaultHandled()) | 441 if (event->defaultHandled()) |
411 return; | 442 return; |
412 HTMLFrameOwnerElement::defaultEventHandler(event); | 443 HTMLFrameOwnerElement::defaultEventHandler(event); |
413 } | 444 } |
414 | 445 |
415 LayoutPart* HTMLPlugInElement::layoutPartForJSBindings() const { | 446 LayoutPart* HTMLPlugInElement::layoutPartForJSBindings() const { |
416 // Needs to load the plugin immediatedly because this function is called | 447 // Needs to load the plugin immediatedly because this function is called |
417 // when JavaScript code accesses the plugin. | 448 // when JavaScript code accesses the plugin. |
418 // FIXME: Check if dispatching events here is safe. | 449 // FIXME: Check if dispatching events here is safe. |
419 document().updateStyleAndLayoutIgnorePendingStylesheets( | 450 document().updateStyleAndLayoutIgnorePendingStylesheets( |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
658 | 689 |
659 void HTMLPlugInElement::lazyReattachIfNeeded() { | 690 void HTMLPlugInElement::lazyReattachIfNeeded() { |
660 if (!useFallbackContent() && needsPluginUpdate() && layoutObject() && | 691 if (!useFallbackContent() && needsPluginUpdate() && layoutObject() && |
661 !isImageType()) { | 692 !isImageType()) { |
662 lazyReattachIfAttached(); | 693 lazyReattachIfAttached(); |
663 setPersistedPlugin(nullptr); | 694 setPersistedPlugin(nullptr); |
664 } | 695 } |
665 } | 696 } |
666 | 697 |
667 } // namespace blink | 698 } // namespace blink |
OLD | NEW |