Trusted types - don't use innerHTML for rapid render, https://github.com/microsoft/vscode/issues/106395
This commit is contained in:
parent
a46ba1f84c
commit
3994ae4c9e
1 changed files with 21 additions and 14 deletions
|
@ -124,7 +124,7 @@ function showPartsSplash(configuration) {
|
|||
const style = document.createElement('style');
|
||||
style.className = 'initialShellColors';
|
||||
document.head.appendChild(style);
|
||||
style.innerHTML = `body { background-color: ${shellBackground}; color: ${shellForeground}; margin: 0; padding: 0; }`;
|
||||
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)
|
||||
|
@ -148,22 +148,29 @@ function showPartsSplash(configuration) {
|
|||
// 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
|
||||
splash.innerHTML = `
|
||||
<div style="position: absolute; width: 100%; left: 0; top: 0; height: ${layoutInfo.titleBarHeight}px; background-color: ${colorInfo.titleBarBackground}; -webkit-app-region: drag;"></div>
|
||||
<div style="position: absolute; height: calc(100% - ${layoutInfo.titleBarHeight}px); top: ${layoutInfo.titleBarHeight}px; ${layoutInfo.sideBarSide}: 0; width: ${layoutInfo.activityBarWidth}px; background-color: ${colorInfo.activityBarBackground};"></div>
|
||||
<div 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};"></div>
|
||||
<div style="position: absolute; width: 100%; bottom: 0; left: 0; height: ${layoutInfo.statusBarHeight}px; background-color: ${colorInfo.statusBarBackground};"></div>
|
||||
`;
|
||||
} else {
|
||||
// empty -> speical status bar color, no sidebar
|
||||
splash.innerHTML = `
|
||||
<div style="position: absolute; width: 100%; left: 0; top: 0; height: ${layoutInfo.titleBarHeight}px; background-color: ${colorInfo.titleBarBackground}; -webkit-app-region: drag;"></div>
|
||||
<div style="position: absolute; height: calc(100% - ${layoutInfo.titleBarHeight}px); top: ${layoutInfo.titleBarHeight}px; ${layoutInfo.sideBarSide}: 0; width: ${layoutInfo.activityBarWidth}px; background-color: ${colorInfo.activityBarBackground};"></div>
|
||||
<div style="position: absolute; width: 100%; bottom: 0; left: 0; height: ${layoutInfo.statusBarHeight}px; background-color: ${colorInfo.statusBarNoFolderBackground};"></div>
|
||||
`;
|
||||
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
|
||||
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};`);
|
||||
splash.appendChild(statusDiv);
|
||||
|
||||
document.body.appendChild(splash);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue