Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start moving window/document to use layout service #195827

Merged
merged 4 commits into from Oct 20, 2023
Merged

Start moving window/document to use layout service #195827

merged 4 commits into from Oct 20, 2023

Conversation

Tyriar
Copy link
Member

@Tyriar Tyriar commented Oct 17, 2023

Fixes #195804

@Tyriar Tyriar added this to the October 2023 milestone Oct 17, 2023
@Tyriar Tyriar self-assigned this Oct 17, 2023
@Tyriar
Copy link
Member Author

Tyriar commented Oct 17, 2023

@bpasero am I on the right track here?

Is it correct to be using this._layoutService.container.ownerDocument to get the primary document? I end up doing this a lot, do we have a layout service API for fetching the primary window and it's document directly? Something like this:

export interface ILayoutService {
  readonly primaryContainer: HTMLElement; // name would make this clearer
  readonly primaryDocument: Document;
  readonly primaryWindow: Window;
}

Copy link
Member

@bpasero bpasero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tyriar this looks good, except for document.createElement: you should use the global main document for now. The ownerDocument will automatically change as soon as the element is appended into the floating window. The advantage of document.createElement is that things like instanceof HTMLElement continue to work.

As for the additional properties on the layout service: I am really not sure that is a good idea because:

  • the main window and document are always accessible as a global
  • the correct window and document should always be computed based on the parent HTMLElement that you get to create your elements in and not by going to a service

@Tyriar Tyriar marked this pull request as ready for review October 20, 2023 20:30
@Tyriar Tyriar enabled auto-merge October 20, 2023 20:31
@Tyriar Tyriar merged commit cbd452f into main Oct 20, 2023
6 checks passed
@Tyriar Tyriar deleted the tyriar/195804 branch October 20, 2023 20:43
Alex0007 pushed a commit to Alex0007/vscode that referenced this pull request Oct 26, 2023
Start moving window/document to use layout service
@github-actions github-actions bot locked and limited conversation to collaborators Dec 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adopt DOM.getWindow in terminal
3 participants