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

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

Issue 2466123002: DevTools: reformat front-end code to match chromium style. (Closed)
Patch Set: all done 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/emulation/Geolocation.js
diff --git a/third_party/WebKit/Source/devtools/front_end/emulation/Geolocation.js b/third_party/WebKit/Source/devtools/front_end/emulation/Geolocation.js
index 17930b94d2b474455719c4eaf499643c73ac4721..f5ce75c0d9d1f839bba66efd5cf95128bf64da7e 100644
--- a/third_party/WebKit/Source/devtools/front_end/emulation/Geolocation.js
+++ b/third_party/WebKit/Source/devtools/front_end/emulation/Geolocation.js
@@ -1,102 +1,100 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
/**
- * @constructor
- * @param {number} latitude
- * @param {number} longitude
- * @param {boolean} error
+ * @unrestricted
*/
-WebInspector.Geolocation = function(latitude, longitude, error)
-{
+WebInspector.Geolocation = class {
+ /**
+ * @param {number} latitude
+ * @param {number} longitude
+ * @param {boolean} error
+ */
+ constructor(latitude, longitude, error) {
this.latitude = latitude;
this.longitude = longitude;
this.error = error;
-};
-
-WebInspector.Geolocation.prototype = {
- /**
- * @return {string}
- */
- toSetting: function()
- {
- return (typeof this.latitude === "number" && typeof this.longitude === "number" && typeof this.error === "string") ? this.latitude + "@" + this.longitude + ":" + this.error : "";
- },
-
- apply: function()
- {
- for (var target of WebInspector.targetManager.targets(WebInspector.Target.Capability.Browser)) {
- if (this.error)
- target.emulationAgent().setGeolocationOverride();
- else
- target.emulationAgent().setGeolocationOverride(this.latitude, this.longitude, WebInspector.Geolocation.DefaultMockAccuracy);
- }
- },
-
- clear: function()
- {
- for (var target of WebInspector.targetManager.targets(WebInspector.Target.Capability.Browser))
- target.emulationAgent().clearGeolocationOverride();
- }
-};
+ }
-/**
- * @return {!WebInspector.Geolocation}
- */
-WebInspector.Geolocation.parseSetting = function(value)
-{
+ /**
+ * @return {!WebInspector.Geolocation}
+ */
+ static parseSetting(value) {
if (value) {
- var splitError = value.split(":");
- if (splitError.length === 2) {
- var splitPosition = splitError[0].split("@");
- if (splitPosition.length === 2)
- return new WebInspector.Geolocation(parseFloat(splitPosition[0]), parseFloat(splitPosition[1]), splitError[1]);
- }
+ var splitError = value.split(':');
+ if (splitError.length === 2) {
+ var splitPosition = splitError[0].split('@');
+ if (splitPosition.length === 2)
+ return new WebInspector.Geolocation(
+ parseFloat(splitPosition[0]), parseFloat(splitPosition[1]), splitError[1]);
+ }
}
return new WebInspector.Geolocation(0, 0, false);
-};
+ }
-/**
- * @param {string} latitudeString
- * @param {string} longitudeString
- * @param {string} errorStatus
- * @return {?WebInspector.Geolocation}
- */
-WebInspector.Geolocation.parseUserInput = function(latitudeString, longitudeString, errorStatus)
-{
+ /**
+ * @param {string} latitudeString
+ * @param {string} longitudeString
+ * @param {string} errorStatus
+ * @return {?WebInspector.Geolocation}
+ */
+ static parseUserInput(latitudeString, longitudeString, errorStatus) {
if (!latitudeString && !longitudeString)
- return null;
+ return null;
var isLatitudeValid = WebInspector.Geolocation.latitudeValidator(latitudeString);
var isLongitudeValid = WebInspector.Geolocation.longitudeValidator(longitudeString);
if (!isLatitudeValid && !isLongitudeValid)
- return null;
+ return null;
var latitude = isLatitudeValid ? parseFloat(latitudeString) : -1;
var longitude = isLongitudeValid ? parseFloat(longitudeString) : -1;
return new WebInspector.Geolocation(latitude, longitude, !!errorStatus);
-};
+ }
-/**
- * @param {string} value
- * @return {boolean}
- */
-WebInspector.Geolocation.latitudeValidator = function(value)
-{
+ /**
+ * @param {string} value
+ * @return {boolean}
+ */
+ static latitudeValidator(value) {
var numValue = parseFloat(value);
return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value) && numValue >= -90 && numValue <= 90;
-};
+ }
-/**
- * @param {string} value
- * @return {boolean}
- */
-WebInspector.Geolocation.longitudeValidator = function(value)
-{
+ /**
+ * @param {string} value
+ * @return {boolean}
+ */
+ static longitudeValidator(value) {
var numValue = parseFloat(value);
return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value) && numValue >= -180 && numValue <= 180;
+ }
+
+ /**
+ * @return {string}
+ */
+ toSetting() {
+ return (typeof this.latitude === 'number' && typeof this.longitude === 'number' && typeof this.error === 'string') ?
+ this.latitude + '@' + this.longitude + ':' + this.error :
+ '';
+ }
+
+ apply() {
+ for (var target of WebInspector.targetManager.targets(WebInspector.Target.Capability.Browser)) {
+ if (this.error)
+ target.emulationAgent().setGeolocationOverride();
+ else
+ target.emulationAgent().setGeolocationOverride(
+ this.latitude, this.longitude, WebInspector.Geolocation.DefaultMockAccuracy);
+ }
+ }
+
+ clear() {
+ for (var target of WebInspector.targetManager.targets(WebInspector.Target.Capability.Browser))
+ target.emulationAgent().clearGeolocationOverride();
+ }
};
+
WebInspector.Geolocation.DefaultMockAccuracy = 150;

Powered by Google App Engine
This is Rietveld 408576698