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 |
27 m_constructionStack.append(element); | 32 m_constructionStack.append(element); |
28 size_t depth = m_constructionStack.size(); | 33 size_t depth = m_constructionStack.size(); |
29 | 34 |
30 bool succeeded = runConstructor(element); | 35 bool succeeded = runConstructor(element); |
31 | 36 |
32 // Pop the construction stack. | 37 // Pop the construction stack. |
33 if (m_constructionStack.last().get()) | 38 if (m_constructionStack.last().get()) |
34 DCHECK_EQ(m_constructionStack.last(), element); | 39 DCHECK_EQ(m_constructionStack.last(), element); |
35 DCHECK_EQ(m_constructionStack.size(), depth); // It's a *stack*. | 40 DCHECK_EQ(m_constructionStack.size(), depth); // It's a *stack*. |
36 m_constructionStack.removeLast(); | 41 m_constructionStack.removeLast(); |
37 | 42 |
38 if (!succeeded) | 43 if (!succeeded) |
39 return; | 44 return; |
40 | 45 |
41 // TODO(dominicc): Turn this into an assertion when setting | 46 CHECK(element->getCustomElementState() == CustomElementState::Custom); |
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; | |
55 } | 47 } |
56 | 48 |
57 } // namespace blink | 49 } // namespace blink |
OLD | NEW |