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

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

Issue 2002903002: Hook createElement for Custom Elements V1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/custom/CustomElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/CustomElement.h" 5 #include "core/dom/custom/CustomElement.h"
6 6
7 #include "core/dom/Document.h"
8 #include "core/dom/Element.h"
9 #include "core/dom/QualifiedName.h"
10 #include "core/dom/custom/V0CustomElement.h"
11 #include "core/dom/custom/V0CustomElementRegistrationContext.h"
12 #include "core/html/HTMLElement.h"
7 #include "platform/text/Character.h" 13 #include "platform/text/Character.h"
8 #include "wtf/text/AtomicStringHash.h" 14 #include "wtf/text/AtomicStringHash.h"
9 15
10 namespace blink { 16 namespace blink {
11 17
12 bool CustomElement::isValidName(const AtomicString& name) 18 bool CustomElement::isValidName(const AtomicString& name)
13 { 19 {
14 if (!name.length() || name[0] < 'a' || name[0] > 'z') 20 if (!name.length() || name[0] < 'a' || name[0] > 'z')
15 return false; 21 return false;
16 22
(...skipping 21 matching lines...) Expand all
38 hyphenContainingElementNames.add("font-face-src"); 44 hyphenContainingElementNames.add("font-face-src");
39 hyphenContainingElementNames.add("font-face-uri"); 45 hyphenContainingElementNames.add("font-face-uri");
40 hyphenContainingElementNames.add("font-face-format"); 46 hyphenContainingElementNames.add("font-face-format");
41 hyphenContainingElementNames.add("font-face-name"); 47 hyphenContainingElementNames.add("font-face-name");
42 hyphenContainingElementNames.add("missing-glyph"); 48 hyphenContainingElementNames.add("missing-glyph");
43 } 49 }
44 50
45 return !hyphenContainingElementNames.contains(name); 51 return !hyphenContainingElementNames.contains(name);
46 } 52 }
47 53
54 bool CustomElement::shouldCreateCustomElement(Document& document, const AtomicSt ring& localName)
55 {
56 // 7.3 of https://dom.spec.whatwg.org/#concept-create-element
57 return document.frame()
kojii 2016/05/23 09:40:20 Is this correct condition when the spec says "has
58 && isValidName(localName);
59 }
60
61 bool CustomElement::shouldCreateCustomElement(Document& document, const Qualifie dName& tagName)
62 {
63 return shouldCreateCustomElement(document, tagName.localName())
64 && tagName.namespaceURI() == HTMLNames::xhtmlNamespaceURI;
65 }
66
67 HTMLElement* CustomElement::createCustomElement(Document& document, const Atomic String& localName)
68 {
69 return createCustomElement(document,
70 QualifiedName(nullAtom, document.convertLocalName(localName), HTMLNames: :xhtmlNamespaceURI));
71 }
72
73 HTMLElement* CustomElement::createCustomElement(Document& document, const Qualif iedName& tagName)
74 {
75 DCHECK(shouldCreateCustomElement(document, tagName));
76
77 // TODO(kojii): This does not lookup already defined custom elements yet.
78
79 HTMLElement* element;
80 if (V0CustomElement::isValidName(tagName.localName()) && document.registrati onContext()) {
81 Element* e = document.registrationContext()->createCustomTagElement(docu ment, tagName);
82 SECURITY_DCHECK(e->isHTMLElement());
83 element = toHTMLElement(e);
84 } else {
85 element = HTMLElement::create(tagName, document);
86 }
87
88 element->setCustomElementState(CustomElementState::Undefined);
89
90 return element;
91 }
92
48 } // namespace blink 93 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/custom/CustomElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698