removed array reference for _dimensionsAffectingProps (#4465)

* removed array reference

* better to concat

* better visibility
This commit is contained in:
Andrea Bogazzi 2017-11-17 19:45:48 +01:00 committed by GitHub
parent 10a8684192
commit c975247db8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 41 additions and 80 deletions

View file

@ -11,11 +11,6 @@
return;
}
var cacheProperties = fabric.Object.prototype.cacheProperties.concat();
cacheProperties.push(
'radius'
);
/**
* Circle class
* @class fabric.Circle
@ -52,7 +47,7 @@
*/
endAngle: pi * 2,
cacheProperties: cacheProperties,
cacheProperties: fabric.Object.prototype.cacheProperties.concat('radius'),
/**
* Constructor

View file

@ -11,12 +11,6 @@
return;
}
var cacheProperties = fabric.Object.prototype.cacheProperties.concat();
cacheProperties.push(
'rx',
'ry'
);
/**
* Ellipse class
* @class fabric.Ellipse
@ -47,7 +41,7 @@
*/
ry: 0,
cacheProperties: cacheProperties,
cacheProperties: fabric.Object.prototype.cacheProperties.concat('rx', 'ry'),
/**
* Constructor

View file

@ -13,14 +13,6 @@
return;
}
var cacheProperties = fabric.Object.prototype.cacheProperties.concat();
cacheProperties.push(
'x1',
'x2',
'y1',
'y2'
);
/**
* Line class
* @class fabric.Line
@ -64,7 +56,7 @@
*/
y2: 0,
cacheProperties: cacheProperties,
cacheProperties: fabric.Object.prototype.cacheProperties.concat('x1', 'x2', 'y1', 'y2'),
/**
* Constructor

View file

@ -29,12 +29,6 @@
return;
}
var stateProperties = fabric.Object.prototype.stateProperties.concat();
stateProperties.push('path');
var cacheProperties = fabric.Object.prototype.cacheProperties.concat();
cacheProperties.push('path', 'fillRule');
/**
* Path class
* @class fabric.Path
@ -58,9 +52,9 @@
*/
path: null,
cacheProperties: cacheProperties,
cacheProperties: fabric.Object.prototype.cacheProperties.concat('path', 'fillRule'),
stateProperties: stateProperties,
stateProperties: fabric.Object.prototype.stateProperties.concat('path'),
/**
* Constructor

View file

@ -14,9 +14,6 @@
return;
}
var cacheProperties = fabric.Object.prototype.cacheProperties.concat();
cacheProperties.push('points');
/**
* Polyline class
* @class fabric.Polyline
@ -39,7 +36,7 @@
*/
points: null,
cacheProperties: cacheProperties,
cacheProperties: fabric.Object.prototype.cacheProperties.concat('points'),
/**
* Constructor

View file

@ -10,12 +10,6 @@
return;
}
var stateProperties = fabric.Object.prototype.stateProperties.concat();
stateProperties.push('rx', 'ry');
var cacheProperties = fabric.Object.prototype.cacheProperties.concat();
cacheProperties.push('rx', 'ry');
/**
* Rectangle class
* @class fabric.Rect
@ -30,7 +24,7 @@
* as well as for history (undo/redo) purposes
* @type Array
*/
stateProperties: stateProperties,
stateProperties: fabric.Object.prototype.stateProperties.concat('rx', 'ry'),
/**
* Type of an object
@ -53,7 +47,7 @@
*/
ry: 0,
cacheProperties: cacheProperties,
cacheProperties: fabric.Object.prototype.cacheProperties.concat('rx', 'ry'),
/**
* Constructor

View file

@ -12,39 +12,6 @@
return;
}
var stateProperties = fabric.Object.prototype.stateProperties.concat();
stateProperties.push(
'fontFamily',
'fontWeight',
'fontSize',
'text',
'underline',
'overline',
'linethrough',
'textAlign',
'fontStyle',
'lineHeight',
'textBackgroundColor',
'charSpacing',
'styles'
);
var cacheProperties = fabric.Object.prototype.cacheProperties.concat();
cacheProperties.push(
'fontFamily',
'fontWeight',
'fontSize',
'text',
'underline',
'overline',
'linethrough',
'textAlign',
'fontStyle',
'lineHeight',
'textBackgroundColor',
'charSpacing',
'styles'
);
/**
* Text class
* @class fabric.Text
@ -182,13 +149,37 @@
* as well as for history (undo/redo) purposes
* @type Array
*/
stateProperties: stateProperties,
stateProperties: fabric.Object.prototype.stateProperties.concat('fontFamily',
'fontWeight',
'fontSize',
'text',
'underline',
'overline',
'linethrough',
'textAlign',
'fontStyle',
'lineHeight',
'textBackgroundColor',
'charSpacing',
'styles'),
/**
* List of properties to consider when checking if cache needs refresh
* @type Array
*/
cacheProperties: cacheProperties,
cacheProperties: fabric.Object.prototype.cacheProperties.concat('fontFamily',
'fontWeight',
'fontSize',
'text',
'underline',
'overline',
'linethrough',
'textAlign',
'fontStyle',
'lineHeight',
'textBackgroundColor',
'charSpacing',
'styles'),
/**
* When defined, an object is rendered via stroke and this property specifies its color.

View file

@ -57,6 +57,13 @@
*/
noScaleCache: false,
/**
* Properties which when set cause object to change dimensions
* @type Object
* @private
*/
_dimensionAffectingProps: fabric.Text.prototype._dimensionAffectingProps.concat('width'),
/**
* Constructor. Some scaling related property values are forced. Visibility
* of controls is also fixed; only the rotation and width controls are
@ -66,11 +73,8 @@
* @return {fabric.Textbox} thisArg
*/
initialize: function(text, options) {
this.callSuper('initialize', text, options);
this.ctx = this.objectCaching ? this._cacheContext : fabric.util.createCanvasElement().getContext('2d');
// add width to this list of props that effect line wrapping.
this._dimensionAffectingProps.push('width');
},
/**