Chromium Code Reviews| 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) |
|
dcheng
2017/03/30 04:43:07
One other concern is that because we don't use HTM
joelhockey
2017/03/30 06:40:57
Yes, I've been trying to figure out a failing test
| |
| 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 LayoutPart* layoutPart = toLayoutPart(layoutObject()); | |
| 115 LayoutPartItem layoutPartItem = LayoutPartItem(layoutPart); | |
| 116 if (layoutPartItem.isNull()) | |
| 117 return; | |
| 118 | |
| 119 // Update layout and frame with new plugin. | |
| 120 if (m_plugin) { | |
| 121 layoutPartItem.updateOnWidgetChange(); | |
| 122 | |
| 123 DCHECK_EQ(document().view(), layoutPartItem.frameView()); | |
| 124 DCHECK(layoutPartItem.frameView()); | |
| 125 plugin->setParent(layoutPartItem.frameView()); | |
| 126 document().view()->addPlugin(plugin); | |
| 127 } | |
| 128 | |
| 129 // Apparently accessibility objects might have been modified if plugin | |
| 130 // was removed. | |
| 131 if (AXObjectCache* cache = document().existingAXObjectCache()) | |
| 132 cache->childrenChanged(layoutPart); | |
| 104 } | 133 } |
| 105 | 134 |
| 106 PluginView* HTMLPlugInElement::releasePlugin() { | 135 PluginView* HTMLPlugInElement::releasePlugin() { |
| 107 FrameViewBase* plugin = releaseWidget(); | 136 if (!m_plugin) |
| 108 return plugin && plugin->isPluginView() ? toPluginView(plugin) : nullptr; | 137 return nullptr; |
| 109 } | 138 document().view()->removePlugin(m_plugin); |
| 110 | 139 LayoutPart* layoutPart = toLayoutPart(layoutObject()); |
| 111 PluginView* HTMLPlugInElement::ownedPlugin() const { | 140 if (layoutPart) { |
| 112 FrameViewBase* plugin = ownedWidget(); | 141 if (AXObjectCache* cache = document().existingAXObjectCache()) |
| 113 return plugin && plugin->isPluginView() ? toPluginView(plugin) : nullptr; | 142 cache->childrenChanged(layoutPart); |
| 143 } | |
| 144 return m_plugin.release(); | |
| 114 } | 145 } |
| 115 | 146 |
| 116 void HTMLPlugInElement::setPersistedPlugin(PluginView* plugin) { | 147 void HTMLPlugInElement::setPersistedPlugin(PluginView* plugin) { |
| 117 if (m_persistedPlugin == plugin) | 148 if (m_persistedPlugin == plugin) |
| 118 return; | 149 return; |
| 119 if (m_persistedPlugin) { | 150 if (m_persistedPlugin) { |
| 120 m_persistedPlugin->hide(); | 151 m_persistedPlugin->hide(); |
| 121 disposeWidgetSoon(m_persistedPlugin.release()); | 152 disposeWidgetSoon(m_persistedPlugin.release()); |
| 122 } | 153 } |
| 123 m_persistedPlugin = plugin; | 154 m_persistedPlugin = plugin; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 146 // new frame and set it as the LayoutPart's FrameViewBase, causing what was | 177 // new frame and set it as the LayoutPart's FrameViewBase, causing what was |
| 147 // previously in the FrameViewBase to be torn down. | 178 // previously in the FrameViewBase to be torn down. |
| 148 return loadOrRedirectSubframe(completedURL, getNameAttribute(), true); | 179 return loadOrRedirectSubframe(completedURL, getNameAttribute(), true); |
| 149 } | 180 } |
| 150 | 181 |
| 151 return loadPlugin(completedURL, mimeType, paramNames, paramValues, | 182 return loadPlugin(completedURL, mimeType, paramNames, paramValues, |
| 152 useFallback, true); | 183 useFallback, true); |
| 153 } | 184 } |
| 154 | 185 |
| 155 bool HTMLPlugInElement::canProcessDrag() const { | 186 bool HTMLPlugInElement::canProcessDrag() const { |
| 156 return pluginWidget() && pluginWidget()->isPluginView() && | 187 return pluginWidget() && pluginWidget()->canProcessDrag(); |
| 157 toPluginView(pluginWidget())->canProcessDrag(); | |
| 158 } | 188 } |
| 159 | 189 |
| 160 bool HTMLPlugInElement::canStartSelection() const { | 190 bool HTMLPlugInElement::canStartSelection() const { |
| 161 return useFallbackContent() && Node::canStartSelection(); | 191 return useFallbackContent() && Node::canStartSelection(); |
| 162 } | 192 } |
| 163 | 193 |
| 164 bool HTMLPlugInElement::willRespondToMouseClickEvents() { | 194 bool HTMLPlugInElement::willRespondToMouseClickEvents() { |
| 165 if (isDisabledFormControl()) | 195 if (isDisabledFormControl()) |
| 166 return false; | 196 return false; |
| 167 LayoutObject* r = layoutObject(); | 197 LayoutObject* r = layoutObject(); |
| 168 return r && (r->isEmbeddedObject() || r->isLayoutPart()); | 198 return r && (r->isEmbeddedObject() || r->isLayoutPart()); |
| 169 } | 199 } |
| 170 | 200 |
| 171 void HTMLPlugInElement::removeAllEventListeners() { | 201 void HTMLPlugInElement::removeAllEventListeners() { |
| 172 HTMLFrameOwnerElement::removeAllEventListeners(); | 202 HTMLFrameOwnerElement::removeAllEventListeners(); |
| 173 if (LayoutPart* layoutObject = existingLayoutPart()) { | 203 if (m_plugin) { |
| 174 if (FrameViewBase* frameViewBase = layoutObject->frameViewBase()) | 204 m_plugin->eventListenersRemoved(); |
| 175 frameViewBase->eventListenersRemoved(); | |
| 176 } | 205 } |
| 177 } | 206 } |
| 178 | 207 |
| 179 void HTMLPlugInElement::didMoveToNewDocument(Document& oldDocument) { | 208 void HTMLPlugInElement::didMoveToNewDocument(Document& oldDocument) { |
| 180 if (m_imageLoader) | 209 if (m_imageLoader) |
| 181 m_imageLoader->elementDidMoveToNewDocument(); | 210 m_imageLoader->elementDidMoveToNewDocument(); |
| 182 HTMLFrameOwnerElement::didMoveToNewDocument(oldDocument); | 211 HTMLFrameOwnerElement::didMoveToNewDocument(oldDocument); |
| 183 } | 212 } |
| 184 | 213 |
| 185 void HTMLPlugInElement::attachLayoutTree(const AttachContext& context) { | 214 void HTMLPlugInElement::attachLayoutTree(const AttachContext& context) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 257 Vector<String> paramValues; | 286 Vector<String> paramValues; |
| 258 | 287 |
| 259 paramNames.push_back("type"); | 288 paramNames.push_back("type"); |
| 260 paramValues.push_back(m_serviceType); | 289 paramValues.push_back(m_serviceType); |
| 261 | 290 |
| 262 bool useFallback = false; | 291 bool useFallback = false; |
| 263 loadPlugin(url, m_serviceType, paramNames, paramValues, useFallback, false); | 292 loadPlugin(url, m_serviceType, paramNames, paramValues, useFallback, false); |
| 264 } | 293 } |
| 265 | 294 |
| 266 bool HTMLPlugInElement::shouldAccelerate() const { | 295 bool HTMLPlugInElement::shouldAccelerate() const { |
| 267 return ownedPlugin() && ownedPlugin()->platformLayer(); | 296 return m_plugin && m_plugin->platformLayer(); |
| 268 } | 297 } |
| 269 | 298 |
| 270 void HTMLPlugInElement::detachLayoutTree(const AttachContext& context) { | 299 void HTMLPlugInElement::detachLayoutTree(const AttachContext& context) { |
| 271 // Update the FrameViewBase the next time we attach (detaching destroys the | 300 // Update the FrameViewBase the next time we attach (detaching destroys the |
| 272 // plugin). | 301 // plugin). |
| 273 // FIXME: None of this "needsPluginUpdate" related code looks right. | 302 // FIXME: None of this "needsPluginUpdate" related code looks right. |
| 274 if (layoutObject() && !useFallbackContent()) | 303 if (layoutObject() && !useFallbackContent()) |
| 275 setNeedsPluginUpdate(true); | 304 setNeedsPluginUpdate(true); |
| 276 | 305 |
| 277 if (m_isDelayingLoadEvent) { | 306 if (m_isDelayingLoadEvent) { |
| 278 m_isDelayingLoadEvent = false; | 307 m_isDelayingLoadEvent = false; |
| 279 document().decrementLoadEventDelayCount(); | 308 document().decrementLoadEventDelayCount(); |
| 280 } | 309 } |
| 281 | 310 |
| 282 // Only try to persist a plugin we actually own. | 311 // Only try to persist a plugin we actually own. |
| 283 PluginView* plugin = ownedPlugin(); | 312 if (m_plugin && context.performingReattach) { |
| 284 if (plugin && context.performingReattach) { | |
| 285 setPersistedPlugin(releasePlugin()); | 313 setPersistedPlugin(releasePlugin()); |
| 286 } else { | 314 } else { |
| 287 // Clear the plugin; will trigger disposal of it with Oilpan. | 315 // Clear the plugin; will trigger disposal of it with Oilpan. |
| 288 setPlugin(nullptr); | 316 setPlugin(nullptr); |
| 289 } | 317 } |
| 290 | 318 |
| 291 resetInstance(); | 319 resetInstance(); |
| 292 | 320 |
| 293 HTMLFrameOwnerElement::detachLayoutTree(context); | 321 HTMLFrameOwnerElement::detachLayoutTree(context); |
| 294 } | 322 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 plugin = m_persistedPlugin.get(); | 368 plugin = m_persistedPlugin.get(); |
| 341 else | 369 else |
| 342 plugin = pluginWidget(); | 370 plugin = pluginWidget(); |
| 343 | 371 |
| 344 if (plugin) | 372 if (plugin) |
| 345 m_pluginWrapper = frame->script().createPluginWrapper(plugin); | 373 m_pluginWrapper = frame->script().createPluginWrapper(plugin); |
| 346 } | 374 } |
| 347 return m_pluginWrapper.get(); | 375 return m_pluginWrapper.get(); |
| 348 } | 376 } |
| 349 | 377 |
| 350 FrameViewBase* HTMLPlugInElement::pluginWidget() const { | 378 // TODO(joelhockey): Remove this and use m_plugin. |
| 379 // Maybe just pluginWrapper function should check if m_plugin is null, | |
| 380 // and call document().updateStyleAndLayoutIgnorePendingStylesheets as per | |
| 381 // layoutPartForJSBindings. | |
|
dcheng
2017/03/30 04:43:07
The difference between these is pretty subtle. Is
joelhockey
2017/03/30 06:40:57
I will look at this in a follow up CL. If I can't
| |
| 382 PluginView* HTMLPlugInElement::pluginWidget() const { | |
| 351 if (LayoutPart* layoutPart = layoutPartForJSBindings()) | 383 if (LayoutPart* layoutPart = layoutPartForJSBindings()) |
| 352 return layoutPart->frameViewBase(); | 384 return layoutPart->plugin(); |
| 353 return nullptr; | 385 return nullptr; |
| 354 } | 386 } |
| 355 | 387 |
| 388 PluginView* HTMLPlugInElement::plugin() const { | |
| 389 return m_plugin.get(); | |
| 390 } | |
| 391 | |
| 356 bool HTMLPlugInElement::isPresentationAttribute( | 392 bool HTMLPlugInElement::isPresentationAttribute( |
| 357 const QualifiedName& name) const { | 393 const QualifiedName& name) const { |
| 358 if (name == widthAttr || name == heightAttr || name == vspaceAttr || | 394 if (name == widthAttr || name == heightAttr || name == vspaceAttr || |
| 359 name == hspaceAttr || name == alignAttr) | 395 name == hspaceAttr || name == alignAttr) |
| 360 return true; | 396 return true; |
| 361 return HTMLFrameOwnerElement::isPresentationAttribute(name); | 397 return HTMLFrameOwnerElement::isPresentationAttribute(name); |
| 362 } | 398 } |
| 363 | 399 |
| 364 void HTMLPlugInElement::collectStyleForPresentationAttribute( | 400 void HTMLPlugInElement::collectStyleForPresentationAttribute( |
| 365 const QualifiedName& name, | 401 const QualifiedName& name, |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 395 // code in EventHandler; these code paths should be united. | 431 // code in EventHandler; these code paths should be united. |
| 396 | 432 |
| 397 LayoutObject* r = layoutObject(); | 433 LayoutObject* r = layoutObject(); |
| 398 if (!r || !r->isLayoutPart()) | 434 if (!r || !r->isLayoutPart()) |
| 399 return; | 435 return; |
| 400 if (r->isEmbeddedObject()) { | 436 if (r->isEmbeddedObject()) { |
| 401 if (LayoutEmbeddedItem(toLayoutEmbeddedObject(r)) | 437 if (LayoutEmbeddedItem(toLayoutEmbeddedObject(r)) |
| 402 .showsUnavailablePluginIndicator()) | 438 .showsUnavailablePluginIndicator()) |
| 403 return; | 439 return; |
| 404 } | 440 } |
| 405 FrameViewBase* frameViewBase = toLayoutPart(r)->frameViewBase(); | 441 if (!m_plugin) |
| 406 if (!frameViewBase) | |
| 407 return; | 442 return; |
| 408 frameViewBase->handleEvent(event); | 443 m_plugin->handleEvent(event); |
|
dcheng
2017/03/30 04:43:07
Hm... if this is an <object> element with a subfra
joelhockey
2017/03/30 06:40:57
I'm not sure if I really understand you, but I'm p
| |
| 409 if (event->defaultHandled()) | 444 if (event->defaultHandled()) |
| 410 return; | 445 return; |
| 411 HTMLFrameOwnerElement::defaultEventHandler(event); | 446 HTMLFrameOwnerElement::defaultEventHandler(event); |
| 412 } | 447 } |
| 413 | 448 |
| 414 LayoutPart* HTMLPlugInElement::layoutPartForJSBindings() const { | 449 LayoutPart* HTMLPlugInElement::layoutPartForJSBindings() const { |
| 415 // Needs to load the plugin immediatedly because this function is called | 450 // Needs to load the plugin immediatedly because this function is called |
| 416 // when JavaScript code accesses the plugin. | 451 // when JavaScript code accesses the plugin. |
| 417 // FIXME: Check if dispatching events here is safe. | 452 // FIXME: Check if dispatching events here is safe. |
| 418 document().updateStyleAndLayoutIgnorePendingStylesheets( | 453 document().updateStyleAndLayoutIgnorePendingStylesheets( |
| 419 Document::RunPostLayoutTasksSynchronously); | 454 Document::RunPostLayoutTasksSynchronously); |
| 420 return existingLayoutPart(); | 455 return existingLayoutPart(); |
| 421 } | 456 } |
| 422 | 457 |
| 423 bool HTMLPlugInElement::isKeyboardFocusable() const { | 458 bool HTMLPlugInElement::isKeyboardFocusable() const { |
| 424 if (HTMLFrameOwnerElement::isKeyboardFocusable()) | 459 if (HTMLFrameOwnerElement::isKeyboardFocusable()) |
| 425 return true; | 460 return true; |
| 426 return document().isActive() && pluginWidget() && | 461 return document().isActive() && pluginWidget() && |
| 427 pluginWidget()->isPluginView() && | 462 pluginWidget()->supportsKeyboardFocus(); |
| 428 toPluginView(pluginWidget())->supportsKeyboardFocus(); | |
| 429 } | 463 } |
| 430 | 464 |
| 431 bool HTMLPlugInElement::hasCustomFocusLogic() const { | 465 bool HTMLPlugInElement::hasCustomFocusLogic() const { |
| 432 return !useFallbackContent(); | 466 return !useFallbackContent(); |
| 433 } | 467 } |
| 434 | 468 |
| 435 bool HTMLPlugInElement::isPluginElement() const { | 469 bool HTMLPlugInElement::isPluginElement() const { |
| 436 return true; | 470 return true; |
| 437 } | 471 } |
| 438 | 472 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 658 | 692 |
| 659 void HTMLPlugInElement::lazyReattachIfNeeded() { | 693 void HTMLPlugInElement::lazyReattachIfNeeded() { |
| 660 if (!useFallbackContent() && needsPluginUpdate() && layoutObject() && | 694 if (!useFallbackContent() && needsPluginUpdate() && layoutObject() && |
| 661 !isImageType()) { | 695 !isImageType()) { |
| 662 lazyReattachIfAttached(); | 696 lazyReattachIfAttached(); |
| 663 setPersistedPlugin(nullptr); | 697 setPersistedPlugin(nullptr); |
| 664 } | 698 } |
| 665 } | 699 } |
| 666 | 700 |
| 667 } // namespace blink | 701 } // namespace blink |
| OLD | NEW |