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

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

Issue 934203002: Add [TypeChecking=Unrestricted] on Device Orientation interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix custom bindings logic 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
OLDNEW
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
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 DeviceOrientationEvent* impl = V8DeviceOrientationEvent::toImpl(info.Holder( )); 38 DeviceOrientationEvent* impl = V8DeviceOrientationEvent::toImpl(info.Holder( ));
38 TOSTRING_VOID(V8StringResource<>, type, info[0]); 39 V8StringResource<> type(info[0]);
40 if (!type.prepare())
41 return;
39 bool bubbles = info[1]->BooleanValue(); 42 bool bubbles = info[1]->BooleanValue();
40 bool cancelable = info[2]->BooleanValue(); 43 bool cancelable = info[2]->BooleanValue();
41 // If alpha, beta, gamma or absolute are null or undefined, mark them as not provided. 44 // If alpha, beta, gamma or absolute are null or undefined, mark them as not provided.
42 // Otherwise, use the standard JavaScript conversion. 45 // Otherwise, use the standard JavaScript conversion.
43 bool alphaProvided = !isUndefinedOrNull(info[3]); 46 bool alphaProvided = !isUndefinedOrNull(info[3]);
44 double alpha = info[3]->NumberValue(); 47 double alpha = 0;
48 if (alphaProvided) {
49 alpha = toRestrictedDouble(info[3], exceptionState);
50 if (exceptionState.throwIfNeeded())
51 return;
52 }
45 bool betaProvided = !isUndefinedOrNull(info[4]); 53 bool betaProvided = !isUndefinedOrNull(info[4]);
46 double beta = info[4]->NumberValue(); 54 double beta = 0;
55 if (betaProvided) {
56 beta = toRestrictedDouble(info[4], exceptionState);
57 if (exceptionState.throwIfNeeded())
58 return;
59 }
47 bool gammaProvided = !isUndefinedOrNull(info[5]); 60 bool gammaProvided = !isUndefinedOrNull(info[5]);
48 double gamma = info[5]->NumberValue(); 61 double gamma = 0;
62 if (gammaProvided) {
63 gamma = toRestrictedDouble(info[5], exceptionState);
64 if (exceptionState.throwIfNeeded())
65 return;
66 }
49 bool absoluteProvided = !isUndefinedOrNull(info[6]); 67 bool absoluteProvided = !isUndefinedOrNull(info[6]);
50 bool absolute = info[6]->BooleanValue(); 68 bool absolute = info[6]->BooleanValue();
51 DeviceOrientationData* orientation = DeviceOrientationData::create(alphaProv ided, alpha, betaProvided, beta, gammaProvided, gamma, absoluteProvided, absolut e); 69 DeviceOrientationData* orientation = DeviceOrientationData::create(alphaProv ided, alpha, betaProvided, beta, gammaProvided, gamma, absoluteProvided, absolut e);
52 impl->initDeviceOrientationEvent(type, bubbles, cancelable, orientation); 70 impl->initDeviceOrientationEvent(type, bubbles, cancelable, orientation);
53 } 71 }
54 72
55 } // namespace blink 73 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698