| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009, The Android Open Source Project | 2 * Copyright 2009, The Android Open Source Project |
| 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * * Redistributions of source code must retain the above copyright | 7 * * Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * * Redistributions in binary form must reproduce the above copyright | 9 * * Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 if (timeoutValue.IsEmpty()) { | 75 if (timeoutValue.IsEmpty()) { |
| 76 succeeded = false; | 76 succeeded = false; |
| 77 return nullptr; | 77 return nullptr; |
| 78 } | 78 } |
| 79 if (!timeoutValue->IsUndefined()) { | 79 if (!timeoutValue->IsUndefined()) { |
| 80 v8::Local<v8::Number> timeoutNumber = timeoutValue->ToNumber(); | 80 v8::Local<v8::Number> timeoutNumber = timeoutValue->ToNumber(); |
| 81 if (timeoutNumber.IsEmpty()) { | 81 if (timeoutNumber.IsEmpty()) { |
| 82 succeeded = false; | 82 succeeded = false; |
| 83 return nullptr; | 83 return nullptr; |
| 84 } | 84 } |
| 85 double timeoutDouble = timeoutNumber->Value(); | 85 if (timeoutNumber->Value() <= 0) |
| 86 // If the value is positive infinity, there's nothing to do. | 86 options->setTimeout(0); |
| 87 if (!(std::isinf(timeoutDouble) && timeoutDouble > 0)) { | 87 else |
| 88 if (timeoutDouble <= 0) { | 88 options->setTimeout(toUInt32(timeoutValue, Clamp, exceptionState)); |
| 89 options->setTimeout(0); | |
| 90 } else { | |
| 91 options->setTimeout(toUInt32(timeoutValue, Clamp, exceptionState
)); | |
| 92 } | |
| 93 } | |
| 94 } | 89 } |
| 95 | 90 |
| 96 v8::Local<v8::Value> maximumAgeValue = object->Get(v8AtomicString(isolate, "
maximumAge")); | 91 v8::Local<v8::Value> maximumAgeValue = object->Get(v8AtomicString(isolate, "
maximumAge")); |
| 97 if (maximumAgeValue.IsEmpty()) { | 92 if (maximumAgeValue.IsEmpty()) { |
| 98 succeeded = false; | 93 succeeded = false; |
| 99 return nullptr; | 94 return nullptr; |
| 100 } | 95 } |
| 101 if (!maximumAgeValue->IsUndefined()) { | 96 if (!maximumAgeValue->IsUndefined()) { |
| 102 v8::Local<v8::Number> maximumAgeNumber = maximumAgeValue->ToNumber(); | 97 v8::Local<v8::Number> maximumAgeNumber = maximumAgeValue->ToNumber(); |
| 103 if (maximumAgeNumber.IsEmpty()) { | 98 if (maximumAgeNumber.IsEmpty()) { |
| 104 succeeded = false; | 99 succeeded = false; |
| 105 return nullptr; | 100 return nullptr; |
| 106 } | 101 } |
| 107 double maximumAgeDouble = maximumAgeNumber->Value(); | 102 if (maximumAgeNumber->Value() <= 0) |
| 108 if (std::isinf(maximumAgeDouble) && maximumAgeDouble > 0) { | 103 options->setMaximumAge(0); |
| 109 // If the value is positive infinity, clear maximumAge. | 104 else |
| 110 options->clearMaximumAge(); | 105 options->setMaximumAge(toUInt32(maximumAgeValue, Clamp, exceptionSta
te)); |
| 111 } else { | |
| 112 if (maximumAgeDouble <= 0) { | |
| 113 options->setMaximumAge(0); | |
| 114 } else { | |
| 115 options->setMaximumAge(toUInt32(maximumAgeValue, Clamp, exceptio
nState)); | |
| 116 } | |
| 117 } | |
| 118 } | 106 } |
| 119 | 107 |
| 120 return options.release(); | 108 return options.release(); |
| 121 } | 109 } |
| 122 | 110 |
| 123 void V8Geolocation::getCurrentPositionMethodCustom(const v8::FunctionCallbackInf
o<v8::Value>& info) | 111 void V8Geolocation::getCurrentPositionMethodCustom(const v8::FunctionCallbackInf
o<v8::Value>& info) |
| 124 { | 112 { |
| 125 bool succeeded = false; | 113 bool succeeded = false; |
| 126 | 114 |
| 127 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getCurrentP
osition", "Geolocation", info.Holder(), info.GetIsolate()); | 115 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getCurrentP
osition", "Geolocation", info.Holder(), info.GetIsolate()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 if (!succeeded) | 153 if (!succeeded) |
| 166 return; | 154 return; |
| 167 ASSERT(positionOptions); | 155 ASSERT(positionOptions); |
| 168 | 156 |
| 169 Geolocation* geolocation = V8Geolocation::toNative(info.Holder()); | 157 Geolocation* geolocation = V8Geolocation::toNative(info.Holder()); |
| 170 int watchId = geolocation->watchPosition(positionCallback.release(), positio
nErrorCallback.release(), positionOptions.release()); | 158 int watchId = geolocation->watchPosition(positionCallback.release(), positio
nErrorCallback.release(), positionOptions.release()); |
| 171 v8SetReturnValue(info, watchId); | 159 v8SetReturnValue(info, watchId); |
| 172 } | 160 } |
| 173 | 161 |
| 174 } // namespace WebCore | 162 } // namespace WebCore |
| OLD | NEW |