mirror of
https://github.com/microsoft/vscode.git
synced 2026-08-20 07:03:06 +01:00
Change IBaseMouseTarget.element to be an HTMLElement
This commit is contained in:
@@ -29,7 +29,7 @@ const enum HitTestResultType {
|
||||
class UnknownHitTestResult {
|
||||
readonly type = HitTestResultType.Unknown;
|
||||
constructor(
|
||||
readonly hitTarget: Element | null = null
|
||||
readonly hitTarget: HTMLElement | null = null
|
||||
) { }
|
||||
}
|
||||
|
||||
@@ -72,31 +72,31 @@ export class MouseTarget {
|
||||
}
|
||||
return range ?? null;
|
||||
}
|
||||
public static createUnknown(element: Element | null, mouseColumn: number, position: Position | null): IMouseTargetUnknown {
|
||||
public static createUnknown(element: HTMLElement | null, mouseColumn: number, position: Position | null): IMouseTargetUnknown {
|
||||
return { type: MouseTargetType.UNKNOWN, element, mouseColumn, position, range: this._deduceRage(position) };
|
||||
}
|
||||
public static createTextarea(element: Element | null, mouseColumn: number): IMouseTargetTextarea {
|
||||
public static createTextarea(element: HTMLElement | null, mouseColumn: number): IMouseTargetTextarea {
|
||||
return { type: MouseTargetType.TEXTAREA, element, mouseColumn, position: null, range: null };
|
||||
}
|
||||
public static createMargin(type: MouseTargetType.GUTTER_GLYPH_MARGIN | MouseTargetType.GUTTER_LINE_NUMBERS | MouseTargetType.GUTTER_LINE_DECORATIONS, element: Element | null, mouseColumn: number, position: Position, range: EditorRange, detail: IMouseTargetMarginData): IMouseTargetMargin {
|
||||
public static createMargin(type: MouseTargetType.GUTTER_GLYPH_MARGIN | MouseTargetType.GUTTER_LINE_NUMBERS | MouseTargetType.GUTTER_LINE_DECORATIONS, element: HTMLElement | null, mouseColumn: number, position: Position, range: EditorRange, detail: IMouseTargetMarginData): IMouseTargetMargin {
|
||||
return { type, element, mouseColumn, position, range, detail };
|
||||
}
|
||||
public static createViewZone(type: MouseTargetType.GUTTER_VIEW_ZONE | MouseTargetType.CONTENT_VIEW_ZONE, element: Element | null, mouseColumn: number, position: Position, detail: IMouseTargetViewZoneData): IMouseTargetViewZone {
|
||||
public static createViewZone(type: MouseTargetType.GUTTER_VIEW_ZONE | MouseTargetType.CONTENT_VIEW_ZONE, element: HTMLElement | null, mouseColumn: number, position: Position, detail: IMouseTargetViewZoneData): IMouseTargetViewZone {
|
||||
return { type, element, mouseColumn, position, range: this._deduceRage(position), detail };
|
||||
}
|
||||
public static createContentText(element: Element | null, mouseColumn: number, position: Position, range: EditorRange | null, detail: IMouseTargetContentTextData): IMouseTargetContentText {
|
||||
public static createContentText(element: HTMLElement | null, mouseColumn: number, position: Position, range: EditorRange | null, detail: IMouseTargetContentTextData): IMouseTargetContentText {
|
||||
return { type: MouseTargetType.CONTENT_TEXT, element, mouseColumn, position, range: this._deduceRage(position, range), detail };
|
||||
}
|
||||
public static createContentEmpty(element: Element | null, mouseColumn: number, position: Position, detail: IMouseTargetContentEmptyData): IMouseTargetContentEmpty {
|
||||
public static createContentEmpty(element: HTMLElement | null, mouseColumn: number, position: Position, detail: IMouseTargetContentEmptyData): IMouseTargetContentEmpty {
|
||||
return { type: MouseTargetType.CONTENT_EMPTY, element, mouseColumn, position, range: this._deduceRage(position), detail };
|
||||
}
|
||||
public static createContentWidget(element: Element | null, mouseColumn: number, detail: string): IMouseTargetContentWidget {
|
||||
public static createContentWidget(element: HTMLElement | null, mouseColumn: number, detail: string): IMouseTargetContentWidget {
|
||||
return { type: MouseTargetType.CONTENT_WIDGET, element, mouseColumn, position: null, range: null, detail };
|
||||
}
|
||||
public static createScrollbar(element: Element | null, mouseColumn: number, position: Position): IMouseTargetScrollbar {
|
||||
public static createScrollbar(element: HTMLElement | null, mouseColumn: number, position: Position): IMouseTargetScrollbar {
|
||||
return { type: MouseTargetType.SCROLLBAR, element, mouseColumn, position, range: this._deduceRage(position) };
|
||||
}
|
||||
public static createOverlayWidget(element: Element | null, mouseColumn: number, detail: string): IMouseTargetOverlayWidget {
|
||||
public static createOverlayWidget(element: HTMLElement | null, mouseColumn: number, detail: string): IMouseTargetOverlayWidget {
|
||||
return { type: MouseTargetType.OVERLAY_WIDGET, element, mouseColumn, position: null, range: null, detail };
|
||||
}
|
||||
public static createOutsideEditor(mouseColumn: number, position: Position, outsidePosition: 'above' | 'below' | 'left' | 'right', outsideDistance: number): IMouseTargetOutsideEditor {
|
||||
@@ -389,10 +389,10 @@ abstract class BareHitTestRequest {
|
||||
|
||||
class HitTestRequest extends BareHitTestRequest {
|
||||
private readonly _ctx: HitTestContext;
|
||||
public readonly target: Element | null;
|
||||
public readonly target: HTMLElement | null;
|
||||
public readonly targetPath: Uint8Array;
|
||||
|
||||
constructor(ctx: HitTestContext, editorPos: EditorPagePosition, pos: PageCoordinates, relativePos: CoordinatesRelativeToEditor, target: Element | null) {
|
||||
constructor(ctx: HitTestContext, editorPos: EditorPagePosition, pos: PageCoordinates, relativePos: CoordinatesRelativeToEditor, target: HTMLElement | null) {
|
||||
super(ctx, editorPos, pos, relativePos);
|
||||
this._ctx = ctx;
|
||||
|
||||
@@ -445,13 +445,13 @@ class HitTestRequest extends BareHitTestRequest {
|
||||
return MouseTarget.createOverlayWidget(this.target, this._getMouseColumn(), detail);
|
||||
}
|
||||
|
||||
public withTarget(target: Element | null): HitTestRequest {
|
||||
public withTarget(target: HTMLElement | null): HitTestRequest {
|
||||
return new HitTestRequest(this._ctx, this.editorPos, this.pos, this.relativePos, target);
|
||||
}
|
||||
}
|
||||
|
||||
interface ResolvedHitTestRequest extends HitTestRequest {
|
||||
readonly target: Element;
|
||||
readonly target: HTMLElement;
|
||||
}
|
||||
|
||||
const EMPTY_CONTENT_AFTER_LINES: IMouseTargetContentEmptyData = { isAfterLines: true };
|
||||
|
||||
@@ -358,7 +358,7 @@ export interface IBaseMouseTarget {
|
||||
/**
|
||||
* The target element
|
||||
*/
|
||||
readonly element: Element | null;
|
||||
readonly element: HTMLElement | null;
|
||||
/**
|
||||
* The 'approximate' editor position
|
||||
*/
|
||||
|
||||
@@ -407,7 +407,7 @@ export class FoldingController extends Disposable implements IEditorContribution
|
||||
switch (e.target.type) {
|
||||
case MouseTargetType.GUTTER_LINE_DECORATIONS: {
|
||||
const data = e.target.detail;
|
||||
const offsetLeftInGutter = (e.target.element as HTMLElement).offsetLeft;
|
||||
const offsetLeftInGutter = e.target.element!.offsetLeft;
|
||||
const gutterOffsetX = data.offsetX - offsetLeftInGutter;
|
||||
|
||||
// const gutterOffsetX = data.offsetX - data.glyphMarginWidth - data.lineNumbersWidth - data.glyphMarginLeft;
|
||||
|
||||
Vendored
+1
-1
@@ -5535,7 +5535,7 @@ declare namespace monaco.editor {
|
||||
/**
|
||||
* The target element
|
||||
*/
|
||||
readonly element: Element | null;
|
||||
readonly element: HTMLElement | null;
|
||||
/**
|
||||
* The 'approximate' editor position
|
||||
*/
|
||||
|
||||
@@ -918,7 +918,7 @@ export class DirtyDiffController extends Disposable implements DirtyDiffContribu
|
||||
}
|
||||
|
||||
const data = e.target.detail;
|
||||
const offsetLeftInGutter = (e.target.element as HTMLElement).offsetLeft;
|
||||
const offsetLeftInGutter = e.target.element.offsetLeft;
|
||||
const gutterOffsetX = data.offsetX - offsetLeftInGutter;
|
||||
|
||||
// TODO@joao TODO@alex TODO@martin this is such that we don't collide with folding
|
||||
|
||||
Reference in New Issue
Block a user