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

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

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: Fix ASAN failure in test helper. 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 #ifndef CustomElement_h 5 #ifndef CustomElement_h
6 #define CustomElement_h 6 #define CustomElement_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/dom/Document.h" 9 #include "core/HTMLNames.h"
10 #include "core/dom/Element.h"
10 #include "wtf/Allocator.h" 11 #include "wtf/Allocator.h"
11 #include "wtf/text/AtomicString.h" 12 #include "wtf/text/AtomicString.h"
12 13
13 namespace blink { 14 namespace blink {
14 15
15 class Document; 16 class Document;
16 class HTMLElement; 17 class HTMLElement;
17 class QualifiedName; 18 class QualifiedName;
19 class CustomElementRegistry;
18 20
19 class CORE_EXPORT CustomElement { 21 class CORE_EXPORT CustomElement {
20 STATIC_ONLY(CustomElement); 22 STATIC_ONLY(CustomElement);
21 public: 23 public:
24 // Retrieves the CustomElementsRegistry for Element, if any. This
25 // may be a different object for a given element over its lifetime
26 // as it moves between documents.
27 static CustomElementsRegistry* registry(const Element&);
28
29 // Returns true if element could possibly match a custom element
30 // descriptor *now*. See CustomElementDescriptor::matches for the
31 // meaning of "match". Custom element processing which depends on
32 // matching a descriptor, such as upgrade, can be skipped for
33 // elements that fail this test.
34 //
35 // Although this result is currently constant for a given element,
36 // when customized built-in elements are implemented the result
37 // will depend on the value of the 'is' attribute. In addition,
38 // these elements may stop matching descriptors after being
39 // upgraded, so use Node::getCustomElementState to detect
40 // customized elements.
41 static bool descriptorMayMatch(const Element& element)
42 {
43 // TODO(dominicc): Broaden this check when customized built-in
44 // elements are implemented.
45 return isValidName(element.localName())
46 && element.namespaceURI() == HTMLNames::xhtmlNamespaceURI;
47 }
48
22 static bool isValidName(const AtomicString& name); 49 static bool isValidName(const AtomicString& name);
23 50
24 static bool shouldCreateCustomElement(Document&, const AtomicString& localNa me); 51 static bool shouldCreateCustomElement(Document&, const AtomicString& localNa me);
25 static bool shouldCreateCustomElement(Document&, const QualifiedName&); 52 static bool shouldCreateCustomElement(Document&, const QualifiedName&);
26 53
27 static HTMLElement* createCustomElement(Document&, const AtomicString& local Name, CreateElementFlags); 54 static HTMLElement* createCustomElement(Document&, const AtomicString& local Name, CreateElementFlags);
28 static HTMLElement* createCustomElement(Document&, const QualifiedName&, Cre ateElementFlags); 55 static HTMLElement* createCustomElement(Document&, const QualifiedName&, Cre ateElementFlags);
29 }; 56 };
30 57
31 } // namespace blink 58 } // namespace blink
32 59
33 #endif // CustomElement_h 60 #endif // CustomElement_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698