(map, ch, bias)
| 2646 | var nullRect = {left: 0, right: 0, top: 0, bottom: 0}; |
| 2647 | |
| 2648 | function nodeAndOffsetInLineMap(map, ch, bias) { |
| 2649 | var node, start, end, collapse; |
| 2650 | // First, search the line map for the text node corresponding to, |
| 2651 | // or closest to, the target character. |
| 2652 | for (var i = 0; i < map.length; i += 3) { |
| 2653 | var mStart = map[i], mEnd = map[i + 1]; |
| 2654 | if (ch < mStart) { |
| 2655 | start = 0; end = 1; |
| 2656 | collapse = "left"; |
| 2657 | } else if (ch < mEnd) { |
| 2658 | start = ch - mStart; |
| 2659 | end = start + 1; |
| 2660 | } else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) { |
| 2661 | end = mEnd - mStart; |
| 2662 | start = end - 1; |
| 2663 | if (ch >= mEnd) collapse = "right"; |
| 2664 | } |
| 2665 | if (start != null) { |
| 2666 | node = map[i + 2]; |
| 2667 | if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right")) |
| 2668 | collapse = bias; |
| 2669 | if (bias == "left" && start == 0) |
| 2670 | while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) { |
| 2671 | node = map[(i -= 3) + 2]; |
| 2672 | collapse = "left"; |
| 2673 | } |
| 2674 | if (bias == "right" && start == mEnd - mStart) |
| 2675 | while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) { |
| 2676 | node = map[(i += 3) + 2]; |
| 2677 | collapse = "right"; |
| 2678 | } |
| 2679 | break; |
| 2680 | } |
| 2681 | } |
| 2682 | return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd}; |
| 2683 | } |
| 2684 | |
| 2685 | function measureCharInner(cm, prepared, ch, bias) { |
| 2686 | var place = nodeAndOffsetInLineMap(prepared.map, ch, bias); |
no outgoing calls
no test coverage detected