Chromium Code Reviews| Index: Source/bindings/v8/custom/V8GeolocationCustom.cpp |
| diff --git a/Source/bindings/v8/custom/V8GeolocationCustom.cpp b/Source/bindings/v8/custom/V8GeolocationCustom.cpp |
| index 33a433b398e51df60f07af8d5ccc34e754116e13..d1105e791c5045a467c0ec45cced7431b3bdf3e1 100644 |
| --- a/Source/bindings/v8/custom/V8GeolocationCustom.cpp |
| +++ b/Source/bindings/v8/custom/V8GeolocationCustom.cpp |
| @@ -85,13 +85,21 @@ static PassRefPtrWillBeRawPtr<PositionOptions> createPositionOptions(v8::Local<v |
| double timeoutDouble = timeoutNumber->Value(); |
| // If the value is positive infinity, there's nothing to do. |
| if (!(std::isinf(timeoutDouble) && timeoutDouble > 0)) { |
| - v8::Local<v8::Int32> timeoutInt32 = timeoutValue->ToInt32(); |
| - if (timeoutInt32.IsEmpty()) { |
| - succeeded = false; |
| - return nullptr; |
| + unsigned timeout; |
|
Inactive
2014/05/22 13:21:07
Could we use toUInt32(timeoutValue, Clamp, es) fro
kihong
2014/05/23 05:03:11
Done, that's much simpler than now.
Thanks chris :
|
| + // If the value is over max of unsigned, timeout is max of unsigned. |
| + if (timeoutDouble >= std::numeric_limits<unsigned>::max()) { |
| + timeout = std::numeric_limits<unsigned>::max(); |
| + } else if (timeoutDouble <= 0) { |
| + timeout = 0; |
| + } else { |
| + v8::Local<v8::Uint32> timeoutUint32 = timeoutValue->ToUint32(); |
| + if (timeoutUint32.IsEmpty()) { |
| + succeeded = false; |
| + return nullptr; |
| + } |
| + timeout = timeoutUint32->Value(); |
| } |
| - // Wrap to int32 and force non-negative to match behavior of window.setTimeout. |
| - options->setTimeout(max(0, timeoutInt32->Value())); |
| + options->setTimeout(timeout); |
| } |
| } |
| @@ -111,13 +119,21 @@ static PassRefPtrWillBeRawPtr<PositionOptions> createPositionOptions(v8::Local<v |
| // If the value is positive infinity, clear maximumAge. |
| options->clearMaximumAge(); |
| } else { |
| - v8::Local<v8::Int32> maximumAgeInt32 = maximumAgeValue->ToInt32(); |
| - if (maximumAgeInt32.IsEmpty()) { |
| - succeeded = false; |
| - return nullptr; |
| + unsigned maximumAge; |
|
Inactive
2014/05/22 13:21:07
Ditto.
|
| + // If the value is over max of unsigned, maximunAge is max of unsigned. |
| + if (maximumAgeDouble >= std::numeric_limits<unsigned>::max()) { |
| + maximumAge = std::numeric_limits<unsigned>::max(); |
| + } else if (maximumAgeDouble <= 0) { |
| + maximumAge = 0; |
| + } else { |
| + v8::Local<v8::Uint32> maximumAgeUint32 = maximumAgeValue->ToUint32(); |
| + if (maximumAgeUint32.IsEmpty()) { |
| + succeeded = false; |
| + return nullptr; |
| + } |
| + maximumAge = maximumAgeUint32->Value(); |
| } |
| - // Wrap to int32 and force non-negative to match behavior of window.setTimeout. |
| - options->setMaximumAge(max(0, maximumAgeInt32->Value())); |
| + options->setMaximumAge(maximumAge); |
| } |
| } |