viewLine.ts 17.2 KB
Newer Older
E
Erich Gamma 已提交
1 2 3 4 5 6
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
'use strict';

A
Alex Dima 已提交
7
import * as Browser from 'vs/base/browser/browser';
E
Erich Gamma 已提交
8 9
import {IVisibleLineData} from 'vs/editor/browser/view/viewLayer';
import {ILineParts, createLineParts} from 'vs/editor/common/viewLayout/viewLineParts';
10 11
import {ClassNames, IViewContext} from 'vs/editor/browser/editorBrowser';
import {IModelDecoration, IConfigurationChangedEvent, HorizontalRange} from 'vs/editor/common/editorCommon';
12
import {renderLine} from 'vs/editor/common/viewLayout/viewLineRenderer';
A
Alex Dima 已提交
13
import {StyleMutator} from 'vs/base/browser/styleMutator';
E
Erich Gamma 已提交
14

A
Alex Dima 已提交
15
export class ViewLine implements IVisibleLineData {
E
Erich Gamma 已提交
16

A
Alex Dima 已提交
17
	protected _context:IViewContext;
E
Erich Gamma 已提交
18 19 20 21 22 23 24
	private _domNode: HTMLElement;

	private _lineParts: ILineParts;

	private _isInvalid: boolean;
	private _isMaybeInvalid: boolean;

A
Alex Dima 已提交
25
	protected _charOffsetInPart:number[];
E
Erich Gamma 已提交
26 27 28
	private _lastRenderedPartIndex:number;
	private _cachedWidth: number;

A
Alex Dima 已提交
29
	constructor(context:IViewContext) {
E
Erich Gamma 已提交
30 31 32 33 34 35 36 37 38
		this._context = context;
		this._domNode = null;
		this._isInvalid = true;
		this._isMaybeInvalid = false;
		this._lineParts = null;
		this._charOffsetInPart = [];
		this._lastRenderedPartIndex = 0;
	}

A
Alex Dima 已提交
39 40
	// --- begin IVisibleLineData

E
Erich Gamma 已提交
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
	public getDomNode(): HTMLElement {
		return this._domNode;
	}
	public setDomNode(domNode:HTMLElement): void {
		this._domNode = domNode;
	}

	public onContentChanged(): void {
		this._isInvalid = true;
	}
	public onLinesInsertedAbove(): void {
		this._isMaybeInvalid = true;
	}
	public onLinesDeletedAbove(): void {
		this._isMaybeInvalid = true;
	}
	public onLineChangedAbove(): void {
		this._isMaybeInvalid = true;
	}
	public onTokensChanged(): void {
		this._isMaybeInvalid = true;
	}
	public onModelDecorationsChanged(): void {
		this._isMaybeInvalid = true;
	}
A
Alex Dima 已提交
66
	public onConfigurationChanged(e:IConfigurationChangedEvent): void {
E
Erich Gamma 已提交
67 68 69
		this._isInvalid = true;
	}

A
Alex Dima 已提交
70 71
	public shouldUpdateHTML(lineNumber:number, inlineDecorations:IModelDecoration[]): boolean {
		let newLineParts:ILineParts = null;
E
Erich Gamma 已提交
72 73 74

		if (this._isMaybeInvalid || this._isInvalid) {
			// Compute new line parts only if there is some evidence that something might have changed
A
Alex Dima 已提交
75 76 77 78 79 80 81
			newLineParts = createLineParts(
				lineNumber,
				this._context.model.getLineContent(lineNumber),
				this._context.model.getLineTokens(lineNumber),
				inlineDecorations,
				this._context.configuration.editor.renderWhitespace
			);
E
Erich Gamma 已提交
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
		}

		// Decide if isMaybeInvalid flips isInvalid to true
		if (this._isMaybeInvalid) {
			if (!this._isInvalid) {
				if (!this._lineParts || !this._lineParts.equals(newLineParts)) {
					this._isInvalid = true;
				}
			}
			this._isMaybeInvalid = false;
		}

		if (this._isInvalid) {
			this._lineParts = newLineParts;
		}

		return this._isInvalid;
	}

	public getLineOuterHTML(out:string[], lineNumber:number, deltaTop:number): void {
		out.push('<div lineNumber="');
		out.push(lineNumber.toString());
		out.push('" style="top:');
		out.push(deltaTop.toString());
		out.push('px;height:');
		out.push(this._context.configuration.editor.lineHeight.toString());
		out.push('px;" class="');
A
Alex Dima 已提交
109
		out.push(ClassNames.VIEW_LINE);
E
Erich Gamma 已提交
110 111 112 113 114 115 116
		out.push('">');
		out.push(this.getLineInnerHTML(lineNumber));
		out.push('</div>');
	}

	public getLineInnerHTML(lineNumber: number): string {
		this._isInvalid = false;
A
Alex Dima 已提交
117
		return this._render(lineNumber, this._lineParts).join('');
E
Erich Gamma 已提交
118 119 120
	}

	public layoutLine(lineNumber:number, deltaTop:number): void {
A
Alex Dima 已提交
121 122 123 124
		let desiredLineNumber = String(lineNumber);
		let currentLineNumber = this._domNode.getAttribute('lineNumber');
		if (currentLineNumber !== desiredLineNumber) {
			this._domNode.setAttribute('lineNumber', desiredLineNumber);
E
Erich Gamma 已提交
125
		}
A
Alex Dima 已提交
126 127
		StyleMutator.setTop(this._domNode, deltaTop);
		StyleMutator.setHeight(this._domNode, this._context.configuration.editor.lineHeight);
E
Erich Gamma 已提交
128 129
	}

A
Alex Dima 已提交
130 131
	// --- end IVisibleLineData

A
Alex Dima 已提交
132
	private _render(lineNumber:number, lineParts:ILineParts): string[] {
E
Erich Gamma 已提交
133

A
Alex Dima 已提交
134
		this._cachedWidth = -1;
E
Erich Gamma 已提交
135

A
Alex Dima 已提交
136
		let r = renderLine({
E
Erich Gamma 已提交
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
			lineContent: this._context.model.getLineContent(lineNumber),
			tabSize: this._context.configuration.getIndentationOptions().tabSize,
			stopRenderingLineAfter: this._context.configuration.editor.stopRenderingLineAfter,
			renderWhitespace: this._context.configuration.editor.renderWhitespace,
			parts: lineParts.getParts()
		});

		this._charOffsetInPart = r.charOffsetInPart;
		this._lastRenderedPartIndex = r.lastRenderedPartIndex;

		return r.output;
	}

	// --- Reading from the DOM methods

152
	protected _getReadingTarget(): HTMLElement {
E
Erich Gamma 已提交
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
		return <HTMLSpanElement>this._domNode.firstChild;
	}

	/**
	 * Width of the line in pixels
	 */
	public getWidth(): number {
		if (this._cachedWidth === -1) {
			this._cachedWidth = this._getReadingTarget().offsetWidth;
		}
		return this._cachedWidth;
	}

	/**
	 * Visible ranges for a model range
	 */
169
	public getVisibleRangesForRange(startColumn:number, endColumn:number, clientRectDeltaLeft:number, endNode:HTMLElement): HorizontalRange[] {
A
Alex Dima 已提交
170
		let stopRenderingLineAfter = this._context.configuration.editor.stopRenderingLineAfter;
E
Erich Gamma 已提交
171 172 173 174 175 176 177 178 179 180 181 182 183 184

		if (stopRenderingLineAfter !== -1 && startColumn > stopRenderingLineAfter && endColumn > stopRenderingLineAfter) {
			// This range is obviously not visible
			return null;
		}

		if (stopRenderingLineAfter !== -1 && startColumn > stopRenderingLineAfter) {
			startColumn = stopRenderingLineAfter;
		}

		if (stopRenderingLineAfter !== -1 && endColumn > stopRenderingLineAfter) {
			endColumn = stopRenderingLineAfter;
		}

185
		return this._readVisibleRangesForRange(startColumn, endColumn, clientRectDeltaLeft, endNode);
E
Erich Gamma 已提交
186 187
	}

188
	protected _readVisibleRangesForRange(startColumn:number, endColumn:number, clientRectDeltaLeft:number, endNode:HTMLElement): HorizontalRange[] {
E
Erich Gamma 已提交
189

A
Alex Dima 已提交
190
		let result: HorizontalRange[];
E
Erich Gamma 已提交
191
		if (startColumn === endColumn) {
192
			result = this._readRawVisibleRangesForPosition(startColumn, clientRectDeltaLeft, endNode);
E
Erich Gamma 已提交
193
		} else {
194
			result = this._readRawVisibleRangesForRange(startColumn, endColumn, clientRectDeltaLeft, endNode);
E
Erich Gamma 已提交
195 196 197 198 199 200 201 202
		}

		if (!result || result.length <= 1) {
			return result;
		}

		result.sort(compareVisibleRanges);

A
Alex Dima 已提交
203 204
		let output: HorizontalRange[] = [];
		let prevRange: HorizontalRange = result[0];
E
Erich Gamma 已提交
205

A
Alex Dima 已提交
206 207
		for (let i = 1, len = result.length; i < len; i++) {
			let currRange = result[i];
E
Erich Gamma 已提交
208

209
			if (prevRange.left + prevRange.width + 0.9 /* account for browser's rounding errors*/ >= currRange.left) {
E
Erich Gamma 已提交
210 211 212 213 214 215 216 217 218 219 220
				prevRange.width = Math.max(prevRange.width, currRange.left + currRange.width - prevRange.left);
			} else {
				output.push(prevRange);
				prevRange = currRange;
			}
		}
		output.push(prevRange);

		return output;
	}

221
	protected _readRawVisibleRangesForPosition(column:number, clientRectDeltaLeft:number, endNode:HTMLElement): HorizontalRange[] {
E
Erich Gamma 已提交
222 223 224

		if (this._charOffsetInPart.length === 0) {
			// This line is empty
A
Alex Dima 已提交
225
			return [new HorizontalRange(0, 0)];
E
Erich Gamma 已提交
226 227
		}

A
Alex Dima 已提交
228 229
		let partIndex = findIndexInArrayWithMax(this._lineParts, column - 1, this._lastRenderedPartIndex);
		let charOffsetInPart = this._charOffsetInPart[column - 1];
E
Erich Gamma 已提交
230

231
		return this._readRawVisibleRangesFrom(this._getReadingTarget(), partIndex, charOffsetInPart, partIndex, charOffsetInPart, clientRectDeltaLeft, endNode);
E
Erich Gamma 已提交
232 233
	}

234
	private _readRawVisibleRangesForRange(startColumn:number, endColumn:number, clientRectDeltaLeft:number, endNode:HTMLElement): HorizontalRange[] {
E
Erich Gamma 已提交
235 236 237 238

		if (startColumn === 1 && endColumn === this._charOffsetInPart.length) {
			// This branch helps IE with bidi text & gives a performance boost to other browsers when reading visible ranges for an entire line

A
Alex Dima 已提交
239
			return [this._readRawVisibleRangeForEntireLine()];
E
Erich Gamma 已提交
240 241
		}

A
Alex Dima 已提交
242 243 244 245
		let startPartIndex = findIndexInArrayWithMax(this._lineParts, startColumn - 1, this._lastRenderedPartIndex);
		let startCharOffsetInPart = this._charOffsetInPart[startColumn - 1];
		let endPartIndex = findIndexInArrayWithMax(this._lineParts, endColumn - 1, this._lastRenderedPartIndex);
		let endCharOffsetInPart = this._charOffsetInPart[endColumn - 1];
E
Erich Gamma 已提交
246

247
		return this._readRawVisibleRangesFrom(this._getReadingTarget(), startPartIndex, startCharOffsetInPart, endPartIndex, endCharOffsetInPart, clientRectDeltaLeft, endNode);
E
Erich Gamma 已提交
248 249
	}

A
Alex Dima 已提交
250 251
	private _readRawVisibleRangeForEntireLine(): HorizontalRange {
		return new HorizontalRange(0, this._getReadingTarget().offsetWidth);
E
Erich Gamma 已提交
252 253
	}

254
	private _readRawVisibleRangesFrom(domNode:HTMLElement, startChildIndex:number, startOffset:number, endChildIndex:number, endOffset:number, clientRectDeltaLeft:number, endNode:HTMLElement): HorizontalRange[] {
A
Alex Dima 已提交
255
		let range = RangeUtil.createRange();
E
Erich Gamma 已提交
256 257 258

		try {
			// Panic check
A
Alex Dima 已提交
259 260
			let min = 0;
			let max = domNode.children.length - 1;
E
Erich Gamma 已提交
261 262 263 264 265 266 267
			if (min > max) {
				return null;
			}
			startChildIndex = Math.min(max, Math.max(min, startChildIndex));
			endChildIndex = Math.min(max, Math.max(min, endChildIndex));

			// If crossing over to a span only to select offset 0, then use the previous span's maximum offset
268
			// Chrome is buggy and doesn't handle 0 offsets well sometimes.
E
Erich Gamma 已提交
269 270 271 272 273 274 275
			if (startChildIndex !== endChildIndex) {
				if (endChildIndex > 0 && endOffset === 0) {
					endChildIndex--;
					endOffset = Number.MAX_VALUE;
				}
			}

A
Alex Dima 已提交
276 277
			let startElement = domNode.children[startChildIndex].firstChild;
			let endElement = domNode.children[endChildIndex].firstChild;
E
Erich Gamma 已提交
278 279 280 281 282 283 284 285 286 287 288

			if (!startElement || !endElement) {
				return null;
			}

			startOffset = Math.min(startElement.textContent.length, Math.max(0, startOffset));
			endOffset = Math.min(endElement.textContent.length, Math.max(0, endOffset));

			range.setStart(startElement, startOffset);
			range.setEnd(endElement, endOffset);

A
Alex Dima 已提交
289 290 291
			let clientRects = range.getClientRects();
			if (clientRects.length === 0) {
				return null;
E
Erich Gamma 已提交
292 293
			}

294
			return this._createRawVisibleRangesFromClientRects(clientRects, clientRectDeltaLeft);
E
Erich Gamma 已提交
295 296 297 298 299 300 301 302 303

		} catch (e) {
			// This is life ...
			return null;
		} finally {
			RangeUtil.detachRange(range, endNode);
		}
	}

304
	protected _createRawVisibleRangesFromClientRects(clientRects:ClientRectList, clientRectDeltaLeft:number): HorizontalRange[] {
A
Alex Dima 已提交
305 306 307
		let result:HorizontalRange[] = [];
		for (let i = 0, len = clientRects.length; i < len; i++) {
			let cR = clientRects[i];
308
			result.push(new HorizontalRange(Math.max(0, cR.left - clientRectDeltaLeft), cR.width));
E
Erich Gamma 已提交
309 310 311 312
		}
		return result;
	}

A
Alex Dima 已提交
313 314 315
	/**
	 * Returns the column for the text found at a specific offset inside a rendered dom node
	 */
E
Erich Gamma 已提交
316
	public getColumnOfNodeOffset(lineNumber:number, spanNode:HTMLElement, offset:number): number {
A
Alex Dima 已提交
317
		let spanIndex = -1;
E
Erich Gamma 已提交
318 319 320 321
		while (spanNode) {
			spanNode = <HTMLElement>spanNode.previousSibling;
			spanIndex++;
		}
A
Alex Dima 已提交
322
		let lineParts = this._lineParts.getParts();
E
Erich Gamma 已提交
323 324 325 326 327 328 329 330 331

		if (spanIndex >= lineParts.length) {
			return this._context.configuration.editor.stopRenderingLineAfter;
		}

		if (offset === 0) {
			return lineParts[spanIndex].startIndex + 1;
		}

A
Alex Dima 已提交
332 333 334
		let originalMin = lineParts[spanIndex].startIndex;
		let originalMax:number;
		let originalMaxStartOffset:number;
E
Erich Gamma 已提交
335 336 337 338 339 340 341 342 343 344

		if (spanIndex + 1 < lineParts.length) {
			// Stop searching characters at the beginning of the next part
			originalMax = lineParts[spanIndex + 1].startIndex;
			originalMaxStartOffset = this._charOffsetInPart[originalMax - 1] + this._charOffsetInPart[originalMax];
		} else {
			originalMax = this._context.model.getLineMaxColumn(lineNumber) - 1;
			originalMaxStartOffset = this._charOffsetInPart[originalMax];
		}

A
Alex Dima 已提交
345 346
		let min = originalMin;
		let max = originalMax;
E
Erich Gamma 已提交
347 348 349 350 351

		if (this._context.configuration.editor.stopRenderingLineAfter !== -1) {
			max = Math.min(this._context.configuration.editor.stopRenderingLineAfter - 1, originalMax);
		}

A
Alex Dima 已提交
352 353
		let nextStartOffset:number;
		let prevStartOffset:number;
E
Erich Gamma 已提交
354 355 356 357 358 359 360 361 362

		// Here are the variables and their relation plotted on an axis

		// prevStartOffset    a    midStartOffset    b    nextStartOffset
		// ------|------------|----------|-----------|-----------|--------->

		// Everything in (a;b] will match mid

		while (min < max) {
A
Alex Dima 已提交
363 364
			let mid = Math.floor( (min + max) / 2 );
			let midStartOffset = this._charOffsetInPart[mid];
E
Erich Gamma 已提交
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382

			if (mid === originalMax) {
				// Using Number.MAX_VALUE to ensure that any offset after midStartOffset will match mid
				nextStartOffset = Number.MAX_VALUE;
			} else if (mid + 1 === originalMax) {
				// mid + 1 is already in next part and might have the _charOffsetInPart = 0
				nextStartOffset = originalMaxStartOffset;
			} else {
				nextStartOffset = this._charOffsetInPart[mid + 1];
			}

			if (mid === originalMin) {
				// Using Number.MIN_VALUE to ensure that any offset before midStartOffset will match mid
				prevStartOffset = Number.MIN_VALUE;
			} else {
				prevStartOffset = this._charOffsetInPart[mid - 1];
			}

A
Alex Dima 已提交
383 384
			let a = (prevStartOffset + midStartOffset) / 2;
			let b = (midStartOffset + nextStartOffset) / 2;
E
Erich Gamma 已提交
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403

			if (a < offset && offset <= b) {
				// Hit!
				return mid + 1;
			}

			if (offset <= a) {
				max = mid - 1;
			} else {
				min = mid + 1;
			}
		}

		return min + 1;
	}
}

class IEViewLine extends ViewLine {

A
Alex Dima 已提交
404
	constructor(context:IViewContext) {
E
Erich Gamma 已提交
405 406 407
		super(context);
	}

408
	protected _createRawVisibleRangesFromClientRects(clientRects:ClientRectList, clientRectDeltaLeft:number): HorizontalRange[] {
A
Alex Dima 已提交
409 410 411 412
		let ratioX = screen.logicalXDPI / screen.deviceXDPI;
		let result:HorizontalRange[] = [];
		for (let i = 0, len = clientRects.length; i < len; i++) {
			let cR = clientRects[i];
413
			result[i] = new HorizontalRange(Math.max(0, cR.left * ratioX - clientRectDeltaLeft), cR.width * ratioX);
E
Erich Gamma 已提交
414 415 416 417 418 419 420 421
		}

		return result;
	}
}

class WebKitViewLine extends ViewLine {

A
Alex Dima 已提交
422
	constructor(context:IViewContext) {
E
Erich Gamma 已提交
423 424 425
		super(context);
	}

426 427
	protected _readVisibleRangesForRange(startColumn:number, endColumn:number, clientRectDeltaLeft:number, endNode:HTMLElement): HorizontalRange[] {
		let output = super._readVisibleRangesForRange(startColumn, endColumn, clientRectDeltaLeft, endNode);
E
Erich Gamma 已提交
428

429 430 431 432 433 434 435 436
		if (this._context.configuration.editor.fontLigatures && output.length === 1 && endColumn > 1 && endColumn === this._charOffsetInPart.length) {
			let lastSpanBoundingClientRect = (<HTMLElement>this._getReadingTarget().lastChild).getBoundingClientRect();
			let lastSpanBoundingClientRectRight = lastSpanBoundingClientRect.right - clientRectDeltaLeft;
			if (startColumn === endColumn) {
				output[0].left = lastSpanBoundingClientRectRight;
				output[0].width = 0;
			} else {
				output[0].width = lastSpanBoundingClientRectRight - output[0].left;
437
			}
438
			return output;
439 440
		}

E
Erich Gamma 已提交
441 442 443 444
		if (!output || output.length === 0 || startColumn === endColumn || (startColumn === 1 && endColumn === this._charOffsetInPart.length)) {
			return output;
		}

445
		// WebKit is buggy and returns an expanded range (to contain words in some cases)
E
Erich Gamma 已提交
446 447 448 449
		// The last client rect is enlarged (I think)

		// This is an attempt to patch things up
		// Find position of previous column
450
		let beforeEndVisibleRanges = this._readRawVisibleRangesForPosition(endColumn - 1, clientRectDeltaLeft, endNode);
E
Erich Gamma 已提交
451
		// Find position of last column
452
		let endVisibleRanges = this._readRawVisibleRangesForPosition(endColumn, clientRectDeltaLeft, endNode);
E
Erich Gamma 已提交
453 454

		if (beforeEndVisibleRanges && beforeEndVisibleRanges.length > 0 && endVisibleRanges && endVisibleRanges.length > 0) {
A
Alex Dima 已提交
455 456 457 458
			let beforeEndVisibleRange = beforeEndVisibleRanges[0];
			let endVisibleRange = endVisibleRanges[0];
			let isLTR = (beforeEndVisibleRange.left <= endVisibleRange.left);
			let lastRange = output[output.length - 1];
E
Erich Gamma 已提交
459

A
Andre Weinand 已提交
460
			if (isLTR && lastRange.left < endVisibleRange.left) {
E
Erich Gamma 已提交
461 462 463 464 465 466 467 468 469 470 471 472 473
				// Trim down the width of the last visible range to not go after the last column's position
				lastRange.width = endVisibleRange.left - lastRange.left;
			}
		}

		return output;
	}
}

class RangeUtil {

	/**
	 * Reusing the same range here
474
	 * because IE is buggy and constantly freezes when using a large number
E
Erich Gamma 已提交
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492
	 * of ranges and calling .detach on them
	 */
	private static _handyReadyRange:Range;

	public static createRange(): Range {
		if (!RangeUtil._handyReadyRange) {
			RangeUtil._handyReadyRange = document.createRange();
		}
		return RangeUtil._handyReadyRange;
	}

	public static detachRange(range:Range, endNode:HTMLElement): void {
		// Move range out of the span node, IE doesn't like having many ranges in
		// the same spot and will act badly for lines containing dashes ('-')
		range.selectNodeContents(endNode);
	}
}

A
Alex Dima 已提交
493
function compareVisibleRanges(a: HorizontalRange, b: HorizontalRange): number {
A
Andre Weinand 已提交
494
	return a.left - b.left;
E
Erich Gamma 已提交
495 496 497
}

function findIndexInArrayWithMax(lineParts:ILineParts, desiredIndex: number, maxResult:number): number {
A
Alex Dima 已提交
498
	let r = lineParts.findIndexOfOffset(desiredIndex);
E
Erich Gamma 已提交
499 500 501
	return r <= maxResult ? r : maxResult;
}

A
Alex Dima 已提交
502
export let createLine: (context: IViewContext) => ViewLine = (function() {
E
Erich Gamma 已提交
503 504 505 506 507 508 509 510 511 512
	if (window.screen && window.screen.deviceXDPI && (navigator.userAgent.indexOf('Trident/6.0') >= 0 || navigator.userAgent.indexOf('Trident/5.0') >= 0)) {
		// IE11 doesn't need the screen.logicalXDPI / screen.deviceXDPI ratio multiplication
		// for TextRange.getClientRects() anymore
		return createIELine;
	} else if (Browser.isWebKit) {
		return createWebKitLine;
	}
	return createNormalLine;
})();

A
Alex Dima 已提交
513
function createIELine(context: IViewContext): ViewLine {
E
Erich Gamma 已提交
514 515 516
	return new IEViewLine(context);
}

A
Alex Dima 已提交
517
function createWebKitLine(context: IViewContext): ViewLine {
E
Erich Gamma 已提交
518 519 520
	return new WebKitViewLine(context);
}

A
Alex Dima 已提交
521
function createNormalLine(context: IViewContext): ViewLine {
E
Erich Gamma 已提交
522 523 524
	return new ViewLine(context);
}