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.
5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
8 #include "V8TestInterfaceDocument.h"
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"
26 static void initializeScriptWrappableForInterface(TestInterfaceDocument* object)
28 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
29 ScriptWrappable::setTypeInfoInObject(object, &V8TestInterfaceDocument::wrapperTypeInfo);
34 } // namespace WebCore
36 void webCoreInitializeScriptWrappableForInterface(WebCore::TestInterfaceDocument* object)
38 WebCore::initializeScriptWrappableForInterface(object);
42 const WrapperTypeInfo V8TestInterfaceDocument::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceDocument::domTemplate, V8TestInterfaceDocument::derefObject, 0, V8TestInterfaceDocument::toEventTarget, 0, V8TestInterfaceDocument::installPerContextEnabledMethods, &V8Document::wrapperTypeInfo, WrapperTypeObjectPrototype, false };
44 namespace TestInterfaceDocumentV8Internal {
46 template <typename T> void V8_USE(T) { }
48 } // namespace TestInterfaceDocumentV8Internal
50 static void configureV8TestInterfaceDocumentTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
52 functionTemplate->ReadOnlyPrototype();
54 v8::Local<v8::Signature> defaultSignature;
55 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceDocument", V8Document::domTemplate(isolate), V8TestInterfaceDocument::internalFieldCount,
60 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTemplate->InstanceTemplate();
61 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTemplate->PrototypeTemplate();
63 // Custom toString template
64 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::current()->toStringTemplate());
67 v8::Handle<v8::FunctionTemplate> V8TestInterfaceDocument::domTemplate(v8::Isolate* isolate)
69 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
70 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(const_cast<WrapperTypeInfo*>(&wrapperTypeInfo));
71 if (!result.IsEmpty())
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);
81 bool V8TestInterfaceDocument::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
83 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
86 v8::Handle<v8::Object> V8TestInterfaceDocument::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
88 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
91 TestInterfaceDocument* V8TestInterfaceDocument::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
93 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Object>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0;
96 EventTarget* V8TestInterfaceDocument::toEventTarget(v8::Handle<v8::Object> object)
98 return toNative(object);
101 v8::Handle<v8::Object> wrap(TestInterfaceDocument* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
104 v8::Handle<v8::Object> wrapper = V8TestInterfaceDocument::createWrapper(impl, creationContext, isolate);
105 if (wrapper.IsEmpty())
107 DOMWrapperWorld* world = DOMWrapperWorld::current(isolate);
108 if (world->isMainWorld()) {
109 if (LocalFrame* frame = impl->frame())
110 frame->script().windowShell(world)->updateDocumentWrapper(wrapper);
115 v8::Handle<v8::Object> V8TestInterfaceDocument::createWrapper(PassRefPtr<TestInterfaceDocument> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
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);
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())
134 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
135 if (UNLIKELY(wrapper.IsEmpty()))
138 installPerContextEnabledProperties(wrapper, impl.get(), isolate);
139 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceDocument>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Dependent);
143 void V8TestInterfaceDocument::derefObject(void* object)
145 fromInternalPointer(object)->deref();
149 v8::Handle<v8::Value> toV8NoInline(TestInterfaceDocument* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
151 return toV8(impl, creationContext, isolate);
154 } // namespace WebCore