mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
Fixes microsoft/monaco-editor#2175: Improve hit testing code on FF
This commit is contained in:
parent
9d9aebd2e6
commit
9934dea688
|
@ -940,12 +940,16 @@ export class MouseTargetFactory {
|
|||
}
|
||||
}
|
||||
|
||||
// For inline decorations, Gecko returns the `<span>` of the line and the offset is the `<span>` with the inline decoration
|
||||
// For inline decorations, Gecko sometimes returns the `<span>` of the line and the offset is the `<span>` with the inline decoration
|
||||
// Some other times, it returns the `<span>` with the inline decoration
|
||||
if (hitResult.offsetNode.nodeType === hitResult.offsetNode.ELEMENT_NODE) {
|
||||
const parent1 = hitResult.offsetNode.parentNode; // expected to be the view line div
|
||||
const parent1 = hitResult.offsetNode.parentNode;
|
||||
const parent1ClassName = parent1 && parent1.nodeType === parent1.ELEMENT_NODE ? (<HTMLElement>parent1).className : null;
|
||||
const parent2 = parent1 ? parent1.parentNode : null;
|
||||
const parent2ClassName = parent2 && parent2.nodeType === parent2.ELEMENT_NODE ? (<HTMLElement>parent2).className : null;
|
||||
|
||||
if (parent1ClassName === ViewLine.CLASS_NAME) {
|
||||
// it returned the `<span>` of the line and the offset is the `<span>` with the inline decoration
|
||||
const tokenSpan = hitResult.offsetNode.childNodes[Math.min(hitResult.offset, hitResult.offsetNode.childNodes.length - 1)];
|
||||
if (tokenSpan) {
|
||||
const p = ctx.getPositionFromDOMInfo(<HTMLElement>tokenSpan, 0);
|
||||
|
@ -954,6 +958,13 @@ export class MouseTargetFactory {
|
|||
hitTarget: null
|
||||
};
|
||||
}
|
||||
} else if (parent2ClassName === ViewLine.CLASS_NAME) {
|
||||
// it returned the `<span>` with the inline decoration
|
||||
const p = ctx.getPositionFromDOMInfo(<HTMLElement>hitResult.offsetNode, 0);
|
||||
return {
|
||||
position: p,
|
||||
hitTarget: null
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue