OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * Copyright (C) 2012 Ericsson AB. All rights reserved. | 3 * Copyright (C) 2012 Ericsson AB. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 29 matching lines...) Expand all Loading... |
40 #include "bindings/v8/V8ThrowException.h" | 40 #include "bindings/v8/V8ThrowException.h" |
41 #include "bindings/v8/V8ValueCache.h" | 41 #include "bindings/v8/V8ValueCache.h" |
42 #include "wtf/MathExtras.h" | 42 #include "wtf/MathExtras.h" |
43 #include "wtf/text/AtomicString.h" | 43 #include "wtf/text/AtomicString.h" |
44 #include <v8.h> | 44 #include <v8.h> |
45 | 45 |
46 namespace WebCore { | 46 namespace WebCore { |
47 | 47 |
48 class DOMWindow; | 48 class DOMWindow; |
49 class Document; | 49 class Document; |
| 50 class ExceptionState; |
50 class Frame; | 51 class Frame; |
51 class NodeFilter; | 52 class NodeFilter; |
52 class ExecutionContext; | 53 class ExecutionContext; |
53 class ScriptWrappable; | 54 class ScriptWrappable; |
54 class XPathNSResolver; | 55 class XPathNSResolver; |
55 | 56 |
56 const int kMaxRecursionDepth = 22; | 57 const int kMaxRecursionDepth = 22; |
57 | 58 |
58 // Schedule a DOM exception to be thrown, if the exception code is different | 59 // Schedule a DOM exception to be thrown, if the exception code is different |
59 // from zero. | 60 // from zero. |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 // Conversion flags, used in toIntXX/toUIntXX. | 291 // Conversion flags, used in toIntXX/toUIntXX. |
291 enum IntegerConversionConfiguration { | 292 enum IntegerConversionConfiguration { |
292 NormalConversion, | 293 NormalConversion, |
293 EnforceRange, | 294 EnforceRange, |
294 Clamp | 295 Clamp |
295 }; | 296 }; |
296 | 297 |
297 // Convert a value to a 8-bit signed integer. The conversion fails if the | 298 // Convert a value to a 8-bit signed integer. The conversion fails if the |
298 // value cannot be converted to a number or the range violated per WebIDL: | 299 // value cannot be converted to a number or the range violated per WebIDL: |
299 // http://www.w3.org/TR/WebIDL/#es-byte | 300 // http://www.w3.org/TR/WebIDL/#es-byte |
300 int8_t toInt8(v8::Handle<v8::Value>, IntegerConversionConfiguration, bool& o
k); | 301 int8_t toInt8(v8::Handle<v8::Value>, IntegerConversionConfiguration, Excepti
onState&); |
301 inline int8_t toInt8(v8::Handle<v8::Value> value, bool& ok) { return toInt8(
value, NormalConversion, ok); } | 302 inline int8_t toInt8(v8::Handle<v8::Value> value, ExceptionState& exceptionS
tate) |
| 303 { |
| 304 return toInt8(value, NormalConversion, exceptionState); |
| 305 } |
302 | 306 |
303 // Convert a value to a 8-bit integer assuming the conversion cannot fail. | 307 // Convert a value to a 8-bit integer assuming the conversion cannot fail. |
304 inline int8_t toInt8(v8::Handle<v8::Value> value) | 308 int8_t toInt8(v8::Handle<v8::Value>); |
305 { | |
306 bool ok; | |
307 return toInt8(value, NormalConversion, ok); | |
308 } | |
309 | 309 |
310 // Convert a value to a 8-bit unsigned integer. The conversion fails if the | 310 // Convert a value to a 8-bit unsigned integer. The conversion fails if the |
311 // value cannot be converted to a number or the range violated per WebIDL: | 311 // value cannot be converted to a number or the range violated per WebIDL: |
312 // http://www.w3.org/TR/WebIDL/#es-octet | 312 // http://www.w3.org/TR/WebIDL/#es-octet |
313 uint8_t toUInt8(v8::Handle<v8::Value>, IntegerConversionConfiguration, bool&
ok); | 313 uint8_t toUInt8(v8::Handle<v8::Value>, IntegerConversionConfiguration, Excep
tionState&); |
314 inline uint8_t toUInt8(v8::Handle<v8::Value> value, bool& ok) { return toUIn
t8(value, NormalConversion, ok); } | 314 inline uint8_t toUInt8(v8::Handle<v8::Value> value, ExceptionState& exceptio
nState) |
| 315 { |
| 316 return toUInt8(value, NormalConversion, exceptionState); |
| 317 } |
315 | 318 |
316 // Convert a value to a 8-bit unsigned integer assuming the conversion canno
t fail. | 319 // Convert a value to a 8-bit unsigned integer assuming the conversion canno
t fail. |
317 inline uint8_t toUInt8(v8::Handle<v8::Value> value) | 320 uint8_t toUInt8(v8::Handle<v8::Value>); |
318 { | |
319 bool ok; | |
320 return toUInt8(value, NormalConversion, ok); | |
321 } | |
322 | 321 |
323 // Convert a value to a 16-bit signed integer. The conversion fails if the | 322 // Convert a value to a 16-bit signed integer. The conversion fails if the |
324 // value cannot be converted to a number or the range violated per WebIDL: | 323 // value cannot be converted to a number or the range violated per WebIDL: |
325 // http://www.w3.org/TR/WebIDL/#es-short | 324 // http://www.w3.org/TR/WebIDL/#es-short |
326 int16_t toInt16(v8::Handle<v8::Value>, IntegerConversionConfiguration, bool&
ok); | 325 int16_t toInt16(v8::Handle<v8::Value>, IntegerConversionConfiguration, Excep
tionState&); |
327 inline int16_t toInt16(v8::Handle<v8::Value> value, bool& ok) { return toInt
16(value, NormalConversion, ok); } | 326 inline int16_t toInt16(v8::Handle<v8::Value> value, ExceptionState& exceptio
nState) |
| 327 { |
| 328 return toInt16(value, NormalConversion, exceptionState); |
| 329 } |
328 | 330 |
329 // Convert a value to a 16-bit integer assuming the conversion cannot fail. | 331 // Convert a value to a 16-bit integer assuming the conversion cannot fail. |
330 inline int16_t toInt16(v8::Handle<v8::Value> value) | 332 int16_t toInt16(v8::Handle<v8::Value>); |
331 { | |
332 bool ok; | |
333 return toInt16(value, NormalConversion, ok); | |
334 } | |
335 | 333 |
336 // Convert a value to a 16-bit unsigned integer. The conversion fails if the | 334 // Convert a value to a 16-bit unsigned integer. The conversion fails if the |
337 // value cannot be converted to a number or the range violated per WebIDL: | 335 // value cannot be converted to a number or the range violated per WebIDL: |
338 // http://www.w3.org/TR/WebIDL/#es-unsigned-short | 336 // http://www.w3.org/TR/WebIDL/#es-unsigned-short |
339 uint16_t toUInt16(v8::Handle<v8::Value>, IntegerConversionConfiguration, boo
l& ok); | 337 uint16_t toUInt16(v8::Handle<v8::Value>, IntegerConversionConfiguration, Exc
eptionState&); |
340 inline uint16_t toUInt16(v8::Handle<v8::Value> value, bool& ok) { return toU
Int16(value, NormalConversion, ok); } | 338 inline uint16_t toUInt16(v8::Handle<v8::Value> value, ExceptionState& except
ionState) |
| 339 { |
| 340 return toUInt16(value, NormalConversion, exceptionState); |
| 341 } |
341 | 342 |
342 // Convert a value to a 16-bit unsigned integer assuming the conversion cann
ot fail. | 343 // Convert a value to a 16-bit unsigned integer assuming the conversion cann
ot fail. |
343 inline uint16_t toUInt16(v8::Handle<v8::Value> value) | 344 uint16_t toUInt16(v8::Handle<v8::Value>); |
344 { | |
345 bool ok; | |
346 return toUInt16(value, NormalConversion, ok); | |
347 } | |
348 | 345 |
349 // Convert a value to a 32-bit signed integer. The conversion fails if the | 346 // Convert a value to a 32-bit signed integer. The conversion fails if the |
350 // value cannot be converted to a number or the range violated per WebIDL: | 347 // value cannot be converted to a number or the range violated per WebIDL: |
351 // http://www.w3.org/TR/WebIDL/#es-long | 348 // http://www.w3.org/TR/WebIDL/#es-long |
352 int32_t toInt32(v8::Handle<v8::Value>, IntegerConversionConfiguration, bool&
ok); | 349 int32_t toInt32(v8::Handle<v8::Value>, IntegerConversionConfiguration, Excep
tionState&); |
353 inline int32_t toInt32(v8::Handle<v8::Value> value, bool& ok) { return toInt
32(value, NormalConversion, ok); } | 350 inline int32_t toInt32(v8::Handle<v8::Value> value, ExceptionState& exceptio
nState) |
| 351 { |
| 352 return toInt32(value, NormalConversion, exceptionState); |
| 353 } |
354 | 354 |
355 // Convert a value to a 32-bit integer assuming the conversion cannot fail. | 355 // Convert a value to a 32-bit integer assuming the conversion cannot fail. |
356 inline int32_t toInt32(v8::Handle<v8::Value> value) | 356 int32_t toInt32(v8::Handle<v8::Value>); |
357 { | |
358 bool ok; | |
359 return toInt32(value, NormalConversion, ok); | |
360 } | |
361 | 357 |
362 // Convert a value to a 32-bit unsigned integer. The conversion fails if the | 358 // Convert a value to a 32-bit unsigned integer. The conversion fails if the |
363 // value cannot be converted to a number or the range violated per WebIDL: | 359 // value cannot be converted to a number or the range violated per WebIDL: |
364 // http://www.w3.org/TR/WebIDL/#es-unsigned-long | 360 // http://www.w3.org/TR/WebIDL/#es-unsigned-long |
365 uint32_t toUInt32(v8::Handle<v8::Value>, IntegerConversionConfiguration, boo
l& ok); | 361 uint32_t toUInt32(v8::Handle<v8::Value>, IntegerConversionConfiguration, Exc
eptionState&); |
366 inline uint32_t toUInt32(v8::Handle<v8::Value> value, bool& ok) { return toU
Int32(value, NormalConversion, ok); } | 362 inline uint32_t toUInt32(v8::Handle<v8::Value> value, ExceptionState& except
ionState) |
| 363 { |
| 364 return toUInt32(value, NormalConversion, exceptionState); |
| 365 } |
367 | 366 |
368 // Convert a value to a 32-bit unsigned integer assuming the conversion cann
ot fail. | 367 // Convert a value to a 32-bit unsigned integer assuming the conversion cann
ot fail. |
369 inline uint32_t toUInt32(v8::Handle<v8::Value> value) | 368 uint32_t toUInt32(v8::Handle<v8::Value>); |
370 { | |
371 bool ok; | |
372 return toUInt32(value, NormalConversion, ok); | |
373 } | |
374 | 369 |
375 // Convert a value to a 64-bit signed integer. The conversion fails if the | 370 // Convert a value to a 64-bit signed integer. The conversion fails if the |
376 // value cannot be converted to a number or the range violated per WebIDL: | 371 // value cannot be converted to a number or the range violated per WebIDL: |
377 // http://www.w3.org/TR/WebIDL/#es-long-long | 372 // http://www.w3.org/TR/WebIDL/#es-long-long |
378 int64_t toInt64(v8::Handle<v8::Value>, IntegerConversionConfiguration, bool&
ok); | 373 int64_t toInt64(v8::Handle<v8::Value>, IntegerConversionConfiguration, Excep
tionState&); |
| 374 inline int64_t toInt64(v8::Handle<v8::Value> value, ExceptionState& exceptio
nState) |
| 375 { |
| 376 return toInt64(value, NormalConversion, exceptionState); |
| 377 } |
379 | 378 |
380 // Convert a value to a 64-bit integer assuming the conversion cannot fail. | 379 // Convert a value to a 64-bit integer assuming the conversion cannot fail. |
381 inline int64_t toInt64(v8::Handle<v8::Value> value) | 380 int64_t toInt64(v8::Handle<v8::Value>); |
382 { | |
383 bool ok; | |
384 return toInt64(value, NormalConversion, ok); | |
385 } | |
386 | 381 |
387 // Convert a value to a 64-bit unsigned integer. The conversion fails if the | 382 // Convert a value to a 64-bit unsigned integer. The conversion fails if the |
388 // value cannot be converted to a number or the range violated per WebIDL: | 383 // value cannot be converted to a number or the range violated per WebIDL: |
389 // http://www.w3.org/TR/WebIDL/#es-unsigned-long-long | 384 // http://www.w3.org/TR/WebIDL/#es-unsigned-long-long |
390 uint64_t toUInt64(v8::Handle<v8::Value>, IntegerConversionConfiguration, boo
l& ok); | 385 uint64_t toUInt64(v8::Handle<v8::Value>, IntegerConversionConfiguration, Exc
eptionState&); |
| 386 inline uint64_t toUInt64(v8::Handle<v8::Value> value, ExceptionState& except
ionState) |
| 387 { |
| 388 return toUInt64(value, NormalConversion, exceptionState); |
| 389 } |
391 | 390 |
392 // Convert a value to a 64-bit unsigned integer assuming the conversion cann
ot fail. | 391 // Convert a value to a 64-bit unsigned integer assuming the conversion cann
ot fail. |
393 inline uint64_t toUInt64(v8::Handle<v8::Value> value) | 392 uint64_t toUInt64(v8::Handle<v8::Value>); |
394 { | |
395 bool ok; | |
396 return toUInt64(value, NormalConversion, ok); | |
397 } | |
398 | 393 |
| 394 // Convert a value to a single precision float, which might fail. |
| 395 float toFloat(v8::Handle<v8::Value>, ExceptionState&); |
| 396 |
| 397 // Convert a value to a single precision float assuming the conversion canno
t fail. |
399 inline float toFloat(v8::Local<v8::Value> value) | 398 inline float toFloat(v8::Local<v8::Value> value) |
400 { | 399 { |
401 return static_cast<float>(value->NumberValue()); | 400 return static_cast<float>(value->NumberValue()); |
402 } | 401 } |
403 | 402 |
404 WrapperWorldType worldType(v8::Isolate*); | 403 WrapperWorldType worldType(v8::Isolate*); |
405 WrapperWorldType worldTypeInMainThread(v8::Isolate*); | 404 WrapperWorldType worldTypeInMainThread(v8::Isolate*); |
406 | 405 |
407 DOMWrapperWorld* isolatedWorldForIsolate(v8::Isolate*); | 406 DOMWrapperWorld* isolatedWorldForIsolate(v8::Isolate*); |
408 | 407 |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 // Result values for platform object 'deleter' methods, | 706 // Result values for platform object 'deleter' methods, |
708 // http://www.w3.org/TR/WebIDL/#delete | 707 // http://www.w3.org/TR/WebIDL/#delete |
709 enum DeleteResult { | 708 enum DeleteResult { |
710 DeleteSuccess, | 709 DeleteSuccess, |
711 DeleteReject, | 710 DeleteReject, |
712 DeleteUnknownProperty | 711 DeleteUnknownProperty |
713 }; | 712 }; |
714 } // namespace WebCore | 713 } // namespace WebCore |
715 | 714 |
716 #endif // V8Binding_h | 715 #endif // V8Binding_h |
OLD | NEW |