107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch// Copyright 2014 The Chromium Authors. All rights reserved.
207a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch// Use of this source code is governed by a BSD-style license that can be
307a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch// found in the LICENSE file.
407a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch
507a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch// This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "config.h"
85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "V8TestNode.h"
95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
10197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/ExceptionState.h"
11197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/V8DOMConfiguration.h"
12197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/V8HiddenValue.h"
13197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/V8ObjectConstructor.h"
1453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/dom/ContextFeatures.h"
15e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)#include "core/dom/Document.h"
1676c265b59aa821ccbf8c75ab2bb0d036e97d2956Torne (Richard Coles)#include "core/frame/LocalDOMWindow.h"
1776c265b59aa821ccbf8c75ab2bb0d036e97d2956Torne (Richard Coles)#include "platform/RuntimeEnabledFeatures.h"
181e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "platform/TraceEvent.h"
1909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#include "wtf/GetPtr.h"
2009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#include "wtf/RefPtr.h"
215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
22c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink {
235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
247242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucciconst WrapperTypeInfo V8TestNode::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestNode::domTemplate, V8TestNode::refObject, V8TestNode::derefObject, V8TestNode::createPersistentHandle, 0, V8TestNode::toEventTarget, 0, V8TestNode::installConditionallyEnabledMethods, V8TestNode::installConditionallyEnabledProperties, &V8Node::wrapperTypeInfo, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::NodeClassId, WrapperTypeInfo::Dependent, WrapperTypeInfo::WillBeGarbageCollectedObject };
255267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
267242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci// This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestNode.h.
277242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci// For details, see the comment of DEFINE_WRAPPERTYPEINFO in
287242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci// bindings/core/v8/ScriptWrappable.h.
297242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucciconst WrapperTypeInfo& TestNode::s_wrapperTypeInfo = V8TestNode::wrapperTypeInfo;
305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)namespace TestNodeV8Internal {
325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)template <typename T> void V8_USE(T) { }
345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
3519cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles)static void hrefAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
361e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles){
3707a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    v8::Handle<v8::Object> holder = info.Holder();
387242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    TestNode* impl = V8TestNode::toImpl(holder);
3943e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles)    v8SetReturnValueString(info, impl->href(), info.GetIsolate());
401e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)}
411e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)
4219cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles)static void hrefAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
431e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles){
44197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
4519cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles)    TestNodeV8Internal::hrefAttributeGetter(info);
46197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
471e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)}
481e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)
4907a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochstatic void hrefAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
501e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles){
5107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    v8::Handle<v8::Object> holder = info.Holder();
527242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    TestNode* impl = V8TestNode::toImpl(holder);
536f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch    TOSTRING_VOID(V8StringResource<>, cppValue, v8Value);
5443e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles)    impl->setHref(cppValue);
551e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)}
561e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)
5707a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochstatic void hrefAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
581e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles){
59197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
6007a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    TestNodeV8Internal::hrefAttributeSetter(v8Value, info);
61197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
621e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)}
631e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)
6419cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles)static void hrefThrowsAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
651e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles){
6607a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    v8::Handle<v8::Object> holder = info.Holder();
677242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    TestNode* impl = V8TestNode::toImpl(holder);
6843e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles)    v8SetReturnValueString(info, impl->hrefThrows(), info.GetIsolate());
691e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)}
701e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)
7119cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles)static void hrefThrowsAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
721e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles){
73197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
7419cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles)    TestNodeV8Internal::hrefThrowsAttributeGetter(info);
75197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
761e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)}
771e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)
7807a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochstatic void hrefThrowsAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
791e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles){
8007a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    v8::Handle<v8::Object> holder = info.Holder();
8107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    ExceptionState exceptionState(ExceptionState::SetterContext, "hrefThrows", "TestNode", holder, info.GetIsolate());
827242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    TestNode* impl = V8TestNode::toImpl(holder);
836f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch    TOSTRING_VOID(V8StringResource<>, cppValue, v8Value);
8443e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles)    impl->setHrefThrows(cppValue, exceptionState);
8551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    exceptionState.throwIfNeeded();
861e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)}
871e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)
8807a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochstatic void hrefThrowsAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
891e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles){
90197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
9107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    TestNodeV8Internal::hrefThrowsAttributeSetter(v8Value, info);
92197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
9309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)}
9409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
9509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)static void hrefCallWithAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
9609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){
9707a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    v8::Handle<v8::Object> holder = info.Holder();
987242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    TestNode* impl = V8TestNode::toImpl(holder);
9943e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles)    v8SetReturnValueString(info, impl->hrefCallWith(), info.GetIsolate());
10009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)}
10109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
10209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)static void hrefCallWithAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
10309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){
104197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
10509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    TestNodeV8Internal::hrefCallWithAttributeGetter(info);
106197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
10709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)}
10809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
10907a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochstatic void hrefCallWithAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
11009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){
11107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    v8::Handle<v8::Object> holder = info.Holder();
1127242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    TestNode* impl = V8TestNode::toImpl(holder);
1136f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch    TOSTRING_VOID(V8StringResource<>, cppValue, v8Value);
114197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
115197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    impl->setHrefCallWith(executionContext, callingDOMWindow(info.GetIsolate()), enteredDOMWindow(info.GetIsolate()), cppValue);
11609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)}
11709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
11807a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochstatic void hrefCallWithAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
11909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){
120197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
12107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    TestNodeV8Internal::hrefCallWithAttributeSetter(v8Value, info);
122197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
123197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}
124197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch
125197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstatic void hrefByteStringAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
126197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{
127197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    v8::Handle<v8::Object> holder = info.Holder();
1287242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    TestNode* impl = V8TestNode::toImpl(holder);
129197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    v8SetReturnValueString(info, impl->hrefByteString(), info.GetIsolate());
130197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}
131197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch
132197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstatic void hrefByteStringAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
133197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{
134197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
135197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    TestNodeV8Internal::hrefByteStringAttributeGetter(info);
136197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
137197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}
138197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch
139197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstatic void hrefByteStringAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
140197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{
141197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    v8::Handle<v8::Object> holder = info.Holder();
142197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    ExceptionState exceptionState(ExceptionState::SetterContext, "hrefByteString", "TestNode", holder, info.GetIsolate());
1437242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    TestNode* impl = V8TestNode::toImpl(holder);
144197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    TONATIVE_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, toByteString(v8Value, exceptionState), exceptionState);
145197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    impl->setHrefByteString(cppValue);
146197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}
147197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch
148197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstatic void hrefByteStringAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
149197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{
150197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
151197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    TestNodeV8Internal::hrefByteStringAttributeSetter(v8Value, info);
152197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
1531e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)}
1541e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)
15519cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles)static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
156926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
157d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles)    RefPtrWillBeRawPtr<TestNode> impl = TestNode::create();
15807a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    v8::Handle<v8::Object> wrapper = info.Holder();
1597242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    impl->associateWithWrapper(&V8TestNode::wrapperTypeInfo, wrapper, info.GetIsolate());
160a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    v8SetReturnValue(info, wrapper);
161926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
162926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
1635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} // namespace TestNodeV8Internal
1645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1651e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)static const V8DOMConfiguration::AttributeConfiguration V8TestNodeAttributes[] = {
166c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    {"href", TestNodeV8Internal::hrefAttributeGetterCallback, TestNodeV8Internal::hrefAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance},
167c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    {"hrefThrows", TestNodeV8Internal::hrefThrowsAttributeGetterCallback, TestNodeV8Internal::hrefThrowsAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance},
168c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    {"hrefCallWith", TestNodeV8Internal::hrefCallWithAttributeGetterCallback, TestNodeV8Internal::hrefCallWithAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance},
169c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    {"hrefByteString", TestNodeV8Internal::hrefByteStringAttributeGetterCallback, TestNodeV8Internal::hrefByteStringAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance},
1701e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)};
1711e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)
17219cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles)void V8TestNode::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
1735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
174197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "DOMConstructor");
17519cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles)    if (!info.IsConstructCall()) {
176c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)        V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("TestNode"), info.GetIsolate());
17793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        return;
17893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    }
1795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
180a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch    if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
181a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)        v8SetReturnValue(info, info.Holder());
18293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        return;
18393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    }
1845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
18519cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles)    TestNodeV8Internal::constructor(info);
1865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
1875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
188197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstatic void installV8TestNodeTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
1895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
19051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    functionTemplate->ReadOnlyPrototype();
1915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    v8::Local<v8::Signature> defaultSignature;
193d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestNode", V8Node::domTemplate(isolate), V8TestNode::internalFieldCount,
1941e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)        V8TestNodeAttributes, WTF_ARRAY_LENGTH(V8TestNodeAttributes),
19519cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles)        0, 0,
19651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)        0, 0,
197d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)        isolate);
19851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    functionTemplate->SetCallHandler(V8TestNode::constructorCallback);
19951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    functionTemplate->SetLength(0);
200f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu    v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
201f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu    v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
2025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
2035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Custom toString template
204a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch    functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
2055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
2065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
207d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)v8::Handle<v8::FunctionTemplate> V8TestNode::domTemplate(v8::Isolate* isolate)
2085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
209197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestNodeTemplate);
2105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
2115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
21207a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochbool V8TestNode::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
2135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
21407a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
215d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)}
216d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)
21707a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochv8::Handle<v8::Object> V8TestNode::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
218d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){
21907a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
220d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)}
221d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)
2227242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano TucciTestNode* V8TestNode::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
223d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){
2247242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle<v8::Object>::Cast(value))->toImpl<TestNode>() : 0;
2255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
2265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
227926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)EventTarget* V8TestNode::toEventTarget(v8::Handle<v8::Object> object)
2285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
2297242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    return toImpl(object);
230926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
2315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
2325d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)
2337242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tuccivoid V8TestNode::refObject(ScriptWrappableBase* internalPointer)
234926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
2357242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci#if !ENABLE(OILPAN)
2367242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    internalPointer->toImpl<TestNode>()->ref();
2377242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci#endif
2385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
239c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles)
240e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)void V8TestNode::derefObject(ScriptWrappableBase* internalPointer)
2415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
242d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles)#if !ENABLE(OILPAN)
2437242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    internalPointer->toImpl<TestNode>()->deref();
2447242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci#endif
2457242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci}
2467242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci
2477242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano TucciWrapperPersistentNode* V8TestNode::createPersistentHandle(ScriptWrappableBase* internalPointer)
2487242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci{
2497242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci#if ENABLE(OILPAN)
2507242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    return WrapperPersistent<TestNode>::create(internalPointer->toImpl<TestNode>());
2517242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci#else
2527242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    ASSERT_NOT_REACHED();
2537242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    return 0;
2547242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci#endif
2555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
2565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
25751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)template<>
25851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)v8::Handle<v8::Value> toV8NoInline(TestNode* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
25951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){
26051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    return toV8(impl, creationContext, isolate);
26151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)}
26251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)
263c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink
264