@@ -27,15 +27,15 @@ Subject: [PATCH] feat: support shadow dom
2727 .../hover/browser/contentHoverWidget.ts | 2 +-
2828 .../actionWidget/browser/actionList.ts | 2 +-
2929 .../clipboard/browser/clipboardService.ts | 4 +--
30- .../contextkey/browser/contextKeyService.ts | 8 ++++--
30+ .../contextkey/browser/contextKeyService.ts | 15 ++++++-- --
3131 src/vs/workbench/browser/layout.ts | 3 ++
3232 .../browser/parts/editor/editorGroupView.ts | 4 +--
3333 src/vs/workbench/browser/workbench.ts | 6 ++--
3434 .../contrib/chat/browser/chatInputPart.ts | 2 +-
3535 .../chatSessions/view/sessionsTreeRenderer.ts | 3 +-
3636 .../files/browser/views/explorerViewer.ts | 4 ++-
3737 .../notebook/browser/notebookEditorWidget.ts | 6 ++--
38- .../browser/view/cellParts/cellStatusPart.ts | 6 ++--
38+ .../browser/view/cellParts/cellStatusPart.ts | 5 ++--
3939 .../browser/view/cellParts/codeCell.ts | 5 ++--
4040 .../browser/view/cellParts/markupCell.ts | 6 ++--
4141 .../notebook/browser/view/notebookCellList.ts | 5 ++--
@@ -49,7 +49,7 @@ Subject: [PATCH] feat: support shadow dom
4949 .../browser/walkThroughPart.ts | 6 ++--
5050 .../suggest/browser/simpleSuggestWidget.ts | 4 +--
5151 .../themes/browser/workbenchThemeService.ts | 2 +-
52- 45 files changed, 143 insertions(+), 88 deletions(-)
52+ 45 files changed, 146 insertions(+), 91 deletions(-)
5353
5454diff --git a/src/vs/base/browser/dom.ts b/src/vs/base/browser/dom.ts
5555index 4681d190ae7..d014d87fb7e 100644
@@ -624,24 +624,43 @@ index 6e0a6e018d0..358aa682cda 100644
624624 const textArea: HTMLTextAreaElement = activeDocument.body.appendChild($('textarea', { 'aria-hidden': true }));
625625 textArea.style.height = '1px';
626626diff --git a/src/vs/platform/contextkey/browser/contextKeyService.ts b/src/vs/platform/contextkey/browser/contextKeyService.ts
627- index 7f749b68489..224b4bbb255 100644
627+ index 7f749b68489..53629be4418 100644
628628--- a/src/vs/platform/contextkey/browser/contextKeyService.ts
629629+++ b/src/vs/platform/contextkey/browser/contextKeyService.ts
630- @@ -18,7 +18,7 @@ import { ContextKeyExpression, ContextKeyInfo, ContextKeyValue, IContext, IConte
630+ @@ -18,7 +18,8 @@ import { ContextKeyExpression, ContextKeyInfo, ContextKeyValue, IContext, IConte
631631 import { ServicesAccessor } from '../../instantiation/common/instantiation.js';
632632 import { InputFocusedContext } from '../common/contextkeys.js';
633633 import { mainWindow } from '../../../base/browser/window.js';
634634- import { addDisposableListener, EventType, getActiveWindow, isEditableElement, onDidRegisterWindow, trackFocus } from '../../../base/browser/dom.js';
635- + import { addDisposableListener, EventType, getActiveElement, getActiveWindow, isEditableElement, onDidRegisterWindow, trackFocus } from '../../../base/browser/dom.js';
635+ + import { addDisposableListener, EventType, getActiveDocument, getActiveElement, isEditableElement, onDidRegisterWindow, trackFocus } from '../../../base/browser/dom.js';
636+ + import { ILayoutService } from '../../layout/browser/layoutService.js';
636637
637638 const KEYBINDING_CONTEXT_ATTR = 'data-keybinding-context';
638639
639- @@ -414,14 +414,16 @@ export class ContextKeyService extends AbstractContextKeyService implements ICon
640+ @@ -383,7 +384,7 @@ export class ContextKeyService extends AbstractContextKeyService implements ICon
641+
642+ private inputFocusedContext: IContextKey<boolean>;
643+
644+ - constructor(@IConfigurationService configurationService: IConfigurationService) {
645+ + constructor(@IConfigurationService configurationService: IConfigurationService, @ILayoutService layoutService: ILayoutService) {
646+ super(0);
647+ this._lastContextId = 0;
648+ this.inputFocusedContext = InputFocusedContext.bindTo(this);
649+ @@ -404,7 +405,7 @@ export class ContextKeyService extends AbstractContextKeyService implements ICon
650+
651+ this._register(Event.runAndSubscribe(onDidRegisterWindow, ({ window, disposables }) => {
652+ const onFocusDisposables = disposables.add(new MutableDisposable<DisposableStore>());
653+ - disposables.add(addDisposableListener(window, EventType.FOCUS_IN, () => {
654+ + disposables.add(addDisposableListener(layoutService.getContainer(window), EventType.FOCUS_IN, () => {
655+ onFocusDisposables.value = new DisposableStore();
656+ this.updateInputContextKeys(window.document, onFocusDisposables.value);
657+ }, true));
658+ @@ -414,14 +415,16 @@ export class ContextKeyService extends AbstractContextKeyService implements ICon
640659 private updateInputContextKeys(ownerDocument: Document, disposables: DisposableStore): void {
641660
642661 function activeElementIsInput(): boolean {
643662- return !!ownerDocument.activeElement && isEditableElement(ownerDocument.activeElement);
644- + const activeElement = getActiveElement(ownerDocument)
663+ + const activeElement = getActiveElement(ownerDocument);
645664+ return !!activeElement && isEditableElement(activeElement);
646665 }
647666
@@ -650,11 +669,20 @@ index 7f749b68489..224b4bbb255 100644
650669
651670 if (isInputFocused) {
652671- const tracker = disposables.add(trackFocus(ownerDocument.activeElement as HTMLElement));
653- + const activeElement = getActiveElement(ownerDocument)
672+ + const activeElement = getActiveElement(ownerDocument);
654673+ const tracker = disposables.add(trackFocus(activeElement as HTMLElement));
655674 Event.once(tracker.onDidBlur)(() => {
656675
657676 // Ensure we are only updating the context key if we are
677+ @@ -432,7 +435,7 @@ export class ContextKeyService extends AbstractContextKeyService implements ICon
678+ // blur events from the focus tracker are emitted with a
679+ // timeout of 0.
680+
681+ - if (getActiveWindow().document === ownerDocument) {
682+ + if (getActiveDocument() === ownerDocument) {
683+ this.inputFocusedContext.set(activeElementIsInput());
684+ }
685+
658686diff --git a/src/vs/workbench/browser/layout.ts b/src/vs/workbench/browser/layout.ts
659687index 668450c90ec..0d38acdef02 100644
660688--- a/src/vs/workbench/browser/layout.ts
@@ -805,31 +833,23 @@ index 2f3fe9d654d..6b153251b34 100644
805833
806834 this._webview?.blurOutput();
807835diff --git a/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellStatusPart.ts b/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellStatusPart.ts
808- index a23d2f8b28e..6e98527bc7e 100644
836+ index a23d2f8b28e..3f9739cf607 100644
809837--- a/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellStatusPart.ts
810838+++ b/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellStatusPart.ts
811- @@ -32,6 +32,7 @@ import { IHoverService } from '../../../../../../platform/hover/browser/hover.js
812- import { IConfigurationService } from '../../../../../../platform/configuration/common/configuration.js';
813- import { HoverPosition } from '../../../../../../base/browser/ui/hover/hoverWidget.js';
814- import type { IManagedHoverTooltipMarkdownString } from '../../../../../../base/browser/ui/hover/hover.js';
815- + import { getActiveElement } from '../../../../../../base/browser/dom.js';
816-
817- const $ = DOM.$;
818-
819- @@ -146,7 +147,7 @@ export class CellEditorStatusBar extends CellContentPart {
839+ @@ -146,7 +146,7 @@ export class CellEditorStatusBar extends CellContentPart {
820840 if (this._editor) {
821841 // Focus Mode
822842 const updateFocusModeForEditorEvent = () => {
823843- if (this._editor && (this._editor.hasWidgetFocus() || (this.statusBarContainer.ownerDocument.activeElement && this.statusBarContainer.contains(this.statusBarContainer.ownerDocument.activeElement)))) {
824- + if (this._editor && (this._editor.hasWidgetFocus() || (DOM.getActiveElement(this.statusBarContainer.ownerDocument) && this.statusBarContainer.contains(getActiveElement(this.statusBarContainer.ownerDocument))))) {
844+ + if (this._editor && (this._editor.hasWidgetFocus() || (DOM.getActiveElement(this.statusBarContainer.ownerDocument) && this.statusBarContainer.contains(DOM. getActiveElement(this.statusBarContainer.ownerDocument))))) {
825845 element.focusMode = CellFocusMode.Editor;
826846 } else {
827847 const currentMode = element.focusMode;
828- @@ -167,9 +168 ,10 @@ export class CellEditorStatusBar extends CellContentPart {
848+ @@ -167,9 +167 ,10 @@ export class CellEditorStatusBar extends CellContentPart {
829849 // this is for a special case:
830850 // users click the status bar empty space, which we will then focus the editor
831851 // so we don't want to update the focus state too eagerly, it will be updated with onDidFocusEditorWidget
832- + const activeElement = getActiveElement(this.statusBarContainer.ownerDocument);
852+ + const activeElement = DOM. getActiveElement(this.statusBarContainer.ownerDocument);
833853 if (
834854 this._notebookEditor.hasEditorFocus() &&
835855- !(this.statusBarContainer.ownerDocument.activeElement && this.statusBarContainer.contains(this.statusBarContainer.ownerDocument.activeElement))) {
0 commit comments