Make baseItem to last optional parameter of _getBounds.

This commit is contained in:
Jürg Lehni 2011-11-26 11:55:19 +01:00
parent f799c85e76
commit b51cf064b0
5 changed files with 11 additions and 11 deletions

View file

@ -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);

View file

@ -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) {

View file

@ -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;
},

View file

@ -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);
}
};

View file

@ -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(