| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 { | 50 { |
| 51 } | 51 } |
| 52 | 52 |
| 53 virtual ~ScriptValue(); | 53 virtual ~ScriptValue(); |
| 54 | 54 |
| 55 ScriptValue(ScriptState* scriptState, v8::Handle<v8::Value> value) | 55 ScriptValue(ScriptState* scriptState, v8::Handle<v8::Value> value) |
| 56 : m_isolate(scriptState->isolate()) | 56 : m_isolate(scriptState->isolate()) |
| 57 , m_scriptState(scriptState) | 57 , m_scriptState(scriptState) |
| 58 , m_value(value.IsEmpty() ? nullptr : SharedPersistent<v8::Value>::creat
e(value, scriptState->isolate())) | 58 , m_value(value.IsEmpty() ? nullptr : SharedPersistent<v8::Value>::creat
e(value, scriptState->isolate())) |
| 59 { | 59 { |
| 60 ASSERT(isEmpty() || m_scriptState); |
| 60 } | 61 } |
| 61 | 62 |
| 62 ScriptValue(const ScriptValue& value) | 63 ScriptValue(const ScriptValue& value) |
| 63 : m_isolate(value.m_isolate) | 64 : m_isolate(value.m_isolate) |
| 64 , m_scriptState(value.m_scriptState) | 65 , m_scriptState(value.m_scriptState) |
| 65 , m_value(value.m_value) | 66 , m_value(value.m_value) |
| 66 { | 67 { |
| 68 ASSERT(isEmpty() || m_scriptState); |
| 67 } | 69 } |
| 68 | 70 |
| 69 ScriptState* scriptState() const | 71 ScriptState* scriptState() const |
| 70 { | 72 { |
| 71 return m_scriptState.get(); | 73 return m_scriptState.get(); |
| 72 } | 74 } |
| 73 | 75 |
| 74 v8::Isolate* isolate() const | 76 v8::Isolate* isolate() const |
| 75 { | 77 { |
| 76 if (!m_isolate) | 78 if (!m_isolate) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 bool isEmpty() const | 139 bool isEmpty() const |
| 138 { | 140 { |
| 139 return !m_value.get() || m_value->isEmpty(); | 141 return !m_value.get() || m_value->isEmpty(); |
| 140 } | 142 } |
| 141 | 143 |
| 142 void clear() | 144 void clear() |
| 143 { | 145 { |
| 144 m_value = nullptr; | 146 m_value = nullptr; |
| 145 } | 147 } |
| 146 | 148 |
| 147 v8::Handle<v8::Value> v8Value() const | 149 v8::Handle<v8::Value> v8Value() const; |
| 148 { | |
| 149 return m_value.get() ? m_value->newLocal(isolate()) : v8::Handle<v8::Val
ue>(); | |
| 150 } | |
| 151 | 150 |
| 152 bool toString(String&) const; | 151 bool toString(String&) const; |
| 153 PassRefPtr<JSONValue> toJSONValue(ScriptState*) const; | 152 PassRefPtr<JSONValue> toJSONValue(ScriptState*) const; |
| 154 | 153 |
| 155 private: | 154 private: |
| 156 mutable v8::Isolate* m_isolate; | 155 mutable v8::Isolate* m_isolate; |
| 157 mutable RefPtr<ScriptState> m_scriptState; | 156 mutable RefPtr<ScriptState> m_scriptState; |
| 158 RefPtr<SharedPersistent<v8::Value> > m_value; | 157 RefPtr<SharedPersistent<v8::Value> > m_value; |
| 159 }; | 158 }; |
| 160 | 159 |
| 161 } // namespace WebCore | 160 } // namespace WebCore |
| 162 | 161 |
| 163 #endif // ScriptValue_h | 162 #endif // ScriptValue_h |
| OLD | NEW |