OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "core/dom/custom/CustomElementDefinition.h" | 5 #include "core/dom/custom/CustomElementDefinition.h" |
6 | 6 |
7 namespace blink { | 7 namespace blink { |
8 | 8 |
9 CustomElementDefinition::CustomElementDefinition( | 9 CustomElementDefinition::CustomElementDefinition( |
10 const CustomElementDescriptor& descriptor) | 10 const CustomElementDescriptor& descriptor) |
11 : m_descriptor(descriptor) | 11 : m_descriptor(descriptor) |
12 { | 12 { |
13 } | 13 } |
14 | 14 |
15 CustomElementDefinition::~CustomElementDefinition() | 15 CustomElementDefinition::~CustomElementDefinition() |
16 { | 16 { |
17 } | 17 } |
18 | 18 |
19 DEFINE_TRACE(CustomElementDefinition) | 19 DEFINE_TRACE(CustomElementDefinition) |
20 { | 20 { |
21 visitor->trace(m_constructionStack); | 21 visitor->trace(m_constructionStack); |
22 } | 22 } |
23 | 23 |
24 // https://html.spec.whatwg.org/multipage/scripting.html#concept-upgrade-an-elem
ent | 24 // https://html.spec.whatwg.org/multipage/scripting.html#concept-upgrade-an-elem
ent |
25 void CustomElementDefinition::upgrade(Element* element) | 25 void CustomElementDefinition::upgrade(Element* element) |
26 { | 26 { |
27 // TODO(dominicc): When the attributeChangedCallback is implemented, | |
28 // enqueue reactions for attributes here. | |
29 // TODO(dominicc): When the connectedCallback is implemented, enqueue | |
30 // reactions here, if applicable. | |
31 | |
32 m_constructionStack.append(element); | 27 m_constructionStack.append(element); |
33 size_t depth = m_constructionStack.size(); | 28 size_t depth = m_constructionStack.size(); |
34 | 29 |
35 bool succeeded = runConstructor(element); | 30 bool succeeded = runConstructor(element); |
36 | 31 |
37 // Pop the construction stack. | 32 // Pop the construction stack. |
38 if (m_constructionStack.last().get()) | 33 if (m_constructionStack.last().get()) |
39 DCHECK_EQ(m_constructionStack.last(), element); | 34 DCHECK_EQ(m_constructionStack.last(), element); |
40 DCHECK_EQ(m_constructionStack.size(), depth); // It's a *stack*. | 35 DCHECK_EQ(m_constructionStack.size(), depth); // It's a *stack*. |
41 m_constructionStack.removeLast(); | 36 m_constructionStack.removeLast(); |
42 | 37 |
43 if (!succeeded) | 38 if (!succeeded) |
44 return; | 39 return; |
45 | 40 |
46 CHECK(element->getCustomElementState() == CustomElementState::Custom); | 41 // TODO(dominicc): Turn this into an assertion when setting |
| 42 // 'custom' moves to the HTMLElement constructor. We will need to |
| 43 // add a bit for MARQUEE to be custom-gets-callbacks-yet-not-custom. |
| 44 element->setCustomElementState(CustomElementState::Custom); |
| 45 |
| 46 // TODO(dominicc): When the attributeChangedCallback is implemented, |
| 47 // enqueue reactions for attributes here. |
| 48 // TODO(dominicc): When the connectedCallback is implemented, enqueue |
| 49 // reactions here, if applicable. |
| 50 } |
| 51 |
| 52 bool CustomElementDefinition::runConstructor(Element*) |
| 53 { |
| 54 return true; |
47 } | 55 } |
48 | 56 |
49 } // namespace blink | 57 } // namespace blink |
OLD | NEW |