Be more strict with {Element} types

This commit is contained in:
Frederic Junod
2013-11-12 10:22:27 +01:00
parent 1560fbace3
commit ca5960666d
4 changed files with 13 additions and 9 deletions
+5 -3
View File
@@ -33,9 +33,10 @@ ol.renderer.canvas.Map = function(container, map) {
/** /**
* @private * @private
* @type {Element} * @type {HTMLCanvasElement}
*/ */
this.canvas_ = goog.dom.createElement(goog.dom.TagName.CANVAS); this.canvas_ = /** @type {HTMLCanvasElement} */
(goog.dom.createElement(goog.dom.TagName.CANVAS));
this.canvas_.height = container.clientHeight; this.canvas_.height = container.clientHeight;
this.canvas_.width = container.clientWidth; this.canvas_.width = container.clientWidth;
this.canvas_.className = ol.css.CLASS_UNSELECTABLE; this.canvas_.className = ol.css.CLASS_UNSELECTABLE;
@@ -57,7 +58,8 @@ ol.renderer.canvas.Map = function(container, map) {
* @private * @private
* @type {CanvasRenderingContext2D} * @type {CanvasRenderingContext2D}
*/ */
this.context_ = this.canvas_.getContext('2d'); this.context_ = /** @type {CanvasRenderingContext2D} */
(this.canvas_.getContext('2d'));
}; };
goog.inherits(ol.renderer.canvas.Map, ol.renderer.Map); goog.inherits(ol.renderer.canvas.Map, ol.renderer.Map);
+1 -1
View File
@@ -93,7 +93,7 @@ ol.renderer.Map.prototype.disposeInternal = function() {
/** /**
* @return {Element} Canvas. * @return {HTMLCanvasElement} Canvas.
*/ */
ol.renderer.Map.prototype.getCanvas = goog.functions.NULL; ol.renderer.Map.prototype.getCanvas = goog.functions.NULL;
+3 -2
View File
@@ -70,9 +70,10 @@ ol.renderer.webgl.Map = function(container, map) {
/** /**
* @private * @private
* @type {Element} * @type {HTMLCanvasElement}
*/ */
this.canvas_ = goog.dom.createElement(goog.dom.TagName.CANVAS); this.canvas_ = /** @type {HTMLCanvasElement} */
(goog.dom.createElement(goog.dom.TagName.CANVAS));
this.canvas_.height = container.clientHeight; this.canvas_.height = container.clientHeight;
this.canvas_.width = container.clientWidth; this.canvas_.width = container.clientWidth;
this.canvas_.className = ol.css.CLASS_UNSELECTABLE; this.canvas_.className = ol.css.CLASS_UNSELECTABLE;
+4 -3
View File
@@ -28,7 +28,7 @@ ol.webgl.WebGLContextEventType = {
/** /**
* @param {Element} canvas Canvas. * @param {HTMLCanvasElement} canvas Canvas.
* @param {Object=} opt_attributes Attributes. * @param {Object=} opt_attributes Attributes.
* @return {WebGLRenderingContext} WebGL rendering context. * @return {WebGLRenderingContext} WebGL rendering context.
*/ */
@@ -38,7 +38,7 @@ ol.webgl.getContext = function(canvas, opt_attributes) {
try { try {
context = canvas.getContext(ol.webgl.CONTEXT_IDS_[i], opt_attributes); context = canvas.getContext(ol.webgl.CONTEXT_IDS_[i], opt_attributes);
if (!goog.isNull(context)) { if (!goog.isNull(context)) {
return context; return /** @type {!WebGLRenderingContext} */ (context);
} }
} catch (e) { } catch (e) {
} }
@@ -57,7 +57,8 @@ ol.webgl.SUPPORTED = (function() {
return false; return false;
} }
try { try {
var canvas = goog.dom.createElement(goog.dom.TagName.CANVAS); var canvas = /** @type {HTMLCanvasElement} */
(goog.dom.createElement(goog.dom.TagName.CANVAS));
return !goog.isNull(ol.webgl.getContext(canvas)); return !goog.isNull(ol.webgl.getContext(canvas));
} catch (e) { } catch (e) {
return false; return false;