@@ -56,6 +56,8 @@ struct PrevBoundaryState {
5656pub enum YieldData {
5757 /// Control flow was yielded because a line break was encountered
5858 LineBreak ( LineBreakData ) ,
59+ /// Control flow was yielded because content on the line caused the line to exceed the max_height
60+ MaxHeightExceeded ( MaxHeightBreakData ) ,
5961 /// Control flow was yielded because an inline box with `break_on_box` set
6062 /// to `true` was encountered
6163 InlineBoxBreak ( BoxBreakData ) ,
@@ -67,6 +69,11 @@ pub struct LineBreakData {
6769 pub line_height : f32 ,
6870}
6971
72+ pub struct MaxHeightBreakData {
73+ pub advance : f32 ,
74+ pub line_height : f32 ,
75+ }
76+
7077pub struct BoxBreakData {
7178 /// The user-supplied ID for the inline box
7279 pub inline_box_id : u64 ,
@@ -75,7 +82,7 @@ pub struct BoxBreakData {
7582 pub advance : f32 ,
7683}
7784
78- #[ derive( Clone , Default ) ]
85+ #[ derive( Clone ) ]
7986pub struct BreakerState {
8087 /// The number of items that have been processed (used to revert state)
8188 items : usize ,
@@ -99,12 +106,34 @@ pub struct BreakerState {
99106 layout_max_advance : f32 ,
100107 /// The max advance (max width) of the current line. This must be <= the `layout_max_advance`.
101108 line_max_advance : f32 ,
109+ /// The max height available to the current line.
110+ line_max_height : f32 ,
102111
103112 line : LineState ,
104113 prev_boundary : Option < PrevBoundaryState > ,
105114 emergency_boundary : Option < PrevBoundaryState > ,
106115}
107116
117+ impl Default for BreakerState {
118+ fn default ( ) -> Self {
119+ Self {
120+ items : 0 ,
121+ lines : 0 ,
122+ item_idx : 0 ,
123+ run_idx : 0 ,
124+ cluster_idx : 0 ,
125+ line_x : 0.0 ,
126+ line_y : 0.0 ,
127+ layout_max_advance : 0.0 ,
128+ line_max_advance : 0.0 ,
129+ line_max_height : f32:: MAX ,
130+ line : LineState :: default ( ) ,
131+ prev_boundary : None ,
132+ emergency_boundary : None ,
133+ }
134+ }
135+ }
136+
108137impl BreakerState {
109138 /// Add the cluster(s) currently being evaluated to the current line
110139 pub fn append_cluster_to_line ( & mut self , next_x : f32 , clusters_height : f32 ) {
@@ -539,6 +568,7 @@ impl<'a, B: Brush> BreakLines<'a, B> {
539568 self . state . line_y += line_break_data. line_height as f64 ;
540569 continue ;
541570 }
571+ YieldData :: MaxHeightExceeded ( _) => continue ,
542572 YieldData :: InlineBoxBreak ( _) => continue ,
543573 }
544574 }
0 commit comments