Skip to content

Commit

Permalink
🎨: avoid check for text style classes if not nessecary
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
merryman committed Dec 19, 2024
1 parent 9c51c58 commit 154aad1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lively.morphic/rendering/font-metric.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 154aad1

Please sign in to comment.