diff --git a/lib/codemirror.js b/lib/codemirror.js index 06042fe884..1bcc6b1cec 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -14,7 +14,6 @@ window.CodeMirror = (function() { var ie = /MSIE \d/.test(navigator.userAgent); var ie_lt8 = /MSIE [1-7]\b/.test(navigator.userAgent); var ie_lt9 = /MSIE [1-8]\b/.test(navigator.userAgent); - var quirksMode = ie && document.documentMode == 5; var webkit = /WebKit\//.test(navigator.userAgent); var chrome = /Chrome\//.test(navigator.userAgent); var opera = /Opera\//.test(navigator.userAgent); @@ -582,13 +581,12 @@ window.CodeMirror = (function() { } else { headPos = cursorCoords(cm, selHead(cm.view), "div"); var fragment = document.createDocumentFragment(); - var clientWidth = display.lineSpace.clientWidth || display.lineSpace.offsetWidth; - var add = function(left, top, right, bottom) { + var clientWidth = display.lineSpace.clientWidth; + var add = function(left, top, width, bottom) { if (top < 0) top = 0; - var rstyle = quirksMode ? "width: " + (!right ? clientWidth : clientWidth - right - left) + "px" - : "right: " + right + "px"; fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left + - "px; top: " + top + "px; " + rstyle + "; height: " + (bottom - top) + "px")); + "px; top: " + top + "px; width: " + (width == null ? clientWidth : width) + + "px; height: " + (bottom - top) + "px")); }; var middleFrom = sel.from.line + 1, middleTo = sel.to.line - 1, sameLine = sel.from.line == sel.to.line; @@ -601,13 +599,13 @@ window.CodeMirror = (function() { var rightPos = coords(dir == "rtl" ? from : to - 1); var left = leftPos.left, right = rightPos.right; if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part - add(left, leftPos.top, 0, leftPos.bottom); + add(left, leftPos.top, null, leftPos.bottom); left = paddingLeft(display); - if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, 0, rightPos.top); + if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top); } if (toArg == null && to == lineLen) right = clientWidth; rVal = retTop ? Math.min(rightPos.top, rVal) : Math.max(rightPos.bottom, rVal); - add(left, rightPos.top, clientWidth - right, rightPos.bottom); + add(left, rightPos.top, right - left, rightPos.bottom); }); return rVal; }; @@ -634,7 +632,7 @@ window.CodeMirror = (function() { middleTop = Math.min(middleTop, top.top); middleBot = Math.max(middleBot, bottom.bottom); } - if (middleTop < middleBot) add(paddingLeft(display), middleTop, 0, middleBot); + if (middleTop < middleBot) add(paddingLeft(display), middleTop, null, middleBot); removeChildrenAndAdd(display.selectionDiv, fragment); display.cursor.style.display = display.otherCursor.style.display = "none";