OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef CustomElementDefinition_h | 31 #ifndef CustomElementDefinition_h |
32 #define CustomElementDefinition_h | 32 #define CustomElementDefinition_h |
33 | 33 |
34 #include "bindings/v8/ScriptValue.h" | 34 #include "bindings/v8/ScriptValue.h" |
35 #include "core/dom/QualifiedName.h" | 35 #include "core/dom/QualifiedName.h" |
36 #include <wtf/Forward.h> | 36 #include "wtf/Forward.h" |
37 #include <wtf/PassRefPtr.h> | 37 #include "wtf/PassRefPtr.h" |
38 #include <wtf/RefCounted.h> | 38 #include "wtf/RefCounted.h" |
39 | 39 |
40 namespace WebCore { | 40 namespace WebCore { |
41 | 41 |
42 class ScriptState; | 42 class ScriptState; |
43 | 43 |
44 class CustomElementDefinition : public RefCounted<CustomElementDefinition> { | 44 class CustomElementDefinition : public RefCounted<CustomElementDefinition> { |
45 public: | 45 public: |
46 static PassRefPtr<CustomElementDefinition> create(ScriptState*, const Atomic
String& type, const AtomicString& name, const AtomicString& namespaceURI, const
ScriptValue& prototype); | 46 static PassRefPtr<CustomElementDefinition> create(ScriptState*, const Atomic
String& type, const AtomicString& name, const AtomicString& namespaceURI, const
ScriptValue& prototype); |
47 | 47 |
48 virtual ~CustomElementDefinition() {} | 48 virtual ~CustomElementDefinition() {} |
49 | 49 |
| 50 enum CustomElementKind { |
| 51 CustomTag, |
| 52 TypeExtension |
| 53 }; |
| 54 |
50 // This specifies whether the custom element is in the HTML or SVG | 55 // This specifies whether the custom element is in the HTML or SVG |
51 // namespace. | 56 // namespace. |
52 const AtomicString& namespaceURI() const { return m_tag.namespaceURI(); } | 57 const AtomicString& namespaceURI() const { return m_tag.namespaceURI(); } |
53 | 58 |
54 // This uniquely identifies the Custom Element. For custom tags, this | 59 // This uniquely identifies the Custom Element. For custom tags, this |
55 // is the tag name and the same as "name". For type extensions, this | 60 // is the tag name and the same as "name". For type extensions, this |
56 // is the value of the "is" attribute. | 61 // is the value of the "is" attribute. |
57 const AtomicString& type() const { return m_type; } | 62 const AtomicString& type() const { return m_type; } |
58 | 63 |
59 // This is the tag name of the Custom Element. | 64 // This is the tag name of the Custom Element. |
60 const AtomicString& name() const { return m_tag.localName(); } | 65 const AtomicString& name() const { return m_tag.localName(); } |
61 | 66 |
62 // This is a convenience property derived from "namespaceURI" and | 67 // This is a convenience property derived from "namespaceURI" and |
63 // "name". Custom Elements of this kind will have this tag | 68 // "name". Custom Elements of this kind will have this tag |
64 // name. This does not have a prefix. | 69 // name. This does not have a prefix. |
65 const QualifiedName& tagQName() const { return m_tag; } | 70 const QualifiedName& tagQName() const { return m_tag; } |
66 | 71 |
| 72 CustomElementKind kind() const { return isTypeExtension() ? TypeExtension :
CustomTag; } |
67 bool isTypeExtension() const { return type() != name(); } | 73 bool isTypeExtension() const { return type() != name(); } |
68 | 74 |
69 const ScriptValue& prototype() { return m_prototype; } | 75 const ScriptValue& prototype() { return m_prototype; } |
70 | 76 |
71 private: | 77 private: |
72 CustomElementDefinition(const AtomicString& type, const AtomicString& name,
const AtomicString& namespaceURI, const ScriptValue& prototype); | 78 CustomElementDefinition(const AtomicString& type, const AtomicString& name,
const AtomicString& namespaceURI, const ScriptValue& prototype); |
73 | 79 |
74 ScriptValue m_prototype; | 80 ScriptValue m_prototype; |
75 | 81 |
76 AtomicString m_type; | 82 AtomicString m_type; |
77 QualifiedName m_tag; | 83 QualifiedName m_tag; |
78 }; | 84 }; |
79 | 85 |
80 } | 86 } |
81 | 87 |
82 #endif // CustomElementDefinition_h | 88 #endif // CustomElementDefinition_h |
OLD | NEW |