@@ -41,6 +41,8 @@ pub struct FloatContext {
4141 /// A list of non-overlapping horizontal segments within the context.
4242 /// Each segment has the same available width for it's entire height.
4343 placer : FloatPlacer ,
44+ /// Whether the float context contains any floats
45+ has_floats : bool ,
4446}
4547
4648/// An empty "slot" that avoids floats that is suitable for non-floated content
@@ -92,9 +94,20 @@ impl FloatContext {
9294 left_floats : Vec :: new ( ) ,
9395 right_floats : Vec :: new ( ) ,
9496 placer : FloatPlacer :: new ( available_space) ,
97+ has_floats : false ,
9598 }
9699 }
97100
101+ /// Whether the float context contains any floats
102+ pub fn has_floats ( & self ) -> bool {
103+ self . has_floats
104+ }
105+
106+ /// Whether the float context contains any floats that extend to or below min_y
107+ pub fn has_active_floats ( & self , min_y : f32 ) -> bool {
108+ self . has_floats && self . placer . segment_end ( ) > min_y
109+ }
110+
98111 /// Create a new empty `FloatContext`
99112 pub fn set_width ( & mut self , available_space : AvailableSpace ) {
100113 self . available_space = available_space;
@@ -136,6 +149,8 @@ impl FloatContext {
136149 // }
137150 // };
138151
152+ self . has_floats = true ;
153+
139154 // Return the (x, y) coordinates of the positioned box
140155 match self . available_space {
141156 // Position won't actually be used if we're layouting under a min-content
@@ -216,13 +231,13 @@ impl Segment {
216231struct FloatPlacer {
217232 // Calling into this
218233 bfc_width : f32 ,
219-
234+ /// A list of the "segments" in the float context.
220235 segments : Vec < Segment > ,
221- // Left hwm in slot 0. Right hwm in slot 1.
222- // high_water_marks: [usize; 2],
223236 /// A closed-open range indicating which segment the last placed float
224237 /// was placed(on each side).
225238 last_placed_floats : [ Range < usize > ; 2 ] ,
239+ // Left hwm in slot 0. Right hwm in slot 1.
240+ // high_water_marks: [usize; 2],
226241 // left_float_high_water_mark: usize,
227242 // right_float_high_water_mark: usize,
228243}
@@ -293,6 +308,10 @@ impl FloatPlacer {
293308 self . last_placed_floats [ slot] . end = self . last_placed_floats [ slot] . end . max ( placement. end ) ;
294309 }
295310
311+ fn segment_end ( & self ) -> f32 {
312+ self . segments . last ( ) . map ( |seg| seg. y . end ) . unwrap_or ( 0.0 )
313+ }
314+
296315 fn place_float (
297316 & mut self ,
298317 min_y : f32 ,
0 commit comments