(cm, e, liberal, forRect)
| 3422 | // selections, and tries to estimate a character position even for |
| 3423 | // coordinates beyond the right of the text. |
| 3424 | function posFromMouse(cm, e, liberal, forRect) { |
| 3425 | var display = cm.display; |
| 3426 | if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") return null; |
| 3427 | |
| 3428 | var x, y, space = display.lineSpace.getBoundingClientRect(); |
| 3429 | // Fails unpredictably on IE[67] when mouse is dragged around quickly. |
| 3430 | try { x = e.clientX - space.left; y = e.clientY - space.top; } |
| 3431 | catch (e) { return null; } |
| 3432 | var coords = coordsChar(cm, x, y), line; |
| 3433 | if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) { |
| 3434 | var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length; |
| 3435 | coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff)); |
| 3436 | } |
| 3437 | return coords; |
| 3438 | } |
| 3439 | |
| 3440 | // A mouse down can be a single click, double click, triple click, |
| 3441 | // start of selection drag, start of text drag, new cursor |
no test coverage detected