Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0707a19c
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,发现更多精彩内容 >>
未验证
提交
0707a19c
编写于
9月 21, 2020
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes microsoft/monaco-editor#2140: Do not create a global style sheet unless needed
上级
2aa5b9f6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
23 deletion
+40
-23
src/vs/base/browser/ui/codicons/codiconStyles.ts
src/vs/base/browser/ui/codicons/codiconStyles.ts
+5
-15
src/vs/editor/standalone/browser/standaloneThemeServiceImpl.ts
...s/editor/standalone/browser/standaloneThemeServiceImpl.ts
+21
-6
src/vs/workbench/services/themes/browser/workbenchThemeService.ts
...orkbench/services/themes/browser/workbenchThemeService.ts
+14
-2
未找到文件。
src/vs/base/browser/ui/codicons/codiconStyles.ts
浏览文件 @
0707a19c
...
...
@@ -8,25 +8,17 @@ import 'vs/css!./codicon/codicon-modifications';
import
'
vs/css!./codicon/codicon-animations
'
;
import
{
Codicon
,
iconRegistry
}
from
'
vs/base/common/codicons
'
;
import
{
createStyleSheet
}
from
'
vs/base/browser/dom
'
;
import
{
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
function
initialize
()
{
let
codiconStyleSheet
=
createStyleSheet
();
codiconStyleSheet
.
id
=
'
codiconStyles
'
;
function
updateAll
()
{
export
const
CodiconStyles
=
new
class
{
onDidChange
=
iconRegistry
.
onDidRegister
;
public
getCSS
():
string
{
const
rules
=
[];
for
(
let
c
of
iconRegistry
.
all
)
{
rules
.
push
(
formatRule
(
c
));
}
codiconStyleSheet
.
textContent
=
rules
.
join
(
'
\n
'
);
return
rules
.
join
(
'
\n
'
);
}
const
delayer
=
new
RunOnceScheduler
(
updateAll
,
0
);
iconRegistry
.
onDidRegister
(()
=>
delayer
.
schedule
());
delayer
.
schedule
();
}
};
export
function
formatRule
(
c
:
Codicon
)
{
let
def
=
c
.
definition
;
...
...
@@ -35,5 +27,3 @@ export function formatRule(c: Codicon) {
}
return
`.codicon-
${
c
.
id
}
:before { content: '
${
def
.
character
}
'; }`
;
}
initialize
();
src/vs/editor/standalone/browser/standaloneThemeServiceImpl.ts
浏览文件 @
0707a19c
...
...
@@ -16,6 +16,7 @@ import { ColorIdentifier, Extensions, IColorRegistry } from 'vs/platform/theme/c
import
{
Extensions
as
ThemingExtensions
,
ICssStyleCollector
,
IFileIconTheme
,
IThemingRegistry
,
ITokenStyle
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IDisposable
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ColorScheme
}
from
'
vs/platform/theme/common/theme
'
;
import
{
CodiconStyles
}
from
'
vs/base/browser/ui/codicons/codiconStyles
'
;
const
VS_THEME_NAME
=
'
vs
'
;
const
VS_DARK_THEME_NAME
=
'
vs-dark
'
;
...
...
@@ -193,7 +194,9 @@ export class StandaloneThemeServiceImpl extends Disposable implements IStandalon
private
readonly
_environment
:
IEnvironmentService
=
Object
.
create
(
null
);
private
readonly
_knownThemes
:
Map
<
string
,
StandaloneTheme
>
;
private
_css
:
string
;
private
_codiconCSS
:
string
;
private
_themeCSS
:
string
;
private
_allCSS
:
string
;
private
_globalStyleElement
:
HTMLStyleElement
|
null
;
private
_styleElements
:
HTMLStyleElement
[];
private
_theme
!
:
IStandaloneTheme
;
...
...
@@ -205,10 +208,17 @@ export class StandaloneThemeServiceImpl extends Disposable implements IStandalon
this
.
_knownThemes
.
set
(
VS_THEME_NAME
,
newBuiltInTheme
(
VS_THEME_NAME
));
this
.
_knownThemes
.
set
(
VS_DARK_THEME_NAME
,
newBuiltInTheme
(
VS_DARK_THEME_NAME
));
this
.
_knownThemes
.
set
(
HC_BLACK_THEME_NAME
,
newBuiltInTheme
(
HC_BLACK_THEME_NAME
));
this
.
_css
=
''
;
this
.
_codiconCSS
=
CodiconStyles
.
getCSS
();
this
.
_themeCSS
=
''
;
this
.
_allCSS
=
`
${
this
.
_codiconCSS
}
\n
${
this
.
_themeCSS
}
`
;
this
.
_globalStyleElement
=
null
;
this
.
_styleElements
=
[];
this
.
setTheme
(
VS_THEME_NAME
);
CodiconStyles
.
onDidChange
(()
=>
{
this
.
_codiconCSS
=
CodiconStyles
.
getCSS
();
this
.
_updateCSS
();
});
}
public
registerEditorContainer
(
domNode
:
HTMLElement
):
IDisposable
{
...
...
@@ -222,7 +232,7 @@ export class StandaloneThemeServiceImpl extends Disposable implements IStandalon
if
(
!
this
.
_globalStyleElement
)
{
this
.
_globalStyleElement
=
dom
.
createStyleSheet
();
this
.
_globalStyleElement
.
className
=
'
monaco-colors
'
;
this
.
_globalStyleElement
.
innerHTML
=
this
.
_
css
;
this
.
_globalStyleElement
.
innerHTML
=
this
.
_
allCSS
;
this
.
_styleElements
.
push
(
this
.
_globalStyleElement
);
}
return
Disposable
.
None
;
...
...
@@ -231,7 +241,7 @@ export class StandaloneThemeServiceImpl extends Disposable implements IStandalon
private
_registerShadowDomContainer
(
domNode
:
HTMLElement
):
IDisposable
{
const
styleElement
=
dom
.
createStyleSheet
(
domNode
);
styleElement
.
className
=
'
monaco-colors
'
;
styleElement
.
innerHTML
=
this
.
_
css
;
styleElement
.
innerHTML
=
this
.
_
allCSS
;
this
.
_styleElements
.
push
(
styleElement
);
return
{
dispose
:
()
=>
{
...
...
@@ -300,8 +310,8 @@ export class StandaloneThemeServiceImpl extends Disposable implements IStandalon
let
colorMap
=
tokenTheme
.
getColorMap
();
ruleCollector
.
addRule
(
generateTokensCSSForColorMap
(
colorMap
));
this
.
_
css
=
cssRules
.
join
(
'
\n
'
);
this
.
_
styleElements
.
forEach
(
styleElement
=>
styleElement
.
innerHTML
=
this
.
_css
);
this
.
_
themeCSS
=
cssRules
.
join
(
'
\n
'
);
this
.
_
updateCSS
(
);
TokenizationRegistry
.
setColorMap
(
colorMap
);
this
.
_onColorThemeChange
.
fire
(
theme
);
...
...
@@ -309,6 +319,11 @@ export class StandaloneThemeServiceImpl extends Disposable implements IStandalon
return
theme
.
id
;
}
private
_updateCSS
():
void
{
this
.
_allCSS
=
`
${
this
.
_codiconCSS
}
\n
${
this
.
_themeCSS
}
`
;
this
.
_styleElements
.
forEach
(
styleElement
=>
styleElement
.
innerHTML
=
this
.
_allCSS
);
}
public
getFileIconTheme
():
IFileIconTheme
{
return
{
hasFileIcons
:
false
,
...
...
src/vs/workbench/services/themes/browser/workbenchThemeService.ts
浏览文件 @
0707a19c
...
...
@@ -18,7 +18,7 @@ import { Event, Emitter } from 'vs/base/common/event';
import
{
registerFileIconThemeSchemas
}
from
'
vs/workbench/services/themes/common/fileIconThemeSchema
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
FileIconThemeData
}
from
'
vs/workbench/services/themes/browser/fileIconThemeData
'
;
import
{
removeClasses
,
addClasses
}
from
'
vs/base/browser/dom
'
;
import
{
removeClasses
,
addClasses
,
createStyleSheet
}
from
'
vs/base/browser/dom
'
;
import
{
IWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/common/environmentService
'
;
import
{
IFileService
,
FileChangeType
}
from
'
vs/platform/files/common/files
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
...
...
@@ -36,7 +36,8 @@ import { ILogService } from 'vs/platform/log/common/log';
import
{
isWeb
}
from
'
vs/base/common/platform
'
;
import
{
ColorScheme
}
from
'
vs/platform/theme/common/theme
'
;
import
{
IHostColorSchemeService
}
from
'
vs/workbench/services/themes/common/hostColorSchemeService
'
;
import
{
CodiconStyles
}
from
'
vs/base/browser/ui/codicons/codiconStyles
'
;
import
{
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
// implementation
...
...
@@ -164,6 +165,17 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
this
.
installPreferredSchemeListener
();
this
.
installRegistryListeners
();
});
const
codiconStyleSheet
=
createStyleSheet
();
codiconStyleSheet
.
id
=
'
codiconStyles
'
;
function
updateAll
()
{
codiconStyleSheet
.
textContent
=
CodiconStyles
.
getCSS
();
}
const
delayer
=
new
RunOnceScheduler
(
updateAll
,
0
);
CodiconStyles
.
onDidChange
(()
=>
delayer
.
schedule
());
delayer
.
schedule
();
}
private
initialize
():
Promise
<
[
IWorkbenchColorTheme
|
null
,
IWorkbenchFileIconTheme
|
null
,
IWorkbenchProductIconTheme
|
null
]
>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录