Chromium Code Reviews| Index: Source/core/testing/Internals.cpp |
| diff --git a/Source/core/testing/Internals.cpp b/Source/core/testing/Internals.cpp |
| index 1535c3884deff6a367f1b7635b48e694876ac89c..5b49a67265ed678645dc0cb295193a003b53aeff 100644 |
| --- a/Source/core/testing/Internals.cpp |
| +++ b/Source/core/testing/Internals.cpp |
| @@ -83,6 +83,7 @@ |
| #include "core/html/HTMLTextAreaElement.h" |
| #include "core/html/canvas/CanvasRenderingContext2D.h" |
| #include "core/html/forms/FormController.h" |
| +#include "core/html/shadow/PluginPlaceholderElement.h" |
| #include "core/html/shadow/ShadowElementNames.h" |
| #include "core/html/shadow/TextControlInnerElements.h" |
| #include "core/inspector/ConsoleMessageStorage.h" |
| @@ -2219,15 +2220,36 @@ void Internals::hideAllTransitionElements() |
| void Internals::forcePluginPlaceholder(HTMLElement* element, const String& htmlSource, ExceptionState& exceptionState) |
| { |
| - if (!element) { |
| - exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "HTMLElement")); |
| + if (!element->isPluginElement()) { |
| + exceptionState.throwDOMException(InvalidNodeTypeError, "The element provided is not a plugin."); |
| return; |
| } |
| + |
| + element->ensureUserAgentShadowRoot().setInnerHTML(htmlSource, exceptionState); |
| + if (exceptionState.hadException()) |
| + return; |
| + |
| + toHTMLPlugInElement(element)->setUsePlaceholderContent(true); |
| +} |
| + |
| +void Internals::forcePluginPlaceholder(HTMLElement* element, const Dictionary& options, ExceptionState& exceptionState) |
|
esprehn
2014/08/29 21:13:26
HTMLObjectElement*
jbroman
2014/08/30 13:55:48
I'd expect this to work on HTMLEmbedElement and HT
|
| +{ |
| if (!element->isPluginElement()) { |
| exceptionState.throwDOMException(InvalidNodeTypeError, "The element provided is not a plugin."); |
| return; |
| } |
| - element->ensureUserAgentShadowRoot().setInnerHTML(htmlSource, exceptionState); |
| + |
| + RefPtrWillBeRawPtr<PluginPlaceholderElement> placeholder = PluginPlaceholderElement::create(element->document()); |
| + String stringValue; |
| + if (DictionaryHelper::get(options, "message", stringValue)) |
| + placeholder->setMessage(stringValue); |
| + |
| + ShadowRoot& shadowRoot = element->ensureUserAgentShadowRoot(); |
| + shadowRoot.removeChildren(); |
| + shadowRoot.appendChild(placeholder.release(), exceptionState); |
| + if (exceptionState.hadException()) |
| + return; |
| + |
| toHTMLPlugInElement(element)->setUsePlaceholderContent(true); |
| } |