Chromium Code Reviews| Index: Source/bindings/dart/DartCustomElementConstructorBuilder.cpp |
| diff --git a/Source/bindings/dart/DartCustomElementConstructorBuilder.cpp b/Source/bindings/dart/DartCustomElementConstructorBuilder.cpp |
| index 0cec8815076954f7ab5dcb1d7bf64f43f50e0b66..365ded868025b649441cb711f1cf0a83ac52a41b 100644 |
| --- a/Source/bindings/dart/DartCustomElementConstructorBuilder.cpp |
| +++ b/Source/bindings/dart/DartCustomElementConstructorBuilder.cpp |
| @@ -31,11 +31,13 @@ |
| #include "config.h" |
| #include "bindings/dart/DartCustomElementConstructorBuilder.h" |
| +#include "DartHTMLElement.h" |
| #include "HTMLNames.h" |
| #include "SVGNames.h" |
| #include "bindings/dart/DartCustomElementBinding.h" |
| #include "bindings/dart/DartCustomElementLifecycleCallbacks.h" |
| #include "bindings/dart/DartDOMData.h" |
| +#include "bindings/dart/DartDOMWrapper.h" |
| #include "bindings/dart/DartUtilities.h" |
| #include "bindings/v8/V8Binding.h" |
| #include "core/dom/CustomElementException.h" |
| @@ -46,6 +48,7 @@ namespace WebCore { |
| DartCustomElementConstructorBuilder::DartCustomElementConstructorBuilder(Dart_Handle customType, const AtomicString& extendsTagName, ScriptState* state, const Dictionary* options) |
| : CustomElementConstructorBuilder(state, options) |
| , m_customType(customType) |
| + , 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.
|
| , m_extendsTagName(extendsTagName) |
| , m_isolate(Dart_CurrentIsolate()) |
| , m_context(state->context()) |
| @@ -79,10 +82,17 @@ bool DartCustomElementConstructorBuilder::validateOptions(const AtomicString& ty |
| if (!m_extendsTagName.isNull() && !m_extendsTagName.isEmpty()) { |
| localName = m_extendsTagName.lower(); |
| - if (!DartUtilities::isTypeSubclassOfTag(m_customType, m_extendsTagName)) { |
| + Dart_Handle nativeElement = DartUtilities::getAndValidateNativeType(m_customType, m_extendsTagName); |
| + if (!nativeElement) { |
| CustomElementException::throwException(CustomElementException::PrototypeDoesNotExtendHTMLElementSVGElementPrototype, type, es); |
| return false; |
| } |
| + 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.
|
| + CustomElementException::throwException(CustomElementException::PrototypeDoesNotExtendHTMLElementSVGElementPrototype, type, es); |
| + return false; |
| + } |
| + |
| + m_nativeClassId = reinterpret_cast<intptr_t>(DartDOMWrapper::readNativePointer(nativeElement, DartDOMWrapper::kNativeTypeIndex)); |
| // TODO: enable once we pick up Blink version 31 |
| // if (!Document::isValidName(localName)) { |
| @@ -95,6 +105,7 @@ bool DartCustomElementConstructorBuilder::validateOptions(const AtomicString& ty |
| // } |
| } else { |
| localName = type; |
| + m_nativeClassId = DartHTMLElement::dartClassId; |
| } |
| m_localName = localName; |
| @@ -127,7 +138,7 @@ bool DartCustomElementConstructorBuilder::createConstructor(Document* document, |
| bool DartCustomElementConstructorBuilder::didRegisterDefinition(CustomElementDefinition* definition) const |
| { |
| - return m_callbacks->setBinding(definition, DartCustomElementBinding::create(m_customType)); |
| + return m_callbacks->setBinding(definition, DartCustomElementBinding::create(m_customType, m_nativeClassId)); |
| } |
| ScriptValue DartCustomElementConstructorBuilder::bindingsReturnValue() const |