| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple 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 | 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 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 DeviceMotionData::Acceleration* readAccelerationArgument(v8::Local<v8::Value> va
lue, v8::Isolate* isolate) | 37 DeviceMotionData::Acceleration* readAccelerationArgument(v8::Local<v8::Value> va
lue, v8::Isolate* isolate) |
| 38 { | 38 { |
| 39 if (isUndefinedOrNull(value)) | 39 if (isUndefinedOrNull(value)) |
| 40 return nullptr; | 40 return nullptr; |
| 41 | 41 |
| 42 // Given the test above, this will always yield an object. | 42 v8::Local<v8::Object> object; |
| 43 v8::Local<v8::Object> object = value->ToObject(isolate); | 43 if (!value->ToObject(isolate->GetCurrentContext()).ToLocal(&object)) |
| 44 return nullptr; |
| 44 | 45 |
| 45 v8::Local<v8::Value> xValue = object->Get(v8AtomicString(isolate, "x")); | 46 v8::Local<v8::Value> xValue = object->Get(v8AtomicString(isolate, "x")); |
| 46 if (xValue.IsEmpty()) | 47 if (xValue.IsEmpty()) |
| 47 return nullptr; | 48 return nullptr; |
| 48 bool canProvideX = !isUndefinedOrNull(xValue); | 49 bool canProvideX = !isUndefinedOrNull(xValue); |
| 49 double x = xValue->NumberValue(); | 50 double x = xValue->NumberValue(); |
| 50 | 51 |
| 51 v8::Local<v8::Value> yValue = object->Get(v8AtomicString(isolate, "y")); | 52 v8::Local<v8::Value> yValue = object->Get(v8AtomicString(isolate, "y")); |
| 52 if (yValue.IsEmpty()) | 53 if (yValue.IsEmpty()) |
| 53 return nullptr; | 54 return nullptr; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 64 return nullptr; | 65 return nullptr; |
| 65 | 66 |
| 66 return DeviceMotionData::Acceleration::create(canProvideX, x, canProvideY, y
, canProvideZ, z); | 67 return DeviceMotionData::Acceleration::create(canProvideX, x, canProvideY, y
, canProvideZ, z); |
| 67 } | 68 } |
| 68 | 69 |
| 69 DeviceMotionData::RotationRate* readRotationRateArgument(v8::Local<v8::Value> va
lue, v8::Isolate* isolate) | 70 DeviceMotionData::RotationRate* readRotationRateArgument(v8::Local<v8::Value> va
lue, v8::Isolate* isolate) |
| 70 { | 71 { |
| 71 if (isUndefinedOrNull(value)) | 72 if (isUndefinedOrNull(value)) |
| 72 return nullptr; | 73 return nullptr; |
| 73 | 74 |
| 74 // Given the test above, this will always yield an object. | 75 v8::Local<v8::Object> object; |
| 75 v8::Local<v8::Object> object = value->ToObject(isolate); | 76 if (!value->ToObject(isolate->GetCurrentContext()).ToLocal(&object)) |
| 77 return nullptr; |
| 76 | 78 |
| 77 v8::Local<v8::Value> alphaValue = object->Get(v8AtomicString(isolate, "alpha
")); | 79 v8::Local<v8::Value> alphaValue = object->Get(v8AtomicString(isolate, "alpha
")); |
| 78 if (alphaValue.IsEmpty()) | 80 if (alphaValue.IsEmpty()) |
| 79 return nullptr; | 81 return nullptr; |
| 80 bool canProvideAlpha = !isUndefinedOrNull(alphaValue); | 82 bool canProvideAlpha = !isUndefinedOrNull(alphaValue); |
| 81 double alpha = alphaValue->NumberValue(); | 83 double alpha = alphaValue->NumberValue(); |
| 82 | 84 |
| 83 v8::Local<v8::Value> betaValue = object->Get(v8AtomicString(isolate, "beta")
); | 85 v8::Local<v8::Value> betaValue = object->Get(v8AtomicString(isolate, "beta")
); |
| 84 if (betaValue.IsEmpty()) | 86 if (betaValue.IsEmpty()) |
| 85 return nullptr; | 87 return nullptr; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 if (intervalProvided) { | 120 if (intervalProvided) { |
| 119 interval = toRestrictedDouble(info[6], exceptionState); | 121 interval = toRestrictedDouble(info[6], exceptionState); |
| 120 if (exceptionState.throwIfNeeded()) | 122 if (exceptionState.throwIfNeeded()) |
| 121 return; | 123 return; |
| 122 } | 124 } |
| 123 DeviceMotionData* deviceMotionData = DeviceMotionData::create(acceleration,
accelerationIncludingGravity, rotationRate, intervalProvided, interval); | 125 DeviceMotionData* deviceMotionData = DeviceMotionData::create(acceleration,
accelerationIncludingGravity, rotationRate, intervalProvided, interval); |
| 124 impl->initDeviceMotionEvent(type, bubbles, cancelable, deviceMotionData); | 126 impl->initDeviceMotionEvent(type, bubbles, cancelable, deviceMotionData); |
| 125 } | 127 } |
| 126 | 128 |
| 127 } // namespace blink | 129 } // namespace blink |
| OLD | NEW |