Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: third_party/WebKit/Source/core/dom/custom/CustomElementDefinition.cpp

Issue 2023093003: Upgrade in-document custom elements when an element is defined. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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);
29
30 bool succeeded = runConstructor(element);
31
32 // Pop the construction stack.
33 if (m_constructionStack.last().get())
34 DCHECK_EQ(m_constructionStack.last(), element);
35 m_constructionStack.removeLast();
36 DCHECK_EQ(m_constructionStack.size(), depth); // It's a *stack*.
yosin_UTC9 2016/06/02 04:06:38 Better way to catch weird situation is: m_constru
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
52 bool CustomElementDefinition::runConstructor(Element*)
53 {
54 return true;
55 }
56
19 } // namespace blink 57 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698