sc_require("views/view"); SC.View.reopen({ /** This code exists to make it possible to pool SC.Views. We are not going to pool SC.Views in Amber */ _lastLayerId: null, /** Handles changes in the layer id. */ layerIdDidChange: function() { var layer = this.get('layer'), lid = this.get('layerId'), lastId = this._lastLayerId; if (lid !== lastId) { // if we had an earlier one, remove from view hash. if (lastId && SC.View.views[lastId] === this) { delete SC.View.views[lastId]; } // set the current one as the new old one this._lastLayerId = lid; // and add the new one SC.View.views[lid] = this; // and finally, set the actual layer id. if (layer) { layer.id = lid; } } }.observes("layerId"), /** This method is called whenever the receiver's parentView has changed. The default implementation of this method marks the view's display location as dirty so that it will update at the end of the run loop. You will not usually need to override or call this method yourself, though if you manually patch the parentView hierarchy for some reason, you should call this method to notify the view that it's parentView has changed. @returns {SC.View} receiver */ parentViewDidChange: function() { this.recomputeIsVisibleInWindow() ; this.resetBuildState(); this.set('layerLocationNeedsUpdate', YES) ; this.invokeOnce(this.updateLayerLocationIfNeeded) ; // We also need to iterate down through the view hierarchy and invalidate // all our child view's caches for 'pane', since it could have changed. // // Note: In theory we could try to avoid this invalidation if we // do this only in cases where we "know" the 'pane' value might // have changed, but those cases are few and far between. this._invalidatePaneCacheForSelfAndAllChildViews(); return this ; }, /** @private We want to cache the 'pane' property, but it's impossible for us to declare a dependence on all properties that can affect the value. (For example, if our grandparent gets attached to a new pane, our pane will have changed.) So when there's the potential for the pane changing, we need to invalidate the caches for all our child views, and their child views, and so on. */ _invalidatePaneCacheForSelfAndAllChildViews: function () { var childView, childViews = this.get('childViews'), len = childViews.length, idx ; this.notifyPropertyChange('pane'); for (idx=0; idx