(cm, lineView)
| 1805 | // The returned object contains the DOM node, this map, and |
| 1806 | // information about line-wide styles that were set by the mode. |
| 1807 | function buildLineContent(cm, lineView) { |
| 1808 | // The padding-right forces the element to have a 'border', which |
| 1809 | // is needed on Webkit to be able to get line-level bounding |
| 1810 | // rectangles for it (in measureChar). |
| 1811 | var content = eltP("span", null, null, webkit ? "padding-right: .1px" : null); |
| 1812 | var builder = {pre: eltP("pre", [content], "CodeMirror-line"), content: content, |
| 1813 | col: 0, pos: 0, cm: cm, |
| 1814 | trailingSpace: false, |
| 1815 | splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")}; |
| 1816 | lineView.measure = {}; |
| 1817 | |
| 1818 | // Iterate over the logical lines that make up this visual line. |
| 1819 | for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) { |
| 1820 | var line = i ? lineView.rest[i - 1] : lineView.line, order = (void 0); |
| 1821 | builder.pos = 0; |
| 1822 | builder.addToken = buildToken; |
| 1823 | // Optionally wire in some hacks into the token-rendering |
| 1824 | // algorithm, to deal with browser quirks. |
| 1825 | if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line, cm.doc.direction))) |
| 1826 | { builder.addToken = buildTokenBadBidi(builder.addToken, order); } |
| 1827 | builder.map = []; |
| 1828 | var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line); |
| 1829 | insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate)); |
| 1830 | if (line.styleClasses) { |
| 1831 | if (line.styleClasses.bgClass) |
| 1832 | { builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || ""); } |
| 1833 | if (line.styleClasses.textClass) |
| 1834 | { builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || ""); } |
| 1835 | } |
| 1836 | |
| 1837 | // Ensure at least a single node is present, for measuring. |
| 1838 | if (builder.map.length == 0) |
| 1839 | { builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))); } |
| 1840 | |
| 1841 | // Store the map and a cache object for the current logical line |
| 1842 | if (i == 0) { |
| 1843 | lineView.measure.map = builder.map; |
| 1844 | lineView.measure.cache = {}; |
| 1845 | } else { |
| 1846 | (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map) |
| 1847 | ;(lineView.measure.caches || (lineView.measure.caches = [])).push({}); |
| 1848 | } |
| 1849 | } |
| 1850 | |
| 1851 | // See issue #2901 |
| 1852 | if (webkit) { |
| 1853 | var last = builder.content.lastChild; |
| 1854 | if (/\bcm-tab\b/.test(last.className) || (last.querySelector && last.querySelector(".cm-tab"))) |
| 1855 | { builder.content.className = "cm-tab-wrap-hack"; } |
| 1856 | } |
| 1857 | |
| 1858 | signal(cm, "renderLine", cm, lineView.line, builder.pre); |
| 1859 | if (builder.pre.className) |
| 1860 | { builder.textClass = joinClasses(builder.pre.className, builder.textClass || ""); } |
| 1861 | |
| 1862 | return builder |
| 1863 | } |
| 1864 |
no test coverage detected