Make Matrix#orNullIfIdentity() private too, and fix error introduced by previous commit.

This commit is contained in:
Jürg Lehni 2016-01-17 19:34:54 +01:00
parent d292e08ed2
commit 40551fcacf
4 changed files with 9 additions and 9 deletions

View file

@ -486,6 +486,10 @@ var Matrix = Base.extend(/** @lends Matrix# */{
return new Matrix(this._a, this._c, this._b, this._d, 0, 0);
},
_orNullIfIdentity: function() {
return this.isIdentity() ? null : this;
},
/**
* @return {Boolean} whether this transform is the identity transform
*/
@ -494,10 +498,6 @@ var Matrix = Base.extend(/** @lends Matrix# */{
&& this._tx === 0 && this._ty === 0;
},
orNullIfIdentity: function() {
return this.isIdentity() ? null : this;
},
/**
* Returns whether the transform is invertible. A transform is not
* invertible if the determinant is 0 or any value is non-finite or NaN.

View file

@ -879,9 +879,9 @@ var Item = Base.extend(Emitter, /** @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).
matrix = matrix && matrix.orNullIfIdentity();
matrix = matrix && matrix._orNullIfIdentity();
// Do not transform by the internal matrix if there is a internalGetter.
var _matrix = internalGetter ? null : this._matrix.orNullIfIdentity(),
var _matrix = internalGetter ? null : this._matrix._orNullIfIdentity(),
cache = (!matrix || matrix.equals(_matrix)) && getter;
// NOTE: This needs to happen before returning cached values, since even
// then, _boundsCache needs to be kept up-to-date.

View file

@ -2770,7 +2770,7 @@ statics: {
return Path.getBounds(segments, closed, style, matrix);
var length = segments.length - (closed ? 0 : 1),
radius = style.getStrokeWidth() / 2,
padding = Path._getPenPadding(radius, matrix),
padding = Path._getStrokePadding(radius, matrix),
bounds = Path.getBounds(segments, closed, style, matrix, padding),
join = style.getStrokeJoin(),
cap = style.getStrokeCap(),

View file

@ -69,9 +69,9 @@ var PathItem = Item.extend(/** @lends PathItem# */{
// NOTE: The hidden argument _matrix is used internally to override the
// passed path's transformation matrix.
var self = this === path || !path, // self-intersections?
matrix1 = this._matrix.orNullIfIdentity(),
matrix1 = this._matrix._orNullIfIdentity(),
matrix2 = self ? matrix1
: (_matrix || path._matrix).orNullIfIdentity();
: (_matrix || path._matrix)._orNullIfIdentity();
// First check the bounds of the two paths. If they don't intersect,
// we don't need to iterate through their curves.
if (!self && !this.getBounds(matrix1).touches(path.getBounds(matrix2)))