Chromium Code Reviews| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 #include "core/dom/Document.h" | 51 #include "core/dom/Document.h" |
| 52 #include "core/dom/custom/CustomElementCallbackDispatcher.h" | 52 #include "core/dom/custom/CustomElementCallbackDispatcher.h" |
| 53 #include "core/dom/shadow/ShadowRoot.h" | 53 #include "core/dom/shadow/ShadowRoot.h" |
| 54 #include "core/events/EventListener.h" | 54 #include "core/events/EventListener.h" |
| 55 #include "wtf/RefPtr.h" | 55 #include "wtf/RefPtr.h" |
| 56 | 56 |
| 57 namespace WebCore { | 57 namespace WebCore { |
| 58 | 58 |
| 59 // These functions are custom to prevent a wrapper lookup of the return value wh ich is always | 59 // These functions are custom to prevent a wrapper lookup of the return value wh ich is always |
| 60 // part of the arguments. | 60 // part of the arguments. |
| 61 void V8Node::insertBeforeMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) | |
| 62 { | |
| 63 v8::Handle<v8::Object> holder = info.Holder(); | |
| 64 Node* impl = V8Node::toNative(holder); | |
| 65 | |
| 66 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; | |
| 67 | |
| 68 ExceptionState exceptionState(ExceptionState::ExecutionContext, "insertBefor e", "Node", info.Holder(), info.GetIsolate()); | |
| 69 Node* newChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]); | |
| 70 Node* refChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[1]); | |
| 71 impl->insertBefore(newChild, refChild, exceptionState); | |
| 72 if (exceptionState.throwIfNeeded()) | |
| 73 return; | |
| 74 v8SetReturnValue(info, info[0]); | |
| 75 } | |
| 76 | |
| 77 void V8Node::replaceChildMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) | 61 void V8Node::replaceChildMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 78 { | 62 { |
| 79 v8::Handle<v8::Object> holder = info.Holder(); | 63 v8::Handle<v8::Object> holder = info.Holder(); |
| 80 Node* impl = V8Node::toNative(holder); | 64 Node* impl = V8Node::toNative(holder); |
| 81 | 65 |
| 82 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; | 66 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; |
| 83 | 67 |
| 84 ExceptionState exceptionState(ExceptionState::ExecutionContext, "replaceChil d", "Node", info.Holder(), info.GetIsolate()); | 68 ExceptionState exceptionState(ExceptionState::ExecutionContext, "replaceChil d", "Node", info.Holder(), info.GetIsolate()); |
| 85 Node* newChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]); | 69 Node* newChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]); |
| 86 Node* oldChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[1]); | 70 Node* oldChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[1]); |
| 87 impl->replaceChild(newChild, oldChild, exceptionState); | 71 impl->replaceChild(newChild, oldChild, exceptionState); |
| 88 if (exceptionState.throwIfNeeded()) | 72 if (exceptionState.throwIfNeeded()) |
| 89 return; | 73 return; |
| 90 v8SetReturnValue(info, info[1]); | 74 v8SetReturnValue(info, info[1]); |
| 91 } | 75 } |
| 92 | 76 |
| 93 void V8Node::removeChildMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) | 77 void V8Node::removeChildMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) |
|
haraken
2014/07/11 02:18:23
You can consider removing these custom bindings fo
kangil_
2014/07/11 02:39:42
Sure I will.
| |
| 94 { | 78 { |
| 95 v8::Handle<v8::Object> holder = info.Holder(); | 79 v8::Handle<v8::Object> holder = info.Holder(); |
| 96 Node* impl = V8Node::toNative(holder); | 80 Node* impl = V8Node::toNative(holder); |
| 97 | 81 |
| 98 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; | 82 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; |
| 99 | 83 |
| 100 ExceptionState exceptionState(ExceptionState::ExecutionContext, "removeChild ", "Node", info.Holder(), info.GetIsolate()); | 84 ExceptionState exceptionState(ExceptionState::ExecutionContext, "removeChild ", "Node", info.Holder(), info.GetIsolate()); |
| 101 Node* oldChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]); | 85 Node* oldChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]); |
| 102 impl->removeChild(oldChild, exceptionState); | 86 impl->removeChild(oldChild, exceptionState); |
| 103 if (exceptionState.throwIfNeeded()) | 87 if (exceptionState.throwIfNeeded()) |
| 104 return; | 88 return; |
| 105 v8SetReturnValue(info, info[0]); | 89 v8SetReturnValue(info, info[0]); |
| 106 } | 90 } |
| 107 | 91 |
| 108 void V8Node::appendChildMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) | |
| 109 { | |
| 110 ExceptionState exceptionState(ExceptionState::ExecutionContext, "appendChild ", "Node", info.Holder(), info.GetIsolate()); | |
| 111 if (UNLIKELY(info.Length() < 1)) { | |
| 112 throwMinimumArityTypeErrorForMethod("appendChild", "Node", 1, info.Lengt h(), info.GetIsolate()); | |
| 113 return; | |
| 114 } | |
| 115 Node* impl = V8Node::toNative(info.Holder()); | |
| 116 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; | |
| 117 Node* newChild; | |
| 118 { | |
| 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 } | |
| 128 impl->appendChild(newChild, exceptionState); | |
| 129 if (exceptionState.hadException()) { | |
| 130 exceptionState.throwIfNeeded(); | |
| 131 return; | |
| 132 } | |
| 133 v8SetReturnValue(info, info[0]); | |
| 134 } | |
| 135 | |
| 136 v8::Handle<v8::Object> wrap(Node* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 92 v8::Handle<v8::Object> wrap(Node* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
| 137 { | 93 { |
| 138 ASSERT(impl); | 94 ASSERT(impl); |
| 139 switch (impl->nodeType()) { | 95 switch (impl->nodeType()) { |
| 140 case Node::ELEMENT_NODE: | 96 case Node::ELEMENT_NODE: |
| 141 // For performance reasons, this is inlined from V8Element::wrap and mus t remain in sync. | 97 // For performance reasons, this is inlined from V8Element::wrap and mus t remain in sync. |
| 142 if (impl->isHTMLElement()) | 98 if (impl->isHTMLElement()) |
| 143 return wrap(toHTMLElement(impl), creationContext, isolate); | 99 return wrap(toHTMLElement(impl), creationContext, isolate); |
| 144 if (impl->isSVGElement()) | 100 if (impl->isSVGElement()) |
| 145 return wrap(toSVGElement(impl), creationContext, isolate); | 101 return wrap(toSVGElement(impl), creationContext, isolate); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 160 return wrap(toDocumentType(impl), creationContext, isolate); | 116 return wrap(toDocumentType(impl), creationContext, isolate); |
| 161 case Node::DOCUMENT_FRAGMENT_NODE: | 117 case Node::DOCUMENT_FRAGMENT_NODE: |
| 162 if (impl->isShadowRoot()) | 118 if (impl->isShadowRoot()) |
| 163 return wrap(toShadowRoot(impl), creationContext, isolate); | 119 return wrap(toShadowRoot(impl), creationContext, isolate); |
| 164 return wrap(toDocumentFragment(impl), creationContext, isolate); | 120 return wrap(toDocumentFragment(impl), creationContext, isolate); |
| 165 } | 121 } |
| 166 ASSERT_NOT_REACHED(); | 122 ASSERT_NOT_REACHED(); |
| 167 return V8Node::createWrapper(impl, creationContext, isolate); | 123 return V8Node::createWrapper(impl, creationContext, isolate); |
| 168 } | 124 } |
| 169 } // namespace WebCore | 125 } // namespace WebCore |
| OLD | NEW |