Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0366e573
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,发现更多精彩内容 >>
提交
0366e573
编写于
7月 22, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Track editor inputs and webview separately
上级
300eea40
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
36 addition
and
19 deletion
+36
-19
src/vs/workbench/api/browser/mainThreadWebview.ts
src/vs/workbench/api/browser/mainThreadWebview.ts
+36
-19
未找到文件。
src/vs/workbench/api/browser/mainThreadWebview.ts
浏览文件 @
0366e573
...
...
@@ -22,6 +22,7 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten
import
{
extHostNamedCustomer
}
from
'
../common/extHostCustomers
'
;
import
{
IProductService
}
from
'
vs/platform/product/common/product
'
;
import
{
startsWith
}
from
'
vs/base/common/strings
'
;
import
{
Webview
}
from
'
vs/workbench/contrib/webview/common/webview
'
;
interface
OldMainThreadWebviewState
{
readonly
viewType
:
string
;
...
...
@@ -41,9 +42,9 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
private
static
revivalPool
=
0
;
private
readonly
_proxy
:
ExtHostWebviewsShape
;
private
readonly
_webviews
=
new
Map
<
WebviewPanelHandle
,
WebviewEditorInput
>
();
private
readonly
_webviewEditorInputs
=
new
Map
<
string
,
WebviewEditorInput
>
();
private
readonly
_webviews
=
new
Map
<
string
,
Webview
>
();
private
readonly
_revivers
=
new
Map
<
string
,
IDisposable
>
();
private
_activeWebview
:
WebviewPanelHandle
|
undefined
=
undefined
;
...
...
@@ -103,7 +104,8 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
});
this
.
hookupWebviewEventDelegate
(
handle
,
webview
);
this
.
_webviews
.
set
(
handle
,
webview
);
this
.
_webviewEditorInputs
.
set
(
handle
,
webview
);
this
.
_webviews
.
set
(
handle
,
webview
.
webview
);
/* __GDPR__
"webviews:createWebviewPanel" : {
...
...
@@ -114,32 +116,32 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
}
public
$disposeWebview
(
handle
:
WebviewPanelHandle
):
void
{
const
webview
=
this
.
getWebview
(
handle
);
const
webview
=
this
.
getWebview
EditorInput
(
handle
);
webview
.
dispose
();
}
public
$setTitle
(
handle
:
WebviewPanelHandle
,
value
:
string
):
void
{
const
webview
=
this
.
getWebview
(
handle
);
const
webview
=
this
.
getWebview
EditorInput
(
handle
);
webview
.
setName
(
value
);
}
public
$setIconPath
(
handle
:
WebviewPanelHandle
,
value
:
{
light
:
UriComponents
,
dark
:
UriComponents
}
|
undefined
):
void
{
const
webview
=
this
.
getWebview
(
handle
);
const
webview
=
this
.
getWebview
EditorInput
(
handle
);
webview
.
iconPath
=
reviveWebviewIcon
(
value
);
}
public
$setHtml
(
handle
:
WebviewPanelHandle
,
value
:
string
):
void
{
const
webview
=
this
.
getWebview
(
handle
);
webview
.
webview
.
html
=
value
;
webview
.
html
=
value
;
}
public
$setOptions
(
handle
:
WebviewPanelHandle
,
options
:
modes
.
IWebviewOptions
):
void
{
const
webview
=
this
.
getWebview
(
handle
);
webview
.
webview
.
contentOptions
=
reviveWebviewOptions
(
options
as
any
/*todo@mat */
);
webview
.
contentOptions
=
reviveWebviewOptions
(
options
as
any
/*todo@mat */
);
}
public
$reveal
(
handle
:
WebviewPanelHandle
,
showOptions
:
WebviewPanelShowOptions
):
void
{
const
webview
=
this
.
getWebview
(
handle
);
const
webview
=
this
.
getWebview
EditorInput
(
handle
);
if
(
webview
.
isDisposed
())
{
return
;
}
...
...
@@ -152,7 +154,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
public
async
$postMessage
(
handle
:
WebviewPanelHandle
,
message
:
any
):
Promise
<
boolean
>
{
const
webview
=
this
.
getWebview
(
handle
);
webview
.
webview
.
sendMessage
(
message
);
webview
.
sendMessage
(
message
);
return
true
;
}
...
...
@@ -173,8 +175,10 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
}
const
handle
=
`revival-
${
MainThreadWebviews
.
revivalPool
++
}
`
;
this
.
_webviews
.
set
(
handle
,
webviewEditorInput
);
this
.
_webviewEditorInputs
.
set
(
handle
,
webviewEditorInput
);
this
.
_webviews
.
set
(
handle
,
webviewEditorInput
.
webview
);
this
.
hookupWebviewEventDelegate
(
handle
,
webviewEditorInput
);
let
state
=
undefined
;
if
(
webviewEditorInput
.
webview
.
state
)
{
try
{
...
...
@@ -229,11 +233,12 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
input
.
webview
.
onMessage
((
message
:
any
)
=>
this
.
_proxy
.
$onMessage
(
handle
,
message
));
input
.
onDispose
(()
=>
{
this
.
_proxy
.
$onDidDisposeWebviewPanel
(
handle
).
finally
(()
=>
{
this
.
_webviewEditorInputs
.
delete
(
handle
);
this
.
_webviews
.
delete
(
handle
);
});
});
input
.
webview
.
onDidUpdateState
((
newState
:
any
)
=>
{
const
webview
=
this
.
tryGetWebview
(
handle
);
const
webview
=
this
.
tryGetWebview
EditorInput
(
handle
);
if
(
!
webview
||
webview
.
isDisposed
())
{
return
;
}
...
...
@@ -245,8 +250,8 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
const
activeEditor
=
this
.
_editorService
.
activeControl
;
let
newActiveWebview
:
{
input
:
WebviewEditorInput
,
handle
:
WebviewPanelHandle
}
|
undefined
=
undefined
;
if
(
activeEditor
&&
activeEditor
.
input
instanceof
WebviewEditorInput
)
{
for
(
const
handle
of
map
.
keys
(
this
.
_webviews
))
{
const
input
=
this
.
_webviews
.
get
(
handle
)
!
;
for
(
const
handle
of
map
.
keys
(
this
.
_webview
EditorInput
s
))
{
const
input
=
this
.
_webview
EditorInput
s
.
get
(
handle
)
!
;
if
(
input
.
matches
(
activeEditor
.
input
))
{
newActiveWebview
=
{
input
,
handle
};
break
;
...
...
@@ -266,7 +271,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
// Broadcast view state update for currently active
if
(
typeof
this
.
_activeWebview
!==
'
undefined
'
)
{
const
oldActiveWebview
=
this
.
_webviews
.
get
(
this
.
_activeWebview
);
const
oldActiveWebview
=
this
.
_webview
EditorInput
s
.
get
(
this
.
_activeWebview
);
if
(
oldActiveWebview
)
{
this
.
_proxy
.
$onDidChangeWebviewPanelViewState
(
this
.
_activeWebview
,
{
active
:
false
,
...
...
@@ -290,7 +295,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
}
private
onVisibleEditorsChanged
():
void
{
this
.
_webviews
.
forEach
((
input
,
handle
)
=>
{
this
.
_webview
EditorInput
s
.
forEach
((
input
,
handle
)
=>
{
for
(
const
workbenchEditor
of
this
.
_editorService
.
visibleControls
)
{
if
(
workbenchEditor
.
input
&&
workbenchEditor
.
input
.
matches
(
input
))
{
const
editorPosition
=
editorGroupToViewColumn
(
this
.
_editorGroupService
,
workbenchEditor
.
group
!
);
...
...
@@ -312,7 +317,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
return
;
}
const
webview
=
this
.
getWebview
(
handle
);
const
webview
=
this
.
getWebview
EditorInput
(
handle
);
if
(
this
.
isSupportedLink
(
webview
,
link
))
{
this
.
_openerService
.
open
(
link
);
}
...
...
@@ -328,7 +333,19 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
return
!!
webview
.
webview
.
contentOptions
.
enableCommandUris
&&
link
.
scheme
===
'
command
'
;
}
private
getWebview
(
handle
:
WebviewPanelHandle
):
WebviewEditorInput
{
private
getWebviewEditorInput
(
handle
:
WebviewPanelHandle
):
WebviewEditorInput
{
const
webview
=
this
.
tryGetWebviewEditorInput
(
handle
);
if
(
!
webview
)
{
throw
new
Error
(
'
Unknown webview handle:
'
+
handle
);
}
return
webview
;
}
private
tryGetWebviewEditorInput
(
handle
:
WebviewPanelHandle
):
WebviewEditorInput
|
undefined
{
return
this
.
_webviewEditorInputs
.
get
(
handle
);
}
private
getWebview
(
handle
:
WebviewPanelHandle
):
Webview
{
const
webview
=
this
.
tryGetWebview
(
handle
);
if
(
!
webview
)
{
throw
new
Error
(
'
Unknown webview handle:
'
+
handle
);
...
...
@@ -336,7 +353,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
return
webview
;
}
private
tryGetWebview
(
handle
:
WebviewPanelHandle
):
Webview
EditorInput
|
undefined
{
private
tryGetWebview
(
handle
:
WebviewPanelHandle
):
Webview
|
undefined
{
return
this
.
_webviews
.
get
(
handle
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录