OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef DictionaryPluginPlaceholder_h | 5 #ifndef DictionaryPluginPlaceholder_h |
6 #define DictionaryPluginPlaceholder_h | 6 #define DictionaryPluginPlaceholder_h |
7 | 7 |
8 #include "bindings/core/v8/Dictionary.h" | |
9 #include "core/html/shadow/PluginPlaceholderElement.h" | 8 #include "core/html/shadow/PluginPlaceholderElement.h" |
10 #include "core/plugins/PluginPlaceholder.h" | 9 #include "core/plugins/PluginPlaceholder.h" |
| 10 #include "core/testing/PluginPlaceholderOptions.h" |
11 #include "wtf/text/WTFString.h" | 11 #include "wtf/text/WTFString.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 // Manipulates a plugin placeholder element based on a fixed dictionary given. | 15 // Manipulates a plugin placeholder element based on a fixed dictionary given. |
16 // Used for layout tests that examine the formatting of structured placeholders. | 16 // Used for layout tests that examine the formatting of structured placeholders. |
17 class DictionaryPluginPlaceholder : public NoBaseWillBeGarbageCollected<Dictiona
ryPluginPlaceholder>, public PluginPlaceholder { | 17 class DictionaryPluginPlaceholder : public NoBaseWillBeGarbageCollected<Dictiona
ryPluginPlaceholder>, public PluginPlaceholder { |
18 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(DictionaryPluginPlaceholder); | 18 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(DictionaryPluginPlaceholder); |
19 public: | 19 public: |
20 static PassOwnPtrWillBeRawPtr<DictionaryPluginPlaceholder> create(Document&
document, const Dictionary& options) | 20 static PassOwnPtrWillBeRawPtr<DictionaryPluginPlaceholder> create(Document&
document, const PluginPlaceholderOptions& options) |
21 { | 21 { |
22 RefPtrWillBeRawPtr<PluginPlaceholderElement> placeholder = PluginPlaceho
lderElement::create(document); | 22 RefPtrWillBeRawPtr<PluginPlaceholderElement> placeholder = PluginPlaceho
lderElement::create(document); |
23 String stringValue; | 23 if (options.hasMessage()) |
24 if (DictionaryHelper::get(options, "message", stringValue)) | 24 placeholder->setMessage(options.message()); |
25 placeholder->setMessage(stringValue); | |
26 | 25 |
27 bool booleanValue; | 26 if (options.hasCloseable()) |
28 if (DictionaryHelper::get(options, "closeable", booleanValue)) | 27 placeholder->setIsCloseable(options.closeable()); |
29 placeholder->setIsCloseable(booleanValue); | |
30 | 28 |
31 return adoptPtrWillBeNoop(new DictionaryPluginPlaceholder(placeholder.re
lease())); | 29 return adoptPtrWillBeNoop(new DictionaryPluginPlaceholder(placeholder.re
lease())); |
32 } | 30 } |
33 | 31 |
34 #if !ENABLE(OILPAN) | 32 #if !ENABLE(OILPAN) |
35 virtual ~DictionaryPluginPlaceholder() override { } | 33 virtual ~DictionaryPluginPlaceholder() override { } |
36 #endif | 34 #endif |
37 virtual void trace(Visitor* visitor) { visitor->trace(m_pluginPlaceholderEle
ment); } | 35 virtual void trace(Visitor* visitor) { visitor->trace(m_pluginPlaceholderEle
ment); } |
38 | 36 |
39 virtual void loadIntoContainer(ContainerNode& container) override | 37 virtual void loadIntoContainer(ContainerNode& container) override |
40 { | 38 { |
41 container.removeChildren(); | 39 container.removeChildren(); |
42 container.appendChild(m_pluginPlaceholderElement, ASSERT_NO_EXCEPTION); | 40 container.appendChild(m_pluginPlaceholderElement, ASSERT_NO_EXCEPTION); |
43 } | 41 } |
44 | 42 |
45 private: | 43 private: |
46 DictionaryPluginPlaceholder(PassRefPtrWillBeRawPtr<PluginPlaceholderElement>
element) : m_pluginPlaceholderElement(element) { } | 44 DictionaryPluginPlaceholder(PassRefPtrWillBeRawPtr<PluginPlaceholderElement>
element) : m_pluginPlaceholderElement(element) { } |
47 | 45 |
48 RefPtrWillBeMember<PluginPlaceholderElement> m_pluginPlaceholderElement; | 46 RefPtrWillBeMember<PluginPlaceholderElement> m_pluginPlaceholderElement; |
49 }; | 47 }; |
50 | 48 |
51 } // namespace blink | 49 } // namespace blink |
52 | 50 |
53 #endif // DictionaryPluginPlaceholder_h | 51 #endif // DictionaryPluginPlaceholder_h |
OLD | NEW |