OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 static void namedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& i
nfo) | 106 static void namedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& i
nfo) |
107 { | 107 { |
108 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 108 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
109 TestEventTargetV8Internal::namedItemMethod(info); | 109 TestEventTargetV8Internal::namedItemMethod(info); |
110 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 110 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
111 } | 111 } |
112 | 112 |
113 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo
<v8::Value>& info) | 113 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo
<v8::Value>& info) |
114 { | 114 { |
115 TestEventTarget* collection = V8TestEventTarget::toNative(info.Holder()); | 115 TestEventTarget* imp = V8TestEventTarget::toNative(info.Holder()); |
116 RefPtr<Node> element = collection->item(index); | 116 RefPtr<Node> result = imp->item(index); |
117 if (!element) | 117 if (!result) |
118 return; | 118 return; |
119 v8SetReturnValueFast(info, element.release(), collection); | 119 v8SetReturnValueFast(info, result.release(), imp); |
120 } | 120 } |
121 | 121 |
122 static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCall
backInfo<v8::Value>& info) | 122 static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCall
backInfo<v8::Value>& info) |
123 { | 123 { |
124 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); | 124 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); |
125 TestEventTargetV8Internal::indexedPropertyGetter(index, info); | 125 TestEventTargetV8Internal::indexedPropertyGetter(index, info); |
126 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 126 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
127 } | 127 } |
128 | 128 |
129 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> jsValue,
const v8::PropertyCallbackInfo<v8::Value>& info) | 129 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> jsValue,
const v8::PropertyCallbackInfo<v8::Value>& info) |
130 { | 130 { |
131 TestEventTarget* collection = V8TestEventTarget::toNative(info.Holder()); | 131 TestEventTarget* imp = V8TestEventTarget::toNative(info.Holder()); |
132 V8TRYCATCH_VOID(Node*, propertyValue, V8Node::hasInstance(jsValue, info.GetI
solate()) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(jsValue)) : 0); | 132 V8TRYCATCH_VOID(Node*, propertyValue, V8Node::hasInstance(jsValue, info.GetI
solate()) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(jsValue)) : 0); |
133 if (!isUndefinedOrNull(jsValue) && !V8Node::hasInstance(jsValue, info.GetIso
late())) { | 133 if (!isUndefinedOrNull(jsValue) && !V8Node::hasInstance(jsValue, info.GetIso
late())) { |
134 exceptionState.throwTypeError("The provided value is not of type 'Node'.
"); | 134 exceptionState.throwTypeError("The provided value is not of type 'Node'.
"); |
135 exceptionState.throwIfNeeded(); | 135 exceptionState.throwIfNeeded(); |
136 return; | 136 return; |
137 } | 137 } |
138 bool result = collection->anonymousIndexedSetter(index, propertyValue); | 138 bool result = imp->anonymousIndexedSetter(index, propertyValue); |
139 if (!result) | 139 if (!result) |
140 return; | 140 return; |
141 v8SetReturnValue(info, jsValue); | 141 v8SetReturnValue(info, jsValue); |
142 } | 142 } |
143 | 143 |
144 static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> j
sValue, const v8::PropertyCallbackInfo<v8::Value>& info) | 144 static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> j
sValue, const v8::PropertyCallbackInfo<v8::Value>& info) |
145 { | 145 { |
146 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); | 146 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); |
147 TestEventTargetV8Internal::indexedPropertySetter(index, jsValue, info); | 147 TestEventTargetV8Internal::indexedPropertySetter(index, jsValue, info); |
148 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 148 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
149 } | 149 } |
150 | 150 |
151 static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInf
o<v8::Boolean>& info) | 151 static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInf
o<v8::Boolean>& info) |
152 { | 152 { |
153 TestEventTarget* collection = V8TestEventTarget::toNative(info.Holder()); | 153 TestEventTarget* imp = V8TestEventTarget::toNative(info.Holder()); |
154 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); | 154 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); |
155 DeleteResult result = collection->anonymousIndexedDeleter(index, exceptionSt
ate); | 155 DeleteResult result = imp->anonymousIndexedDeleter(index, exceptionState); |
156 if (exceptionState.throwIfNeeded()) | 156 if (exceptionState.throwIfNeeded()) |
157 return; | 157 return; |
158 if (result != DeleteUnknownProperty) | 158 if (result != DeleteUnknownProperty) |
159 return v8SetReturnValueBool(info, result == DeleteSuccess); | 159 return v8SetReturnValueBool(info, result == DeleteSuccess); |
160 } | 160 } |
161 | 161 |
162 static void indexedPropertyDeleterCallback(uint32_t index, const v8::PropertyCal
lbackInfo<v8::Boolean>& info) | 162 static void indexedPropertyDeleterCallback(uint32_t index, const v8::PropertyCal
lbackInfo<v8::Boolean>& info) |
163 { | 163 { |
164 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); | 164 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); |
165 TestEventTargetV8Internal::indexedPropertyDeleter(index, info); | 165 TestEventTargetV8Internal::indexedPropertyDeleter(index, info); |
166 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 166 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
167 } | 167 } |
168 | 168 |
169 static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCa
llbackInfo<v8::Value>& info) | 169 static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCa
llbackInfo<v8::Value>& info) |
170 { | 170 { |
171 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) | 171 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) |
172 return; | 172 return; |
173 if (info.Holder()->HasRealNamedCallbackProperty(name)) | 173 if (info.Holder()->HasRealNamedCallbackProperty(name)) |
174 return; | 174 return; |
175 if (info.Holder()->HasRealNamedProperty(name)) | 175 if (info.Holder()->HasRealNamedProperty(name)) |
176 return; | 176 return; |
177 | 177 |
178 TestEventTarget* collection = V8TestEventTarget::toNative(info.Holder()); | 178 TestEventTarget* imp = V8TestEventTarget::toNative(info.Holder()); |
179 AtomicString propertyName = toCoreAtomicString(name); | 179 AtomicString propertyName = toCoreAtomicString(name); |
180 RefPtr<Node> element = collection->namedItem(propertyName); | 180 RefPtr<Node> result = imp->namedItem(propertyName); |
181 if (!element) | 181 if (!result) |
182 return; | 182 return; |
183 v8SetReturnValueFast(info, element.release(), collection); | 183 v8SetReturnValueFast(info, result.release(), imp); |
184 } | 184 } |
185 | 185 |
186 static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::Pr
opertyCallbackInfo<v8::Value>& info) | 186 static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::Pr
opertyCallbackInfo<v8::Value>& info) |
187 { | 187 { |
188 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); | 188 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); |
189 TestEventTargetV8Internal::namedPropertyGetter(name, info); | 189 TestEventTargetV8Internal::namedPropertyGetter(name, info); |
190 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 190 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
191 } | 191 } |
192 | 192 |
193 static void namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value>
jsValue, const v8::PropertyCallbackInfo<v8::Value>& info) | 193 static void namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value>
jsValue, const v8::PropertyCallbackInfo<v8::Value>& info) |
194 { | 194 { |
195 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) | 195 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) |
196 return; | 196 return; |
197 if (info.Holder()->HasRealNamedCallbackProperty(name)) | 197 if (info.Holder()->HasRealNamedCallbackProperty(name)) |
198 return; | 198 return; |
199 if (info.Holder()->HasRealNamedProperty(name)) | 199 if (info.Holder()->HasRealNamedProperty(name)) |
200 return; | 200 return; |
201 | 201 |
202 TestEventTarget* collection = V8TestEventTarget::toNative(info.Holder()); | 202 TestEventTarget* imp = V8TestEventTarget::toNative(info.Holder()); |
203 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyName, name)
; | 203 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyName, name)
; |
204 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyValue, jsVa
lue); | 204 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyValue, jsVa
lue); |
205 bool result = collection->anonymousNamedSetter(propertyName, propertyValue); | 205 bool result = imp->anonymousNamedSetter(propertyName, propertyValue); |
206 if (!result) | 206 if (!result) |
207 return; | 207 return; |
208 v8SetReturnValue(info, jsValue); | 208 v8SetReturnValue(info, jsValue); |
209 } | 209 } |
210 | 210 |
211 static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8
::Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info) | 211 static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8
::Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info) |
212 { | 212 { |
213 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); | 213 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); |
214 TestEventTargetV8Internal::namedPropertySetter(name, jsValue, info); | 214 TestEventTargetV8Internal::namedPropertySetter(name, jsValue, info); |
215 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 215 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
216 } | 216 } |
217 | 217 |
218 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal
lbackInfo<v8::Integer>& info) | 218 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal
lbackInfo<v8::Integer>& info) |
219 { | 219 { |
220 TestEventTarget* collection = V8TestEventTarget::toNative(info.Holder()); | 220 TestEventTarget* imp = V8TestEventTarget::toNative(info.Holder()); |
221 AtomicString propertyName = toCoreAtomicString(name); | 221 AtomicString propertyName = toCoreAtomicString(name); |
222 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); | 222 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); |
223 bool result = collection->namedPropertyQuery(propertyName, exceptionState); | 223 bool result = imp->namedPropertyQuery(propertyName, exceptionState); |
224 if (exceptionState.throwIfNeeded()) | 224 if (exceptionState.throwIfNeeded()) |
225 return; | 225 return; |
226 if (!result) | 226 if (!result) |
227 return; | 227 return; |
228 v8SetReturnValueInt(info, v8::None); | 228 v8SetReturnValueInt(info, v8::None); |
229 } | 229 } |
230 | 230 |
231 static void namedPropertyQueryCallback(v8::Local<v8::String> name, const v8::Pro
pertyCallbackInfo<v8::Integer>& info) | 231 static void namedPropertyQueryCallback(v8::Local<v8::String> name, const v8::Pro
pertyCallbackInfo<v8::Integer>& info) |
232 { | 232 { |
233 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); | 233 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); |
234 TestEventTargetV8Internal::namedPropertyQuery(name, info); | 234 TestEventTargetV8Internal::namedPropertyQuery(name, info); |
235 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 235 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
236 } | 236 } |
237 | 237 |
238 static void namedPropertyDeleter(v8::Local<v8::String> name, const v8::PropertyC
allbackInfo<v8::Boolean>& info) | 238 static void namedPropertyDeleter(v8::Local<v8::String> name, const v8::PropertyC
allbackInfo<v8::Boolean>& info) |
239 { | 239 { |
240 TestEventTarget* collection = V8TestEventTarget::toNative(info.Holder()); | 240 TestEventTarget* imp = V8TestEventTarget::toNative(info.Holder()); |
241 AtomicString propertyName = toCoreAtomicString(name); | 241 AtomicString propertyName = toCoreAtomicString(name); |
242 DeleteResult result = collection->anonymousNamedDeleter(propertyName); | 242 DeleteResult result = imp->anonymousNamedDeleter(propertyName); |
243 if (result != DeleteUnknownProperty) | 243 if (result != DeleteUnknownProperty) |
244 return v8SetReturnValueBool(info, result == DeleteSuccess); | 244 return v8SetReturnValueBool(info, result == DeleteSuccess); |
245 } | 245 } |
246 | 246 |
247 static void namedPropertyDeleterCallback(v8::Local<v8::String> name, const v8::P
ropertyCallbackInfo<v8::Boolean>& info) | 247 static void namedPropertyDeleterCallback(v8::Local<v8::String> name, const v8::P
ropertyCallbackInfo<v8::Boolean>& info) |
248 { | 248 { |
249 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); | 249 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); |
250 TestEventTargetV8Internal::namedPropertyDeleter(name, info); | 250 TestEventTargetV8Internal::namedPropertyDeleter(name, info); |
251 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 251 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
252 } | 252 } |
253 | 253 |
254 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i
nfo) | 254 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i
nfo) |
255 { | 255 { |
256 TestEventTarget* collection = V8TestEventTarget::toNative(info.Holder()); | 256 TestEventTarget* imp = V8TestEventTarget::toNative(info.Holder()); |
257 Vector<String> names; | 257 Vector<String> names; |
258 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); | 258 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); |
259 collection->namedPropertyEnumerator(names, exceptionState); | 259 imp->namedPropertyEnumerator(names, exceptionState); |
260 if (exceptionState.throwIfNeeded()) | 260 if (exceptionState.throwIfNeeded()) |
261 return; | 261 return; |
262 v8::Handle<v8::Array> v8names = v8::Array::New(info.GetIsolate(), names.size
()); | 262 v8::Handle<v8::Array> v8names = v8::Array::New(info.GetIsolate(), names.size
()); |
263 for (size_t i = 0; i < names.size(); ++i) | 263 for (size_t i = 0; i < names.size(); ++i) |
264 v8names->Set(v8::Integer::New(info.GetIsolate(), i), v8String(info.GetIs
olate(), names[i])); | 264 v8names->Set(v8::Integer::New(info.GetIsolate(), i), v8String(info.GetIs
olate(), names[i])); |
265 v8SetReturnValue(info, v8names); | 265 v8SetReturnValue(info, v8names); |
266 } | 266 } |
267 | 267 |
268 static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::A
rray>& info) | 268 static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::A
rray>& info) |
269 { | 269 { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 fromInternalPointer(object)->deref(); | 349 fromInternalPointer(object)->deref(); |
350 } | 350 } |
351 | 351 |
352 template<> | 352 template<> |
353 v8::Handle<v8::Value> toV8NoInline(TestEventTarget* impl, v8::Handle<v8::Object>
creationContext, v8::Isolate* isolate) | 353 v8::Handle<v8::Value> toV8NoInline(TestEventTarget* impl, v8::Handle<v8::Object>
creationContext, v8::Isolate* isolate) |
354 { | 354 { |
355 return toV8(impl, creationContext, isolate); | 355 return toV8(impl, creationContext, isolate); |
356 } | 356 } |
357 | 357 |
358 } // namespace WebCore | 358 } // namespace WebCore |
OLD | NEW |