| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); | 128 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); |
| 129 instanceTemplate->SetInternalFieldCount(V8TestInterfaceNamedConstructor::int
ernalFieldCount); | 129 instanceTemplate->SetInternalFieldCount(V8TestInterfaceNamedConstructor::int
ernalFieldCount); |
| 130 result->SetClassName(v8::String::NewFromUtf8(isolate, "TestInterfaceNamedCon
structor", v8::String::kInternalizedString)); | 130 result->SetClassName(v8::String::NewFromUtf8(isolate, "TestInterfaceNamedCon
structor", v8::String::kInternalizedString)); |
| 131 result->Inherit(V8TestInterfaceNamedConstructor::domTemplate(isolate, curren
tWorldType)); | 131 result->Inherit(V8TestInterfaceNamedConstructor::domTemplate(isolate, curren
tWorldType)); |
| 132 data->setPrivateTemplate(currentWorldType, &privateTemplateUniqueKey, result
); | 132 data->setPrivateTemplate(currentWorldType, &privateTemplateUniqueKey, result
); |
| 133 | 133 |
| 134 return scope.Escape(result); | 134 return scope.Escape(result); |
| 135 } | 135 } |
| 136 | 136 |
| 137 static v8::Handle<v8::FunctionTemplate> ConfigureV8TestInterfaceNamedConstructor
Template(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate
, WrapperWorldType currentWorldType) | 137 static void configureV8TestInterfaceNamedConstructorTemplate(v8::Handle<v8::Func
tionTemplate> functionTemplate, v8::Isolate* isolate, WrapperWorldType currentWo
rldType) |
| 138 { | 138 { |
| 139 functionTemplate->ReadOnlyPrototype(); | 139 functionTemplate->ReadOnlyPrototype(); |
| 140 | 140 |
| 141 v8::Local<v8::Signature> defaultSignature; | 141 v8::Local<v8::Signature> defaultSignature; |
| 142 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestInterfaceNamedConstructor", v8::Local<v8::FunctionTemplate>(), V8TestI
nterfaceNamedConstructor::internalFieldCount, | 142 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestInterfaceNamedConstructor", v8::Local<v8::FunctionTemplate>(), V8TestI
nterfaceNamedConstructor::internalFieldCount, |
| 143 0, 0, | 143 0, 0, |
| 144 0, 0, | 144 0, 0, |
| 145 0, 0, | 145 0, 0, |
| 146 isolate, currentWorldType); | 146 isolate, currentWorldType); |
| 147 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); | 147 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); |
| 148 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); | 148 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); |
| 149 | 149 |
| 150 // Custom toString template | 150 // Custom toString template |
| 151 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::Strin
g::kInternalizedString), V8PerIsolateData::current()->toStringTemplate()); | 151 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::Strin
g::kInternalizedString), V8PerIsolateData::current()->toStringTemplate()); |
| 152 return functionTemplate; | |
| 153 } | 152 } |
| 154 | 153 |
| 155 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructor::domTemplate(v8
::Isolate* isolate, WrapperWorldType currentWorldType) | 154 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructor::domTemplate(v8
::Isolate* isolate, WrapperWorldType currentWorldType) |
| 156 { | 155 { |
| 157 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 156 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 158 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&wrapperTypeInfo); | 157 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&wrapperTypeInfo); |
| 159 if (result != data->templateMap(currentWorldType).end()) | 158 if (result != data->templateMap(currentWorldType).end()) |
| 160 return result->value.newLocal(isolate); | 159 return result->value.newLocal(isolate); |
| 161 | 160 |
| 162 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | 161 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
| 163 v8::EscapableHandleScope handleScope(isolate); | 162 v8::EscapableHandleScope handleScope(isolate); |
| 164 v8::Local<v8::FunctionTemplate> templ = | 163 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V
8ObjectConstructor::isValidConstructorMode); |
| 165 ConfigureV8TestInterfaceNamedConstructorTemplate(data->rawDOMTemplate(&w
rapperTypeInfo, currentWorldType), isolate, currentWorldType); | 164 configureV8TestInterfaceNamedConstructorTemplate(templ, isolate, currentWorl
dType); |
| 166 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); | 165 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); |
| 167 return handleScope.Escape(templ); | 166 return handleScope.Escape(templ); |
| 168 } | 167 } |
| 169 | 168 |
| 170 bool V8TestInterfaceNamedConstructor::hasInstance(v8::Handle<v8::Value> jsValue,
v8::Isolate* isolate, WrapperWorldType currentWorldType) | 169 bool V8TestInterfaceNamedConstructor::hasInstance(v8::Handle<v8::Value> jsValue,
v8::Isolate* isolate, WrapperWorldType currentWorldType) |
| 171 { | 170 { |
| 172 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, currentWorldType); | 171 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, currentWorldType); |
| 173 } | 172 } |
| 174 | 173 |
| 175 bool V8TestInterfaceNamedConstructor::hasInstanceInAnyWorld(v8::Handle<v8::Value
> jsValue, v8::Isolate* isolate) | 174 bool V8TestInterfaceNamedConstructor::hasInstanceInAnyWorld(v8::Handle<v8::Value
> jsValue, v8::Isolate* isolate) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 fromInternalPointer(object)->deref(); | 208 fromInternalPointer(object)->deref(); |
| 210 } | 209 } |
| 211 | 210 |
| 212 template<> | 211 template<> |
| 213 v8::Handle<v8::Value> toV8NoInline(TestInterfaceNamedConstructor* impl, v8::Hand
le<v8::Object> creationContext, v8::Isolate* isolate) | 212 v8::Handle<v8::Value> toV8NoInline(TestInterfaceNamedConstructor* impl, v8::Hand
le<v8::Object> creationContext, v8::Isolate* isolate) |
| 214 { | 213 { |
| 215 return toV8(impl, creationContext, isolate); | 214 return toV8(impl, creationContext, isolate); |
| 216 } | 215 } |
| 217 | 216 |
| 218 } // namespace WebCore | 217 } // namespace WebCore |
| OLD | NEW |