@@ -313,13 +313,21 @@ pub fn aspect_ratio_in_block_width_fixed() {
313
313
child. set_aspect_ratio ( Some ( 2. / 1. ) ) ;
314
314
container. append_child ( convert_node_ref_to_ptr ( child) ) ;
315
315
316
+ let child2 = as_ref ( Node :: new_ptr ( ) ) ;
317
+ child2. set_width ( DefLength :: Points ( Len :: from_f32 ( 100. ) ) ) ;
318
+ child2. set_height ( DefLength :: Auto ) ;
319
+ child2. set_aspect_ratio ( Some ( 0.5 / 1. ) ) ;
320
+ container. append_child ( convert_node_ref_to_ptr ( child2) ) ;
321
+
316
322
root. layout (
317
323
OptionSize :: new ( OptionNum :: some ( Len :: from_f32 ( 400. ) ) , OptionNum :: none ( ) ) ,
318
324
Size :: new ( Len :: from_f32 ( 0. ) , Len :: from_f32 ( 0. ) ) ,
319
325
) ;
320
326
321
327
assert_eq ! ( child. layout_position( ) . width, 100. ) ;
322
328
assert_eq ! ( child. layout_position( ) . height, 50. ) ;
329
+ assert_eq ! ( child2. layout_position( ) . width, 100. ) ;
330
+ assert_eq ! ( child2. layout_position( ) . height, 200. ) ;
323
331
}
324
332
}
325
333
@@ -338,13 +346,21 @@ pub fn aspect_ratio_in_block_height_fixed() {
338
346
child. set_aspect_ratio ( Some ( 2. / 1. ) ) ;
339
347
container. append_child ( convert_node_ref_to_ptr ( child) ) ;
340
348
349
+ let child2 = as_ref ( Node :: new_ptr ( ) ) ;
350
+ child2. set_width ( DefLength :: Auto ) ;
351
+ child2. set_height ( DefLength :: Points ( Len :: from_f32 ( 200. ) ) ) ;
352
+ child2. set_aspect_ratio ( Some ( 0.5 / 1. ) ) ;
353
+ container. append_child ( convert_node_ref_to_ptr ( child2) ) ;
354
+
341
355
root. layout (
342
356
OptionSize :: new ( OptionNum :: some ( Len :: from_f32 ( 400. ) ) , OptionNum :: none ( ) ) ,
343
357
Size :: new ( Len :: from_f32 ( 0. ) , Len :: from_f32 ( 0. ) ) ,
344
358
) ;
345
359
346
360
assert_eq ! ( child. layout_position( ) . width, 200. ) ;
347
361
assert_eq ! ( child. layout_position( ) . height, 100. ) ;
362
+ assert_eq ! ( child2. layout_position( ) . width, 100. ) ;
363
+ assert_eq ! ( child2. layout_position( ) . height, 200. ) ;
348
364
}
349
365
}
350
366
@@ -360,9 +376,20 @@ pub fn aspect_ratio_in_parent_block_cross_size_fixed() {
360
376
361
377
let child = as_ref ( Node :: new_ptr ( ) ) ;
362
378
child. set_width ( DefLength :: Auto ) ;
363
- child. set_aspect_ratio ( Some ( 1 . / 1. ) ) ;
379
+ child. set_aspect_ratio ( Some ( 2 . / 1. ) ) ;
364
380
container. append_child ( convert_node_ref_to_ptr ( child) ) ;
365
381
382
+ let container2 = as_ref ( Node :: new_ptr ( ) ) ;
383
+ container2. set_width ( DefLength :: Auto ) ;
384
+ container2. set_height ( DefLength :: Points ( Len :: from_f32 ( 300. ) ) ) ;
385
+ container2. set_writing_mode ( WritingMode :: VerticalLr ) ;
386
+ root. append_child ( convert_node_ref_to_ptr ( container2) ) ;
387
+
388
+ let child2 = as_ref ( Node :: new_ptr ( ) ) ;
389
+ child2. set_width ( DefLength :: Auto ) ;
390
+ child2. set_aspect_ratio ( Some ( 0.5 / 1. ) ) ;
391
+ container2. append_child ( convert_node_ref_to_ptr ( child2) ) ;
392
+
366
393
root. layout (
367
394
OptionSize :: new ( OptionNum :: some ( Len :: from_f32 ( 400. ) ) , OptionNum :: none ( ) ) ,
368
395
Size :: new ( Len :: from_f32 ( 0. ) , Len :: from_f32 ( 0. ) ) ,
@@ -381,7 +408,9 @@ pub fn aspect_ratio_in_parent_block_cross_size_fixed() {
381
408
) ;
382
409
383
410
assert_eq ! ( child. layout_position( ) . width, 300. ) ;
384
- assert_eq ! ( child. layout_position( ) . height, 300. ) ;
411
+ assert_eq ! ( child. layout_position( ) . height, 150. ) ;
412
+ assert_eq ! ( child2. layout_position( ) . width, 150. ) ;
413
+ assert_eq ! ( child2. layout_position( ) . height, 300. ) ;
385
414
}
386
415
}
387
416
@@ -398,7 +427,7 @@ pub fn aspect_ratio_with_min_width_constraint() {
398
427
child. set_width ( DefLength :: Auto ) ;
399
428
child. set_height ( DefLength :: Auto ) ;
400
429
child. set_min_width ( DefLength :: Points ( Len :: from_f32 ( 400. ) ) ) ;
401
- child. set_aspect_ratio ( Some ( 1 . / 1. ) ) ;
430
+ child. set_aspect_ratio ( Some ( 2 . / 1. ) ) ;
402
431
container. append_child ( convert_node_ref_to_ptr ( child) ) ;
403
432
404
433
root. layout (
@@ -419,7 +448,7 @@ pub fn aspect_ratio_with_min_width_constraint() {
419
448
) ;
420
449
421
450
assert_eq ! ( child. layout_position( ) . width, 400. ) ;
422
- assert_eq ! ( child. layout_position( ) . height, 400 .) ;
451
+ assert_eq ! ( child. layout_position( ) . height, 200 .) ;
423
452
}
424
453
}
425
454
@@ -436,7 +465,7 @@ pub fn aspect_ratio_with_max_width_constraint() {
436
465
child. set_width ( DefLength :: Auto ) ;
437
466
child. set_height ( DefLength :: Auto ) ;
438
467
child. set_max_width ( DefLength :: Points ( Len :: from_f32 ( 80. ) ) ) ;
439
- child. set_aspect_ratio ( Some ( 1 . / 1. ) ) ;
468
+ child. set_aspect_ratio ( Some ( 2 . / 1. ) ) ;
440
469
container. append_child ( convert_node_ref_to_ptr ( child) ) ;
441
470
442
471
root. layout (
@@ -457,7 +486,7 @@ pub fn aspect_ratio_with_max_width_constraint() {
457
486
) ;
458
487
459
488
assert_eq ! ( child. layout_position( ) . width, 80. ) ;
460
- assert_eq ! ( child. layout_position( ) . height, 80 .) ;
489
+ assert_eq ! ( child. layout_position( ) . height, 40 .) ;
461
490
}
462
491
}
463
492
@@ -516,7 +545,7 @@ pub fn aspect_ratio_block_size_with_box_sizing() {
516
545
child. set_padding_left ( DefLength :: Points ( Len :: from_f32 ( 30. ) ) ) ;
517
546
child. set_border_left ( DefLength :: Points ( Len :: from_f32 ( 20. ) ) ) ;
518
547
child. set_box_sizing ( BoxSizing :: BorderBox ) ;
519
- child. set_aspect_ratio ( Some ( 1 . / 1. ) ) ;
548
+ child. set_aspect_ratio ( Some ( 2 . / 1. ) ) ;
520
549
container. append_child ( convert_node_ref_to_ptr ( child) ) ;
521
550
522
551
let child2 = as_ref ( Node :: new_ptr ( ) ) ;
@@ -526,7 +555,7 @@ pub fn aspect_ratio_block_size_with_box_sizing() {
526
555
child2. set_padding_left ( DefLength :: Points ( Len :: from_f32 ( 30. ) ) ) ;
527
556
child2. set_border_left ( DefLength :: Points ( Len :: from_f32 ( 20. ) ) ) ;
528
557
child2. set_box_sizing ( BoxSizing :: PaddingBox ) ;
529
- child2. set_aspect_ratio ( Some ( 1 . / 1. ) ) ;
558
+ child2. set_aspect_ratio ( Some ( 2 . / 1. ) ) ;
530
559
container. append_child ( convert_node_ref_to_ptr ( child2) ) ;
531
560
532
561
let child3 = as_ref ( Node :: new_ptr ( ) ) ;
@@ -535,7 +564,7 @@ pub fn aspect_ratio_block_size_with_box_sizing() {
535
564
child3. set_width ( DefLength :: Points ( Len :: from_f32 ( 50. ) ) ) ;
536
565
child3. set_padding_left ( DefLength :: Points ( Len :: from_f32 ( 30. ) ) ) ;
537
566
child3. set_border_left ( DefLength :: Points ( Len :: from_f32 ( 20. ) ) ) ;
538
- child3. set_aspect_ratio ( Some ( 1 . / 1. ) ) ;
567
+ child3. set_aspect_ratio ( Some ( 2 . / 1. ) ) ;
539
568
container. append_child ( convert_node_ref_to_ptr ( child3) ) ;
540
569
541
570
root. layout (
@@ -556,11 +585,11 @@ pub fn aspect_ratio_block_size_with_box_sizing() {
556
585
) ;
557
586
558
587
assert_eq ! ( child. layout_position( ) . width, 50. ) ;
559
- assert_eq ! ( child. layout_position( ) . height, 50 .) ;
588
+ assert_eq ! ( child. layout_position( ) . height, 25 .) ;
560
589
assert_eq ! ( child2. layout_position( ) . width, 80. ) ;
561
- assert_eq ! ( child2. layout_position( ) . height, 50 .) ;
590
+ assert_eq ! ( child2. layout_position( ) . height, 25 .) ;
562
591
assert_eq ! ( child3. layout_position( ) . width, 100. ) ;
563
- assert_eq ! ( child3. layout_position( ) . height, 50 .) ;
592
+ assert_eq ! ( child3. layout_position( ) . height, 25 .) ;
564
593
}
565
594
}
566
595
@@ -581,7 +610,7 @@ pub fn aspect_ratio_block_size_with_box_sizing_and_writing_mode() {
581
610
child. set_padding_top ( DefLength :: Points ( Len :: from_f32 ( 30. ) ) ) ;
582
611
child. set_border_top ( DefLength :: Points ( Len :: from_f32 ( 20. ) ) ) ;
583
612
child. set_box_sizing ( BoxSizing :: BorderBox ) ;
584
- child. set_aspect_ratio ( Some ( 1 . / 1. ) ) ;
613
+ child. set_aspect_ratio ( Some ( 2 . / 1. ) ) ;
585
614
container. append_child ( convert_node_ref_to_ptr ( child) ) ;
586
615
587
616
let child2 = as_ref ( Node :: new_ptr ( ) ) ;
@@ -591,7 +620,7 @@ pub fn aspect_ratio_block_size_with_box_sizing_and_writing_mode() {
591
620
child2. set_padding_top ( DefLength :: Points ( Len :: from_f32 ( 30. ) ) ) ;
592
621
child2. set_border_top ( DefLength :: Points ( Len :: from_f32 ( 20. ) ) ) ;
593
622
child2. set_box_sizing ( BoxSizing :: PaddingBox ) ;
594
- child2. set_aspect_ratio ( Some ( 1 . / 1. ) ) ;
623
+ child2. set_aspect_ratio ( Some ( 2 . / 1. ) ) ;
595
624
container. append_child ( convert_node_ref_to_ptr ( child2) ) ;
596
625
597
626
let child3 = as_ref ( Node :: new_ptr ( ) ) ;
@@ -600,7 +629,7 @@ pub fn aspect_ratio_block_size_with_box_sizing_and_writing_mode() {
600
629
child3. set_height ( DefLength :: Points ( Len :: from_f32 ( 50. ) ) ) ;
601
630
child3. set_padding_top ( DefLength :: Points ( Len :: from_f32 ( 30. ) ) ) ;
602
631
child3. set_border_top ( DefLength :: Points ( Len :: from_f32 ( 20. ) ) ) ;
603
- child3. set_aspect_ratio ( Some ( 1 . / 1. ) ) ;
632
+ child3. set_aspect_ratio ( Some ( 2 . / 1. ) ) ;
604
633
container. append_child ( convert_node_ref_to_ptr ( child3) ) ;
605
634
606
635
root. layout (
@@ -620,11 +649,11 @@ pub fn aspect_ratio_block_size_with_box_sizing_and_writing_mode() {
620
649
)
621
650
) ;
622
651
623
- assert_eq ! ( child. layout_position( ) . width, 50 .) ;
652
+ assert_eq ! ( child. layout_position( ) . width, 100 .) ;
624
653
assert_eq ! ( child. layout_position( ) . height, 50. ) ;
625
- assert_eq ! ( child2. layout_position( ) . width, 50 .) ;
654
+ assert_eq ! ( child2. layout_position( ) . width, 100 .) ;
626
655
assert_eq ! ( child2. layout_position( ) . height, 80. ) ;
627
- assert_eq ! ( child3. layout_position( ) . width, 50 .) ;
656
+ assert_eq ! ( child3. layout_position( ) . width, 100 .) ;
628
657
assert_eq ! ( child3. layout_position( ) . height, 100. ) ;
629
658
}
630
659
}
0 commit comments