| 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 should_prefer_plug_ins_for_images_(prefer_plug_ins_for_images_option == | 85 should_prefer_plug_ins_for_images_(prefer_plug_ins_for_images_option == |
| 86 kShouldPreferPlugInsForImages) {} | 86 kShouldPreferPlugInsForImages) {} |
| 87 | 87 |
| 88 HTMLPlugInElement::~HTMLPlugInElement() { | 88 HTMLPlugInElement::~HTMLPlugInElement() { |
| 89 DCHECK(!plugin_wrapper_); // cleared in detachLayoutTree() | 89 DCHECK(!plugin_wrapper_); // cleared in detachLayoutTree() |
| 90 DCHECK(!is_delaying_load_event_); | 90 DCHECK(!is_delaying_load_event_); |
| 91 } | 91 } |
| 92 | 92 |
| 93 DEFINE_TRACE(HTMLPlugInElement) { | 93 DEFINE_TRACE(HTMLPlugInElement) { |
| 94 visitor->Trace(image_loader_); | 94 visitor->Trace(image_loader_); |
| 95 visitor->Trace(plugin_); | |
| 96 visitor->Trace(persisted_plugin_); | 95 visitor->Trace(persisted_plugin_); |
| 97 HTMLFrameOwnerElement::Trace(visitor); | 96 HTMLFrameOwnerElement::Trace(visitor); |
| 98 } | 97 } |
| 99 | 98 |
| 100 void HTMLPlugInElement::SetPlugin(PluginView* plugin) { | |
| 101 if (plugin == plugin_) | |
| 102 return; | |
| 103 | |
| 104 // Remove and dispose the old plugin if we had one. | |
| 105 if (plugin_) { | |
| 106 GetDocument().View()->RemovePlugin(plugin_); | |
| 107 DisposeFrameOrPluginSoon(plugin_); | |
| 108 } | |
| 109 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* layout_part = ToLayoutPart(GetLayoutObject()); | |
| 117 LayoutPartItem layout_part_item = LayoutPartItem(layout_part); | |
| 118 if (layout_part_item.IsNull()) | |
| 119 return; | |
| 120 | |
| 121 // Update layout and frame with new plugin. | |
| 122 if (plugin_) { | |
| 123 layout_part_item.UpdateOnWidgetChange(); | |
| 124 | |
| 125 DCHECK_EQ(GetDocument().View(), layout_part_item.GetFrameView()); | |
| 126 DCHECK(layout_part_item.GetFrameView()); | |
| 127 GetDocument().View()->AddPlugin(plugin); | |
| 128 } | |
| 129 | |
| 130 // Apparently accessibility objects might have been modified if plugin | |
| 131 // was removed. | |
| 132 if (AXObjectCache* cache = GetDocument().ExistingAXObjectCache()) | |
| 133 cache->ChildrenChanged(layout_part); | |
| 134 } | |
| 135 | |
| 136 PluginView* HTMLPlugInElement::ReleasePlugin() { | |
| 137 if (!plugin_) | |
| 138 return nullptr; | |
| 139 GetDocument().View()->RemovePlugin(plugin_); | |
| 140 LayoutPart* layout_part = ToLayoutPart(GetLayoutObject()); | |
| 141 if (layout_part) { | |
| 142 if (AXObjectCache* cache = GetDocument().ExistingAXObjectCache()) | |
| 143 cache->ChildrenChanged(layout_part); | |
| 144 } | |
| 145 return plugin_.Release(); | |
| 146 } | |
| 147 | |
| 148 void HTMLPlugInElement::SetPersistedPlugin(PluginView* plugin) { | 99 void HTMLPlugInElement::SetPersistedPlugin(PluginView* plugin) { |
| 149 if (persisted_plugin_ == plugin) | 100 if (persisted_plugin_ == plugin) |
| 150 return; | 101 return; |
| 151 if (persisted_plugin_) { | 102 if (persisted_plugin_) { |
| 152 persisted_plugin_->Hide(); | 103 persisted_plugin_->Hide(); |
| 153 DisposeFrameOrPluginSoon(persisted_plugin_.Release()); | 104 DisposeFrameOrPluginSoon(persisted_plugin_.Release()); |
| 154 } | 105 } |
| 155 persisted_plugin_ = plugin; | 106 persisted_plugin_ = plugin; |
| 156 } | 107 } |
| 157 | 108 |
| 158 void HTMLPlugInElement::SetFocused(bool focused, WebFocusType focus_type) { | 109 void HTMLPlugInElement::SetFocused(bool focused, WebFocusType focus_type) { |
| 159 if (plugin_) | 110 PluginView* plugin = OwnedPlugin(); |
| 160 plugin_->SetFocused(focused, focus_type); | 111 if (plugin) |
| 112 plugin->SetFocused(focused, focus_type); |
| 161 HTMLFrameOwnerElement::SetFocused(focused, focus_type); | 113 HTMLFrameOwnerElement::SetFocused(focused, focus_type); |
| 162 } | 114 } |
| 163 | 115 |
| 164 bool HTMLPlugInElement::RequestObjectInternal( | 116 bool HTMLPlugInElement::RequestObjectInternal( |
| 165 const String& url, | 117 const String& url, |
| 166 const String& mime_type, | 118 const String& mime_type, |
| 167 const Vector<String>& param_names, | 119 const Vector<String>& param_names, |
| 168 const Vector<String>& param_values) { | 120 const Vector<String>& param_values) { |
| 169 if (url.IsEmpty() && mime_type.IsEmpty()) | 121 if (url.IsEmpty() && mime_type.IsEmpty()) |
| 170 return false; | 122 return false; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 200 | 152 |
| 201 bool HTMLPlugInElement::WillRespondToMouseClickEvents() { | 153 bool HTMLPlugInElement::WillRespondToMouseClickEvents() { |
| 202 if (IsDisabledFormControl()) | 154 if (IsDisabledFormControl()) |
| 203 return false; | 155 return false; |
| 204 LayoutObject* r = GetLayoutObject(); | 156 LayoutObject* r = GetLayoutObject(); |
| 205 return r && (r->IsEmbeddedObject() || r->IsLayoutPart()); | 157 return r && (r->IsEmbeddedObject() || r->IsLayoutPart()); |
| 206 } | 158 } |
| 207 | 159 |
| 208 void HTMLPlugInElement::RemoveAllEventListeners() { | 160 void HTMLPlugInElement::RemoveAllEventListeners() { |
| 209 HTMLFrameOwnerElement::RemoveAllEventListeners(); | 161 HTMLFrameOwnerElement::RemoveAllEventListeners(); |
| 210 if (plugin_) { | 162 PluginView* plugin = OwnedPlugin(); |
| 211 plugin_->EventListenersRemoved(); | 163 if (plugin) |
| 212 } | 164 plugin->EventListenersRemoved(); |
| 213 } | 165 } |
| 214 | 166 |
| 215 void HTMLPlugInElement::DidMoveToNewDocument(Document& old_document) { | 167 void HTMLPlugInElement::DidMoveToNewDocument(Document& old_document) { |
| 216 if (image_loader_) | 168 if (image_loader_) |
| 217 image_loader_->ElementDidMoveToNewDocument(); | 169 image_loader_->ElementDidMoveToNewDocument(); |
| 218 HTMLFrameOwnerElement::DidMoveToNewDocument(old_document); | 170 HTMLFrameOwnerElement::DidMoveToNewDocument(old_document); |
| 219 } | 171 } |
| 220 | 172 |
| 221 void HTMLPlugInElement::AttachLayoutTree(const AttachContext& context) { | 173 void HTMLPlugInElement::AttachLayoutTree(const AttachContext& context) { |
| 222 HTMLFrameOwnerElement::AttachLayoutTree(context); | 174 HTMLFrameOwnerElement::AttachLayoutTree(context); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 253 |
| 302 param_names.push_back("type"); | 254 param_names.push_back("type"); |
| 303 param_values.push_back(service_type_); | 255 param_values.push_back(service_type_); |
| 304 | 256 |
| 305 bool use_fallback = false; | 257 bool use_fallback = false; |
| 306 LoadPlugin(url, service_type_, param_names, param_values, use_fallback, | 258 LoadPlugin(url, service_type_, param_names, param_values, use_fallback, |
| 307 false); | 259 false); |
| 308 } | 260 } |
| 309 | 261 |
| 310 bool HTMLPlugInElement::ShouldAccelerate() const { | 262 bool HTMLPlugInElement::ShouldAccelerate() const { |
| 311 return plugin_ && plugin_->PlatformLayer(); | 263 PluginView* plugin = OwnedPlugin(); |
| 264 return plugin && plugin->PlatformLayer(); |
| 312 } | 265 } |
| 313 | 266 |
| 314 void HTMLPlugInElement::DetachLayoutTree(const AttachContext& context) { | 267 void HTMLPlugInElement::DetachLayoutTree(const AttachContext& context) { |
| 315 // Update the FrameViewBase the next time we attach (detaching destroys the | 268 // Update the FrameViewBase the next time we attach (detaching destroys the |
| 316 // plugin). | 269 // plugin). |
| 317 // FIXME: None of this "needsPluginUpdate" related code looks right. | 270 // FIXME: None of this "needsPluginUpdate" related code looks right. |
| 318 if (GetLayoutObject() && !UseFallbackContent()) | 271 if (GetLayoutObject() && !UseFallbackContent()) |
| 319 SetNeedsPluginUpdate(true); | 272 SetNeedsPluginUpdate(true); |
| 320 | 273 |
| 321 if (is_delaying_load_event_) { | 274 if (is_delaying_load_event_) { |
| 322 is_delaying_load_event_ = false; | 275 is_delaying_load_event_ = false; |
| 323 GetDocument().DecrementLoadEventDelayCount(); | 276 GetDocument().DecrementLoadEventDelayCount(); |
| 324 } | 277 } |
| 325 | 278 |
| 326 // Only try to persist a plugin we actually own. | 279 // Only try to persist a plugin we actually own. |
| 327 if (plugin_ && context.performing_reattach) { | 280 PluginView* plugin = OwnedPlugin(); |
| 328 SetPersistedPlugin(ReleasePlugin()); | 281 if (plugin && context.performing_reattach) { |
| 282 SetPersistedPlugin(ToPluginView(ReleaseWidget())); |
| 329 } else { | 283 } else { |
| 330 // Clear the plugin; will trigger disposal of it with Oilpan. | 284 // Clear the plugin; will trigger disposal of it with Oilpan. |
| 331 SetPlugin(nullptr); | 285 SetWidget(nullptr); |
| 332 } | 286 } |
| 333 | 287 |
| 334 ResetInstance(); | 288 ResetInstance(); |
| 335 | 289 |
| 336 HTMLFrameOwnerElement::DetachLayoutTree(context); | 290 HTMLFrameOwnerElement::DetachLayoutTree(context); |
| 337 } | 291 } |
| 338 | 292 |
| 339 LayoutObject* HTMLPlugInElement::CreateLayoutObject( | 293 LayoutObject* HTMLPlugInElement::CreateLayoutObject( |
| 340 const ComputedStyle& style) { | 294 const ComputedStyle& style) { |
| 341 // Fallback content breaks the DOM->layoutObject class relationship of this | 295 // Fallback content breaks the DOM->layoutObject class relationship of this |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 if (!frame) | 327 if (!frame) |
| 374 return nullptr; | 328 return nullptr; |
| 375 | 329 |
| 376 // If the host dynamically turns off JavaScript (or Java) we will still | 330 // If the host dynamically turns off JavaScript (or Java) we will still |
| 377 // return the cached allocated Bindings::Instance. Not supporting this | 331 // return the cached allocated Bindings::Instance. Not supporting this |
| 378 // edge-case is OK. | 332 // edge-case is OK. |
| 379 if (!plugin_wrapper_) { | 333 if (!plugin_wrapper_) { |
| 380 PluginView* plugin; | 334 PluginView* plugin; |
| 381 | 335 |
| 382 if (persisted_plugin_) | 336 if (persisted_plugin_) |
| 383 plugin = persisted_plugin_.Get(); | 337 plugin = persisted_plugin_; |
| 384 else | 338 else |
| 385 plugin = PluginWidget(); | 339 plugin = PluginWidget(); |
| 386 | 340 |
| 387 if (plugin) { | 341 if (plugin) { |
| 388 plugin_wrapper_ = | 342 plugin_wrapper_ = |
| 389 frame->GetScriptController().CreatePluginWrapper(*plugin); | 343 frame->GetScriptController().CreatePluginWrapper(*plugin); |
| 390 } | 344 } |
| 391 } | 345 } |
| 392 return plugin_wrapper_.Get(); | 346 return plugin_wrapper_.Get(); |
| 393 } | 347 } |
| 394 | 348 |
| 395 PluginView* HTMLPlugInElement::PluginWidget() const { | 349 PluginView* HTMLPlugInElement::PluginWidget() const { |
| 396 if (LayoutPart* layout_part = LayoutPartForJSBindings()) | 350 if (LayoutPart* layout_part = LayoutPartForJSBindings()) |
| 397 return layout_part->Plugin(); | 351 return layout_part->Plugin(); |
| 398 return nullptr; | 352 return nullptr; |
| 399 } | 353 } |
| 400 | 354 |
| 401 PluginView* HTMLPlugInElement::Plugin() const { | 355 PluginView* HTMLPlugInElement::OwnedPlugin() const { |
| 402 return plugin_.Get(); | 356 FrameOrPlugin* frame_or_plugin = OwnedWidget(); |
| 357 if (frame_or_plugin && frame_or_plugin->IsPluginView()) |
| 358 return ToPluginView(frame_or_plugin); |
| 359 return nullptr; |
| 403 } | 360 } |
| 404 | 361 |
| 405 bool HTMLPlugInElement::IsPresentationAttribute( | 362 bool HTMLPlugInElement::IsPresentationAttribute( |
| 406 const QualifiedName& name) const { | 363 const QualifiedName& name) const { |
| 407 if (name == widthAttr || name == heightAttr || name == vspaceAttr || | 364 if (name == widthAttr || name == heightAttr || name == vspaceAttr || |
| 408 name == hspaceAttr || name == alignAttr) | 365 name == hspaceAttr || name == alignAttr) |
| 409 return true; | 366 return true; |
| 410 return HTMLFrameOwnerElement::IsPresentationAttribute(name); | 367 return HTMLFrameOwnerElement::IsPresentationAttribute(name); |
| 411 } | 368 } |
| 412 | 369 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 // code in EventHandler; these code paths should be united. | 401 // code in EventHandler; these code paths should be united. |
| 445 | 402 |
| 446 LayoutObject* r = GetLayoutObject(); | 403 LayoutObject* r = GetLayoutObject(); |
| 447 if (!r || !r->IsLayoutPart()) | 404 if (!r || !r->IsLayoutPart()) |
| 448 return; | 405 return; |
| 449 if (r->IsEmbeddedObject()) { | 406 if (r->IsEmbeddedObject()) { |
| 450 if (LayoutEmbeddedItem(ToLayoutEmbeddedObject(r)) | 407 if (LayoutEmbeddedItem(ToLayoutEmbeddedObject(r)) |
| 451 .ShowsUnavailablePluginIndicator()) | 408 .ShowsUnavailablePluginIndicator()) |
| 452 return; | 409 return; |
| 453 } | 410 } |
| 454 if (!plugin_) | 411 PluginView* plugin = OwnedPlugin(); |
| 412 if (!plugin) |
| 455 return; | 413 return; |
| 456 plugin_->HandleEvent(event); | 414 plugin->HandleEvent(event); |
| 457 if (event->DefaultHandled()) | 415 if (event->DefaultHandled()) |
| 458 return; | 416 return; |
| 459 HTMLFrameOwnerElement::DefaultEventHandler(event); | 417 HTMLFrameOwnerElement::DefaultEventHandler(event); |
| 460 } | 418 } |
| 461 | 419 |
| 462 LayoutPart* HTMLPlugInElement::LayoutPartForJSBindings() const { | 420 LayoutPart* HTMLPlugInElement::LayoutPartForJSBindings() const { |
| 463 // Needs to load the plugin immediatedly because this function is called | 421 // Needs to load the plugin immediatedly because this function is called |
| 464 // when JavaScript code accesses the plugin. | 422 // when JavaScript code accesses the plugin. |
| 465 // FIXME: Check if dispatching events here is safe. | 423 // FIXME: Check if dispatching events here is safe. |
| 466 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets( | 424 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets( |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 LayoutEmbeddedItem layout_item = GetLayoutEmbeddedItem(); | 532 LayoutEmbeddedItem layout_item = GetLayoutEmbeddedItem(); |
| 575 // FIXME: This code should not depend on layoutObject! | 533 // FIXME: This code should not depend on layoutObject! |
| 576 if ((layout_item.IsNull() && require_layout_object) || use_fallback) | 534 if ((layout_item.IsNull() && require_layout_object) || use_fallback) |
| 577 return false; | 535 return false; |
| 578 | 536 |
| 579 VLOG(1) << this << " Plugin URL: " << url_; | 537 VLOG(1) << this << " Plugin URL: " << url_; |
| 580 VLOG(1) << "Loaded URL: " << url.GetString(); | 538 VLOG(1) << "Loaded URL: " << url.GetString(); |
| 581 loaded_url_ = url; | 539 loaded_url_ = url; |
| 582 | 540 |
| 583 if (persisted_plugin_) { | 541 if (persisted_plugin_) { |
| 584 SetPlugin(persisted_plugin_.Release()); | 542 SetWidget(persisted_plugin_.Release()); |
| 585 } else { | 543 } else { |
| 586 bool load_manually = | 544 bool load_manually = |
| 587 GetDocument().IsPluginDocument() && !GetDocument().ContainsPlugins(); | 545 GetDocument().IsPluginDocument() && !GetDocument().ContainsPlugins(); |
| 588 LocalFrameClient::DetachedPluginPolicy policy = | 546 LocalFrameClient::DetachedPluginPolicy policy = |
| 589 require_layout_object ? LocalFrameClient::kFailOnDetachedPlugin | 547 require_layout_object ? LocalFrameClient::kFailOnDetachedPlugin |
| 590 : LocalFrameClient::kAllowDetachedPlugin; | 548 : LocalFrameClient::kAllowDetachedPlugin; |
| 591 PluginView* plugin = frame->Loader().Client()->CreatePlugin( | 549 PluginView* plugin = frame->Loader().Client()->CreatePlugin( |
| 592 this, url, param_names, param_values, mime_type, load_manually, policy); | 550 this, url, param_names, param_values, mime_type, load_manually, policy); |
| 593 if (!plugin) { | 551 if (!plugin) { |
| 594 if (!layout_item.IsNull() && | 552 if (!layout_item.IsNull() && |
| 595 !layout_item.ShowsUnavailablePluginIndicator()) { | 553 !layout_item.ShowsUnavailablePluginIndicator()) { |
| 596 plugin_is_available_ = false; | 554 plugin_is_available_ = false; |
| 597 layout_item.SetPluginAvailability(LayoutEmbeddedObject::kPluginMissing); | 555 layout_item.SetPluginAvailability(LayoutEmbeddedObject::kPluginMissing); |
| 598 } | 556 } |
| 599 return false; | 557 return false; |
| 600 } | 558 } |
| 601 | 559 |
| 602 if (!layout_item.IsNull()) | 560 if (!layout_item.IsNull()) |
| 603 SetPlugin(plugin); | 561 SetWidget(plugin); |
| 604 else | 562 else |
| 605 SetPersistedPlugin(plugin); | 563 SetPersistedPlugin(plugin); |
| 606 } | 564 } |
| 607 | 565 |
| 608 GetDocument().SetContainsPlugins(); | 566 GetDocument().SetContainsPlugins(); |
| 609 // TODO(esprehn): WebPluginContainerImpl::setWebLayer also schedules a | 567 // TODO(esprehn): WebPluginContainerImpl::setWebLayer also schedules a |
| 610 // compositing update, do we need both? | 568 // compositing update, do we need both? |
| 611 SetNeedsCompositingUpdate(); | 569 SetNeedsCompositingUpdate(); |
| 612 // Make sure any input event handlers introduced by the plugin are taken into | 570 // Make sure any input event handlers introduced by the plugin are taken into |
| 613 // account. | 571 // account. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 | 665 |
| 708 void HTMLPlugInElement::LazyReattachIfNeeded() { | 666 void HTMLPlugInElement::LazyReattachIfNeeded() { |
| 709 if (!UseFallbackContent() && NeedsPluginUpdate() && GetLayoutObject() && | 667 if (!UseFallbackContent() && NeedsPluginUpdate() && GetLayoutObject() && |
| 710 !IsImageType()) { | 668 !IsImageType()) { |
| 711 LazyReattachIfAttached(); | 669 LazyReattachIfAttached(); |
| 712 SetPersistedPlugin(nullptr); | 670 SetPersistedPlugin(nullptr); |
| 713 } | 671 } |
| 714 } | 672 } |
| 715 | 673 |
| 716 } // namespace blink | 674 } // namespace blink |
| OLD | NEW |