| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 return; | 100 return; |
| 101 } | 101 } |
| 102 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, stringArg, info[0])
; | 102 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, stringArg, info[0])
; |
| 103 RefPtr<TestInterfaceNamedConstructor2> impl = TestInterfaceNamedConstructor2
::createForJSConstructor(*document, stringArg); | 103 RefPtr<TestInterfaceNamedConstructor2> impl = TestInterfaceNamedConstructor2
::createForJSConstructor(*document, stringArg); |
| 104 v8::Handle<v8::Object> wrapper = info.Holder(); | 104 v8::Handle<v8::Object> wrapper = info.Holder(); |
| 105 | 105 |
| 106 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceNamedConstructor2>(i
mpl.release(), &V8TestInterfaceNamedConstructor2Constructor::wrapperTypeInfo, wr
apper, info.GetIsolate(), WrapperConfiguration::Dependent); | 106 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceNamedConstructor2>(i
mpl.release(), &V8TestInterfaceNamedConstructor2Constructor::wrapperTypeInfo, wr
apper, info.GetIsolate(), WrapperConfiguration::Dependent); |
| 107 v8SetReturnValue(info, wrapper); | 107 v8SetReturnValue(info, wrapper); |
| 108 } | 108 } |
| 109 | 109 |
| 110 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructor2Constructor::do
mTemplate(v8::Isolate* isolate, WrapperWorldType currentWorldType) | 110 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructor2Constructor::do
mTemplate(v8::Isolate* isolate) |
| 111 { | 111 { |
| 112 static int domTemplateKey; // This address is used for a key to look up the
dom template. | 112 static int domTemplateKey; // This address is used for a key to look up the
dom template. |
| 113 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 113 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 114 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(currentWo
rldType, &domTemplateKey); | 114 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(&domTempl
ateKey); |
| 115 if (!result.IsEmpty()) | 115 if (!result.IsEmpty()) |
| 116 return result; | 116 return result; |
| 117 | 117 |
| 118 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | 118 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
| 119 v8::EscapableHandleScope scope(isolate); | 119 v8::EscapableHandleScope scope(isolate); |
| 120 result = v8::FunctionTemplate::New(isolate, V8TestInterfaceNamedConstructor2
ConstructorCallback); | 120 result = v8::FunctionTemplate::New(isolate, V8TestInterfaceNamedConstructor2
ConstructorCallback); |
| 121 | 121 |
| 122 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); | 122 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); |
| 123 instanceTemplate->SetInternalFieldCount(V8TestInterfaceNamedConstructor2::in
ternalFieldCount); | 123 instanceTemplate->SetInternalFieldCount(V8TestInterfaceNamedConstructor2::in
ternalFieldCount); |
| 124 result->SetClassName(v8AtomicString(isolate, "TestInterfaceNamedConstructor2
")); | 124 result->SetClassName(v8AtomicString(isolate, "TestInterfaceNamedConstructor2
")); |
| 125 result->Inherit(V8TestInterfaceNamedConstructor2::domTemplate(isolate, curre
ntWorldType)); | 125 result->Inherit(V8TestInterfaceNamedConstructor2::domTemplate(isolate)); |
| 126 data->setDOMTemplate(currentWorldType, &domTemplateKey, result); | 126 data->setDOMTemplate(&domTemplateKey, result); |
| 127 | |
| 128 return scope.Escape(result); | 127 return scope.Escape(result); |
| 129 } | 128 } |
| 130 | 129 |
| 131 static void configureV8TestInterfaceNamedConstructor2Template(v8::Handle<v8::Fun
ctionTemplate> functionTemplate, v8::Isolate* isolate, WrapperWorldType currentW
orldType) | 130 static void configureV8TestInterfaceNamedConstructor2Template(v8::Handle<v8::Fun
ctionTemplate> functionTemplate, v8::Isolate* isolate) |
| 132 { | 131 { |
| 133 functionTemplate->ReadOnlyPrototype(); | 132 functionTemplate->ReadOnlyPrototype(); |
| 134 | 133 |
| 135 v8::Local<v8::Signature> defaultSignature; | 134 v8::Local<v8::Signature> defaultSignature; |
| 136 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestInterfaceNamedConstructor2", v8::Local<v8::FunctionTemplate>(), V8Test
InterfaceNamedConstructor2::internalFieldCount, | 135 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestInterfaceNamedConstructor2", v8::Local<v8::FunctionTemplate>(), V8Test
InterfaceNamedConstructor2::internalFieldCount, |
| 137 0, 0, | 136 0, 0, |
| 138 0, 0, | 137 0, 0, |
| 139 0, 0, | 138 0, 0, |
| 140 isolate, currentWorldType); | 139 isolate); |
| 141 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); | 140 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); |
| 142 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); | 141 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); |
| 143 | 142 |
| 144 // Custom toString template | 143 // Custom toString template |
| 145 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData:
:current()->toStringTemplate()); | 144 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData:
:current()->toStringTemplate()); |
| 146 } | 145 } |
| 147 | 146 |
| 148 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructor2::domTemplate(v
8::Isolate* isolate, WrapperWorldType currentWorldType) | 147 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructor2::domTemplate(v
8::Isolate* isolate) |
| 149 { | 148 { |
| 150 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 149 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 151 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&wrapperTypeInfo); | 150 V8PerIsolateData::TemplateMap::iterator result = data->templateMap().find(&w
rapperTypeInfo); |
| 152 if (result != data->templateMap(currentWorldType).end()) | 151 if (result != data->templateMap().end()) |
| 153 return result->value.newLocal(isolate); | 152 return result->value.newLocal(isolate); |
| 154 | 153 |
| 155 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | 154 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
| 156 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V
8ObjectConstructor::isValidConstructorMode); | 155 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V
8ObjectConstructor::isValidConstructorMode); |
| 157 configureV8TestInterfaceNamedConstructor2Template(templ, isolate, currentWor
ldType); | 156 configureV8TestInterfaceNamedConstructor2Template(templ, isolate); |
| 158 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); | 157 data->templateMap().add(&wrapperTypeInfo, UnsafePersistent<v8::FunctionTempl
ate>(isolate, templ)); |
| 159 return templ; | 158 return templ; |
| 160 } | 159 } |
| 161 | 160 |
| 162 bool V8TestInterfaceNamedConstructor2::hasInstance(v8::Handle<v8::Value> jsValue
, v8::Isolate* isolate) | 161 bool V8TestInterfaceNamedConstructor2::hasInstance(v8::Handle<v8::Value> jsValue
, v8::Isolate* isolate) |
| 163 { | 162 { |
| 164 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e); | 163 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e); |
| 165 } | 164 } |
| 166 | 165 |
| 167 v8::Handle<v8::Object> V8TestInterfaceNamedConstructor2::findInstanceInPrototype
Chain(v8::Handle<v8::Value> jsValue, v8::Isolate* isolate) | 166 v8::Handle<v8::Object> V8TestInterfaceNamedConstructor2::findInstanceInPrototype
Chain(v8::Handle<v8::Value> jsValue, v8::Isolate* isolate) |
| 168 { | 167 { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 199 fromInternalPointer(object)->deref(); | 198 fromInternalPointer(object)->deref(); |
| 200 } | 199 } |
| 201 | 200 |
| 202 template<> | 201 template<> |
| 203 v8::Handle<v8::Value> toV8NoInline(TestInterfaceNamedConstructor2* impl, v8::Han
dle<v8::Object> creationContext, v8::Isolate* isolate) | 202 v8::Handle<v8::Value> toV8NoInline(TestInterfaceNamedConstructor2* impl, v8::Han
dle<v8::Object> creationContext, v8::Isolate* isolate) |
| 204 { | 203 { |
| 205 return toV8(impl, creationContext, isolate); | 204 return toV8(impl, creationContext, isolate); |
| 206 } | 205 } |
| 207 | 206 |
| 208 } // namespace WebCore | 207 } // namespace WebCore |
| OLD | NEW |