Path: blob/trunk/third_party/closure/goog/dom/savedrange.js
2868 views
// Copyright 2007 The Closure Library Authors. All Rights Reserved.1//2// Licensed under the Apache License, Version 2.0 (the "License");3// you may not use this file except in compliance with the License.4// You may obtain a copy of the License at5//6// http://www.apache.org/licenses/LICENSE-2.07//8// Unless required by applicable law or agreed to in writing, software9// distributed under the License is distributed on an "AS-IS" BASIS,10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11// See the License for the specific language governing permissions and12// limitations under the License.1314/**15* @fileoverview A generic interface for saving and restoring ranges.16*17* @author [email protected] (Robby Walker)18*/192021goog.provide('goog.dom.SavedRange');2223goog.require('goog.Disposable');24goog.require('goog.log');25262728/**29* Abstract interface for a saved range.30* @constructor31* @extends {goog.Disposable}32*/33goog.dom.SavedRange = function() {34goog.Disposable.call(this);35};36goog.inherits(goog.dom.SavedRange, goog.Disposable);373839/**40* Logging object.41* @type {goog.log.Logger}42* @private43*/44goog.dom.SavedRange.logger_ = goog.log.getLogger('goog.dom.SavedRange');454647/**48* Restores the range and by default disposes of the saved copy. Take note:49* this means the by default SavedRange objects are single use objects.50* @param {boolean=} opt_stayAlive Whether this SavedRange should stay alive51* (not be disposed) after restoring the range. Defaults to false (dispose).52* @return {goog.dom.AbstractRange} The restored range.53*/54goog.dom.SavedRange.prototype.restore = function(opt_stayAlive) {55if (this.isDisposed()) {56goog.log.error(57goog.dom.SavedRange.logger_,58'Disposed SavedRange objects cannot be restored.');59}6061var range = this.restoreInternal();62if (!opt_stayAlive) {63this.dispose();64}65return range;66};676869/**70* Internal method to restore the saved range.71* @return {goog.dom.AbstractRange} The restored range.72*/73goog.dom.SavedRange.prototype.restoreInternal = goog.abstractMethod;747576