Clean up _getCachedBounds() code.

This commit is contained in:
Jürg Lehni 2013-12-08 22:06:32 +01:00
parent 8cec512cc2
commit 238f577e6f

View file

@ -829,7 +829,8 @@ var Item = Base.extend(Callback, /** @lends Item# */{
// See if we can cache these bounds. We only cache the bounds
// transformed with the internally stored _matrix, (the default if no
// matrix is passed).
var cache = (!matrix || matrix.equals(this._matrix)) && getter;
var _matrix = this._matrix,
cache = (!matrix || matrix.equals(_matrix)) && getter;
// Set up a boundsCache structure that keeps track of items that keep
// cached bounds that depend on this item. We store this in our parent,
// for multiple reasons:
@ -861,10 +862,13 @@ var Item = Base.extend(Callback, /** @lends Item# */{
// If the result of concatinating the passed matrix with our internal
// one is an identity transformation, set it to null for faster
// processing
var identity = this._matrix.isIdentity();
if (_matrix.isIdentity())
_matrix = null;
matrix = !matrix || matrix.isIdentity()
? identity ? null : this._matrix
: identity ? matrix : matrix.clone().concatenate(this._matrix);
? _matrix
: _matrix
? matrix.clone().concatenate(_matrix)
: matrix;
// If we're caching bounds on this item, pass it on as cacheItem, so the
// children can setup the _boundsCache structures for it.
var bounds = this._getBounds(getter, matrix, cache ? this : cacheItem);