Chromium Code Reviews| Index: Source/bindings/dart/custom/DartDocumentCustom.cpp |
| diff --git a/Source/bindings/dart/custom/DartDocumentCustom.cpp b/Source/bindings/dart/custom/DartDocumentCustom.cpp |
| index 362de2277ff7e100797edf2cf12628a1da8ff8fb..e3e4b8d69d94bb5681f52a370b84701a5f98495a 100644 |
| --- a/Source/bindings/dart/custom/DartDocumentCustom.cpp |
| +++ b/Source/bindings/dart/custom/DartDocumentCustom.cpp |
| @@ -30,10 +30,12 @@ |
| #include "config.h" |
| #include "DartDocument.h" |
| +#include "DartElement.h" |
| #include "DartHTMLDocument.h" |
| #include "DartSVGDocument.h" |
| #include "DartTouchList.h" |
| #include "bindings/dart/DartDOMWrapper.h" |
| +#include "core/dom/CustomElementCallbackDispatcher.h" |
| #include "core/dom/Document.h" |
| namespace WebCore { |
| @@ -59,6 +61,90 @@ void createTouchListCallback(Dart_NativeArguments args) |
| DartTouchList::returnToDart(args, touchList.release()); |
| } |
| +void createElementCallback(Dart_NativeArguments args) |
| +{ |
| + Dart_Handle exception = 0; |
| + { |
| + Document* receiver = DartDOMWrapper::receiver< Document >(args); |
| + |
| + DartStringAdapter localName = DartUtilities::dartToString(args, 1, exception); |
| + if (exception) |
| + goto fail; |
| + |
| + DartStringAdapter typeExtension = DartUtilities::dartToStringWithNullCheck(args, 2, exception); |
| + if (exception) |
| + goto fail; |
| + |
| + DartExceptionState es; |
| + RefPtr<Element> result; |
| + { |
| + CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; |
| + |
| + const AtomicString& typeExtensionString = typeExtension; |
| + if (typeExtensionString.isNull()) { |
| + result = receiver->createElement(localName, es); |
| + } else { |
| + result = receiver->createElement(localName, typeExtensionString, es); |
| + } |
| + } |
| + |
| + Dart_SetReturnValue(args, DartElement::toDart(result)); |
|
siva
2013/09/20 20:57:37
This is an inefficient way to return stuff, you sh
blois
2013/09/20 22:18:03
Done.
|
| + if (es.hadException()) { |
| + exception = DartDOMWrapper::exceptionCodeToDartException(es); |
| + goto fail; |
| + } |
| + return; |
| + } |
| + |
| +fail: |
| + Dart_ThrowException(exception); |
| + ASSERT_NOT_REACHED(); |
| } |
| +void createElementNSCallback(Dart_NativeArguments args) |
| +{ |
| + Dart_Handle exception = 0; |
| + { |
| + Document* receiver = DartDOMWrapper::receiver< Document >(args); |
| + |
| + DartStringAdapter namespaceURI = DartUtilities::dartToString(args, 1, exception); |
| + if (exception) |
| + goto fail; |
| + |
| + DartStringAdapter qualifiedName = DartUtilities::dartToString(args, 2, exception); |
| + if (exception) |
| + goto fail; |
| + |
| + DartStringAdapter typeExtension = DartUtilities::dartToStringWithNullCheck(args, 3, exception); |
| + if (exception) |
| + goto fail; |
| + |
| + DartExceptionState es; |
| + RefPtr<Element> result; |
| + { |
| + CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; |
| + |
| + const AtomicString& typeExtensionString = typeExtension; |
| + if (typeExtensionString.isNull()) { |
| + result = receiver->createElementNS(namespaceURI, qualifiedName, es); |
| + } else { |
| + result = receiver->createElementNS(namespaceURI, qualifiedName, typeExtensionString, es); |
| + } |
| + } |
| + |
| + Dart_SetReturnValue(args, DartElement::toDart(result)); |
|
siva
2013/09/20 20:57:37
Ditto.
blois
2013/09/20 22:18:03
Done.
|
| + if (es.hadException()) { |
| + exception = DartDOMWrapper::exceptionCodeToDartException(es); |
| + goto fail; |
| + } |
| + return; |
| + } |
| + |
| +fail: |
| + Dart_ThrowException(exception); |
| + ASSERT_NOT_REACHED(); |
| } |
| + |
| +} // namespace DartDocumentInternal |
| + |
| +} // namespace WebCore |