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

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

Issue 170603003: Use nullptr_t for RefPtr, PassRefPtr and RawPtr. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Final rebase Created 6 years, 10 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 19 matching lines...) Expand all
30 #include "modules/device_orientation/DeviceMotionData.h" 30 #include "modules/device_orientation/DeviceMotionData.h"
31 #include <v8.h> 31 #include <v8.h>
32 32
33 namespace WebCore { 33 namespace WebCore {
34 34
35 namespace { 35 namespace {
36 36
37 PassRefPtrWillBeRawPtr<DeviceMotionData::Acceleration> readAccelerationArgument( v8::Local<v8::Value> value, v8::Isolate* isolate) 37 PassRefPtrWillBeRawPtr<DeviceMotionData::Acceleration> readAccelerationArgument( v8::Local<v8::Value> value, v8::Isolate* isolate)
38 { 38 {
39 if (isUndefinedOrNull(value)) 39 if (isUndefinedOrNull(value))
40 return 0; 40 return nullptr;
41 41
42 // Given the test above, this will always yield an object. 42 // Given the test above, this will always yield an object.
43 v8::Local<v8::Object> object = value->ToObject(); 43 v8::Local<v8::Object> object = value->ToObject();
44 44
45 v8::Local<v8::Value> xValue = object->Get(v8AtomicString(isolate, "x")); 45 v8::Local<v8::Value> xValue = object->Get(v8AtomicString(isolate, "x"));
46 if (xValue.IsEmpty()) 46 if (xValue.IsEmpty())
47 return 0; 47 return nullptr;
48 bool canProvideX = !isUndefinedOrNull(xValue); 48 bool canProvideX = !isUndefinedOrNull(xValue);
49 double x = xValue->NumberValue(); 49 double x = xValue->NumberValue();
50 50
51 v8::Local<v8::Value> yValue = object->Get(v8AtomicString(isolate, "y")); 51 v8::Local<v8::Value> yValue = object->Get(v8AtomicString(isolate, "y"));
52 if (yValue.IsEmpty()) 52 if (yValue.IsEmpty())
53 return 0; 53 return nullptr;
54 bool canProvideY = !isUndefinedOrNull(yValue); 54 bool canProvideY = !isUndefinedOrNull(yValue);
55 double y = yValue->NumberValue(); 55 double y = yValue->NumberValue();
56 56
57 v8::Local<v8::Value> zValue = object->Get(v8AtomicString(isolate, "z")); 57 v8::Local<v8::Value> zValue = object->Get(v8AtomicString(isolate, "z"));
58 if (zValue.IsEmpty()) 58 if (zValue.IsEmpty())
59 return 0; 59 return nullptr;
60 bool canProvideZ = !isUndefinedOrNull(zValue); 60 bool canProvideZ = !isUndefinedOrNull(zValue);
61 double z = zValue->NumberValue(); 61 double z = zValue->NumberValue();
62 62
63 if (!canProvideX && !canProvideY && !canProvideZ) 63 if (!canProvideX && !canProvideY && !canProvideZ)
64 return 0; 64 return nullptr;
65 65
66 return DeviceMotionData::Acceleration::create(canProvideX, x, canProvideY, y , canProvideZ, z); 66 return DeviceMotionData::Acceleration::create(canProvideX, x, canProvideY, y , canProvideZ, z);
67 } 67 }
68 68
69 PassRefPtrWillBeRawPtr<DeviceMotionData::RotationRate> readRotationRateArgument( v8::Local<v8::Value> value, v8::Isolate* isolate) 69 PassRefPtrWillBeRawPtr<DeviceMotionData::RotationRate> readRotationRateArgument( v8::Local<v8::Value> value, v8::Isolate* isolate)
70 { 70 {
71 if (isUndefinedOrNull(value)) 71 if (isUndefinedOrNull(value))
72 return 0; 72 return nullptr;
73 73
74 // Given the test above, this will always yield an object. 74 // Given the test above, this will always yield an object.
75 v8::Local<v8::Object> object = value->ToObject(); 75 v8::Local<v8::Object> object = value->ToObject();
76 76
77 v8::Local<v8::Value> alphaValue = object->Get(v8AtomicString(isolate, "alpha ")); 77 v8::Local<v8::Value> alphaValue = object->Get(v8AtomicString(isolate, "alpha "));
78 if (alphaValue.IsEmpty()) 78 if (alphaValue.IsEmpty())
79 return 0; 79 return nullptr;
80 bool canProvideAlpha = !isUndefinedOrNull(alphaValue); 80 bool canProvideAlpha = !isUndefinedOrNull(alphaValue);
81 double alpha = alphaValue->NumberValue(); 81 double alpha = alphaValue->NumberValue();
82 82
83 v8::Local<v8::Value> betaValue = object->Get(v8AtomicString(isolate, "beta") ); 83 v8::Local<v8::Value> betaValue = object->Get(v8AtomicString(isolate, "beta") );
84 if (betaValue.IsEmpty()) 84 if (betaValue.IsEmpty())
85 return 0; 85 return nullptr;
86 bool canProvideBeta = !isUndefinedOrNull(betaValue); 86 bool canProvideBeta = !isUndefinedOrNull(betaValue);
87 double beta = betaValue->NumberValue(); 87 double beta = betaValue->NumberValue();
88 88
89 v8::Local<v8::Value> gammaValue = object->Get(v8AtomicString(isolate, "gamma ")); 89 v8::Local<v8::Value> gammaValue = object->Get(v8AtomicString(isolate, "gamma "));
90 if (gammaValue.IsEmpty()) 90 if (gammaValue.IsEmpty())
91 return 0; 91 return nullptr;
92 bool canProvideGamma = !isUndefinedOrNull(gammaValue); 92 bool canProvideGamma = !isUndefinedOrNull(gammaValue);
93 double gamma = gammaValue->NumberValue(); 93 double gamma = gammaValue->NumberValue();
94 94
95 if (!canProvideAlpha && !canProvideBeta && !canProvideGamma) 95 if (!canProvideAlpha && !canProvideBeta && !canProvideGamma)
96 return 0; 96 return nullptr;
97 97
98 return DeviceMotionData::RotationRate::create(canProvideAlpha, alpha, canPro videBeta, beta, canProvideGamma, gamma); 98 return DeviceMotionData::RotationRate::create(canProvideAlpha, alpha, canPro videBeta, beta, canProvideGamma, gamma);
99 } 99 }
100 100
101 } // namespace 101 } // namespace
102 102
103 void V8DeviceMotionEvent::initDeviceMotionEventMethodCustom(const v8::FunctionCa llbackInfo<v8::Value>& info) 103 void V8DeviceMotionEvent::initDeviceMotionEventMethodCustom(const v8::FunctionCa llbackInfo<v8::Value>& info)
104 { 104 {
105 DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(info.Holder()); 105 DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(info.Holder());
106 v8::Isolate* isolate = info.GetIsolate(); 106 v8::Isolate* isolate = info.GetIsolate();
107 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, info[0]); 107 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, info[0]);
108 bool bubbles = info[1]->BooleanValue(); 108 bool bubbles = info[1]->BooleanValue();
109 bool cancelable = info[2]->BooleanValue(); 109 bool cancelable = info[2]->BooleanValue();
110 RefPtrWillBeRawPtr<DeviceMotionData::Acceleration> acceleration = readAccele rationArgument(info[3], isolate); 110 RefPtrWillBeRawPtr<DeviceMotionData::Acceleration> acceleration = readAccele rationArgument(info[3], isolate);
111 RefPtrWillBeRawPtr<DeviceMotionData::Acceleration> accelerationIncludingGrav ity = readAccelerationArgument(info[4], isolate); 111 RefPtrWillBeRawPtr<DeviceMotionData::Acceleration> accelerationIncludingGrav ity = readAccelerationArgument(info[4], isolate);
112 RefPtrWillBeRawPtr<DeviceMotionData::RotationRate> rotationRate = readRotati onRateArgument(info[5], isolate); 112 RefPtrWillBeRawPtr<DeviceMotionData::RotationRate> rotationRate = readRotati onRateArgument(info[5], isolate);
113 bool intervalProvided = !isUndefinedOrNull(info[6]); 113 bool intervalProvided = !isUndefinedOrNull(info[6]);
114 double interval = info[6]->NumberValue(); 114 double interval = info[6]->NumberValue();
115 RefPtrWillBeRawPtr<DeviceMotionData> deviceMotionData = DeviceMotionData::cr eate(acceleration.release(), accelerationIncludingGravity.release(), rotationRat e.release(), intervalProvided, interval); 115 RefPtrWillBeRawPtr<DeviceMotionData> deviceMotionData = DeviceMotionData::cr eate(acceleration.release(), accelerationIncludingGravity.release(), rotationRat e.release(), intervalProvided, interval);
116 imp->initDeviceMotionEvent(type, bubbles, cancelable, deviceMotionData.get() ); 116 imp->initDeviceMotionEvent(type, bubbles, cancelable, deviceMotionData.get() );
117 } 117 }
118 118
119 } // namespace WebCore 119 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/WorkerScriptController.cpp ('k') | Source/bindings/v8/custom/V8GeolocationCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698