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::replaceChildMethodCustom(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, "replaceChil
d", "Node", info.Holder(), info.GetIsolate()); | |
69 Node* newChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]); | |
70 Node* oldChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[1]); | |
71 impl->replaceChild(newChild, oldChild, exceptionState); | |
72 if (exceptionState.throwIfNeeded()) | |
73 return; | |
74 v8SetReturnValue(info, info[1]); | |
75 } | |
76 | |
77 void V8Node::removeChildMethodCustom(const v8::FunctionCallbackInfo<v8::Value>&
info) | |
78 { | |
79 v8::Handle<v8::Object> holder = info.Holder(); | |
80 Node* impl = V8Node::toNative(holder); | |
81 | |
82 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; | |
83 | |
84 ExceptionState exceptionState(ExceptionState::ExecutionContext, "removeChild
", "Node", info.Holder(), info.GetIsolate()); | |
85 Node* oldChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]); | |
86 impl->removeChild(oldChild, exceptionState); | |
87 if (exceptionState.throwIfNeeded()) | |
88 return; | |
89 v8SetReturnValue(info, info[0]); | |
90 } | |
91 | |
92 v8::Handle<v8::Object> wrap(Node* impl, v8::Handle<v8::Object> creationContext,
v8::Isolate* isolate) | 61 v8::Handle<v8::Object> wrap(Node* impl, v8::Handle<v8::Object> creationContext,
v8::Isolate* isolate) |
93 { | 62 { |
94 ASSERT(impl); | 63 ASSERT(impl); |
95 switch (impl->nodeType()) { | 64 switch (impl->nodeType()) { |
96 case Node::ELEMENT_NODE: | 65 case Node::ELEMENT_NODE: |
97 // For performance reasons, this is inlined from V8Element::wrap and mus
t remain in sync. | 66 // For performance reasons, this is inlined from V8Element::wrap and mus
t remain in sync. |
98 if (impl->isHTMLElement()) | 67 if (impl->isHTMLElement()) |
99 return wrap(toHTMLElement(impl), creationContext, isolate); | 68 return wrap(toHTMLElement(impl), creationContext, isolate); |
100 if (impl->isSVGElement()) | 69 if (impl->isSVGElement()) |
101 return wrap(toSVGElement(impl), creationContext, isolate); | 70 return wrap(toSVGElement(impl), creationContext, isolate); |
(...skipping 14 matching lines...) Expand all Loading... |
116 return wrap(toDocumentType(impl), creationContext, isolate); | 85 return wrap(toDocumentType(impl), creationContext, isolate); |
117 case Node::DOCUMENT_FRAGMENT_NODE: | 86 case Node::DOCUMENT_FRAGMENT_NODE: |
118 if (impl->isShadowRoot()) | 87 if (impl->isShadowRoot()) |
119 return wrap(toShadowRoot(impl), creationContext, isolate); | 88 return wrap(toShadowRoot(impl), creationContext, isolate); |
120 return wrap(toDocumentFragment(impl), creationContext, isolate); | 89 return wrap(toDocumentFragment(impl), creationContext, isolate); |
121 } | 90 } |
122 ASSERT_NOT_REACHED(); | 91 ASSERT_NOT_REACHED(); |
123 return V8Node::createWrapper(impl, creationContext, isolate); | 92 return V8Node::createWrapper(impl, creationContext, isolate); |
124 } | 93 } |
125 } // namespace WebCore | 94 } // namespace WebCore |
OLD | NEW |