From 2f4f00387365bafdd9f4004c7f4d750a81830c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sun, 8 May 2011 13:38:09 +0100 Subject: [PATCH] Have Base.read() clone owned objects such as SegmentPoint or LinkedPoint. --- src/paper.js | 25 ++++++++++++++++--------- src/path/SegmentPoint.js | 12 ++++++------ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/paper.js b/src/paper.js index 79205e61..18332d96 100644 --- a/src/paper.js +++ b/src/paper.js @@ -59,8 +59,13 @@ Base.inject({ var start = start || 0, length = length || list.length - start; var obj = list[start]; - // If the class defines _readNull, return null when nothing was provided - if (obj instanceof this + // As a convention, do not return objects that are owned, e.g. + // LinkedPoint or SegmentPoint, although they are instances of Point, + // since they override properties with beans. Convert these to pure + // Points instead, further down. + if (obj && !obj._owner && obj instanceof this + // If the class defines _readNull, return null when nothing + // was provided || this.prototype._readNull && obj == null && length <= 1) return obj; obj = new this(this.dont); @@ -158,21 +163,23 @@ Base.inject({ //#include "color/Gradient.js" //#include "color/GradientStop.js" +//#ifdef BROWSER + +//#include "browser/DomElement.js" +//#include "browser/DomEvent.js" + +//#include "ui/Event.js" +//#include "ui/KeyEvent.js" +//#include "ui/Key.js" + //#include "tool/ToolEvent.js" //#include "tool/ToolHandler.js" //#include "tool/Tool.js" -//#ifdef BROWSER -//#include "browser/DomElement.js" -//#include "browser/DomEvent.js" //#endif // BROWSER //#include "util/CanvasProvider.js" //#include "util/Numerical.js" //#include "util/PaperScript.js" //#include "util/BlendMode.js" - -//#ifdef BROWSER -//#include "ui/Key.js" -//#endif // BROWSER }; diff --git a/src/path/SegmentPoint.js b/src/path/SegmentPoint.js index 17b6b5ab..3f655fc0 100644 --- a/src/path/SegmentPoint.js +++ b/src/path/SegmentPoint.js @@ -24,7 +24,7 @@ var SegmentPoint = Point.extend({ set: function(x, y) { this._x = x; this._y = y; - this._segment._changed(this); + this._owner._changed(this); return this; }, @@ -34,7 +34,7 @@ var SegmentPoint = Point.extend({ setX: function(x) { this._x = x; - this._segment._changed(this); + this._owner._changed(this); }, getY: function() { @@ -43,15 +43,15 @@ var SegmentPoint = Point.extend({ setY: function(y) { this._y = y; - this._segment._changed(this); + this._owner._changed(this); }, setSelected: function(selected) { - this._segment._setSelected(this, selected); + this._owner._setSelected(this, selected); }, isSelected: function() { - return this._segment._isSelected(this); + return this._owner._isSelected(this); }, statics: { @@ -65,7 +65,7 @@ var SegmentPoint = Point.extend({ var point = new SegmentPoint(SegmentPoint.dont); point._x = x; point._y = y; - point._segment = segment; + point._owner = segment; return point; } }