From b51cf064b0c65b7c7606e5e473fdd6a15d6fa62e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sat, 26 Nov 2011 11:55:19 +0100 Subject: [PATCH] Make baseItem to last optional parameter of _getBounds. --- src/item/Item.js | 12 ++++++------ src/item/PlacedSymbol.js | 4 ++-- src/item/Raster.js | 2 +- src/path/Path.js | 2 +- src/text/PointText.js | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/item/Item.js b/src/item/Item.js index 2f564579..7f528353 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -1258,7 +1258,7 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{ * matrix concatenation and handles all the complicated caching mechanisms. * Note: Needs to be called on an item using getBounds.call(item, ...). */ - function getBounds(baseItem, type, matrix) { + function getBounds(type, matrix, baseItem) { // If the result of concatinating the passed matrix with our internal // one is an identity transformation, set it to null for faster // processing @@ -1270,10 +1270,10 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{ // bounds on items without children, as we do not receive hierarchy // change notifiers from children, and walking up the parents and // merging cache bounds is not expensive. - var cache = !this._children && !matrix && type; + var cache = !matrix && type; if (cache && this._bounds && this._bounds[cache]) return this._bounds[cache]; - var bounds = this._getBounds(baseItem, type, matrix); + var bounds = this._getBounds(type, matrix, baseItem); // If we're returning 'bounds', create a LinkedRectangle that uses // the setBounds() setter to update the Item whenever the bounds are // changed: @@ -1297,7 +1297,7 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{ // overridden by subclasses, see below. this['get' + Base.capitalize(name)] = function(/* matrix */) { var type = this._boundsType; - return getBounds.call(this, this, + return getBounds.call(this, // Allow subclasses to override _boundsType if they use the // same calculations for multiple types. // The default is name: @@ -1314,7 +1314,7 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{ * them. Subclasses override it to define calculations for the various * required bounding types. */ - _getBounds: function(baseItem, type, matrix) { + _getBounds: function(type, matrix, baseItem) { // Note: We cannot cache these results here, since we do not get // _changed() notifications here for changing geometry in children. // But cacheName is used in sub-classes such as PlacedItem. @@ -1330,7 +1330,7 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{ for (var i = 0, l = children.length; i < l; i++) { var child = children[i]; if (child._visible) { - var rect = getBounds.call(child, baseItem, type, matrix); + var rect = getBounds.call(child, type, matrix, baseItem); x1 = Math.min(rect.x, x1); y1 = Math.min(rect.y, y1); x2 = Math.max(rect.x + rect.width, x2); diff --git a/src/item/PlacedSymbol.js b/src/item/PlacedSymbol.js index 5a57ea37..aa99fb33 100644 --- a/src/item/PlacedSymbol.js +++ b/src/item/PlacedSymbol.js @@ -94,9 +94,9 @@ var PlacedSymbol = this.PlacedSymbol = PlacedItem.extend(/** @lends PlacedSymbol return this._clone(new PlacedSymbol(this.symbol, this._matrix.clone())); }, - _getBounds: function(baseItem, type, matrix) { + _getBounds: function(type, matrix) { // Redirect the call to the symbol definition to calculate the bounds - return this.symbol._definition._getBounds(baseItem, type, matrix); + return this.symbol._definition._getBounds(type, matrix); }, draw: function(ctx, param) { diff --git a/src/item/Raster.js b/src/item/Raster.js index 70aed79a..67e08043 100644 --- a/src/item/Raster.js +++ b/src/item/Raster.js @@ -382,7 +382,7 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{ this.getContext(true).putImageData(data, point.x, point.y); }, - _getBounds: function(baseItem, type, matrix) { + _getBounds: function(type, matrix) { var rect = new Rectangle(this._size).setCenter(0, 0); return matrix ? matrix._transformBounds(rect) : rect; }, diff --git a/src/path/Path.js b/src/path/Path.js index 3ef96564..24ae3ca7 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -2060,7 +2060,7 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{ }; return { - _getBounds: function(baseItem, type, matrix) { + _getBounds: function(type, matrix) { return get[type].call(this, matrix); } }; diff --git a/src/text/PointText.js b/src/text/PointText.js index 6e14e0a5..3e50ba02 100644 --- a/src/text/PointText.js +++ b/src/text/PointText.js @@ -98,7 +98,7 @@ var PointText = this.PointText = TextItem.extend(/** @lends PointText# */{ var context = null; return { - _getBounds: function(baseItem, type, matrix) { + _getBounds: function(type, matrix) { // Create an in-memory canvas on which to do the measuring if (!context) context = CanvasProvider.getCanvas(