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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // This is a check to validate that you don't return a ScriptValue to a worl
d different | 51 // This is a check to validate that you don't return a ScriptValue to a worl
d different |
52 // from the world that created the ScriptValue. | 52 // from the world that created the ScriptValue. |
53 // Probably this could be: | 53 // Probably this could be: |
54 // if (&m_scriptState->world() == &DOMWrapperWorld::current(isolate())) | 54 // if (&m_scriptState->world() == &DOMWrapperWorld::current(isolate())) |
55 // return v8::Handle<v8::Value>(); | 55 // return v8::Handle<v8::Value>(); |
56 // instead of triggering RELEASE_ASSERT. | 56 // instead of triggering RELEASE_ASSERT. |
57 RELEASE_ASSERT(&m_scriptState->world() == &DOMWrapperWorld::current(isolate(
))); | 57 RELEASE_ASSERT(&m_scriptState->world() == &DOMWrapperWorld::current(isolate(
))); |
58 return m_value->newLocal(isolate()); | 58 return m_value->newLocal(isolate()); |
59 } | 59 } |
60 | 60 |
| 61 v8::Handle<v8::Value> ScriptValue::v8ValueUnsafe() const |
| 62 { |
| 63 if (isEmpty()) |
| 64 return v8::Handle<v8::Value>(); |
| 65 return m_value->newLocal(isolate()); |
| 66 } |
| 67 |
61 bool ScriptValue::toString(String& result) const | 68 bool ScriptValue::toString(String& result) const |
62 { | 69 { |
63 if (isEmpty()) | 70 if (isEmpty()) |
64 return false; | 71 return false; |
65 | 72 |
66 ScriptState::Scope scope(m_scriptState.get()); | 73 ScriptState::Scope scope(m_scriptState.get()); |
67 v8::Handle<v8::Value> string = v8Value(); | 74 v8::Handle<v8::Value> string = v8Value(); |
68 if (string.IsEmpty() || !string->IsString()) | 75 if (string.IsEmpty() || !string->IsString()) |
69 return false; | 76 return false; |
70 result = toCoreString(v8::Handle<v8::String>::Cast(string)); | 77 result = toCoreString(v8::Handle<v8::String>::Cast(string)); |
71 return true; | 78 return true; |
72 } | 79 } |
73 | 80 |
74 PassRefPtr<JSONValue> ScriptValue::toJSONValue(ScriptState* scriptState) const | 81 PassRefPtr<JSONValue> ScriptValue::toJSONValue(ScriptState* scriptState) const |
75 { | 82 { |
76 ASSERT(!scriptState->contextIsEmpty()); | 83 ASSERT(!scriptState->contextIsEmpty()); |
77 ScriptState::Scope scope(scriptState); | 84 ScriptState::Scope scope(scriptState); |
78 return v8ToJSONValue(scriptState->isolate(), v8Value(), JSONValue::maxDepth)
; | 85 return v8ToJSONValue(scriptState->isolate(), v8Value(), JSONValue::maxDepth)
; |
79 } | 86 } |
80 | 87 |
81 } // namespace blink | 88 } // namespace blink |
OLD | NEW |