Path: blob/main/src/vs/editor/browser/viewParts/viewLines/domReadingContext.ts
5281 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45export class DomReadingContext {67private _didDomLayout: boolean = false;8private _clientRectDeltaLeft: number = 0;9private _clientRectScale: number = 1;10private _clientRectRead: boolean = false;1112public get didDomLayout(): boolean {13return this._didDomLayout;14}1516private readClientRect(): void {17if (!this._clientRectRead) {18this._clientRectRead = true;19const rect = this._domNode.getBoundingClientRect();20this.markDidDomLayout();21this._clientRectDeltaLeft = rect.left;22const offsetWidth = this._domNode.offsetWidth;23this._clientRectScale = offsetWidth > 0 ? rect.width / offsetWidth : 1;24}25}2627public get clientRectDeltaLeft(): number {28if (!this._clientRectRead) {29this.readClientRect();30}31return this._clientRectDeltaLeft;32}3334public get clientRectScale(): number {35if (!this._clientRectRead) {36this.readClientRect();37}38return this._clientRectScale;39}4041constructor(42private readonly _domNode: HTMLElement,43public readonly endNode: HTMLElement44) {45}4647public markDidDomLayout(): void {48this._didDomLayout = true;49}50}515253