Various optimizations around Project#view.

This commit is contained in:
Jürg Lehni 2016-01-14 01:44:05 +01:00
parent 00a7588a3a
commit 0743f1b7b8
5 changed files with 11 additions and 5 deletions

View file

@ -155,7 +155,8 @@ var PaperScope = Base.extend(/** @lends PaperScope# */{
* @type View * @type View
*/ */
getView: function() { getView: function() {
return this.project && this.project.getView(); var project = this.project;
return project && project._view;
}, },
/** /**

View file

@ -58,5 +58,9 @@ var PaperScopeItem = Base.extend(Emitter, /** @lends PaperScopeItem# */{
this._scope[this._reference] = null; this._scope[this._reference] = null;
this._scope = null; this._scope = null;
return true; return true;
},
getView: function() {
return this._scope.getView();
} }
}); });

View file

@ -1189,7 +1189,7 @@ var Item = Base.extend(Emitter, /** @lends Item# */{
* @bean * @bean
*/ */
getView: function() { getView: function() {
return this._project.getView(); return this._project._view;
}, },
/** /**

View file

@ -302,7 +302,7 @@ var Style = Base.extend(new function() {
* @type View * @type View
*/ */
getView: function() { getView: function() {
return this._project.getView(); return this._project._view;
}, },
// Overrides // Overrides

View file

@ -132,8 +132,9 @@ var View = Base.extend(Emitter, /** @lends View# */{
View._views.splice(View._views.indexOf(this), 1); View._views.splice(View._views.indexOf(this), 1);
delete View._viewsById[this._id]; delete View._viewsById[this._id];
// Unlink from project // Unlink from project
if (this._project._view === this) var project = this._project;
this._project._view = null; if (project._view === this)
project._view = null;
/*#*/ if (__options.environment == 'browser') { /*#*/ if (__options.environment == 'browser') {
// Uninstall event handlers again for this view. // Uninstall event handlers again for this view.
DomEvent.remove(this._element, this._viewEvents); DomEvent.remove(this._element, this._viewEvents);