@@ -8,8 +8,7 @@ use float_pigment_css::{
8
8
} ,
9
9
} ;
10
10
use float_pigment_layout:: {
11
- DefLength , Edge , EdgeOption , InlineMeasure , InlineUnit , LayoutNode , LayoutStyle ,
12
- LayoutTreeNode , LayoutTreeVisitor , MeasureResult , OptionNum , OptionSize , Point , Size , Vector ,
11
+ DefLength , Edge , EdgeOption , InlineMeasure , InlineUnit , InlineUnitMetadata , LayoutNode , LayoutStyle , LayoutTreeNode , LayoutTreeVisitor , MeasureResult , OptionNum , OptionSize , Point , Size , Vector
13
12
} ;
14
13
15
14
use crate :: { convert_node_ref_to_ptr, Length } ;
@@ -240,22 +239,8 @@ impl LayoutTreeNode for Node {
240
239
min : Size < Self :: Length > ,
241
240
max : Size < Self :: Length > ,
242
241
max_content : OptionSize < Self :: Length > ,
243
- ) -> Self :: InlineUnit {
244
- let measure_res = self . measure_block_size ( env, req_size, min, max, max_content, false ) ;
245
- let size = measure_res. size ;
246
- LayoutInlineUnit {
247
- offset : Point :: zero ( ) ,
248
- size,
249
- first_baseline_ascent : Vector :: new (
250
- measure_res. first_baseline_ascent . x ,
251
- measure_res. first_baseline_ascent . y ,
252
- ) ,
253
- last_baseline_ascent : Vector :: new (
254
- measure_res. last_baseline_ascent . x ,
255
- measure_res. last_baseline_ascent . y ,
256
- ) ,
257
- is_inline_block : false ,
258
- }
242
+ ) -> MeasureResult < Self :: Length > {
243
+ self . measure_block_size ( env, req_size, min, max, max_content, false )
259
244
}
260
245
}
261
246
@@ -290,7 +275,6 @@ pub struct LayoutInlineUnit {
290
275
size : Size < Len > ,
291
276
first_baseline_ascent : Vector < Len > ,
292
277
last_baseline_ascent : Vector < Len > ,
293
- is_inline_block : bool ,
294
278
}
295
279
296
280
impl LayoutInlineUnit {
@@ -304,26 +288,16 @@ impl LayoutInlineUnit {
304
288
} ,
305
289
)
306
290
}
307
- fn adjust_inline_size ( & mut self , padding_border : Edge < Len > ) {
308
- if self . is_inline_block {
309
- return ;
310
- }
311
- self . size . height += padding_border. vertical ( ) ;
312
- self . size . width += padding_border. horizontal ( ) ;
313
- self . first_baseline_ascent . y += padding_border. top ;
314
- self . last_baseline_ascent . y += padding_border. top ;
315
- }
316
291
}
317
292
318
293
impl InlineUnit < Node > for LayoutInlineUnit {
319
294
type Env = Env ;
320
- fn inline_block ( _env : & mut Env , _node : & Node , size : Size < Len > , baseline_ascent : Len ) -> Self {
295
+ fn new ( _env : & mut Env , _node : & Node , res : MeasureResult < Len > ) -> Self {
321
296
Self {
322
297
offset : Point :: zero ( ) ,
323
- size,
324
- first_baseline_ascent : Vector :: new ( Len :: zero ( ) , baseline_ascent) ,
325
- last_baseline_ascent : Vector :: new ( Len :: zero ( ) , baseline_ascent) ,
326
- is_inline_block : true ,
298
+ size : res. size ,
299
+ first_baseline_ascent : res. first_baseline_ascent ,
300
+ last_baseline_ascent : res. last_baseline_ascent ,
327
301
}
328
302
}
329
303
}
@@ -399,7 +373,7 @@ impl InlineMeasure<Node> for LayoutInlineMeasure {
399
373
fn block_size (
400
374
_env : & mut Env ,
401
375
block_node : & Node ,
402
- inline_nodes : Vec < ( LayoutInlineUnit , EdgeOption < Len > , Edge < Len > ) > ,
376
+ inline_nodes : Vec < InlineUnitMetadata < Node > > ,
403
377
req_size : OptionSize < Len > ,
404
378
_max_content_with_max_size : OptionSize < Len > ,
405
379
_update_position : bool ,
@@ -421,10 +395,9 @@ impl InlineMeasure<Node> for LayoutInlineMeasure {
421
395
if let Some ( suggested_width) = suggested_width. val ( ) {
422
396
inline_nodes
423
397
. into_iter ( )
424
- . for_each ( |( mut inline_unit, margin, padding_border) | {
425
- inline_unit. adjust_inline_size ( padding_border) ;
398
+ . for_each ( |InlineUnitMetadata { unit, margin } | {
426
399
if ( current_line. total_inline_size
427
- + inline_unit . size . width
400
+ + unit . size . width
428
401
+ margin. horizontal ( )
429
402
> suggested_width)
430
403
&& !current_line. is_empty ( )
@@ -434,14 +407,13 @@ impl InlineMeasure<Node> for LayoutInlineMeasure {
434
407
current_line = Line :: default ( ) ;
435
408
current_line. block_start = prev_line_block_start;
436
409
}
437
- current_line. collect_inline_unit ( inline_unit , margin) ;
410
+ current_line. collect_inline_unit ( unit , margin) ;
438
411
} ) ;
439
412
} else {
440
413
inline_nodes
441
414
. into_iter ( )
442
- . for_each ( |( mut inline_unit, margin, padding_border) | {
443
- inline_unit. adjust_inline_size ( padding_border) ;
444
- current_line. collect_inline_unit ( inline_unit, margin) ;
415
+ . for_each ( |InlineUnitMetadata { unit, margin } | {
416
+ current_line. collect_inline_unit ( unit, margin) ;
445
417
} ) ;
446
418
}
447
419
if !current_line. is_empty ( ) {
0 commit comments