pub struct FragmentationLayoutContext {Show 15 fields
pub page_size: LogicalSize,
pub margins: PageMargins,
pub template: PageTemplate,
pub current_page: usize,
pub current_y: f32,
pub available_height: f32,
pub page_content_height: f32,
pub break_inside_avoid_depth: usize,
pub orphans: u32,
pub widows: u32,
pub fragments: Vec<PageFragment>,
pub counter: PageCounter,
pub defaults: FragmentationDefaults,
pub break_points: Vec<BreakPoint>,
pub avoid_break_before_next: bool,
}Expand description
Context for fragmentation-aware layout
Fields§
§page_size: LogicalSizePage size (including margins)
margins: PageMarginsContent area margins
template: PageTemplatePage template for headers/footers
current_page: usizeCurrent page being laid out (0-indexed)
current_y: f32Y position on current page (0 = top of content area)
available_height: f32Available height remaining on current page
page_content_height: f32Page content height (without margins and headers/footers)
break_inside_avoid_depth: usizeAccumulated break-inside: avoid depth from ancestors
orphans: u32Current orphans setting (inherited)
widows: u32Current widows setting (inherited)
fragments: Vec<PageFragment>All page fragments generated so far
counter: PageCounterPage counter for headers/footers
defaults: FragmentationDefaultsFragmentation defaults (smart behavior settings)
break_points: Vec<BreakPoint>Break points encountered during layout
avoid_break_before_next: boolWhether to avoid break before next box
Implementations§
Source§impl FragmentationLayoutContext
impl FragmentationLayoutContext
Sourcepub fn new(page_size: LogicalSize, margins: PageMargins) -> Self
pub fn new(page_size: LogicalSize, margins: PageMargins) -> Self
Create a new fragmentation context for paged layout
Sourcepub fn with_template(self, template: PageTemplate) -> Self
pub fn with_template(self, template: PageTemplate) -> Self
Create context with a page template
Sourcepub fn with_defaults(self, defaults: FragmentationDefaults) -> Self
pub fn with_defaults(self, defaults: FragmentationDefaults) -> Self
Create context with custom defaults
Sourcepub fn content_origin(&self) -> LogicalPosition
pub fn content_origin(&self) -> LogicalPosition
Get the content area origin for the current page
Sourcepub fn content_size(&self) -> LogicalSize
pub fn content_size(&self) -> LogicalSize
Get the content area size for the current page
Sourcepub fn can_fit(&self, height: f32) -> bool
pub fn can_fit(&self, height: f32) -> bool
Check if content of given height can fit on current page
Sourcepub fn would_fit_on_empty_page(&self, height: f32) -> bool
pub fn would_fit_on_empty_page(&self, height: f32) -> bool
Check if content would fit on an empty page
Sourcepub fn advance_page(&mut self)
pub fn advance_page(&mut self)
Advance to the next page
Sourcepub fn advance_to_left_page(&mut self)
pub fn advance_to_left_page(&mut self)
Advance to a left (even) page
Sourcepub fn advance_to_right_page(&mut self)
pub fn advance_to_right_page(&mut self)
Advance to a right (odd) page
Sourcepub fn enter_avoid_break(&mut self)
pub fn enter_avoid_break(&mut self)
Enter a box with break-inside: avoid
Sourcepub fn exit_avoid_break(&mut self)
pub fn exit_avoid_break(&mut self)
Exit a box with break-inside: avoid
Sourcepub fn set_avoid_break_before_next(&mut self)
pub fn set_avoid_break_before_next(&mut self)
Set flag to avoid break before next content
Sourcepub fn add_fragment(&mut self, fragment: PageFragment)
pub fn add_fragment(&mut self, fragment: PageFragment)
Add a page fragment
Sourcepub fn page_count(&self) -> usize
pub fn page_count(&self) -> usize
Get the total number of pages so far
Sourcepub fn set_total_pages(&mut self, total: usize)
pub fn set_total_pages(&mut self, total: usize)
Set total page count (for “Page X of Y” footers)
Sourcepub fn into_display_lists(self) -> Vec<DisplayList>
pub fn into_display_lists(self) -> Vec<DisplayList>
Convert fragments to display lists (one per page)
Sourcepub fn generate_page_chrome(&self, page_index: usize) -> Vec<DisplayListItem>
pub fn generate_page_chrome(&self, page_index: usize) -> Vec<DisplayListItem>
Generate header/footer display list items for a specific page
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FragmentationLayoutContext
impl !RefUnwindSafe for FragmentationLayoutContext
impl Send for FragmentationLayoutContext
impl Sync for FragmentationLayoutContext
impl Unpin for FragmentationLayoutContext
impl !UnwindSafe for FragmentationLayoutContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more