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 "bindings/core/v8/V8HiddenValue.h" | 5 #include "bindings/core/v8/V8HiddenValue.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptState.h" | 7 #include "bindings/core/v8/ScriptState.h" |
8 #include "bindings/core/v8/ScriptWrappable.h" | 8 #include "bindings/core/v8/ScriptWrappable.h" |
9 #include "bindings/core/v8/V8Binding.h" | 9 #include "bindings/core/v8/V8Binding.h" |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 if (UNLIKELY(value.IsEmpty())) | 44 if (UNLIKELY(value.IsEmpty())) |
45 return false; | 45 return false; |
46 return v8CallBoolean(object->SetPrivate( | 46 return v8CallBoolean(object->SetPrivate( |
47 scriptState->context(), v8::Private::ForApi(scriptState->isolate(), key), | 47 scriptState->context(), v8::Private::ForApi(scriptState->isolate(), key), |
48 value)); | 48 value)); |
49 } | 49 } |
50 | 50 |
51 bool V8HiddenValue::deleteHiddenValue(ScriptState* scriptState, | 51 bool V8HiddenValue::deleteHiddenValue(ScriptState* scriptState, |
52 v8::Local<v8::Object> object, | 52 v8::Local<v8::Object> object, |
53 v8::Local<v8::String> key) { | 53 v8::Local<v8::String> key) { |
54 // Actually deleting the value would make force the object into dictionary mod
e which is unnecessarily slow. Instead, we replace the hidden value with "undefi
ned". | 54 // Actually deleting the value would make force the object into dictionary |
| 55 // mode which is unnecessarily slow. Instead, we replace the hidden value with |
| 56 // "undefined". |
55 return v8CallBoolean(object->SetPrivate( | 57 return v8CallBoolean(object->SetPrivate( |
56 scriptState->context(), v8::Private::ForApi(scriptState->isolate(), key), | 58 scriptState->context(), v8::Private::ForApi(scriptState->isolate(), key), |
57 v8::Undefined(scriptState->isolate()))); | 59 v8::Undefined(scriptState->isolate()))); |
58 } | 60 } |
59 | 61 |
60 v8::Local<v8::Value> V8HiddenValue::getHiddenValueFromMainWorldWrapper( | 62 v8::Local<v8::Value> V8HiddenValue::getHiddenValueFromMainWorldWrapper( |
61 ScriptState* scriptState, | 63 ScriptState* scriptState, |
62 ScriptWrappable* wrappable, | 64 ScriptWrappable* wrappable, |
63 v8::Local<v8::String> key) { | 65 v8::Local<v8::String> key) { |
64 v8::Local<v8::Object> wrapper = | 66 v8::Local<v8::Object> wrapper = |
65 wrappable->mainWorldWrapper(scriptState->isolate()); | 67 wrappable->mainWorldWrapper(scriptState->isolate()); |
66 return wrapper.IsEmpty() ? v8::Local<v8::Value>() | 68 return wrapper.IsEmpty() ? v8::Local<v8::Value>() |
67 : getHiddenValue(scriptState, wrapper, key); | 69 : getHiddenValue(scriptState, wrapper, key); |
68 } | 70 } |
69 | 71 |
70 } // namespace blink | 72 } // namespace blink |
OLD | NEW |