Chromium Code Reviews| Index: third_party/WebKit/Source/core/dom/custom/CustomElement.cpp |
| diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp b/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp |
| index fb55576c5c0db3774ea8c68b6b824ebb26f2300c..ab5eab4d3571b991ce58bbae0ab341dcff19bcf7 100644 |
| --- a/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp |
| +++ b/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp |
| @@ -4,6 +4,12 @@ |
| #include "core/dom/custom/CustomElement.h" |
| +#include "core/dom/Document.h" |
| +#include "core/dom/Element.h" |
| +#include "core/dom/QualifiedName.h" |
| +#include "core/dom/custom/V0CustomElement.h" |
| +#include "core/dom/custom/V0CustomElementRegistrationContext.h" |
| +#include "core/html/HTMLElement.h" |
| #include "platform/text/Character.h" |
| #include "wtf/text/AtomicStringHash.h" |
| @@ -45,4 +51,42 @@ bool CustomElement::isValidName(const AtomicString& name) |
| return !hyphenContainingElementNames.contains(name); |
| } |
| +bool CustomElement::shouldCreateCustomElement(Document& document, const AtomicString& localName) |
| +{ |
| + return RuntimeEnabledFeatures::customElementsV1Enabled() |
| + && document.frame() && isValidName(localName); |
| +} |
| + |
| +bool CustomElement::shouldCreateCustomElement(Document& document, const QualifiedName& tagName) |
| +{ |
| + return shouldCreateCustomElement(document, tagName.localName()) |
| + && tagName.namespaceURI() == HTMLNames::xhtmlNamespaceURI; |
| +} |
| + |
| +HTMLElement* CustomElement::createCustomElement(Document& document, const AtomicString& localName) |
| +{ |
| + return createCustomElement(document, |
| + QualifiedName(nullAtom, document.convertLocalName(localName), HTMLNames::xhtmlNamespaceURI)); |
| +} |
| + |
| +HTMLElement* CustomElement::createCustomElement(Document& document, const QualifiedName& tagName) |
| +{ |
| + DCHECK(shouldCreateCustomElement(document, tagName)); |
| + |
| + // TODO(kojii): This does not lookup already defined custom elements yet. |
|
dominicc (has gone to gerrit)
2016/05/25 05:25:52
Could you make this TODO(who) what/when so it is e
kojii
2016/05/25 05:58:24
Done.
|
| + |
| + HTMLElement* element; |
| + if (V0CustomElement::isValidName(tagName.localName()) && document.registrationContext()) { |
| + Element* e = document.registrationContext()->createCustomTagElement(document, tagName); |
|
yosin_UTC9
2016/05/25 01:16:20
nit: Could you avoid to use one letter variable na
kojii
2016/05/25 02:44:53
Will do in the next patch.
kojii
2016/05/25 05:58:24
Done.
|
| + SECURITY_DCHECK(e->isHTMLElement()); |
| + element = toHTMLElement(e); |
| + } else { |
| + element = HTMLElement::create(tagName, document); |
| + } |
| + |
| + element->setCustomElementState(CustomElementState::Undefined); |
|
yosin_UTC9
2016/05/25 01:16:20
Can we set customer element state in HTML construc
kojii
2016/05/25 02:44:53
Shouldn't the default be "uncustomized"? That's th
yosin_UTC9
2016/05/25 04:18:15
I summarize initial state of "customer element sta
dominicc (has gone to gerrit)
2016/05/25 05:25:52
I guess "is" happens in parserSetAttributes?
kojii
2016/05/25 05:58:24
Yeah, for parser, I think we'll need to split crea
|
| + |
| + return element; |
| +} |
| + |
| } // namespace blink |