Merge pull request #1538 from twpayne/vector-api-this

[vector-api] Use opt_this for this arguments
This commit is contained in:
Tom Payne
2014-01-15 06:24:03 -08:00
16 changed files with 93 additions and 95 deletions
+3 -3
View File
@@ -115,12 +115,12 @@ ol.Collection.prototype.extend = function(arr) {
* @param {function(this: S, T, number, Array.<T>): *} f The function to call * @param {function(this: S, T, number, Array.<T>): *} f The function to call
* for every element. This function takes 3 arguments (the element, the * for every element. This function takes 3 arguments (the element, the
* index and the array). The return value is ignored. * index and the array). The return value is ignored.
* @param {S=} opt_obj The object to be used as the value of 'this' within f. * @param {S=} opt_this The object to use as `this` in `f`.
* @template T,S * @template T,S
* @todo stability experimental * @todo stability experimental
*/ */
ol.Collection.prototype.forEach = function(f, opt_obj) { ol.Collection.prototype.forEach = function(f, opt_this) {
goog.array.forEach(this.array_, f, opt_obj); goog.array.forEach(this.array_, f, opt_this);
}; };
+3 -3
View File
@@ -1274,13 +1274,13 @@ ol.Map.prototype.updateSize = function() {
/** /**
* @param {function(this: T)} f Function. * @param {function(this: T)} f Function.
* @param {T=} opt_obj Object. * @param {T=} opt_this The object to use as `this` in `f`.
* @template T * @template T
*/ */
ol.Map.prototype.withFrozenRendering = function(f, opt_obj) { ol.Map.prototype.withFrozenRendering = function(f, opt_this) {
this.freezeRendering(); this.freezeRendering();
try { try {
f.call(opt_obj); f.call(opt_this);
} finally { } finally {
this.unfreezeRendering(); this.unfreezeRendering();
} }
+9 -12
View File
@@ -25,13 +25,12 @@ goog.inherits(ol.Observable, goog.events.EventTarget);
* Listen for a certain type of event. * Listen for a certain type of event.
* @param {string|Array.<string>} type The event type or array of event types. * @param {string|Array.<string>} type The event type or array of event types.
* @param {function(?): ?} listener The listener function. * @param {function(?): ?} listener The listener function.
* @param {Object=} opt_scope Object is whose scope to call * @param {Object=} opt_this The object to use as `this` in `listener`.
* the listener.
* @return {goog.events.Key} Unique key for the listener. * @return {goog.events.Key} Unique key for the listener.
* @todo stability experimental * @todo stability experimental
*/ */
ol.Observable.prototype.on = function(type, listener, opt_scope) { ol.Observable.prototype.on = function(type, listener, opt_this) {
return goog.events.listen(this, type, listener, false, opt_scope); return goog.events.listen(this, type, listener, false, opt_this);
}; };
@@ -39,13 +38,12 @@ ol.Observable.prototype.on = function(type, listener, opt_scope) {
* Listen once for a certain type of event. * Listen once for a certain type of event.
* @param {string|Array.<string>} type The event type or array of event types. * @param {string|Array.<string>} type The event type or array of event types.
* @param {function(?): ?} listener The listener function. * @param {function(?): ?} listener The listener function.
* @param {Object=} opt_scope Object is whose scope to call * @param {Object=} opt_this The object to use as `this` in `listener`.
* the listener.
* @return {goog.events.Key} Unique key for the listener. * @return {goog.events.Key} Unique key for the listener.
* @todo stability experimental * @todo stability experimental
*/ */
ol.Observable.prototype.once = function(type, listener, opt_scope) { ol.Observable.prototype.once = function(type, listener, opt_this) {
return goog.events.listenOnce(this, type, listener, false, opt_scope); return goog.events.listenOnce(this, type, listener, false, opt_this);
}; };
@@ -53,12 +51,11 @@ ol.Observable.prototype.once = function(type, listener, opt_scope) {
* Unlisten for a certain type of event. * Unlisten for a certain type of event.
* @param {string|Array.<string>} type The event type or array of event types. * @param {string|Array.<string>} type The event type or array of event types.
* @param {function(?): ?} listener The listener function. * @param {function(?): ?} listener The listener function.
* @param {Object=} opt_scope Object is whose scope to call * @param {Object=} opt_this The object to use as `this` in `listener`.
* the listener.
* @todo stability experimental * @todo stability experimental
*/ */
ol.Observable.prototype.un = function(type, listener, opt_scope) { ol.Observable.prototype.un = function(type, listener, opt_this) {
goog.events.unlisten(this, type, listener, false, opt_scope); goog.events.unlisten(this, type, listener, false, opt_this);
}; };
@@ -45,7 +45,7 @@ goog.inherits(ol.renderer.canvas.ImageLayer, ol.renderer.canvas.Layer);
* @inheritDoc * @inheritDoc
*/ */
ol.renderer.canvas.ImageLayer.prototype.forEachFeatureAtPixel = ol.renderer.canvas.ImageLayer.prototype.forEachFeatureAtPixel =
function(coordinate, frameState, callback, opt_obj) { function(coordinate, frameState, callback, opt_this) {
var layer = this.getLayer(); var layer = this.getLayer();
var source = layer.getSource(); var source = layer.getSource();
goog.asserts.assertInstanceof(source, ol.source.Image); goog.asserts.assertInstanceof(source, ol.source.Image);
@@ -58,7 +58,7 @@ ol.renderer.canvas.ImageLayer.prototype.forEachFeatureAtPixel =
* @return {?} Callback result. * @return {?} Callback result.
*/ */
function(feature) { function(feature) {
return callback.call(opt_obj, feature, this); return callback.call(opt_this, feature, this);
}); });
}; };
@@ -89,7 +89,7 @@ ol.renderer.canvas.VectorLayer.prototype.composeFrame =
* @inheritDoc * @inheritDoc
*/ */
ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtPixel = ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtPixel =
function(coordinate, frameState, callback, opt_obj) { function(coordinate, frameState, callback, opt_this) {
if (goog.isNull(this.replayGroup_)) { if (goog.isNull(this.replayGroup_)) {
return undefined; return undefined;
} else { } else {
@@ -109,7 +109,7 @@ ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtPixel =
function(geometry, data) { function(geometry, data) {
var feature = /** @type {ol.Feature} */ (data); var feature = /** @type {ol.Feature} */ (data);
goog.asserts.assert(goog.isDef(feature)); goog.asserts.assert(goog.isDef(feature));
return callback.call(opt_obj, feature, layer); return callback.call(opt_this, feature, layer);
}); });
} }
}; };
+2 -2
View File
@@ -50,7 +50,7 @@ goog.inherits(ol.renderer.dom.ImageLayer, ol.renderer.dom.Layer);
* @inheritDoc * @inheritDoc
*/ */
ol.renderer.dom.ImageLayer.prototype.forEachFeatureAtPixel = ol.renderer.dom.ImageLayer.prototype.forEachFeatureAtPixel =
function(coordinate, frameState, callback, opt_obj) { function(coordinate, frameState, callback, opt_this) {
var layer = this.getLayer(); var layer = this.getLayer();
var source = layer.getSource(); var source = layer.getSource();
goog.asserts.assertInstanceof(source, ol.source.Image); goog.asserts.assertInstanceof(source, ol.source.Image);
@@ -63,7 +63,7 @@ ol.renderer.dom.ImageLayer.prototype.forEachFeatureAtPixel =
* @return {?} Callback result. * @return {?} Callback result.
*/ */
function(feature) { function(feature) {
return callback.call(opt_obj, feature, this); return callback.call(opt_this, feature, this);
}); });
}; };
+4 -4
View File
@@ -49,7 +49,7 @@ goog.inherits(ol.renderer.Layer, goog.Disposable);
* @param {ol.FrameState} frameState Frame state. * @param {ol.FrameState} frameState Frame state.
* @param {function(this: S, ol.Feature, ol.layer.Layer): T} callback Feature * @param {function(this: S, ol.Feature, ol.layer.Layer): T} callback Feature
* callback. * callback.
* @param {S=} opt_obj Scope. * @param {S=} opt_this Object to use as `this` in `callback`.
* @return {T|undefined} Callback result. * @return {T|undefined} Callback result.
* @template S,T * @template S,T
*/ */
@@ -249,13 +249,13 @@ ol.renderer.Layer.prototype.snapCenterToPixel =
* @param {number} currentZ Current Z. * @param {number} currentZ Current Z.
* @param {number} preload Load low resolution tiles up to 'preload' levels. * @param {number} preload Load low resolution tiles up to 'preload' levels.
* @param {function(this: T, ol.Tile)=} opt_tileCallback Tile callback. * @param {function(this: T, ol.Tile)=} opt_tileCallback Tile callback.
* @param {T=} opt_obj Object. * @param {T=} opt_this Object to use as `this` in `opt_tileCallback`.
* @protected * @protected
* @template T * @template T
*/ */
ol.renderer.Layer.prototype.manageTilePyramid = function( ol.renderer.Layer.prototype.manageTilePyramid = function(
frameState, tileSource, tileGrid, projection, extent, currentZ, preload, frameState, tileSource, tileGrid, projection, extent, currentZ, preload,
opt_tileCallback, opt_obj) { opt_tileCallback, opt_this) {
var tileSourceKey = goog.getUid(tileSource).toString(); var tileSourceKey = goog.getUid(tileSource).toString();
if (!(tileSourceKey in frameState.wantedTiles)) { if (!(tileSourceKey in frameState.wantedTiles)) {
frameState.wantedTiles[tileSourceKey] = {}; frameState.wantedTiles[tileSourceKey] = {};
@@ -279,7 +279,7 @@ ol.renderer.Layer.prototype.manageTilePyramid = function(
} }
} }
if (goog.isDef(opt_tileCallback)) { if (goog.isDef(opt_tileCallback)) {
opt_tileCallback.call(opt_obj, tile); opt_tileCallback.call(opt_this, tile);
} }
} else { } else {
tileSource.useTile(z, x, y); tileSource.useTile(z, x, y);
@@ -76,7 +76,7 @@ ol.renderer.webgl.ImageLayer.prototype.createTexture_ = function(image) {
* @inheritDoc * @inheritDoc
*/ */
ol.renderer.webgl.ImageLayer.prototype.forEachFeatureAtPixel = ol.renderer.webgl.ImageLayer.prototype.forEachFeatureAtPixel =
function(coordinate, frameState, callback, opt_obj) { function(coordinate, frameState, callback, opt_this) {
var layer = this.getLayer(); var layer = this.getLayer();
var source = layer.getSource(); var source = layer.getSource();
goog.asserts.assertInstanceof(source, ol.source.Image); goog.asserts.assertInstanceof(source, ol.source.Image);
@@ -89,7 +89,7 @@ ol.renderer.webgl.ImageLayer.prototype.forEachFeatureAtPixel =
* @return {?} Callback result. * @return {?} Callback result.
*/ */
function(feature) { function(feature) {
return callback.call(opt_obj, feature, this); return callback.call(opt_this, feature, this);
}); });
}; };
+9 -9
View File
@@ -140,30 +140,30 @@ ol.source.Vector.prototype.clear = function() {
/** /**
* @param {function(this: T, ol.Feature): S} f Callback. * @param {function(this: T, ol.Feature): S} f Callback.
* @param {T=} opt_obj The object to be used as the value of 'this' within f. * @param {T=} opt_this The object to use as `this` in `f`.
* @return {S|undefined} * @return {S|undefined}
* @template T,S * @template T,S
*/ */
ol.source.Vector.prototype.forEachFeature = function(f, opt_obj) { ol.source.Vector.prototype.forEachFeature = function(f, opt_this) {
return this.rBush_.forEach(f, opt_obj); return this.rBush_.forEach(f, opt_this);
}; };
/** /**
* @param {ol.Coordinate} coordinate Coordinate. * @param {ol.Coordinate} coordinate Coordinate.
* @param {function(this: T, ol.Feature): S} f Callback. * @param {function(this: T, ol.Feature): S} f Callback.
* @param {T=} opt_obj The object to be used as the value of 'this' within f. * @param {T=} opt_this The object to use as `this` in `f`.
* @return {S|undefined} * @return {S|undefined}
* @template T,S * @template T,S
*/ */
ol.source.Vector.prototype.forEachFeatureAtCoordinate = ol.source.Vector.prototype.forEachFeatureAtCoordinate =
function(coordinate, f, opt_obj) { function(coordinate, f, opt_this) {
var extent = [coordinate[0], coordinate[1], coordinate[0], coordinate[1]]; var extent = [coordinate[0], coordinate[1], coordinate[0], coordinate[1]];
return this.forEachFeatureInExtent(extent, function(feature) { return this.forEachFeatureInExtent(extent, function(feature) {
var geometry = feature.getGeometry(); var geometry = feature.getGeometry();
goog.asserts.assert(!goog.isNull(geometry)); goog.asserts.assert(!goog.isNull(geometry));
if (geometry.containsCoordinate(coordinate)) { if (geometry.containsCoordinate(coordinate)) {
return f.call(opt_obj, feature); return f.call(opt_this, feature);
} else { } else {
return undefined; return undefined;
} }
@@ -174,13 +174,13 @@ ol.source.Vector.prototype.forEachFeatureAtCoordinate =
/** /**
* @param {ol.Extent} extent Extent. * @param {ol.Extent} extent Extent.
* @param {function(this: T, ol.Feature): S} f Callback. * @param {function(this: T, ol.Feature): S} f Callback.
* @param {T=} opt_obj The object to be used as the value of 'this' within f. * @param {T=} opt_this The object to use as `this` in `f`.
* @return {S|undefined} * @return {S|undefined}
* @template T,S * @template T,S
*/ */
ol.source.Vector.prototype.forEachFeatureInExtent = ol.source.Vector.prototype.forEachFeatureInExtent =
function(extent, f, opt_obj) { function(extent, f, opt_this) {
return this.rBush_.forEachInExtent(extent, f, opt_obj); return this.rBush_.forEachInExtent(extent, f, opt_this);
}; };
+3 -3
View File
@@ -126,12 +126,12 @@ ol.structs.Buffer.prototype.addDirtySet = function(dirtySet) {
/** /**
* @param {function(this: T, number, number)} f Callback. * @param {function(this: T, number, number)} f Callback.
* @param {T=} opt_obj The object to be used as the value of 'this' within f. * @param {T=} opt_this The object to use as `this` in `f`.
* @template T * @template T
*/ */
ol.structs.Buffer.prototype.forEachRange = function(f, opt_obj) { ol.structs.Buffer.prototype.forEachRange = function(f, opt_this) {
if (this.arr_.length !== 0) { if (this.arr_.length !== 0) {
this.freeSet_.forEachRangeInverted(0, this.arr_.length, f, opt_obj); this.freeSet_.forEachRangeInverted(0, this.arr_.length, f, opt_this);
} }
}; };
+9 -9
View File
@@ -126,15 +126,15 @@ ol.structs.IntegerSet.prototype.findRange = function(minSize) {
/** /**
* Calls f with each integer range. * Calls f with each integer range.
* @param {function(this: T, number, number)} f Callback. * @param {function(this: T, number, number)} f Callback.
* @param {T=} opt_obj The object to be used as the value of 'this' within f. * @param {T=} opt_this The object to use as `this` in `f`.
* @template T * @template T
*/ */
ol.structs.IntegerSet.prototype.forEachRange = function(f, opt_obj) { ol.structs.IntegerSet.prototype.forEachRange = function(f, opt_this) {
var arr = this.arr_; var arr = this.arr_;
var n = arr.length; var n = arr.length;
var i; var i;
for (i = 0; i < n; i += 2) { for (i = 0; i < n; i += 2) {
f.call(opt_obj, arr[i], arr[i + 1]); f.call(opt_this, arr[i], arr[i + 1]);
} }
}; };
@@ -144,26 +144,26 @@ ol.structs.IntegerSet.prototype.forEachRange = function(f, opt_obj) {
* @param {number} start Start. * @param {number} start Start.
* @param {number} stop Stop. * @param {number} stop Stop.
* @param {function(this: T, number, number)} f Callback. * @param {function(this: T, number, number)} f Callback.
* @param {T=} opt_obj The object to be used as the value of 'this' within f. * @param {T=} opt_this The object to use as `this` in `f`.
* @template T * @template T
*/ */
ol.structs.IntegerSet.prototype.forEachRangeInverted = ol.structs.IntegerSet.prototype.forEachRangeInverted =
function(start, stop, f, opt_obj) { function(start, stop, f, opt_this) {
goog.asserts.assert(start < stop); goog.asserts.assert(start < stop);
var arr = this.arr_; var arr = this.arr_;
var n = arr.length; var n = arr.length;
if (n === 0) { if (n === 0) {
f.call(opt_obj, start, stop); f.call(opt_this, start, stop);
} else { } else {
if (start < arr[0]) { if (start < arr[0]) {
f.call(opt_obj, start, arr[0]); f.call(opt_this, start, arr[0]);
} }
var i; var i;
for (i = 1; i < n - 1; i += 2) { for (i = 1; i < n - 1; i += 2) {
f.call(opt_obj, arr[i], arr[i + 1]); f.call(opt_this, arr[i], arr[i + 1]);
} }
if (arr[n - 1] < stop) { if (arr[n - 1] < stop) {
f.call(opt_obj, arr[n - 1], stop); f.call(opt_this, arr[n - 1], stop);
} }
} }
}; };
+3 -3
View File
@@ -102,13 +102,13 @@ ol.structs.LRUCache.prototype.containsKey = function(key) {
* to call for every entry from the oldest to the newer. This function takes * to call for every entry from the oldest to the newer. This function takes
* 3 arguments (the entry value, the entry key and the LRUCache object). * 3 arguments (the entry value, the entry key and the LRUCache object).
* The return value is ignored. * The return value is ignored.
* @param {S=} opt_obj The object to be used as the value of 'this' within f. * @param {S=} opt_this The object to use as `this` in `f`.
* @template S * @template S
*/ */
ol.structs.LRUCache.prototype.forEach = function(f, opt_obj) { ol.structs.LRUCache.prototype.forEach = function(f, opt_this) {
var entry = this.oldest_; var entry = this.oldest_;
while (!goog.isNull(entry)) { while (!goog.isNull(entry)) {
f.call(opt_obj, entry.value_, entry.key_, this); f.call(opt_this, entry.value_, entry.key_, this);
entry = entry.newer; entry = entry.newer;
} }
}; };
+18 -18
View File
@@ -361,20 +361,20 @@ ol.structs.RBush.prototype.condense_ = function(path) {
* Calls a callback function with each node in the tree. Inside the callback, * Calls a callback function with each node in the tree. Inside the callback,
* no tree modifications (insert, update, remove) can be made. * no tree modifications (insert, update, remove) can be made.
* @param {function(this: S, T): *} callback Callback. * @param {function(this: S, T): *} callback Callback.
* @param {S=} opt_obj Scope. * @param {S=} opt_this The object to use as `this` in `callback`.
* @return {*} Callback return value. * @return {*} Callback return value.
* @template S * @template S
*/ */
ol.structs.RBush.prototype.forEach = function(callback, opt_obj) { ol.structs.RBush.prototype.forEach = function(callback, opt_this) {
if (goog.DEBUG) { if (goog.DEBUG) {
++this.readers_; ++this.readers_;
try { try {
return this.forEach_(this.root_, callback, opt_obj); return this.forEach_(this.root_, callback, opt_this);
} finally { } finally {
--this.readers_; --this.readers_;
} }
} else { } else {
return this.forEach_(this.root_, callback, opt_obj); return this.forEach_(this.root_, callback, opt_this);
} }
}; };
@@ -382,12 +382,12 @@ ol.structs.RBush.prototype.forEach = function(callback, opt_obj) {
/** /**
* @param {ol.structs.RBushNode.<T>} node Node. * @param {ol.structs.RBushNode.<T>} node Node.
* @param {function(this: S, T): *} callback Callback. * @param {function(this: S, T): *} callback Callback.
* @param {S=} opt_obj Scope. * @param {S=} opt_this The object to use as `this` in `callback`.
* @private * @private
* @return {*} Callback return value. * @return {*} Callback return value.
* @template S * @template S
*/ */
ol.structs.RBush.prototype.forEach_ = function(node, callback, opt_obj) { ol.structs.RBush.prototype.forEach_ = function(node, callback, opt_this) {
goog.asserts.assert(!node.isLeaf()); goog.asserts.assert(!node.isLeaf());
/** @type {Array.<ol.structs.RBushNode.<T>>} */ /** @type {Array.<ol.structs.RBushNode.<T>>} */
var toVisit = [node]; var toVisit = [node];
@@ -397,7 +397,7 @@ ol.structs.RBush.prototype.forEach_ = function(node, callback, opt_obj) {
children = node.children; children = node.children;
if (node.height == 1) { if (node.height == 1) {
for (i = 0, ii = children.length; i < ii; ++i) { for (i = 0, ii = children.length; i < ii; ++i) {
result = callback.call(opt_obj, children[i].value); result = callback.call(opt_this, children[i].value);
if (result) { if (result) {
return result; return result;
} }
@@ -414,21 +414,21 @@ ol.structs.RBush.prototype.forEach_ = function(node, callback, opt_obj) {
* callback, no tree modifications (insert, update, remove) can be made. * callback, no tree modifications (insert, update, remove) can be made.
* @param {ol.Extent} extent Extent. * @param {ol.Extent} extent Extent.
* @param {function(this: S, T): *} callback Callback. * @param {function(this: S, T): *} callback Callback.
* @param {S=} opt_obj Scope. * @param {S=} opt_this The object to use as `this` in `callback`.
* @return {*} Callback return value. * @return {*} Callback return value.
* @template S * @template S
*/ */
ol.structs.RBush.prototype.forEachInExtent = ol.structs.RBush.prototype.forEachInExtent =
function(extent, callback, opt_obj) { function(extent, callback, opt_this) {
if (goog.DEBUG) { if (goog.DEBUG) {
++this.readers_; ++this.readers_;
try { try {
return this.forEachInExtent_(extent, callback, opt_obj); return this.forEachInExtent_(extent, callback, opt_this);
} finally { } finally {
--this.readers_; --this.readers_;
} }
} else { } else {
return this.forEachInExtent_(extent, callback, opt_obj); return this.forEachInExtent_(extent, callback, opt_this);
} }
}; };
@@ -436,13 +436,13 @@ ol.structs.RBush.prototype.forEachInExtent =
/** /**
* @param {ol.Extent} extent Extent. * @param {ol.Extent} extent Extent.
* @param {function(this: S, T): *} callback Callback. * @param {function(this: S, T): *} callback Callback.
* @param {S=} opt_obj Scope. * @param {S=} opt_this The object to use as `this` in `callback`.
* @private * @private
* @return {*} Callback return value. * @return {*} Callback return value.
* @template S * @template S
*/ */
ol.structs.RBush.prototype.forEachInExtent_ = ol.structs.RBush.prototype.forEachInExtent_ =
function(extent, callback, opt_obj) { function(extent, callback, opt_this) {
/** @type {Array.<ol.structs.RBushNode.<T>>} */ /** @type {Array.<ol.structs.RBushNode.<T>>} */
var toVisit = [this.root_]; var toVisit = [this.root_];
var result; var result;
@@ -450,12 +450,12 @@ ol.structs.RBush.prototype.forEachInExtent_ =
var node = toVisit.pop(); var node = toVisit.pop();
if (ol.extent.intersects(extent, node.extent)) { if (ol.extent.intersects(extent, node.extent)) {
if (node.isLeaf()) { if (node.isLeaf()) {
result = callback.call(opt_obj, node.value); result = callback.call(opt_this, node.value);
if (result) { if (result) {
return result; return result;
} }
} else if (ol.extent.containsExtent(extent, node.extent)) { } else if (ol.extent.containsExtent(extent, node.extent)) {
result = this.forEach_(node, callback, opt_obj); result = this.forEach_(node, callback, opt_this);
if (result) { if (result) {
return result; return result;
} }
@@ -470,16 +470,16 @@ ol.structs.RBush.prototype.forEachInExtent_ =
/** /**
* @param {function(this: S, ol.structs.RBushNode.<T>): *} callback Callback. * @param {function(this: S, ol.structs.RBushNode.<T>): *} callback Callback.
* @param {S=} opt_obj Scope. * @param {S=} opt_this The object to use as `this` in `callback`.
* @return {*} Callback return value. * @return {*} Callback return value.
* @template S * @template S
*/ */
ol.structs.RBush.prototype.forEachNode = function(callback, opt_obj) { ol.structs.RBush.prototype.forEachNode = function(callback, opt_this) {
/** @type {Array.<ol.structs.RBushNode.<T>>} */ /** @type {Array.<ol.structs.RBushNode.<T>>} */
var toVisit = [this.root_]; var toVisit = [this.root_];
while (toVisit.length > 0) { while (toVisit.length > 0) {
var node = toVisit.pop(); var node = toVisit.pop();
var result = callback.call(opt_obj, node); var result = callback.call(opt_this, node);
if (result) { if (result) {
return result; return result;
} }
+3 -3
View File
@@ -115,18 +115,18 @@ ol.tilegrid.TileGrid.prototype.createTileCoordTransform = goog.abstractMethod;
/** /**
* @param {ol.TileCoord} tileCoord Tile coordinate. * @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {function(this: T, number, ol.TileRange): boolean} callback Callback. * @param {function(this: T, number, ol.TileRange): boolean} callback Callback.
* @param {T=} opt_obj Object. * @param {T=} opt_this The object to use as `this` in `callback`.
* @param {ol.TileRange=} opt_tileRange Temporary ol.TileRange object. * @param {ol.TileRange=} opt_tileRange Temporary ol.TileRange object.
* @param {ol.Extent=} opt_extent Temporary ol.Extent object. * @param {ol.Extent=} opt_extent Temporary ol.Extent object.
* @return {boolean} Callback succeeded. * @return {boolean} Callback succeeded.
* @template T * @template T
*/ */
ol.tilegrid.TileGrid.prototype.forEachTileCoordParentTileRange = ol.tilegrid.TileGrid.prototype.forEachTileCoordParentTileRange =
function(tileCoord, callback, opt_obj, opt_tileRange, opt_extent) { function(tileCoord, callback, opt_this, opt_tileRange, opt_extent) {
var tileCoordExtent = this.getTileCoordExtent(tileCoord, opt_extent); var tileCoordExtent = this.getTileCoordExtent(tileCoord, opt_extent);
var z = tileCoord.z - 1; var z = tileCoord.z - 1;
while (z >= this.minZoom) { while (z >= this.minZoom) {
if (callback.call(opt_obj, z, if (callback.call(opt_this, z,
this.getTileRangeForExtentAndZ(tileCoordExtent, z, opt_tileRange))) { this.getTileRangeForExtentAndZ(tileCoordExtent, z, opt_tileRange))) {
return true; return true;
} }
+2 -2
View File
@@ -114,14 +114,14 @@ ol.tilegrid.XYZ.prototype.getTileCoordChildTileRange =
* @inheritDoc * @inheritDoc
*/ */
ol.tilegrid.XYZ.prototype.forEachTileCoordParentTileRange = ol.tilegrid.XYZ.prototype.forEachTileCoordParentTileRange =
function(tileCoord, callback, opt_obj, opt_tileRange) { function(tileCoord, callback, opt_this, opt_tileRange) {
var tileRange = ol.TileRange.createOrUpdate( var tileRange = ol.TileRange.createOrUpdate(
0, tileCoord.x, 0, tileCoord.y, opt_tileRange); 0, tileCoord.x, 0, tileCoord.y, opt_tileRange);
var z; var z;
for (z = tileCoord.z - 1; z >= this.minZoom; --z) { for (z = tileCoord.z - 1; z >= this.minZoom; --z) {
tileRange.minX = tileRange.maxX >>= 1; tileRange.minX = tileRange.maxX >>= 1;
tileRange.minY = tileRange.maxY >>= 1; tileRange.minY = tileRange.maxY >>= 1;
if (callback.call(opt_obj, z, tileRange)) { if (callback.call(opt_this, z, tileRange)) {
return true; return true;
} }
} }
+19 -18
View File
@@ -51,18 +51,18 @@ ol.xml.getAllTextContent_ = function(node, normalizeWhitespace, accumulator) {
/** /**
* @param {function(this: T, Node, Array.<*>): (Array.<*>|undefined)} * @param {function(this: T, Node, Array.<*>): (Array.<*>|undefined)}
* valueReader Value reader. * valueReader Value reader.
* @param {T=} opt_obj Scope. * @param {T=} opt_this The object to use as `this` in `valueReader`.
* @return {ol.xml.Parser} Parser. * @return {ol.xml.Parser} Parser.
* @template T * @template T
*/ */
ol.xml.makeArrayExtender = function(valueReader, opt_obj) { ol.xml.makeArrayExtender = function(valueReader, opt_this) {
return ( return (
/** /**
* @param {Node} node Node. * @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack. * @param {Array.<*>} objectStack Object stack.
*/ */
function(node, objectStack) { function(node, objectStack) {
var value = valueReader.call(opt_obj, node, objectStack); var value = valueReader.call(opt_this, node, objectStack);
if (goog.isDef(value)) { if (goog.isDef(value)) {
goog.asserts.assert(goog.isArray(value)); goog.asserts.assert(goog.isArray(value));
var array = /** @type {Array.<*>} */ var array = /** @type {Array.<*>} */
@@ -76,18 +76,18 @@ ol.xml.makeArrayExtender = function(valueReader, opt_obj) {
/** /**
* @param {function(this: T, Node, Array.<*>): *} valueReader Value reader. * @param {function(this: T, Node, Array.<*>): *} valueReader Value reader.
* @param {T=} opt_obj Scope. * @param {T=} opt_this The object to use as `this` in `valueReader`.
* @return {ol.xml.Parser} Parser. * @return {ol.xml.Parser} Parser.
* @template T * @template T
*/ */
ol.xml.makeArrayPusher = function(valueReader, opt_obj) { ol.xml.makeArrayPusher = function(valueReader, opt_this) {
return ( return (
/** /**
* @param {Node} node Node. * @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack. * @param {Array.<*>} objectStack Object stack.
*/ */
function(node, objectStack) { function(node, objectStack) {
var value = valueReader.call(opt_obj, node, objectStack); var value = valueReader.call(opt_this, node, objectStack);
if (goog.isDef(value)) { if (goog.isDef(value)) {
var array = objectStack[objectStack.length - 1]; var array = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isArray(array)); goog.asserts.assert(goog.isArray(array));
@@ -99,18 +99,18 @@ ol.xml.makeArrayPusher = function(valueReader, opt_obj) {
/** /**
* @param {function(this: T, Node, Array.<*>): *} valueReader Value reader. * @param {function(this: T, Node, Array.<*>): *} valueReader Value reader.
* @param {T=} opt_obj Scope. * @param {T=} opt_this The object to use as `this` in `valueReader`.
* @return {ol.xml.Parser} Parser. * @return {ol.xml.Parser} Parser.
* @template T * @template T
*/ */
ol.xml.makeReplacer = function(valueReader, opt_obj) { ol.xml.makeReplacer = function(valueReader, opt_this) {
return ( return (
/** /**
* @param {Node} node Node. * @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack. * @param {Array.<*>} objectStack Object stack.
*/ */
function(node, objectStack) { function(node, objectStack) {
var value = valueReader.call(opt_obj, node, objectStack); var value = valueReader.call(opt_this, node, objectStack);
if (goog.isDef(value)) { if (goog.isDef(value)) {
objectStack[objectStack.length - 1] = value; objectStack[objectStack.length - 1] = value;
} }
@@ -121,11 +121,12 @@ ol.xml.makeReplacer = function(valueReader, opt_obj) {
/** /**
* @param {function(this: T, Node, Array.<*>): *} valueReader Value reader. * @param {function(this: T, Node, Array.<*>): *} valueReader Value reader.
* @param {string=} opt_property Property. * @param {string=} opt_property Property.
* @param {T=} opt_obj Scope. * @param {T=} opt_this The object to use as `this` in `valueReader`.
* @return {ol.xml.Parser} Parser. * @return {ol.xml.Parser} Parser.
* @template T * @template T
*/ */
ol.xml.makeObjectPropertySetter = function(valueReader, opt_property, opt_obj) { ol.xml.makeObjectPropertySetter =
function(valueReader, opt_property, opt_this) {
goog.asserts.assert(goog.isDef(valueReader)); goog.asserts.assert(goog.isDef(valueReader));
return ( return (
/** /**
@@ -133,7 +134,7 @@ ol.xml.makeObjectPropertySetter = function(valueReader, opt_property, opt_obj) {
* @param {Array.<*>} objectStack Object stack. * @param {Array.<*>} objectStack Object stack.
*/ */
function(node, objectStack) { function(node, objectStack) {
var value = valueReader.call(opt_obj, node, objectStack); var value = valueReader.call(opt_this, node, objectStack);
if (goog.isDef(value)) { if (goog.isDef(value)) {
var object = /** @type {Object} */ var object = /** @type {Object} */
(objectStack[objectStack.length - 1]); (objectStack[objectStack.length - 1]);
@@ -169,16 +170,16 @@ ol.xml.makeParsersNS = function(namespaceURIs, parsers, opt_parsersNS) {
* Parsers by namespace. * Parsers by namespace.
* @param {Node} node Node. * @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack. * @param {Array.<*>} objectStack Object stack.
* @param {*=} opt_obj Scope. * @param {*=} opt_this The object to use as `this`.
*/ */
ol.xml.parse = function(parsersNS, node, objectStack, opt_obj) { ol.xml.parse = function(parsersNS, node, objectStack, opt_this) {
var n; var n;
for (n = node.firstElementChild; !goog.isNull(n); n = n.nextElementSibling) { for (n = node.firstElementChild; !goog.isNull(n); n = n.nextElementSibling) {
var parsers = parsersNS[n.namespaceURI]; var parsers = parsersNS[n.namespaceURI];
if (goog.isDef(parsers)) { if (goog.isDef(parsers)) {
var parser = parsers[n.localName]; var parser = parsers[n.localName];
if (goog.isDef(parser)) { if (goog.isDef(parser)) {
parser.call(opt_obj, n, objectStack); parser.call(opt_this, n, objectStack);
} }
} }
} }
@@ -191,12 +192,12 @@ ol.xml.parse = function(parsersNS, node, objectStack, opt_obj) {
* Parsers by namespace. * Parsers by namespace.
* @param {Node} node Node. * @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack. * @param {Array.<*>} objectStack Object stack.
* @param {*=} opt_obj Scope. * @param {*=} opt_this The object to use as `this`.
* @return {T|undefined} Object. * @return {T|undefined} Object.
* @template T * @template T
*/ */
ol.xml.pushAndParse = function(object, parsersNS, node, objectStack, opt_obj) { ol.xml.pushAndParse = function(object, parsersNS, node, objectStack, opt_this) {
objectStack.push(object); objectStack.push(object);
ol.xml.parse(parsersNS, node, objectStack, opt_obj); ol.xml.parse(parsersNS, node, objectStack, opt_this);
return objectStack.pop(); return objectStack.pop();
}; };