use crate::model::table::{Cell, Table, TablePageBreak};
use super::{CellUnit, LayoutEngine, ResolvedStyleSet};
impl LayoutEngine {
pub(super) fn nested_source_frame_bottom_padding(
&self,
table: &Table,
cell: &Cell,
units: &[CellUnit],
start: usize,
end: usize,
styles: &ResolvedStyleSet,
) -> f64 {
let profile = self.profile.get();
if !(profile.hwp5_stored_pagination_layout() || profile.hwpx_stored_layout())
|| profile.session_edited()
|| table.layout_page_break() != TablePageBreak::RowBreak
|| cell.row_span != 1
|| cell.dirty_flag
|| self
.render_normalization
.borrow()
.table_text_reflowed(table)
|| end <= start
|| end >= units.len()
{
return 0.0;
}
let closing = &units[end - 1];
let next = &units[end];
if !closing.mixed_nested_recursive
|| !next.mixed_nested_recursive
|| !next.stored_frame_break_before
|| closing.para_idx != next.para_idx
|| closing.mixed_nested_source_para_idx != next.mixed_nested_source_para_idx
{
return 0.0;
}
if cell.paragraphs[closing.para_idx]
.controls
.iter()
.find_map(|control| match control {
crate::model::control::Control::Table(child) => self
.render_normalization
.borrow()
.stored_nested_text_frames(child),
_ => None,
})
.is_some_and(|frames| frames.parent_opening_owns_bottom_padding)
{
return 0.0;
}
let (_, _, _, bottom) = self.resolve_stored_nested_cell_padding(cell, table, styles);
bottom.min(closing.height)
}
}