| 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 // Conversion flags, used in toIntXX/toUIntXX. | 271 // Conversion flags, used in toIntXX/toUIntXX. |
| 271 enum IntegerConversionConfiguration { | 272 enum IntegerConversionConfiguration { |
| 272 NormalConversion, | 273 NormalConversion, |
| 273 EnforceRange, | 274 EnforceRange, |
| 274 Clamp | 275 Clamp |
| 275 }; | 276 }; |
| 276 | 277 |
| 277 // Convert a value to a 8-bit signed integer. The conversion fails if the | 278 // Convert a value to a 8-bit signed integer. The conversion fails if the |
| 278 // value cannot be converted to a number or the range violated per WebIDL: | 279 // value cannot be converted to a number or the range violated per WebIDL: |
| 279 // http://www.w3.org/TR/WebIDL/#es-byte | 280 // http://www.w3.org/TR/WebIDL/#es-byte |
| 280 int8_t toInt8(v8::Handle<v8::Value>, IntegerConversionConfiguration, bool& o
k); | 281 int8_t toInt8(v8::Handle<v8::Value>, IntegerConversionConfiguration, Excepti
onState&); |
| 281 inline int8_t toInt8(v8::Handle<v8::Value> value, bool& ok) { return toInt8(
value, NormalConversion, ok); } | 282 inline int8_t toInt8(v8::Handle<v8::Value> value, ExceptionState& exceptionS
tate) |
| 283 { |
| 284 return toInt8(value, NormalConversion, exceptionState); |
| 285 } |
| 282 | 286 |
| 283 // Convert a value to a 8-bit integer assuming the conversion cannot fail. | 287 // Convert a value to a 8-bit integer assuming the conversion cannot fail. |
| 284 inline int8_t toInt8(v8::Handle<v8::Value> value) | 288 int8_t toInt8(v8::Handle<v8::Value>); |
| 285 { | |
| 286 bool ok; | |
| 287 return toInt8(value, NormalConversion, ok); | |
| 288 } | |
| 289 | 289 |
| 290 // Convert a value to a 8-bit unsigned integer. The conversion fails if the | 290 // Convert a value to a 8-bit unsigned integer. The conversion fails if the |
| 291 // value cannot be converted to a number or the range violated per WebIDL: | 291 // value cannot be converted to a number or the range violated per WebIDL: |
| 292 // http://www.w3.org/TR/WebIDL/#es-octet | 292 // http://www.w3.org/TR/WebIDL/#es-octet |
| 293 uint8_t toUInt8(v8::Handle<v8::Value>, IntegerConversionConfiguration, bool&
ok); | 293 uint8_t toUInt8(v8::Handle<v8::Value>, IntegerConversionConfiguration, Excep
tionState&); |
| 294 inline uint8_t toUInt8(v8::Handle<v8::Value> value, bool& ok) { return toUIn
t8(value, NormalConversion, ok); } | 294 inline uint8_t toUInt8(v8::Handle<v8::Value> value, ExceptionState& exceptio
nState) |
| 295 { |
| 296 return toUInt8(value, NormalConversion, exceptionState); |
| 297 } |
| 295 | 298 |
| 296 // Convert a value to a 8-bit unsigned integer assuming the conversion canno
t fail. | 299 // Convert a value to a 8-bit unsigned integer assuming the conversion canno
t fail. |
| 297 inline uint8_t toUInt8(v8::Handle<v8::Value> value) | 300 uint8_t toUInt8(v8::Handle<v8::Value>); |
| 298 { | |
| 299 bool ok; | |
| 300 return toUInt8(value, NormalConversion, ok); | |
| 301 } | |
| 302 | 301 |
| 303 // Convert a value to a 16-bit signed integer. The conversion fails if the | 302 // Convert a value to a 16-bit signed integer. The conversion fails if the |
| 304 // value cannot be converted to a number or the range violated per WebIDL: | 303 // value cannot be converted to a number or the range violated per WebIDL: |
| 305 // http://www.w3.org/TR/WebIDL/#es-short | 304 // http://www.w3.org/TR/WebIDL/#es-short |
| 306 int16_t toInt16(v8::Handle<v8::Value>, IntegerConversionConfiguration, bool&
ok); | 305 int16_t toInt16(v8::Handle<v8::Value>, IntegerConversionConfiguration, Excep
tionState&); |
| 307 inline int16_t toInt16(v8::Handle<v8::Value> value, bool& ok) { return toInt
16(value, NormalConversion, ok); } | 306 inline int16_t toInt16(v8::Handle<v8::Value> value, ExceptionState& exceptio
nState) |
| 307 { |
| 308 return toInt16(value, NormalConversion, exceptionState); |
| 309 } |
| 308 | 310 |
| 309 // Convert a value to a 16-bit integer assuming the conversion cannot fail. | 311 // Convert a value to a 16-bit integer assuming the conversion cannot fail. |
| 310 inline int16_t toInt16(v8::Handle<v8::Value> value) | 312 int16_t toInt16(v8::Handle<v8::Value>); |
| 311 { | |
| 312 bool ok; | |
| 313 return toInt16(value, NormalConversion, ok); | |
| 314 } | |
| 315 | 313 |
| 316 // Convert a value to a 16-bit unsigned integer. The conversion fails if the | 314 // Convert a value to a 16-bit unsigned integer. The conversion fails if the |
| 317 // value cannot be converted to a number or the range violated per WebIDL: | 315 // value cannot be converted to a number or the range violated per WebIDL: |
| 318 // http://www.w3.org/TR/WebIDL/#es-unsigned-short | 316 // http://www.w3.org/TR/WebIDL/#es-unsigned-short |
| 319 uint16_t toUInt16(v8::Handle<v8::Value>, IntegerConversionConfiguration, boo
l& ok); | 317 uint16_t toUInt16(v8::Handle<v8::Value>, IntegerConversionConfiguration, Exc
eptionState&); |
| 320 inline uint16_t toUInt16(v8::Handle<v8::Value> value, bool& ok) { return toU
Int16(value, NormalConversion, ok); } | 318 inline uint16_t toUInt16(v8::Handle<v8::Value> value, ExceptionState& except
ionState) |
| 319 { |
| 320 return toUInt16(value, NormalConversion, exceptionState); |
| 321 } |
| 321 | 322 |
| 322 // Convert a value to a 16-bit unsigned integer assuming the conversion cann
ot fail. | 323 // Convert a value to a 16-bit unsigned integer assuming the conversion cann
ot fail. |
| 323 inline uint16_t toUInt16(v8::Handle<v8::Value> value) | 324 uint16_t toUInt16(v8::Handle<v8::Value>); |
| 324 { | |
| 325 bool ok; | |
| 326 return toUInt16(value, NormalConversion, ok); | |
| 327 } | |
| 328 | 325 |
| 329 // Convert a value to a 32-bit signed integer. The conversion fails if the | 326 // Convert a value to a 32-bit signed integer. The conversion fails if the |
| 330 // value cannot be converted to a number or the range violated per WebIDL: | 327 // value cannot be converted to a number or the range violated per WebIDL: |
| 331 // http://www.w3.org/TR/WebIDL/#es-long | 328 // http://www.w3.org/TR/WebIDL/#es-long |
| 332 int32_t toInt32(v8::Handle<v8::Value>, IntegerConversionConfiguration, bool&
ok); | 329 int32_t toInt32(v8::Handle<v8::Value>, IntegerConversionConfiguration, Excep
tionState&); |
| 333 inline int32_t toInt32(v8::Handle<v8::Value> value, bool& ok) { return toInt
32(value, NormalConversion, ok); } | 330 inline int32_t toInt32(v8::Handle<v8::Value> value, ExceptionState& exceptio
nState) |
| 331 { |
| 332 return toInt32(value, NormalConversion, exceptionState); |
| 333 } |
| 334 | 334 |
| 335 // Convert a value to a 32-bit integer assuming the conversion cannot fail. | 335 // Convert a value to a 32-bit integer assuming the conversion cannot fail. |
| 336 inline int32_t toInt32(v8::Handle<v8::Value> value) | 336 int32_t toInt32(v8::Handle<v8::Value>); |
| 337 { | |
| 338 bool ok; | |
| 339 return toInt32(value, NormalConversion, ok); | |
| 340 } | |
| 341 | 337 |
| 342 // Convert a value to a 32-bit unsigned integer. The conversion fails if the | 338 // Convert a value to a 32-bit unsigned integer. The conversion fails if the |
| 343 // value cannot be converted to a number or the range violated per WebIDL: | 339 // value cannot be converted to a number or the range violated per WebIDL: |
| 344 // http://www.w3.org/TR/WebIDL/#es-unsigned-long | 340 // http://www.w3.org/TR/WebIDL/#es-unsigned-long |
| 345 uint32_t toUInt32(v8::Handle<v8::Value>, IntegerConversionConfiguration, boo
l& ok); | 341 uint32_t toUInt32(v8::Handle<v8::Value>, IntegerConversionConfiguration, Exc
eptionState&); |
| 346 inline uint32_t toUInt32(v8::Handle<v8::Value> value, bool& ok) { return toU
Int32(value, NormalConversion, ok); } | 342 inline uint32_t toUInt32(v8::Handle<v8::Value> value, ExceptionState& except
ionState) |
| 343 { |
| 344 return toUInt32(value, NormalConversion, exceptionState); |
| 345 } |
| 347 | 346 |
| 348 // Convert a value to a 32-bit unsigned integer assuming the conversion cann
ot fail. | 347 // Convert a value to a 32-bit unsigned integer assuming the conversion cann
ot fail. |
| 349 inline uint32_t toUInt32(v8::Handle<v8::Value> value) | 348 uint32_t toUInt32(v8::Handle<v8::Value>); |
| 350 { | |
| 351 bool ok; | |
| 352 return toUInt32(value, NormalConversion, ok); | |
| 353 } | |
| 354 | 349 |
| 355 // Convert a value to a 64-bit signed integer. The conversion fails if the | 350 // Convert a value to a 64-bit signed integer. The conversion fails if the |
| 356 // value cannot be converted to a number or the range violated per WebIDL: | 351 // value cannot be converted to a number or the range violated per WebIDL: |
| 357 // http://www.w3.org/TR/WebIDL/#es-long-long | 352 // http://www.w3.org/TR/WebIDL/#es-long-long |
| 358 int64_t toInt64(v8::Handle<v8::Value>, IntegerConversionConfiguration, bool&
ok); | 353 int64_t toInt64(v8::Handle<v8::Value>, IntegerConversionConfiguration, Excep
tionState&); |
| 354 inline int64_t toInt64(v8::Handle<v8::Value> value, ExceptionState& exceptio
nState) |
| 355 { |
| 356 return toInt64(value, NormalConversion, exceptionState); |
| 357 } |
| 359 | 358 |
| 360 // Convert a value to a 64-bit integer assuming the conversion cannot fail. | 359 // Convert a value to a 64-bit integer assuming the conversion cannot fail. |
| 361 inline int64_t toInt64(v8::Handle<v8::Value> value) | 360 int64_t toInt64(v8::Handle<v8::Value>); |
| 362 { | |
| 363 bool ok; | |
| 364 return toInt64(value, NormalConversion, ok); | |
| 365 } | |
| 366 | 361 |
| 367 // Convert a value to a 64-bit unsigned integer. The conversion fails if the | 362 // Convert a value to a 64-bit unsigned integer. The conversion fails if the |
| 368 // value cannot be converted to a number or the range violated per WebIDL: | 363 // value cannot be converted to a number or the range violated per WebIDL: |
| 369 // http://www.w3.org/TR/WebIDL/#es-unsigned-long-long | 364 // http://www.w3.org/TR/WebIDL/#es-unsigned-long-long |
| 370 uint64_t toUInt64(v8::Handle<v8::Value>, IntegerConversionConfiguration, boo
l& ok); | 365 uint64_t toUInt64(v8::Handle<v8::Value>, IntegerConversionConfiguration, Exc
eptionState&); |
| 366 inline uint64_t toUInt64(v8::Handle<v8::Value> value, ExceptionState& except
ionState) |
| 367 { |
| 368 return toUInt64(value, NormalConversion, exceptionState); |
| 369 } |
| 371 | 370 |
| 372 // Convert a value to a 64-bit unsigned integer assuming the conversion cann
ot fail. | 371 // Convert a value to a 64-bit unsigned integer assuming the conversion cann
ot fail. |
| 373 inline uint64_t toUInt64(v8::Handle<v8::Value> value) | 372 uint64_t toUInt64(v8::Handle<v8::Value>); |
| 374 { | |
| 375 bool ok; | |
| 376 return toUInt64(value, NormalConversion, ok); | |
| 377 } | |
| 378 | 373 |
| 374 // Convert a value to a single precision float, which might fail. |
| 375 float toFloat(v8::Handle<v8::Value>, ExceptionState&); |
| 376 |
| 377 // Convert a value to a single precision float assuming the conversion canno
t fail. |
| 379 inline float toFloat(v8::Local<v8::Value> value) | 378 inline float toFloat(v8::Local<v8::Value> value) |
| 380 { | 379 { |
| 381 return static_cast<float>(value->NumberValue()); | 380 return static_cast<float>(value->NumberValue()); |
| 382 } | 381 } |
| 383 | 382 |
| 384 WrapperWorldType worldType(v8::Isolate*); | 383 WrapperWorldType worldType(v8::Isolate*); |
| 385 WrapperWorldType worldTypeInMainThread(v8::Isolate*); | 384 WrapperWorldType worldTypeInMainThread(v8::Isolate*); |
| 386 | 385 |
| 387 DOMWrapperWorld* isolatedWorldForIsolate(v8::Isolate*); | 386 DOMWrapperWorld* isolatedWorldForIsolate(v8::Isolate*); |
| 388 | 387 |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 // Result values for platform object 'deleter' methods, | 699 // Result values for platform object 'deleter' methods, |
| 701 // http://www.w3.org/TR/WebIDL/#delete | 700 // http://www.w3.org/TR/WebIDL/#delete |
| 702 enum DeleteResult { | 701 enum DeleteResult { |
| 703 DeleteSuccess, | 702 DeleteSuccess, |
| 704 DeleteReject, | 703 DeleteReject, |
| 705 DeleteUnknownProperty | 704 DeleteUnknownProperty |
| 706 }; | 705 }; |
| 707 } // namespace WebCore | 706 } // namespace WebCore |
| 708 | 707 |
| 709 #endif // V8Binding_h | 708 #endif // V8Binding_h |
| OLD | NEW |