Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e259543b
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,发现更多精彩内容 >>
提交
e259543b
编写于
2月 07, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Split up static webview options and options that can be changed dynamically
上级
c460e31c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
36 addition
and
39 deletion
+36
-39
src/vs/workbench/contrib/extensions/electron-browser/extensionEditor.ts
...ch/contrib/extensions/electron-browser/extensionEditor.ts
+6
-3
src/vs/workbench/contrib/html/electron-browser/htmlPreviewPart.ts
...orkbench/contrib/html/electron-browser/htmlPreviewPart.ts
+4
-4
src/vs/workbench/contrib/webview/electron-browser/webviewEditor.ts
...rkbench/contrib/webview/electron-browser/webviewEditor.ts
+3
-6
src/vs/workbench/contrib/webview/electron-browser/webviewEditorInput.ts
...ch/contrib/webview/electron-browser/webviewEditorInput.ts
+0
-2
src/vs/workbench/contrib/webview/electron-browser/webviewElement.ts
...kbench/contrib/webview/electron-browser/webviewElement.ts
+23
-24
未找到文件。
src/vs/workbench/contrib/extensions/electron-browser/extensionEditor.ts
浏览文件 @
e259543b
...
...
@@ -525,9 +525,12 @@ export class ExtensionEditor extends BaseEditor {
.
then
(
renderBody
)
.
then
(
removeEmbeddedSVGs
)
.
then
(
body
=>
{
const
allowedBadgeProviders
=
this
.
extensionsWorkbenchService
.
allowedBadgeProviders
;
const
webViewOptions
=
allowedBadgeProviders
.
length
>
0
?
{
allowScripts
:
false
,
allowSvgs
:
false
,
svgWhiteList
:
allowedBadgeProviders
}
:
{};
const
wbeviewElement
=
this
.
instantiationService
.
createInstance
(
WebviewElement
,
this
.
partService
.
getContainer
(
Parts
.
EDITOR_PART
),
webViewOptions
);
const
wbeviewElement
=
this
.
instantiationService
.
createInstance
(
WebviewElement
,
this
.
partService
.
getContainer
(
Parts
.
EDITOR_PART
),
{},
{
svgWhiteList
:
this
.
extensionsWorkbenchService
.
allowedBadgeProviders
});
wbeviewElement
.
mountTo
(
this
.
content
);
const
removeLayoutParticipant
=
arrays
.
insert
(
this
.
layoutParticipants
,
wbeviewElement
);
this
.
contentDisposables
.
push
(
toDisposable
(
removeLayoutParticipant
));
...
...
src/vs/workbench/contrib/html/electron-browser/htmlPreviewPart.ts
浏览文件 @
e259543b
...
...
@@ -17,7 +17,7 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
Dimension
}
from
'
vs/base/browser/dom
'
;
import
{
BaseWebviewEditor
}
from
'
vs/workbench/contrib/webview/electron-browser/baseWebviewEditor
'
;
import
{
WebviewElement
,
WebviewOptions
}
from
'
vs/workbench/contrib/webview/electron-browser/webviewElement
'
;
import
{
WebviewElement
,
Webview
Content
Options
}
from
'
vs/workbench/contrib/webview/electron-browser/webviewElement
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IEditorGroupsService
,
IEditorGroup
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
...
...
@@ -88,7 +88,7 @@ export class HtmlPreviewPart extends BaseWebviewEditor {
private
get
webview
():
WebviewElement
{
if
(
!
this
.
_webview
)
{
let
webviewOptions
:
WebviewOptions
=
{};
let
webviewOptions
:
Webview
Content
Options
=
{};
if
(
this
.
input
&&
this
.
input
instanceof
HtmlInput
)
{
webviewOptions
=
this
.
input
.
options
;
}
...
...
@@ -96,9 +96,9 @@ export class HtmlPreviewPart extends BaseWebviewEditor {
this
.
_webview
=
this
.
_instantiationService
.
createInstance
(
WebviewElement
,
this
.
_partService
.
getContainer
(
Parts
.
EDITOR_PART
),
{
...
webviewOptions
,
useSameOriginForRoot
:
true
});
},
webviewOptions
);
this
.
_webview
.
mountTo
(
this
.
_content
);
if
(
this
.
input
&&
this
.
input
instanceof
HtmlInput
)
{
...
...
src/vs/workbench/contrib/webview/electron-browser/webviewEditor.ts
浏览文件 @
e259543b
...
...
@@ -183,10 +183,7 @@ export class WebviewEditor extends BaseWebviewEditor {
input
.
claimWebview
(
this
);
webview
.
update
(
input
.
html
,
{
allowScripts
:
input
.
options
.
enableScripts
,
allowSvgs
:
true
,
useSameOriginForRoot
:
false
,
localResourceRoots
:
input
.
options
.
localResourceRoots
||
this
.
getDefaultLocalResourceRoots
(),
extensionLocation
:
input
.
extensionLocation
},
!!
input
.
options
.
retainContextWhenHidden
);
if
(
this
.
_webviewContent
)
{
...
...
@@ -224,9 +221,9 @@ export class WebviewEditor extends BaseWebviewEditor {
this
.
_partService
.
getContainer
(
Parts
.
EDITOR_PART
),
{
allowSvgs
:
true
,
useSameOriginForRoot
:
false
,
extensionLocation
:
input
.
extensionLocation
});
extensionLocation
:
input
.
extensionLocation
,
},
{
});
this
.
_webview
.
mountTo
(
this
.
_webviewContent
);
input
.
webview
=
this
.
_webview
;
...
...
src/vs/workbench/contrib/webview/electron-browser/webviewEditorInput.ts
浏览文件 @
e259543b
...
...
@@ -207,8 +207,6 @@ export class WebviewEditorInput extends EditorInput {
if
(
this
.
_webview
)
{
this
.
_webview
.
options
=
{
allowScripts
:
this
.
_options
.
enableScripts
,
allowSvgs
:
true
,
useSameOriginForRoot
:
false
,
localResourceRoots
:
this
.
_options
.
localResourceRoots
};
}
...
...
src/vs/workbench/contrib/webview/electron-browser/webviewElement.ts
浏览文件 @
e259543b
...
...
@@ -21,14 +21,17 @@ import { endsWith } from 'vs/base/common/strings';
import
{
isMacintosh
}
from
'
vs/base/common/platform
'
;
export
interface
WebviewOptions
{
readonly
allowScripts
?:
boolean
;
readonly
allowSvgs
?:
boolean
;
readonly
svgWhiteList
?:
string
[];
readonly
useSameOriginForRoot
?:
boolean
;
readonly
localResourceRoots
?:
ReadonlyArray
<
URI
>
;
readonly
extensionLocation
?:
URI
;
}
export
interface
WebviewContentOptions
{
readonly
allowScripts
?:
boolean
;
readonly
svgWhiteList
?:
string
[];
readonly
localResourceRoots
?:
ReadonlyArray
<
URI
>
;
}
interface
IKeydownEvent
{
key
:
string
;
keyCode
:
number
;
...
...
@@ -88,14 +91,10 @@ class SvgBlocker extends Disposable {
constructor
(
webview
:
Electron
.
WebviewTag
,
private
readonly
_options
:
WebviewOptions
,
private
readonly
_options
:
Webview
Content
Options
,
)
{
super
();
if
(
this
.
_options
.
allowSvgs
)
{
return
;
}
let
loaded
=
false
;
this
.
_register
(
addDisposableListener
(
webview
,
'
did-start-loading
'
,
()
=>
{
if
(
loaded
)
{
...
...
@@ -134,9 +133,6 @@ class SvgBlocker extends Disposable {
}
private
isAllowedSvg
(
uri
:
URI
):
boolean
{
if
(
this
.
_options
.
allowSvgs
)
{
return
true
;
}
if
(
this
.
_options
.
svgWhiteList
)
{
return
this
.
_options
.
svgWhiteList
.
indexOf
(
uri
.
authority
.
toLowerCase
())
>=
0
;
}
...
...
@@ -239,7 +235,8 @@ export class WebviewElement extends Disposable {
constructor
(
private
readonly
_styleElement
:
Element
,
private
_options
:
WebviewOptions
,
private
readonly
_options
:
WebviewOptions
,
private
_contentOptions
:
WebviewContentOptions
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IThemeService
private
readonly
_themeService
:
IThemeService
,
@
IEnvironmentService
environmentService
:
IEnvironmentService
,
...
...
@@ -276,12 +273,14 @@ export class WebviewElement extends Disposable {
new
WebviewProtocolProvider
(
this
.
_webview
,
this
.
_options
.
extensionLocation
,
()
=>
(
this
.
_
o
ptions
.
localResourceRoots
||
[]),
()
=>
(
this
.
_
contentO
ptions
.
localResourceRoots
||
[]),
environmentService
,
fileService
));
const
svgBlocker
=
this
.
_register
(
new
SvgBlocker
(
this
.
_webview
,
this
.
_options
));
svgBlocker
.
onDidBlockSvg
(()
=>
this
.
onDidBlockSvg
());
if
(
!
this
.
_options
.
allowSvgs
)
{
const
svgBlocker
=
this
.
_register
(
new
SvgBlocker
(
this
.
_webview
,
this
.
_contentOptions
));
svgBlocker
.
onDidBlockSvg
(()
=>
this
.
onDidBlockSvg
());
}
this
.
_register
(
new
WebviewKeyboardHandler
(
this
.
_webview
,
this
.
_keybindingService
));
...
...
@@ -397,15 +396,15 @@ export class WebviewElement extends Disposable {
this
.
_state
=
value
;
}
public
set
options
(
value
:
WebviewOptions
)
{
if
(
this
.
_
options
&&
areWebviewInputOptionsEqual
(
value
,
this
.
_o
ptions
))
{
public
set
options
(
value
:
Webview
Content
Options
)
{
if
(
this
.
_
contentOptions
&&
areWebviewInputOptionsEqual
(
value
,
this
.
_contentO
ptions
))
{
return
;
}
this
.
_
o
ptions
=
value
;
this
.
_
contentO
ptions
=
value
;
this
.
_send
(
'
content
'
,
{
contents
:
this
.
_contents
,
options
:
this
.
_
o
ptions
,
options
:
this
.
_
contentO
ptions
,
state
:
this
.
_state
});
}
...
...
@@ -414,20 +413,20 @@ export class WebviewElement extends Disposable {
this
.
_contents
=
value
;
this
.
_send
(
'
content
'
,
{
contents
:
value
,
options
:
this
.
_
o
ptions
,
options
:
this
.
_
contentO
ptions
,
state
:
this
.
_state
});
}
public
update
(
value
:
string
,
options
:
WebviewOptions
,
retainContextWhenHidden
:
boolean
)
{
if
(
retainContextWhenHidden
&&
value
===
this
.
_contents
&&
this
.
_
options
&&
areWebviewInputOptionsEqual
(
options
,
this
.
_o
ptions
))
{
public
update
(
value
:
string
,
options
:
Webview
Content
Options
,
retainContextWhenHidden
:
boolean
)
{
if
(
retainContextWhenHidden
&&
value
===
this
.
_contents
&&
this
.
_
contentOptions
&&
areWebviewInputOptionsEqual
(
options
,
this
.
_contentO
ptions
))
{
return
;
}
this
.
_contents
=
value
;
this
.
_
o
ptions
=
options
;
this
.
_
contentO
ptions
=
options
;
this
.
_send
(
'
content
'
,
{
contents
:
this
.
_contents
,
options
:
this
.
_
o
ptions
,
options
:
this
.
_
contentO
ptions
,
state
:
this
.
_state
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录