(cm, e, liberal, forRect)
| 2955 | // selections, and tries to estimate a character position even for |
| 2956 | // coordinates beyond the right of the text. |
| 2957 | function posFromMouse(cm, e, liberal, forRect) { |
| 2958 | var display = cm.display; |
| 2959 | if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") { return null } |
| 2960 | |
| 2961 | var x, y, space = display.lineSpace.getBoundingClientRect(); |
| 2962 | // Fails unpredictably on IE[67] when mouse is dragged around quickly. |
| 2963 | try { x = e.clientX - space.left; y = e.clientY - space.top; } |
| 2964 | catch (e$1) { return null } |
| 2965 | var coords = coordsChar(cm, x, y), line; |
| 2966 | if (forRect && coords.xRel > 0 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) { |
| 2967 | var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length; |
| 2968 | coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff)); |
| 2969 | } |
| 2970 | return coords |
| 2971 | } |
| 2972 | |
| 2973 | // Find the view element corresponding to a given line. Return null |
| 2974 | // when the line isn't visible. |
no test coverage detected