提交 cedc357c 编写于 作者: A Alex Dima

Don't hold onto the rendered html in viewLine

上级 d6b4af10
...@@ -108,7 +108,7 @@ export class Colorizer { ...@@ -108,7 +108,7 @@ export class Colorizer {
'none', 'none',
false false
)); ));
return renderResult.output; return renderResult.html;
} }
public static colorizeModelLine(model: IModel, lineNumber: number, tabSize: number = 4): string { public static colorizeModelLine(model: IModel, lineNumber: number, tabSize: number = 4): string {
...@@ -143,7 +143,7 @@ function _fakeColorize(lines: string[], tabSize: number): string { ...@@ -143,7 +143,7 @@ function _fakeColorize(lines: string[], tabSize: number): string {
false false
)); ));
html = html.concat(renderResult.output); html = html.concat(renderResult.html);
html.push('<br/>'); html.push('<br/>');
} }
...@@ -173,7 +173,7 @@ function _actualColorize(lines: string[], tabSize: number, tokenizationSupport: ...@@ -173,7 +173,7 @@ function _actualColorize(lines: string[], tabSize: number, tokenizationSupport:
false false
)); ));
html = html.concat(renderResult.output); html = html.concat(renderResult.html);
html.push('<br/>'); html.push('<br/>');
state = tokenizeResult.endState; state = tokenizeResult.endState;
......
...@@ -19,11 +19,16 @@ export interface IVisibleLine { ...@@ -19,11 +19,16 @@ export interface IVisibleLine {
onContentChanged(): void; onContentChanged(): void;
onTokensChanged(): void; onTokensChanged(): void;
onConfigurationChanged(e: editorCommon.IConfigurationChangedEvent): void;
getLineOuterHTML(out: string[], lineNumber: number, deltaTop: number): void; /**
* Return null if the HTML should not be touched.
* Return the new HTML otherwise.
*/
renderLine(lineNumber: number, deltaTop: number, viewportData: ViewportData): string;
shouldUpdateHTML(lineNumber: number, viewportData: ViewportData): boolean; /**
* Layout the line.
*/
layoutLine(lineNumber: number, deltaTop: number): void; layoutLine(lineNumber: number, deltaTop: number): void;
} }
...@@ -267,16 +272,6 @@ export abstract class ViewLayer<T extends IVisibleLine> extends ViewPart { ...@@ -267,16 +272,6 @@ export abstract class ViewLayer<T extends IVisibleLine> extends ViewPart {
// ---- begin view event handlers // ---- begin view event handlers
public onConfigurationChanged(e: editorCommon.IConfigurationChangedEvent): boolean {
let startLineNumber = this._linesCollection.getStartLineNumber();
let endLineNumber = this._linesCollection.getEndLineNumber();
for (let lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) {
let line = this._linesCollection.getLine(lineNumber);
line.onConfigurationChanged(e);
}
return true;
}
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean { public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
return true; return true;
} }
...@@ -487,12 +482,12 @@ class ViewLayerRenderer<T extends IVisibleLine> { ...@@ -487,12 +482,12 @@ class ViewLayerRenderer<T extends IVisibleLine> {
} }
private _renderUntouchedLines(ctx: IRendererContext<T>, startIndex: number, endIndex: number, deltaTop: number[], deltaLN: number): void { private _renderUntouchedLines(ctx: IRendererContext<T>, startIndex: number, endIndex: number, deltaTop: number[], deltaLN: number): void {
const rendLineNumberStart = ctx.rendLineNumberStart;
const lines = ctx.lines;
for (let i = startIndex; i <= endIndex; i++) { for (let i = startIndex; i <= endIndex; i++) {
let lineNumber = ctx.rendLineNumberStart + i; let lineNumber = rendLineNumberStart + i;
let lineDomNode = ctx.lines[i].getDomNode(); lines[i].layoutLine(lineNumber, deltaTop[lineNumber - deltaLN]);
if (lineDomNode) {
ctx.lines[i].layoutLine(lineNumber, deltaTop[lineNumber - deltaLN]);
}
} }
} }
...@@ -617,16 +612,22 @@ class ViewLayerRenderer<T extends IVisibleLine> { ...@@ -617,16 +612,22 @@ class ViewLayerRenderer<T extends IVisibleLine> {
let line = ctx.lines[i]; let line = ctx.lines[i];
let lineNumber = i + ctx.rendLineNumberStart; let lineNumber = i + ctx.rendLineNumberStart;
if (line.shouldUpdateHTML(lineNumber, ctx.viewportData)) { wasNew[i] = false;
wasInvalid[i] = false;
let renderResult = line.renderLine(lineNumber, deltaTop[i], ctx.viewportData);
if (renderResult !== null) {
// Line needs rendering
let lineDomNode = line.getDomNode(); let lineDomNode = line.getDomNode();
if (!lineDomNode) { if (!lineDomNode) {
// Line is new // Line is new
line.getLineOuterHTML(newLinesHTML, lineNumber, deltaTop[i]); newLinesHTML.push(renderResult);
wasNew[i] = true; wasNew[i] = true;
hadNewLine = true; hadNewLine = true;
} else { } else {
// Line is invalid // Line is invalid
line.getLineOuterHTML(invalidLinesHTML, lineNumber, deltaTop[i]); invalidLinesHTML.push(renderResult);
wasInvalid[i] = true; wasInvalid[i] = true;
hadInvalidLine = true; hadInvalidLine = true;
} }
......
...@@ -67,6 +67,17 @@ export class ViewOverlays extends ViewLayer<ViewOverlayLine> { ...@@ -67,6 +67,17 @@ export class ViewOverlays extends ViewLayer<ViewOverlayLine> {
// ----- event handlers // ----- event handlers
public onConfigurationChanged(e: IConfigurationChangedEvent): boolean {
super.onConfigurationChanged(e);
let startLineNumber = this._linesCollection.getStartLineNumber();
let endLineNumber = this._linesCollection.getEndLineNumber();
for (let lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) {
let line = this._linesCollection.getLine(lineNumber);
line.onConfigurationChanged(e);
}
return true;
}
public onViewFocusChanged(isFocused: boolean): boolean { public onViewFocusChanged(isFocused: boolean): boolean {
this._isFocused = isFocused; this._isFocused = isFocused;
return true; return true;
...@@ -108,7 +119,7 @@ export class ViewOverlayLine implements IVisibleLine { ...@@ -108,7 +119,7 @@ export class ViewOverlayLine implements IVisibleLine {
private _configuration: IConfiguration; private _configuration: IConfiguration;
private _dynamicOverlays: DynamicViewOverlay[]; private _dynamicOverlays: DynamicViewOverlay[];
private _domNode: FastDomNode; private _domNode: FastDomNode;
private _renderPieces: string; private _renderedContent: string;
private _lineHeight: number; private _lineHeight: number;
constructor(configuration: IConfiguration, dynamicOverlays: DynamicViewOverlay[]) { constructor(configuration: IConfiguration, dynamicOverlays: DynamicViewOverlay[]) {
...@@ -117,7 +128,7 @@ export class ViewOverlayLine implements IVisibleLine { ...@@ -117,7 +128,7 @@ export class ViewOverlayLine implements IVisibleLine {
this._dynamicOverlays = dynamicOverlays; this._dynamicOverlays = dynamicOverlays;
this._domNode = null; this._domNode = null;
this._renderPieces = null; this._renderedContent = null;
} }
public getDomNode(): HTMLElement { public getDomNode(): HTMLElement {
...@@ -142,36 +153,29 @@ export class ViewOverlayLine implements IVisibleLine { ...@@ -142,36 +153,29 @@ export class ViewOverlayLine implements IVisibleLine {
} }
} }
public shouldUpdateHTML(lineNumber: number, viewportData: ViewportData): boolean { public renderLine(lineNumber: number, deltaTop: number, viewportData: ViewportData): string {
let newPieces = ''; let result = '';
for (let i = 0, len = this._dynamicOverlays.length; i < len; i++) { for (let i = 0, len = this._dynamicOverlays.length; i < len; i++) {
let dynamicOverlay = this._dynamicOverlays[i]; let dynamicOverlay = this._dynamicOverlays[i];
newPieces += dynamicOverlay.render(viewportData.startLineNumber, lineNumber); result += dynamicOverlay.render(viewportData.startLineNumber, lineNumber);
} }
let piecesEqual = (this._renderPieces === newPieces); if (this._renderedContent === result) {
// No rendering needed
if (!piecesEqual) { return null;
this._renderPieces = newPieces;
} }
return !piecesEqual; this._renderedContent = result;
}
public getLineOuterHTML(out: string[], lineNumber: number, deltaTop: number): void { return `<div lineNumber="${lineNumber}" style="position:absolute;top:${deltaTop}px;width:100%;height:${this._lineHeight}px;">${result}</div>`;
out.push(`<div lineNumber="${lineNumber}" style="position:absolute;top:${deltaTop}px;width:100%;height:${this._lineHeight}px;">`);
out.push(this.getLineInnerHTML(lineNumber));
out.push(`</div>`);
}
private getLineInnerHTML(lineNumber: number): string {
return this._renderPieces;
} }
public layoutLine(lineNumber: number, deltaTop: number): void { public layoutLine(lineNumber: number, deltaTop: number): void {
this._domNode.setLineNumber(String(lineNumber)); if (this._domNode) {
this._domNode.setTop(deltaTop); this._domNode.setLineNumber(String(lineNumber));
this._domNode.setHeight(this._lineHeight); this._domNode.setTop(deltaTop);
this._domNode.setHeight(this._lineHeight);
}
} }
} }
......
...@@ -8,9 +8,9 @@ import * as browser from 'vs/base/browser/browser'; ...@@ -8,9 +8,9 @@ import * as browser from 'vs/base/browser/browser';
import * as platform from 'vs/base/common/platform'; import * as platform from 'vs/base/common/platform';
import * as strings from 'vs/base/common/strings'; import * as strings from 'vs/base/common/strings';
import { FastDomNode, createFastDomNode } from 'vs/base/browser/styleMutator'; import { FastDomNode, createFastDomNode } from 'vs/base/browser/styleMutator';
import { IConfiguration, IConfigurationChangedEvent } from 'vs/editor/common/editorCommon'; import { IConfiguration } from 'vs/editor/common/editorCommon';
import { Decoration } from 'vs/editor/common/viewLayout/viewLineParts'; import { Decoration } from 'vs/editor/common/viewLayout/viewLineParts';
import { renderViewLine, RenderLineInput, RenderLineOutput, CharacterMapping } from 'vs/editor/common/viewLayout/viewLineRenderer'; import { renderViewLine, RenderLineInput, CharacterMapping } from 'vs/editor/common/viewLayout/viewLineRenderer';
import { ClassNames } from 'vs/editor/browser/editorBrowser'; import { ClassNames } from 'vs/editor/browser/editorBrowser';
import { IVisibleLine } from 'vs/editor/browser/view/viewLayer'; import { IVisibleLine } from 'vs/editor/browser/view/viewLayer';
import { RangeUtil } from 'vs/editor/browser/viewParts/lines/rangeUtil'; import { RangeUtil } from 'vs/editor/browser/viewParts/lines/rangeUtil';
...@@ -65,7 +65,7 @@ export class DomReadingContext { ...@@ -65,7 +65,7 @@ export class DomReadingContext {
} }
class ViewLineOptions { export class ViewLineOptions {
public readonly renderWhitespace: 'none' | 'boundary' | 'all'; public readonly renderWhitespace: 'none' | 'boundary' | 'all';
public readonly renderControlCharacters: boolean; public readonly renderControlCharacters: boolean;
public readonly spaceWidth: number; public readonly spaceWidth: number;
...@@ -99,14 +99,12 @@ class ViewLineOptions { ...@@ -99,14 +99,12 @@ class ViewLineOptions {
export class ViewLine implements IVisibleLine { export class ViewLine implements IVisibleLine {
private readonly _configuration: IConfiguration;
private _options: ViewLineOptions; private _options: ViewLineOptions;
private _isMaybeInvalid: boolean; private _isMaybeInvalid: boolean;
private _renderedViewLine: IRenderedViewLine; private _renderedViewLine: IRenderedViewLine;
constructor(configuration: IConfiguration) { constructor(options: ViewLineOptions) {
this._configuration = configuration; this._options = options;
this._options = new ViewLineOptions(this._configuration);
this._isMaybeInvalid = true; this._isMaybeInvalid = true;
this._renderedViewLine = null; this._renderedViewLine = null;
} }
...@@ -136,28 +134,22 @@ export class ViewLine implements IVisibleLine { ...@@ -136,28 +134,22 @@ export class ViewLine implements IVisibleLine {
public onModelDecorationsChanged(): void { public onModelDecorationsChanged(): void {
this._isMaybeInvalid = true; this._isMaybeInvalid = true;
} }
public onConfigurationChanged(e: IConfigurationChangedEvent): void { public onOptionsChanged(newOptions: ViewLineOptions): void {
let newOptions = new ViewLineOptions(this._configuration);
if (this._options.equals(newOptions)) {
// Nothing changed
return;
}
this._isMaybeInvalid = true; this._isMaybeInvalid = true;
this._options = newOptions; this._options = newOptions;
} }
public shouldUpdateHTML(lineNumber: number, viewportData: ViewportData): boolean { public renderLine(lineNumber: number, deltaTop: number, viewportData: ViewportData): string {
if (this._isMaybeInvalid === false) { if (this._isMaybeInvalid === false) {
// it appears that nothing relevant has changed // it appears that nothing relevant has changed
return false; return null;
} }
this._isMaybeInvalid = false; this._isMaybeInvalid = false;
const lineData = viewportData.getViewLineRenderingData(lineNumber); const lineData = viewportData.getViewLineRenderingData(lineNumber);
const options = this._options; const options = this._options;
const actualInlineDecorations = Decoration.filter(lineData.inlineDecorations, lineNumber, lineData.minColumn, lineData.maxColumn); const actualInlineDecorations = Decoration.filter(lineData.inlineDecorations, lineNumber, lineData.minColumn, lineData.maxColumn);
let renderLineInput = new RenderLineInput( let renderLineInput = new RenderLineInput(
options.useMonospaceOptimizations, options.useMonospaceOptimizations,
lineData.content, lineData.content,
...@@ -174,7 +166,7 @@ export class ViewLine implements IVisibleLine { ...@@ -174,7 +166,7 @@ export class ViewLine implements IVisibleLine {
if (this._renderedViewLine && this._renderedViewLine.input.equals(renderLineInput)) { if (this._renderedViewLine && this._renderedViewLine.input.equals(renderLineInput)) {
// no need to do anything, we have the same render input // no need to do anything, we have the same render input
return false; return null;
} }
const output = renderViewLine(renderLineInput); const output = renderViewLine(renderLineInput);
...@@ -192,40 +184,31 @@ export class ViewLine implements IVisibleLine { ...@@ -192,40 +184,31 @@ export class ViewLine implements IVisibleLine {
renderedViewLine = new FastRenderedViewLine( renderedViewLine = new FastRenderedViewLine(
this._renderedViewLine ? this._renderedViewLine.domNode : null, this._renderedViewLine ? this._renderedViewLine.domNode : null,
renderLineInput, renderLineInput,
output output.characterMapping
); );
} }
} }
if (!renderedViewLine) { if (!renderedViewLine) {
let isWhitespaceOnly = /^\s*$/.test(renderLineInput.lineContent);
renderedViewLine = createRenderedLine( renderedViewLine = createRenderedLine(
this._renderedViewLine ? this._renderedViewLine.domNode : null, this._renderedViewLine ? this._renderedViewLine.domNode : null,
renderLineInput, renderLineInput,
isWhitespaceOnly, output.characterMapping,
output output.containsRTL
); );
} }
this._renderedViewLine = renderedViewLine; this._renderedViewLine = renderedViewLine;
return true; return `<div lineNumber="${lineNumber}" style="top:${deltaTop}px;height:${this._options.lineHeight}px;" class="${ClassNames.VIEW_LINE}">${output.html}</div>`;
}
public getLineOuterHTML(out: string[], lineNumber: number, deltaTop: number): void {
out.push(`<div lineNumber="${lineNumber}" style="top:${deltaTop}px;height:${this._options.lineHeight}px;" class="${ClassNames.VIEW_LINE}">`);
out.push(this.getLineInnerHTML(lineNumber));
out.push(`</div>`);
}
private getLineInnerHTML(lineNumber: number): string {
return this._renderedViewLine.html;
} }
public layoutLine(lineNumber: number, deltaTop: number): void { public layoutLine(lineNumber: number, deltaTop: number): void {
this._renderedViewLine.domNode.setLineNumber(String(lineNumber)); if (this._renderedViewLine && this._renderedViewLine.domNode) {
this._renderedViewLine.domNode.setTop(deltaTop); this._renderedViewLine.domNode.setLineNumber(String(lineNumber));
this._renderedViewLine.domNode.setHeight(this._options.lineHeight); this._renderedViewLine.domNode.setTop(deltaTop);
this._renderedViewLine.domNode.setHeight(this._options.lineHeight);
}
} }
// --- end IVisibleLineData // --- end IVisibleLineData
...@@ -249,7 +232,6 @@ export class ViewLine implements IVisibleLine { ...@@ -249,7 +232,6 @@ export class ViewLine implements IVisibleLine {
interface IRenderedViewLine { interface IRenderedViewLine {
domNode: FastDomNode; domNode: FastDomNode;
readonly input: RenderLineInput; readonly input: RenderLineInput;
readonly html: string;
getWidth(): number; getWidth(): number;
getVisibleRangesForRange(startColumn: number, endColumn: number, context: DomReadingContext): HorizontalRange[]; getVisibleRangesForRange(startColumn: number, endColumn: number, context: DomReadingContext): HorizontalRange[];
getColumnOfNodeOffset(lineNumber: number, spanNode: HTMLElement, offset: number): number; getColumnOfNodeOffset(lineNumber: number, spanNode: HTMLElement, offset: number): number;
...@@ -262,20 +244,18 @@ class FastRenderedViewLine implements IRenderedViewLine { ...@@ -262,20 +244,18 @@ class FastRenderedViewLine implements IRenderedViewLine {
public domNode: FastDomNode; public domNode: FastDomNode;
public readonly input: RenderLineInput; public readonly input: RenderLineInput;
public readonly html: string;
private readonly _characterMapping: CharacterMapping; private readonly _characterMapping: CharacterMapping;
private readonly _charWidth: number; private readonly _charWidth: number;
private readonly _charOffset: Uint32Array; private readonly _charOffset: Uint32Array;
constructor(domNode: FastDomNode, renderLineInput: RenderLineInput, renderLineOutput: RenderLineOutput) { constructor(domNode: FastDomNode, renderLineInput: RenderLineInput, characterMapping: CharacterMapping) {
this.domNode = domNode; this.domNode = domNode;
this.input = renderLineInput; this.input = renderLineInput;
this.html = renderLineOutput.output;
this._characterMapping = renderLineOutput.characterMapping; this._characterMapping = characterMapping;
this._charWidth = renderLineInput.spaceWidth; this._charWidth = renderLineInput.spaceWidth;
this._charOffset = FastRenderedViewLine._createCharOffset(renderLineOutput.characterMapping); this._charOffset = FastRenderedViewLine._createCharOffset(characterMapping);
} }
private static _createCharOffset(characterMapping: CharacterMapping): Uint32Array { private static _createCharOffset(characterMapping: CharacterMapping): Uint32Array {
...@@ -357,7 +337,6 @@ class RenderedViewLine { ...@@ -357,7 +337,6 @@ class RenderedViewLine {
public domNode: FastDomNode; public domNode: FastDomNode;
public readonly input: RenderLineInput; public readonly input: RenderLineInput;
public readonly html: string;
protected readonly _characterMapping: CharacterMapping; protected readonly _characterMapping: CharacterMapping;
private readonly _isWhitespaceOnly: boolean; private readonly _isWhitespaceOnly: boolean;
...@@ -368,16 +347,15 @@ class RenderedViewLine { ...@@ -368,16 +347,15 @@ class RenderedViewLine {
*/ */
private _pixelOffsetCache: Int32Array; private _pixelOffsetCache: Int32Array;
constructor(domNode: FastDomNode, renderLineInput: RenderLineInput, isWhitespaceOnly: boolean, renderLineOutput: RenderLineOutput) { constructor(domNode: FastDomNode, renderLineInput: RenderLineInput, characterMapping: CharacterMapping, containsRTL: boolean) {
this.domNode = domNode; this.domNode = domNode;
this.input = renderLineInput; this.input = renderLineInput;
this.html = renderLineOutput.output; this._characterMapping = characterMapping;
this._characterMapping = renderLineOutput.characterMapping; this._isWhitespaceOnly = /^\s*$/.test(renderLineInput.lineContent);
this._isWhitespaceOnly = isWhitespaceOnly;
this._cachedWidth = -1; this._cachedWidth = -1;
this._pixelOffsetCache = null; this._pixelOffsetCache = null;
if (!renderLineOutput.containsRTL) { if (!containsRTL) {
this._pixelOffsetCache = new Int32Array(this._characterMapping.length + 1); this._pixelOffsetCache = new Int32Array(this._characterMapping.length + 1);
for (let column = 0, len = this._characterMapping.length; column <= len; column++) { for (let column = 0, len = this._characterMapping.length; column <= len; column++) {
this._pixelOffsetCache[column] = -1; this._pixelOffsetCache[column] = -1;
...@@ -560,17 +538,17 @@ class WebKitRenderedViewLine extends RenderedViewLine { ...@@ -560,17 +538,17 @@ class WebKitRenderedViewLine extends RenderedViewLine {
} }
} }
const createRenderedLine: (domNode: FastDomNode, renderLineInput: RenderLineInput, isWhitespaceOnly: boolean, renderLineOutput: RenderLineOutput) => RenderedViewLine = (function () { const createRenderedLine: (domNode: FastDomNode, renderLineInput: RenderLineInput, characterMapping: CharacterMapping, containsRTL: boolean) => RenderedViewLine = (function () {
if (browser.isWebKit) { if (browser.isWebKit) {
return createWebKitRenderedLine; return createWebKitRenderedLine;
} }
return createNormalRenderedLine; return createNormalRenderedLine;
})(); })();
function createWebKitRenderedLine(domNode: FastDomNode, renderLineInput: RenderLineInput, isWhitespaceOnly: boolean, renderLineOutput: RenderLineOutput): RenderedViewLine { function createWebKitRenderedLine(domNode: FastDomNode, renderLineInput: RenderLineInput, characterMapping: CharacterMapping, containsRTL: boolean): RenderedViewLine {
return new WebKitRenderedViewLine(domNode, renderLineInput, isWhitespaceOnly, renderLineOutput); return new WebKitRenderedViewLine(domNode, renderLineInput, characterMapping, containsRTL);
} }
function createNormalRenderedLine(domNode: FastDomNode, renderLineInput: RenderLineInput, isWhitespaceOnly: boolean, renderLineOutput: RenderLineOutput): RenderedViewLine { function createNormalRenderedLine(domNode: FastDomNode, renderLineInput: RenderLineInput, characterMapping: CharacterMapping, containsRTL: boolean): RenderedViewLine {
return new RenderedViewLine(domNode, renderLineInput, isWhitespaceOnly, renderLineOutput); return new RenderedViewLine(domNode, renderLineInput, characterMapping, containsRTL);
} }
...@@ -12,7 +12,7 @@ import { Position } from 'vs/editor/common/core/position'; ...@@ -12,7 +12,7 @@ import { Position } from 'vs/editor/common/core/position';
import * as editorCommon from 'vs/editor/common/editorCommon'; import * as editorCommon from 'vs/editor/common/editorCommon';
import { ClassNames } from 'vs/editor/browser/editorBrowser'; import { ClassNames } from 'vs/editor/browser/editorBrowser';
import { ViewLayer } from 'vs/editor/browser/view/viewLayer'; import { ViewLayer } from 'vs/editor/browser/view/viewLayer';
import { DomReadingContext, ViewLine } from 'vs/editor/browser/viewParts/lines/viewLine'; import { ViewLineOptions, DomReadingContext, ViewLine } from 'vs/editor/browser/viewParts/lines/viewLine';
import { Configuration } from 'vs/editor/browser/config/configuration'; import { Configuration } from 'vs/editor/browser/config/configuration';
import { ViewContext } from 'vs/editor/common/view/viewContext'; import { ViewContext } from 'vs/editor/common/view/viewContext';
import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'; import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData';
...@@ -66,6 +66,7 @@ export class ViewLines extends ViewLayer<ViewLine> implements IViewLines { ...@@ -66,6 +66,7 @@ export class ViewLines extends ViewLayer<ViewLine> implements IViewLines {
private _isViewportWrapping: boolean; private _isViewportWrapping: boolean;
private _revealHorizontalRightPadding: number; private _revealHorizontalRightPadding: number;
private _canUseTranslate3d: boolean; private _canUseTranslate3d: boolean;
private _viewLineOptions: ViewLineOptions;
// --- width // --- width
private _maxLineWidth: number; private _maxLineWidth: number;
...@@ -79,7 +80,8 @@ export class ViewLines extends ViewLayer<ViewLine> implements IViewLines { ...@@ -79,7 +80,8 @@ export class ViewLines extends ViewLayer<ViewLine> implements IViewLines {
this._lineHeight = this._context.configuration.editor.lineHeight; this._lineHeight = this._context.configuration.editor.lineHeight;
this._isViewportWrapping = this._context.configuration.editor.wrappingInfo.isViewportWrapping; this._isViewportWrapping = this._context.configuration.editor.wrappingInfo.isViewportWrapping;
this._revealHorizontalRightPadding = this._context.configuration.editor.viewInfo.revealHorizontalRightPadding; this._revealHorizontalRightPadding = this._context.configuration.editor.viewInfo.revealHorizontalRightPadding;
this._canUseTranslate3d = context.configuration.editor.viewInfo.canUseTranslate3d; this._canUseTranslate3d = this._context.configuration.editor.viewInfo.canUseTranslate3d;
this._viewLineOptions = new ViewLineOptions(this._context.configuration);
this._layoutProvider = layoutProvider; this._layoutProvider = layoutProvider;
PartFingerprints.write(this.domNode.domNode, PartFingerprint.ViewLines); PartFingerprints.write(this.domNode.domNode, PartFingerprint.ViewLines);
...@@ -112,7 +114,7 @@ export class ViewLines extends ViewLayer<ViewLine> implements IViewLines { ...@@ -112,7 +114,7 @@ export class ViewLines extends ViewLayer<ViewLine> implements IViewLines {
// ---- begin view event handlers // ---- begin view event handlers
public onConfigurationChanged(e: editorCommon.IConfigurationChangedEvent): boolean { public onConfigurationChanged(e: editorCommon.IConfigurationChangedEvent): boolean {
let shouldRender = super.onConfigurationChanged(e); super.onConfigurationChanged(e);
if (e.wrappingInfo) { if (e.wrappingInfo) {
this._maxLineWidth = 0; this._maxLineWidth = 0;
} }
...@@ -133,7 +135,19 @@ export class ViewLines extends ViewLayer<ViewLine> implements IViewLines { ...@@ -133,7 +135,19 @@ export class ViewLines extends ViewLayer<ViewLine> implements IViewLines {
Configuration.applyFontInfo(this.domNode, this._context.configuration.editor.fontInfo); Configuration.applyFontInfo(this.domNode, this._context.configuration.editor.fontInfo);
} }
return shouldRender; let newViewLineOptions = new ViewLineOptions(this._context.configuration);
if (!this._viewLineOptions.equals(newViewLineOptions)) {
this._viewLineOptions = newViewLineOptions;
let startLineNumber = this._linesCollection.getStartLineNumber();
let endLineNumber = this._linesCollection.getEndLineNumber();
for (let lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) {
let line = this._linesCollection.getLine(lineNumber);
line.onOptionsChanged(this._viewLineOptions);
}
}
return true;
} }
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean { public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
...@@ -350,8 +364,8 @@ export class ViewLines extends ViewLayer<ViewLine> implements IViewLines { ...@@ -350,8 +364,8 @@ export class ViewLines extends ViewLayer<ViewLine> implements IViewLines {
// --- implementation // --- implementation
_createLine(): ViewLine { protected _createLine(): ViewLine {
return new ViewLine(this._context.configuration); return new ViewLine(this._viewLineOptions);
} }
private _updateLineWidths(): void { private _updateLineWidths(): void {
......
...@@ -1916,7 +1916,7 @@ class InlineViewZonesComputer extends ViewZonesComputer { ...@@ -1916,7 +1916,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
myResult.push('" style="top:'); myResult.push('" style="top:');
myResult.push(String(count * config.lineHeight)); myResult.push(String(count * config.lineHeight));
myResult.push('px;width:1000000px;">'); myResult.push('px;width:1000000px;">');
myResult = myResult.concat(r.output); myResult = myResult.concat(r.html);
myResult.push('</div>'); myResult.push('</div>');
return myResult; return myResult;
......
...@@ -204,13 +204,13 @@ export class RenderLineOutput { ...@@ -204,13 +204,13 @@ export class RenderLineOutput {
_renderLineOutputBrand: void; _renderLineOutputBrand: void;
readonly characterMapping: CharacterMapping; readonly characterMapping: CharacterMapping;
readonly output: string; readonly html: string;
readonly containsRTL: boolean; readonly containsRTL: boolean;
readonly containsForeignElements: boolean; readonly containsForeignElements: boolean;
constructor(characterMapping: CharacterMapping, output: string, containsRTL: boolean, containsForeignElements: boolean) { constructor(characterMapping: CharacterMapping, html: string, containsRTL: boolean, containsForeignElements: boolean) {
this.characterMapping = characterMapping; this.characterMapping = characterMapping;
this.output = output; this.html = html;
this.containsRTL = containsRTL; this.containsRTL = containsRTL;
this.containsForeignElements = containsForeignElements; this.containsForeignElements = containsForeignElements;
} }
......
...@@ -70,7 +70,7 @@ suite('Editor ViewLayout - ViewLineParts', () => { ...@@ -70,7 +70,7 @@ suite('Editor ViewLayout - ViewLineParts', () => {
false false
)); ));
assert.deepEqual(actual.output.split(/></g), expected.split(/></g)); assert.deepEqual(actual.html.split(/></g), expected.split(/></g));
} }
test('issue #18616: Inline decorations ending at the text length are no longer rendered', () => { test('issue #18616: Inline decorations ending at the text length are no longer rendered', () => {
...@@ -97,7 +97,7 @@ suite('Editor ViewLayout - ViewLineParts', () => { ...@@ -97,7 +97,7 @@ suite('Editor ViewLayout - ViewLineParts', () => {
'</span>' '</span>'
].join(''); ].join('');
assert.deepEqual(actual.output, expected); assert.deepEqual(actual.html, expected);
}); });
test('issue #19207: Link in Monokai is not rendered correctly', () => { test('issue #19207: Link in Monokai is not rendered correctly', () => {
...@@ -138,7 +138,7 @@ suite('Editor ViewLayout - ViewLineParts', () => { ...@@ -138,7 +138,7 @@ suite('Editor ViewLayout - ViewLineParts', () => {
'</span>' '</span>'
].join(''); ].join('');
assert.deepEqual(actual.output, expected); assert.deepEqual(actual.html, expected);
}); });
test('createLineParts simple', () => { test('createLineParts simple', () => {
...@@ -391,7 +391,7 @@ suite('Editor ViewLayout - ViewLineParts', () => { ...@@ -391,7 +391,7 @@ suite('Editor ViewLayout - ViewLineParts', () => {
// bb--------- // bb---------
// -cccccc---- // -cccccc----
assert.deepEqual(actual.output, [ assert.deepEqual(actual.html, [
'<span>', '<span>',
'<span class=" b">H</span>', '<span class=" b">H</span>',
'<span class=" b c">e</span>', '<span class=" b c">e</span>',
......
...@@ -30,7 +30,7 @@ suite('viewLineRenderer.renderLine', () => { ...@@ -30,7 +30,7 @@ suite('viewLineRenderer.renderLine', () => {
false false
)); ));
assert.equal(_actual.output, '<span><span class="">' + expected + '</span></span>'); assert.equal(_actual.html, '<span><span class="">' + expected + '</span></span>');
assertCharacterMapping(_actual.characterMapping, expectedCharOffsetInPart); assertCharacterMapping(_actual.characterMapping, expectedCharOffsetInPart);
assertPartLengths(_actual.characterMapping, expectedPartLengts); assertPartLengths(_actual.characterMapping, expectedPartLengts);
} }
...@@ -77,7 +77,7 @@ suite('viewLineRenderer.renderLine', () => { ...@@ -77,7 +77,7 @@ suite('viewLineRenderer.renderLine', () => {
false false
)); ));
assert.equal(_actual.output, '<span>' + expected + '</span>'); assert.equal(_actual.html, '<span>' + expected + '</span>');
assertCharacterMapping(_actual.characterMapping, expectedCharOffsetInPart); assertCharacterMapping(_actual.characterMapping, expectedCharOffsetInPart);
assertPartLengths(_actual.characterMapping, expectedPartLengts); assertPartLengths(_actual.characterMapping, expectedPartLengts);
} }
...@@ -136,7 +136,7 @@ suite('viewLineRenderer.renderLine', () => { ...@@ -136,7 +136,7 @@ suite('viewLineRenderer.renderLine', () => {
'<span class="vs-whitespace">&hellip;</span>' '<span class="vs-whitespace">&hellip;</span>'
].join(''); ].join('');
assert.equal(_actual.output, '<span>' + expectedOutput + '</span>'); assert.equal(_actual.html, '<span>' + expectedOutput + '</span>');
assertCharacterMapping(_actual.characterMapping, [ assertCharacterMapping(_actual.characterMapping, [
[0], [0],
[0], [0],
...@@ -211,7 +211,7 @@ suite('viewLineRenderer.renderLine', () => { ...@@ -211,7 +211,7 @@ suite('viewLineRenderer.renderLine', () => {
false false
)); ));
assert.equal(_actual.output, '<span>' + expectedOutput + '</span>'); assert.equal(_actual.html, '<span>' + expectedOutput + '</span>');
assertCharacterMapping(_actual.characterMapping, expectedOffsetsArr); assertCharacterMapping(_actual.characterMapping, expectedOffsetsArr);
assertPartLengths(_actual.characterMapping, [4, 4, 6, 1, 5, 1, 4, 1, 1, 1, 3, 15, 2, 3]); assertPartLengths(_actual.characterMapping, [4, 4, 6, 1, 5, 1, 4, 1, 1, 1, 3, 15, 2, 3]);
}); });
...@@ -270,7 +270,7 @@ suite('viewLineRenderer.renderLine', () => { ...@@ -270,7 +270,7 @@ suite('viewLineRenderer.renderLine', () => {
false false
)); ));
assert.equal(_actual.output, '<span>' + expectedOutput + '</span>'); assert.equal(_actual.html, '<span>' + expectedOutput + '</span>');
assertCharacterMapping(_actual.characterMapping, expectedOffsetsArr); assertCharacterMapping(_actual.characterMapping, expectedOffsetsArr);
assertPartLengths(_actual.characterMapping, [12, 12, 24, 1, 21, 2, 1, 20, 1, 1]); assertPartLengths(_actual.characterMapping, [12, 12, 24, 1, 21, 2, 1, 20, 1, 1]);
}); });
...@@ -329,7 +329,7 @@ suite('viewLineRenderer.renderLine', () => { ...@@ -329,7 +329,7 @@ suite('viewLineRenderer.renderLine', () => {
false false
)); ));
assert.equal(_actual.output, '<span>' + expectedOutput + '</span>'); assert.equal(_actual.html, '<span>' + expectedOutput + '</span>');
assertCharacterMapping(_actual.characterMapping, expectedOffsetsArr); assertCharacterMapping(_actual.characterMapping, expectedOffsetsArr);
assertPartLengths(_actual.characterMapping, [12, 12, 24, 1, 21, 2, 1, 20, 1, 1]); assertPartLengths(_actual.characterMapping, [12, 12, 24, 1, 21, 2, 1, 20, 1, 1]);
}); });
...@@ -365,7 +365,7 @@ suite('viewLineRenderer.renderLine', () => { ...@@ -365,7 +365,7 @@ suite('viewLineRenderer.renderLine', () => {
false false
)); ));
assert.equal(_actual.output, '<span>' + expectedOutput + '</span>'); assert.equal(_actual.html, '<span>' + expectedOutput + '</span>');
assert.equal(_actual.containsRTL, true); assert.equal(_actual.containsRTL, true);
}); });
...@@ -390,7 +390,7 @@ suite('viewLineRenderer.renderLine', () => { ...@@ -390,7 +390,7 @@ suite('viewLineRenderer.renderLine', () => {
'none', 'none',
false false
)); ));
assert.equal(actual.output, '<span>' + expectedOutput.join('') + '</span>', message); assert.equal(actual.html, '<span>' + expectedOutput.join('') + '</span>', message);
} }
// A token with 49 chars // A token with 49 chars
...@@ -484,7 +484,7 @@ suite('viewLineRenderer.renderLine', () => { ...@@ -484,7 +484,7 @@ suite('viewLineRenderer.renderLine', () => {
'none', 'none',
false false
)); ));
assert.equal(actual.output, '<span>' + expectedOutput.join('') + '</span>'); assert.equal(actual.html, '<span>' + expectedOutput.join('') + '</span>');
assert.equal(actual.containsRTL, true); assert.equal(actual.containsRTL, true);
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册