Chromium Code Reviews| 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 #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/HTMLNames.h" | 9 #include "core/HTMLNames.h" |
| 10 #include "core/dom/Element.h" | 10 #include "core/dom/Element.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 | 22 |
| 23 class CORE_EXPORT CustomElement { | 23 class CORE_EXPORT CustomElement { |
| 24 STATIC_ONLY(CustomElement); | 24 STATIC_ONLY(CustomElement); |
| 25 public: | 25 public: |
| 26 // Retrieves the CustomElementsRegistry for Element, if any. This | 26 // Retrieves the CustomElementsRegistry for Element, if any. This |
| 27 // may be a different object for a given element over its lifetime | 27 // may be a different object for a given element over its lifetime |
| 28 // as it moves between documents. | 28 // as it moves between documents. |
| 29 static CustomElementsRegistry* registry(const Element&); | 29 static CustomElementsRegistry* registry(const Element&); |
| 30 static CustomElementsRegistry* registry(const Document&); | 30 static CustomElementsRegistry* registry(const Document&); |
| 31 | 31 |
| 32 static CustomElementDefinition* definitionForName(const Document&, const Ato micString& name); | |
| 33 | |
| 32 // Returns true if element could possibly match a custom element | 34 // Returns true if element could possibly match a custom element |
| 33 // descriptor *now*. See CustomElementDescriptor::matches for the | 35 // descriptor *now*. See CustomElementDescriptor::matches for the |
| 34 // meaning of "match". Custom element processing which depends on | 36 // meaning of "match". Custom element processing which depends on |
| 35 // matching a descriptor, such as upgrade, can be skipped for | 37 // matching a descriptor, such as upgrade, can be skipped for |
| 36 // elements that fail this test. | 38 // elements that fail this test. |
| 37 // | 39 // |
| 38 // Although this result is currently constant for a given element, | 40 // Although this result is currently constant for a given element, |
| 39 // when customized built-in elements are implemented the result | 41 // when customized built-in elements are implemented the result |
| 40 // will depend on the value of the 'is' attribute. In addition, | 42 // will depend on the value of the 'is' attribute. In addition, |
| 41 // these elements may stop matching descriptors after being | 43 // these elements may stop matching descriptors after being |
| 42 // upgraded, so use Node::getCustomElementState to detect | 44 // upgraded, so use Node::getCustomElementState to detect |
| 43 // customized elements. | 45 // customized elements. |
| 44 static bool descriptorMayMatch(const Element& element) | 46 static bool descriptorMayMatch(const Element& element) |
| 45 { | 47 { |
| 46 // TODO(dominicc): Broaden this check when customized built-in | 48 // TODO(dominicc): Broaden this check when customized built-in |
| 47 // elements are implemented. | 49 // elements are implemented. |
| 48 return isValidName(element.localName()) | 50 return isValidName(element.localName()) |
| 49 && element.namespaceURI() == HTMLNames::xhtmlNamespaceURI; | 51 && element.namespaceURI() == HTMLNames::xhtmlNamespaceURI; |
| 50 } | 52 } |
| 51 | 53 |
| 52 static bool isValidName(const AtomicString& name); | 54 static bool isValidName(const AtomicString& name); |
| 53 | 55 |
| 54 static bool shouldCreateCustomElement(Document&, const AtomicString& localNa me); | 56 static bool shouldCreateCustomElement(Document&, const AtomicString& localNa me); |
| 55 static bool shouldCreateCustomElement(Document&, const QualifiedName&); | 57 static bool shouldCreateCustomElement(Document&, const QualifiedName&); |
| 56 | 58 |
| 57 static HTMLElement* createCustomElement(Document&, const AtomicString& local Name, CreateElementFlags); | 59 static HTMLElement* createCustomElementSync(Document&, const AtomicString& l ocalName, ExceptionState&); |
| 58 static HTMLElement* createCustomElement(Document&, const QualifiedName&, Cre ateElementFlags); | 60 static HTMLElement* createCustomElementSync(Document&, const QualifiedName&, ExceptionState&); |
| 61 static HTMLElement* createCustomElementSync(Document&, const QualifiedName& localName); | |
|
dominicc (has gone to gerrit)
2016/06/13 07:37:24
Be consistent about whether you are naming the loc
kojii
2016/06/13 13:44:31
Done.
| |
| 62 static HTMLElement* createCustomElementAsync(Document&, const QualifiedName& ); | |
| 59 | 63 |
| 60 static void enqueueUpgradeReaction(Element*, CustomElementDefinition*); | 64 static void enqueueUpgradeReaction(Element*, CustomElementDefinition*); |
| 61 | 65 |
| 62 private: | 66 private: |
| 63 static HTMLElement* createCustomElementAsync(Document&, CustomElementDefinit ion&, const QualifiedName&); | 67 static HTMLElement* createUndefinedElement(Document&, const QualifiedName&); |
| 64 }; | 68 }; |
| 65 | 69 |
| 66 } // namespace blink | 70 } // namespace blink |
| 67 | 71 |
| 68 #endif // CustomElement_h | 72 #endif // CustomElement_h |
| OLD | NEW |