OLD | NEW |
1 # Design of V8 bindings | 1 # Design of V8 bindings |
2 | 2 |
3 This document explains key concepts in the V8 binding architecture | 3 This document explains key concepts in the V8 binding architecture |
4 except the lifetime management of DOM wrappers. | 4 except the lifetime management of DOM wrappers. |
5 See [V8GCController.md](V8GCController.md) to learn the lifetime management. | 5 See [V8GCController.md](V8GCController.md) to learn the lifetime management. |
6 | 6 |
7 [TOC] | 7 [TOC] |
8 | 8 |
9 ## Isolate | 9 ## Isolate |
10 | 10 |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 218 |
219 To accomplish the semantics that the same DOM wrapper is returned to JavaScript | 219 To accomplish the semantics that the same DOM wrapper is returned to JavaScript |
220 as long as the underlying C++ DOM object is alive, we need a mapping | 220 as long as the underlying C++ DOM object is alive, we need a mapping |
221 from the C++ DOM objects to the DOM wrappers. | 221 from the C++ DOM objects to the DOM wrappers. |
222 In addition, we need to sandbox DOM wrappers in each world. | 222 In addition, we need to sandbox DOM wrappers in each world. |
223 To meet the requirements, we make each world hold a DOM wrapper storage | 223 To meet the requirements, we make each world hold a DOM wrapper storage |
224 that stores a mapping from the C++ DOM objects to the DOM wrappers in that world
. | 224 that stores a mapping from the C++ DOM objects to the DOM wrappers in that world
. |
225 | 225 |
226 As a result, we have multiple DOM wrapper storages in one isolate. | 226 As a result, we have multiple DOM wrapper storages in one isolate. |
227 The mapping of the main world is written in `ScriptWrappable`. | 227 The mapping of the main world is written in `ScriptWrappable`. |
228 If `ScriptWrappable::m_mainWorldWrapper` has a non-empty value, it is a DOM | 228 If `ScriptWrappable::main_world_wrapper_` has a non-empty value, it is a DOM |
229 wrapper of the C++ DOM object of the main world. | 229 wrapper of the C++ DOM object of the main world. |
230 The mapping of other worlds are written in `DOMWrapperMap`. | 230 The mapping of other worlds are written in `DOMWrapperMap`. |
231 | 231 |
232 ## DOM wrappers and contexts | 232 ## DOM wrappers and contexts |
233 | 233 |
234 When you create a new DOM wrapper, you need to choose a correct context | 234 When you create a new DOM wrapper, you need to choose a correct context |
235 on which the DOM wrapper is created. If you create a new DOM wrapper in a | 235 on which the DOM wrapper is created. If you create a new DOM wrapper in a |
236 wrong context, you will end up with leaking JavaScript objects to other | 236 wrong context, you will end up with leaking JavaScript objects to other |
237 contexts, which is very likely to cause security issues. | 237 contexts, which is very likely to cause security issues. |
238 | 238 |
(...skipping 17 matching lines...) Expand all Loading... |
256 // iframe.html | 256 // iframe.html |
257 <script> | 257 <script> |
258 </script> | 258 </script> |
259 ``` | 259 ``` |
260 | 260 |
261 To make sure that a DOM wrapper is created in a correct context, you need to | 261 To make sure that a DOM wrapper is created in a correct context, you need to |
262 make sure that the current context must be set to the correct context | 262 make sure that the current context must be set to the correct context |
263 whenever you call ToV8(). If you're not sure what context to use, | 263 whenever you call ToV8(). If you're not sure what context to use, |
264 ask haraken@chromium.org. | 264 ask haraken@chromium.org. |
265 | 265 |
OLD | NEW |