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) | |
20 { | |
21 visitor->trace(m_constructionStack); | |
22 } | |
23 | |
24 // https://html.spec.whatwg.org/multipage/scripting.html#concept-upgrade-an-elem ent | |
25 void CustomElementDefinition::upgrade(Element* element) | |
26 { | |
27 size_t depth = m_constructionStack.size(); | |
28 m_constructionStack.append(element); | |
yosin_UTC9
2016/06/01 06:15:44
We should have DCHECK(!m_constructionStack.isEmpty
dominicc (has gone to gerrit)
2016/06/01 23:30:56
Why? How would anything get upgraded if there's an
yosin_UTC9
2016/06/02 02:02:18
Sorry, my comment is wrong.
| |
29 | |
30 bool succeeded = runConstructor(element); | |
31 | |
32 // Pop the construction stack. | |
33 DCHECK(m_constructionStack.last() == element | |
yosin_UTC9
2016/06/01 06:15:44
Better to use DCHECK_EQ
if (!m_consturctionStack.l
dominicc (has gone to gerrit)
2016/06/01 23:30:57
I don't think that's applicable because of the tes
yosin_UTC9
2016/06/02 02:02:18
Oh, typo
if (m_consturctionStack.last())
DCHEC
| |
34 || !m_constructionStack.last()); | |
35 m_constructionStack.removeLast(); | |
36 DCHECK(m_constructionStack.size() == depth); // It's a *stack*. | |
yosin_UTC9
2016/06/01 06:15:44
nit: DCHECK_EQ
| |
37 | |
38 if (!succeeded) | |
39 return; | |
40 | |
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 | |
19 } // namespace blink | 52 } // namespace blink |
OLD | NEW |