| 4055 | } |
| 4056 | |
| 4057 | function restoreSelection(snapshot) { |
| 4058 | if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt()) { return } |
| 4059 | snapshot.activeElt.focus(); |
| 4060 | if (!/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) && |
| 4061 | snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) { |
| 4062 | var sel = window.getSelection(), range = document.createRange(); |
| 4063 | range.setEnd(snapshot.anchorNode, snapshot.anchorOffset); |
| 4064 | range.collapse(false); |
| 4065 | sel.removeAllRanges(); |
| 4066 | sel.addRange(range); |
| 4067 | sel.extend(snapshot.focusNode, snapshot.focusOffset); |
| 4068 | } |
| 4069 | } |
| 4070 | |
| 4071 | // Does the actual updating of the line display. Bails out |
| 4072 | // (returning false) when there is nothing to be done and forced is |