mirror of
https://github.com/typst/typst
synced 2025-05-21 20:45:27 +08:00
use cached value in auto row measurement, less todos
This commit is contained in:
parent
2c5045d210
commit
3fa425dc83
@ -240,6 +240,8 @@ impl<'a> GridLayouter<'a> {
|
|||||||
// TODO(layout model): re-calculate heights of headers and footers
|
// TODO(layout model): re-calculate heights of headers and footers
|
||||||
// on each region if 'full' changes? (Assuming height doesn't
|
// on each region if 'full' changes? (Assuming height doesn't
|
||||||
// change for now...)
|
// change for now...)
|
||||||
|
//
|
||||||
|
// Would remove the footer height update below (move it here).
|
||||||
skipped_region = true;
|
skipped_region = true;
|
||||||
|
|
||||||
self.regions.size.y -= self.current.footer_height;
|
self.regions.size.y -= self.current.footer_height;
|
||||||
@ -250,7 +252,6 @@ impl<'a> GridLayouter<'a> {
|
|||||||
if skipped_region {
|
if skipped_region {
|
||||||
// Simulate the footer again; the region's 'full' might have
|
// Simulate the footer again; the region's 'full' might have
|
||||||
// changed.
|
// changed.
|
||||||
// TODO: maybe this should go in the loop, a bit hacky as is...
|
|
||||||
self.regions.size.y += self.current.footer_height;
|
self.regions.size.y += self.current.footer_height;
|
||||||
self.current.footer_height = self
|
self.current.footer_height = self
|
||||||
.simulate_footer(footer, &self.regions, engine, disambiguator)?
|
.simulate_footer(footer, &self.regions, engine, disambiguator)?
|
||||||
|
@ -527,23 +527,7 @@ impl GridLayouter<'_> {
|
|||||||
// we have to use initial header heights (note that
|
// we have to use initial header heights (note that
|
||||||
// header height can change in the middle of the
|
// header height can change in the middle of the
|
||||||
// region).
|
// region).
|
||||||
// TODO: maybe cache this
|
self.current.initial_after_repeats
|
||||||
// NOTE: it is safe to access 'lrows' here since
|
|
||||||
// 'breakable' can only be true outside of headers
|
|
||||||
// and unbreakable rows in general, so there is no risk
|
|
||||||
// of accessing an incomplete list of rows.
|
|
||||||
let initial_header_height = self.current.lrows
|
|
||||||
[..self.current.repeated_header_rows]
|
|
||||||
.iter()
|
|
||||||
.map(|row| match row {
|
|
||||||
Row::Frame(frame, _, _) => frame.height(),
|
|
||||||
Row::Fr(_, _, _) => Abs::zero(),
|
|
||||||
})
|
|
||||||
.sum();
|
|
||||||
|
|
||||||
self.current.initial.y
|
|
||||||
- initial_header_height
|
|
||||||
- self.current.footer_height
|
|
||||||
} else {
|
} else {
|
||||||
// When measuring unbreakable auto rows, infinite
|
// When measuring unbreakable auto rows, infinite
|
||||||
// height is available for content to expand.
|
// height is available for content to expand.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user