| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 m_wrapperBoilerplates.Set(type, instanceTemplate); | 86 m_wrapperBoilerplates.Set(type, instanceTemplate); |
| 87 return instanceTemplate->Clone(); | 87 return instanceTemplate->Clone(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 v8::Local<v8::Function> V8PerContextData::constructorForTypeSlowCase(const Wrapp
erTypeInfo* type) | 90 v8::Local<v8::Function> V8PerContextData::constructorForTypeSlowCase(const Wrapp
erTypeInfo* type) |
| 91 { | 91 { |
| 92 ASSERT(!m_errorPrototype.isEmpty()); | 92 ASSERT(!m_errorPrototype.isEmpty()); |
| 93 | 93 |
| 94 v8::Local<v8::Context> currentContext = context(); | 94 v8::Local<v8::Context> currentContext = context(); |
| 95 v8::Context::Scope scope(currentContext); | 95 v8::Context::Scope scope(currentContext); |
| 96 // We shouldn't reach this point for the types that are implemented in v8 su
che as typed arrays and | 96 // We shouldn't reach this point for the types that are implemented in v8 su
ch as typed arrays and |
| 97 // hence don't have domTemplateFunction. | 97 // hence don't have domTemplateFunction. |
| 98 ASSERT(type->domTemplateFunction); | 98 ASSERT(type->domTemplateFunction); |
| 99 v8::Local<v8::FunctionTemplate> functionTemplate = type->domTemplate(m_isola
te); | 99 v8::Local<v8::FunctionTemplate> functionTemplate = type->domTemplate(m_isola
te); |
| 100 // Getting the function might fail if we're running out of stack or memory. | 100 // Getting the function might fail if we're running out of stack or memory. |
| 101 v8::Local<v8::Function> function; | 101 v8::Local<v8::Function> function; |
| 102 if (!functionTemplate->GetFunction(currentContext).ToLocal(&function)) | 102 if (!functionTemplate->GetFunction(currentContext).ToLocal(&function)) |
| 103 return v8::Local<v8::Function>(); | 103 return v8::Local<v8::Function>(); |
| 104 | 104 |
| 105 if (type->parentClass) { | 105 if (type->parentClass) { |
| 106 v8::Local<v8::Object> prototypeTemplate = constructorForType(type->paren
tClass); | 106 v8::Local<v8::Object> prototypeTemplate = constructorForType(type->paren
tClass); |
| 107 if (prototypeTemplate.IsEmpty()) | 107 if (prototypeTemplate.IsEmpty()) |
| 108 return v8::Local<v8::Function>(); | 108 return v8::Local<v8::Function>(); |
| 109 if (!v8CallBoolean(function->SetPrototype(currentContext, prototypeTempl
ate))) | 109 if (!v8CallBoolean(function->SetPrototype(currentContext, prototypeTempl
ate))) |
| 110 return v8::Local<v8::Function>(); | 110 return v8::Local<v8::Function>(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 v8::Local<v8::Object> prototypeObject = function->Get(currentContext, v8Atom
icString(m_isolate, "prototype")).ToLocalChecked().As<v8::Object>(); | 113 v8::Local<v8::Object> prototypeObject = function->Get(currentContext, v8Atom
icString(m_isolate, "prototype")).ToLocalChecked().As<v8::Object>(); |
| 114 if (prototypeObject->InternalFieldCount() == v8PrototypeInternalFieldcount | 114 if (prototypeObject->InternalFieldCount() == v8PrototypeInternalFieldcount |
| 115 && type->wrapperTypePrototype == WrapperTypeInfo::WrapperTypeObjectProto
type) | 115 && type->wrapperTypePrototype == WrapperTypeInfo::WrapperTypeObjectProto
type) |
| 116 prototypeObject->SetAlignedPointerInInternalField(v8PrototypeTypeIndex,
const_cast<WrapperTypeInfo*>(type)); | 116 prototypeObject->SetAlignedPointerInInternalField(v8PrototypeTypeIndex,
const_cast<WrapperTypeInfo*>(type)); |
| 117 type->preparePrototypeObject(m_isolate, prototypeObject); | 117 type->preparePrototypeObject(m_isolate, prototypeObject, functionTemplate); |
| 118 if (type->wrapperTypePrototype == WrapperTypeInfo::WrapperTypeExceptionProto
type) { | 118 if (type->wrapperTypePrototype == WrapperTypeInfo::WrapperTypeExceptionProto
type) { |
| 119 if (!v8CallBoolean(prototypeObject->SetPrototype(currentContext, m_error
Prototype.newLocal(m_isolate)))) | 119 if (!v8CallBoolean(prototypeObject->SetPrototype(currentContext, m_error
Prototype.newLocal(m_isolate)))) |
| 120 return v8::Local<v8::Function>(); | 120 return v8::Local<v8::Function>(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 m_constructorMap.Set(type, function); | 123 m_constructorMap.Set(type, function); |
| 124 | 124 |
| 125 return function; | 125 return function; |
| 126 } | 126 } |
| 127 | 127 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 145 { | 145 { |
| 146 return m_compiledPrivateScript.Get(className); | 146 return m_compiledPrivateScript.Get(className); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void V8PerContextData::setCompiledPrivateScript(String className, v8::Local<v8::
Value> compiledObject) | 149 void V8PerContextData::setCompiledPrivateScript(String className, v8::Local<v8::
Value> compiledObject) |
| 150 { | 150 { |
| 151 m_compiledPrivateScript.Set(className, compiledObject); | 151 m_compiledPrivateScript.Set(className, compiledObject); |
| 152 } | 152 } |
| 153 | 153 |
| 154 } // namespace blink | 154 } // namespace blink |
| OLD | NEW |