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';
A
Alex Dima 已提交
8
import {FastDomNode, createFastDomNode} from 'vs/base/browser/styleMutator';
A
Alex Dima 已提交
9
import {HorizontalRange, IConfigurationChangedEvent, IModelDecoration} from 'vs/editor/common/editorCommon';
E
Erich Gamma 已提交
10
import {ILineParts, createLineParts} from 'vs/editor/common/viewLayout/viewLineParts';
A
Alex Dima 已提交
11
import {renderLine, RenderLineInput} from 'vs/editor/common/viewLayout/viewLineRenderer';
A
Alex Dima 已提交
12 13
import {ClassNames, IViewContext} from 'vs/editor/browser/editorBrowser';
import {IVisibleLineData} from 'vs/editor/browser/view/viewLayer';
E
Erich Gamma 已提交
14

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

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

	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
	public getDomNode(): HTMLElement {
A
Alex Dima 已提交
42 43 44 45
		if (!this._domNode) {
			return null;
		}
		return this._domNode.domNode;
E
Erich Gamma 已提交
46 47
	}
	public setDomNode(domNode:HTMLElement): void {
A
Alex Dima 已提交
48
		this._domNode = createFastDomNode(domNode);
E
Erich Gamma 已提交
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
	}

	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 已提交
69
	public onConfigurationChanged(e:IConfigurationChangedEvent): void {
E
Erich Gamma 已提交
70 71 72
		this._isInvalid = true;
	}

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

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

		// 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 已提交
113
		out.push(ClassNames.VIEW_LINE);
E
Erich Gamma 已提交
114 115 116 117 118 119 120
		out.push('">');
		out.push(this.getLineInnerHTML(lineNumber));
		out.push('</div>');
	}

	public getLineInnerHTML(lineNumber: number): string {
		this._isInvalid = false;
A
Alex Dima 已提交
121
		return this._render(lineNumber, this._lineParts).join('');
E
Erich Gamma 已提交
122 123 124
	}

	public layoutLine(lineNumber:number, deltaTop:number): void {
A
Alex Dima 已提交
125 126 127
		this._domNode.setLineNumber(String(lineNumber));
		this._domNode.setTop(deltaTop);
		this._domNode.setHeight(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 137 138 139 140 141 142
		let r = renderLine(new RenderLineInput(
			this._context.model.getLineContent(lineNumber),
			this._context.model.getTabSize(),
			this._context.configuration.editor.stopRenderingLineAfter,
			this._context.configuration.editor.renderWhitespace,
			lineParts.getParts()
		));
E
Erich Gamma 已提交
143 144 145 146 147 148 149 150 151

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

		return r.output;
	}

	// --- Reading from the DOM methods

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

	/**
	 * 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 171 172 173
		startColumn = +startColumn; // @perf
		endColumn = +endColumn; // @perf
		clientRectDeltaLeft = +clientRectDeltaLeft; // @perf
		let stopRenderingLineAfter = +this._context.configuration.editor.stopRenderingLineAfter; // @perf
E
Erich Gamma 已提交
174 175 176 177 178 179 180 181 182 183 184 185 186 187

		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;
		}

188
		return this._readVisibleRangesForRange(startColumn, endColumn, clientRectDeltaLeft, endNode);
E
Erich Gamma 已提交
189 190
	}

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

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

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

		result.sort(compareVisibleRanges);

A
Alex Dima 已提交
206 207
		let output: HorizontalRange[] = [];
		let prevRange: HorizontalRange = result[0];
E
Erich Gamma 已提交
208

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

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

		return output;
	}

224
	protected _readRawVisibleRangesForPosition(column:number, clientRectDeltaLeft:number, endNode:HTMLElement): HorizontalRange[] {
E
Erich Gamma 已提交
225 226 227

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

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

234
		return this._readRawVisibleRangesFrom(this._getReadingTarget(), partIndex, charOffsetInPart, partIndex, charOffsetInPart, clientRectDeltaLeft, endNode);
E
Erich Gamma 已提交
235 236
	}

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

		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 已提交
242
			return [this._readRawVisibleRangeForEntireLine()];
E
Erich Gamma 已提交
243 244
		}

A
Alex Dima 已提交
245 246 247 248
		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 已提交
249

250
		return this._readRawVisibleRangesFrom(this._getReadingTarget(), startPartIndex, startCharOffsetInPart, endPartIndex, endCharOffsetInPart, clientRectDeltaLeft, endNode);
E
Erich Gamma 已提交
251 252
	}

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

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

		try {
			// Panic check
A
Alex Dima 已提交
262 263
			let min = 0;
			let max = domNode.children.length - 1;
E
Erich Gamma 已提交
264 265 266 267 268 269 270
			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
271
			// Chrome is buggy and doesn't handle 0 offsets well sometimes.
E
Erich Gamma 已提交
272 273 274 275 276 277 278
			if (startChildIndex !== endChildIndex) {
				if (endChildIndex > 0 && endOffset === 0) {
					endChildIndex--;
					endOffset = Number.MAX_VALUE;
				}
			}

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

			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 已提交
292 293 294
			let clientRects = range.getClientRects();
			if (clientRects.length === 0) {
				return null;
E
Erich Gamma 已提交
295 296
			}

297
			return this._createRawVisibleRangesFromClientRects(clientRects, clientRectDeltaLeft);
E
Erich Gamma 已提交
298 299 300 301 302 303 304 305 306

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

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

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

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

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

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

		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 已提交
348 349
		let min = originalMin;
		let max = originalMax;
E
Erich Gamma 已提交
350 351 352 353 354

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

A
Alex Dima 已提交
355 356
		let nextStartOffset:number;
		let prevStartOffset:number;
E
Erich Gamma 已提交
357 358 359 360 361 362 363 364 365

		// 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 已提交
366 367
			let mid = Math.floor( (min + max) / 2 );
			let midStartOffset = this._charOffsetInPart[mid];
E
Erich Gamma 已提交
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385

			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 已提交
386 387
			let a = (prevStartOffset + midStartOffset) / 2;
			let b = (midStartOffset + nextStartOffset) / 2;
E
Erich Gamma 已提交
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406

			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 已提交
407
	constructor(context:IViewContext) {
E
Erich Gamma 已提交
408 409 410
		super(context);
	}

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

		return result;
	}
}

class WebKitViewLine extends ViewLine {

A
Alex Dima 已提交
425
	constructor(context:IViewContext) {
E
Erich Gamma 已提交
426 427 428
		super(context);
	}

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

432 433 434 435 436 437 438 439
		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;
440
			}
441
			return output;
442 443
		}

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

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

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

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

A
Andre Weinand 已提交
463
			if (isLTR && lastRange.left < endVisibleRange.left) {
E
Erich Gamma 已提交
464 465 466 467 468 469 470 471 472 473 474 475 476
				// 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
477
	 * because IE is buggy and constantly freezes when using a large number
E
Erich Gamma 已提交
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495
	 * 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 已提交
496
function compareVisibleRanges(a: HorizontalRange, b: HorizontalRange): number {
A
Andre Weinand 已提交
497
	return a.left - b.left;
E
Erich Gamma 已提交
498 499 500
}

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

A
Alex Dima 已提交
505
export let createLine: (context: IViewContext) => ViewLine = (function() {
E
Erich Gamma 已提交
506 507 508 509
	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;
A
Alex Dima 已提交
510
	} else if (browser.isWebKit) {
E
Erich Gamma 已提交
511 512 513 514 515
		return createWebKitLine;
	}
	return createNormalLine;
})();

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

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

A
Alex Dima 已提交
524
function createNormalLine(context: IViewContext): ViewLine {
E
Erich Gamma 已提交
525 526 527
	return new ViewLine(context);
}