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

Unified Diff: Source/bindings/modules/v8/custom/V8DeviceMotionEventCustom.cpp

Issue 995203002: bindings: Add a macro for V8 Maybe<T> APIs. (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 side-by-side diff with in-line comments
Download patch
Index: Source/bindings/modules/v8/custom/V8DeviceMotionEventCustom.cpp
diff --git a/Source/bindings/modules/v8/custom/V8DeviceMotionEventCustom.cpp b/Source/bindings/modules/v8/custom/V8DeviceMotionEventCustom.cpp
index 32b87fdbc44418b76bcb53d73507272493dbd801..6f4687ce0f6a0e7df02a965e3efc936ee737af3d 100644
--- a/Source/bindings/modules/v8/custom/V8DeviceMotionEventCustom.cpp
+++ b/Source/bindings/modules/v8/custom/V8DeviceMotionEventCustom.cpp
@@ -39,27 +39,31 @@ DeviceMotionData::Acceleration* readAccelerationArgument(v8::Local<v8::Value> va
if (isUndefinedOrNull(value))
return nullptr;
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::Local<v8::Object> object;
- if (!value->ToObject(isolate->GetCurrentContext()).ToLocal(&object))
+ if (!value->ToObject(context).ToLocal(&object))
return nullptr;
v8::Local<v8::Value> xValue = object->Get(v8AtomicString(isolate, "x"));
if (xValue.IsEmpty())
return nullptr;
bool canProvideX = !isUndefinedOrNull(xValue);
- double x = xValue->NumberValue();
+ double x;
+ V8_MAYBE(x, xValue, NumberValue(context), return nullptr);
haraken 2015/03/11 02:43:21 I might want to have a better name for the macro t
bashi 2015/03/11 03:46:27 Changed to V8_CALL(). (This sounds a bit too gener
v8::Local<v8::Value> yValue = object->Get(v8AtomicString(isolate, "y"));
if (yValue.IsEmpty())
return nullptr;
bool canProvideY = !isUndefinedOrNull(yValue);
- double y = yValue->NumberValue();
+ double y;
+ V8_MAYBE(y, yValue, NumberValue(context), return nullptr);
v8::Local<v8::Value> zValue = object->Get(v8AtomicString(isolate, "z"));
if (zValue.IsEmpty())
return nullptr;
bool canProvideZ = !isUndefinedOrNull(zValue);
- double z = zValue->NumberValue();
+ double z;
+ V8_MAYBE(z, zValue, NumberValue(context), return nullptr);
if (!canProvideX && !canProvideY && !canProvideZ)
return nullptr;
@@ -72,27 +76,31 @@ DeviceMotionData::RotationRate* readRotationRateArgument(v8::Local<v8::Value> va
if (isUndefinedOrNull(value))
return nullptr;
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::Local<v8::Object> object;
- if (!value->ToObject(isolate->GetCurrentContext()).ToLocal(&object))
+ if (!value->ToObject(context).ToLocal(&object))
return nullptr;
v8::Local<v8::Value> alphaValue = object->Get(v8AtomicString(isolate, "alpha"));
if (alphaValue.IsEmpty())
return nullptr;
bool canProvideAlpha = !isUndefinedOrNull(alphaValue);
- double alpha = alphaValue->NumberValue();
+ double alpha;
+ V8_MAYBE(alpha, alphaValue, NumberValue(context), return nullptr);
v8::Local<v8::Value> betaValue = object->Get(v8AtomicString(isolate, "beta"));
if (betaValue.IsEmpty())
return nullptr;
bool canProvideBeta = !isUndefinedOrNull(betaValue);
- double beta = betaValue->NumberValue();
+ double beta;
+ V8_MAYBE(beta, betaValue, NumberValue(context), return nullptr);
v8::Local<v8::Value> gammaValue = object->Get(v8AtomicString(isolate, "gamma"));
if (gammaValue.IsEmpty())
return nullptr;
bool canProvideGamma = !isUndefinedOrNull(gammaValue);
- double gamma = gammaValue->NumberValue();
+ double gamma;
+ V8_MAYBE(gamma, gammaValue, NumberValue(context), return nullptr);
if (!canProvideAlpha && !canProvideBeta && !canProvideGamma)
return nullptr;
@@ -110,8 +118,11 @@ void V8DeviceMotionEvent::initDeviceMotionEventMethodCustom(const v8::FunctionCa
V8StringResource<> type(info[0]);
if (!type.prepare())
return;
- bool bubbles = info[1]->BooleanValue();
- bool cancelable = info[2]->BooleanValue();
+ v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
+ bool bubbles;
+ V8_MAYBE(bubbles, info[1], BooleanValue(context), return);
+ bool cancelable;
+ V8_MAYBE(cancelable, info[2], BooleanValue(context), return);
DeviceMotionData::Acceleration* acceleration = readAccelerationArgument(info[3], isolate);
DeviceMotionData::Acceleration* accelerationIncludingGravity = readAccelerationArgument(info[4], isolate);
DeviceMotionData::RotationRate* rotationRate = readRotationRateArgument(info[5], isolate);

Powered by Google App Engine
This is Rietveld 408576698