| OLD | NEW |
| (Empty) |
| 1 // Copyright 2011, Google Inc. | |
| 2 // All rights reserved. | |
| 3 // | |
| 4 // Redistribution and use in source and binary forms, with or without | |
| 5 // modification, are permitted provided that the following conditions are | |
| 6 // met: | |
| 7 // | |
| 8 // * Redistributions of source code must retain the above copyright | |
| 9 // notice, this list of conditions and the following disclaimer. | |
| 10 // * Redistributions in binary form must reproduce the above | |
| 11 // copyright notice, this list of conditions and the following disclaimer | |
| 12 // in the documentation and/or other materials provided with the | |
| 13 // distribution. | |
| 14 // * Neither the name of Google Inc. nor the names of its | |
| 15 // contributors may be used to endorse or promote products derived from | |
| 16 // this software without specific prior written permission. | |
| 17 // | |
| 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 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. | |
| 29 | |
| 30 #include "config.h" | |
| 31 #include "bindings/core/dart/DartDocument.h" | |
| 32 | |
| 33 #include "bindings/core/dart/DartDOMWrapper.h" | |
| 34 #include "bindings/core/dart/DartElement.h" | |
| 35 #include "bindings/core/dart/DartHTMLDocument.h" | |
| 36 #include "bindings/core/dart/DartTouchList.h" | |
| 37 #include "core/dom/Document.h" | |
| 38 #include "core/dom/custom/CustomElementCallbackDispatcher.h" | |
| 39 | |
| 40 namespace blink { | |
| 41 | |
| 42 Dart_Handle DartDocument::createWrapper(DartDOMData* domData, Document* document
) | |
| 43 { | |
| 44 if (!document) | |
| 45 return Dart_Null(); | |
| 46 | |
| 47 if (document->isHTMLDocument()) | |
| 48 return DartHTMLDocument::createWrapper(domData, static_cast<HTMLDocument
*>(document)); | |
| 49 | |
| 50 return DartDOMWrapper::createWrapper<DartDocument>(domData, document); | |
| 51 } | |
| 52 | |
| 53 namespace DartDocumentInternal { | |
| 54 | |
| 55 void createTouchListCallback(Dart_NativeArguments args) | |
| 56 { | |
| 57 RefPtr<TouchList> touchList = TouchList::create(); | |
| 58 ASSERT(Dart_GetNativeArgumentCount(args) == 1); | |
| 59 DartTouchList::returnToDart(args, touchList.release()); | |
| 60 } | |
| 61 | |
| 62 void createElementCallback(Dart_NativeArguments args) | |
| 63 { | |
| 64 Dart_Handle exception = 0; | |
| 65 { | |
| 66 Document* receiver = DartDOMWrapper::receiver< Document >(args); | |
| 67 | |
| 68 DartStringAdapter localName = DartUtilities::dartToString(args, 1, excep
tion); | |
| 69 if (exception) | |
| 70 goto fail; | |
| 71 | |
| 72 DartStringAdapter typeExtension = DartUtilities::dartToStringWithNullChe
ck(args, 2, exception); | |
| 73 if (exception) | |
| 74 goto fail; | |
| 75 | |
| 76 DartExceptionState es; | |
| 77 RefPtr<Element> result; | |
| 78 { | |
| 79 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope
; | |
| 80 | |
| 81 const AtomicString& typeExtensionString = typeExtension; | |
| 82 if (typeExtensionString.isNull()) { | |
| 83 result = receiver->createElement(localName, es); | |
| 84 } else { | |
| 85 result = receiver->createElement(localName, typeExtensionString,
es); | |
| 86 } | |
| 87 } | |
| 88 | |
| 89 DartElement::returnToDart(args, result); | |
| 90 if (es.hadException()) { | |
| 91 exception = es.toDart(args); | |
| 92 goto fail; | |
| 93 } | |
| 94 return; | |
| 95 } | |
| 96 | |
| 97 fail: | |
| 98 Dart_ThrowException(exception); | |
| 99 ASSERT_NOT_REACHED(); | |
| 100 } | |
| 101 | |
| 102 void createElementCallback_2(Dart_NativeArguments args) | |
| 103 { | |
| 104 return createElementCallback(args); | |
| 105 } | |
| 106 | |
| 107 void createElementNSCallback(Dart_NativeArguments args) | |
| 108 { | |
| 109 Dart_Handle exception = 0; | |
| 110 { | |
| 111 Document* receiver = DartDOMWrapper::receiver< Document >(args); | |
| 112 | |
| 113 DartStringAdapter namespaceURI = DartUtilities::dartToString(args, 1, ex
ception); | |
| 114 if (exception) | |
| 115 goto fail; | |
| 116 | |
| 117 DartStringAdapter qualifiedName = DartUtilities::dartToString(args, 2, e
xception); | |
| 118 if (exception) | |
| 119 goto fail; | |
| 120 | |
| 121 DartStringAdapter typeExtension = DartUtilities::dartToStringWithNullChe
ck(args, 3, exception); | |
| 122 if (exception) | |
| 123 goto fail; | |
| 124 | |
| 125 DartExceptionState es; | |
| 126 RefPtr<Element> result; | |
| 127 { | |
| 128 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope
; | |
| 129 | |
| 130 const AtomicString& typeExtensionString = typeExtension; | |
| 131 if (typeExtensionString.isNull()) { | |
| 132 result = receiver->createElementNS(namespaceURI, qualifiedName,
es); | |
| 133 } else { | |
| 134 result = receiver->createElementNS(namespaceURI, qualifiedName,
typeExtensionString, es); | |
| 135 } | |
| 136 } | |
| 137 | |
| 138 DartElement::returnToDart(args, result); | |
| 139 if (es.hadException()) { | |
| 140 exception = es.toDart(args); | |
| 141 goto fail; | |
| 142 } | |
| 143 return; | |
| 144 } | |
| 145 | |
| 146 fail: | |
| 147 Dart_ThrowException(exception); | |
| 148 ASSERT_NOT_REACHED(); | |
| 149 } | |
| 150 | |
| 151 void createElementNSCallback_2(Dart_NativeArguments args) | |
| 152 { | |
| 153 return createElementNSCallback(args); | |
| 154 } | |
| 155 | |
| 156 } // namespace DartDocumentInternal | |
| 157 | |
| 158 } // namespace blink | |
| OLD | NEW |