(cm, lineView)
| 6938 | // The returned object contains the DOM node, this map, and |
| 6939 | // information about line-wide styles that were set by the mode. |
| 6940 | function buildLineContent(cm, lineView) { |
| 6941 | // The padding-right forces the element to have a 'border', which |
| 6942 | // is needed on Webkit to be able to get line-level bounding |
| 6943 | // rectangles for it (in measureChar). |
| 6944 | var content = elt("span", null, null, webkit ? "padding-right: .1px" : null); |
| 6945 | var builder = {pre: elt("pre", [content], "CodeMirror-line"), content: content, |
| 6946 | col: 0, pos: 0, cm: cm, |
| 6947 | splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")}; |
| 6948 | lineView.measure = {}; |
| 6949 | |
| 6950 | // Iterate over the logical lines that make up this visual line. |
| 6951 | for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) { |
| 6952 | var line = i ? lineView.rest[i - 1] : lineView.line, order; |
| 6953 | builder.pos = 0; |
| 6954 | builder.addToken = buildToken; |
| 6955 | // Optionally wire in some hacks into the token-rendering |
| 6956 | // algorithm, to deal with browser quirks. |
| 6957 | if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line))) |
| 6958 | builder.addToken = buildTokenBadBidi(builder.addToken, order); |
| 6959 | builder.map = []; |
| 6960 | var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line); |
| 6961 | insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate)); |
| 6962 | if (line.styleClasses) { |
| 6963 | if (line.styleClasses.bgClass) |
| 6964 | builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || ""); |
| 6965 | if (line.styleClasses.textClass) |
| 6966 | builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || ""); |
| 6967 | } |
| 6968 | |
| 6969 | // Ensure at least a single node is present, for measuring. |
| 6970 | if (builder.map.length == 0) |
| 6971 | builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))); |
| 6972 | |
| 6973 | // Store the map and a cache object for the current logical line |
| 6974 | if (i == 0) { |
| 6975 | lineView.measure.map = builder.map; |
| 6976 | lineView.measure.cache = {}; |
| 6977 | } else { |
| 6978 | (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map); |
| 6979 | (lineView.measure.caches || (lineView.measure.caches = [])).push({}); |
| 6980 | } |
| 6981 | } |
| 6982 | |
| 6983 | // See issue #2901 |
| 6984 | if (webkit) { |
| 6985 | var last = builder.content.lastChild |
| 6986 | if (/\bcm-tab\b/.test(last.className) || (last.querySelector && last.querySelector(".cm-tab"))) |
| 6987 | builder.content.className = "cm-tab-wrap-hack"; |
| 6988 | } |
| 6989 | |
| 6990 | signal(cm, "renderLine", cm, lineView.line, builder.pre); |
| 6991 | if (builder.pre.className) |
| 6992 | builder.textClass = joinClasses(builder.pre.className, builder.textClass || ""); |
| 6993 | |
| 6994 | return builder; |
| 6995 | } |
| 6996 | |
| 6997 | function defaultSpecialCharPlaceholder(ch) { |
no test coverage detected