dist/dom-selection.es.js
function getRect(sel) {
	sel = sel || getSelection();
	if (!sel.rangeCount) { return false; }

	var range = sel.getRangeAt(0).cloneRange();

	// on Webkit 'range.getBoundingClientRect()' sometimes return 0/0/0/0 - but 'range.getClientRects()' works
	var rects = range.getClientRects ? range.getClientRects() : [];
	for (var i = 0; i < rects.length; ++i) {
		var rect = rects[i];
		if (rect.left && rect.top && rect.right && rect.bottom) {
			return {
				// Modern browsers return floating-point numbers
				left: parseInt(rect.left, 10),
				top: parseInt(rect.top, 10),
				width: parseInt(rect.right - rect.left, 10),
				height: parseInt(rect.bottom - rect.top, 10)
			};
		}
	}

	return false;
}
function getRect(sel) {
	sel = sel || getSelection();
	if (!sel.rangeCount) { return false; }

	var range = sel.getRangeAt(0).cloneRange();

	// on Webkit 'range.getBoundingClientRect()' sometimes return 0/0/0/0 - but 'range.getClientRects()' works
	var rects = range.getClientRects ? range.getClientRects() : [];
	for (var i = 0; i < rects.length; ++i) {
		var rect = rects[i];
		if (rect.left && rect.top && rect.right && rect.bottom) {
			return {
				// Modern browsers return floating-point numbers
				left: parseInt(rect.left, 10),
				top: parseInt(rect.top, 10),
				width: parseInt(rect.right - rect.left, 10),
				height: parseInt(rect.bottom - rect.top, 10)
			};
		}
	}

	return false;
}
function getRect ( sel ) { sel = sel || getSelection ( ) ; if ( ! sel . rangeCount ) { return false ; } var range = sel . getRangeAt ( 0 ) . cloneRange ( ) ; // on Webkit 'range.getBoundingClientRect()' sometimes return 0/0/0/0 - but 'range.getClientRects()' works var rects = range . getClientRects ? range . getClientRects ( ) : [ ] ; for ( var i = 0 ; i < rects . length ; ++ i ) { var rect = rects [ i ] ; if ( rect . left && rect . top && rect . right && rect . bottom ) { return { // Modern browsers return floating-point numbers left : parseInt ( rect . left , 10 ) , top : parseInt ( rect . top , 10 ) , width : parseInt ( rect . right - rect . left , 10 ) , height : parseInt ( rect . bottom - rect . top , 10 ) } ; } } return false ; }
Get a Selection Rectangle
@see http://stackoverflow.com/questions/12603397/calculate-width-height-of-the-selected-text-javascript
@see http://stackoverflow.com/questions/6846230/coordinates-of-selected-text-in-browser-page
@param {Selection} sel
@return {Object|Boolean}
Get a Selection Rectangle