mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from master
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { BareFontInfo } from 'vs/editor/common/config/fontInfo';
|
||||
|
||||
@@ -29,17 +28,13 @@ export class CharWidthRequest {
|
||||
}
|
||||
}
|
||||
|
||||
interface ICharWidthReader {
|
||||
read(): void;
|
||||
}
|
||||
|
||||
class DomCharWidthReader implements ICharWidthReader {
|
||||
class DomCharWidthReader {
|
||||
|
||||
private readonly _bareFontInfo: BareFontInfo;
|
||||
private readonly _requests: CharWidthRequest[];
|
||||
|
||||
private _container: HTMLElement;
|
||||
private _testElements: HTMLSpanElement[];
|
||||
private _container: HTMLElement | null;
|
||||
private _testElements: HTMLSpanElement[] | null;
|
||||
|
||||
constructor(bareFontInfo: BareFontInfo, requests: CharWidthRequest[]) {
|
||||
this._bareFontInfo = bareFontInfo;
|
||||
@@ -54,13 +49,13 @@ class DomCharWidthReader implements ICharWidthReader {
|
||||
this._createDomElements();
|
||||
|
||||
// Add the container to the DOM
|
||||
document.body.appendChild(this._container);
|
||||
document.body.appendChild(this._container!);
|
||||
|
||||
// Read character widths
|
||||
this._readFromDomElements();
|
||||
|
||||
// Remove the container from the DOM
|
||||
document.body.removeChild(this._container);
|
||||
document.body.removeChild(this._container!);
|
||||
|
||||
this._container = null;
|
||||
this._testElements = null;
|
||||
@@ -73,7 +68,7 @@ class DomCharWidthReader implements ICharWidthReader {
|
||||
container.style.width = '50000px';
|
||||
|
||||
let regularDomNode = document.createElement('div');
|
||||
regularDomNode.style.fontFamily = this._bareFontInfo.fontFamily;
|
||||
regularDomNode.style.fontFamily = this._bareFontInfo.getMassagedFontFamily();
|
||||
regularDomNode.style.fontWeight = this._bareFontInfo.fontWeight;
|
||||
regularDomNode.style.fontSize = this._bareFontInfo.fontSize + 'px';
|
||||
regularDomNode.style.lineHeight = this._bareFontInfo.lineHeight + 'px';
|
||||
@@ -81,7 +76,7 @@ class DomCharWidthReader implements ICharWidthReader {
|
||||
container.appendChild(regularDomNode);
|
||||
|
||||
let boldDomNode = document.createElement('div');
|
||||
boldDomNode.style.fontFamily = this._bareFontInfo.fontFamily;
|
||||
boldDomNode.style.fontFamily = this._bareFontInfo.getMassagedFontFamily();
|
||||
boldDomNode.style.fontWeight = 'bold';
|
||||
boldDomNode.style.fontSize = this._bareFontInfo.fontSize + 'px';
|
||||
boldDomNode.style.lineHeight = this._bareFontInfo.lineHeight + 'px';
|
||||
@@ -89,7 +84,7 @@ class DomCharWidthReader implements ICharWidthReader {
|
||||
container.appendChild(boldDomNode);
|
||||
|
||||
let italicDomNode = document.createElement('div');
|
||||
italicDomNode.style.fontFamily = this._bareFontInfo.fontFamily;
|
||||
italicDomNode.style.fontFamily = this._bareFontInfo.getMassagedFontFamily();
|
||||
italicDomNode.style.fontWeight = this._bareFontInfo.fontWeight;
|
||||
italicDomNode.style.fontSize = this._bareFontInfo.fontSize + 'px';
|
||||
italicDomNode.style.lineHeight = this._bareFontInfo.lineHeight + 'px';
|
||||
@@ -112,11 +107,11 @@ class DomCharWidthReader implements ICharWidthReader {
|
||||
parent = italicDomNode;
|
||||
}
|
||||
|
||||
parent.appendChild(document.createElement('br'));
|
||||
parent!.appendChild(document.createElement('br'));
|
||||
|
||||
let testElement = document.createElement('span');
|
||||
DomCharWidthReader._render(testElement, request);
|
||||
parent.appendChild(testElement);
|
||||
parent!.appendChild(testElement);
|
||||
|
||||
testElements[i] = testElement;
|
||||
}
|
||||
@@ -146,7 +141,7 @@ class DomCharWidthReader implements ICharWidthReader {
|
||||
private _readFromDomElements(): void {
|
||||
for (let i = 0, len = this._requests.length; i < len; i++) {
|
||||
const request = this._requests[i];
|
||||
const testElement = this._testElements[i];
|
||||
const testElement = this._testElements![i];
|
||||
|
||||
request.fulfill(testElement.offsetWidth / 256);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user