Check if fonts are available and redraw when label cache was cleared

This commit is contained in:
Andreas Hocevar
2017-10-20 00:02:20 +02:00
parent dea8a340a6
commit 7f865b8520
10 changed files with 376 additions and 21 deletions

View File

@@ -1,6 +1,9 @@
goog.provide('ol.structs.LRUCache');
goog.require('ol');
goog.require('ol.asserts');
goog.require('ol.events.EventTarget');
goog.require('ol.events.EventType');
/**
@@ -8,12 +11,16 @@ goog.require('ol.asserts');
* Object's properties (e.g. 'hasOwnProperty' is not allowed as a key). Expiring
* items from the cache is the responsibility of the user.
* @constructor
* @extends {ol.events.EventTarget}
* @fires ol.events.Event
* @struct
* @template T
* @param {number=} opt_highWaterMark High water mark.
*/
ol.structs.LRUCache = function(opt_highWaterMark) {
ol.events.EventTarget.call(this);
/**
* @type {number}
*/
@@ -45,6 +52,8 @@ ol.structs.LRUCache = function(opt_highWaterMark) {
};
ol.inherits(ol.structs.LRUCache, ol.events.EventTarget);
/**
* @return {boolean} Can expire cache.
@@ -62,6 +71,7 @@ ol.structs.LRUCache.prototype.clear = function() {
this.entries_ = {};
this.oldest_ = null;
this.newest_ = null;
this.dispatchEvent(ol.events.EventType.CLEAR);
};
@@ -255,3 +265,15 @@ ol.structs.LRUCache.prototype.set = function(key, value) {
this.entries_[key] = entry;
++this.count_;
};
/**
* @param {string} key Key.
* @param {T} value Value.
*/
ol.structs.LRUCache.prototype.pruneAndSet = function(key, value) {
while (this.canExpireCache()) {
this.pop();
}
this.set(key, value);
};