Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: Source/bindings/modules/v8/custom/V8DeviceMotionEventCustom.cpp

Issue 970403003: bindings: Use V8 MaybeLocal APIs in V8DeviceMotionEventCustom (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 CALL_V8_WITH_CHECK_MAYBELOCAL(v8::Object, object, value->ToObject(isolate->G etCurrentContext()), return nullptr);
43 v8::Local<v8::Object> object = value->ToObject(isolate);
44 43
45 v8::Local<v8::Value> xValue = object->Get(v8AtomicString(isolate, "x")); 44 v8::Local<v8::Value> xValue = object->Get(v8AtomicString(isolate, "x"));
46 if (xValue.IsEmpty()) 45 if (xValue.IsEmpty())
47 return nullptr; 46 return nullptr;
48 bool canProvideX = !isUndefinedOrNull(xValue); 47 bool canProvideX = !isUndefinedOrNull(xValue);
49 double x = xValue->NumberValue(); 48 double x = xValue->NumberValue();
50 49
51 v8::Local<v8::Value> yValue = object->Get(v8AtomicString(isolate, "y")); 50 v8::Local<v8::Value> yValue = object->Get(v8AtomicString(isolate, "y"));
52 if (yValue.IsEmpty()) 51 if (yValue.IsEmpty())
53 return nullptr; 52 return nullptr;
(...skipping 10 matching lines...) Expand all
64 return nullptr; 63 return nullptr;
65 64
66 return DeviceMotionData::Acceleration::create(canProvideX, x, canProvideY, y , canProvideZ, z); 65 return DeviceMotionData::Acceleration::create(canProvideX, x, canProvideY, y , canProvideZ, z);
67 } 66 }
68 67
69 DeviceMotionData::RotationRate* readRotationRateArgument(v8::Local<v8::Value> va lue, v8::Isolate* isolate) 68 DeviceMotionData::RotationRate* readRotationRateArgument(v8::Local<v8::Value> va lue, v8::Isolate* isolate)
70 { 69 {
71 if (isUndefinedOrNull(value)) 70 if (isUndefinedOrNull(value))
72 return nullptr; 71 return nullptr;
73 72
74 // Given the test above, this will always yield an object. 73 CALL_V8_WITH_CHECK_MAYBELOCAL(v8::Object, object, value->ToObject(isolate->G etCurrentContext()), return nullptr);
75 v8::Local<v8::Object> object = value->ToObject(isolate);
76 74
77 v8::Local<v8::Value> alphaValue = object->Get(v8AtomicString(isolate, "alpha ")); 75 v8::Local<v8::Value> alphaValue = object->Get(v8AtomicString(isolate, "alpha "));
78 if (alphaValue.IsEmpty()) 76 if (alphaValue.IsEmpty())
79 return nullptr; 77 return nullptr;
80 bool canProvideAlpha = !isUndefinedOrNull(alphaValue); 78 bool canProvideAlpha = !isUndefinedOrNull(alphaValue);
81 double alpha = alphaValue->NumberValue(); 79 double alpha = alphaValue->NumberValue();
82 80
83 v8::Local<v8::Value> betaValue = object->Get(v8AtomicString(isolate, "beta") ); 81 v8::Local<v8::Value> betaValue = object->Get(v8AtomicString(isolate, "beta") );
84 if (betaValue.IsEmpty()) 82 if (betaValue.IsEmpty())
85 return nullptr; 83 return nullptr;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (intervalProvided) { 116 if (intervalProvided) {
119 interval = toRestrictedDouble(info[6], exceptionState); 117 interval = toRestrictedDouble(info[6], exceptionState);
120 if (exceptionState.throwIfNeeded()) 118 if (exceptionState.throwIfNeeded())
121 return; 119 return;
122 } 120 }
123 DeviceMotionData* deviceMotionData = DeviceMotionData::create(acceleration, accelerationIncludingGravity, rotationRate, intervalProvided, interval); 121 DeviceMotionData* deviceMotionData = DeviceMotionData::create(acceleration, accelerationIncludingGravity, rotationRate, intervalProvided, interval);
124 impl->initDeviceMotionEvent(type, bubbles, cancelable, deviceMotionData); 122 impl->initDeviceMotionEvent(type, bubbles, cancelable, deviceMotionData);
125 } 123 }
126 124
127 } // namespace blink 125 } // namespace blink
OLDNEW
« Source/bindings/core/v8/V8BindingMacros.h ('K') | « Source/bindings/core/v8/V8BindingMacros.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698