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 "bindings/v8/ExceptionState.h" 11 #include "bindings/v8/ScriptController.h" 12 #include "bindings/v8/V8DOMConfiguration.h" 13 #include "bindings/v8/V8HiddenValue.h" 14 #include "bindings/v8/V8ObjectConstructor.h" 15 #include "bindings/v8/V8WindowShell.h" 16 #include "core/dom/ContextFeatures.h" 17 #include "core/dom/Document.h" 18 #include "core/frame/LocalFrame.h" 19 #include "platform/RuntimeEnabledFeatures.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::fromObject(object)->setTypeInfo(&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, WillBeGarbageCollectedObject }; 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> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate(); 61 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate(); 62 63 // Custom toString template 64 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate()); 65 } 66 67 v8::Handle<v8::FunctionTemplate> V8TestInterfaceDocument::domTemplate(v8::Isolate* isolate) 68 { 69 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), configureV8TestInterfaceDocumentTemplate); 70 } 71 72 bool V8TestInterfaceDocument::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) 73 { 74 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value); 75 } 76 77 v8::Handle<v8::Object> V8TestInterfaceDocument::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) 78 { 79 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value); 80 } 81 82 TestInterfaceDocument* V8TestInterfaceDocument::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value) 83 { 84 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Object>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0; 85 } 86 87 EventTarget* V8TestInterfaceDocument::toEventTarget(v8::Handle<v8::Object> object) 88 { 89 return toNative(object); 90 } 91 92 v8::Handle<v8::Object> wrap(TestInterfaceDocument* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 93 { 94 ASSERT(impl); 95 v8::Handle<v8::Object> wrapper = V8TestInterfaceDocument::createWrapper(impl, creationContext, isolate); 96 if (wrapper.IsEmpty()) 97 return wrapper; 98 DOMWrapperWorld& world = DOMWrapperWorld::current(isolate); 99 if (world.isMainWorld()) { 100 if (LocalFrame* frame = impl->frame()) 101 frame->script().windowShell(world)->updateDocumentWrapper(wrapper); 102 } 103 return wrapper; 104 } 105 106 v8::Handle<v8::Object> V8TestInterfaceDocument::createWrapper(PassRefPtrWillBeRawPtr<TestInterfaceDocument> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 107 { 108 ASSERT(impl); 109 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceDocument>(impl.get(), isolate)); 110 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { 111 const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo(); 112 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have 113 // the same object de-ref functions, though, so use that as the basis of the check. 114 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction); 115 } 116 117 if (LocalFrame* frame = impl->frame()) { 118 if (frame->script().initializeMainWorld()) { 119 // initializeMainWorld may have created a wrapper for the object, retry from the start. 120 v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapper<V8TestInterfaceDocument>(impl.get(), isolate); 121 if (!wrapper.IsEmpty()) 122 return wrapper; 123 } 124 } 125 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate); 126 if (UNLIKELY(wrapper.IsEmpty())) 127 return wrapper; 128 129 installPerContextEnabledProperties(wrapper, impl.get(), isolate); 130 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceDocument>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Dependent); 131 return wrapper; 132 } 133 134 void V8TestInterfaceDocument::derefObject(void* object) 135 { 136 #if !ENABLE(OILPAN) 137 fromInternalPointer(object)->deref(); 138 #endif // !ENABLE(OILPAN) 139 } 140 141 template<> 142 v8::Handle<v8::Value> toV8NoInline(TestInterfaceDocument* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 143 { 144 return toV8(impl, creationContext, isolate); 145 } 146 147 } // namespace WebCore 148