1
0

Milde optimizations

This commit is contained in:
Zef Hemel 2023-11-16 09:59:37 +01:00
parent 5b81185afa
commit 1af5e022a0
8 changed files with 18 additions and 13 deletions

View File

@ -1,8 +1,9 @@
/* Reset SB styles */
html,
body {
height: initial !important;
overflow: initial !important;
/*height: initial !important;
overflow-x: initial !important;
overflow-y: hidden !important;*/
background-color: var(--root-background-color) !important;
}

View File

@ -33,6 +33,7 @@ ol {
ul {
list-style: none;
padding-left: 1ch;
}
ul li::before {

View File

@ -47,7 +47,7 @@ async function init() {
const messageData = e.data;
switch (messageData.type) {
case "setHeight":
iframe.style.height = messageData.height + "px";
iframe.height = messageData.height + "px";
// Propagate height setting to parent
updateHeight();
break;

View File

@ -55,7 +55,8 @@ class IFrameWidget extends WidgetType {
},
);
iframe.style.height = `${this.estimatedHeight}px`;
const estimatedHeight = this.estimatedHeight;
iframe.height = `${estimatedHeight}px`;
return iframe;
}

View File

@ -105,7 +105,8 @@ function loadJsByUrl(url) {
html,
body {
height: initial !important;
overflow: initial !important;
overflow-x: initial !important;
overflow-y: hidden !important;
background-color: var(--root-background-color);
}
</style>

View File

@ -32,7 +32,7 @@ function updatePool(exclude?: PreloadedIFrame) {
preloadedIframe.used && !document.body.contains(preloadedIframe.iframe)
) {
// Ditch it
console.log("Garbage collecting iframe", preloadedIframe);
// console.log("Garbage collecting iframe", preloadedIframe);
iframePool.delete(preloadedIframe);
}
if (!preloadedIframe.used) {
@ -46,7 +46,7 @@ function updatePool(exclude?: PreloadedIFrame) {
}
export function prepareSandboxIFrame(): PreloadedIFrame {
console.log("Preloading iframe");
// console.log("Preloading iframe");
const iframe = document.createElement("iframe");
// Empty page with current origin. Handled this differently before, but "dock apps" in Safari (PWA implementation) seem to have various restrictions
@ -70,7 +70,7 @@ export function prepareSandboxIFrame(): PreloadedIFrame {
function claimIFrame(): PreloadedIFrame {
for (const preloadedIframe of iframePool) {
if (!preloadedIframe.used) {
console.log("Took iframe from pool");
// console.log("Took iframe from pool");
preloadedIframe.used = true;
updatePool(preloadedIframe);
return preloadedIframe;
@ -108,6 +108,7 @@ export function mountIFrame(
onMessage?: (message: any) => void,
) {
const iframe = preloadedIFrame.iframe;
preloadedIFrame.ready.then(async () => {
const messageListener = (evt: any) => {
(async () => {
@ -146,7 +147,7 @@ export function mountIFrame(
break;
}
case "setHeight":
iframe.style.height = data.height + "px";
iframe.height = data.height + "px";
if (widgetHeightCacheKey) {
client.space.setCachedWidgetHeight(
widgetHeightCacheKey,
@ -183,10 +184,10 @@ export function mountIFrame(
} else if (resolvedContent.url) {
iframe.contentWindow!.location.href = resolvedContent.url;
if (resolvedContent.height) {
iframe.style.height = resolvedContent.height + "px";
iframe.height = resolvedContent.height + "px";
}
if (resolvedContent.width) {
iframe.style.width = resolvedContent.width + "px";
iframe.width = resolvedContent.width + "px";
}
}
}).catch(console.error);

View File

@ -35,7 +35,7 @@ export class Space {
.catch(
console.error,
);
console.log("Flushed widget height cache to store");
// console.log("Flushed widget height cache to store");
}, 5000);
setCachedWidgetHeight(bodyText: string, height: number) {

View File

@ -437,7 +437,7 @@
font-weight: bold;
}
// this seems to not be used anymore
// Allow for cursor movement into a code widget fenced code block from bottom-up
.sb-fenced-code-hide {
background-color: transparent;
line-height: 0;