Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 #include "core/html/shadow/PluginPlaceholderElement.h" | |
| 7 | |
| 8 #include "bindings/core/v8/ExceptionState.h" | |
| 9 #include "core/CSSPropertyNames.h" | |
| 10 #include "core/CSSValueKeywords.h" | |
| 11 #include "wtf/StdLibExtras.h" | |
| 12 #include "wtf/text/AtomicString.h" | |
| 13 | |
| 14 namespace blink { | |
| 15 | |
| 16 PluginPlaceholderElement::PluginPlaceholderElement(Document& document) | |
| 17 : HTMLDivElement(document) | |
| 18 { | |
| 19 } | |
| 20 | |
| 21 PassRefPtrWillBeRawPtr<PluginPlaceholderElement> PluginPlaceholderElement::creat e(Document& document) | |
| 22 { | |
| 23 RefPtrWillBeRawPtr<PluginPlaceholderElement> element = adoptRefWillBeNoop(ne w PluginPlaceholderElement(document)); | |
| 24 | |
| 25 if (element->initializePlaceholderElements()) | |
|
esprehn
2014/08/29 21:13:26
This shouldn't be allowed to return nullptr, creat
jbroman
2014/08/30 13:55:48
The shadow root host is the HTMLPlugInElement (obj
| |
| 26 return element.release(); | |
| 27 | |
| 28 return nullptr; | |
| 29 } | |
| 30 | |
| 31 void PluginPlaceholderElement::trace(Visitor* visitor) | |
| 32 { | |
| 33 visitor->trace(m_messageElement); | |
| 34 HTMLDivElement::trace(visitor); | |
| 35 } | |
| 36 | |
| 37 void PluginPlaceholderElement::setMessage(const String& message) | |
| 38 { | |
| 39 m_messageElement->setInnerHTML(message, ASSERT_NO_EXCEPTION); | |
| 40 } | |
| 41 | |
| 42 bool PluginPlaceholderElement::initializePlaceholderElements() | |
|
esprehn
2014/08/29 21:13:26
Just use didAddUserAgentShadowRoot(ShadowRoot& roo
jbroman
2014/08/30 13:55:48
See above.
| |
| 43 { | |
| 44 // Produces DOM roughly equivalent to the following HTML: | |
| 45 // | |
| 46 // <div id="plugin-placeholder"> | |
| 47 // <div id="plugin-placeholder-content"> | |
| 48 // <div id="plugin-placeholder-message"></div> | |
| 49 // </div> | |
| 50 // </div> | |
| 51 | |
| 52 // FIXME: Move style out of C++ and into CSS. | |
| 53 | |
| 54 TrackExceptionState exceptionState; | |
| 55 | |
| 56 DEFINE_STATIC_LOCAL(AtomicString, id, ("plugin-placeholder")); | |
| 57 setIdAttribute(id); | |
| 58 setInlineStyleProperty(CSSPropertyWidth, 100, CSSPrimitiveValue::CSS_PERCENT AGE); | |
| 59 setInlineStyleProperty(CSSPropertyHeight, 100, CSSPrimitiveValue::CSS_PERCEN TAGE); | |
| 60 setInlineStyleProperty(CSSPropertyOverflow, CSSValueHidden); | |
| 61 setInlineStyleProperty(CSSPropertyDisplay, CSSValueFlex); | |
| 62 setInlineStyleProperty(CSSPropertyAlignItems, CSSValueCenter); | |
| 63 setInlineStyleProperty(CSSPropertyBackgroundColor, CSSValueGray); | |
| 64 setInlineStyleProperty(CSSPropertyFont, "12px -webkit-control"); | |
| 65 | |
| 66 DEFINE_STATIC_LOCAL(AtomicString, contentId, ("plugin-placeholder-content")) ; | |
| 67 RefPtrWillBeRawPtr<HTMLDivElement> contentElement = HTMLDivElement::create(d ocument()); | |
| 68 contentElement->setIdAttribute(contentId); | |
| 69 contentElement->setInlineStyleProperty(CSSPropertyTextAlign, CSSValueCenter) ; | |
| 70 contentElement->setInlineStyleProperty(CSSPropertyMargin, CSSValueAuto); | |
| 71 | |
| 72 DEFINE_STATIC_LOCAL(AtomicString, messageId, ("plugin-placeholder-message")) ; | |
| 73 RefPtrWillBeRawPtr<HTMLDivElement> messageElement = HTMLDivElement::create(d ocument()); | |
| 74 messageElement->setIdAttribute(messageId); | |
| 75 m_messageElement = messageElement.get(); | |
| 76 contentElement->appendChild(messageElement.release(), exceptionState); | |
| 77 if (exceptionState.hadException()) | |
|
esprehn
2014/08/29 21:13:26
ASSERT_NO_EXCEPTION
jbroman
2014/08/30 13:55:48
Okay. I assumed that tracking the exception and po
| |
| 78 return false; | |
| 79 | |
| 80 appendChild(contentElement.release(), exceptionState); | |
|
esprehn
2014/08/29 21:13:26
ASSERT_NO_EXCEPTION, don't check it. Internal code
jbroman
2014/08/30 13:55:48
Ditto.
| |
| 81 if (exceptionState.hadException()) | |
| 82 return false; | |
| 83 | |
| 84 return true; | |
|
esprehn
2014/08/29 21:13:26
no return value, just use the Shadow DOM framework
jbroman
2014/08/30 13:55:48
I understand the "no return value", though I'm not
| |
| 85 } | |
| 86 | |
| 87 } // namespace blink | |
| OLD | NEW |