(cm, e, liberal, forRect)
| 3563 | // selections, and tries to estimate a character position even for |
| 3564 | // coordinates beyond the right of the text. |
| 3565 | function posFromMouse(cm, e, liberal, forRect) { |
| 3566 | var display = cm.display; |
| 3567 | if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") return null; |
| 3568 | |
| 3569 | var x, y, space = display.lineSpace.getBoundingClientRect(); |
| 3570 | // Fails unpredictably on IE[67] when mouse is dragged around quickly. |
| 3571 | try { x = e.clientX - space.left; y = e.clientY - space.top; } |
| 3572 | catch (e) { return null; } |
| 3573 | var coords = coordsChar(cm, x, y), line; |
| 3574 | if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) { |
| 3575 | var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length; |
| 3576 | coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff)); |
| 3577 | } |
| 3578 | return coords; |
| 3579 | } |
| 3580 | |
| 3581 | // A mouse down can be a single click, double click, triple click, |
| 3582 | // start of selection drag, start of text drag, new cursor |
no test coverage detected