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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/emulation/DeviceOrientation.js

Issue 2440953003: DevTools: use semicolons after each statement. (Closed)
Patch Set: rebaseline Created 4 years, 1 month 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @param {number} alpha 7 * @param {number} alpha
8 * @param {number} beta 8 * @param {number} beta
9 * @param {number} gamma 9 * @param {number} gamma
10 */ 10 */
11 WebInspector.DeviceOrientation = function(alpha, beta, gamma) 11 WebInspector.DeviceOrientation = function(alpha, beta, gamma)
12 { 12 {
13 this.alpha = alpha; 13 this.alpha = alpha;
14 this.beta = beta; 14 this.beta = beta;
15 this.gamma = gamma; 15 this.gamma = gamma;
16 } 16 };
17 17
18 WebInspector.DeviceOrientation.prototype = { 18 WebInspector.DeviceOrientation.prototype = {
19 /** 19 /**
20 * @return {string} 20 * @return {string}
21 */ 21 */
22 toSetting: function() 22 toSetting: function()
23 { 23 {
24 return JSON.stringify(this); 24 return JSON.stringify(this);
25 }, 25 },
26 26
27 apply: function() 27 apply: function()
28 { 28 {
29 for (var target of WebInspector.targetManager.targets(WebInspector.Targe t.Capability.Browser)) 29 for (var target of WebInspector.targetManager.targets(WebInspector.Targe t.Capability.Browser))
30 target.deviceOrientationAgent().setDeviceOrientationOverride(this.al pha, this.beta, this.gamma); 30 target.deviceOrientationAgent().setDeviceOrientationOverride(this.al pha, this.beta, this.gamma);
31 }, 31 },
32 32
33 clear: function() 33 clear: function()
34 { 34 {
35 for (var target of WebInspector.targetManager.targets(WebInspector.Targe t.Capability.Browser)) 35 for (var target of WebInspector.targetManager.targets(WebInspector.Targe t.Capability.Browser))
36 target.deviceOrientationAgent().clearDeviceOrientationOverride(); 36 target.deviceOrientationAgent().clearDeviceOrientationOverride();
37 } 37 }
38 } 38 };
39 39
40 /** 40 /**
41 * @return {!WebInspector.DeviceOrientation} 41 * @return {!WebInspector.DeviceOrientation}
42 */ 42 */
43 WebInspector.DeviceOrientation.parseSetting = function(value) 43 WebInspector.DeviceOrientation.parseSetting = function(value)
44 { 44 {
45 if (value) { 45 if (value) {
46 var jsonObject = JSON.parse(value); 46 var jsonObject = JSON.parse(value);
47 return new WebInspector.DeviceOrientation(jsonObject.alpha, jsonObject.b eta, jsonObject.gamma); 47 return new WebInspector.DeviceOrientation(jsonObject.alpha, jsonObject.b eta, jsonObject.gamma);
48 } 48 }
49 return new WebInspector.DeviceOrientation(0, 0, 0); 49 return new WebInspector.DeviceOrientation(0, 0, 0);
50 } 50 };
51 51
52 /** 52 /**
53 * @return {?WebInspector.DeviceOrientation} 53 * @return {?WebInspector.DeviceOrientation}
54 */ 54 */
55 WebInspector.DeviceOrientation.parseUserInput = function(alphaString, betaString , gammaString) 55 WebInspector.DeviceOrientation.parseUserInput = function(alphaString, betaString , gammaString)
56 { 56 {
57 if (!alphaString && !betaString && !gammaString) 57 if (!alphaString && !betaString && !gammaString)
58 return null; 58 return null;
59 59
60 var isAlphaValid = WebInspector.DeviceOrientation.validator(alphaString); 60 var isAlphaValid = WebInspector.DeviceOrientation.validator(alphaString);
61 var isBetaValid = WebInspector.DeviceOrientation.validator(betaString); 61 var isBetaValid = WebInspector.DeviceOrientation.validator(betaString);
62 var isGammaValid = WebInspector.DeviceOrientation.validator(gammaString); 62 var isGammaValid = WebInspector.DeviceOrientation.validator(gammaString);
63 63
64 if (!isAlphaValid && !isBetaValid && !isGammaValid) 64 if (!isAlphaValid && !isBetaValid && !isGammaValid)
65 return null; 65 return null;
66 66
67 var alpha = isAlphaValid ? parseFloat(alphaString) : -1; 67 var alpha = isAlphaValid ? parseFloat(alphaString) : -1;
68 var beta = isBetaValid ? parseFloat(betaString) : -1; 68 var beta = isBetaValid ? parseFloat(betaString) : -1;
69 var gamma = isGammaValid ? parseFloat(gammaString) : -1; 69 var gamma = isGammaValid ? parseFloat(gammaString) : -1;
70 70
71 return new WebInspector.DeviceOrientation(alpha, beta, gamma); 71 return new WebInspector.DeviceOrientation(alpha, beta, gamma);
72 } 72 };
73 73
74 /** 74 /**
75 * @param {string} value 75 * @param {string} value
76 * @return {boolean} 76 * @return {boolean}
77 */ 77 */
78 WebInspector.DeviceOrientation.validator = function(value) 78 WebInspector.DeviceOrientation.validator = function(value)
79 { 79 {
80 return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value); 80 return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value);
81 } 81 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698