| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 344 |
| 345 return numberObject->Int32Value(); | 345 return numberObject->Int32Value(); |
| 346 } | 346 } |
| 347 | 347 |
| 348 int32_t toInt32(v8::Handle<v8::Value> value) | 348 int32_t toInt32(v8::Handle<v8::Value> value) |
| 349 { | 349 { |
| 350 NonThrowableExceptionState exceptionState; | 350 NonThrowableExceptionState exceptionState; |
| 351 return toInt32(value, NormalConversion, exceptionState); | 351 return toInt32(value, NormalConversion, exceptionState); |
| 352 } | 352 } |
| 353 | 353 |
| 354 uint32_t toUInt32(v8::Handle<v8::Value> value, IntegerConversionConfiguration co
nfiguration, ExceptionState& exceptionState) | 354 uint32_t toUInt32Slow(v8::Handle<v8::Value> value, IntegerConversionConfiguratio
n configuration, ExceptionState& exceptionState) |
| 355 { | 355 { |
| 356 // Fast case. The value is already a 32-bit unsigned integer. | 356 ASSERT(!value->IsUint32() || !value->IsInt32()()); |
| 357 if (value->IsUint32()) | 357 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 358 return value->Uint32Value(); | 358 // Can the value be converted to a number? |
| 359 | 359 v8::Local<v8::Number> numberObject = value->ToNumber(isolate); |
| 360 // Fast case. The value is a 32-bit signed integer - possibly positive? | 360 v8::TryCatch block(isolate); |
| 361 if (value->IsInt32()) { | 361 if (block.HasCaught()) { |
| 362 int32_t result = value->Int32Value(); | 362 exceptionState.rethrowV8Exception(block.Exception()); |
| 363 if (result >= 0) | 363 return 0; |
| 364 return result; | |
| 365 if (configuration == EnforceRange) { | |
| 366 exceptionState.throwTypeError("Value is outside the 'unsigned long'
value range."); | |
| 367 return 0; | |
| 368 } | |
| 369 if (configuration == Clamp) | |
| 370 return clampTo<uint32_t>(result); | |
| 371 return result; | |
| 372 } | |
| 373 | |
| 374 v8::Local<v8::Number> numberObject; | |
| 375 if (value->IsNumber()) { | |
| 376 numberObject = value.As<v8::Number>(); | |
| 377 } else { | |
| 378 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
| 379 // Can the value be converted to a number? | |
| 380 v8::TryCatch block(isolate); | |
| 381 numberObject = value->ToNumber(isolate); | |
| 382 if (block.HasCaught()) { | |
| 383 exceptionState.rethrowV8Exception(block.Exception()); | |
| 384 return 0; | |
| 385 } | |
| 386 } | 364 } |
| 387 ASSERT(!numberObject.IsEmpty()); | 365 ASSERT(!numberObject.IsEmpty()); |
| 388 | 366 |
| 389 if (configuration == EnforceRange) | 367 if (configuration == EnforceRange) |
| 390 return enforceRange(numberObject->Value(), 0, kMaxUInt32, "unsigned long
", exceptionState); | 368 return enforceRange(numberObject->Value(), 0, kMaxUInt32, "unsigned long
", exceptionState); |
| 391 | 369 |
| 392 double numberValue = numberObject->Value(); | 370 double numberValue = numberObject->Value(); |
| 393 | 371 |
| 394 if (std::isnan(numberValue)) | 372 if (std::isnan(numberValue)) |
| 395 return 0; | 373 return 0; |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 attributes->append(value); | 1064 attributes->append(value); |
| 1087 } | 1065 } |
| 1088 | 1066 |
| 1089 AttributesWithSideEffectOnGet::AttributeSet* AttributesWithSideEffectOnGet::attr
ibutesWithSideEffectOnGet() | 1067 AttributesWithSideEffectOnGet::AttributeSet* AttributesWithSideEffectOnGet::attr
ibutesWithSideEffectOnGet() |
| 1090 { | 1068 { |
| 1091 DEFINE_STATIC_LOCAL(AttributeSet, attributes, ()); | 1069 DEFINE_STATIC_LOCAL(AttributeSet, attributes, ()); |
| 1092 return &attributes; | 1070 return &attributes; |
| 1093 } | 1071 } |
| 1094 | 1072 |
| 1095 } // namespace blink | 1073 } // namespace blink |
| OLD | NEW |