1ae803dcfb9059f340355cf5d4c9d46a886d9f7a
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / tests / results / V8TestInterfaceDocument.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 "V8TestInterfaceDocument.h"
9
10 #include "RuntimeEnabledFeatures.h"
11 #include "bindings/v8/ExceptionState.h"
12 #include "bindings/v8/ScriptController.h"
13 #include "bindings/v8/V8DOMConfiguration.h"
14 #include "bindings/v8/V8HiddenValue.h"
15 #include "bindings/v8/V8ObjectConstructor.h"
16 #include "bindings/v8/V8WindowShell.h"
17 #include "core/dom/ContextFeatures.h"
18 #include "core/dom/Document.h"
19 #include "core/frame/LocalFrame.h"
20 #include "platform/TraceEvent.h"
21 #include "wtf/GetPtr.h"
22 #include "wtf/RefPtr.h"
23
24 namespace WebCore {
25
26 static void initializeScriptWrappableForInterface(TestInterfaceDocument* object)
27 {
28     if (ScriptWrappable::wrapperCanBeStoredInObject(object))
29         ScriptWrappable::setTypeInfoInObject(object, &V8TestInterfaceDocument::wrapperTypeInfo);
30     else
31         ASSERT_NOT_REACHED();
32 }
33
34 } // namespace WebCore
35
36 void webCoreInitializeScriptWrappableForInterface(WebCore::TestInterfaceDocument* object)
37 {
38     WebCore::initializeScriptWrappableForInterface(object);
39 }
40
41 namespace WebCore {
42 const WrapperTypeInfo V8TestInterfaceDocument::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceDocument::domTemplate, V8TestInterfaceDocument::derefObject, 0, V8TestInterfaceDocument::toEventTarget, 0, V8TestInterfaceDocument::installPerContextEnabledMethods, &V8Document::wrapperTypeInfo, WrapperTypeObjectPrototype, false };
43
44 namespace TestInterfaceDocumentV8Internal {
45
46 template <typename T> void V8_USE(T) { }
47
48 } // namespace TestInterfaceDocumentV8Internal
49
50 static void configureV8TestInterfaceDocumentTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
51 {
52     functionTemplate->ReadOnlyPrototype();
53
54     v8::Local<v8::Signature> defaultSignature;
55     defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceDocument", V8Document::domTemplate(isolate), V8TestInterfaceDocument::internalFieldCount,
56         0, 0,
57         0, 0,
58         0, 0,
59         isolate);
60     v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTemplate->InstanceTemplate();
61     v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTemplate->PrototypeTemplate();
62
63     // Custom toString template
64     functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::current()->toStringTemplate());
65 }
66
67 v8::Handle<v8::FunctionTemplate> V8TestInterfaceDocument::domTemplate(v8::Isolate* isolate)
68 {
69     V8PerIsolateData* data = V8PerIsolateData::from(isolate);
70     v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(const_cast<WrapperTypeInfo*>(&wrapperTypeInfo));
71     if (!result.IsEmpty())
72         return result;
73
74     TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
75     result = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidConstructorMode);
76     configureV8TestInterfaceDocumentTemplate(result, isolate);
77     data->setDOMTemplate(const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), result);
78     return result;
79 }
80
81 bool V8TestInterfaceDocument::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
82 {
83     return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
84 }
85
86 v8::Handle<v8::Object> V8TestInterfaceDocument::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
87 {
88     return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
89 }
90
91 TestInterfaceDocument* V8TestInterfaceDocument::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
92 {
93     return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Object>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0;
94 }
95
96 EventTarget* V8TestInterfaceDocument::toEventTarget(v8::Handle<v8::Object> object)
97 {
98     return toNative(object);
99 }
100
101 v8::Handle<v8::Object> wrap(TestInterfaceDocument* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
102 {
103     ASSERT(impl);
104     v8::Handle<v8::Object> wrapper = V8TestInterfaceDocument::createWrapper(impl, creationContext, isolate);
105     if (wrapper.IsEmpty())
106         return wrapper;
107     DOMWrapperWorld* world = DOMWrapperWorld::current(isolate);
108     if (world->isMainWorld()) {
109         if (LocalFrame* frame = impl->frame())
110             frame->script().windowShell(world)->updateDocumentWrapper(wrapper);
111     }
112     return wrapper;
113 }
114
115 v8::Handle<v8::Object> V8TestInterfaceDocument::createWrapper(PassRefPtr<TestInterfaceDocument> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
116 {
117     ASSERT(impl);
118     ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceDocument>(impl.get(), isolate));
119     if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
120         const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObject(impl.get());
121         // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
122         // the same object de-ref functions, though, so use that as the basis of the check.
123         RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
124     }
125
126     if (LocalFrame* frame = impl->frame()) {
127         if (frame->script().initializeMainWorld()) {
128             // initializeMainWorld may have created a wrapper for the object, retry from the start.
129             v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapper<V8TestInterfaceDocument>(impl.get(), isolate);
130             if (!wrapper.IsEmpty())
131                 return wrapper;
132         }
133     }
134     v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
135     if (UNLIKELY(wrapper.IsEmpty()))
136         return wrapper;
137
138     installPerContextEnabledProperties(wrapper, impl.get(), isolate);
139     V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceDocument>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Dependent);
140     return wrapper;
141 }
142
143 void V8TestInterfaceDocument::derefObject(void* object)
144 {
145     fromInternalPointer(object)->deref();
146 }
147
148 template<>
149 v8::Handle<v8::Value> toV8NoInline(TestInterfaceDocument* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
150 {
151     return toV8(impl, creationContext, isolate);
152 }
153
154 } // namespace WebCore