| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // Given the above test, this will always yield an object. | 54 // Given the above test, this will always yield an object. |
| 55 v8::Local<v8::Object> object = value->ToObject(); | 55 v8::Local<v8::Object> object = value->ToObject(); |
| 56 | 56 |
| 57 // For all three properties, we apply the following ... | 57 // For all three properties, we apply the following ... |
| 58 // - If the getter or the property's valueOf method throws an exception, we | 58 // - If the getter or the property's valueOf method throws an exception, we |
| 59 // quit so as not to risk overwriting the exception. | 59 // quit so as not to risk overwriting the exception. |
| 60 // - If the value is absent or undefined, we don't override the default. | 60 // - If the value is absent or undefined, we don't override the default. |
| 61 v8::Local<v8::Value> enableHighAccuracyValue = object->Get(v8AtomicString(is
olate, "enableHighAccuracy")); | 61 v8::Local<v8::Value> enableHighAccuracyValue = object->Get(v8AtomicString(is
olate, "enableHighAccuracy")); |
| 62 if (enableHighAccuracyValue.IsEmpty()) { | 62 if (enableHighAccuracyValue.IsEmpty()) { |
| 63 succeeded = false; | 63 succeeded = false; |
| 64 return 0; | 64 return nullptr; |
| 65 } | 65 } |
| 66 if (!enableHighAccuracyValue->IsUndefined()) { | 66 if (!enableHighAccuracyValue->IsUndefined()) { |
| 67 v8::Local<v8::Boolean> enableHighAccuracyBoolean = enableHighAccuracyVal
ue->ToBoolean(); | 67 v8::Local<v8::Boolean> enableHighAccuracyBoolean = enableHighAccuracyVal
ue->ToBoolean(); |
| 68 if (enableHighAccuracyBoolean.IsEmpty()) { | 68 if (enableHighAccuracyBoolean.IsEmpty()) { |
| 69 succeeded = false; | 69 succeeded = false; |
| 70 return 0; | 70 return nullptr; |
| 71 } | 71 } |
| 72 options->setEnableHighAccuracy(enableHighAccuracyBoolean->Value()); | 72 options->setEnableHighAccuracy(enableHighAccuracyBoolean->Value()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 v8::Local<v8::Value> timeoutValue = object->Get(v8AtomicString(isolate, "tim
eout")); | 75 v8::Local<v8::Value> timeoutValue = object->Get(v8AtomicString(isolate, "tim
eout")); |
| 76 if (timeoutValue.IsEmpty()) { | 76 if (timeoutValue.IsEmpty()) { |
| 77 succeeded = false; | 77 succeeded = false; |
| 78 return 0; | 78 return nullptr; |
| 79 } | 79 } |
| 80 if (!timeoutValue->IsUndefined()) { | 80 if (!timeoutValue->IsUndefined()) { |
| 81 v8::Local<v8::Number> timeoutNumber = timeoutValue->ToNumber(); | 81 v8::Local<v8::Number> timeoutNumber = timeoutValue->ToNumber(); |
| 82 if (timeoutNumber.IsEmpty()) { | 82 if (timeoutNumber.IsEmpty()) { |
| 83 succeeded = false; | 83 succeeded = false; |
| 84 return 0; | 84 return nullptr; |
| 85 } | 85 } |
| 86 double timeoutDouble = timeoutNumber->Value(); | 86 double timeoutDouble = timeoutNumber->Value(); |
| 87 // If the value is positive infinity, there's nothing to do. | 87 // If the value is positive infinity, there's nothing to do. |
| 88 if (!(std::isinf(timeoutDouble) && timeoutDouble > 0)) { | 88 if (!(std::isinf(timeoutDouble) && timeoutDouble > 0)) { |
| 89 v8::Local<v8::Int32> timeoutInt32 = timeoutValue->ToInt32(); | 89 v8::Local<v8::Int32> timeoutInt32 = timeoutValue->ToInt32(); |
| 90 if (timeoutInt32.IsEmpty()) { | 90 if (timeoutInt32.IsEmpty()) { |
| 91 succeeded = false; | 91 succeeded = false; |
| 92 return 0; | 92 return nullptr; |
| 93 } | 93 } |
| 94 // Wrap to int32 and force non-negative to match behavior of window.
setTimeout. | 94 // Wrap to int32 and force non-negative to match behavior of window.
setTimeout. |
| 95 options->setTimeout(max(0, timeoutInt32->Value())); | 95 options->setTimeout(max(0, timeoutInt32->Value())); |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 | 98 |
| 99 v8::Local<v8::Value> maximumAgeValue = object->Get(v8AtomicString(isolate, "
maximumAge")); | 99 v8::Local<v8::Value> maximumAgeValue = object->Get(v8AtomicString(isolate, "
maximumAge")); |
| 100 if (maximumAgeValue.IsEmpty()) { | 100 if (maximumAgeValue.IsEmpty()) { |
| 101 succeeded = false; | 101 succeeded = false; |
| 102 return 0; | 102 return nullptr; |
| 103 } | 103 } |
| 104 if (!maximumAgeValue->IsUndefined()) { | 104 if (!maximumAgeValue->IsUndefined()) { |
| 105 v8::Local<v8::Number> maximumAgeNumber = maximumAgeValue->ToNumber(); | 105 v8::Local<v8::Number> maximumAgeNumber = maximumAgeValue->ToNumber(); |
| 106 if (maximumAgeNumber.IsEmpty()) { | 106 if (maximumAgeNumber.IsEmpty()) { |
| 107 succeeded = false; | 107 succeeded = false; |
| 108 return 0; | 108 return nullptr; |
| 109 } | 109 } |
| 110 double maximumAgeDouble = maximumAgeNumber->Value(); | 110 double maximumAgeDouble = maximumAgeNumber->Value(); |
| 111 if (std::isinf(maximumAgeDouble) && maximumAgeDouble > 0) { | 111 if (std::isinf(maximumAgeDouble) && maximumAgeDouble > 0) { |
| 112 // If the value is positive infinity, clear maximumAge. | 112 // If the value is positive infinity, clear maximumAge. |
| 113 options->clearMaximumAge(); | 113 options->clearMaximumAge(); |
| 114 } else { | 114 } else { |
| 115 v8::Local<v8::Int32> maximumAgeInt32 = maximumAgeValue->ToInt32(); | 115 v8::Local<v8::Int32> maximumAgeInt32 = maximumAgeValue->ToInt32(); |
| 116 if (maximumAgeInt32.IsEmpty()) { | 116 if (maximumAgeInt32.IsEmpty()) { |
| 117 succeeded = false; | 117 succeeded = false; |
| 118 return 0; | 118 return nullptr; |
| 119 } | 119 } |
| 120 // Wrap to int32 and force non-negative to match behavior of window.
setTimeout. | 120 // Wrap to int32 and force non-negative to match behavior of window.
setTimeout. |
| 121 options->setMaximumAge(max(0, maximumAgeInt32->Value())); | 121 options->setMaximumAge(max(0, maximumAgeInt32->Value())); |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 return options.release(); | 125 return options.release(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void V8Geolocation::getCurrentPositionMethodCustom(const v8::FunctionCallbackInf
o<v8::Value>& info) | 128 void V8Geolocation::getCurrentPositionMethodCustom(const v8::FunctionCallbackInf
o<v8::Value>& info) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 if (!succeeded) | 170 if (!succeeded) |
| 171 return; | 171 return; |
| 172 ASSERT(positionOptions); | 172 ASSERT(positionOptions); |
| 173 | 173 |
| 174 Geolocation* geolocation = V8Geolocation::toNative(info.Holder()); | 174 Geolocation* geolocation = V8Geolocation::toNative(info.Holder()); |
| 175 int watchId = geolocation->watchPosition(positionCallback.release(), positio
nErrorCallback.release(), positionOptions.release()); | 175 int watchId = geolocation->watchPosition(positionCallback.release(), positio
nErrorCallback.release(), positionOptions.release()); |
| 176 v8SetReturnValue(info, watchId); | 176 v8SetReturnValue(info, watchId); |
| 177 } | 177 } |
| 178 | 178 |
| 179 } // namespace WebCore | 179 } // namespace WebCore |
| OLD | NEW |