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