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): Look up already defined custom elements when custom element | 77 // TODO(kojii): Look up already defined custom elements when custom element |
77 // queues and upgrade are implemented. | 78 // queues and upgrade are implemented. |
78 | 79 |
79 HTMLElement* element; | 80 HTMLElement* element; |
80 if (V0CustomElement::isValidName(tagName.localName()) && document.registrati
onContext()) { | 81 if (V0CustomElement::isValidName(tagName.localName()) && document.registrati
onContext()) { |
81 Element* v0element = document.registrationContext()->createCustomTagElem
ent(document, tagName); | 82 Element* v0element = document.registrationContext()->createCustomTagElem
ent(document, tagName); |
82 SECURITY_DCHECK(v0element->isHTMLElement()); | 83 SECURITY_DCHECK(v0element->isHTMLElement()); |
83 element = toHTMLElement(v0element); | 84 element = toHTMLElement(v0element); |
84 } else { | 85 } else { |
85 element = HTMLElement::create(tagName, document); | 86 element = HTMLElement::create(tagName, document); |
86 } | 87 } |
87 | 88 |
88 element->setCustomElementState(CustomElementState::Undefined); | 89 element->setCustomElementState(CustomElementState::Undefined); |
89 | 90 |
90 return element; | 91 return element; |
91 } | 92 } |
92 | 93 |
93 } // namespace blink | 94 } // namespace blink |
OLD | NEW |