| OLD | NEW |
| 1 // Copyright 2011, Google Inc. | 1 // Copyright 2011, Google Inc. |
| 2 // All rights reserved. | 2 // 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 namespace DartNodeInternal { | 48 namespace DartNodeInternal { |
| 49 | 49 |
| 50 // This function is customized to take advantage of the optional 4th argument: s
houldLazyAttach. | 50 // This function is customized to take advantage of the optional 4th argument: s
houldLazyAttach. |
| 51 void insertBeforeCallback(Dart_NativeArguments args) | 51 void insertBeforeCallback(Dart_NativeArguments args) |
| 52 { | 52 { |
| 53 Dart_Handle exception = 0; | 53 Dart_Handle exception = 0; |
| 54 { | 54 { |
| 55 Node* receiver = DartDOMWrapper::receiver<Node>(args); | 55 Node* receiver = DartDOMWrapper::receiver<Node>(args); |
| 56 | 56 |
| 57 Node* newChild = DartNode::toNative(args, 1, exception); | 57 Node* newChild = DartNode::toNativeWithNullCheck(args, 1, exception); |
| 58 if (exception) | 58 if (exception) |
| 59 goto fail; | 59 goto fail; |
| 60 | 60 |
| 61 Node* refChild = DartNode::toNative(args, 2, exception); | 61 Node* refChild = DartNode::toNativeWithNullCheck(args, 2, exception); |
| 62 if (exception) | 62 if (exception) |
| 63 goto fail; | 63 goto fail; |
| 64 | 64 |
| 65 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; | 65 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; |
| 66 | 66 |
| 67 DartExceptionState es; | 67 DartExceptionState es; |
| 68 receiver->insertBefore(newChild, refChild, es); | 68 receiver->insertBefore(newChild, refChild, es); |
| 69 if (es.hadException()) { | 69 if (es.hadException()) { |
| 70 exception = DartDOMWrapper::exceptionCodeToDartException(es); | 70 exception = DartDOMWrapper::exceptionCodeToDartException(es); |
| 71 goto fail; | 71 goto fail; |
| 72 } | 72 } |
| 73 | 73 |
| 74 DartDOMWrapper::returnToDart<DartNode>(args, newChild); | 74 DartDOMWrapper::returnToDart<DartNode>(args, newChild); |
| 75 return; | 75 return; |
| 76 } | 76 } |
| 77 | 77 |
| 78 fail: | 78 fail: |
| 79 Dart_ThrowException(exception); | 79 Dart_ThrowException(exception); |
| 80 ASSERT_NOT_REACHED(); | 80 ASSERT_NOT_REACHED(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 // This function is customized to take advantage of the optional 4th argument: s
houldLazyAttach. | 83 // This function is customized to take advantage of the optional 4th argument: s
houldLazyAttach. |
| 84 void replaceChildCallback(Dart_NativeArguments args) | 84 void replaceChildCallback(Dart_NativeArguments args) |
| 85 { | 85 { |
| 86 Dart_Handle exception = 0; | 86 Dart_Handle exception = 0; |
| 87 { | 87 { |
| 88 Node* receiver = DartDOMWrapper::receiver<Node>(args); | 88 Node* receiver = DartDOMWrapper::receiver<Node>(args); |
| 89 | 89 |
| 90 Node* newChild = DartNode::toNative(args, 1, exception); | 90 Node* newChild = DartNode::toNativeWithNullCheck(args, 1, exception); |
| 91 if (exception) | 91 if (exception) |
| 92 goto fail; | 92 goto fail; |
| 93 | 93 |
| 94 Node* oldChild = DartNode::toNative(args, 2, exception); | 94 Node* oldChild = DartNode::toNativeWithNullCheck(args, 2, exception); |
| 95 if (exception) | 95 if (exception) |
| 96 goto fail; | 96 goto fail; |
| 97 | 97 |
| 98 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; | 98 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; |
| 99 | 99 |
| 100 DartExceptionState es; | 100 DartExceptionState es; |
| 101 receiver->replaceChild(newChild, oldChild, es); | 101 receiver->replaceChild(newChild, oldChild, es); |
| 102 if (es.hadException()) { | 102 if (es.hadException()) { |
| 103 exception = DartDOMWrapper::exceptionCodeToDartException(es); | 103 exception = DartDOMWrapper::exceptionCodeToDartException(es); |
| 104 goto fail; | 104 goto fail; |
| 105 } | 105 } |
| 106 | 106 |
| 107 DartDOMWrapper::returnToDart<DartNode>(args, newChild); | 107 DartDOMWrapper::returnToDart<DartNode>(args, newChild); |
| 108 return; | 108 return; |
| 109 } | 109 } |
| 110 | 110 |
| 111 fail: | 111 fail: |
| 112 Dart_ThrowException(exception); | 112 Dart_ThrowException(exception); |
| 113 ASSERT_NOT_REACHED(); | 113 ASSERT_NOT_REACHED(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 // Custom handling of the return value. | 116 // Custom handling of the return value. |
| 117 void removeChildCallback(Dart_NativeArguments args) | 117 void removeChildCallback(Dart_NativeArguments args) |
| 118 { | 118 { |
| 119 Dart_Handle exception = 0; | 119 Dart_Handle exception = 0; |
| 120 { | 120 { |
| 121 Node* receiver = DartDOMWrapper::receiver<Node>(args); | 121 Node* receiver = DartDOMWrapper::receiver<Node>(args); |
| 122 | 122 |
| 123 Node* child = DartNode::toNative(args, 1, exception); | 123 Node* child = DartNode::toNativeWithNullCheck(args, 1, exception); |
| 124 if (exception) | 124 if (exception) |
| 125 goto fail; | 125 goto fail; |
| 126 | 126 |
| 127 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; | 127 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; |
| 128 | 128 |
| 129 DartExceptionState es; | 129 DartExceptionState es; |
| 130 receiver->removeChild(child, es); | 130 receiver->removeChild(child, es); |
| 131 if (es.hadException()) { | 131 if (es.hadException()) { |
| 132 exception = DartDOMWrapper::exceptionCodeToDartException(es); | 132 exception = DartDOMWrapper::exceptionCodeToDartException(es); |
| 133 goto fail; | 133 goto fail; |
| 134 } | 134 } |
| 135 | 135 |
| 136 DartDOMWrapper::returnToDart<DartNode>(args, child); | 136 DartDOMWrapper::returnToDart<DartNode>(args, child); |
| 137 return; | 137 return; |
| 138 } | 138 } |
| 139 | 139 |
| 140 fail: | 140 fail: |
| 141 Dart_ThrowException(exception); | 141 Dart_ThrowException(exception); |
| 142 ASSERT_NOT_REACHED(); | 142 ASSERT_NOT_REACHED(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 // This function is customized to enable lazy attaching - see the last argument
to appendChild. | 145 // This function is customized to enable lazy attaching - see the last argument
to appendChild. |
| 146 void appendChildCallback(Dart_NativeArguments args) | 146 void appendChildCallback(Dart_NativeArguments args) |
| 147 { | 147 { |
| 148 Dart_Handle exception = 0; | 148 Dart_Handle exception = 0; |
| 149 { | 149 { |
| 150 Node* receiver = DartDOMWrapper::receiver<Node>(args); | 150 Node* receiver = DartDOMWrapper::receiver<Node>(args); |
| 151 | 151 |
| 152 Node* child = DartNode::toNative(args, 1, exception); | 152 Node* child = DartNode::toNativeWithNullCheck(args, 1, exception); |
| 153 if (exception) | 153 if (exception) |
| 154 goto fail; | 154 goto fail; |
| 155 | 155 |
| 156 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; | 156 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; |
| 157 | 157 |
| 158 DartExceptionState es; | 158 DartExceptionState es; |
| 159 receiver->appendChild(child, es); | 159 receiver->appendChild(child, es); |
| 160 if (es.hadException()) { | 160 if (es.hadException()) { |
| 161 exception = DartDOMWrapper::exceptionCodeToDartException(es); | 161 exception = DartDOMWrapper::exceptionCodeToDartException(es); |
| 162 goto fail; | 162 goto fail; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 case Node::DOCUMENT_TYPE_NODE: | 222 case Node::DOCUMENT_TYPE_NODE: |
| 223 return DartDocumentType::createWrapper(domData, static_cast<DocumentType
*>(node)); | 223 return DartDocumentType::createWrapper(domData, static_cast<DocumentType
*>(node)); |
| 224 case Node::DOCUMENT_FRAGMENT_NODE: | 224 case Node::DOCUMENT_FRAGMENT_NODE: |
| 225 return DartDocumentFragment::createWrapper(domData, static_cast<Document
Fragment*>(node)); | 225 return DartDocumentFragment::createWrapper(domData, static_cast<Document
Fragment*>(node)); |
| 226 default: break; // XPATH_NAMESPACE_NODE | 226 default: break; // XPATH_NAMESPACE_NODE |
| 227 } | 227 } |
| 228 return DartDOMWrapper::createWrapper<DartNode>(domData, node); | 228 return DartDOMWrapper::createWrapper<DartNode>(domData, node); |
| 229 } | 229 } |
| 230 | 230 |
| 231 } | 231 } |
| OLD | NEW |