diff --git a/build.py b/build.py index ca6130a78a..e8ecd57fe4 100755 --- a/build.py +++ b/build.py @@ -316,7 +316,7 @@ def examples_star_json(name, match): '../externs/oli.js', '../externs/proj4js.js', '../externs/tilejson.js', - '../externs/html5.js', + '../externs/closure-compiler.js', ], }) with open(t.name, 'w') as f: diff --git a/buildcfg/base.json b/buildcfg/base.json index 6b645e49e7..4a0fc293c1 100644 --- a/buildcfg/base.json +++ b/buildcfg/base.json @@ -46,7 +46,7 @@ "../externs/oli.js", "../externs/proj4js.js", "../externs/tilejson.js", - "../externs/html5.js" + "../externs/closure-compiler.js" ], "level": "VERBOSE", diff --git a/buildcfg/ol-all.json b/buildcfg/ol-all.json index a808f0f797..b3a6cfd3de 100644 --- a/buildcfg/ol-all.json +++ b/buildcfg/ol-all.json @@ -11,7 +11,7 @@ "../externs/oli.js", "../externs/proj4js.js", "../externs/tilejson.js", - "../externs/html5.js" + "../externs/closure-compiler.js" ], "inherits": "base.json", diff --git a/buildcfg/ol-simple.json b/buildcfg/ol-simple.json index d7e50b1552..93192f4484 100644 --- a/buildcfg/ol-simple.json +++ b/buildcfg/ol-simple.json @@ -20,7 +20,7 @@ "../externs/oli.js", "../externs/proj4js.js", "../externs/tilejson.js", - "../externs/html5.js" + "../externs/closure-compiler.js" ], "inherits": "ol.json", diff --git a/buildcfg/ol-whitespace.json b/buildcfg/ol-whitespace.json index 4364a2769d..fb956da2fd 100644 --- a/buildcfg/ol-whitespace.json +++ b/buildcfg/ol-whitespace.json @@ -21,7 +21,7 @@ "../externs/oli.js", "../externs/proj4js.js", "../externs/tilejson.js", - "../externs/html5.js" + "../externs/closure-compiler.js" ], "inherits": "ol.json", diff --git a/buildcfg/ol.json b/buildcfg/ol.json index c64d3fbf0d..7bfc960045 100644 --- a/buildcfg/ol.json +++ b/buildcfg/ol.json @@ -21,7 +21,7 @@ "../externs/oli.js", "../externs/proj4js.js", "../externs/tilejson.js", - "../externs/html5.js" + "../externs/closure-compiler.js" ], "inherits": "base.json", diff --git a/externs/closure-compiler.js b/externs/closure-compiler.js new file mode 100644 index 0000000000..7632dd8368 --- /dev/null +++ b/externs/closure-compiler.js @@ -0,0 +1,38 @@ +/** + * @fileoverview Definitions for externs that are either missing or incorrect + * in the current release version of the closure compiler we use. + * + * The entries must be removed once they are available/correct in the + * version we use. + * + * @externs + */ + +// @see https://code.google.com/p/closure-compiler/issues/detail?id=1060 + +/** @type {Date} */ +HTMLInputElement.prototype.valueAsDate; + +/** @type {number} */ +HTMLInputElement.prototype.valueAsNumber; + + +// @see https://code.google.com/p/closure-compiler/issues/detail?id=1084 + +/** @type {?number} */ +DeviceRotationRate.prototype.alpha; + +/** @type {?number} */ +DeviceRotationRate.prototype.beta; + +/** @type {?number} */ +DeviceRotationRate.prototype.gamma; + + +// @see https://code.google.com/p/closure-compiler/issues/detail?id=1088 + +/** @type {?number} */ +DeviceOrientationEvent.prototype.webkitCompassAccuracy; + +/** @type {?number} */ +DeviceOrientationEvent.prototype.webkitCompassHeading; diff --git a/externs/html5.js b/externs/html5.js deleted file mode 100644 index bc8a63ad2f..0000000000 --- a/externs/html5.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * @fileoverview Definitions for extensions over the W3C's DOM3 specification - * in HTML5 which are not yet available with the current release version of - * the closure compiler we use. - * @see http://dev.w3.org/html5/spec/Overview.html - * @externs - */ - -// See issue https://code.google.com/p/closure-compiler/issues/detail?id=1060 -// FIXME: this should be remove when the next closure compiler release is out -// with valueAsDate and valueAsNumber externs. - -/** @type {Date} */ -HTMLInputElement.prototype.valueAsDate; - -/** @type {number} */ -HTMLInputElement.prototype.valueAsNumber; diff --git a/src/ol/deviceorientation.js b/src/ol/deviceorientation.js index 3b86d5bba4..a9660d1119 100644 --- a/src/ol/deviceorientation.js +++ b/src/ol/deviceorientation.js @@ -122,6 +122,11 @@ ol.DeviceOrientation.prototype.orientationChange_ = function(browserEvent) { // event.absolute is undefined in iOS. if (goog.isBoolean(event.absolute) && event.absolute) { this.set(ol.DeviceOrientationProperty.HEADING, alpha); + } else if (goog.isDefAndNotNull(event.webkitCompassHeading) && + goog.isDefAndNotNull(event.webkitCompassAccuracy) && + event.webkitCompassAccuracy != -1) { + var heading = goog.math.toRadians(event.webkitCompassHeading); + this.set(ol.DeviceOrientationProperty.HEADING, heading); } } if (goog.isDefAndNotNull(event.beta)) {