(cm, e, liberal, forRect)
| 4389 | // selections, and tries to estimate a character position even for |
| 4390 | // coordinates beyond the right of the text. |
| 4391 | function posFromMouse(cm, e, liberal, forRect) { |
| 4392 | var display = cm.display |
| 4393 | if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") { |
| 4394 | return null |
| 4395 | } |
| 4396 | |
| 4397 | var x, |
| 4398 | y, |
| 4399 | space = display.lineSpace.getBoundingClientRect() |
| 4400 | // Fails unpredictably on IE[67] when mouse is dragged around quickly. |
| 4401 | try { |
| 4402 | x = e.clientX - space.left |
| 4403 | y = e.clientY - space.top |
| 4404 | } catch (e) { |
| 4405 | return null |
| 4406 | } |
| 4407 | var coords = coordsChar(cm, x, y), |
| 4408 | line |
| 4409 | if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) { |
| 4410 | var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length |
| 4411 | coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff)) |
| 4412 | } |
| 4413 | return coords |
| 4414 | } |
| 4415 | |
| 4416 | // Find the view element corresponding to a given line. Return null |
| 4417 | // when the line isn't visible. |
no test coverage detected