Skip to content

Commit

Permalink
Merge pull request #4680 from Tyriar/crash
Browse files Browse the repository at this point in the history
Revert Stylesheet change
  • Loading branch information
Tyriar committed Aug 15, 2023
2 parents 2eca26b + 843bdc4 commit 1a3e14a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 62 deletions.
23 changes: 12 additions & 11 deletions src/browser/renderer/dom/DomRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { color } from 'common/Color';
import { EventEmitter } from 'common/EventEmitter';
import { Disposable, toDisposable } from 'common/Lifecycle';
import { IBufferService, IInstantiationService, IOptionsService } from 'common/services/Services';
import { createStyle, IStyleSheet } from './StyleSheet';


const TERMINAL_CLASS_PREFIX = 'xterm-dom-renderer-owner-';
Expand All @@ -36,8 +35,8 @@ export class DomRenderer extends Disposable implements IRenderer {
private _rowFactory: DomRendererRowFactory;
private _terminalClass: number = nextTerminalId++;

private _themeStyle!: IStyleSheet;
private _dimensionsStyle!: IStyleSheet;
private _themeStyleElement!: HTMLStyleElement;
private _dimensionsStyleElement!: HTMLStyleElement;
private _rowContainer: HTMLElement;
private _rowElements: HTMLElement[] = [];
private _selectionContainer: HTMLElement;
Expand Down Expand Up @@ -92,9 +91,9 @@ export class DomRenderer extends Disposable implements IRenderer {
// https://github.com/xtermjs/xterm.js/issues/2960
this._rowContainer.remove();
this._selectionContainer.remove();
this._themeStyle.dispose();
this._dimensionsStyle.dispose();
this._widthCache.dispose();
this._themeStyleElement.remove();
this._dimensionsStyleElement.remove();
}));

this._widthCache = new WidthCache(document);
Expand Down Expand Up @@ -130,8 +129,9 @@ export class DomRenderer extends Disposable implements IRenderer {
element.style.overflow = 'hidden';
}

if (!this._dimensionsStyle) {
this._dimensionsStyle = createStyle(this._screenElement);
if (!this._dimensionsStyleElement) {
this._dimensionsStyleElement = document.createElement('style');
this._screenElement.appendChild(this._dimensionsStyleElement);
}

const styles =
Expand All @@ -141,16 +141,17 @@ export class DomRenderer extends Disposable implements IRenderer {
` vertical-align: top;` +
`}`;

this._dimensionsStyle.setCss(styles);
this._dimensionsStyleElement.textContent = styles;

this._selectionContainer.style.height = this._viewportElement.style.height;
this._screenElement.style.width = `${this.dimensions.css.canvas.width}px`;
this._screenElement.style.height = `${this.dimensions.css.canvas.height}px`;
}

private _injectCss(colors: ReadonlyColorSet): void {
if (!this._themeStyle) {
this._themeStyle = createStyle(this._screenElement);
if (!this._themeStyleElement) {
this._themeStyleElement = document.createElement('style');
this._screenElement.appendChild(this._themeStyleElement);
}

// Base CSS
Expand Down Expand Up @@ -248,7 +249,7 @@ export class DomRenderer extends Disposable implements IRenderer {
`${this._terminalSelector} .${FG_CLASS_PREFIX}${INVERTED_DEFAULT_COLOR}.${RowCss.DIM_CLASS} { color: ${color.multiplyOpacity(color.opaque(colors.background), 0.5).css}; }` +
`${this._terminalSelector} .${BG_CLASS_PREFIX}${INVERTED_DEFAULT_COLOR} { background-color: ${colors.foreground.css}; }`;

this._themeStyle.setCss(styles);
this._themeStyleElement.textContent = styles;
}

/**
Expand Down
50 changes: 0 additions & 50 deletions src/browser/renderer/dom/StyleSheet.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/common/Platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const isNode = (typeof navigator === 'undefined') ? true : false;
const userAgent = (isNode) ? 'node' : navigator.userAgent;
const platform = (isNode) ? 'node' : navigator.platform;

export const isElectron = userAgent.includes('Electron');
export const isFirefox = userAgent.includes('Firefox');
export const isLegacyEdge = userAgent.includes('Edge');
export const isSafari = /^((?!chrome|android).)*safari/i.test(userAgent);
Expand Down

0 comments on commit 1a3e14a

Please sign in to comment.