未验证 提交 8f8c09ed 编写于 作者: A Alex Dima

Remove other reference of monacoShadowRoot

上级 bb73c423
...@@ -827,14 +827,18 @@ export function isShadowRoot(node: Node): node is ShadowRoot { ...@@ -827,14 +827,18 @@ export function isShadowRoot(node: Node): node is ShadowRoot {
} }
export function isInShadowDOM(domNode: Node): boolean { export function isInShadowDOM(domNode: Node): boolean {
return !!getShadowRoot(domNode);
}
export function getShadowRoot(domNode: Node): ShadowRoot | null {
while (domNode.parentNode) { while (domNode.parentNode) {
if (domNode === document.body) { if (domNode === document.body) {
// reached the body // reached the body
return false; return null;
} }
domNode = domNode.parentNode; domNode = domNode.parentNode;
} }
return isShadowRoot(domNode); return isShadowRoot(domNode) ? domNode : null;
} }
export function createStyleSheet(container: HTMLElement = document.getElementsByTagName('head')[0]): HTMLStyleElement { export function createStyleSheet(container: HTMLElement = document.getElementsByTagName('head')[0]): HTMLStyleElement {
......
...@@ -17,6 +17,7 @@ import { HorizontalPosition } from 'vs/editor/common/view/renderingContext'; ...@@ -17,6 +17,7 @@ import { HorizontalPosition } from 'vs/editor/common/view/renderingContext';
import { ViewContext } from 'vs/editor/common/view/viewContext'; import { ViewContext } from 'vs/editor/common/view/viewContext';
import { IViewModel } from 'vs/editor/common/viewModel/viewModel'; import { IViewModel } from 'vs/editor/common/viewModel/viewModel';
import { CursorColumns } from 'vs/editor/common/controller/cursorCommon'; import { CursorColumns } from 'vs/editor/common/controller/cursorCommon';
import * as dom from 'vs/base/browser/dom';
export interface IViewZoneData { export interface IViewZoneData {
viewZoneId: string; viewZoneId: string;
...@@ -835,11 +836,13 @@ export class MouseTargetFactory { ...@@ -835,11 +836,13 @@ export class MouseTargetFactory {
} }
private static _actualDoHitTestWithCaretRangeFromPoint(ctx: HitTestContext, coords: ClientCoordinates): IHitTestResult { private static _actualDoHitTestWithCaretRangeFromPoint(ctx: HitTestContext, coords: ClientCoordinates): IHitTestResult {
const shadowRoot = dom.getShadowRoot(ctx.viewDomNode);
const docOrRoot = (window as any).monacoShadowRoot || document; let range: Range;
const range: Range = docOrRoot.caretRangeFromPoint(coords.clientX, coords.clientY); if (shadowRoot) {
range = shadowRoot.caretRangeFromPoint(coords.clientX, coords.clientY);
//const range: Range = document.caretRangeFromPoint(coords.clientX, coords.clientY); } else {
range = document.caretRangeFromPoint(coords.clientX, coords.clientY);
}
if (!range || !range.startContainer) { if (!range || !range.startContainer) {
return { return {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册