Path: blob/main/src/vs/editor/browser/viewParts/viewLines/domReadingContext.ts
3296 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;22this._clientRectScale = rect.width / this._domNode.offsetWidth;23}24}2526public get clientRectDeltaLeft(): number {27if (!this._clientRectRead) {28this.readClientRect();29}30return this._clientRectDeltaLeft;31}3233public get clientRectScale(): number {34if (!this._clientRectRead) {35this.readClientRect();36}37return this._clientRectScale;38}3940constructor(41private readonly _domNode: HTMLElement,42public readonly endNode: HTMLElement43) {44}4546public markDidDomLayout(): void {47this._didDomLayout = true;48}49}505152