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 if (UNLIKELY(info.Length() < 1)) { |
112 | 112 throwMinimumArityTypeErrorForMethod("appendChild", "Node", 1, info.Lengt h(), info.GetIsolate()); |
haraken
2014/07/09 01:38:53
Can we make this change in a separate change with
kangil_
2014/07/09 02:53:20
Sure, I will.
| |
113 return; | |
114 } | |
115 Node* impl = V8Node::toNative(info.Holder()); | |
113 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; | 116 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; |
114 | 117 Node* newChild; |
115 ExceptionState exceptionState(ExceptionState::ExecutionContext, "appendChild ", "Node", info.Holder(), info.GetIsolate()); | 118 { |
116 Node* newChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]); | 119 v8::TryCatch block; |
120 V8RethrowTryCatchScope rethrow(block); | |
121 if (info.Length() > 0 && !V8Node::hasInstance(info[0], info.GetIsolate() )) { | |
122 exceptionState.throwTypeError("parameter 1 is not of type 'Node'."); | |
123 exceptionState.throwIfNeeded(); | |
124 return; | |
125 } | |
126 TONATIVE_VOID_INTERNAL(newChild, V8Node::toNativeWithTypeCheck(info.GetI solate(), info[0])); | |
127 } | |
117 impl->appendChild(newChild, exceptionState); | 128 impl->appendChild(newChild, exceptionState); |
118 if (exceptionState.throwIfNeeded()) | 129 if (exceptionState.hadException()) { |
130 exceptionState.throwIfNeeded(); | |
119 return; | 131 return; |
132 } | |
120 v8SetReturnValue(info, info[0]); | 133 v8SetReturnValue(info, info[0]); |
121 } | 134 } |
122 | 135 |
123 v8::Handle<v8::Object> wrap(Node* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 136 v8::Handle<v8::Object> wrap(Node* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
124 { | 137 { |
125 ASSERT(impl); | 138 ASSERT(impl); |
126 switch (impl->nodeType()) { | 139 switch (impl->nodeType()) { |
127 case Node::ELEMENT_NODE: | 140 case Node::ELEMENT_NODE: |
128 // For performance reasons, this is inlined from V8Element::wrap and mus t remain in sync. | 141 // For performance reasons, this is inlined from V8Element::wrap and mus t remain in sync. |
129 if (impl->isHTMLElement()) | 142 if (impl->isHTMLElement()) |
(...skipping 17 matching lines...) Expand all Loading... | |
147 return wrap(toDocumentType(impl), creationContext, isolate); | 160 return wrap(toDocumentType(impl), creationContext, isolate); |
148 case Node::DOCUMENT_FRAGMENT_NODE: | 161 case Node::DOCUMENT_FRAGMENT_NODE: |
149 if (impl->isShadowRoot()) | 162 if (impl->isShadowRoot()) |
150 return wrap(toShadowRoot(impl), creationContext, isolate); | 163 return wrap(toShadowRoot(impl), creationContext, isolate); |
151 return wrap(toDocumentFragment(impl), creationContext, isolate); | 164 return wrap(toDocumentFragment(impl), creationContext, isolate); |
152 } | 165 } |
153 ASSERT_NOT_REACHED(); | 166 ASSERT_NOT_REACHED(); |
154 return V8Node::createWrapper(impl, creationContext, isolate); | 167 return V8Node::createWrapper(impl, creationContext, isolate); |
155 } | 168 } |
156 } // namespace WebCore | 169 } // namespace WebCore |
OLD | NEW |