OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google 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 16 matching lines...) Expand all Loading... |
27 #include "bindings/modules/v8/V8DeviceOrientationEvent.h" | 27 #include "bindings/modules/v8/V8DeviceOrientationEvent.h" |
28 | 28 |
29 #include "bindings/core/v8/V8Binding.h" | 29 #include "bindings/core/v8/V8Binding.h" |
30 #include "modules/device_orientation/DeviceOrientationData.h" | 30 #include "modules/device_orientation/DeviceOrientationData.h" |
31 #include <v8.h> | 31 #include <v8.h> |
32 | 32 |
33 namespace blink { | 33 namespace blink { |
34 | 34 |
35 void V8DeviceOrientationEvent::initDeviceOrientationEventMethodCustom(const v8::
FunctionCallbackInfo<v8::Value>& info) | 35 void V8DeviceOrientationEvent::initDeviceOrientationEventMethodCustom(const v8::
FunctionCallbackInfo<v8::Value>& info) |
36 { | 36 { |
37 ExceptionState exceptionState(ExceptionState::ExecutionContext, "initDeviceO
rientationEvent", "DeviceOrientationEvent", info.Holder(), info.GetIsolate()); | 37 v8::Isolate* isolate = info.GetIsolate(); |
| 38 ExceptionState exceptionState(ExceptionState::ExecutionContext, "initDeviceO
rientationEvent", "DeviceOrientationEvent", info.Holder(), isolate); |
38 DeviceOrientationEvent* impl = V8DeviceOrientationEvent::toImpl(info.Holder(
)); | 39 DeviceOrientationEvent* impl = V8DeviceOrientationEvent::toImpl(info.Holder(
)); |
39 V8StringResource<> type(info[0]); | 40 V8StringResource<> type(info[0]); |
40 if (!type.prepare()) | 41 if (!type.prepare()) |
41 return; | 42 return; |
42 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext(); | 43 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
43 bool bubbles; | 44 bool bubbles; |
44 V8_CALL(bubbles, info[1], BooleanValue(context), return); | 45 V8_CALL(bubbles, info[1], BooleanValue(context), return); |
45 bool cancelable; | 46 bool cancelable; |
46 V8_CALL(cancelable, info[2], BooleanValue(context), return); | 47 V8_CALL(cancelable, info[2], BooleanValue(context), return); |
47 // If alpha, beta, gamma or absolute are null or undefined, mark them as not
provided. | 48 // If alpha, beta, gamma or absolute are null or undefined, mark them as not
provided. |
48 // Otherwise, use the standard JavaScript conversion. | 49 // Otherwise, use the standard JavaScript conversion. |
49 bool alphaProvided = !isUndefinedOrNull(info[3]); | 50 bool alphaProvided = !isUndefinedOrNull(info[3]); |
50 double alpha = 0; | 51 double alpha = 0; |
51 if (alphaProvided) { | 52 if (alphaProvided) { |
52 alpha = toRestrictedDouble(info[3], exceptionState); | 53 alpha = toRestrictedDouble(isolate, info[3], exceptionState); |
53 if (exceptionState.throwIfNeeded()) | 54 if (exceptionState.throwIfNeeded()) |
54 return; | 55 return; |
55 } | 56 } |
56 bool betaProvided = !isUndefinedOrNull(info[4]); | 57 bool betaProvided = !isUndefinedOrNull(info[4]); |
57 double beta = 0; | 58 double beta = 0; |
58 if (betaProvided) { | 59 if (betaProvided) { |
59 beta = toRestrictedDouble(info[4], exceptionState); | 60 beta = toRestrictedDouble(isolate, info[4], exceptionState); |
60 if (exceptionState.throwIfNeeded()) | 61 if (exceptionState.throwIfNeeded()) |
61 return; | 62 return; |
62 } | 63 } |
63 bool gammaProvided = !isUndefinedOrNull(info[5]); | 64 bool gammaProvided = !isUndefinedOrNull(info[5]); |
64 double gamma = 0; | 65 double gamma = 0; |
65 if (gammaProvided) { | 66 if (gammaProvided) { |
66 gamma = toRestrictedDouble(info[5], exceptionState); | 67 gamma = toRestrictedDouble(isolate, info[5], exceptionState); |
67 if (exceptionState.throwIfNeeded()) | 68 if (exceptionState.throwIfNeeded()) |
68 return; | 69 return; |
69 } | 70 } |
70 bool absoluteProvided = !isUndefinedOrNull(info[6]); | 71 bool absoluteProvided = !isUndefinedOrNull(info[6]); |
71 bool absolute = info[6]->BooleanValue(); | 72 bool absolute = info[6]->BooleanValue(); |
72 DeviceOrientationData* orientation = DeviceOrientationData::create(alphaProv
ided, alpha, betaProvided, beta, gammaProvided, gamma, absoluteProvided, absolut
e); | 73 DeviceOrientationData* orientation = DeviceOrientationData::create(alphaProv
ided, alpha, betaProvided, beta, gammaProvided, gamma, absoluteProvided, absolut
e); |
73 impl->initDeviceOrientationEvent(type, bubbles, cancelable, orientation); | 74 impl->initDeviceOrientationEvent(type, bubbles, cancelable, orientation); |
74 } | 75 } |
75 | 76 |
76 } // namespace blink | 77 } // namespace blink |
OLD | NEW |