(cm, lineView)
| 1724 | // The returned object contains the DOM node, this map, and |
| 1725 | // information about line-wide styles that were set by the mode. |
| 1726 | function buildLineContent(cm, lineView) { |
| 1727 | // The padding-right forces the element to have a 'border', which |
| 1728 | // is needed on Webkit to be able to get line-level bounding |
| 1729 | // rectangles for it (in measureChar). |
| 1730 | var content = eltP("span", null, null, webkit ? "padding-right: .1px" : null); |
| 1731 | var builder = {pre: eltP("pre", [content], "CodeMirror-line"), content: content, |
| 1732 | col: 0, pos: 0, cm: cm, |
| 1733 | trailingSpace: false, |
| 1734 | splitSpaces: cm.getOption("lineWrapping")}; |
| 1735 | lineView.measure = {}; |
| 1736 | |
| 1737 | // Iterate over the logical lines that make up this visual line. |
| 1738 | for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) { |
| 1739 | var line = i ? lineView.rest[i - 1] : lineView.line, order = (void 0); |
| 1740 | builder.pos = 0; |
| 1741 | builder.addToken = buildToken; |
| 1742 | // Optionally wire in some hacks into the token-rendering |
| 1743 | // algorithm, to deal with browser quirks. |
| 1744 | if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line, cm.doc.direction))) |
| 1745 | { builder.addToken = buildTokenBadBidi(builder.addToken, order); } |
| 1746 | builder.map = []; |
| 1747 | var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line); |
| 1748 | insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate)); |
| 1749 | if (line.styleClasses) { |
| 1750 | if (line.styleClasses.bgClass) |
| 1751 | { builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || ""); } |
| 1752 | if (line.styleClasses.textClass) |
| 1753 | { builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || ""); } |
| 1754 | } |
| 1755 | |
| 1756 | // Ensure at least a single node is present, for measuring. |
| 1757 | if (builder.map.length == 0) |
| 1758 | { builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))); } |
| 1759 | |
| 1760 | // Store the map and a cache object for the current logical line |
| 1761 | if (i == 0) { |
| 1762 | lineView.measure.map = builder.map; |
| 1763 | lineView.measure.cache = {}; |
| 1764 | } else { |
| 1765 | (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map) |
| 1766 | ;(lineView.measure.caches || (lineView.measure.caches = [])).push({}); |
| 1767 | } |
| 1768 | } |
| 1769 | |
| 1770 | // See issue #2901 |
| 1771 | if (webkit) { |
| 1772 | var last = builder.content.lastChild; |
| 1773 | if (/\bcm-tab\b/.test(last.className) || (last.querySelector && last.querySelector(".cm-tab"))) |
| 1774 | { builder.content.className = "cm-tab-wrap-hack"; } |
| 1775 | } |
| 1776 | |
| 1777 | signal(cm, "renderLine", cm, lineView.line, builder.pre); |
| 1778 | if (builder.pre.className) |
| 1779 | { builder.textClass = joinClasses(builder.pre.className, builder.textClass || ""); } |
| 1780 | |
| 1781 | return builder |
| 1782 | } |
| 1783 |
no test coverage detected