(cm, e, liberal, forRect)
| 3542 | // selections, and tries to estimate a character position even for |
| 3543 | // coordinates beyond the right of the text. |
| 3544 | function posFromMouse(cm, e, liberal, forRect) { |
| 3545 | var display = cm.display; |
| 3546 | if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") return null; |
| 3547 | |
| 3548 | var x, y, space = display.lineSpace.getBoundingClientRect(); |
| 3549 | // Fails unpredictably on IE[67] when mouse is dragged around quickly. |
| 3550 | try { x = e.clientX - space.left; y = e.clientY - space.top; } |
| 3551 | catch (e) { return null; } |
| 3552 | var coords = coordsChar(cm, x, y), line; |
| 3553 | if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) { |
| 3554 | var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length; |
| 3555 | coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff)); |
| 3556 | } |
| 3557 | return coords; |
| 3558 | } |
| 3559 | |
| 3560 | // A mouse down can be a single click, double click, triple click, |
| 3561 | // start of selection drag, start of text drag, new cursor |
no test coverage detected