| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 return v8::Local<v8::Object>(); | 99 return v8::Local<v8::Object>(); |
| 100 | 100 |
| 101 v8::Local<v8::Object> shadow = V8ScriptRunner::instantiateObject(shadowConst
ructor); | 101 v8::Local<v8::Object> shadow = V8ScriptRunner::instantiateObject(shadowConst
ructor); |
| 102 if (shadow.IsEmpty()) | 102 if (shadow.IsEmpty()) |
| 103 return v8::Local<v8::Object>(); | 103 return v8::Local<v8::Object>(); |
| 104 shadow->SetPrototype(wrapper); | 104 shadow->SetPrototype(wrapper); |
| 105 V8DOMWrapper::setNativeInfo(wrapper, &V8HTMLDocument::wrapperTypeInfo, impl)
; | 105 V8DOMWrapper::setNativeInfo(wrapper, &V8HTMLDocument::wrapperTypeInfo, impl)
; |
| 106 return shadow; | 106 return shadow; |
| 107 } | 107 } |
| 108 | 108 |
| 109 v8::Local<v8::Object> V8DOMWrapper::createWrapper(v8::Handle<v8::Object> creatio
nContext, WrapperTypeInfo* type, void* impl, v8::Isolate* isolate) | 109 v8::Local<v8::Object> V8DOMWrapper::createWrapper(v8::Handle<v8::Object> creatio
nContext, const WrapperTypeInfo* type, void* impl, v8::Isolate* isolate) |
| 110 { | 110 { |
| 111 V8WrapperInstantiationScope scope(creationContext, isolate); | 111 V8WrapperInstantiationScope scope(creationContext, isolate); |
| 112 | 112 |
| 113 V8PerContextData* perContextData = V8PerContextData::from(scope.context()); | 113 V8PerContextData* perContextData = V8PerContextData::from(scope.context()); |
| 114 v8::Local<v8::Object> wrapper = perContextData ? perContextData->createWrapp
erFromCache(type) : V8ObjectConstructor::newInstance(type->getTemplate(isolate,
worldTypeInMainThread(isolate))->GetFunction()); | 114 v8::Local<v8::Object> wrapper = perContextData ? perContextData->createWrapp
erFromCache(type) : V8ObjectConstructor::newInstance(type->getTemplate(isolate,
worldTypeInMainThread(isolate))->GetFunction()); |
| 115 | 115 |
| 116 if (type == &V8HTMLDocument::wrapperTypeInfo && !wrapper.IsEmpty()) | 116 if (type == &V8HTMLDocument::wrapperTypeInfo && !wrapper.IsEmpty()) |
| 117 wrapper = wrapInShadowTemplate(wrapper, static_cast<Node*>(impl), isolat
e); | 117 wrapper = wrapInShadowTemplate(wrapper, static_cast<Node*>(impl), isolat
e); |
| 118 | 118 |
| 119 return wrapper; | 119 return wrapper; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 150 v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(value); | 150 v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(value); |
| 151 if (wrapper->InternalFieldCount() < v8DefaultWrapperInternalFieldCount) | 151 if (wrapper->InternalFieldCount() < v8DefaultWrapperInternalFieldCount) |
| 152 return false; | 152 return false; |
| 153 ASSERT(wrapper->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex))
; | 153 ASSERT(wrapper->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex))
; |
| 154 ASSERT(wrapper->GetAlignedPointerFromInternalField(v8DOMWrapperTypeIndex)); | 154 ASSERT(wrapper->GetAlignedPointerFromInternalField(v8DOMWrapperTypeIndex)); |
| 155 | 155 |
| 156 // FIXME: Add class id checks. | 156 // FIXME: Add class id checks. |
| 157 return true; | 157 return true; |
| 158 } | 158 } |
| 159 | 159 |
| 160 bool V8DOMWrapper::isWrapperOfType(v8::Handle<v8::Value> value, WrapperTypeInfo*
type) | 160 bool V8DOMWrapper::isWrapperOfType(v8::Handle<v8::Value> value, const WrapperTyp
eInfo* type) |
| 161 { | 161 { |
| 162 if (!hasInternalField(value)) | 162 if (!hasInternalField(value)) |
| 163 return false; | 163 return false; |
| 164 | 164 |
| 165 v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(value); | 165 v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(value); |
| 166 ASSERT(wrapper->InternalFieldCount() >= v8DefaultWrapperInternalFieldCount); | 166 ASSERT(wrapper->InternalFieldCount() >= v8DefaultWrapperInternalFieldCount); |
| 167 ASSERT(wrapper->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex))
; | 167 ASSERT(wrapper->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex))
; |
| 168 | 168 |
| 169 WrapperTypeInfo* typeInfo = static_cast<WrapperTypeInfo*>(wrapper->GetAligne
dPointerFromInternalField(v8DOMWrapperTypeIndex)); | 169 const WrapperTypeInfo* typeInfo = static_cast<const WrapperTypeInfo*>(wrappe
r->GetAlignedPointerFromInternalField(v8DOMWrapperTypeIndex)); |
| 170 return typeInfo == type; | 170 return typeInfo == type; |
| 171 } | 171 } |
| 172 | 172 |
| 173 } // namespace WebCore | 173 } // namespace WebCore |
| OLD | NEW |