diff options
Diffstat (limited to 'WebCore/bindings/js/JSGeolocationCustom.cpp')
-rw-r--r-- | WebCore/bindings/js/JSGeolocationCustom.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/WebCore/bindings/js/JSGeolocationCustom.cpp b/WebCore/bindings/js/JSGeolocationCustom.cpp index 8ef8601..530b89b 100644 --- a/WebCore/bindings/js/JSGeolocationCustom.cpp +++ b/WebCore/bindings/js/JSGeolocationCustom.cpp @@ -34,40 +34,39 @@ #include "JSCustomPositionErrorCallback.h" #include "JSDOMWindow.h" #include "PositionOptions.h" +#include <runtime/InternalFunction.h> using namespace JSC; using namespace std; namespace WebCore { -static PassRefPtr<PositionCallback> createPositionCallback(ExecState* exec, JSValue value) +static PassRefPtr<PositionCallback> createPositionCallback(ExecState* exec, JSDOMGlobalObject* globalObject, JSValue value) { // The spec specifies 'FunctionOnly' for this object. - if (!value.isObject(&InternalFunction::info)) { + if (!value.inherits(&InternalFunction::info)) { setDOMException(exec, TYPE_MISMATCH_ERR); return 0; } JSObject* object = asObject(value); - Frame* frame = toJSDOMWindow(exec->lexicalGlobalObject())->impl()->frame(); - return JSCustomPositionCallback::create(object, frame); + return JSCustomPositionCallback::create(object, globalObject); } -static PassRefPtr<PositionErrorCallback> createPositionErrorCallback(ExecState* exec, JSValue value) +static PassRefPtr<PositionErrorCallback> createPositionErrorCallback(ExecState* exec, JSDOMGlobalObject* globalObject, JSValue value) { // Argument is optional (hence undefined is allowed), and null is allowed. if (value.isUndefinedOrNull()) return 0; // The spec specifies 'FunctionOnly' for this object. - if (!value.isObject(&InternalFunction::info)) { + if (!value.inherits(&InternalFunction::info)) { setDOMException(exec, TYPE_MISMATCH_ERR); return 0; } JSObject* object = asObject(value); - Frame* frame = toJSDOMWindow(exec->lexicalGlobalObject())->impl()->frame(); - return JSCustomPositionErrorCallback::create(object, frame); + return JSCustomPositionErrorCallback::create(object, globalObject); } static PassRefPtr<PositionOptions> createPositionOptions(ExecState* exec, JSValue value) @@ -91,7 +90,7 @@ static PassRefPtr<PositionOptions> createPositionOptions(ExecState* exec, JSValu JSValue enableHighAccuracyValue = object->get(exec, Identifier(exec, "enableHighAccuracy")); if (exec->hadException()) return 0; - if(!enableHighAccuracyValue.isUndefined()) { + if (!enableHighAccuracyValue.isUndefined()) { options->setEnableHighAccuracy(enableHighAccuracyValue.toBoolean(exec)); if (exec->hadException()) return 0; @@ -104,8 +103,8 @@ static PassRefPtr<PositionOptions> createPositionOptions(ExecState* exec, JSValu double timeoutNumber = timeoutValue.toNumber(exec); if (exec->hadException()) return 0; - // If the value is infinity, there's nothing to do. - if (timeoutNumber != Inf) { + // If the value is positive infinity, there's nothing to do. + if (!(isinf(timeoutNumber) && (timeoutNumber > 0))) { // Wrap to int32 and force non-negative to match behavior of window.setTimeout. options->setTimeout(max(0, timeoutValue.toInt32(exec))); if (exec->hadException()) @@ -120,8 +119,8 @@ static PassRefPtr<PositionOptions> createPositionOptions(ExecState* exec, JSValu double maximumAgeNumber = maximumAgeValue.toNumber(exec); if (exec->hadException()) return 0; - if (maximumAgeNumber == Inf) { - // If the value is infinity, clear maximumAge. + if (isinf(maximumAgeNumber) && (maximumAgeNumber > 0)) { + // If the value is positive infinity, clear maximumAge. options->clearMaximumAge(); } else { // Wrap to int32 and force non-negative to match behavior of window.setTimeout. @@ -138,12 +137,12 @@ JSValue JSGeolocation::getCurrentPosition(ExecState* exec, const ArgList& args) { // Arguments: PositionCallback, (optional)PositionErrorCallback, (optional)PositionOptions - RefPtr<PositionCallback> positionCallback = createPositionCallback(exec, args.at(0)); + RefPtr<PositionCallback> positionCallback = createPositionCallback(exec, static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), args.at(0)); if (exec->hadException()) return jsUndefined(); ASSERT(positionCallback); - RefPtr<PositionErrorCallback> positionErrorCallback = createPositionErrorCallback(exec, args.at(1)); + RefPtr<PositionErrorCallback> positionErrorCallback = createPositionErrorCallback(exec, static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), args.at(1)); if (exec->hadException()) return jsUndefined(); @@ -160,12 +159,12 @@ JSValue JSGeolocation::watchPosition(ExecState* exec, const ArgList& args) { // Arguments: PositionCallback, (optional)PositionErrorCallback, (optional)PositionOptions - RefPtr<PositionCallback> positionCallback = createPositionCallback(exec, args.at(0)); + RefPtr<PositionCallback> positionCallback = createPositionCallback(exec, static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), args.at(0)); if (exec->hadException()) return jsUndefined(); ASSERT(positionCallback); - RefPtr<PositionErrorCallback> positionErrorCallback = createPositionErrorCallback(exec, args.at(1)); + RefPtr<PositionErrorCallback> positionErrorCallback = createPositionErrorCallback(exec, static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), args.at(1)); if (exec->hadException()) return jsUndefined(); |