Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e649ef37
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,发现更多精彩内容 >>
提交
e649ef37
编写于
9月 22, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sandbox - function scope for workbench too
上级
7c593490
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
240 addition
and
214 deletion
+240
-214
src/vs/code/electron-browser/workbench/workbench.js
src/vs/code/electron-browser/workbench/workbench.js
+166
-153
src/vs/code/electron-sandbox/workbench/workbench.js
src/vs/code/electron-sandbox/workbench/workbench.js
+74
-61
未找到文件。
src/vs/code/electron-browser/workbench/workbench.js
浏览文件 @
e649ef37
...
@@ -8,171 +8,184 @@
...
@@ -8,171 +8,184 @@
//@ts-check
//@ts-check
'
use strict
'
;
'
use strict
'
;
const
perf
=
(
function
()
{
(
function
()
{
globalThis
.
MonacoPerformanceMarks
=
globalThis
.
MonacoPerformanceMarks
||
[];
return
{
// Add a perf entry right from the top
/**
const
perf
=
perfLib
();
* @param {string} name
perf
.
mark
(
'
renderer/started
'
);
*/
mark
(
name
)
{
// Load environment in parallel to workbench loading to avoid waterfall
globalThis
.
MonacoPerformanceMarks
.
push
(
name
,
Date
.
now
());
const
bootstrapWindow
=
bootstrapWindowLib
();
}
const
whenEnvResolved
=
bootstrapWindow
.
globals
().
process
.
whenEnvResolved
();
};
})();
// Load workbench main JS, CSS and NLS all in parallel. This is an
// optimization to prevent a waterfall of loading to happen, because
perf
.
mark
(
'
renderer/started
'
);
// we know for a fact that workbench.desktop.main will depend on
// the related CSS and NLS counterparts.
/**
bootstrapWindow
.
load
([
* @type {{
'
vs/workbench/workbench.desktop.main
'
,
* load: (modules: string[], resultCallback: (result, configuration: object) => any, options: object) => unknown,
'
vs/nls!vs/workbench/workbench.desktop.main
'
,
* globals: () => typeof import('../../../base/parts/sandbox/electron-sandbox/globals')
'
vs/css!vs/workbench/workbench.desktop.main
'
* }}
],
*/
async
function
(
workbench
,
configuration
)
{
const
bootstrapWindow
=
(()
=>
{
// @ts-ignore (defined in bootstrap-window.js)
// Mark start of workbench
return
window
.
MonacoBootstrapWindow
;
perf
.
mark
(
'
didLoadWorkbenchMain
'
);
})();
performance
.
mark
(
'
workbench-start
'
);
// Load environment in parallel to workbench loading to avoid waterfall
// Wait for process environment being fully resolved
const
whenEnvResolved
=
bootstrapWindow
.
globals
().
process
.
whenEnvResolved
();
await
whenEnvResolved
;
// Load workbench main JS, CSS and NLS all in parallel. This is an
perf
.
mark
(
'
main/startup
'
);
// optimization to prevent a waterfall of loading to happen, because
// we know for a fact that workbench.desktop.main will depend on
// @ts-ignore
// the related CSS and NLS counterparts.
return
require
(
'
vs/workbench/electron-browser/desktop.main
'
).
main
(
configuration
);
bootstrapWindow
.
load
([
'
vs/workbench/workbench.desktop.main
'
,
'
vs/nls!vs/workbench/workbench.desktop.main
'
,
'
vs/css!vs/workbench/workbench.desktop.main
'
],
async
function
(
workbench
,
configuration
)
{
// Mark start of workbench
perf
.
mark
(
'
didLoadWorkbenchMain
'
);
performance
.
mark
(
'
workbench-start
'
);
// Wait for process environment being fully resolved
await
whenEnvResolved
;
perf
.
mark
(
'
main/startup
'
);
// @ts-ignore
return
require
(
'
vs/workbench/electron-browser/desktop.main
'
).
main
(
configuration
);
},
{
removeDeveloperKeybindingsAfterLoad
:
true
,
canModifyDOM
:
function
(
windowConfig
)
{
showPartsSplash
(
windowConfig
);
},
beforeLoaderConfig
:
function
(
windowConfig
,
loaderConfig
)
{
loaderConfig
.
recordStats
=
true
;
},
},
beforeRequire
:
function
()
{
{
perf
.
mark
(
'
willLoadWorkbenchMain
'
);
removeDeveloperKeybindingsAfterLoad
:
true
,
}
canModifyDOM
:
function
(
windowConfig
)
{
}
showPartsSplash
(
windowConfig
);
);
},
beforeLoaderConfig
:
function
(
windowConfig
,
loaderConfig
)
{
/**
loaderConfig
.
recordStats
=
true
;
* @param {{
},
* partsSplashPath?: string,
beforeRequire
:
function
()
{
* colorScheme: ('light' | 'dark' | 'hc'),
perf
.
mark
(
'
willLoadWorkbenchMain
'
);
* autoDetectHighContrast?: boolean,
}
* extensionDevelopmentPath?: string[],
* folderUri?: object,
* workspace?: object
* }} configuration
*/
function
showPartsSplash
(
configuration
)
{
perf
.
mark
(
'
willShowPartsSplash
'
);
let
data
;
if
(
typeof
configuration
.
partsSplashPath
===
'
string
'
)
{
try
{
data
=
JSON
.
parse
(
require
.
__$__nodeRequire
(
'
fs
'
).
readFileSync
(
configuration
.
partsSplashPath
,
'
utf8
'
));
}
catch
(
e
)
{
// ignore
}
}
}
);
// high contrast mode has been turned on from the outside, e.g. OS -> ignore stored colors and layouts
const
isHighContrast
=
configuration
.
colorScheme
===
'
hc
'
/* ColorScheme.HIGH_CONTRAST */
&&
configuration
.
autoDetectHighContrast
;
if
(
data
&&
isHighContrast
&&
data
.
baseTheme
!==
'
hc-black
'
)
{
data
=
undefined
;
}
// developing an extension -> ignore stored layouts
//region Helpers
if
(
data
&&
configuration
.
extensionDevelopmentPath
)
{
data
.
layoutInfo
=
undefined
;
function
perfLib
()
{
globalThis
.
MonacoPerformanceMarks
=
globalThis
.
MonacoPerformanceMarks
||
[];
return
{
/**
* @param {string} name
*/
mark
(
name
)
{
globalThis
.
MonacoPerformanceMarks
.
push
(
name
,
Date
.
now
());
}
};
}
}
// minimal color configuration (works with or without persisted data)
/**
let
baseTheme
,
shellBackground
,
shellForeground
;
* @returns {{
if
(
data
)
{
* load: (modules: string[], resultCallback: (result, configuration: object) => any, options: object) => unknown,
baseTheme
=
data
.
baseTheme
;
* globals: () => typeof import('../../../base/parts/sandbox/electron-sandbox/globals')
shellBackground
=
data
.
colorInfo
.
editorBackground
;
* }}
shellForeground
=
data
.
colorInfo
.
foreground
;
*/
}
else
if
(
isHighContrast
)
{
function
bootstrapWindowLib
()
{
baseTheme
=
'
hc-black
'
;
// @ts-ignore (defined in bootstrap-window.js)
shellBackground
=
'
#000000
'
;
return
window
.
MonacoBootstrapWindow
;
shellForeground
=
'
#FFFFFF
'
;
}
else
{
baseTheme
=
'
vs-dark
'
;
shellBackground
=
'
#1E1E1E
'
;
shellForeground
=
'
#CCCCCC
'
;
}
}
const
style
=
document
.
createElement
(
'
style
'
);
style
.
className
=
'
initialShellColors
'
;
/**
document
.
head
.
appendChild
(
style
);
* @param {{
style
.
textContent
=
`body { background-color:
${
shellBackground
}
; color:
${
shellForeground
}
; margin: 0; padding: 0; }`
;
* partsSplashPath?: string,
* colorScheme: ('light' | 'dark' | 'hc'),
if
(
data
&&
data
.
layoutInfo
)
{
* autoDetectHighContrast?: boolean,
// restore parts if possible (we might not always store layout info)
* extensionDevelopmentPath?: string[],
const
{
id
,
layoutInfo
,
colorInfo
}
=
data
;
* folderUri?: object,
const
splash
=
document
.
createElement
(
'
div
'
);
* workspace?: object
splash
.
id
=
id
;
* }} configuration
splash
.
className
=
baseTheme
;
*/
function
showPartsSplash
(
configuration
)
{
if
(
layoutInfo
.
windowBorder
)
{
perf
.
mark
(
'
willShowPartsSplash
'
);
splash
.
style
.
position
=
'
relative
'
;
splash
.
style
.
height
=
'
calc(100vh - 2px)
'
;
let
data
;
splash
.
style
.
width
=
'
calc(100vw - 2px)
'
;
if
(
typeof
configuration
.
partsSplashPath
===
'
string
'
)
{
splash
.
style
.
border
=
'
1px solid var(--window-border-color)
'
;
try
{
splash
.
style
.
setProperty
(
'
--window-border-color
'
,
colorInfo
.
windowBorder
);
data
=
JSON
.
parse
(
require
.
__$__nodeRequire
(
'
fs
'
).
readFileSync
(
configuration
.
partsSplashPath
,
'
utf8
'
));
}
catch
(
e
)
{
if
(
layoutInfo
.
windowBorderRadius
)
{
// ignore
splash
.
style
.
borderRadius
=
layoutInfo
.
windowBorderRadius
;
}
}
}
}
// ensure there is enough space
// high contrast mode has been turned on from the outside, e.g. OS -> ignore stored colors and layouts
layoutInfo
.
sideBarWidth
=
Math
.
min
(
layoutInfo
.
sideBarWidth
,
window
.
innerWidth
-
(
layoutInfo
.
activityBarWidth
+
layoutInfo
.
editorPartMinWidth
));
const
isHighContrast
=
configuration
.
colorScheme
===
'
hc
'
/* ColorScheme.HIGH_CONTRAST */
&&
configuration
.
autoDetectHighContrast
;
if
(
data
&&
isHighContrast
&&
data
.
baseTheme
!==
'
hc-black
'
)
{
// part: title
data
=
undefined
;
const
titleDiv
=
document
.
createElement
(
'
div
'
);
}
titleDiv
.
setAttribute
(
'
style
'
,
`position: absolute; width: 100%; left: 0; top: 0; height:
${
layoutInfo
.
titleBarHeight
}
px; background-color:
${
colorInfo
.
titleBarBackground
}
; -webkit-app-region: drag;`
);
splash
.
appendChild
(
titleDiv
);
// developing an extension -> ignore stored layouts
if
(
data
&&
configuration
.
extensionDevelopmentPath
)
{
// part: activity bar
data
.
layoutInfo
=
undefined
;
const
activityDiv
=
document
.
createElement
(
'
div
'
);
}
activityDiv
.
setAttribute
(
'
style
'
,
`position: absolute; height: calc(100% -
${
layoutInfo
.
titleBarHeight
}
px); top:
${
layoutInfo
.
titleBarHeight
}
px;
${
layoutInfo
.
sideBarSide
}
: 0; width:
${
layoutInfo
.
activityBarWidth
}
px; background-color:
${
colorInfo
.
activityBarBackground
}
;`
);
splash
.
appendChild
(
activityDiv
);
// minimal color configuration (works with or without persisted data)
let
baseTheme
,
shellBackground
,
shellForeground
;
// part: side bar (only when opening workspace/folder)
if
(
data
)
{
if
(
configuration
.
folderUri
||
configuration
.
workspace
)
{
baseTheme
=
data
.
baseTheme
;
// folder or workspace -> status bar color, sidebar
shellBackground
=
data
.
colorInfo
.
editorBackground
;
const
sideDiv
=
document
.
createElement
(
'
div
'
);
shellForeground
=
data
.
colorInfo
.
foreground
;
sideDiv
.
setAttribute
(
'
style
'
,
`position: absolute; height: calc(100% -
${
layoutInfo
.
titleBarHeight
}
px); top:
${
layoutInfo
.
titleBarHeight
}
px;
${
layoutInfo
.
sideBarSide
}
:
${
layoutInfo
.
activityBarWidth
}
px; width:
${
layoutInfo
.
sideBarWidth
}
px; background-color:
${
colorInfo
.
sideBarBackground
}
;`
);
}
else
if
(
isHighContrast
)
{
splash
.
appendChild
(
sideDiv
);
baseTheme
=
'
hc-black
'
;
shellBackground
=
'
#000000
'
;
shellForeground
=
'
#FFFFFF
'
;
}
else
{
baseTheme
=
'
vs-dark
'
;
shellBackground
=
'
#1E1E1E
'
;
shellForeground
=
'
#CCCCCC
'
;
}
}
const
style
=
document
.
createElement
(
'
style
'
);
style
.
className
=
'
initialShellColors
'
;
document
.
head
.
appendChild
(
style
);
style
.
textContent
=
`body { background-color:
${
shellBackground
}
; color:
${
shellForeground
}
; margin: 0; padding: 0; }`
;
if
(
data
&&
data
.
layoutInfo
)
{
// restore parts if possible (we might not always store layout info)
const
{
id
,
layoutInfo
,
colorInfo
}
=
data
;
const
splash
=
document
.
createElement
(
'
div
'
);
splash
.
id
=
id
;
splash
.
className
=
baseTheme
;
if
(
layoutInfo
.
windowBorder
)
{
splash
.
style
.
position
=
'
relative
'
;
splash
.
style
.
height
=
'
calc(100vh - 2px)
'
;
splash
.
style
.
width
=
'
calc(100vw - 2px)
'
;
splash
.
style
.
border
=
'
1px solid var(--window-border-color)
'
;
splash
.
style
.
setProperty
(
'
--window-border-color
'
,
colorInfo
.
windowBorder
);
if
(
layoutInfo
.
windowBorderRadius
)
{
splash
.
style
.
borderRadius
=
layoutInfo
.
windowBorderRadius
;
}
}
// ensure there is enough space
layoutInfo
.
sideBarWidth
=
Math
.
min
(
layoutInfo
.
sideBarWidth
,
window
.
innerWidth
-
(
layoutInfo
.
activityBarWidth
+
layoutInfo
.
editorPartMinWidth
));
// part: title
const
titleDiv
=
document
.
createElement
(
'
div
'
);
titleDiv
.
setAttribute
(
'
style
'
,
`position: absolute; width: 100%; left: 0; top: 0; height:
${
layoutInfo
.
titleBarHeight
}
px; background-color:
${
colorInfo
.
titleBarBackground
}
; -webkit-app-region: drag;`
);
splash
.
appendChild
(
titleDiv
);
// part: activity bar
const
activityDiv
=
document
.
createElement
(
'
div
'
);
activityDiv
.
setAttribute
(
'
style
'
,
`position: absolute; height: calc(100% -
${
layoutInfo
.
titleBarHeight
}
px); top:
${
layoutInfo
.
titleBarHeight
}
px;
${
layoutInfo
.
sideBarSide
}
: 0; width:
${
layoutInfo
.
activityBarWidth
}
px; background-color:
${
colorInfo
.
activityBarBackground
}
;`
);
splash
.
appendChild
(
activityDiv
);
// part: side bar (only when opening workspace/folder)
if
(
configuration
.
folderUri
||
configuration
.
workspace
)
{
// folder or workspace -> status bar color, sidebar
const
sideDiv
=
document
.
createElement
(
'
div
'
);
sideDiv
.
setAttribute
(
'
style
'
,
`position: absolute; height: calc(100% -
${
layoutInfo
.
titleBarHeight
}
px); top:
${
layoutInfo
.
titleBarHeight
}
px;
${
layoutInfo
.
sideBarSide
}
:
${
layoutInfo
.
activityBarWidth
}
px; width:
${
layoutInfo
.
sideBarWidth
}
px; background-color:
${
colorInfo
.
sideBarBackground
}
;`
);
splash
.
appendChild
(
sideDiv
);
}
// part: statusbar
// part: statusbar
const
statusDiv
=
document
.
createElement
(
'
div
'
);
const
statusDiv
=
document
.
createElement
(
'
div
'
);
statusDiv
.
setAttribute
(
'
style
'
,
`position: absolute; width: 100%; bottom: 0; left: 0; height:
${
layoutInfo
.
statusBarHeight
}
px; background-color:
${
configuration
.
folderUri
||
configuration
.
workspace
?
colorInfo
.
statusBarBackground
:
colorInfo
.
statusBarNoFolderBackground
}
;`
);
statusDiv
.
setAttribute
(
'
style
'
,
`position: absolute; width: 100%; bottom: 0; left: 0; height:
${
layoutInfo
.
statusBarHeight
}
px; background-color:
${
configuration
.
folderUri
||
configuration
.
workspace
?
colorInfo
.
statusBarBackground
:
colorInfo
.
statusBarNoFolderBackground
}
;`
);
splash
.
appendChild
(
statusDiv
);
splash
.
appendChild
(
statusDiv
);
document
.
body
.
appendChild
(
splash
);
}
document
.
body
.
appendChild
(
splash
);
perf
.
mark
(
'
didShowPartsSplash
'
);
}
}
perf
.
mark
(
'
didShowPartsSplash
'
);
//#endregion
}
}());
src/vs/code/electron-sandbox/workbench/workbench.js
浏览文件 @
e649ef37
...
@@ -8,67 +8,80 @@
...
@@ -8,67 +8,80 @@
//@ts-check
//@ts-check
'
use strict
'
;
'
use strict
'
;
const
perf
=
(
function
()
{
(
function
()
{
globalThis
.
MonacoPerformanceMarks
=
globalThis
.
MonacoPerformanceMarks
||
[];
return
{
// Add a perf entry right from the top
/**
const
perf
=
perfLib
();
* @param {string} name
perf
.
mark
(
'
renderer/started
'
);
*/
mark
(
name
)
{
// Load environment in parallel to workbench loading to avoid waterfall
globalThis
.
MonacoPerformanceMarks
.
push
(
name
,
Date
.
now
());
const
bootstrapWindow
=
bootstrapWindowLib
();
}
const
whenEnvResolved
=
bootstrapWindow
.
globals
().
process
.
whenEnvResolved
();
};
})();
// Load workbench main JS, CSS and NLS all in parallel. This is an
// optimization to prevent a waterfall of loading to happen, because
perf
.
mark
(
'
renderer/started
'
);
// we know for a fact that workbench.desktop.sandbox.main will depend on
// the related CSS and NLS counterparts.
/**
bootstrapWindow
.
load
([
* @type {{
'
vs/workbench/workbench.desktop.sandbox.main
'
,
* load: (modules: string[], resultCallback: (result, configuration: object) => any, options: object) => unknown,
'
vs/nls!vs/workbench/workbench.desktop.main
'
,
* globals: () => typeof import('../../../base/parts/sandbox/electron-sandbox/globals')
'
vs/css!vs/workbench/workbench.desktop.main
'
* }}
],
*/
async
function
(
workbench
,
configuration
)
{
const
bootstrapWindow
=
(()
=>
{
// @ts-ignore (defined in bootstrap-window.js)
// Mark start of workbench
return
window
.
MonacoBootstrapWindow
;
perf
.
mark
(
'
didLoadWorkbenchMain
'
);
})();
performance
.
mark
(
'
workbench-start
'
);
// Load environment in parallel to workbench loading to avoid waterfall
// Wait for process environment being fully resolved
const
whenEnvResolved
=
bootstrapWindow
.
globals
().
process
.
whenEnvResolved
();
await
whenEnvResolved
;
// Load workbench main JS, CSS and NLS all in parallel. This is an
perf
.
mark
(
'
main/startup
'
);
// optimization to prevent a waterfall of loading to happen, because
// we know for a fact that workbench.desktop.sandbox.main will depend on
// @ts-ignore
// the related CSS and NLS counterparts.
return
require
(
'
vs/workbench/electron-sandbox/desktop.main
'
).
main
(
configuration
);
bootstrapWindow
.
load
([
'
vs/workbench/workbench.desktop.sandbox.main
'
,
'
vs/nls!vs/workbench/workbench.desktop.main
'
,
'
vs/css!vs/workbench/workbench.desktop.main
'
],
async
function
(
workbench
,
configuration
)
{
// Mark start of workbench
perf
.
mark
(
'
didLoadWorkbenchMain
'
);
performance
.
mark
(
'
workbench-start
'
);
// Wait for process environment being fully resolved
await
whenEnvResolved
;
perf
.
mark
(
'
main/startup
'
);
// @ts-ignore
return
require
(
'
vs/workbench/electron-sandbox/desktop.main
'
).
main
(
configuration
);
},
{
removeDeveloperKeybindingsAfterLoad
:
true
,
canModifyDOM
:
function
(
windowConfig
)
{
// TODO@sandbox part-splash is non-sandboxed only
},
beforeLoaderConfig
:
function
(
windowConfig
,
loaderConfig
)
{
loaderConfig
.
recordStats
=
true
;
},
},
beforeRequire
:
function
()
{
{
perf
.
mark
(
'
willLoadWorkbenchMain
'
);
removeDeveloperKeybindingsAfterLoad
:
true
,
canModifyDOM
:
function
(
windowConfig
)
{
// TODO@sandbox part-splash is non-sandboxed only
},
beforeLoaderConfig
:
function
(
windowConfig
,
loaderConfig
)
{
loaderConfig
.
recordStats
=
true
;
},
beforeRequire
:
function
()
{
perf
.
mark
(
'
willLoadWorkbenchMain
'
);
}
}
}
);
//region Helpers
function
perfLib
()
{
globalThis
.
MonacoPerformanceMarks
=
globalThis
.
MonacoPerformanceMarks
||
[];
return
{
/**
* @param {string} name
*/
mark
(
name
)
{
globalThis
.
MonacoPerformanceMarks
.
push
(
name
,
Date
.
now
());
}
};
}
}
);
/**
* @returns {{
* load: (modules: string[], resultCallback: (result, configuration: object) => any, options: object) => unknown,
* globals: () => typeof import('../../../base/parts/sandbox/electron-sandbox/globals')
* }}
*/
function
bootstrapWindowLib
()
{
// @ts-ignore (defined in bootstrap-window.js)
return
window
.
MonacoBootstrapWindow
;
}
//#endregion
}());
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录