OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 13 matching lines...) Expand all Loading... | |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
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 #include "config.h" | 31 #include "config.h" |
32 #include "bindings/dart/DartCustomElementConstructorBuilder.h" | 32 #include "bindings/dart/DartCustomElementConstructorBuilder.h" |
33 | 33 |
34 #include "DartHTMLElement.h" | |
34 #include "HTMLNames.h" | 35 #include "HTMLNames.h" |
35 #include "SVGNames.h" | 36 #include "SVGNames.h" |
36 #include "bindings/dart/DartCustomElementBinding.h" | 37 #include "bindings/dart/DartCustomElementBinding.h" |
37 #include "bindings/dart/DartCustomElementLifecycleCallbacks.h" | 38 #include "bindings/dart/DartCustomElementLifecycleCallbacks.h" |
38 #include "bindings/dart/DartDOMData.h" | 39 #include "bindings/dart/DartDOMData.h" |
40 #include "bindings/dart/DartDOMWrapper.h" | |
39 #include "bindings/dart/DartUtilities.h" | 41 #include "bindings/dart/DartUtilities.h" |
40 #include "bindings/v8/V8Binding.h" | 42 #include "bindings/v8/V8Binding.h" |
41 #include "core/dom/CustomElementException.h" | 43 #include "core/dom/CustomElementException.h" |
42 #include "core/dom/Document.h" | 44 #include "core/dom/Document.h" |
43 | 45 |
44 namespace WebCore { | 46 namespace WebCore { |
45 | 47 |
46 DartCustomElementConstructorBuilder::DartCustomElementConstructorBuilder(Dart_Ha ndle customType, const AtomicString& extendsTagName, ScriptState* state, const D ictionary* options) | 48 DartCustomElementConstructorBuilder::DartCustomElementConstructorBuilder(Dart_Ha ndle customType, const AtomicString& extendsTagName, ScriptState* state, const D ictionary* options) |
47 : CustomElementConstructorBuilder(state, options) | 49 : CustomElementConstructorBuilder(state, options) |
48 , m_customType(customType) | 50 , m_customType(customType) |
51 , m_nativeClassId(-1) | |
vsm
2013/10/18 21:18:15
We should make an enum for InvalidClassId just to
blois
2013/10/18 23:03:40
Done.
| |
49 , m_extendsTagName(extendsTagName) | 52 , m_extendsTagName(extendsTagName) |
50 , m_isolate(Dart_CurrentIsolate()) | 53 , m_isolate(Dart_CurrentIsolate()) |
51 , m_context(state->context()) | 54 , m_context(state->context()) |
52 { | 55 { |
53 ASSERT(m_context == v8::Isolate::GetCurrent()->GetCurrentContext()); | 56 ASSERT(m_context == v8::Isolate::GetCurrent()->GetCurrentContext()); |
54 } | 57 } |
55 | 58 |
56 bool DartCustomElementConstructorBuilder::isFeatureAllowed() const | 59 bool DartCustomElementConstructorBuilder::isFeatureAllowed() const |
57 { | 60 { |
58 // Check that we are in the main world | 61 // Check that we are in the main world |
(...skipping 13 matching lines...) Expand all Loading... | |
72 return false; | 75 return false; |
73 } else { | 76 } else { |
74 CustomElementException::throwException(CustomElementException::Prototype DoesNotExtendHTMLElementSVGElementPrototype, type, es); | 77 CustomElementException::throwException(CustomElementException::Prototype DoesNotExtendHTMLElementSVGElementPrototype, type, es); |
75 return false; | 78 return false; |
76 } | 79 } |
77 | 80 |
78 AtomicString localName; | 81 AtomicString localName; |
79 if (!m_extendsTagName.isNull() && !m_extendsTagName.isEmpty()) { | 82 if (!m_extendsTagName.isNull() && !m_extendsTagName.isEmpty()) { |
80 localName = m_extendsTagName.lower(); | 83 localName = m_extendsTagName.lower(); |
81 | 84 |
82 if (!DartUtilities::isTypeSubclassOfTag(m_customType, m_extendsTagName)) { | 85 Dart_Handle nativeElement = DartUtilities::getAndValidateNativeType(m_cu stomType, m_extendsTagName); |
86 if (!nativeElement) { | |
87 CustomElementException::throwException(CustomElementException::Proto typeDoesNotExtendHTMLElementSVGElementPrototype, type, es); | |
88 return false; | |
89 } | |
90 if (Dart_IsNull(nativeElement)) { | |
vsm
2013/10/18 21:18:15
Why not combine these two if clauses? The bodies
blois
2013/10/18 23:03:40
Done.
| |
83 CustomElementException::throwException(CustomElementException::Proto typeDoesNotExtendHTMLElementSVGElementPrototype, type, es); | 91 CustomElementException::throwException(CustomElementException::Proto typeDoesNotExtendHTMLElementSVGElementPrototype, type, es); |
84 return false; | 92 return false; |
85 } | 93 } |
86 | 94 |
95 m_nativeClassId = reinterpret_cast<intptr_t>(DartDOMWrapper::readNativeP ointer(nativeElement, DartDOMWrapper::kNativeTypeIndex)); | |
96 | |
87 // TODO: enable once we pick up Blink version 31 | 97 // TODO: enable once we pick up Blink version 31 |
88 // if (!Document::isValidName(localName)) { | 98 // if (!Document::isValidName(localName)) { |
89 // CustomElementException::throwException(CustomElementException::Ex tendsIsInvalidName, type, es); | 99 // CustomElementException::throwException(CustomElementException::Ex tendsIsInvalidName, type, es); |
90 // return false; | 100 // return false; |
91 // } | 101 // } |
92 // if (CustomElement::isValidName(localName)) { | 102 // if (CustomElement::isValidName(localName)) { |
93 // CustomElementException::throwException(CustomElementException::Ex tendsIsCustomElementName, type, es); | 103 // CustomElementException::throwException(CustomElementException::Ex tendsIsCustomElementName, type, es); |
94 // return false; | 104 // return false; |
95 // } | 105 // } |
96 } else { | 106 } else { |
97 localName = type; | 107 localName = type; |
108 m_nativeClassId = DartHTMLElement::dartClassId; | |
98 } | 109 } |
99 | 110 |
100 m_localName = localName; | 111 m_localName = localName; |
101 m_namespaceURI = namespaceURI; | 112 m_namespaceURI = namespaceURI; |
102 return true; | 113 return true; |
103 } | 114 } |
104 | 115 |
105 bool DartCustomElementConstructorBuilder::findTagName(const AtomicString& custom ElementType, QualifiedName& tagName) | 116 bool DartCustomElementConstructorBuilder::findTagName(const AtomicString& custom ElementType, QualifiedName& tagName) |
106 { | 117 { |
107 if (!m_extendsTagName.isNull() && !m_extendsTagName.isEmpty()) { | 118 if (!m_extendsTagName.isNull() && !m_extendsTagName.isEmpty()) { |
(...skipping 12 matching lines...) Expand all Loading... | |
120 return m_callbacks.get(); | 131 return m_callbacks.get(); |
121 } | 132 } |
122 | 133 |
123 bool DartCustomElementConstructorBuilder::createConstructor(Document* document, CustomElementDefinition* definition, ExceptionState& es) | 134 bool DartCustomElementConstructorBuilder::createConstructor(Document* document, CustomElementDefinition* definition, ExceptionState& es) |
124 { | 135 { |
125 return true; | 136 return true; |
126 } | 137 } |
127 | 138 |
128 bool DartCustomElementConstructorBuilder::didRegisterDefinition(CustomElementDef inition* definition) const | 139 bool DartCustomElementConstructorBuilder::didRegisterDefinition(CustomElementDef inition* definition) const |
129 { | 140 { |
130 return m_callbacks->setBinding(definition, DartCustomElementBinding::create( m_customType)); | 141 return m_callbacks->setBinding(definition, DartCustomElementBinding::create( m_customType, m_nativeClassId)); |
131 } | 142 } |
132 | 143 |
133 ScriptValue DartCustomElementConstructorBuilder::bindingsReturnValue() const | 144 ScriptValue DartCustomElementConstructorBuilder::bindingsReturnValue() const |
134 { | 145 { |
135 // Dart does not return a constructor. | 146 // Dart does not return a constructor. |
136 return ScriptValue(); | 147 return ScriptValue(); |
137 } | 148 } |
138 } // namespace WebCore | 149 } // namespace WebCore |
OLD | NEW |