OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/dom/DOMDataView.h" | 6 #include "core/dom/DOMDataView.h" |
7 | 7 |
8 #include "bindings/core/v8/DOMDataStore.h" | 8 #include "bindings/core/v8/DOMDataStore.h" |
9 #include "bindings/core/v8/V8ArrayBuffer.h" | 9 #include "bindings/core/v8/V8ArrayBuffer.h" |
10 #include "bindings/core/v8/V8DOMWrapper.h" | 10 #include "bindings/core/v8/V8DOMWrapper.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 ASSERT(!DOMDataStore::containsWrapper(this, isolate)); | 65 ASSERT(!DOMDataStore::containsWrapper(this, isolate)); |
66 | 66 |
67 const WrapperTypeInfo* wrapperTypeInfo = this->wrapperTypeInfo(); | 67 const WrapperTypeInfo* wrapperTypeInfo = this->wrapperTypeInfo(); |
68 v8::Local<v8::Value> v8Buffer = toV8(buffer(), creationContext, isolate); | 68 v8::Local<v8::Value> v8Buffer = toV8(buffer(), creationContext, isolate); |
69 if (v8Buffer.IsEmpty()) | 69 if (v8Buffer.IsEmpty()) |
70 return v8::Handle<v8::Object>(); | 70 return v8::Handle<v8::Object>(); |
71 ASSERT(v8Buffer->IsArrayBuffer()); | 71 ASSERT(v8Buffer->IsArrayBuffer()); |
72 | 72 |
73 v8::Local<v8::Object> wrapper = v8::DataView::New(v8Buffer.As<v8::ArrayBuffe
r>(), byteOffset(), byteLength()); | 73 v8::Local<v8::Object> wrapper = v8::DataView::New(v8Buffer.As<v8::ArrayBuffe
r>(), byteOffset(), byteLength()); |
| 74 // V8::DataView::New may run an arbitrary script and it may result in |
| 75 // creating a new wrapper and associating it with |this|. If so, the |
| 76 // wrapper already created and associated must be used. |
| 77 v8::Local<v8::Object> associatedWrapper = DOMDataStore::getWrapper(this, iso
late); |
| 78 if (UNLIKELY(!associatedWrapper.IsEmpty())) |
| 79 return associatedWrapper; |
74 | 80 |
75 return associateWithWrapper(isolate, wrapperTypeInfo, wrapper); | 81 return associateWithWrapper(isolate, wrapperTypeInfo, wrapper); |
76 } | 82 } |
77 | 83 |
78 v8::Local<v8::Object> DOMDataView::associateWithWrapper(v8::Isolate* isolate, co
nst WrapperTypeInfo* wrapperTypeInfo, v8::Local<v8::Object> wrapper) | 84 v8::Local<v8::Object> DOMDataView::associateWithWrapper(v8::Isolate* isolate, co
nst WrapperTypeInfo* wrapperTypeInfo, v8::Local<v8::Object> wrapper) |
79 { | 85 { |
80 return V8DOMWrapper::associateObjectWithWrapper(isolate, this, wrapperTypeIn
fo, wrapper); | 86 return V8DOMWrapper::associateObjectWithWrapper(isolate, this, wrapperTypeIn
fo, wrapper); |
81 } | 87 } |
82 | 88 |
83 } // namespace blink | 89 } // namespace blink |
OLD | NEW |