(&mut self)
| 3515 | } |
| 3516 | |
| 3517 | fn propagate_sizes_up_tree(&mut self) { |
| 3518 | let mut dfs_buffer: Vec<i32> = Vec::new(); |
| 3519 | let mut visited: Vec<bool> = Vec::new(); |
| 3520 | |
| 3521 | for i in 0..self.layout_element_tree_roots.len() { |
| 3522 | let root = self.layout_element_tree_roots[i]; |
| 3523 | dfs_buffer.push(root.layout_element_index); |
| 3524 | visited.push(false); |
| 3525 | } |
| 3526 | |
| 3527 | while !dfs_buffer.is_empty() { |
| 3528 | let buf_idx = dfs_buffer.len() - 1; |
| 3529 | let current_elem_idx = dfs_buffer[buf_idx] as usize; |
| 3530 | |
| 3531 | if !visited[buf_idx] { |
| 3532 | visited[buf_idx] = true; |
| 3533 | let is_text = |
| 3534 | self.element_has_config(current_elem_idx, ElementConfigType::Text); |
| 3535 | let children_length = self.layout_elements[current_elem_idx].children_length; |
| 3536 | if is_text || children_length == 0 { |
| 3537 | dfs_buffer.pop(); |
| 3538 | visited.pop(); |
| 3539 | continue; |
| 3540 | } |
| 3541 | let children_start = self.layout_elements[current_elem_idx].children_start; |
| 3542 | for j in 0..children_length as usize { |
| 3543 | let child_idx = self.layout_element_children[children_start + j]; |
| 3544 | dfs_buffer.push(child_idx); |
| 3545 | visited.push(false); |
| 3546 | } |
| 3547 | continue; |
| 3548 | } |
| 3549 | |
| 3550 | dfs_buffer.pop(); |
| 3551 | visited.pop(); |
| 3552 | |
| 3553 | let layout_idx = self.layout_elements[current_elem_idx].layout_config_index; |
| 3554 | let layout_config = self.layout_configs[layout_idx]; |
| 3555 | let children_start = self.layout_elements[current_elem_idx].children_start; |
| 3556 | let children_length = self.layout_elements[current_elem_idx].children_length; |
| 3557 | |
| 3558 | if layout_config.layout_direction == LayoutDirection::LeftToRight { |
| 3559 | if layout_config.wrap { |
| 3560 | let lines = self.compute_wrapped_lines(current_elem_idx, true); |
| 3561 | let mut content_height = |
| 3562 | layout_config.padding.top as f32 + layout_config.padding.bottom as f32; |
| 3563 | if !lines.is_empty() { |
| 3564 | content_height += |
| 3565 | lines.iter().map(|line| line.cross_size).sum::<f32>(); |
| 3566 | content_height += |
| 3567 | lines.len().saturating_sub(1) as f32 * layout_config.wrap_gap as f32; |
| 3568 | } |
| 3569 | self.layout_elements[current_elem_idx].dimensions.height = f32::min( |
| 3570 | f32::max(content_height, layout_config.sizing.height.min_max.min), |
| 3571 | layout_config.sizing.height.min_max.max, |
| 3572 | ); |
| 3573 | } else { |
| 3574 | for j in 0..children_length as usize { |
no test coverage detected