@xterm/xterm 6.1.0-beta.21 → 6.1.0-beta.211
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -38
- package/css/xterm.css +29 -22
- package/lib/xterm.js +1 -1
- package/lib/xterm.js.map +1 -1
- package/lib/xterm.mjs +8 -34
- package/lib/xterm.mjs.map +4 -4
- package/package.json +24 -13
- package/src/browser/AccessibilityManager.ts +6 -3
- package/src/browser/Clipboard.ts +6 -3
- package/src/browser/CoreBrowserTerminal.ts +147 -318
- package/src/browser/Dom.ts +178 -0
- package/src/browser/Linkifier.ts +11 -11
- package/src/browser/OscLinkProvider.ts +3 -1
- package/src/browser/RenderDebouncer.ts +2 -2
- package/src/browser/TimeBasedDebouncer.ts +2 -2
- package/src/browser/Types.ts +12 -11
- package/src/browser/Viewport.ts +55 -20
- package/src/browser/decorations/BufferDecorationRenderer.ts +1 -1
- package/src/browser/decorations/OverviewRulerRenderer.ts +33 -17
- package/src/browser/input/CompositionHelper.ts +44 -8
- package/src/browser/public/Terminal.ts +25 -28
- package/src/browser/renderer/dom/DomRenderer.ts +205 -41
- package/src/browser/renderer/dom/DomRendererRowFactory.ts +19 -13
- package/src/browser/renderer/dom/WidthCache.ts +54 -52
- package/src/browser/renderer/shared/Constants.ts +7 -0
- package/src/browser/renderer/shared/TextBlinkStateManager.ts +97 -0
- package/src/browser/renderer/shared/Types.ts +8 -2
- package/src/browser/scrollable/abstractScrollbar.ts +300 -0
- package/src/browser/scrollable/fastDomNode.ts +126 -0
- package/src/browser/scrollable/globalPointerMoveMonitor.ts +90 -0
- package/src/browser/scrollable/horizontalScrollbar.ts +85 -0
- package/src/browser/scrollable/mouseEvent.ts +292 -0
- package/src/browser/scrollable/scrollable.ts +486 -0
- package/src/browser/scrollable/scrollableElement.ts +579 -0
- package/src/browser/scrollable/scrollableElementOptions.ts +161 -0
- package/src/browser/scrollable/scrollbarArrow.ts +110 -0
- package/src/browser/scrollable/scrollbarState.ts +246 -0
- package/src/browser/scrollable/scrollbarVisibilityController.ts +113 -0
- package/src/browser/scrollable/touch.ts +485 -0
- package/src/browser/scrollable/verticalScrollbar.ts +143 -0
- package/src/browser/scrollable/widget.ts +23 -0
- package/src/browser/services/CharSizeService.ts +2 -2
- package/src/browser/services/CoreBrowserService.ts +7 -5
- package/src/browser/services/KeyboardService.ts +67 -0
- package/src/browser/services/LinkProviderService.ts +1 -1
- package/src/browser/services/MouseCoordsService.ts +47 -0
- package/src/browser/services/MouseService.ts +518 -25
- package/src/browser/services/RenderService.ts +22 -15
- package/src/browser/services/SelectionService.ts +16 -8
- package/src/browser/services/Services.ts +40 -17
- package/src/browser/services/ThemeService.ts +2 -2
- package/src/common/Async.ts +105 -0
- package/src/common/CircularList.ts +2 -2
- package/src/common/Color.ts +8 -0
- package/src/common/CoreTerminal.ts +28 -18
- package/src/common/Event.ts +118 -0
- package/src/common/InputHandler.ts +263 -43
- package/src/common/Lifecycle.ts +113 -0
- package/src/common/Platform.ts +13 -3
- package/src/common/SortedList.ts +7 -3
- package/src/common/TaskQueue.ts +14 -5
- package/src/common/Types.ts +35 -15
- package/src/common/Version.ts +9 -0
- package/src/common/buffer/Buffer.ts +20 -14
- package/src/common/buffer/BufferLine.ts +4 -5
- package/src/common/buffer/BufferSet.ts +7 -6
- package/src/common/buffer/CellData.ts +57 -0
- package/src/common/buffer/Marker.ts +2 -2
- package/src/common/buffer/Types.ts +6 -2
- package/src/common/data/EscapeSequences.ts +71 -70
- package/src/common/input/Keyboard.ts +14 -7
- package/src/common/input/KittyKeyboard.ts +519 -0
- package/src/common/input/Win32InputMode.ts +297 -0
- package/src/common/input/WriteBuffer.ts +34 -2
- package/src/common/input/XParseColor.ts +2 -2
- package/src/common/parser/ApcParser.ts +245 -0
- package/src/common/parser/Constants.ts +22 -4
- package/src/common/parser/DcsParser.ts +5 -5
- package/src/common/parser/EscapeSequenceParser.ts +167 -57
- package/src/common/parser/OscParser.ts +5 -5
- package/src/common/parser/Params.ts +13 -0
- package/src/common/parser/Types.ts +36 -2
- package/src/common/public/BufferLineApiView.ts +2 -2
- package/src/common/public/BufferNamespaceApi.ts +2 -2
- package/src/common/public/ParserApi.ts +3 -0
- package/src/common/services/BufferService.ts +8 -5
- package/src/common/services/CharsetService.ts +4 -0
- package/src/common/services/CoreService.ts +18 -4
- package/src/common/services/DecorationService.ts +24 -8
- package/src/common/services/LogService.ts +1 -31
- package/src/common/services/{CoreMouseService.ts → MouseStateService.ts} +21 -132
- package/src/common/services/OptionsService.ts +13 -4
- package/src/common/services/Services.ts +47 -40
- package/src/common/services/UnicodeService.ts +1 -1
- package/typings/xterm.d.ts +316 -32
- package/src/common/TypedArrayUtils.ts +0 -17
- package/src/vs/base/browser/browser.ts +0 -141
- package/src/vs/base/browser/canIUse.ts +0 -49
- package/src/vs/base/browser/dom.ts +0 -2369
- package/src/vs/base/browser/fastDomNode.ts +0 -316
- package/src/vs/base/browser/globalPointerMoveMonitor.ts +0 -112
- package/src/vs/base/browser/iframe.ts +0 -135
- package/src/vs/base/browser/keyboardEvent.ts +0 -213
- package/src/vs/base/browser/mouseEvent.ts +0 -229
- package/src/vs/base/browser/touch.ts +0 -372
- package/src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts +0 -303
- package/src/vs/base/browser/ui/scrollbar/horizontalScrollbar.ts +0 -114
- package/src/vs/base/browser/ui/scrollbar/scrollableElement.ts +0 -720
- package/src/vs/base/browser/ui/scrollbar/scrollableElementOptions.ts +0 -165
- package/src/vs/base/browser/ui/scrollbar/scrollbarArrow.ts +0 -114
- package/src/vs/base/browser/ui/scrollbar/scrollbarState.ts +0 -243
- package/src/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.ts +0 -118
- package/src/vs/base/browser/ui/scrollbar/verticalScrollbar.ts +0 -116
- package/src/vs/base/browser/ui/widget.ts +0 -57
- package/src/vs/base/browser/window.ts +0 -14
- package/src/vs/base/common/arrays.ts +0 -887
- package/src/vs/base/common/arraysFind.ts +0 -202
- package/src/vs/base/common/assert.ts +0 -71
- package/src/vs/base/common/async.ts +0 -1992
- package/src/vs/base/common/cancellation.ts +0 -148
- package/src/vs/base/common/charCode.ts +0 -450
- package/src/vs/base/common/collections.ts +0 -140
- package/src/vs/base/common/decorators.ts +0 -130
- package/src/vs/base/common/equals.ts +0 -146
- package/src/vs/base/common/errors.ts +0 -303
- package/src/vs/base/common/event.ts +0 -1778
- package/src/vs/base/common/functional.ts +0 -32
- package/src/vs/base/common/hash.ts +0 -316
- package/src/vs/base/common/iterator.ts +0 -159
- package/src/vs/base/common/keyCodes.ts +0 -526
- package/src/vs/base/common/keybindings.ts +0 -284
- package/src/vs/base/common/lazy.ts +0 -47
- package/src/vs/base/common/lifecycle.ts +0 -801
- package/src/vs/base/common/linkedList.ts +0 -142
- package/src/vs/base/common/map.ts +0 -202
- package/src/vs/base/common/numbers.ts +0 -98
- package/src/vs/base/common/observable.ts +0 -76
- package/src/vs/base/common/observableInternal/api.ts +0 -31
- package/src/vs/base/common/observableInternal/autorun.ts +0 -281
- package/src/vs/base/common/observableInternal/base.ts +0 -489
- package/src/vs/base/common/observableInternal/debugName.ts +0 -145
- package/src/vs/base/common/observableInternal/derived.ts +0 -428
- package/src/vs/base/common/observableInternal/lazyObservableValue.ts +0 -146
- package/src/vs/base/common/observableInternal/logging.ts +0 -328
- package/src/vs/base/common/observableInternal/promise.ts +0 -209
- package/src/vs/base/common/observableInternal/utils.ts +0 -610
- package/src/vs/base/common/platform.ts +0 -281
- package/src/vs/base/common/scrollable.ts +0 -522
- package/src/vs/base/common/sequence.ts +0 -34
- package/src/vs/base/common/stopwatch.ts +0 -43
- package/src/vs/base/common/strings.ts +0 -557
- package/src/vs/base/common/symbols.ts +0 -9
- package/src/vs/base/common/uint.ts +0 -59
- package/src/vs/patches/nls.ts +0 -90
- package/src/vs/typings/base-common.d.ts +0 -20
- package/src/vs/typings/require.d.ts +0 -42
- package/src/vs/typings/vscode-globals-nls.d.ts +0 -36
- package/src/vs/typings/vscode-globals-product.d.ts +0 -33
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
|
|
6
|
+
export class FastDomNode<T extends HTMLElement> {
|
|
7
|
+
|
|
8
|
+
private _width: string = '';
|
|
9
|
+
private _height: string = '';
|
|
10
|
+
private _top: string = '';
|
|
11
|
+
private _left: string = '';
|
|
12
|
+
private _bottom: string = '';
|
|
13
|
+
private _right: string = '';
|
|
14
|
+
private _className: string = '';
|
|
15
|
+
private _position: string = '';
|
|
16
|
+
private _layerHint: boolean = false;
|
|
17
|
+
private _contain: 'none' | 'strict' | 'content' | 'size' | 'layout' | 'style' | 'paint' = 'none';
|
|
18
|
+
|
|
19
|
+
constructor(
|
|
20
|
+
public readonly domNode: T
|
|
21
|
+
) { }
|
|
22
|
+
|
|
23
|
+
public setWidth(_width: number | string): void {
|
|
24
|
+
const width = numberAsPixels(_width);
|
|
25
|
+
if (this._width === width) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
this._width = width;
|
|
29
|
+
this.domNode.style.width = this._width;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public setHeight(_height: number | string): void {
|
|
33
|
+
const height = numberAsPixels(_height);
|
|
34
|
+
if (this._height === height) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this._height = height;
|
|
38
|
+
this.domNode.style.height = this._height;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public setTop(_top: number | string): void {
|
|
42
|
+
const top = numberAsPixels(_top);
|
|
43
|
+
if (this._top === top) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
this._top = top;
|
|
47
|
+
this.domNode.style.top = this._top;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public setLeft(_left: number | string): void {
|
|
51
|
+
const left = numberAsPixels(_left);
|
|
52
|
+
if (this._left === left) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this._left = left;
|
|
56
|
+
this.domNode.style.left = this._left;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public setBottom(_bottom: number | string): void {
|
|
60
|
+
const bottom = numberAsPixels(_bottom);
|
|
61
|
+
if (this._bottom === bottom) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this._bottom = bottom;
|
|
65
|
+
this.domNode.style.bottom = this._bottom;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public setRight(_right: number | string): void {
|
|
69
|
+
const right = numberAsPixels(_right);
|
|
70
|
+
if (this._right === right) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this._right = right;
|
|
74
|
+
this.domNode.style.right = this._right;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public setClassName(className: string): void {
|
|
78
|
+
if (this._className === className) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
this._className = className;
|
|
82
|
+
this.domNode.className = this._className;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public toggleClassName(className: string, shouldHaveIt?: boolean): void {
|
|
86
|
+
this.domNode.classList.toggle(className, shouldHaveIt);
|
|
87
|
+
this._className = this.domNode.className;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public setPosition(position: string): void {
|
|
91
|
+
if (this._position === position) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
this._position = position;
|
|
95
|
+
this.domNode.style.position = this._position;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public setLayerHinting(layerHint: boolean): void {
|
|
99
|
+
if (this._layerHint === layerHint) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
this._layerHint = layerHint;
|
|
103
|
+
if (layerHint) {
|
|
104
|
+
this.domNode.style.transform = 'translate3d(0px, 0px, 0px)';
|
|
105
|
+
} else {
|
|
106
|
+
this.domNode.style.transform = '';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
public setContain(contain: 'none' | 'strict' | 'content' | 'size' | 'layout' | 'style' | 'paint'): void {
|
|
111
|
+
if (this._contain === contain) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
this._contain = contain;
|
|
115
|
+
this.domNode.style.contain = this._contain;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public setAttribute(name: string, value: string): void {
|
|
119
|
+
this.domNode.setAttribute(name, value);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function numberAsPixels(value: number | string): string {
|
|
125
|
+
return (typeof value === 'number' ? `${value}px` : value);
|
|
126
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
|
|
6
|
+
import * as dom from '../Dom';
|
|
7
|
+
import { DisposableStore, IDisposable, toDisposable } from 'common/Lifecycle';
|
|
8
|
+
|
|
9
|
+
type PointerMoveCallback = (event: PointerEvent) => void;
|
|
10
|
+
type OnStopCallback = () => void;
|
|
11
|
+
|
|
12
|
+
export class GlobalPointerMoveMonitor implements IDisposable {
|
|
13
|
+
|
|
14
|
+
private readonly _hooks = new DisposableStore();
|
|
15
|
+
private _pointerMoveCallback: PointerMoveCallback | null = null;
|
|
16
|
+
private _onStopCallback: OnStopCallback | null = null;
|
|
17
|
+
|
|
18
|
+
public dispose(): void {
|
|
19
|
+
this.stopMonitoring(false);
|
|
20
|
+
this._hooks.dispose();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public stopMonitoring(invokeStopCallback: boolean): void {
|
|
24
|
+
if (!this.isMonitoring()) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
this._hooks.clear();
|
|
29
|
+
this._pointerMoveCallback = null;
|
|
30
|
+
const onStopCallback = this._onStopCallback;
|
|
31
|
+
this._onStopCallback = null;
|
|
32
|
+
|
|
33
|
+
if (invokeStopCallback && onStopCallback) {
|
|
34
|
+
onStopCallback();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public isMonitoring(): boolean {
|
|
39
|
+
return !!this._pointerMoveCallback;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public startMonitoring(
|
|
43
|
+
initialElement: Element,
|
|
44
|
+
pointerId: number,
|
|
45
|
+
initialButtons: number,
|
|
46
|
+
pointerMoveCallback: PointerMoveCallback,
|
|
47
|
+
onStopCallback: OnStopCallback
|
|
48
|
+
): void {
|
|
49
|
+
if (this.isMonitoring()) {
|
|
50
|
+
this.stopMonitoring(false);
|
|
51
|
+
}
|
|
52
|
+
this._pointerMoveCallback = pointerMoveCallback;
|
|
53
|
+
this._onStopCallback = onStopCallback;
|
|
54
|
+
|
|
55
|
+
let eventSource: Element | Window = initialElement;
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
initialElement.setPointerCapture(pointerId);
|
|
59
|
+
this._hooks.add(toDisposable(() => {
|
|
60
|
+
try {
|
|
61
|
+
initialElement.releasePointerCapture(pointerId);
|
|
62
|
+
} catch {
|
|
63
|
+
// ignore
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
66
|
+
} catch {
|
|
67
|
+
eventSource = dom.getWindow(initialElement);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
this._hooks.add(dom.addDisposableListener(
|
|
71
|
+
eventSource,
|
|
72
|
+
dom.eventType.POINTER_MOVE,
|
|
73
|
+
(e) => {
|
|
74
|
+
if (e.buttons !== initialButtons) {
|
|
75
|
+
this.stopMonitoring(true);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
this._pointerMoveCallback!(e);
|
|
81
|
+
}
|
|
82
|
+
));
|
|
83
|
+
|
|
84
|
+
this._hooks.add(dom.addDisposableListener(
|
|
85
|
+
eventSource,
|
|
86
|
+
dom.eventType.POINTER_UP,
|
|
87
|
+
(e: PointerEvent) => this.stopMonitoring(true)
|
|
88
|
+
));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
|
|
6
|
+
import { AbstractScrollbar, ISimplifiedPointerEvent, IScrollbarHost } from './abstractScrollbar';
|
|
7
|
+
import { IScrollableElementResolvedOptions } from './scrollableElementOptions';
|
|
8
|
+
import { ScrollbarState } from './scrollbarState';
|
|
9
|
+
import { INewScrollPosition, Scrollable, ScrollbarVisibility, IScrollEvent } from './scrollable';
|
|
10
|
+
|
|
11
|
+
export class HorizontalScrollbar extends AbstractScrollbar {
|
|
12
|
+
|
|
13
|
+
constructor(scrollable: Scrollable, options: IScrollableElementResolvedOptions, host: IScrollbarHost) {
|
|
14
|
+
const scrollDimensions = scrollable.getScrollDimensions();
|
|
15
|
+
const scrollPosition = scrollable.getCurrentScrollPosition();
|
|
16
|
+
super({
|
|
17
|
+
lazyRender: options.lazyRender,
|
|
18
|
+
host: host,
|
|
19
|
+
scrollbarState: new ScrollbarState(
|
|
20
|
+
(options.horizontalHasArrows ? options.horizontalScrollbarSize : 0),
|
|
21
|
+
(options.horizontal === ScrollbarVisibility.HIDDEN ? 0 : options.horizontalScrollbarSize),
|
|
22
|
+
(options.vertical === ScrollbarVisibility.HIDDEN ? 0 : options.verticalScrollbarSize),
|
|
23
|
+
scrollDimensions.width,
|
|
24
|
+
scrollDimensions.scrollWidth,
|
|
25
|
+
scrollPosition.scrollLeft
|
|
26
|
+
),
|
|
27
|
+
visibility: options.horizontal,
|
|
28
|
+
extraScrollbarClassName: 'xterm-horizontal',
|
|
29
|
+
scrollable: scrollable,
|
|
30
|
+
scrollByPage: options.scrollByPage
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
if (options.horizontalHasArrows) {
|
|
34
|
+
throw new Error('horizontalHasArrows is not supported in xterm.js');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
this._createSlider(Math.floor((options.horizontalScrollbarSize - options.horizontalSliderSize) / 2), 0, undefined, options.horizontalSliderSize);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
protected _updateSlider(sliderSize: number, sliderPosition: number): void {
|
|
41
|
+
this.slider.setWidth(sliderSize);
|
|
42
|
+
this.slider.setLeft(sliderPosition);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
protected _renderDomNode(largeSize: number, smallSize: number): void {
|
|
46
|
+
this.domNode.setWidth(largeSize);
|
|
47
|
+
this.domNode.setHeight(smallSize);
|
|
48
|
+
this.domNode.setLeft(0);
|
|
49
|
+
this.domNode.setBottom(0);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public handleScroll(e: IScrollEvent): boolean {
|
|
53
|
+
this._shouldRender = this._handleElementScrollSize(e.scrollWidth) || this._shouldRender;
|
|
54
|
+
this._shouldRender = this._handleElementScrollPosition(e.scrollLeft) || this._shouldRender;
|
|
55
|
+
this._shouldRender = this._handleElementSize(e.width) || this._shouldRender;
|
|
56
|
+
return this._shouldRender;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
protected _pointerDownRelativePosition(offsetX: number, offsetY: number): number {
|
|
60
|
+
return offsetX;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
protected _sliderPointerPosition(e: ISimplifiedPointerEvent): number {
|
|
64
|
+
return e.pageX;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
protected _sliderOrthogonalPointerPosition(e: ISimplifiedPointerEvent): number {
|
|
68
|
+
return e.pageY;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
protected _updateScrollbarSize(size: number): void {
|
|
72
|
+
this.slider.setHeight(size);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public writeScrollPosition(target: INewScrollPosition, scrollPosition: number): void {
|
|
76
|
+
target.scrollLeft = scrollPosition;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public updateOptions(options: IScrollableElementResolvedOptions): void {
|
|
80
|
+
this.updateScrollbarSize(options.horizontal === ScrollbarVisibility.HIDDEN ? 0 : options.horizontalScrollbarSize);
|
|
81
|
+
this._scrollbarState.setOppositeScrollbarSize(options.vertical === ScrollbarVisibility.HIDDEN ? 0 : options.verticalScrollbarSize);
|
|
82
|
+
this._visibilityController.setVisibility(options.horizontal);
|
|
83
|
+
this._scrollByPage = options.scrollByPage;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
|
|
6
|
+
import * as platform from 'common/Platform';
|
|
7
|
+
|
|
8
|
+
interface IWindowChainElement {
|
|
9
|
+
readonly window: WeakRef<Window>;
|
|
10
|
+
readonly iframeElement: Element | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const sameOriginWindowChainCache = new WeakMap<Window, IWindowChainElement[] | null>();
|
|
14
|
+
|
|
15
|
+
function getParentWindowIfSameOrigin(w: Window): Window | null {
|
|
16
|
+
if (!w.parent || w.parent === w) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const location = w.location;
|
|
22
|
+
const parentLocation = w.parent.location;
|
|
23
|
+
if (location.origin !== 'null' && parentLocation.origin !== 'null' && location.origin !== parentLocation.origin) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
} catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return w.parent;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class IframeUtils {
|
|
34
|
+
|
|
35
|
+
private static _getSameOriginWindowChain(targetWindow: Window): IWindowChainElement[] {
|
|
36
|
+
let windowChainCache = sameOriginWindowChainCache.get(targetWindow);
|
|
37
|
+
if (!windowChainCache) {
|
|
38
|
+
windowChainCache = [];
|
|
39
|
+
sameOriginWindowChainCache.set(targetWindow, windowChainCache);
|
|
40
|
+
let w: Window | null = targetWindow;
|
|
41
|
+
let parent: Window | null;
|
|
42
|
+
do {
|
|
43
|
+
parent = getParentWindowIfSameOrigin(w);
|
|
44
|
+
if (parent) {
|
|
45
|
+
windowChainCache.push({
|
|
46
|
+
window: new WeakRef(w),
|
|
47
|
+
iframeElement: w.frameElement ?? null
|
|
48
|
+
});
|
|
49
|
+
} else {
|
|
50
|
+
windowChainCache.push({
|
|
51
|
+
window: new WeakRef(w),
|
|
52
|
+
iframeElement: null
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
w = parent;
|
|
56
|
+
} while (w);
|
|
57
|
+
}
|
|
58
|
+
return windowChainCache.slice(0);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public static getPositionOfChildWindowRelativeToAncestorWindow(childWindow: Window, ancestorWindow: Window | null): { top: number, left: number } {
|
|
62
|
+
|
|
63
|
+
if (!ancestorWindow || childWindow === ancestorWindow) {
|
|
64
|
+
return {
|
|
65
|
+
top: 0,
|
|
66
|
+
left: 0
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let top = 0;
|
|
71
|
+
let left = 0;
|
|
72
|
+
|
|
73
|
+
const windowChain = this._getSameOriginWindowChain(childWindow);
|
|
74
|
+
|
|
75
|
+
for (const windowChainEl of windowChain) {
|
|
76
|
+
const windowInChain = windowChainEl.window.deref();
|
|
77
|
+
top += windowInChain?.scrollY ?? 0;
|
|
78
|
+
left += windowInChain?.scrollX ?? 0;
|
|
79
|
+
|
|
80
|
+
if (windowInChain === ancestorWindow) {
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!windowChainEl.iframeElement) {
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const boundingRect = windowChainEl.iframeElement.getBoundingClientRect();
|
|
89
|
+
top += boundingRect.top;
|
|
90
|
+
left += boundingRect.left;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
top: top,
|
|
95
|
+
left: left
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface IMouseEvent {
|
|
101
|
+
readonly browserEvent: MouseEvent;
|
|
102
|
+
readonly leftButton: boolean;
|
|
103
|
+
readonly middleButton: boolean;
|
|
104
|
+
readonly rightButton: boolean;
|
|
105
|
+
readonly buttons: number;
|
|
106
|
+
readonly target: HTMLElement;
|
|
107
|
+
readonly detail: number;
|
|
108
|
+
readonly posx: number;
|
|
109
|
+
readonly posy: number;
|
|
110
|
+
readonly ctrlKey: boolean;
|
|
111
|
+
readonly shiftKey: boolean;
|
|
112
|
+
readonly altKey: boolean;
|
|
113
|
+
readonly metaKey: boolean;
|
|
114
|
+
readonly timestamp: number;
|
|
115
|
+
|
|
116
|
+
preventDefault(): void;
|
|
117
|
+
stopPropagation(): void;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export class StandardMouseEvent implements IMouseEvent {
|
|
121
|
+
|
|
122
|
+
public readonly browserEvent: MouseEvent;
|
|
123
|
+
|
|
124
|
+
public readonly leftButton: boolean;
|
|
125
|
+
public readonly middleButton: boolean;
|
|
126
|
+
public readonly rightButton: boolean;
|
|
127
|
+
public readonly buttons: number;
|
|
128
|
+
public readonly target: HTMLElement;
|
|
129
|
+
public detail: number;
|
|
130
|
+
public readonly posx: number;
|
|
131
|
+
public readonly posy: number;
|
|
132
|
+
public readonly ctrlKey: boolean;
|
|
133
|
+
public readonly shiftKey: boolean;
|
|
134
|
+
public readonly altKey: boolean;
|
|
135
|
+
public readonly metaKey: boolean;
|
|
136
|
+
public readonly timestamp: number;
|
|
137
|
+
|
|
138
|
+
constructor(targetWindow: Window, e: MouseEvent) {
|
|
139
|
+
this.timestamp = Date.now();
|
|
140
|
+
this.browserEvent = e;
|
|
141
|
+
this.leftButton = e.button === 0;
|
|
142
|
+
this.middleButton = e.button === 1;
|
|
143
|
+
this.rightButton = e.button === 2;
|
|
144
|
+
this.buttons = e.buttons;
|
|
145
|
+
|
|
146
|
+
this.target = e.target as HTMLElement;
|
|
147
|
+
|
|
148
|
+
this.detail = e.detail ?? 1;
|
|
149
|
+
if (e.type === 'dblclick') {
|
|
150
|
+
this.detail = 2;
|
|
151
|
+
}
|
|
152
|
+
this.ctrlKey = e.ctrlKey;
|
|
153
|
+
this.shiftKey = e.shiftKey;
|
|
154
|
+
this.altKey = e.altKey;
|
|
155
|
+
this.metaKey = e.metaKey;
|
|
156
|
+
|
|
157
|
+
if (typeof e.pageX === 'number') {
|
|
158
|
+
this.posx = e.pageX;
|
|
159
|
+
this.posy = e.pageY;
|
|
160
|
+
} else {
|
|
161
|
+
this.posx = e.clientX + this.target.ownerDocument.body.scrollLeft + this.target.ownerDocument.documentElement.scrollLeft;
|
|
162
|
+
this.posy = e.clientY + this.target.ownerDocument.body.scrollTop + this.target.ownerDocument.documentElement.scrollTop;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const iframeOffsets = IframeUtils.getPositionOfChildWindowRelativeToAncestorWindow(targetWindow, e.view);
|
|
166
|
+
this.posx -= iframeOffsets.left;
|
|
167
|
+
this.posy -= iframeOffsets.top;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
public preventDefault(): void {
|
|
171
|
+
this.browserEvent.preventDefault();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
public stopPropagation(): void {
|
|
175
|
+
this.browserEvent.stopPropagation();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface IMouseWheelEvent extends MouseEvent {
|
|
180
|
+
readonly wheelDelta: number;
|
|
181
|
+
readonly wheelDeltaX: number;
|
|
182
|
+
readonly wheelDeltaY: number;
|
|
183
|
+
|
|
184
|
+
readonly deltaX: number;
|
|
185
|
+
readonly deltaY: number;
|
|
186
|
+
readonly deltaZ: number;
|
|
187
|
+
readonly deltaMode: number;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
interface IWebKitMouseWheelEvent {
|
|
191
|
+
wheelDeltaY: number;
|
|
192
|
+
wheelDeltaX: number;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
interface IGeckoMouseWheelEvent {
|
|
196
|
+
HORIZONTAL_AXIS: number;
|
|
197
|
+
VERTICAL_AXIS: number;
|
|
198
|
+
axis: number;
|
|
199
|
+
detail: number;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export class StandardWheelEvent {
|
|
203
|
+
|
|
204
|
+
public readonly browserEvent: IMouseWheelEvent | null;
|
|
205
|
+
public readonly deltaY: number;
|
|
206
|
+
public readonly deltaX: number;
|
|
207
|
+
public readonly target: Node | null;
|
|
208
|
+
|
|
209
|
+
constructor(e: IMouseWheelEvent | null, deltaX: number = 0, deltaY: number = 0) {
|
|
210
|
+
|
|
211
|
+
this.browserEvent = e ?? null;
|
|
212
|
+
this.target = e ? (e.target ?? (e as any).targetNode ?? e.srcElement ?? null) : null;
|
|
213
|
+
|
|
214
|
+
this.deltaY = deltaY;
|
|
215
|
+
this.deltaX = deltaX;
|
|
216
|
+
|
|
217
|
+
let shouldFactorDPR: boolean = false;
|
|
218
|
+
if (platform.isChrome) {
|
|
219
|
+
const chromeVersionMatch = navigator.userAgent.match(/Chrome\/(\d+)/);
|
|
220
|
+
const chromeMajorVersion = chromeVersionMatch ? parseInt(chromeVersionMatch[1]) : 123;
|
|
221
|
+
shouldFactorDPR = chromeMajorVersion <= 122;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (e) {
|
|
225
|
+
const e1 = e as IWebKitMouseWheelEvent as any;
|
|
226
|
+
const e2 = e as unknown as IGeckoMouseWheelEvent;
|
|
227
|
+
const devicePixelRatio = e.view?.devicePixelRatio ?? 1;
|
|
228
|
+
|
|
229
|
+
if (typeof e1.wheelDeltaY !== 'undefined') {
|
|
230
|
+
if (shouldFactorDPR) {
|
|
231
|
+
this.deltaY = e1.wheelDeltaY / (120 * devicePixelRatio);
|
|
232
|
+
} else {
|
|
233
|
+
this.deltaY = e1.wheelDeltaY / 120;
|
|
234
|
+
}
|
|
235
|
+
} else if (typeof e2.VERTICAL_AXIS !== 'undefined' && e2.axis === e2.VERTICAL_AXIS) {
|
|
236
|
+
this.deltaY = -e2.detail / 3;
|
|
237
|
+
} else if (e.type === 'wheel') {
|
|
238
|
+
const ev = e as unknown as WheelEvent;
|
|
239
|
+
|
|
240
|
+
if (ev.deltaMode === ev.DOM_DELTA_LINE) {
|
|
241
|
+
if (platform.isFirefox && !platform.isMac) {
|
|
242
|
+
this.deltaY = -e.deltaY / 3;
|
|
243
|
+
} else {
|
|
244
|
+
this.deltaY = -e.deltaY;
|
|
245
|
+
}
|
|
246
|
+
} else {
|
|
247
|
+
this.deltaY = -e.deltaY / 40;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (typeof e1.wheelDeltaX !== 'undefined') {
|
|
252
|
+
if (platform.isSafari && platform.isWindows) {
|
|
253
|
+
this.deltaX = -(e1.wheelDeltaX / 120);
|
|
254
|
+
} else if (shouldFactorDPR) {
|
|
255
|
+
this.deltaX = e1.wheelDeltaX / (120 * devicePixelRatio);
|
|
256
|
+
} else {
|
|
257
|
+
this.deltaX = e1.wheelDeltaX / 120;
|
|
258
|
+
}
|
|
259
|
+
} else if (typeof e2.HORIZONTAL_AXIS !== 'undefined' && e2.axis === e2.HORIZONTAL_AXIS) {
|
|
260
|
+
this.deltaX = -e.detail / 3;
|
|
261
|
+
} else if (e.type === 'wheel') {
|
|
262
|
+
const ev = e as unknown as WheelEvent;
|
|
263
|
+
|
|
264
|
+
if (ev.deltaMode === ev.DOM_DELTA_LINE) {
|
|
265
|
+
if (platform.isFirefox && !platform.isMac) {
|
|
266
|
+
this.deltaX = -e.deltaX / 3;
|
|
267
|
+
} else {
|
|
268
|
+
this.deltaX = -e.deltaX;
|
|
269
|
+
}
|
|
270
|
+
} else {
|
|
271
|
+
this.deltaX = -e.deltaX / 40;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (this.deltaY === 0 && this.deltaX === 0 && e.wheelDelta) {
|
|
276
|
+
if (shouldFactorDPR) {
|
|
277
|
+
this.deltaY = e.wheelDelta / (120 * devicePixelRatio);
|
|
278
|
+
} else {
|
|
279
|
+
this.deltaY = e.wheelDelta / 120;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
public preventDefault(): void {
|
|
286
|
+
this.browserEvent?.preventDefault();
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
public stopPropagation(): void {
|
|
290
|
+
this.browserEvent?.stopPropagation();
|
|
291
|
+
}
|
|
292
|
+
}
|