Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
2091f715
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2091f715
编写于
7月 17, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Don't hang on to webview in `WebviewEditor`
上级
eb0dc4c5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
33 deletion
+23
-33
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
+21
-30
src/vs/workbench/contrib/webview/browser/webviewEditorInput.ts
...s/workbench/contrib/webview/browser/webviewEditorInput.ts
+2
-3
未找到文件。
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
浏览文件 @
2091f715
...
...
@@ -23,7 +23,7 @@ export class WebviewEditor extends BaseEditor {
public
static
readonly
ID
=
'
WebviewEditor
'
;
private
_webview
:
WebviewEditorOverlay
|
undefined
;
private
readonly
_scopedContextKeyService
=
this
.
_register
(
new
MutableDisposable
<
IContextKeyService
>
())
;
private
_findWidgetVisible
:
IContextKey
<
boolean
>
;
private
_editorFrame
?:
HTMLElement
;
...
...
@@ -38,15 +38,14 @@ export class WebviewEditor extends BaseEditor {
constructor
(
@
ITelemetryService
telemetryService
:
ITelemetryService
,
@
IThemeService
themeService
:
IThemeService
,
@
IContextKeyService
private
_contextKeyService
:
IContextKeyService
,
@
IContextKeyService
private
readonly
_contextKeyService
:
IContextKeyService
,
@
IEditorService
private
readonly
_editorService
:
IEditorService
,
@
IWindowService
private
readonly
_windowService
:
IWindowService
,
@
IStorageService
storageService
:
IStorageService
)
{
super
(
WebviewEditor
.
ID
,
telemetryService
,
themeService
,
storageService
);
if
(
_contextKeyService
)
{
this
.
_findWidgetVisible
=
KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE
.
bindTo
(
_contextKeyService
);
}
this
.
_findWidgetVisible
=
KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE
.
bindTo
(
_contextKeyService
);
}
public
get
isWebviewEditor
()
{
...
...
@@ -85,16 +84,15 @@ export class WebviewEditor extends BaseEditor {
}
public
layout
(
_dimension
:
DOM
.
Dimension
):
void
{
if
(
this
.
_webview
)
{
this
.
doUpdateContainer
(
this
.
_
webview
);
this
.
_
webview
.
layout
();
if
(
this
.
input
&&
this
.
input
instanceof
WebviewEditorInput
)
{
this
.
synchronizeWebviewContainerDimensions
(
this
.
input
.
webview
);
this
.
input
.
webview
.
layout
();
}
}
public
focus
():
void
{
super
.
focus
();
if
(
!
this
.
_onFocusWindowHandler
.
value
)
{
// Make sure we restore focus when switching back to a VS Code window
this
.
_onFocusWindowHandler
.
value
=
this
.
_windowService
.
onDidChangeFocus
(
focused
=>
{
if
(
focused
&&
this
.
_editorService
.
activeControl
===
this
)
{
...
...
@@ -106,13 +104,13 @@ export class WebviewEditor extends BaseEditor {
}
public
withWebview
(
f
:
(
element
:
Webview
)
=>
void
):
void
{
if
(
this
.
_webview
)
{
f
(
this
.
_
webview
);
if
(
this
.
input
&&
this
.
input
instanceof
WebviewEditorInput
)
{
f
(
this
.
input
.
webview
);
}
}
protected
setEditorVisible
(
visible
:
boolean
,
group
:
IEditorGroup
):
void
{
const
webview
=
(
this
.
input
&&
(
this
.
input
as
WebviewEditorInput
).
webview
)
||
this
.
_
webview
;
const
webview
=
this
.
input
&&
(
this
.
input
as
WebviewEditorInput
).
webview
;
if
(
webview
)
{
if
(
visible
)
{
webview
.
claim
(
this
);
...
...
@@ -130,14 +128,12 @@ export class WebviewEditor extends BaseEditor {
this
.
input
.
webview
.
release
(
this
);
}
this
.
_webview
=
undefined
;
super
.
clearInput
();
}
public
async
setInput
(
input
:
WebviewEditorInput
,
options
:
EditorOptions
,
token
:
CancellationToken
):
Promise
<
void
>
{
if
(
this
.
input
&&
(
this
.
input
as
WebviewEditorInput
).
webview
)
{
(
this
.
input
as
WebviewEditorInput
).
webview
!
.
release
(
this
);
this
.
_webview
=
undefined
;
if
(
this
.
input
&&
this
.
input
instanceof
WebviewEditorInput
)
{
this
.
input
.
webview
.
release
(
this
);
}
await
super
.
setInput
(
input
,
options
,
token
);
...
...
@@ -149,32 +145,27 @@ export class WebviewEditor extends BaseEditor {
if
(
this
.
group
)
{
input
.
updateGroup
(
this
.
group
.
id
);
}
this
.
claimWebview
(
input
);
}
private
claimWebview
(
input
:
WebviewEditorInput
):
void
{
if
(
this
.
_webview
)
{
this
.
_webview
.
claim
(
this
);
return
;
}
this
.
_webview
=
input
.
webview
;
this
.
_webview
.
claim
(
this
);
input
.
webview
.
claim
(
this
);
if
(
this
.
_
webview
.
options
.
enableFindWidget
)
{
this
.
_
contextKeyService
=
this
.
_register
(
this
.
_contextKeyService
.
createScoped
(
this
.
_webview
.
container
)
);
this
.
_findWidgetVisible
=
KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE
.
bindTo
(
this
.
_
contextKeyServic
e
);
if
(
input
.
webview
.
options
.
enableFindWidget
)
{
this
.
_
scopedContextKeyService
.
value
=
this
.
_contextKeyService
.
createScoped
(
input
.
webview
.
container
);
this
.
_findWidgetVisible
=
KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE
.
bindTo
(
this
.
_
scopedContextKeyService
.
valu
e
);
}
if
(
this
.
_content
)
{
this
.
_content
.
setAttribute
(
'
aria-flowto
'
,
this
.
_
webview
.
container
.
id
);
this
.
_content
.
setAttribute
(
'
aria-flowto
'
,
input
.
webview
.
container
.
id
);
}
this
.
doUpdateContainer
(
this
.
_
webview
);
this
.
trackFocus
(
this
.
_
webview
);
this
.
synchronizeWebviewContainerDimensions
(
input
.
webview
);
this
.
trackFocus
(
input
.
webview
);
}
private
doUpdateContainer
(
webview
:
WebviewEditorOverlay
)
{
private
synchronizeWebviewContainerDimensions
(
webview
:
WebviewEditorOverlay
)
{
const
webviewContainer
=
webview
.
container
;
if
(
webviewContainer
&&
webviewContainer
.
parentElement
&&
this
.
_editorFrame
)
{
const
frameRect
=
this
.
_editorFrame
.
getBoundingClientRect
();
...
...
src/vs/workbench/contrib/webview/browser/webviewEditorInput.ts
浏览文件 @
2091f715
...
...
@@ -59,7 +59,6 @@ export class WebviewEditorInput extends EditorInput {
private
_iconPath
?:
{
light
:
URI
,
dark
:
URI
};
private
_group
?:
GroupIdentifier
;
constructor
(
public
readonly
id
:
string
,
public
readonly
viewType
:
string
,
...
...
@@ -123,8 +122,8 @@ export class WebviewEditorInput extends EditorInput {
return
this
.
_group
;
}
public
resolve
():
Promise
<
IEditorModel
>
{
return
Promise
.
resolve
(
new
EditorModel
()
);
public
async
resolve
():
Promise
<
IEditorModel
>
{
return
new
EditorModel
(
);
}
public
supportsSplitEditor
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录