Skip to content

Commit

Permalink
layout: improve perf of text-align hack
Browse files Browse the repository at this point in the history
  • Loading branch information
CanadaHonk committed Nov 8, 2023
1 parent 33bd28d commit 88e55af
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions engine/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -997,11 +997,14 @@ export class LayoutNode extends Node {
if (this.isInline() && this.css()['text-align'] !== 'left') {
// hack: align next time as we cannot compute our own width here
if (!this.cache._alignWidth) {
setTimeout(() => {
this.cache._alignWidth = this.totalWidth();
this.cache._alignWidthParent = this.parent.contentWidth();
this.invalidateCaches(false, ['_alignWidth', '_alignWidthParent']);
}, 0);
if (this.cache._alignWidth === undefined) {
this.cache._alignWidth = null;
setTimeout(() => {
this.cache._alignWidth = this.totalWidth();
this.cache._alignWidthParent = this.parent.contentWidth();
this.invalidateCaches(false, ['_alignWidth', '_alignWidthParent']);
}, 0);
}

return this._alignTmp ?? -9999;
}
Expand Down

0 comments on commit 88e55af

Please sign in to comment.