| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 } | 150 } |
| 151 | 151 |
| 152 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { | 152 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { |
| 153 v8SetReturnValue(info, info.Holder()); | 153 v8SetReturnValue(info, info.Holder()); |
| 154 return; | 154 return; |
| 155 } | 155 } |
| 156 | 156 |
| 157 TestNodeV8Internal::constructor(info); | 157 TestNodeV8Internal::constructor(info); |
| 158 } | 158 } |
| 159 | 159 |
| 160 static v8::Handle<v8::FunctionTemplate> ConfigureV8TestNodeTemplate(v8::Handle<v
8::FunctionTemplate> functionTemplate, v8::Isolate* isolate, WrapperWorldType cu
rrentWorldType) | 160 static void configureV8TestNodeTemplate(v8::Handle<v8::FunctionTemplate> functio
nTemplate, v8::Isolate* isolate, WrapperWorldType currentWorldType) |
| 161 { | 161 { |
| 162 functionTemplate->ReadOnlyPrototype(); | 162 functionTemplate->ReadOnlyPrototype(); |
| 163 | 163 |
| 164 v8::Local<v8::Signature> defaultSignature; | 164 v8::Local<v8::Signature> defaultSignature; |
| 165 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestNode", V8Node::domTemplate(isolate, currentWorldType), V8TestNode::int
ernalFieldCount, | 165 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestNode", V8Node::domTemplate(isolate, currentWorldType), V8TestNode::int
ernalFieldCount, |
| 166 V8TestNodeAttributes, WTF_ARRAY_LENGTH(V8TestNodeAttributes), | 166 V8TestNodeAttributes, WTF_ARRAY_LENGTH(V8TestNodeAttributes), |
| 167 0, 0, | 167 0, 0, |
| 168 0, 0, | 168 0, 0, |
| 169 isolate, currentWorldType); | 169 isolate, currentWorldType); |
| 170 functionTemplate->SetCallHandler(V8TestNode::constructorCallback); | 170 functionTemplate->SetCallHandler(V8TestNode::constructorCallback); |
| 171 functionTemplate->SetLength(0); | 171 functionTemplate->SetLength(0); |
| 172 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); | 172 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); |
| 173 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); | 173 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); |
| 174 | 174 |
| 175 // Custom toString template | 175 // Custom toString template |
| 176 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::Strin
g::kInternalizedString), V8PerIsolateData::current()->toStringTemplate()); | 176 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::Strin
g::kInternalizedString), V8PerIsolateData::current()->toStringTemplate()); |
| 177 return functionTemplate; | |
| 178 } | 177 } |
| 179 | 178 |
| 180 v8::Handle<v8::FunctionTemplate> V8TestNode::domTemplate(v8::Isolate* isolate, W
rapperWorldType currentWorldType) | 179 v8::Handle<v8::FunctionTemplate> V8TestNode::domTemplate(v8::Isolate* isolate, W
rapperWorldType currentWorldType) |
| 181 { | 180 { |
| 182 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 181 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 183 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&wrapperTypeInfo); | 182 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&wrapperTypeInfo); |
| 184 if (result != data->templateMap(currentWorldType).end()) | 183 if (result != data->templateMap(currentWorldType).end()) |
| 185 return result->value.newLocal(isolate); | 184 return result->value.newLocal(isolate); |
| 186 | 185 |
| 187 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | 186 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
| 188 v8::EscapableHandleScope handleScope(isolate); | 187 v8::EscapableHandleScope handleScope(isolate); |
| 189 v8::Local<v8::FunctionTemplate> templ = | 188 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V
8ObjectConstructor::isValidConstructorMode); |
| 190 ConfigureV8TestNodeTemplate(data->rawDOMTemplate(&wrapperTypeInfo, curre
ntWorldType), isolate, currentWorldType); | 189 configureV8TestNodeTemplate(templ, isolate, currentWorldType); |
| 191 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); | 190 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); |
| 192 return handleScope.Escape(templ); | 191 return handleScope.Escape(templ); |
| 193 } | 192 } |
| 194 | 193 |
| 195 bool V8TestNode::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* isolate
, WrapperWorldType currentWorldType) | 194 bool V8TestNode::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* isolate
, WrapperWorldType currentWorldType) |
| 196 { | 195 { |
| 197 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, currentWorldType); | 196 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, currentWorldType); |
| 198 } | 197 } |
| 199 | 198 |
| 200 bool V8TestNode::hasInstanceInAnyWorld(v8::Handle<v8::Value> jsValue, v8::Isolat
e* isolate) | 199 bool V8TestNode::hasInstanceInAnyWorld(v8::Handle<v8::Value> jsValue, v8::Isolat
e* isolate) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 fromInternalPointer(object)->deref(); | 233 fromInternalPointer(object)->deref(); |
| 235 } | 234 } |
| 236 | 235 |
| 237 template<> | 236 template<> |
| 238 v8::Handle<v8::Value> toV8NoInline(TestNode* impl, v8::Handle<v8::Object> creati
onContext, v8::Isolate* isolate) | 237 v8::Handle<v8::Value> toV8NoInline(TestNode* impl, v8::Handle<v8::Object> creati
onContext, v8::Isolate* isolate) |
| 239 { | 238 { |
| 240 return toV8(impl, creationContext, isolate); | 239 return toV8(impl, creationContext, isolate); |
| 241 } | 240 } |
| 242 | 241 |
| 243 } // namespace WebCore | 242 } // namespace WebCore |
| OLD | NEW |