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/CustomElement.h" | 5 #include "core/dom/custom/CustomElement.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/dom/Element.h" | 8 #include "core/dom/Element.h" |
9 #include "core/dom/QualifiedName.h" | 9 #include "core/dom/QualifiedName.h" |
10 #include "core/dom/custom/V0CustomElement.h" | 10 #include "core/dom/custom/V0CustomElement.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 return RuntimeEnabledFeatures::customElementsV1Enabled() | 56 return RuntimeEnabledFeatures::customElementsV1Enabled() |
57 && document.frame() && isValidName(localName); | 57 && document.frame() && isValidName(localName); |
58 } | 58 } |
59 | 59 |
60 bool CustomElement::shouldCreateCustomElement(Document& document, const Qualifie
dName& tagName) | 60 bool CustomElement::shouldCreateCustomElement(Document& document, const Qualifie
dName& tagName) |
61 { | 61 { |
62 return shouldCreateCustomElement(document, tagName.localName()) | 62 return shouldCreateCustomElement(document, tagName.localName()) |
63 && tagName.namespaceURI() == HTMLNames::xhtmlNamespaceURI; | 63 && tagName.namespaceURI() == HTMLNames::xhtmlNamespaceURI; |
64 } | 64 } |
65 | 65 |
66 HTMLElement* CustomElement::createCustomElement(Document& document, const Atomic
String& localName) | 66 HTMLElement* CustomElement::createCustomElement(Document& document, const Atomic
String& localName, CreateElementFlags flags) |
67 { | 67 { |
68 return createCustomElement(document, | 68 return createCustomElement(document, |
69 QualifiedName(nullAtom, document.convertLocalName(localName), HTMLNames:
:xhtmlNamespaceURI)); | 69 QualifiedName(nullAtom, document.convertLocalName(localName), HTMLNames:
:xhtmlNamespaceURI), |
| 70 flags); |
70 } | 71 } |
71 | 72 |
72 HTMLElement* CustomElement::createCustomElement(Document& document, const Qualif
iedName& tagName) | 73 HTMLElement* CustomElement::createCustomElement(Document& document, const Qualif
iedName& tagName, CreateElementFlags flags) |
73 { | 74 { |
74 DCHECK(shouldCreateCustomElement(document, tagName)); | 75 DCHECK(shouldCreateCustomElement(document, tagName)); |
75 | 76 |
76 // TODO(kojii): This does not lookup already defined custom elements yet. | 77 // TODO(kojii): This does not lookup already defined custom elements yet. |
77 | 78 |
78 HTMLElement* element; | 79 HTMLElement* element; |
79 if (V0CustomElement::isValidName(tagName.localName()) && document.registrati
onContext()) { | 80 if (V0CustomElement::isValidName(tagName.localName()) && document.registrati
onContext()) { |
80 Element* e = document.registrationContext()->createCustomTagElement(docu
ment, tagName); | 81 Element* e = document.registrationContext()->createCustomTagElement(docu
ment, tagName); |
81 SECURITY_DCHECK(e->isHTMLElement()); | 82 SECURITY_DCHECK(e->isHTMLElement()); |
82 element = toHTMLElement(e); | 83 element = toHTMLElement(e); |
83 } else { | 84 } else { |
84 element = HTMLElement::create(tagName, document); | 85 element = HTMLElement::create(tagName, document); |
85 } | 86 } |
86 | 87 |
87 element->setCustomElementState(CustomElementState::Undefined); | 88 element->setCustomElementState(CustomElementState::Undefined); |
88 | 89 |
89 return element; | 90 return element; |
90 } | 91 } |
91 | 92 |
92 } // namespace blink | 93 } // namespace blink |
OLD | NEW |