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

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

Issue 1923393006: DevTools: fix styles and input validation in sensor pane (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Orientation labels now alpha-beta-gamma Created 4 years, 7 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 // 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} latitude 7 * @param {number} latitude
8 * @param {number} longitude 8 * @param {number} longitude
9 * @param {boolean} error 9 * @param {boolean} error
10 */ 10 */
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 var longitude = isLongitudeValid ? parseFloat(longitudeString) : -1; 78 var longitude = isLongitudeValid ? parseFloat(longitudeString) : -1;
79 return new WebInspector.Geolocation(latitude, longitude, !!errorStatus); 79 return new WebInspector.Geolocation(latitude, longitude, !!errorStatus);
80 } 80 }
81 81
82 /** 82 /**
83 * @param {string} value 83 * @param {string} value
84 * @return {boolean} 84 * @return {boolean}
85 */ 85 */
86 WebInspector.Geolocation.latitudeValidator = function(value) 86 WebInspector.Geolocation.latitudeValidator = function(value)
87 { 87 {
88 return !value || (/^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value) && value > = -90 && value <= 90); 88 var numValue = parseFloat(value);
89 return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value) && numValue >= -90 && numValue <= 90;
89 } 90 }
90 91
91 /** 92 /**
92 * @param {string} value 93 * @param {string} value
93 * @return {boolean} 94 * @return {boolean}
94 */ 95 */
95 WebInspector.Geolocation.longitudeValidator = function(value) 96 WebInspector.Geolocation.longitudeValidator = function(value)
96 { 97 {
97 return !value || (/^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value) && value > = -180 && value <= 180); 98 var numValue = parseFloat(value);
99 return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value) && numValue >= -180 & & numValue <= 180;
lushnikov 2016/05/04 17:10:45 Is this regex just a fancy way of saying "this is
luoe 2016/05/04 17:31:10 Not quite. One case, value="1-0", parseFloat("1-0
98 } 100 }
99 101
100 WebInspector.Geolocation.DefaultMockAccuracy = 150; 102 WebInspector.Geolocation.DefaultMockAccuracy = 150;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698