function Selection() {
      this.selection = rootDoc.getSelection();
      if (this.selection.rangeCount && this.selection.anchorNode) {
        var startNode   = this.selection.anchorNode;
        var startOffset = this.selection.anchorOffset;
        var endNode     = this.selection.focusNode;
        var endOffset   = this.selection.focusOffset;

        // if the range starts and ends on the same node, then we must swap the
        // offsets if ever focusOffset is smaller than anchorOffset
        if (startNode === endNode && endOffset < startOffset) {
          var tmp = startOffset;
          startOffset = endOffset;
          endOffset = tmp;
        }
        // if the range ends *before* it starts, then we must reverse the range
        else if (nodeHelpers.isBefore(endNode, startNode)) {
          var tmpNode = startNode,
            tmpOffset = startOffset;
          startNode = endNode;
          startOffset = endOffset;
          endNode = tmpNode;
          endOffset = tmpOffset;
        }

        // create the range to avoid chrome bug from getRangeAt / window.getSelection()
        // https://code.google.com/p/chromium/issues/detail?id=380690
        this.range = document.createRange();
        this.range.setStart(startNode, startOffset);
        this.range.setEnd(endNode, endOffset);
      }
    }
Wrapper for object holding currently selected text.