From 154aad128403ef1d7b29332cc5449fb7a6f4a549 Mon Sep 17 00:00:00 2001 From: Robin Schreiber Date: Thu, 19 Dec 2024 18:44:28 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8:=20avoid=20check=20for=20text=20st?= =?UTF-8?q?yle=20classes=20if=20not=20nessecary?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously especially in text morphs with a large document such as the editors inside the system browser, overly eager checks for certain text style classes would cause the performance to tank. This can be avoided by first checking wether or not the text morph is hugging its text contents or not. In case of hugging, the measurment via canvas has to be dispatched to each line, since textwrapping is not supported on canvas. --- lively.morphic/rendering/font-metric.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lively.morphic/rendering/font-metric.js b/lively.morphic/rendering/font-metric.js index e7cb72592b..f48ca3034e 100644 --- a/lively.morphic/rendering/font-metric.js +++ b/lively.morphic/rendering/font-metric.js @@ -363,7 +363,7 @@ class DOMTextMeasure { canBeMeasuredViaCanvas (aMorph) { if (!aMorph.allFontsLoaded() && document.fonts.status !== 'loading') return false; - if (this.hasTextStyleClasses(aMorph) && !aMorph.fixedWidth) return false; + if (!aMorph.fixedWidth && this.hasTextStyleClasses(aMorph)) return false; const { fontFamily, fontWeight, fontStyle } = aMorph; const key = `${fontFamily}-${fontWeight}-${fontStyle}`; if (key in this.canvasCompatibility) return this.canvasCompatibility[key];