Merge from vscode a234f13c45b40a0929777cb440ee011b7549eed2 (#8911)

* Merge from vscode a234f13c45b40a0929777cb440ee011b7549eed2

* update distro

* fix layering

* update distro

* fix tests
This commit is contained in:
Anthony Dresser
2020-01-22 13:42:37 -08:00
committed by GitHub
parent 977111eb21
commit bd7aac8ee0
895 changed files with 24651 additions and 14520 deletions

View File

@@ -12,6 +12,7 @@ import { BrowserFeatures } from 'vs/base/browser/canIUse';
export interface IStandardMouseMoveEventData {
leftButton: boolean;
buttons: number;
posx: number;
posy: number;
}
@@ -33,21 +34,22 @@ export function standardMouseMoveMerger(lastEvent: IStandardMouseMoveEventData |
ev.preventDefault();
return {
leftButton: ev.leftButton,
buttons: ev.buttons,
posx: ev.posx,
posy: ev.posy
};
}
export class GlobalMouseMoveMonitor<R> implements IDisposable {
export class GlobalMouseMoveMonitor<R extends { buttons: number; }> implements IDisposable {
protected readonly hooks = new DisposableStore();
protected mouseMoveEventMerger: IEventMerger<R> | null = null;
protected mouseMoveCallback: IMouseMoveCallback<R> | null = null;
protected onStopCallback: IOnStopCallback | null = null;
private readonly _hooks = new DisposableStore();
private _mouseMoveEventMerger: IEventMerger<R> | null = null;
private _mouseMoveCallback: IMouseMoveCallback<R> | null = null;
private _onStopCallback: IOnStopCallback | null = null;
public dispose(): void {
this.stopMonitoring(false);
this.hooks.dispose();
this._hooks.dispose();
}
public stopMonitoring(invokeStopCallback: boolean): void {
@@ -57,11 +59,11 @@ export class GlobalMouseMoveMonitor<R> implements IDisposable {
}
// Unhook
this.hooks.clear();
this.mouseMoveEventMerger = null;
this.mouseMoveCallback = null;
const onStopCallback = this.onStopCallback;
this.onStopCallback = null;
this._hooks.clear();
this._mouseMoveEventMerger = null;
this._mouseMoveCallback = null;
const onStopCallback = this._onStopCallback;
this._onStopCallback = null;
if (invokeStopCallback && onStopCallback) {
onStopCallback();
@@ -69,10 +71,11 @@ export class GlobalMouseMoveMonitor<R> implements IDisposable {
}
public isMonitoring(): boolean {
return !!this.mouseMoveEventMerger;
return !!this._mouseMoveEventMerger;
}
public startMonitoring(
initialButtons: number,
mouseMoveEventMerger: IEventMerger<R>,
mouseMoveCallback: IMouseMoveCallback<R>,
onStopCallback: IOnStopCallback
@@ -81,40 +84,47 @@ export class GlobalMouseMoveMonitor<R> implements IDisposable {
// I am already hooked
return;
}
this.mouseMoveEventMerger = mouseMoveEventMerger;
this.mouseMoveCallback = mouseMoveCallback;
this.onStopCallback = onStopCallback;
this._mouseMoveEventMerger = mouseMoveEventMerger;
this._mouseMoveCallback = mouseMoveCallback;
this._onStopCallback = onStopCallback;
let windowChain = IframeUtils.getSameOriginWindowChain();
const mouseMove = platform.isIOS && BrowserFeatures.pointerEvents ? 'pointermove' : 'mousemove';
const mouseUp = platform.isIOS && BrowserFeatures.pointerEvents ? 'pointerup' : 'mouseup';
for (const element of windowChain) {
this.hooks.add(dom.addDisposableThrottledListener(element.window.document, mouseMove,
(data: R) => this.mouseMoveCallback!(data),
(lastEvent: R | null, currentEvent) => this.mouseMoveEventMerger!(lastEvent, currentEvent as MouseEvent)
this._hooks.add(dom.addDisposableThrottledListener(element.window.document, mouseMove,
(data: R) => {
if (data.buttons !== initialButtons) {
// Buttons state has changed in the meantime
this.stopMonitoring(true);
return;
}
this._mouseMoveCallback!(data);
},
(lastEvent: R | null, currentEvent) => this._mouseMoveEventMerger!(lastEvent, currentEvent as MouseEvent)
));
this.hooks.add(dom.addDisposableListener(element.window.document, mouseUp, (e: MouseEvent) => this.stopMonitoring(true)));
this._hooks.add(dom.addDisposableListener(element.window.document, mouseUp, (e: MouseEvent) => this.stopMonitoring(true)));
}
if (IframeUtils.hasDifferentOriginAncestor()) {
let lastSameOriginAncestor = windowChain[windowChain.length - 1];
// We might miss a mouse up if it happens outside the iframe
// This one is for Chrome
this.hooks.add(dom.addDisposableListener(lastSameOriginAncestor.window.document, 'mouseout', (browserEvent: MouseEvent) => {
this._hooks.add(dom.addDisposableListener(lastSameOriginAncestor.window.document, 'mouseout', (browserEvent: MouseEvent) => {
let e = new StandardMouseEvent(browserEvent);
if (e.target.tagName.toLowerCase() === 'html') {
this.stopMonitoring(true);
}
}));
// This one is for FF
this.hooks.add(dom.addDisposableListener(lastSameOriginAncestor.window.document, 'mouseover', (browserEvent: MouseEvent) => {
this._hooks.add(dom.addDisposableListener(lastSameOriginAncestor.window.document, 'mouseover', (browserEvent: MouseEvent) => {
let e = new StandardMouseEvent(browserEvent);
if (e.target.tagName.toLowerCase() === 'html') {
this.stopMonitoring(true);
}
}));
// This one is for IE
this.hooks.add(dom.addDisposableListener(lastSameOriginAncestor.window.document.body, 'mouseleave', (browserEvent: MouseEvent) => {
this._hooks.add(dom.addDisposableListener(lastSameOriginAncestor.window.document.body, 'mouseleave', (browserEvent: MouseEvent) => {
this.stopMonitoring(true);
}));
}

View File

@@ -12,6 +12,7 @@ export interface IMouseEvent {
readonly leftButton: boolean;
readonly middleButton: boolean;
readonly rightButton: boolean;
readonly buttons: number;
readonly target: HTMLElement;
readonly detail: number;
readonly posx: number;
@@ -33,6 +34,7 @@ export class StandardMouseEvent implements IMouseEvent {
public readonly leftButton: boolean;
public readonly middleButton: boolean;
public readonly rightButton: boolean;
public readonly buttons: number;
public readonly target: HTMLElement;
public detail: number;
public readonly posx: number;
@@ -49,6 +51,7 @@ export class StandardMouseEvent implements IMouseEvent {
this.leftButton = e.button === 0;
this.middleButton = e.button === 1;
this.rightButton = e.button === 2;
this.buttons = e.buttons;
this.target = <HTMLElement>e.target;

View File

@@ -130,7 +130,7 @@ export class Button extends Disposable {
applyStyles(): void {
if (this._element) {
const background = this.buttonBackground ? this.buttonBackground.toString() : '';
const foreground = this.buttonForeground ? this.buttonForeground.toString() : null;
const foreground = this.buttonForeground ? this.buttonForeground.toString() : '';
const border = this.buttonBorder ? this.buttonBorder.toString() : '';
this._element.style.color = foreground;

View File

@@ -220,7 +220,7 @@ export class SimpleCheckbox extends Widget {
}
protected applyStyles(): void {
this.domNode.style.color = this.styles.checkboxForeground ? this.styles.checkboxForeground.toString() : null;
this.domNode.style.color = this.styles.checkboxForeground ? this.styles.checkboxForeground.toString() : '';
this.domNode.style.backgroundColor = this.styles.checkboxBackground ? this.styles.checkboxBackground.toString() : '';
this.domNode.style.borderColor = this.styles.checkboxBorder ? this.styles.checkboxBorder.toString() : '';
}

View File

@@ -5,7 +5,7 @@
@font-face {
font-family: "codicon";
src: url("./codicon.ttf?17db7f5e5f31fd546e62218bb0823c0c") format("truetype");
src: url("./codicon.ttf?ed926e87ee4e27771159d875e877f74a") format("truetype");
}
.codicon[class*='codicon-'] {
@@ -409,4 +409,5 @@
.codicon-call-outgoing:before { content: "\eb93" }
.codicon-menu:before { content: "\eb94" }
.codicon-expand-all:before { content: "\eb95" }
.codicon-feedback:before { content: "\eb96" }
.codicon-debug-alt:before { content: "\f101" }

View File

@@ -392,6 +392,8 @@ class BranchNode implements ISplitView<ILayoutContext>, IDisposable {
const child = this._removeChild(from);
this._addChild(child, to);
this.onDidChildrenChange();
}
swapChildren(from: number, to: number): void {
@@ -408,6 +410,8 @@ class BranchNode implements ISplitView<ILayoutContext>, IDisposable {
this.splitview.swapViews(from, to);
[this.children[from].orthogonalStartSash, this.children[from].orthogonalEndSash, this.children[to].orthogonalStartSash, this.children[to].orthogonalEndSash] = [this.children[to].orthogonalStartSash, this.children[to].orthogonalEndSash, this.children[from].orthogonalStartSash, this.children[from].orthogonalEndSash];
[this.children[from], this.children[to]] = [this.children[to], this.children[from]];
this.onDidChildrenChange();
}
resizeChild(index: number, size: number): void {

View File

@@ -10,6 +10,7 @@ import { escape } from 'vs/base/common/strings';
export interface IHighlight {
start: number;
end: number;
extraClasses?: string;
}
export class HighlightedLabel {
@@ -69,7 +70,11 @@ export class HighlightedLabel {
htmlContent += '</span>';
pos = highlight.end;
}
htmlContent += '<span class="highlight">';
if (highlight.extraClasses) {
htmlContent += `<span class="highlight ${highlight.extraClasses}">`;
} else {
htmlContent += `<span class="highlight">`;
}
const substring = this.text.substring(highlight.start, highlight.end);
htmlContent += this.supportCodicons ? renderCodicons(escape(substring)) : escape(substring);
htmlContent += '</span>';

View File

@@ -511,7 +511,7 @@ export class InputBox extends Widget {
const styles = this.stylesForType(this.message.type);
spanElement.style.backgroundColor = styles.background ? styles.background.toString() : '';
spanElement.style.color = styles.foreground ? styles.foreground.toString() : null;
spanElement.style.color = styles.foreground ? styles.foreground.toString() : '';
spanElement.style.border = styles.border ? `1px solid ${styles.border}` : '';
dom.append(div, spanElement);

View File

@@ -597,12 +597,12 @@ class BaseMenuActionViewItem extends BaseActionViewItem {
const border = isSelected && this.menuStyle.selectionBorderColor ? `thin solid ${this.menuStyle.selectionBorderColor}` : '';
if (this.item) {
this.item.style.color = fgColor ? `${fgColor}` : null;
this.item.style.backgroundColor = bgColor ? `${bgColor}` : '';
this.item.style.color = fgColor ? fgColor.toString() : '';
this.item.style.backgroundColor = bgColor ? bgColor.toString() : '';
}
if (this.check) {
this.check.style.color = fgColor ? `${fgColor}` : '';
this.check.style.color = fgColor ? fgColor.toString() : '';
}
if (this.container) {

View File

@@ -20,6 +20,7 @@ import { INewScrollPosition, Scrollable, ScrollbarVisibility } from 'vs/base/com
const MOUSE_DRAG_RESET_DISTANCE = 140;
export interface ISimplifiedMouseEvent {
buttons: number;
posx: number;
posy: number;
}
@@ -222,6 +223,7 @@ export abstract class AbstractScrollbar extends Widget {
this.slider.toggleClassName('active', true);
this._mouseMoveMonitor.startMonitoring(
e.buttons,
standardMouseMoveMerger,
(mouseMoveData: IStandardMouseMoveEventData) => {
const mouseOrthogonalPosition = this._sliderOrthogonalMousePosition(mouseMoveData);

View File

@@ -93,6 +93,7 @@ export class ScrollbarArrow extends Widget {
this._mousedownScheduleRepeatTimer.cancelAndSet(scheduleRepeater, 200);
this._mouseMoveMonitor.startMonitoring(
e.buttons,
standardMouseMoveMerger,
(mouseMoveData: IStandardMouseMoveEventData) => {
/* Intentional empty */

View File

@@ -230,7 +230,7 @@ export abstract class Pane extends Disposable implements IView {
toggleClass(this.header, 'expanded', expanded);
this.header.setAttribute('aria-expanded', String(expanded));
this.header.style.color = this.styles.headerForeground ? this.styles.headerForeground.toString() : null;
this.header.style.color = this.styles.headerForeground ? this.styles.headerForeground.toString() : '';
this.header.style.backgroundColor = this.styles.headerBackground ? this.styles.headerBackground.toString() : '';
this.header.style.borderTop = this.styles.headerBorder ? `1px solid ${this.styles.headerBorder}` : '';
this._dropBackground = this.styles.dropBackground;

View File

@@ -190,7 +190,13 @@ function asListOptions<T, TFilterData, TRef>(modelProvider: () => ITreeModel<T,
},
getPosInSet(node) {
return node.visibleChildIndex + 1;
}
},
isChecked: options.ariaProvider && options.ariaProvider.isChecked ? (node) => {
return options.ariaProvider!.isChecked!(node.element);
} : undefined,
getRole: options.ariaProvider && options.ariaProvider.getRole ? (node) => {
return options.ariaProvider!.getRole!(node.element);
} : undefined
}
};
}

View File

@@ -258,7 +258,20 @@ function asObjectTreeOptions<TInput, T, TFilterData>(options?: IAsyncDataTreeOpt
e => (options.expandOnlyOnTwistieClick as ((e: T) => boolean))(e.element as T)
)
),
ariaProvider: undefined,
ariaProvider: options.ariaProvider && {
getPosInSet(el, index) {
return options.ariaProvider!.getPosInSet(el.element as T, index);
},
getSetSize(el, index, listLength) {
return options.ariaProvider!.getSetSize(el.element as T, index, listLength);
},
getRole: options.ariaProvider!.getRole ? (el) => {
return options.ariaProvider!.getRole!(el.element as T);
} : undefined,
isChecked: options.ariaProvider!.isChecked ? (e) => {
return options.ariaProvider?.isChecked!(e.element as T);
} : undefined
},
additionalScrollHeight: options.additionalScrollHeight
};
}