Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
f57ff0b2
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,发现更多精彩内容 >>
提交
f57ff0b2
编写于
7月 10, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove webview _onBeforeShutdown
This should no longer be required
上级
c9e83415
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
32 addition
and
33 deletion
+32
-33
src/vs/workbench/api/browser/mainThreadWebview.ts
src/vs/workbench/api/browser/mainThreadWebview.ts
+22
-21
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
+1
-1
src/vs/workbench/contrib/webview/browser/webviewEditorInput.ts
...s/workbench/contrib/webview/browser/webviewEditorInput.ts
+8
-11
src/vs/workbench/contrib/webview/browser/webviewEditorService.ts
...workbench/contrib/webview/browser/webviewEditorService.ts
+1
-0
未找到文件。
src/vs/workbench/api/browser/mainThreadWebview.ts
浏览文件 @
f57ff0b2
...
...
@@ -10,7 +10,6 @@ import { URI, UriComponents } from 'vs/base/common/uri';
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
ExtensionIdentifier
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
ExtHostContext
,
ExtHostWebviewsShape
,
IExtHostContext
,
MainContext
,
MainThreadWebviewsShape
,
WebviewPanelHandle
,
WebviewPanelShowOptions
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
...
...
@@ -24,6 +23,11 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten
import
{
extHostNamedCustomer
}
from
'
../common/extHostCustomers
'
;
import
{
IProductService
}
from
'
vs/platform/product/common/product
'
;
interface
MainThreadWebviewState
{
readonly
viewType
:
string
;
state
:
any
;
}
@
extHostNamedCustomer
(
MainContext
.
MainThreadWebviews
)
export
class
MainThreadWebviews
extends
Disposable
implements
MainThreadWebviewsShape
{
...
...
@@ -39,14 +43,13 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
private
readonly
_proxy
:
ExtHostWebviewsShape
;
private
readonly
_webviews
=
new
Map
<
WebviewPanelHandle
,
WebviewEditorInput
>
();
private
readonly
_webviews
=
new
Map
<
WebviewPanelHandle
,
WebviewEditorInput
<
MainThreadWebviewState
>
>
();
private
readonly
_revivers
=
new
Map
<
string
,
IDisposable
>
();
private
_activeWebview
:
WebviewPanelHandle
|
undefined
=
undefined
;
constructor
(
context
:
IExtHostContext
,
@
ILifecycleService
lifecycleService
:
ILifecycleService
,
@
IExtensionService
extensionService
:
IExtensionService
,
@
IEditorGroupsService
private
readonly
_editorGroupService
:
IEditorGroupsService
,
@
IEditorService
private
readonly
_editorService
:
IEditorService
,
...
...
@@ -64,20 +67,15 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
// This reviver's only job is to activate webview extensions
// This should trigger the real reviver to be registered from the extension host side.
this
.
_register
(
_webviewEditorService
.
registerReviver
({
canRevive
:
(
webview
)
=>
{
const
viewType
=
webview
.
state
.
viewType
;
if
(
viewType
)
{
canRevive
:
(
webview
:
WebviewEditorInput
<
any
>
)
=>
{
const
viewType
=
webview
.
state
&&
webview
.
state
.
viewType
;
if
(
typeof
viewType
===
'
string
'
)
{
extensionService
.
activateByEvent
(
`onWebviewPanel:
${
viewType
}
`
);
}
return
false
;
},
reviveWebview
:
()
=>
{
throw
new
Error
(
'
not implemented
'
);
}
}));
this
.
_register
(
lifecycleService
.
onBeforeShutdown
(
e
=>
{
this
.
_onBeforeShutdown
();
e
.
veto
(
false
);
// Don't veto shutdown
},
this
));
}
public
$createWebviewPanel
(
...
...
@@ -98,7 +96,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
const
webview
=
this
.
_webviewEditorService
.
createWebview
(
this
.
getInternalWebviewId
(
viewType
),
title
,
mainThreadShowOptions
,
reviveWebviewOptions
(
options
),
{
location
:
URI
.
revive
(
extensionLocation
),
id
:
extensionId
},
this
.
createWebviewEventDelegate
(
handle
));
},
this
.
createWebviewEventDelegate
(
handle
))
as
WebviewEditorInput
<
MainThreadWebviewState
>
;
webview
.
state
=
{
viewType
:
viewType
,
state
:
undefined
...
...
@@ -218,14 +216,6 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
return
`mainThreadWebview-
${
viewType
}
`
;
}
private
_onBeforeShutdown
():
void
{
this
.
_webviews
.
forEach
((
webview
)
=>
{
if
(
!
webview
.
isDisposed
()
&&
webview
.
state
&&
this
.
_revivers
.
has
(
webview
.
state
.
viewType
))
{
webview
.
state
.
state
=
webview
.
webviewState
;
}
});
}
private
createWebviewEventDelegate
(
handle
:
WebviewPanelHandle
)
{
return
{
onDidClickLink
:
(
uri
:
URI
)
=>
this
.
onDidClickLink
(
handle
,
uri
),
...
...
@@ -234,6 +224,13 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
this
.
_proxy
.
$onDidDisposeWebviewPanel
(
handle
).
finally
(()
=>
{
this
.
_webviews
.
delete
(
handle
);
});
},
onDidUpdateWebviewState
:
(
newState
:
any
)
=>
{
const
webview
=
this
.
tryGetWebview
(
handle
);
if
(
!
webview
||
webview
.
isDisposed
())
{
return
;
}
(
webview
as
WebviewEditorInput
<
MainThreadWebviewState
>
).
state
.
state
=
newState
;
}
};
}
...
...
@@ -326,13 +323,17 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
}
private
getWebview
(
handle
:
WebviewPanelHandle
):
WebviewEditorInput
{
const
webview
=
this
.
_webviews
.
get
(
handle
);
const
webview
=
this
.
tryGetWebview
(
handle
);
if
(
!
webview
)
{
throw
new
Error
(
'
Unknown webview handle:
'
+
handle
);
}
return
webview
;
}
private
tryGetWebview
(
handle
:
WebviewPanelHandle
):
WebviewEditorInput
|
undefined
{
return
this
.
_webviews
.
get
(
handle
);
}
private
static
getDeserializationFailedContents
(
viewType
:
string
)
{
return
`<!DOCTYPE html>
<html>
...
...
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
浏览文件 @
f57ff0b2
...
...
@@ -256,7 +256,7 @@ export class WebviewEditor extends BaseEditor {
this
.
_webview
.
initialScrollProgress
=
input
.
scrollYPercentage
;
}
this
.
_webview
.
state
=
input
.
webviewState
;
this
.
_webview
.
state
=
input
.
state
?
input
.
state
.
state
:
undefined
;
this
.
_content
!
.
setAttribute
(
'
aria-flowto
'
,
this
.
_webviewContent
.
id
);
...
...
src/vs/workbench/contrib/webview/browser/webviewEditorInput.ts
浏览文件 @
f57ff0b2
...
...
@@ -13,7 +13,7 @@ import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/bro
import
{
WebviewEvents
,
WebviewInputOptions
}
from
'
./webviewEditorService
'
;
import
{
Webview
,
WebviewOptions
}
from
'
vs/workbench/contrib/webview/common/webview
'
;
export
class
WebviewEditorInput
extends
EditorInput
{
export
class
WebviewEditorInput
<
State
=
any
>
extends
EditorInput
{
private
static
handlePool
=
0
;
private
static
_styleElement
?:
HTMLStyleElement
;
...
...
@@ -62,7 +62,7 @@ export class WebviewEditorInput extends EditorInput {
private
readonly
_webviewDisposables
=
this
.
_register
(
new
DisposableStore
());
private
_group
?:
GroupIdentifier
;
private
_scrollYPercentage
:
number
=
0
;
private
_state
:
any
;
private
_state
:
State
;
public
readonly
extension
?:
{
readonly
location
:
URI
;
...
...
@@ -74,7 +74,7 @@ export class WebviewEditorInput extends EditorInput {
public
readonly
viewType
:
string
,
name
:
string
,
options
:
WebviewInputOptions
,
state
:
any
,
state
:
State
,
events
:
WebviewEvents
,
extension
:
undefined
|
{
readonly
location
:
URI
;
...
...
@@ -175,18 +175,14 @@ export class WebviewEditorInput extends EditorInput {
}
}
public
get
state
():
any
{
public
get
state
():
State
{
return
this
.
_state
;
}
public
set
state
(
value
:
any
)
{
public
set
state
(
value
:
State
)
{
this
.
_state
=
value
;
}
public
get
webviewState
()
{
return
this
.
_state
.
state
;
}
public
get
options
():
WebviewInputOptions
{
return
this
.
_options
;
}
...
...
@@ -253,7 +249,9 @@ export class WebviewEditorInput extends EditorInput {
},
null
,
this
.
_webviewDisposables
);
this
.
_webview
.
onDidUpdateState
(
newState
=>
{
this
.
_state
.
state
=
newState
;
if
(
this
.
_events
&&
this
.
_events
.
onDidUpdateWebviewState
)
{
this
.
_events
.
onDidUpdateWebviewState
(
newState
);
}
},
null
,
this
.
_webviewDisposables
);
}
...
...
@@ -262,7 +260,6 @@ export class WebviewEditorInput extends EditorInput {
}
public
claimWebview
(
owner
:
any
)
{
this
.
_webviewOwner
=
owner
;
}
...
...
src/vs/workbench/contrib/webview/browser/webviewEditorService.ts
浏览文件 @
f57ff0b2
...
...
@@ -79,6 +79,7 @@ export interface WebviewEvents {
onMessage
?(
message
:
any
):
void
;
onDispose
?():
void
;
onDidClickLink
?(
link
:
URI
,
options
:
IWebviewOptions
):
void
;
onDidUpdateWebviewState
?(
newState
:
any
):
void
;
}
export
interface
WebviewInputOptions
extends
IWebviewOptions
,
IWebviewPanelOptions
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录