OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007-2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2007-2009 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 ExceptionState exceptionState(ExceptionState::ExecutionContext, "removeChild
", "Node", info.Holder(), info.GetIsolate()); | 100 ExceptionState exceptionState(ExceptionState::ExecutionContext, "removeChild
", "Node", info.Holder(), info.GetIsolate()); |
101 Node* oldChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]); | 101 Node* oldChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]); |
102 impl->removeChild(oldChild, exceptionState); | 102 impl->removeChild(oldChild, exceptionState); |
103 if (exceptionState.throwIfNeeded()) | 103 if (exceptionState.throwIfNeeded()) |
104 return; | 104 return; |
105 v8SetReturnValue(info, info[0]); | 105 v8SetReturnValue(info, info[0]); |
106 } | 106 } |
107 | 107 |
108 void V8Node::appendChildMethodCustom(const v8::FunctionCallbackInfo<v8::Value>&
info) | 108 void V8Node::appendChildMethodCustom(const v8::FunctionCallbackInfo<v8::Value>&
info) |
109 { | 109 { |
110 v8::Handle<v8::Object> holder = info.Holder(); | 110 ExceptionState exceptionState(ExceptionState::ExecutionContext, "appendChild
", "Node", info.Holder(), info.GetIsolate()); |
111 Node* impl = V8Node::toNative(holder); | 111 Node* impl = V8Node::toNative(info.Holder()); |
112 | |
113 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; | 112 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; |
114 | 113 Node* newChild; |
115 ExceptionState exceptionState(ExceptionState::ExecutionContext, "appendChild
", "Node", info.Holder(), info.GetIsolate()); | 114 { |
116 Node* newChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]); | 115 v8::TryCatch block; |
| 116 V8RethrowTryCatchScope rethrow(block); |
| 117 if (info.Length() > 0 && !V8Node::hasInstance(info[0], info.GetIsolate()
)) { |
| 118 exceptionState.throwTypeError("parameter 1 is not of type 'Node'."); |
| 119 exceptionState.throwIfNeeded(); |
| 120 return; |
| 121 } |
| 122 TONATIVE_VOID_INTERNAL(newChild, V8Node::toNativeWithTypeCheck(info.GetI
solate(), info[0])); |
| 123 } |
117 impl->appendChild(newChild, exceptionState); | 124 impl->appendChild(newChild, exceptionState); |
118 if (exceptionState.throwIfNeeded()) | 125 if (exceptionState.hadException()) { |
| 126 exceptionState.throwIfNeeded(); |
119 return; | 127 return; |
| 128 } |
120 v8SetReturnValue(info, info[0]); | 129 v8SetReturnValue(info, info[0]); |
121 } | 130 } |
122 | 131 |
123 v8::Handle<v8::Object> wrap(Node* impl, v8::Handle<v8::Object> creationContext,
v8::Isolate* isolate) | 132 v8::Handle<v8::Object> wrap(Node* impl, v8::Handle<v8::Object> creationContext,
v8::Isolate* isolate) |
124 { | 133 { |
125 ASSERT(impl); | 134 ASSERT(impl); |
126 switch (impl->nodeType()) { | 135 switch (impl->nodeType()) { |
127 case Node::ELEMENT_NODE: | 136 case Node::ELEMENT_NODE: |
128 // For performance reasons, this is inlined from V8Element::wrap and mus
t remain in sync. | 137 // For performance reasons, this is inlined from V8Element::wrap and mus
t remain in sync. |
129 if (impl->isHTMLElement()) | 138 if (impl->isHTMLElement()) |
(...skipping 17 matching lines...) Expand all Loading... |
147 return wrap(toDocumentType(impl), creationContext, isolate); | 156 return wrap(toDocumentType(impl), creationContext, isolate); |
148 case Node::DOCUMENT_FRAGMENT_NODE: | 157 case Node::DOCUMENT_FRAGMENT_NODE: |
149 if (impl->isShadowRoot()) | 158 if (impl->isShadowRoot()) |
150 return wrap(toShadowRoot(impl), creationContext, isolate); | 159 return wrap(toShadowRoot(impl), creationContext, isolate); |
151 return wrap(toDocumentFragment(impl), creationContext, isolate); | 160 return wrap(toDocumentFragment(impl), creationContext, isolate); |
152 } | 161 } |
153 ASSERT_NOT_REACHED(); | 162 ASSERT_NOT_REACHED(); |
154 return V8Node::createWrapper(impl, creationContext, isolate); | 163 return V8Node::createWrapper(impl, creationContext, isolate); |
155 } | 164 } |
156 } // namespace WebCore | 165 } // namespace WebCore |
OLD | NEW |