From 4ba17127aae81435979e1f8d0ef30b526a39984a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sat, 1 Mar 2014 23:24:33 +0100 Subject: [PATCH] Make sure that #transformContent can only be set to true on items that actually support it. --- src/item/Item.js | 12 ++++++------ src/item/PlacedSymbol.js | 1 + src/item/Raster.js | 1 + src/item/Shape.js | 1 + 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/item/Item.js b/src/item/Item.js index 5b181a61..5843c73c 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -54,6 +54,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{ // All items apply their matrix by default. // Exceptions are Raster, PlacedSymbol, Clip and Shape. _transformContent: true, + _canTransformContent: true, _boundsSelected: false, _selectChildren: false, // Provide information about fields to be serialized, with their defaults @@ -1173,8 +1174,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{ }, setTransformContent: function(transform) { - this._transformContent = !!transform; - if (transform) + if (this._transformContent = this._canTransformContent && !!transform) this.applyMatrix(); }, @@ -1986,8 +1986,8 @@ var Item = Base.extend(Callback, /** @lends Item# */{ // Only pass on the transformContent setting if it's different // and the child has not its onw setting already. if (item._transformContent ^ transformContent - && !item.hasOwnProperty('_transformContent')) - item.setTransformContent(transformContent) + && !item.hasOwnProperty('_transformContent')) + item.setTransformContent(transformContent); // Setting the name again makes sure all name lookup structures // are kept in sync. if (item._name) @@ -2841,9 +2841,9 @@ var Item = Base.extend(Callback, /** @lends Item# */{ // Reset the internal matrix to the identity transformation if it // was possible to apply it. matrix.reset(true); + if (!_dontNotify) + this._changed(/*#=*/ Change.GEOMETRY); } - if (!_dontNotify) - this._changed(/*#=*/ Change.GEOMETRY); return this; }, diff --git a/src/item/PlacedSymbol.js b/src/item/PlacedSymbol.js index b2c8cae0..7d8f2067 100644 --- a/src/item/PlacedSymbol.js +++ b/src/item/PlacedSymbol.js @@ -21,6 +21,7 @@ var PlacedSymbol = Item.extend(/** @lends PlacedSymbol# */{ _class: 'PlacedSymbol', _transformContent: false, + _canTransformContent: false, // PlacedSymbol uses strokeBounds for bounds _boundsGetter: { getBounds: 'getStrokeBounds' }, _boundsSelected: true, diff --git a/src/item/Raster.js b/src/item/Raster.js index ce7d89d5..4dad6a2f 100644 --- a/src/item/Raster.js +++ b/src/item/Raster.js @@ -20,6 +20,7 @@ var Raster = Item.extend(/** @lends Raster# */{ _class: 'Raster', _transformContent: false, + _canTransformContent: false, // Raster doesn't make the distinction between the different bounds, // so use the same name for all of them _boundsGetter: 'getBounds', diff --git a/src/item/Shape.js b/src/item/Shape.js index 09b74ea3..c5eb1d5e 100644 --- a/src/item/Shape.js +++ b/src/item/Shape.js @@ -20,6 +20,7 @@ var Shape = Item.extend(/** @lends Shape# */{ _class: 'Shape', _transformContent: false, + _canTransformContent: false, _boundsSelected: true, _serializeFields: { shape: null,