(cm, e, liberal, forRect)
| 2467 | // selections, and tries to estimate a character position even for |
| 2468 | // coordinates beyond the right of the text. |
| 2469 | function posFromMouse(cm, e, liberal, forRect) { |
| 2470 | var display = cm.display; |
| 2471 | if (!liberal) { |
| 2472 | var target = e_target(e); |
| 2473 | if (target == display.scrollbarH || target == display.scrollbarV || |
| 2474 | target == display.scrollbarFiller || target == display.gutterFiller) return null; |
| 2475 | } |
| 2476 | var x, y, space = display.lineSpace.getBoundingClientRect(); |
| 2477 | // Fails unpredictably on IE[67] when mouse is dragged around quickly. |
| 2478 | try { x = e.clientX - space.left; y = e.clientY - space.top; } |
| 2479 | catch (e) { return null; } |
| 2480 | var coords = coordsChar(cm, x, y), line; |
| 2481 | if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) { |
| 2482 | var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length; |
| 2483 | coords = Pos(coords.line, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff); |
| 2484 | } |
| 2485 | return coords; |
| 2486 | } |
| 2487 | |
| 2488 | // A mouse down can be a single click, double click, triple click, |
| 2489 | // start of selection drag, start of text drag, new cursor |
no test coverage detected