Merge pull request #7948 from fredj/typecheck

Better type definition
This commit is contained in:
Frédéric Junod
2018-03-08 09:21:45 +01:00
committed by GitHub
30 changed files with 80 additions and 116 deletions
+2 -3
View File
@@ -321,7 +321,7 @@ const PluggableMap = function(options) {
/** /**
* @private * @private
* @type {Array.<module:ol/types~PostRenderFunction>} * @type {!Array.<module:ol/types~PostRenderFunction>}
*/ */
this.postRenderFunctions_ = []; this.postRenderFunctions_ = [];
@@ -1232,8 +1232,7 @@ PluggableMap.prototype.renderFrame_ = function(time) {
if (frameState.animate) { if (frameState.animate) {
this.render(); this.render();
} }
Array.prototype.push.apply( Array.prototype.push.apply(this.postRenderFunctions_, frameState.postRenderFunctions);
this.postRenderFunctions_, frameState.postRenderFunctions);
if (previousFrameState) { if (previousFrameState) {
const moveStart = !this.previousExtent_ || const moveStart = !this.previousExtent_ ||
+3 -4
View File
@@ -21,13 +21,12 @@ inherits(TileCache, LRUCache);
/** /**
* @param {Object.<string, ol.TileRange>} usedTiles Used tiles. * @param {!Object.<string, ol.TileRange>} usedTiles Used tiles.
*/ */
TileCache.prototype.expireCache = function(usedTiles) { TileCache.prototype.expireCache = function(usedTiles) {
let tile, zKey;
while (this.canExpireCache()) { while (this.canExpireCache()) {
tile = this.peekLast(); const tile = this.peekLast();
zKey = tile.tileCoord[0].toString(); const zKey = tile.tileCoord[0].toString();
if (zKey in usedTiles && usedTiles[zKey].contains(tile.tileCoord)) { if (zKey in usedTiles && usedTiles[zKey].contains(tile.tileCoord)) {
break; break;
} else { } else {
+2 -2
View File
@@ -40,7 +40,7 @@ const VectorImageTile = function(tileCoord, state, sourceRevision, format,
/** /**
* @private * @private
* @type {Object.<string, CanvasRenderingContext2D>} * @type {!Object.<string, CanvasRenderingContext2D>}
*/ */
this.context_ = {}; this.context_ = {};
@@ -52,7 +52,7 @@ const VectorImageTile = function(tileCoord, state, sourceRevision, format,
/** /**
* @private * @private
* @type {Object.<string, ol.TileReplayState>} * @type {!Object.<string, ol.TileReplayState>}
*/ */
this.replayState_ = {}; this.replayState_ = {};
+3 -5
View File
@@ -126,15 +126,13 @@ export function reverseSubArray(arr, begin, end) {
/** /**
* @param {Array.<VALUE>} arr The array to modify. * @param {Array.<VALUE>} arr The array to modify.
* @param {Array.<VALUE>|VALUE} data The elements or arrays of elements * @param {!Array.<VALUE>|VALUE} data The elements or arrays of elements to add to arr.
* to add to arr.
* @template VALUE * @template VALUE
*/ */
export function extend(arr, data) { export function extend(arr, data) {
let i;
const extension = Array.isArray(data) ? data : [data]; const extension = Array.isArray(data) ? data : [data];
const length = extension.length; const length = extension.length;
for (i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
arr[arr.length] = extension[i]; arr[arr.length] = extension[i];
} }
} }
@@ -160,7 +158,7 @@ export function remove(arr, obj) {
* @param {Array.<VALUE>} arr The array to search in. * @param {Array.<VALUE>} arr The array to search in.
* @param {function(VALUE, number, ?) : boolean} func The function to compare. * @param {function(VALUE, number, ?) : boolean} func The function to compare.
* @template VALUE * @template VALUE
* @return {VALUE} The element found. * @return {VALUE|null} The element found or null.
*/ */
export function find(arr, func) { export function find(arr, func) {
const length = arr.length >>> 0; const length = arr.length >>> 0;
+1 -1
View File
@@ -130,7 +130,7 @@ inherits(Attribution, Control);
Attribution.prototype.getSourceAttributions_ = function(frameState) { Attribution.prototype.getSourceAttributions_ = function(frameState) {
/** /**
* Used to determine if an attribution already exists. * Used to determine if an attribution already exists.
* @type {Object.<string, boolean>} * @type {!Object.<string, boolean>}
*/ */
const lookup = {}; const lookup = {};
+8 -13
View File
@@ -379,7 +379,7 @@ const GPX_SERIALIZERS = makeStructureNS(
* @param {Array.<number>} flatCoordinates Flat coordinates. * @param {Array.<number>} flatCoordinates Flat coordinates.
* @param {ol.LayoutOptions} layoutOptions Layout options. * @param {ol.LayoutOptions} layoutOptions Layout options.
* @param {Node} node Node. * @param {Node} node Node.
* @param {Object} values Values. * @param {!Object} values Values.
* @return {Array.<number>} Flat coordinates. * @return {Array.<number>} Flat coordinates.
*/ */
function appendCoordinate(flatCoordinates, layoutOptions, node, values) { function appendCoordinate(flatCoordinates, layoutOptions, node, values) {
@@ -477,14 +477,11 @@ function parseExtensions(node, objectStack) {
* @param {Array.<*>} objectStack Object stack. * @param {Array.<*>} objectStack Object stack.
*/ */
function parseRtePt(node, objectStack) { function parseRtePt(node, objectStack) {
const values = pushParseAndPop( const values = pushParseAndPop({}, RTEPT_PARSERS, node, objectStack);
{}, RTEPT_PARSERS, node, objectStack);
if (values) { if (values) {
const rteValues = /** @type {Object} */ (objectStack[objectStack.length - 1]); const rteValues = /** @type {!Object} */ (objectStack[objectStack.length - 1]);
const flatCoordinates = /** @type {Array.<number>} */ const flatCoordinates = /** @type {Array.<number>} */ (rteValues['flatCoordinates']);
(rteValues['flatCoordinates']); const layoutOptions = /** @type {ol.LayoutOptions} */ (rteValues['layoutOptions']);
const layoutOptions = /** @type {ol.LayoutOptions} */
(rteValues['layoutOptions']);
appendCoordinate(flatCoordinates, layoutOptions, node, values); appendCoordinate(flatCoordinates, layoutOptions, node, values);
} }
} }
@@ -497,11 +494,9 @@ function parseRtePt(node, objectStack) {
function parseTrkPt(node, objectStack) { function parseTrkPt(node, objectStack) {
const values = pushParseAndPop({}, TRKPT_PARSERS, node, objectStack); const values = pushParseAndPop({}, TRKPT_PARSERS, node, objectStack);
if (values) { if (values) {
const trkValues = /** @type {Object} */ (objectStack[objectStack.length - 1]); const trkValues = /** @type {!Object} */ (objectStack[objectStack.length - 1]);
const flatCoordinates = /** @type {Array.<number>} */ const flatCoordinates = /** @type {Array.<number>} */ (trkValues['flatCoordinates']);
(trkValues['flatCoordinates']); const layoutOptions = /** @type {ol.LayoutOptions} */ (trkValues['layoutOptions']);
const layoutOptions = /** @type {ol.LayoutOptions} */
(trkValues['layoutOptions']);
appendCoordinate(flatCoordinates, layoutOptions, node, values); appendCoordinate(flatCoordinates, layoutOptions, node, values);
} }
} }
+10 -18
View File
@@ -277,7 +277,7 @@ const KML = function(opt_options) {
/** /**
* @private * @private
* @type {Object.<string, (Array.<ol.style.Style>|string)>} * @type {!Object.<string, (Array.<ol.style.Style>|string)>}
*/ */
this.sharedStyles_ = {}; this.sharedStyles_ = {};
@@ -384,14 +384,11 @@ function createNameStyleFunction(foundStyle, name) {
* @param {Array.<ol.style.Style>|undefined} style Style. * @param {Array.<ol.style.Style>|undefined} style Style.
* @param {string} styleUrl Style URL. * @param {string} styleUrl Style URL.
* @param {Array.<ol.style.Style>} defaultStyle Default style. * @param {Array.<ol.style.Style>} defaultStyle Default style.
* @param {Object.<string, (Array.<ol.style.Style>|string)>} sharedStyles Shared * @param {!Object.<string, (Array.<ol.style.Style>|string)>} sharedStyles Shared styles.
* styles. * @param {boolean|undefined} showPointNames true to show names for point placemarks.
* @param {boolean|undefined} showPointNames true to show names for point
* placemarks.
* @return {ol.StyleFunction} Feature style function. * @return {ol.StyleFunction} Feature style function.
*/ */
function createFeatureStyleFunction(style, styleUrl, function createFeatureStyleFunction(style, styleUrl, defaultStyle, sharedStyles, showPointNames) {
defaultStyle, sharedStyles, showPointNames) {
return ( return (
/** /**
@@ -418,25 +415,21 @@ function createFeatureStyleFunction(style, styleUrl,
if (style) { if (style) {
if (drawName) { if (drawName) {
nameStyle = createNameStyleFunction(style[0], nameStyle = createNameStyleFunction(style[0], name);
name);
return style.concat(nameStyle); return style.concat(nameStyle);
} }
return style; return style;
} }
if (styleUrl) { if (styleUrl) {
const foundStyle = findStyle(styleUrl, defaultStyle, const foundStyle = findStyle(styleUrl, defaultStyle, sharedStyles);
sharedStyles);
if (drawName) { if (drawName) {
nameStyle = createNameStyleFunction(foundStyle[0], nameStyle = createNameStyleFunction(foundStyle[0], name);
name);
return foundStyle.concat(nameStyle); return foundStyle.concat(nameStyle);
} }
return foundStyle; return foundStyle;
} }
if (drawName) { if (drawName) {
nameStyle = createNameStyleFunction(defaultStyle[0], nameStyle = createNameStyleFunction(defaultStyle[0], name);
name);
return defaultStyle.concat(nameStyle); return defaultStyle.concat(nameStyle);
} }
return defaultStyle; return defaultStyle;
@@ -448,7 +441,7 @@ function createFeatureStyleFunction(style, styleUrl,
/** /**
* @param {Array.<ol.style.Style>|string|undefined} styleValue Style value. * @param {Array.<ol.style.Style>|string|undefined} styleValue Style value.
* @param {Array.<ol.style.Style>} defaultStyle Default style. * @param {Array.<ol.style.Style>} defaultStyle Default style.
* @param {Object.<string, (Array.<ol.style.Style>|string)>} sharedStyles * @param {!Object.<string, (Array.<ol.style.Style>|string)>} sharedStyles
* Shared styles. * Shared styles.
* @return {Array.<ol.style.Style>} Style. * @return {Array.<ol.style.Style>} Style.
*/ */
@@ -462,8 +455,7 @@ function findStyle(styleValue, defaultStyle, sharedStyles) {
if (!(styleValue in sharedStyles) && ('#' + styleValue in sharedStyles)) { if (!(styleValue in sharedStyles) && ('#' + styleValue in sharedStyles)) {
styleValue = '#' + styleValue; styleValue = '#' + styleValue;
} }
return findStyle( return findStyle(sharedStyles[styleValue], defaultStyle, sharedStyles);
sharedStyles[styleValue], defaultStyle, sharedStyles);
} else { } else {
return defaultStyle; return defaultStyle;
} }
+1 -2
View File
@@ -446,8 +446,7 @@ function readCapabilityLayer(node, objectStack) {
* @return {Object|undefined} Layer object. * @return {Object|undefined} Layer object.
*/ */
function readLayer(node, objectStack) { function readLayer(node, objectStack) {
const parentLayerObject = /** @type {Object.<string,*>} */ const parentLayerObject = /** @type {!Object.<string,*>} */ (objectStack[objectStack.length - 1]);
(objectStack[objectStack.length - 1]);
const layerObject = pushParseAndPop({}, LAYER_PARSERS, node, objectStack); const layerObject = pushParseAndPop({}, LAYER_PARSERS, node, objectStack);
+1 -1
View File
@@ -32,7 +32,7 @@ function line(interpolate, transform, squaredTolerance) {
/** @type {Array.<number>} */ /** @type {Array.<number>} */
const fractionStack = [1, 0]; const fractionStack = [1, 0];
/** @type {Object.<string, boolean>} */ /** @type {!Object.<string, boolean>} */
const fractions = {}; const fractions = {};
let maxIterations = 1e5; let maxIterations = 1e5;
+1 -1
View File
@@ -223,7 +223,7 @@ const Modify = function(options) {
/** /**
* @const * @const
* @private * @private
* @type {Object.<string, function(ol.Feature, ol.geom.Geometry)>} * @type {!Object.<string, function(ol.Feature, ol.geom.Geometry)>}
*/ */
this.SEGMENT_WRITERS_ = { this.SEGMENT_WRITERS_ = {
'Point': this.writePointGeometry_, 'Point': this.writePointGeometry_,
+1 -1
View File
@@ -97,7 +97,7 @@ const PointerInteraction = function(opt_options) {
this.handlingDownUpSequence = false; this.handlingDownUpSequence = false;
/** /**
* @type {Object.<string, ol.pointer.PointerEvent>} * @type {!Object.<string, ol.pointer.PointerEvent>}
* @private * @private
*/ */
this.trackedPointers_ = {}; this.trackedPointers_ = {};
+1 -1
View File
@@ -97,7 +97,7 @@ const Snap = function(opt_options) {
* If a feature geometry changes while a pointer drag|move event occurs, the * If a feature geometry changes while a pointer drag|move event occurs, the
* feature doesn't get updated right away. It will be at the next 'pointerup' * feature doesn't get updated right away. It will be at the next 'pointerup'
* event fired. * event fired.
* @type {Object.<number, ol.Feature>} * @type {!Object.<number, ol.Feature>}
* @private * @private
*/ */
this.pendingFeatures_ = {}; this.pendingFeatures_ = {};
+1 -1
View File
@@ -6,7 +6,7 @@ import {isEmpty} from '../obj.js';
/** /**
* @private * @private
* @type {Object.<string, Object.<string, ol.TransformFunction>>} * @type {!Object.<string, !Object.<string, ol.TransformFunction>>}
*/ */
let transforms = {}; let transforms = {};
+1 -1
View File
@@ -129,7 +129,7 @@ const CanvasReplay = function(tolerance, maxExtent, resolution, pixelRatio, over
/** /**
* @private * @private
* @type {Object.<number,ol.Coordinate|Array.<ol.Coordinate>|Array.<Array.<ol.Coordinate>>>} * @type {!Object.<number,ol.Coordinate|Array.<ol.Coordinate>|Array.<Array.<ol.Coordinate>>>}
*/ */
this.coordinateCache_ = {}; this.coordinateCache_ = {};
+1 -2
View File
@@ -100,8 +100,7 @@ const CanvasReplayGroup = function(
/** /**
* @private * @private
* @type {!Object.<string, * @type {!Object.<string, !Object.<ol.render.ReplayType, ol.render.canvas.Replay>>}
* Object.<ol.render.ReplayType, ol.render.canvas.Replay>>}
*/ */
this.replaysByZIndex_ = {}; this.replaysByZIndex_ = {};
+3 -3
View File
@@ -79,7 +79,7 @@ const CanvasTextReplay = function(
this.textFillState_ = null; this.textFillState_ = null;
/** /**
* @type {Object.<string, ol.CanvasFillState>} * @type {!Object.<string, ol.CanvasFillState>}
*/ */
this.fillStates = {}; this.fillStates = {};
@@ -90,7 +90,7 @@ const CanvasTextReplay = function(
this.textStrokeState_ = null; this.textStrokeState_ = null;
/** /**
* @type {Object.<string, ol.CanvasStrokeState>} * @type {!Object.<string, ol.CanvasStrokeState>}
*/ */
this.strokeStates = {}; this.strokeStates = {};
@@ -101,7 +101,7 @@ const CanvasTextReplay = function(
this.textState_ = /** @type {ol.CanvasTextState} */ ({}); this.textState_ = /** @type {ol.CanvasTextState} */ ({});
/** /**
* @type {Object.<string, ol.CanvasTextState>} * @type {!Object.<string, ol.CanvasTextState>}
*/ */
this.textStates = {}; this.textStates = {};
+2 -3
View File
@@ -242,9 +242,8 @@ WebGLTextureReplay.prototype.drawCoordinates = function(flatCoordinates, offset,
/** /**
* @protected * @protected
* @param {Array.<WebGLTexture>} textures Textures. * @param {Array.<WebGLTexture>} textures Textures.
* @param {Array.<HTMLCanvasElement|HTMLImageElement|HTMLVideoElement>} images * @param {Array.<HTMLCanvasElement|HTMLImageElement|HTMLVideoElement>} images Images.
* Images. * @param {!Object.<string, WebGLTexture>} texturePerImage Texture cache.
* @param {Object.<string, WebGLTexture>} texturePerImage Texture cache.
* @param {WebGLRenderingContext} gl Gl. * @param {WebGLRenderingContext} gl Gl.
*/ */
WebGLTextureReplay.prototype.createTextures = function(textures, images, texturePerImage, gl) { WebGLTextureReplay.prototype.createTextures = function(textures, images, texturePerImage, gl) {
+1 -1
View File
@@ -164,7 +164,7 @@ LayerRenderer.prototype.scheduleExpireCache = function(frameState, tileSource) {
/** /**
* @param {Object.<string, Object.<string, ol.TileRange>>} usedTiles Used tiles. * @param {!Object.<string, !Object.<string, ol.TileRange>>} usedTiles Used tiles.
* @param {ol.source.Tile} tileSource Tile source. * @param {ol.source.Tile} tileSource Tile source.
* @param {number} z Z. * @param {number} z Z.
* @param {ol.TileRange} tileRange Tile range. * @param {ol.TileRange} tileRange Tile range.
+1 -1
View File
@@ -32,7 +32,7 @@ const MapRenderer = function(container, map) {
/** /**
* @private * @private
* @type {Object.<string, ol.renderer.Layer>} * @type {!Object.<string, ol.renderer.Layer>}
*/ */
this.layerRenderers_ = {}; this.layerRenderers_ = {};
+5 -6
View File
@@ -253,14 +253,13 @@ CanvasVectorLayerRenderer.prototype.forEachFeatureAtCoordinate = function(coordi
const resolution = frameState.viewState.resolution; const resolution = frameState.viewState.resolution;
const rotation = frameState.viewState.rotation; const rotation = frameState.viewState.rotation;
const layer = /** @type {ol.layer.Vector} */ (this.getLayer()); const layer = /** @type {ol.layer.Vector} */ (this.getLayer());
/** @type {Object.<string, boolean>} */ /** @type {!Object.<string, boolean>} */
const features = {}; const features = {};
const result = this.replayGroup_.forEachFeatureAtCoordinate(coordinate, resolution, const result = this.replayGroup_.forEachFeatureAtCoordinate(coordinate, resolution, rotation, hitTolerance, {},
rotation, hitTolerance, {},
/** /**
* @param {ol.Feature|ol.render.Feature} feature Feature. * @param {ol.Feature|ol.render.Feature} feature Feature.
* @return {?} Callback result. * @return {?} Callback result.
*/ */
function(feature) { function(feature) {
const key = getUid(feature).toString(); const key = getUid(feature).toString();
if (!(key in features)) { if (!(key in features)) {
+2 -3
View File
@@ -265,7 +265,7 @@ CanvasVectorTileLayerRenderer.prototype.forEachFeatureAtCoordinate = function(co
const rotation = frameState.viewState.rotation; const rotation = frameState.viewState.rotation;
hitTolerance = hitTolerance == undefined ? 0 : hitTolerance; hitTolerance = hitTolerance == undefined ? 0 : hitTolerance;
const layer = this.getLayer(); const layer = this.getLayer();
/** @type {Object.<string, boolean>} */ /** @type {!Object.<string, boolean>} */
const features = {}; const features = {};
/** @type {Array.<ol.VectorImageTile>} */ /** @type {Array.<ol.VectorImageTile>} */
@@ -290,8 +290,7 @@ CanvasVectorTileLayerRenderer.prototype.forEachFeatureAtCoordinate = function(co
continue; continue;
} }
replayGroup = sourceTile.getReplayGroup(layer, tile.tileCoord.toString()); replayGroup = sourceTile.getReplayGroup(layer, tile.tileCoord.toString());
found = found || replayGroup.forEachFeatureAtCoordinate( found = found || replayGroup.forEachFeatureAtCoordinate(coordinate, resolution, rotation, hitTolerance, {},
coordinate, resolution, rotation, hitTolerance, {},
/** /**
* @param {ol.Feature|ol.render.Feature} feature Feature. * @param {ol.Feature|ol.render.Feature} feature Feature.
* @return {?} Callback result. * @return {?} Callback result.
+1 -1
View File
@@ -143,7 +143,7 @@ WebGLVectorLayerRenderer.prototype.forEachFeatureAtCoordinate = function(coordin
const viewState = frameState.viewState; const viewState = frameState.viewState;
const layer = this.getLayer(); const layer = this.getLayer();
const layerState = this.layerState_; const layerState = this.layerState_;
/** @type {Object.<string, boolean>} */ /** @type {!Object.<string, boolean>} */
const features = {}; const features = {};
return this.replayGroup_.forEachFeatureAtCoordinate(coordinate, return this.replayGroup_.forEachFeatureAtCoordinate(coordinate,
context, viewState.center, viewState.resolution, viewState.rotation, context, viewState.center, viewState.resolution, viewState.rotation,
+3 -4
View File
@@ -61,13 +61,13 @@ const TileImage = function(options) {
/** /**
* @protected * @protected
* @type {Object.<string, ol.TileCache>} * @type {!Object.<string, ol.TileCache>}
*/ */
this.tileCacheForProjection = {}; this.tileCacheForProjection = {};
/** /**
* @protected * @protected
* @type {Object.<string, ol.tilegrid.TileGrid>} * @type {!Object.<string, ol.tilegrid.TileGrid>}
*/ */
this.tileGridForProjection = {}; this.tileGridForProjection = {};
@@ -173,8 +173,7 @@ TileImage.prototype.getTileGridForProjection = function(projection) {
} else { } else {
const projKey = getUid(projection).toString(); const projKey = getUid(projection).toString();
if (!(projKey in this.tileGridForProjection)) { if (!(projKey in this.tileGridForProjection)) {
this.tileGridForProjection[projKey] = this.tileGridForProjection[projKey] = getTileGridForProjection(projection);
getTileGridForProjection(projection);
} }
return /** @type {!ol.tilegrid.TileGrid} */ (this.tileGridForProjection[projKey]); return /** @type {!ol.tilegrid.TileGrid} */ (this.tileGridForProjection[projKey]);
} }
+1 -1
View File
@@ -63,7 +63,7 @@ const UrlTile = function(options) {
/** /**
* @private * @private
* @type {Object.<number, boolean>} * @type {!Object.<number, boolean>}
*/ */
this.tileLoadingKeys_ = {}; this.tileLoadingKeys_ = {};
+3 -3
View File
@@ -126,21 +126,21 @@ const VectorSource = function(opt_options) {
/** /**
* @private * @private
* @type {Object.<string, ol.Feature>} * @type {!Object.<string, ol.Feature>}
*/ */
this.nullGeometryFeatures_ = {}; this.nullGeometryFeatures_ = {};
/** /**
* A lookup of features by id (the return from feature.getId()). * A lookup of features by id (the return from feature.getId()).
* @private * @private
* @type {Object.<string, ol.Feature>} * @type {!Object.<string, ol.Feature>}
*/ */
this.idIndex_ = {}; this.idIndex_ = {};
/** /**
* A lookup of features without id (keyed by ol.getUid(feature)). * A lookup of features without id (keyed by ol.getUid(feature)).
* @private * @private
* @type {Object.<string, ol.Feature>} * @type {!Object.<string, ol.Feature>}
*/ */
this.undefIdIndex_ = {}; this.undefIdIndex_ = {};
+1 -1
View File
@@ -288,7 +288,7 @@ WMTS.prototype.updateDimensions = function(dimensions) {
/** /**
* Generate source options from a capabilities object. * Generate source options from a capabilities object.
* @param {Object} wmtsCap An object representing the capabilities document. * @param {Object} wmtsCap An object representing the capabilities document.
* @param {Object} config Configuration properties for the layer. Defaults for * @param {!Object} config Configuration properties for the layer. Defaults for
* the layer will apply if not provided. * the layer will apply if not provided.
* *
* Required config properties: * Required config properties:
+1 -1
View File
@@ -46,7 +46,7 @@ const PriorityQueue = function(priorityFunction, keyFunction) {
this.priorities_ = []; this.priorities_ = [];
/** /**
* @type {Object.<string, boolean>} * @type {!Object.<string, boolean>}
* @private * @private
*/ */
this.queuedElements_ = {}; this.queuedElements_ = {};
+1 -1
View File
@@ -10,7 +10,7 @@ import {asString} from '../color.js';
const IconImageCache = function() { const IconImageCache = function() {
/** /**
* @type {Object.<string, ol.style.IconImage>} * @type {!Object.<string, ol.style.IconImage>}
* @private * @private
*/ */
this.cache_ = {}; this.cache_ = {};
+3 -3
View File
@@ -34,19 +34,19 @@ const WebGLContext = function(canvas, gl) {
/** /**
* @private * @private
* @type {Object.<string, ol.WebglBufferCacheEntry>} * @type {!Object.<string, ol.WebglBufferCacheEntry>}
*/ */
this.bufferCache_ = {}; this.bufferCache_ = {};
/** /**
* @private * @private
* @type {Object.<string, WebGLShader>} * @type {!Object.<string, WebGLShader>}
*/ */
this.shaderCache_ = {}; this.shaderCache_ = {};
/** /**
* @private * @private
* @type {Object.<string, WebGLProgram>} * @type {!Object.<string, WebGLProgram>}
*/ */
this.programCache_ = {}; this.programCache_ = {};
+15 -28
View File
@@ -133,8 +133,7 @@ export function makeArrayExtender(valueReader, opt_this) {
function(node, objectStack) { function(node, objectStack) {
const value = valueReader.call(opt_this, node, objectStack); const value = valueReader.call(opt_this, node, objectStack);
if (value !== undefined) { if (value !== undefined) {
const array = /** @type {Array.<*>} */ const array = /** @type {Array.<*>} */ (objectStack[objectStack.length - 1]);
(objectStack[objectStack.length - 1]);
extend(array, value); extend(array, value);
} }
} }
@@ -157,8 +156,7 @@ export function makeArrayPusher(valueReader, opt_this) {
* @param {Array.<*>} objectStack Object stack. * @param {Array.<*>} objectStack Object stack.
*/ */
function(node, objectStack) { function(node, objectStack) {
const value = valueReader.call(opt_this !== undefined ? opt_this : this, const value = valueReader.call(opt_this !== undefined ? opt_this : this, node, objectStack);
node, objectStack);
if (value !== undefined) { if (value !== undefined) {
const array = objectStack[objectStack.length - 1]; const array = objectStack[objectStack.length - 1];
array.push(value); array.push(value);
@@ -182,8 +180,7 @@ export function makeReplacer(valueReader, opt_this) {
* @param {Array.<*>} objectStack Object stack. * @param {Array.<*>} objectStack Object stack.
*/ */
function(node, objectStack) { function(node, objectStack) {
const value = valueReader.call(opt_this !== undefined ? opt_this : this, const value = valueReader.call(opt_this !== undefined ? opt_this : this, node, objectStack);
node, objectStack);
if (value !== undefined) { if (value !== undefined) {
objectStack[objectStack.length - 1] = value; objectStack[objectStack.length - 1] = value;
} }
@@ -207,13 +204,10 @@ export function makeObjectPropertyPusher(valueReader, opt_property, opt_this) {
* @param {Array.<*>} objectStack Object stack. * @param {Array.<*>} objectStack Object stack.
*/ */
function(node, objectStack) { function(node, objectStack) {
const value = valueReader.call(opt_this !== undefined ? opt_this : this, const value = valueReader.call(opt_this !== undefined ? opt_this : this, node, objectStack);
node, objectStack);
if (value !== undefined) { if (value !== undefined) {
const object = /** @type {Object} */ const object = /** @type {!Object} */ (objectStack[objectStack.length - 1]);
(objectStack[objectStack.length - 1]); const property = opt_property !== undefined ? opt_property : node.localName;
const property = opt_property !== undefined ?
opt_property : node.localName;
let array; let array;
if (property in object) { if (property in object) {
array = object[property]; array = object[property];
@@ -241,13 +235,10 @@ export function makeObjectPropertySetter(valueReader, opt_property, opt_this) {
* @param {Array.<*>} objectStack Object stack. * @param {Array.<*>} objectStack Object stack.
*/ */
function(node, objectStack) { function(node, objectStack) {
const value = valueReader.call(opt_this !== undefined ? opt_this : this, const value = valueReader.call(opt_this !== undefined ? opt_this : this, node, objectStack);
node, objectStack);
if (value !== undefined) { if (value !== undefined) {
const object = /** @type {Object} */ const object = /** @type {!Object} */ (objectStack[objectStack.length - 1]);
(objectStack[objectStack.length - 1]); const property = opt_property !== undefined ? opt_property : node.localName;
const property = opt_property !== undefined ?
opt_property : node.localName;
object[property] = value; object[property] = value;
} }
}); });
@@ -266,8 +257,7 @@ export function makeObjectPropertySetter(valueReader, opt_property, opt_this) {
*/ */
export function makeChildAppender(nodeWriter, opt_this) { export function makeChildAppender(nodeWriter, opt_this) {
return function(node, value, objectStack) { return function(node, value, objectStack) {
nodeWriter.call(opt_this !== undefined ? opt_this : this, nodeWriter.call(opt_this !== undefined ? opt_this : this, node, value, objectStack);
node, value, objectStack);
const parent = objectStack[objectStack.length - 1]; const parent = objectStack[objectStack.length - 1];
const parentNode = parent.node; const parentNode = parent.node;
parentNode.appendChild(node); parentNode.appendChild(node);
@@ -430,11 +420,10 @@ export function parseNode(parsersNS, node, objectStack, opt_this) {
* @return {T} Object. * @return {T} Object.
* @template T * @template T
*/ */
export function pushParseAndPop( export function pushParseAndPop(object, parsersNS, node, objectStack, opt_this) {
object, parsersNS, node, objectStack, opt_this) {
objectStack.push(object); objectStack.push(object);
parseNode(parsersNS, node, objectStack, opt_this); parseNode(parsersNS, node, objectStack, opt_this);
return objectStack.pop(); return /** @type {T} */ (objectStack.pop());
} }
@@ -501,10 +490,8 @@ export function serialize(
* @return {O|undefined} Object. * @return {O|undefined} Object.
* @template O, T * @template O, T
*/ */
export function pushSerializeAndPop(object, export function pushSerializeAndPop(object, serializersNS, nodeFactory, values, objectStack, opt_keys, opt_this) {
serializersNS, nodeFactory, values, objectStack, opt_keys, opt_this) {
objectStack.push(object); objectStack.push(object);
serialize( serialize(serializersNS, nodeFactory, values, objectStack, opt_keys, opt_this);
serializersNS, nodeFactory, values, objectStack, opt_keys, opt_this); return /** @type {O|undefined} */ (objectStack.pop());
return objectStack.pop();
} }