OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2011 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 19 matching lines...) Expand all Loading... |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "bindings/core/v8/ScriptValue.h" | 32 #include "bindings/core/v8/ScriptValue.h" |
33 | 33 |
34 #include "bindings/core/v8/ScriptState.h" | 34 #include "bindings/core/v8/ScriptState.h" |
35 #include "bindings/core/v8/V8Binding.h" | 35 #include "bindings/core/v8/V8Binding.h" |
36 #include "platform/JSONValues.h" | 36 #include "platform/JSONValues.h" |
37 | 37 |
38 namespace blink { | 38 namespace blink { |
39 | 39 |
| 40 int ScriptValue::identityHash() const |
| 41 { |
| 42 if (isEmpty()) |
| 43 return 0; |
| 44 v8::HandleScope handleScope(isolate()); |
| 45 v8::Local<v8::Value> value = m_value->newLocal(isolate()); |
| 46 if (!value->IsObject()) |
| 47 return 0; |
| 48 return v8::Local<v8::Object>::Cast(value)->GetIdentityHash(); |
| 49 } |
| 50 |
40 v8::Handle<v8::Value> ScriptValue::v8Value() const | 51 v8::Handle<v8::Value> ScriptValue::v8Value() const |
41 { | 52 { |
42 if (isEmpty()) | 53 if (isEmpty()) |
43 return v8::Handle<v8::Value>(); | 54 return v8::Handle<v8::Value>(); |
44 | 55 |
45 ASSERT(isolate()->InContext()); | 56 ASSERT(isolate()->InContext()); |
46 | 57 |
47 // This is a check to validate that you don't return a ScriptValue to a worl
d different | 58 // This is a check to validate that you don't return a ScriptValue to a worl
d different |
48 // from the world that created the ScriptValue. | 59 // from the world that created the ScriptValue. |
49 // Probably this could be: | 60 // Probably this could be: |
(...skipping 25 matching lines...) Expand all Loading... |
75 } | 86 } |
76 | 87 |
77 PassRefPtr<JSONValue> ScriptValue::toJSONValue(ScriptState* scriptState) const | 88 PassRefPtr<JSONValue> ScriptValue::toJSONValue(ScriptState* scriptState) const |
78 { | 89 { |
79 ASSERT(!scriptState->contextIsValid()); | 90 ASSERT(!scriptState->contextIsValid()); |
80 ScriptState::Scope scope(scriptState); | 91 ScriptState::Scope scope(scriptState); |
81 return v8ToJSONValue(scriptState->isolate(), v8Value(), JSONValue::maxDepth)
; | 92 return v8ToJSONValue(scriptState->isolate(), v8Value(), JSONValue::maxDepth)
; |
82 } | 93 } |
83 | 94 |
84 } // namespace blink | 95 } // namespace blink |
OLD | NEW |