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

Side by Side Diff: Source/modules/device_orientation/DeviceOrientationData.cpp

Issue 1186823014: [bindings] Eliminate custom bindings for DeviceOrientationEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Initialize the constructor to be null Created 5 years, 6 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 "modules/device_orientation/DeviceOrientationData.h" 27 #include "modules/device_orientation/DeviceOrientationData.h"
28 #include "public/platform/modules/device_orientation/WebDeviceOrientationData.h" 28 #include "public/platform/modules/device_orientation/WebDeviceOrientationData.h"
29 29
30 namespace blink { 30 namespace blink {
31 31
32 DeviceOrientationData* DeviceOrientationData::create() 32 DeviceOrientationData* DeviceOrientationData::create()
33 { 33 {
34 return new DeviceOrientationData; 34 return new DeviceOrientationData;
35 } 35 }
36 36
37 DeviceOrientationData* DeviceOrientationData::create(bool canProvideAlpha, doubl e alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma, b ool canProvideAbsolute, bool absolute) 37 DeviceOrientationData* DeviceOrientationData::create(const Nullable<double>& alp ha, const Nullable<double>& beta, const Nullable<double>& gamma, const Nullable< bool>& absolute)
38 { 38 {
39 return new DeviceOrientationData(canProvideAlpha, alpha, canProvideBeta, bet a, canProvideGamma, gamma, canProvideAbsolute, absolute); 39 return new DeviceOrientationData(alpha, beta, gamma, absolute);
40 } 40 }
41 41
42 DeviceOrientationData* DeviceOrientationData::create(const WebDeviceOrientationD ata& data) 42 DeviceOrientationData* DeviceOrientationData::create(const WebDeviceOrientationD ata& data)
43 { 43 {
44 return DeviceOrientationData::create(data.hasAlpha, data.alpha, data.hasBeta , data.beta, data.hasGamma, data.gamma, data.hasAbsolute, data.absolute); 44 Nullable<double> alpha;
45 Nullable<double> beta;
46 Nullable<double> gamma;
47 Nullable<bool> absolute;
48 if (data.hasAlpha)
49 alpha = data.alpha;
50 if (data.hasBeta)
51 beta = data.beta;
52 if (data.hasGamma)
53 gamma = data.gamma;
54 if (data.hasAbsolute)
55 absolute = data.absolute;
56 return DeviceOrientationData::create(alpha, beta, gamma, absolute);
45 } 57 }
46 58
47 DeviceOrientationData::DeviceOrientationData() 59 DeviceOrientationData::DeviceOrientationData()
48 : m_canProvideAlpha(false)
49 , m_canProvideBeta(false)
50 , m_canProvideGamma(false)
51 , m_canProvideAbsolute(false)
52 , m_alpha(0)
53 , m_beta(0)
54 , m_gamma(0)
55 , m_absolute(false)
56 { 60 {
57 } 61 }
58 62
59 DeviceOrientationData::DeviceOrientationData(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma, bool canP rovideAbsolute, bool absolute) 63 DeviceOrientationData::DeviceOrientationData(const Nullable<double>& alpha, cons t Nullable<double>& beta, const Nullable<double>& gamma, const Nullable<bool>& a bsolute)
60 : m_canProvideAlpha(canProvideAlpha) 64 : m_alpha(alpha)
61 , m_canProvideBeta(canProvideBeta)
62 , m_canProvideGamma(canProvideGamma)
63 , m_canProvideAbsolute(canProvideAbsolute)
64 , m_alpha(alpha)
65 , m_beta(beta) 65 , m_beta(beta)
66 , m_gamma(gamma) 66 , m_gamma(gamma)
67 , m_absolute(absolute) 67 , m_absolute(absolute)
68 { 68 {
69 } 69 }
70 70
71 double DeviceOrientationData::alpha() const 71 double DeviceOrientationData::alpha() const
72 { 72 {
73 return m_alpha; 73 return m_alpha.get();
74 } 74 }
75 75
76 double DeviceOrientationData::beta() const 76 double DeviceOrientationData::beta() const
77 { 77 {
78 return m_beta; 78 return m_beta.get();
79 } 79 }
80 80
81 double DeviceOrientationData::gamma() const 81 double DeviceOrientationData::gamma() const
82 { 82 {
83 return m_gamma; 83 return m_gamma.get();
84 } 84 }
85 85
86 bool DeviceOrientationData::absolute() const 86 bool DeviceOrientationData::absolute() const
87 { 87 {
88 return m_absolute; 88 return m_absolute.get();
89 } 89 }
90 90
91 bool DeviceOrientationData::canProvideAlpha() const 91 bool DeviceOrientationData::canProvideAlpha() const
92 { 92 {
93 return m_canProvideAlpha; 93 return !m_alpha.isNull();
94 } 94 }
95 95
96 bool DeviceOrientationData::canProvideBeta() const 96 bool DeviceOrientationData::canProvideBeta() const
97 { 97 {
98 return m_canProvideBeta; 98 return !m_beta.isNull();
99 } 99 }
100 100
101 bool DeviceOrientationData::canProvideGamma() const 101 bool DeviceOrientationData::canProvideGamma() const
102 { 102 {
103 return m_canProvideGamma; 103 return !m_gamma.isNull();
104 } 104 }
105 105
106 bool DeviceOrientationData::canProvideAbsolute() const 106 bool DeviceOrientationData::canProvideAbsolute() const
107 { 107 {
108 return m_canProvideAbsolute; 108 return !m_absolute.isNull();
109 } 109 }
110 110
111 bool DeviceOrientationData::canProvideEventData() const 111 bool DeviceOrientationData::canProvideEventData() const
112 { 112 {
113 return canProvideAlpha() || canProvideBeta() || canProvideGamma(); 113 return canProvideAlpha() || canProvideBeta() || canProvideGamma();
114 } 114 }
115 115
116 } // namespace blink 116 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/device_orientation/DeviceOrientationData.h ('k') | Source/modules/device_orientation/DeviceOrientationEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698