@@ -8,7 +8,7 @@ use float_pigment_css::{
8
8
} ,
9
9
} ;
10
10
use float_pigment_layout:: {
11
- DefLength , Edge , EdgeOption , InlineMeasure , InlineUnit , LayoutNode , LayoutStyle ,
11
+ DefLength , EdgeOption , InlineMeasure , InlineUnit , InlineUnitMetadata , LayoutNode , LayoutStyle ,
12
12
LayoutTreeNode , LayoutTreeVisitor , MeasureResult , OptionNum , OptionSize , Point , Size , Vector ,
13
13
} ;
14
14
@@ -240,22 +240,8 @@ impl LayoutTreeNode for Node {
240
240
min : Size < Self :: Length > ,
241
241
max : Size < Self :: Length > ,
242
242
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
- }
243
+ ) -> MeasureResult < Self :: Length > {
244
+ self . measure_block_size ( env, req_size, min, max, max_content, false )
259
245
}
260
246
}
261
247
@@ -290,7 +276,6 @@ pub struct LayoutInlineUnit {
290
276
size : Size < Len > ,
291
277
first_baseline_ascent : Vector < Len > ,
292
278
last_baseline_ascent : Vector < Len > ,
293
- is_inline_block : bool ,
294
279
}
295
280
296
281
impl LayoutInlineUnit {
@@ -304,26 +289,16 @@ impl LayoutInlineUnit {
304
289
} ,
305
290
)
306
291
}
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
292
}
317
293
318
294
impl InlineUnit < Node > for LayoutInlineUnit {
319
295
type Env = Env ;
320
- fn inline_block ( _env : & mut Env , _node : & Node , size : Size < Len > , baseline_ascent : Len ) -> Self {
296
+ fn new ( _env : & mut Env , _node : & Node , res : MeasureResult < Len > ) -> Self {
321
297
Self {
322
298
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 ,
299
+ size : res. size ,
300
+ first_baseline_ascent : res. first_baseline_ascent ,
301
+ last_baseline_ascent : res. last_baseline_ascent ,
327
302
}
328
303
}
329
304
}
@@ -399,7 +374,7 @@ impl InlineMeasure<Node> for LayoutInlineMeasure {
399
374
fn block_size (
400
375
_env : & mut Env ,
401
376
block_node : & Node ,
402
- inline_nodes : Vec < ( LayoutInlineUnit , EdgeOption < Len > , Edge < Len > ) > ,
377
+ inline_nodes : Vec < InlineUnitMetadata < Node > > ,
403
378
req_size : OptionSize < Len > ,
404
379
_max_content_with_max_size : OptionSize < Len > ,
405
380
_update_position : bool ,
@@ -421,11 +396,8 @@ impl InlineMeasure<Node> for LayoutInlineMeasure {
421
396
if let Some ( suggested_width) = suggested_width. val ( ) {
422
397
inline_nodes
423
398
. into_iter ( )
424
- . for_each ( |( mut inline_unit, margin, padding_border) | {
425
- inline_unit. adjust_inline_size ( padding_border) ;
426
- if ( current_line. total_inline_size
427
- + inline_unit. size . width
428
- + margin. horizontal ( )
399
+ . for_each ( |InlineUnitMetadata { unit, margin } | {
400
+ if ( current_line. total_inline_size + unit. size . width + margin. horizontal ( )
429
401
> suggested_width)
430
402
&& !current_line. is_empty ( )
431
403
{
@@ -434,14 +406,13 @@ impl InlineMeasure<Node> for LayoutInlineMeasure {
434
406
current_line = Line :: default ( ) ;
435
407
current_line. block_start = prev_line_block_start;
436
408
}
437
- current_line. collect_inline_unit ( inline_unit , margin) ;
409
+ current_line. collect_inline_unit ( unit , margin) ;
438
410
} ) ;
439
411
} else {
440
412
inline_nodes
441
413
. 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) ;
414
+ . for_each ( |InlineUnitMetadata { unit, margin } | {
415
+ current_line. collect_inline_unit ( unit, margin) ;
445
416
} ) ;
446
417
}
447
418
if !current_line. is_empty ( ) {
0 commit comments