Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / tests / results / core / V8TestNode.cpp
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
6
7 #include "config.h"
8 #include "V8TestNode.h"
9
10 #include "bindings/core/v8/ExceptionState.h"
11 #include "bindings/core/v8/V8DOMConfiguration.h"
12 #include "bindings/core/v8/V8HiddenValue.h"
13 #include "bindings/core/v8/V8ObjectConstructor.h"
14 #include "core/dom/ContextFeatures.h"
15 #include "core/dom/Document.h"
16 #include "core/frame/LocalDOMWindow.h"
17 #include "platform/RuntimeEnabledFeatures.h"
18 #include "platform/TraceEvent.h"
19 #include "wtf/GetPtr.h"
20 #include "wtf/RefPtr.h"
21
22 namespace blink {
23
24 const WrapperTypeInfo V8TestNode::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestNode::domTemplate, V8TestNode::refObject, V8TestNode::derefObject, V8TestNode::trace, 0, V8TestNode::toEventTarget, 0, V8TestNode::installConditionallyEnabledMethods, V8TestNode::installConditionallyEnabledProperties, &V8Node::wrapperTypeInfo, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::NodeClassId, WrapperTypeInfo::Dependent, WrapperTypeInfo::WillBeGarbageCollectedObject };
25
26 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestNode.h.
27 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in
28 // bindings/core/v8/ScriptWrappable.h.
29 const WrapperTypeInfo& TestNode::s_wrapperTypeInfo = V8TestNode::wrapperTypeInfo;
30
31 namespace TestNodeV8Internal {
32
33 static void hrefAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
34 {
35     v8::Handle<v8::Object> holder = info.Holder();
36     TestNode* impl = V8TestNode::toImpl(holder);
37     v8SetReturnValueString(info, impl->href(), info.GetIsolate());
38 }
39
40 static void hrefAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
41 {
42     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
43     TestNodeV8Internal::hrefAttributeGetter(info);
44     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
45 }
46
47 static void hrefAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
48 {
49     v8::Handle<v8::Object> holder = info.Holder();
50     TestNode* impl = V8TestNode::toImpl(holder);
51     TOSTRING_VOID(V8StringResource<>, cppValue, v8Value);
52     impl->setHref(cppValue);
53 }
54
55 static void hrefAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
56 {
57     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
58     TestNodeV8Internal::hrefAttributeSetter(v8Value, info);
59     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
60 }
61
62 static void hrefThrowsAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
63 {
64     v8::Handle<v8::Object> holder = info.Holder();
65     TestNode* impl = V8TestNode::toImpl(holder);
66     v8SetReturnValueString(info, impl->hrefThrows(), info.GetIsolate());
67 }
68
69 static void hrefThrowsAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
70 {
71     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
72     TestNodeV8Internal::hrefThrowsAttributeGetter(info);
73     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
74 }
75
76 static void hrefThrowsAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
77 {
78     v8::Handle<v8::Object> holder = info.Holder();
79     ExceptionState exceptionState(ExceptionState::SetterContext, "hrefThrows", "TestNode", holder, info.GetIsolate());
80     TestNode* impl = V8TestNode::toImpl(holder);
81     TOSTRING_VOID(V8StringResource<>, cppValue, v8Value);
82     impl->setHrefThrows(cppValue, exceptionState);
83     exceptionState.throwIfNeeded();
84 }
85
86 static void hrefThrowsAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
87 {
88     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
89     TestNodeV8Internal::hrefThrowsAttributeSetter(v8Value, info);
90     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
91 }
92
93 static void hrefCallWithAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
94 {
95     v8::Handle<v8::Object> holder = info.Holder();
96     TestNode* impl = V8TestNode::toImpl(holder);
97     v8SetReturnValueString(info, impl->hrefCallWith(), info.GetIsolate());
98 }
99
100 static void hrefCallWithAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
101 {
102     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
103     TestNodeV8Internal::hrefCallWithAttributeGetter(info);
104     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
105 }
106
107 static void hrefCallWithAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
108 {
109     v8::Handle<v8::Object> holder = info.Holder();
110     TestNode* impl = V8TestNode::toImpl(holder);
111     TOSTRING_VOID(V8StringResource<>, cppValue, v8Value);
112     ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
113     impl->setHrefCallWith(executionContext, callingDOMWindow(info.GetIsolate()), enteredDOMWindow(info.GetIsolate()), cppValue);
114 }
115
116 static void hrefCallWithAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
117 {
118     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
119     TestNodeV8Internal::hrefCallWithAttributeSetter(v8Value, info);
120     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
121 }
122
123 static void hrefByteStringAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
124 {
125     v8::Handle<v8::Object> holder = info.Holder();
126     TestNode* impl = V8TestNode::toImpl(holder);
127     v8SetReturnValueString(info, impl->hrefByteString(), info.GetIsolate());
128 }
129
130 static void hrefByteStringAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
131 {
132     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
133     TestNodeV8Internal::hrefByteStringAttributeGetter(info);
134     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
135 }
136
137 static void hrefByteStringAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
138 {
139     v8::Handle<v8::Object> holder = info.Holder();
140     ExceptionState exceptionState(ExceptionState::SetterContext, "hrefByteString", "TestNode", holder, info.GetIsolate());
141     TestNode* impl = V8TestNode::toImpl(holder);
142     TONATIVE_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, toByteString(v8Value, exceptionState), exceptionState);
143     impl->setHrefByteString(cppValue);
144 }
145
146 static void hrefByteStringAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
147 {
148     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
149     TestNodeV8Internal::hrefByteStringAttributeSetter(v8Value, info);
150     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
151 }
152
153 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
154 {
155     RefPtrWillBeRawPtr<TestNode> impl = TestNode::create();
156     v8::Handle<v8::Object> wrapper = info.Holder();
157     impl->associateWithWrapper(&V8TestNode::wrapperTypeInfo, wrapper, info.GetIsolate());
158     v8SetReturnValue(info, wrapper);
159 }
160
161 } // namespace TestNodeV8Internal
162
163 static const V8DOMConfiguration::AttributeConfiguration V8TestNodeAttributes[] = {
164     {"href", TestNodeV8Internal::hrefAttributeGetterCallback, TestNodeV8Internal::hrefAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance},
165     {"hrefThrows", TestNodeV8Internal::hrefThrowsAttributeGetterCallback, TestNodeV8Internal::hrefThrowsAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance},
166     {"hrefCallWith", TestNodeV8Internal::hrefCallWithAttributeGetterCallback, TestNodeV8Internal::hrefCallWithAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance},
167     {"hrefByteString", TestNodeV8Internal::hrefByteStringAttributeGetterCallback, TestNodeV8Internal::hrefByteStringAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance},
168 };
169
170 void V8TestNode::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
171 {
172     TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "DOMConstructor");
173     if (!info.IsConstructCall()) {
174         V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::constructorNotCallableAsFunction("TestNode"));
175         return;
176     }
177
178     if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
179         v8SetReturnValue(info, info.Holder());
180         return;
181     }
182
183     TestNodeV8Internal::constructor(info);
184 }
185
186 static void installV8TestNodeTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
187 {
188     functionTemplate->ReadOnlyPrototype();
189
190     v8::Local<v8::Signature> defaultSignature;
191     defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestNode", V8Node::domTemplate(isolate), V8TestNode::internalFieldCount,
192         V8TestNodeAttributes, WTF_ARRAY_LENGTH(V8TestNodeAttributes),
193         0, 0,
194         0, 0,
195         isolate);
196     functionTemplate->SetCallHandler(V8TestNode::constructorCallback);
197     functionTemplate->SetLength(0);
198     v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceTemplate();
199     ALLOW_UNUSED_LOCAL(instanceTemplate);
200     v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->PrototypeTemplate();
201     ALLOW_UNUSED_LOCAL(prototypeTemplate);
202
203     // Custom toString template
204     functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
205 }
206
207 v8::Handle<v8::FunctionTemplate> V8TestNode::domTemplate(v8::Isolate* isolate)
208 {
209     return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestNodeTemplate);
210 }
211
212 bool V8TestNode::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
213 {
214     return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
215 }
216
217 v8::Handle<v8::Object> V8TestNode::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
218 {
219     return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
220 }
221
222 TestNode* V8TestNode::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
223 {
224     return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle<v8::Object>::Cast(value))->toImpl<TestNode>() : 0;
225 }
226
227 EventTarget* V8TestNode::toEventTarget(v8::Handle<v8::Object> object)
228 {
229     return toImpl(object);
230 }
231
232 void V8TestNode::refObject(ScriptWrappableBase* scriptWrappableBase)
233 {
234 #if !ENABLE(OILPAN)
235     scriptWrappableBase->toImpl<TestNode>()->ref();
236 #endif
237 }
238
239 void V8TestNode::derefObject(ScriptWrappableBase* scriptWrappableBase)
240 {
241 #if !ENABLE(OILPAN)
242     scriptWrappableBase->toImpl<TestNode>()->deref();
243 #endif
244 }
245
246 template<>
247 v8::Handle<v8::Value> toV8NoInline(TestNode* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
248 {
249     return toV8(impl, creationContext, isolate);
250 }
251
252 } // namespace blink