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 20 matching lines...) Expand all Loading... |
31 #include "core/dom/Node.h" | 31 #include "core/dom/Node.h" |
32 #include "core/dom/shadow/ShadowRoot.h" | 32 #include "core/dom/shadow/ShadowRoot.h" |
33 #include "core/events/Event.h" | 33 #include "core/events/Event.h" |
34 #include "core/frame/FrameView.h" | 34 #include "core/frame/FrameView.h" |
35 #include "core/frame/LocalFrame.h" | 35 #include "core/frame/LocalFrame.h" |
36 #include "core/frame/Settings.h" | 36 #include "core/frame/Settings.h" |
37 #include "core/frame/csp/ContentSecurityPolicy.h" | 37 #include "core/frame/csp/ContentSecurityPolicy.h" |
38 #include "core/html/HTMLContentElement.h" | 38 #include "core/html/HTMLContentElement.h" |
39 #include "core/html/HTMLImageLoader.h" | 39 #include "core/html/HTMLImageLoader.h" |
40 #include "core/html/PluginDocument.h" | 40 #include "core/html/PluginDocument.h" |
| 41 #include "core/layout/LayoutEmbeddedObject.h" |
41 #include "core/layout/LayoutImage.h" | 42 #include "core/layout/LayoutImage.h" |
42 #include "core/layout/LayoutPart.h" | 43 #include "core/layout/LayoutPart.h" |
43 #include "core/loader/FrameLoaderClient.h" | 44 #include "core/loader/FrameLoaderClient.h" |
44 #include "core/loader/MixedContentChecker.h" | 45 #include "core/loader/MixedContentChecker.h" |
45 #include "core/page/EventHandler.h" | 46 #include "core/page/EventHandler.h" |
46 #include "core/page/Page.h" | 47 #include "core/page/Page.h" |
47 #include "core/page/scrolling/ScrollingCoordinator.h" | 48 #include "core/page/scrolling/ScrollingCoordinator.h" |
48 #include "core/plugins/PluginPlaceholder.h" | 49 #include "core/plugins/PluginPlaceholder.h" |
49 #include "core/plugins/PluginView.h" | 50 #include "core/plugins/PluginView.h" |
50 #include "core/rendering/RenderBlockFlow.h" | 51 #include "core/rendering/RenderBlockFlow.h" |
51 #include "core/rendering/RenderEmbeddedObject.h" | |
52 #include "platform/Logging.h" | 52 #include "platform/Logging.h" |
53 #include "platform/MIMETypeFromURL.h" | 53 #include "platform/MIMETypeFromURL.h" |
54 #include "platform/MIMETypeRegistry.h" | 54 #include "platform/MIMETypeRegistry.h" |
55 #include "platform/Widget.h" | 55 #include "platform/Widget.h" |
56 #include "platform/plugins/PluginData.h" | 56 #include "platform/plugins/PluginData.h" |
57 #include "public/platform/WebURLRequest.h" | 57 #include "public/platform/WebURLRequest.h" |
58 | 58 |
59 namespace blink { | 59 namespace blink { |
60 | 60 |
61 using namespace HTMLNames; | 61 using namespace HTMLNames; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 HTMLFrameOwnerElement::attach(context); | 165 HTMLFrameOwnerElement::attach(context); |
166 | 166 |
167 if (!renderer() || useFallbackContent()) | 167 if (!renderer() || useFallbackContent()) |
168 return; | 168 return; |
169 | 169 |
170 if (isImageType()) { | 170 if (isImageType()) { |
171 if (!m_imageLoader) | 171 if (!m_imageLoader) |
172 m_imageLoader = HTMLImageLoader::create(this); | 172 m_imageLoader = HTMLImageLoader::create(this); |
173 m_imageLoader->updateFromElement(); | 173 m_imageLoader->updateFromElement(); |
174 } else if (needsWidgetUpdate() | 174 } else if (needsWidgetUpdate() |
175 && renderEmbeddedObject() | 175 && layoutEmbeddedObject() |
176 && !renderEmbeddedObject()->showsUnavailablePluginIndicator() | 176 && !layoutEmbeddedObject()->showsUnavailablePluginIndicator() |
177 && !wouldLoadAsNetscapePlugin(m_url, m_serviceType) | 177 && !wouldLoadAsNetscapePlugin(m_url, m_serviceType) |
178 && !m_isDelayingLoadEvent) { | 178 && !m_isDelayingLoadEvent) { |
179 m_isDelayingLoadEvent = true; | 179 m_isDelayingLoadEvent = true; |
180 document().incrementLoadEventDelayCount(); | 180 document().incrementLoadEventDelayCount(); |
181 document().loadPluginsSoon(); | 181 document().loadPluginsSoon(); |
182 } | 182 } |
183 } | 183 } |
184 | 184 |
185 void HTMLPlugInElement::updateWidget() | 185 void HTMLPlugInElement::updateWidget() |
186 { | 186 { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 m_NPObject = 0; | 260 m_NPObject = 0; |
261 } | 261 } |
262 | 262 |
263 HTMLFrameOwnerElement::detach(context); | 263 HTMLFrameOwnerElement::detach(context); |
264 } | 264 } |
265 | 265 |
266 LayoutObject* HTMLPlugInElement::createRenderer(const LayoutStyle& style) | 266 LayoutObject* HTMLPlugInElement::createRenderer(const LayoutStyle& style) |
267 { | 267 { |
268 // Fallback content breaks the DOM->Renderer class relationship of this | 268 // Fallback content breaks the DOM->Renderer class relationship of this |
269 // class and all superclasses because createObject won't necessarily return | 269 // class and all superclasses because createObject won't necessarily return |
270 // a RenderEmbeddedObject or LayoutPart. | 270 // a LayoutEmbeddedObject or LayoutPart. |
271 if (useFallbackContent()) | 271 if (useFallbackContent()) |
272 return LayoutObject::createObject(this, style); | 272 return LayoutObject::createObject(this, style); |
273 | 273 |
274 if (isImageType()) { | 274 if (isImageType()) { |
275 LayoutImage* image = new LayoutImage(this); | 275 LayoutImage* image = new LayoutImage(this); |
276 image->setImageResource(LayoutImageResource::create()); | 276 image->setImageResource(LayoutImageResource::create()); |
277 return image; | 277 return image; |
278 } | 278 } |
279 | 279 |
280 if (usePlaceholderContent()) | 280 if (usePlaceholderContent()) |
281 return new RenderBlockFlow(this); | 281 return new RenderBlockFlow(this); |
282 | 282 |
283 return new RenderEmbeddedObject(this); | 283 return new LayoutEmbeddedObject(this); |
284 } | 284 } |
285 | 285 |
286 void HTMLPlugInElement::finishParsingChildren() | 286 void HTMLPlugInElement::finishParsingChildren() |
287 { | 287 { |
288 HTMLFrameOwnerElement::finishParsingChildren(); | 288 HTMLFrameOwnerElement::finishParsingChildren(); |
289 if (useFallbackContent()) | 289 if (useFallbackContent()) |
290 return; | 290 return; |
291 | 291 |
292 setNeedsWidgetUpdate(true); | 292 setNeedsWidgetUpdate(true); |
293 if (inDocument()) | 293 if (inDocument()) |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 // other event listeners fire. Hopefully, this difference does not matter in | 371 // other event listeners fire. Hopefully, this difference does not matter in |
372 // practice. | 372 // practice. |
373 | 373 |
374 // FIXME: Mouse down and scroll events are passed down to plug-in via custom | 374 // FIXME: Mouse down and scroll events are passed down to plug-in via custom |
375 // code in EventHandler; these code paths should be united. | 375 // code in EventHandler; these code paths should be united. |
376 | 376 |
377 LayoutObject* r = renderer(); | 377 LayoutObject* r = renderer(); |
378 if (!r || !r->isLayoutPart()) | 378 if (!r || !r->isLayoutPart()) |
379 return; | 379 return; |
380 if (r->isEmbeddedObject()) { | 380 if (r->isEmbeddedObject()) { |
381 if (toRenderEmbeddedObject(r)->showsUnavailablePluginIndicator()) | 381 if (toLayoutEmbeddedObject(r)->showsUnavailablePluginIndicator()) |
382 return; | 382 return; |
383 } | 383 } |
384 RefPtrWillBeRawPtr<Widget> widget = toLayoutPart(r)->widget(); | 384 RefPtrWillBeRawPtr<Widget> widget = toLayoutPart(r)->widget(); |
385 if (!widget) | 385 if (!widget) |
386 return; | 386 return; |
387 widget->handleEvent(event); | 387 widget->handleEvent(event); |
388 if (event->defaultHandled()) | 388 if (event->defaultHandled()) |
389 return; | 389 return; |
390 HTMLFrameOwnerElement::defaultEventHandler(event); | 390 HTMLFrameOwnerElement::defaultEventHandler(event); |
391 } | 391 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 return true; | 423 return true; |
424 } | 424 } |
425 | 425 |
426 bool HTMLPlugInElement::rendererIsFocusable() const | 426 bool HTMLPlugInElement::rendererIsFocusable() const |
427 { | 427 { |
428 if (HTMLFrameOwnerElement::supportsFocus() && HTMLFrameOwnerElement::rendere
rIsFocusable()) | 428 if (HTMLFrameOwnerElement::supportsFocus() && HTMLFrameOwnerElement::rendere
rIsFocusable()) |
429 return true; | 429 return true; |
430 | 430 |
431 if (useFallbackContent() || !renderer() || !renderer()->isEmbeddedObject()) | 431 if (useFallbackContent() || !renderer() || !renderer()->isEmbeddedObject()) |
432 return false; | 432 return false; |
433 return !toRenderEmbeddedObject(renderer())->showsUnavailablePluginIndicator(
); | 433 return !toLayoutEmbeddedObject(renderer())->showsUnavailablePluginIndicator(
); |
434 } | 434 } |
435 | 435 |
436 NPObject* HTMLPlugInElement::getNPObject() | 436 NPObject* HTMLPlugInElement::getNPObject() |
437 { | 437 { |
438 ASSERT(document().frame()); | 438 ASSERT(document().frame()); |
439 if (!m_NPObject) | 439 if (!m_NPObject) |
440 m_NPObject = document().frame()->script().createScriptObjectForPluginEle
ment(this); | 440 m_NPObject = document().frame()->script().createScriptObjectForPluginEle
ment(this); |
441 return m_NPObject; | 441 return m_NPObject; |
442 } | 442 } |
443 | 443 |
(...skipping 11 matching lines...) Expand all Loading... |
455 m_serviceType = mimeTypeFromDataURL(m_url); | 455 m_serviceType = mimeTypeFromDataURL(m_url); |
456 | 456 |
457 if (LocalFrame* frame = document().frame()) { | 457 if (LocalFrame* frame = document().frame()) { |
458 KURL completedURL = document().completeURL(m_url); | 458 KURL completedURL = document().completeURL(m_url); |
459 return frame->loader().client()->objectContentType(completedURL, m_servi
ceType, shouldPreferPlugInsForImages()) == ObjectContentImage; | 459 return frame->loader().client()->objectContentType(completedURL, m_servi
ceType, shouldPreferPlugInsForImages()) == ObjectContentImage; |
460 } | 460 } |
461 | 461 |
462 return Image::supportsType(m_serviceType); | 462 return Image::supportsType(m_serviceType); |
463 } | 463 } |
464 | 464 |
465 RenderEmbeddedObject* HTMLPlugInElement::renderEmbeddedObject() const | 465 LayoutEmbeddedObject* HTMLPlugInElement::layoutEmbeddedObject() const |
466 { | 466 { |
467 // HTMLObjectElement and HTMLEmbedElement may return arbitrary renderers | 467 // HTMLObjectElement and HTMLEmbedElement may return arbitrary renderers |
468 // when using fallback content. | 468 // when using fallback content. |
469 if (!renderer() || !renderer()->isEmbeddedObject()) | 469 if (!renderer() || !renderer()->isEmbeddedObject()) |
470 return nullptr; | 470 return nullptr; |
471 return toRenderEmbeddedObject(renderer()); | 471 return toLayoutEmbeddedObject(renderer()); |
472 } | 472 } |
473 | 473 |
474 // We don't use m_url, as it may not be the final URL that the object loads, | 474 // We don't use m_url, as it may not be the final URL that the object loads, |
475 // depending on <param> values. | 475 // depending on <param> values. |
476 bool HTMLPlugInElement::allowedToLoadFrameURL(const String& url) | 476 bool HTMLPlugInElement::allowedToLoadFrameURL(const String& url) |
477 { | 477 { |
478 KURL completeURL = document().completeURL(url); | 478 KURL completeURL = document().completeURL(url); |
479 if (contentFrame() && protocolIsJavaScript(completeURL) | 479 if (contentFrame() && protocolIsJavaScript(completeURL) |
480 && !document().securityOrigin()->canAccess(contentDocument()->securityOr
igin())) | 480 && !document().securityOrigin()->canAccess(contentDocument()->securityOr
igin())) |
481 return false; | 481 return false; |
(...skipping 13 matching lines...) Expand all Loading... |
495 | 495 |
496 bool HTMLPlugInElement::requestObject(const String& url, const String& mimeType,
const Vector<String>& paramNames, const Vector<String>& paramValues) | 496 bool HTMLPlugInElement::requestObject(const String& url, const String& mimeType,
const Vector<String>& paramNames, const Vector<String>& paramValues) |
497 { | 497 { |
498 if (url.isEmpty() && mimeType.isEmpty()) | 498 if (url.isEmpty() && mimeType.isEmpty()) |
499 return false; | 499 return false; |
500 | 500 |
501 if (protocolIsJavaScript(url)) | 501 if (protocolIsJavaScript(url)) |
502 return false; | 502 return false; |
503 | 503 |
504 // FIXME: None of this code should use renderers! | 504 // FIXME: None of this code should use renderers! |
505 RenderEmbeddedObject* renderer = renderEmbeddedObject(); | 505 LayoutEmbeddedObject* renderer = layoutEmbeddedObject(); |
506 ASSERT(renderer); | 506 ASSERT(renderer); |
507 if (!renderer) | 507 if (!renderer) |
508 return false; | 508 return false; |
509 | 509 |
510 KURL completedURL = document().completeURL(url); | 510 KURL completedURL = document().completeURL(url); |
511 if (!pluginIsLoadable(completedURL, mimeType)) | 511 if (!pluginIsLoadable(completedURL, mimeType)) |
512 return false; | 512 return false; |
513 | 513 |
514 bool useFallback; | 514 bool useFallback; |
515 bool requireRenderer = true; | 515 bool requireRenderer = true; |
516 if (shouldUsePlugin(completedURL, mimeType, hasFallbackContent(), useFallbac
k)) | 516 if (shouldUsePlugin(completedURL, mimeType, hasFallbackContent(), useFallbac
k)) |
517 return loadPlugin(completedURL, mimeType, paramNames, paramValues, useFa
llback, requireRenderer); | 517 return loadPlugin(completedURL, mimeType, paramNames, paramValues, useFa
llback, requireRenderer); |
518 | 518 |
519 // If the plug-in element already contains a subframe, | 519 // If the plug-in element already contains a subframe, |
520 // loadOrRedirectSubframe will re-use it. Otherwise, it will create a new | 520 // loadOrRedirectSubframe will re-use it. Otherwise, it will create a new |
521 // frame and set it as the LayoutPart's widget, causing what was previously | 521 // frame and set it as the LayoutPart's widget, causing what was previously |
522 // in the widget to be torn down. | 522 // in the widget to be torn down. |
523 return loadOrRedirectSubframe(completedURL, getNameAttribute(), true, CheckC
ontentSecurityPolicy); | 523 return loadOrRedirectSubframe(completedURL, getNameAttribute(), true, CheckC
ontentSecurityPolicy); |
524 } | 524 } |
525 | 525 |
526 bool HTMLPlugInElement::loadPlugin(const KURL& url, const String& mimeType, cons
t Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallbac
k, bool requireRenderer) | 526 bool HTMLPlugInElement::loadPlugin(const KURL& url, const String& mimeType, cons
t Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallbac
k, bool requireRenderer) |
527 { | 527 { |
528 LocalFrame* frame = document().frame(); | 528 LocalFrame* frame = document().frame(); |
529 | 529 |
530 if (!frame->loader().allowPlugins(AboutToInstantiatePlugin)) | 530 if (!frame->loader().allowPlugins(AboutToInstantiatePlugin)) |
531 return false; | 531 return false; |
532 | 532 |
533 RenderEmbeddedObject* renderer = renderEmbeddedObject(); | 533 LayoutEmbeddedObject* renderer = layoutEmbeddedObject(); |
534 // FIXME: This code should not depend on renderer! | 534 // FIXME: This code should not depend on renderer! |
535 if ((!renderer && requireRenderer) || useFallback) | 535 if ((!renderer && requireRenderer) || useFallback) |
536 return false; | 536 return false; |
537 | 537 |
538 WTF_LOG(Plugins, "%p Plug-in URL: %s", this, m_url.utf8().data()); | 538 WTF_LOG(Plugins, "%p Plug-in URL: %s", this, m_url.utf8().data()); |
539 WTF_LOG(Plugins, " Loaded URL: %s", url.string().utf8().data()); | 539 WTF_LOG(Plugins, " Loaded URL: %s", url.string().utf8().data()); |
540 m_loadedUrl = url; | 540 m_loadedUrl = url; |
541 | 541 |
542 OwnPtrWillBeRawPtr<PluginPlaceholder> placeholder = nullptr; | 542 OwnPtrWillBeRawPtr<PluginPlaceholder> placeholder = nullptr; |
543 RefPtrWillBeRawPtr<Widget> widget = m_persistedPluginWidget; | 543 RefPtrWillBeRawPtr<Widget> widget = m_persistedPluginWidget; |
544 if (!widget) { | 544 if (!widget) { |
545 bool loadManually = document().isPluginDocument() && !document().contain
sPlugins(); | 545 bool loadManually = document().isPluginDocument() && !document().contain
sPlugins(); |
546 placeholder = frame->loader().client()->createPluginPlaceholder(document
(), url, paramNames, paramValues, mimeType, loadManually); | 546 placeholder = frame->loader().client()->createPluginPlaceholder(document
(), url, paramNames, paramValues, mimeType, loadManually); |
547 if (!placeholder) { | 547 if (!placeholder) { |
548 FrameLoaderClient::DetachedPluginPolicy policy = requireRenderer ? F
rameLoaderClient::FailOnDetachedPlugin : FrameLoaderClient::AllowDetachedPlugin; | 548 FrameLoaderClient::DetachedPluginPolicy policy = requireRenderer ? F
rameLoaderClient::FailOnDetachedPlugin : FrameLoaderClient::AllowDetachedPlugin; |
549 widget = frame->loader().client()->createPlugin(this, url, paramName
s, paramValues, mimeType, loadManually, policy); | 549 widget = frame->loader().client()->createPlugin(this, url, paramName
s, paramValues, mimeType, loadManually, policy); |
550 } | 550 } |
551 } | 551 } |
552 | 552 |
553 if (!placeholder && !widget) { | 553 if (!placeholder && !widget) { |
554 if (renderer && !renderer->showsUnavailablePluginIndicator()) | 554 if (renderer && !renderer->showsUnavailablePluginIndicator()) |
555 renderer->setPluginUnavailabilityReason(RenderEmbeddedObject::Plugin
Missing); | 555 renderer->setPluginUnavailabilityReason(LayoutEmbeddedObject::Plugin
Missing); |
556 setPlaceholder(nullptr); | 556 setPlaceholder(nullptr); |
557 return false; | 557 return false; |
558 } | 558 } |
559 | 559 |
560 if (placeholder) { | 560 if (placeholder) { |
561 setPlaceholder(placeholder.release()); | 561 setPlaceholder(placeholder.release()); |
562 return true; | 562 return true; |
563 } | 563 } |
564 | 564 |
565 if (renderer) { | 565 if (renderer) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 if (!document().securityOrigin()->canDisplay(url)) { | 638 if (!document().securityOrigin()->canDisplay(url)) { |
639 FrameLoader::reportLocalLoadFailed(frame, url.string()); | 639 FrameLoader::reportLocalLoadFailed(frame, url.string()); |
640 return false; | 640 return false; |
641 } | 641 } |
642 | 642 |
643 AtomicString declaredMimeType = document().isPluginDocument() && document().
ownerElement() ? | 643 AtomicString declaredMimeType = document().isPluginDocument() && document().
ownerElement() ? |
644 document().ownerElement()->fastGetAttribute(HTMLNames::typeAttr) : | 644 document().ownerElement()->fastGetAttribute(HTMLNames::typeAttr) : |
645 fastGetAttribute(HTMLNames::typeAttr); | 645 fastGetAttribute(HTMLNames::typeAttr); |
646 if (!document().contentSecurityPolicy()->allowObjectFromSource(url) | 646 if (!document().contentSecurityPolicy()->allowObjectFromSource(url) |
647 || !document().contentSecurityPolicy()->allowPluginType(mimeType, declar
edMimeType, url)) { | 647 || !document().contentSecurityPolicy()->allowPluginType(mimeType, declar
edMimeType, url)) { |
648 renderEmbeddedObject()->setPluginUnavailabilityReason(RenderEmbeddedObje
ct::PluginBlockedByContentSecurityPolicy); | 648 layoutEmbeddedObject()->setPluginUnavailabilityReason(LayoutEmbeddedObje
ct::PluginBlockedByContentSecurityPolicy); |
649 return false; | 649 return false; |
650 } | 650 } |
651 | 651 |
652 return !MixedContentChecker::shouldBlockFetch(frame, WebURLRequest::RequestC
ontextObject, WebURLRequest::FrameTypeNone, url); | 652 return !MixedContentChecker::shouldBlockFetch(frame, WebURLRequest::RequestC
ontextObject, WebURLRequest::FrameTypeNone, url); |
653 } | 653 } |
654 | 654 |
655 void HTMLPlugInElement::didAddUserAgentShadowRoot(ShadowRoot&) | 655 void HTMLPlugInElement::didAddUserAgentShadowRoot(ShadowRoot&) |
656 { | 656 { |
657 userAgentShadowRoot()->appendChild(HTMLContentElement::create(document())); | 657 userAgentShadowRoot()->appendChild(HTMLContentElement::create(document())); |
658 } | 658 } |
(...skipping 13 matching lines...) Expand all Loading... |
672 return hasAuthorShadowRoot(); | 672 return hasAuthorShadowRoot(); |
673 } | 673 } |
674 | 674 |
675 void HTMLPlugInElement::lazyReattachIfNeeded() | 675 void HTMLPlugInElement::lazyReattachIfNeeded() |
676 { | 676 { |
677 if (!useFallbackContent() && !usePlaceholderContent() && needsWidgetUpdate()
&& renderer() && !isImageType()) | 677 if (!useFallbackContent() && !usePlaceholderContent() && needsWidgetUpdate()
&& renderer() && !isImageType()) |
678 lazyReattachIfAttached(); | 678 lazyReattachIfAttached(); |
679 } | 679 } |
680 | 680 |
681 } | 681 } |
OLD | NEW |