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" |
| 35 #include "DartWebkitClassIds.h" |
34 #include "HTMLNames.h" | 36 #include "HTMLNames.h" |
35 #include "SVGNames.h" | 37 #include "SVGNames.h" |
36 #include "bindings/dart/DartCustomElementBinding.h" | 38 #include "bindings/dart/DartCustomElementBinding.h" |
37 #include "bindings/dart/DartCustomElementLifecycleCallbacks.h" | 39 #include "bindings/dart/DartCustomElementLifecycleCallbacks.h" |
38 #include "bindings/dart/DartDOMData.h" | 40 #include "bindings/dart/DartDOMData.h" |
| 41 #include "bindings/dart/DartDOMWrapper.h" |
39 #include "bindings/dart/DartUtilities.h" | 42 #include "bindings/dart/DartUtilities.h" |
40 #include "bindings/v8/V8Binding.h" | 43 #include "bindings/v8/V8Binding.h" |
41 #include "core/dom/CustomElementException.h" | 44 #include "core/dom/CustomElementException.h" |
42 #include "core/dom/Document.h" | 45 #include "core/dom/Document.h" |
43 | 46 |
44 namespace WebCore { | 47 namespace WebCore { |
45 | 48 |
46 DartCustomElementConstructorBuilder::DartCustomElementConstructorBuilder(Dart_Ha
ndle customType, const AtomicString& extendsTagName, ScriptState* state, const D
ictionary* options) | 49 DartCustomElementConstructorBuilder::DartCustomElementConstructorBuilder(Dart_Ha
ndle customType, const AtomicString& extendsTagName, ScriptState* state, const D
ictionary* options) |
47 : CustomElementConstructorBuilder(state, options) | 50 : CustomElementConstructorBuilder(state, options) |
48 , m_customType(customType) | 51 , m_customType(customType) |
| 52 , m_nativeClassId(_InvalidClassId) |
49 , m_extendsTagName(extendsTagName) | 53 , m_extendsTagName(extendsTagName) |
50 , m_isolate(Dart_CurrentIsolate()) | 54 , m_isolate(Dart_CurrentIsolate()) |
51 , m_context(state->context()) | 55 , m_context(state->context()) |
52 { | 56 { |
53 ASSERT(m_context == v8::Isolate::GetCurrent()->GetCurrentContext()); | 57 ASSERT(m_context == v8::Isolate::GetCurrent()->GetCurrentContext()); |
54 } | 58 } |
55 | 59 |
56 bool DartCustomElementConstructorBuilder::isFeatureAllowed() const | 60 bool DartCustomElementConstructorBuilder::isFeatureAllowed() const |
57 { | 61 { |
58 // Check that we are in the main world | 62 // Check that we are in the main world |
(...skipping 13 matching lines...) Expand all Loading... |
72 return false; | 76 return false; |
73 } else { | 77 } else { |
74 CustomElementException::throwException(CustomElementException::Prototype
DoesNotExtendHTMLElementSVGElementPrototype, type, es); | 78 CustomElementException::throwException(CustomElementException::Prototype
DoesNotExtendHTMLElementSVGElementPrototype, type, es); |
75 return false; | 79 return false; |
76 } | 80 } |
77 | 81 |
78 AtomicString localName; | 82 AtomicString localName; |
79 if (!m_extendsTagName.isNull() && !m_extendsTagName.isEmpty()) { | 83 if (!m_extendsTagName.isNull() && !m_extendsTagName.isEmpty()) { |
80 localName = m_extendsTagName.lower(); | 84 localName = m_extendsTagName.lower(); |
81 | 85 |
82 if (!DartUtilities::isTypeSubclassOfTag(m_customType, m_extendsTagName))
{ | 86 Dart_Handle nativeElement = DartUtilities::getAndValidateNativeType(m_cu
stomType, m_extendsTagName); |
| 87 if (!nativeElement || Dart_IsNull(nativeElement)) { |
83 CustomElementException::throwException(CustomElementException::Proto
typeDoesNotExtendHTMLElementSVGElementPrototype, type, es); | 88 CustomElementException::throwException(CustomElementException::Proto
typeDoesNotExtendHTMLElementSVGElementPrototype, type, es); |
84 return false; | 89 return false; |
85 } | 90 } |
86 | 91 |
| 92 m_nativeClassId = reinterpret_cast<intptr_t>(DartDOMWrapper::readNativeP
ointer(nativeElement, DartDOMWrapper::kNativeTypeIndex)); |
| 93 |
87 // TODO: enable once we pick up Blink version 31 | 94 // TODO: enable once we pick up Blink version 31 |
88 // if (!Document::isValidName(localName)) { | 95 // if (!Document::isValidName(localName)) { |
89 // CustomElementException::throwException(CustomElementException::Ex
tendsIsInvalidName, type, es); | 96 // CustomElementException::throwException(CustomElementException::Ex
tendsIsInvalidName, type, es); |
90 // return false; | 97 // return false; |
91 // } | 98 // } |
92 // if (CustomElement::isValidName(localName)) { | 99 // if (CustomElement::isValidName(localName)) { |
93 // CustomElementException::throwException(CustomElementException::Ex
tendsIsCustomElementName, type, es); | 100 // CustomElementException::throwException(CustomElementException::Ex
tendsIsCustomElementName, type, es); |
94 // return false; | 101 // return false; |
95 // } | 102 // } |
96 } else { | 103 } else { |
97 localName = type; | 104 localName = type; |
| 105 m_nativeClassId = DartHTMLElement::dartClassId; |
98 } | 106 } |
99 | 107 |
100 m_localName = localName; | 108 m_localName = localName; |
101 m_namespaceURI = namespaceURI; | 109 m_namespaceURI = namespaceURI; |
102 return true; | 110 return true; |
103 } | 111 } |
104 | 112 |
105 bool DartCustomElementConstructorBuilder::findTagName(const AtomicString& custom
ElementType, QualifiedName& tagName) | 113 bool DartCustomElementConstructorBuilder::findTagName(const AtomicString& custom
ElementType, QualifiedName& tagName) |
106 { | 114 { |
107 if (!m_extendsTagName.isNull() && !m_extendsTagName.isEmpty()) { | 115 if (!m_extendsTagName.isNull() && !m_extendsTagName.isEmpty()) { |
(...skipping 12 matching lines...) Expand all Loading... |
120 return m_callbacks.get(); | 128 return m_callbacks.get(); |
121 } | 129 } |
122 | 130 |
123 bool DartCustomElementConstructorBuilder::createConstructor(Document* document,
CustomElementDefinition* definition, ExceptionState& es) | 131 bool DartCustomElementConstructorBuilder::createConstructor(Document* document,
CustomElementDefinition* definition, ExceptionState& es) |
124 { | 132 { |
125 return true; | 133 return true; |
126 } | 134 } |
127 | 135 |
128 bool DartCustomElementConstructorBuilder::didRegisterDefinition(CustomElementDef
inition* definition) const | 136 bool DartCustomElementConstructorBuilder::didRegisterDefinition(CustomElementDef
inition* definition) const |
129 { | 137 { |
130 return m_callbacks->setBinding(definition, DartCustomElementBinding::create(
m_customType)); | 138 return m_callbacks->setBinding(definition, DartCustomElementBinding::create(
m_customType, m_nativeClassId)); |
131 } | 139 } |
132 | 140 |
133 ScriptValue DartCustomElementConstructorBuilder::bindingsReturnValue() const | 141 ScriptValue DartCustomElementConstructorBuilder::bindingsReturnValue() const |
134 { | 142 { |
135 // Dart does not return a constructor. | 143 // Dart does not return a constructor. |
136 return ScriptValue(); | 144 return ScriptValue(); |
137 } | 145 } |
138 } // namespace WebCore | 146 } // namespace WebCore |
OLD | NEW |