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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 if (type->parent_class) { | 122 if (type->parent_class) { |
123 v8::Local<v8::Object> prototype_template = | 123 v8::Local<v8::Object> prototype_template = |
124 ConstructorForType(type->parent_class); | 124 ConstructorForType(type->parent_class); |
125 if (prototype_template.IsEmpty()) | 125 if (prototype_template.IsEmpty()) |
126 return v8::Local<v8::Function>(); | 126 return v8::Local<v8::Function>(); |
127 if (!V8CallBoolean(interface_object->SetPrototype(current_context, | 127 if (!V8CallBoolean(interface_object->SetPrototype(current_context, |
128 prototype_template))) | 128 prototype_template))) |
129 return v8::Local<v8::Function>(); | 129 return v8::Local<v8::Function>(); |
130 } | 130 } |
131 | 131 |
132 v8::Local<v8::Value> prototype_value; | 132 v8::Local<v8::Object> prototype_object; |
133 if (!interface_object | 133 if (type->wrapper_type_prototype != |
134 ->Get(current_context, V8AtomicString(isolate_, "prototype")) | 134 WrapperTypeInfo::kWrapperTypeNoPrototype) { |
135 .ToLocal(&prototype_value) || | 135 v8::Local<v8::Value> prototype_value; |
136 !prototype_value->IsObject()) | 136 if (!interface_object |
137 return v8::Local<v8::Function>(); | 137 ->Get(current_context, V8AtomicString(isolate_, "prototype")) |
138 v8::Local<v8::Object> prototype_object = prototype_value.As<v8::Object>(); | 138 .ToLocal(&prototype_value) || |
139 if (prototype_object->InternalFieldCount() == | 139 !prototype_value->IsObject()) |
140 kV8PrototypeInternalFieldcount && | |
141 type->wrapper_type_prototype == | |
142 WrapperTypeInfo::kWrapperTypeObjectPrototype) { | |
143 prototype_object->SetAlignedPointerInInternalField( | |
144 kV8PrototypeTypeIndex, const_cast<WrapperTypeInfo*>(type)); | |
145 } | |
146 type->PreparePrototypeAndInterfaceObject(current_context, world, | |
147 prototype_object, interface_object, | |
148 interface_template); | |
149 if (type->wrapper_type_prototype == | |
150 WrapperTypeInfo::kWrapperTypeExceptionPrototype) { | |
151 if (!V8CallBoolean(prototype_object->SetPrototype( | |
152 current_context, error_prototype_.NewLocal(isolate_)))) { | |
153 return v8::Local<v8::Function>(); | 140 return v8::Local<v8::Function>(); |
| 141 prototype_object = prototype_value.As<v8::Object>(); |
| 142 if (prototype_object->InternalFieldCount() == |
| 143 kV8PrototypeInternalFieldcount && |
| 144 type->wrapper_type_prototype == |
| 145 WrapperTypeInfo::kWrapperTypeObjectPrototype) { |
| 146 prototype_object->SetAlignedPointerInInternalField( |
| 147 kV8PrototypeTypeIndex, const_cast<WrapperTypeInfo*>(type)); |
| 148 } |
| 149 type->PreparePrototypeAndInterfaceObject(current_context, world, |
| 150 prototype_object, interface_object, |
| 151 interface_template); |
| 152 if (type->wrapper_type_prototype == |
| 153 WrapperTypeInfo::kWrapperTypeExceptionPrototype) { |
| 154 if (!V8CallBoolean(prototype_object->SetPrototype( |
| 155 current_context, error_prototype_.NewLocal(isolate_)))) { |
| 156 return v8::Local<v8::Function>(); |
| 157 } |
154 } | 158 } |
155 } | 159 } |
156 | 160 |
157 // Origin Trials | 161 // Origin Trials |
158 InstallConditionalFeatures(type, ScriptState::From(current_context), | 162 InstallConditionalFeatures(type, ScriptState::From(current_context), |
159 prototype_object, interface_object); | 163 prototype_object, interface_object); |
160 | 164 |
161 constructor_map_.Set(type, interface_object); | 165 constructor_map_.Set(type, interface_object); |
162 | 166 |
163 return interface_object; | 167 return interface_object; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 | 205 |
202 void V8PerContextData::ClearData(const char* key) { | 206 void V8PerContextData::ClearData(const char* key) { |
203 data_map_.erase(key); | 207 data_map_.erase(key); |
204 } | 208 } |
205 | 209 |
206 V8PerContextData::Data* V8PerContextData::GetData(const char* key) { | 210 V8PerContextData::Data* V8PerContextData::GetData(const char* key) { |
207 return data_map_.at(key); | 211 return data_map_.at(key); |
208 } | 212 } |
209 | 213 |
210 } // namespace blink | 214 } // namespace blink |
OLD | NEW |