@@ -313,13 +313,21 @@ pub fn aspect_ratio_in_block_width_fixed() {
313313 child. set_aspect_ratio ( Some ( 2. / 1. ) ) ;
314314 container. append_child ( convert_node_ref_to_ptr ( child) ) ;
315315
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+
316322 root. layout (
317323 OptionSize :: new ( OptionNum :: some ( Len :: from_f32 ( 400. ) ) , OptionNum :: none ( ) ) ,
318324 Size :: new ( Len :: from_f32 ( 0. ) , Len :: from_f32 ( 0. ) ) ,
319325 ) ;
320326
321327 assert_eq ! ( child. layout_position( ) . width, 100. ) ;
322328 assert_eq ! ( child. layout_position( ) . height, 50. ) ;
329+ assert_eq ! ( child2. layout_position( ) . width, 100. ) ;
330+ assert_eq ! ( child2. layout_position( ) . height, 200. ) ;
323331 }
324332}
325333
@@ -338,13 +346,21 @@ pub fn aspect_ratio_in_block_height_fixed() {
338346 child. set_aspect_ratio ( Some ( 2. / 1. ) ) ;
339347 container. append_child ( convert_node_ref_to_ptr ( child) ) ;
340348
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+
341355 root. layout (
342356 OptionSize :: new ( OptionNum :: some ( Len :: from_f32 ( 400. ) ) , OptionNum :: none ( ) ) ,
343357 Size :: new ( Len :: from_f32 ( 0. ) , Len :: from_f32 ( 0. ) ) ,
344358 ) ;
345359
346360 assert_eq ! ( child. layout_position( ) . width, 200. ) ;
347361 assert_eq ! ( child. layout_position( ) . height, 100. ) ;
362+ assert_eq ! ( child2. layout_position( ) . width, 100. ) ;
363+ assert_eq ! ( child2. layout_position( ) . height, 200. ) ;
348364 }
349365}
350366
@@ -360,9 +376,20 @@ pub fn aspect_ratio_in_parent_block_cross_size_fixed() {
360376
361377 let child = as_ref ( Node :: new_ptr ( ) ) ;
362378 child. set_width ( DefLength :: Auto ) ;
363- child. set_aspect_ratio ( Some ( 1 . / 1. ) ) ;
379+ child. set_aspect_ratio ( Some ( 2 . / 1. ) ) ;
364380 container. append_child ( convert_node_ref_to_ptr ( child) ) ;
365381
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+
366393 root. layout (
367394 OptionSize :: new ( OptionNum :: some ( Len :: from_f32 ( 400. ) ) , OptionNum :: none ( ) ) ,
368395 Size :: new ( Len :: from_f32 ( 0. ) , Len :: from_f32 ( 0. ) ) ,
@@ -381,7 +408,9 @@ pub fn aspect_ratio_in_parent_block_cross_size_fixed() {
381408 ) ;
382409
383410 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. ) ;
385414 }
386415}
387416
@@ -398,7 +427,7 @@ pub fn aspect_ratio_with_min_width_constraint() {
398427 child. set_width ( DefLength :: Auto ) ;
399428 child. set_height ( DefLength :: Auto ) ;
400429 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. ) ) ;
402431 container. append_child ( convert_node_ref_to_ptr ( child) ) ;
403432
404433 root. layout (
@@ -419,7 +448,7 @@ pub fn aspect_ratio_with_min_width_constraint() {
419448 ) ;
420449
421450 assert_eq ! ( child. layout_position( ) . width, 400. ) ;
422- assert_eq ! ( child. layout_position( ) . height, 400 .) ;
451+ assert_eq ! ( child. layout_position( ) . height, 200 .) ;
423452 }
424453}
425454
@@ -436,7 +465,7 @@ pub fn aspect_ratio_with_max_width_constraint() {
436465 child. set_width ( DefLength :: Auto ) ;
437466 child. set_height ( DefLength :: Auto ) ;
438467 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. ) ) ;
440469 container. append_child ( convert_node_ref_to_ptr ( child) ) ;
441470
442471 root. layout (
@@ -457,7 +486,7 @@ pub fn aspect_ratio_with_max_width_constraint() {
457486 ) ;
458487
459488 assert_eq ! ( child. layout_position( ) . width, 80. ) ;
460- assert_eq ! ( child. layout_position( ) . height, 80 .) ;
489+ assert_eq ! ( child. layout_position( ) . height, 40 .) ;
461490 }
462491}
463492
@@ -516,7 +545,7 @@ pub fn aspect_ratio_block_size_with_box_sizing() {
516545 child. set_padding_left ( DefLength :: Points ( Len :: from_f32 ( 30. ) ) ) ;
517546 child. set_border_left ( DefLength :: Points ( Len :: from_f32 ( 20. ) ) ) ;
518547 child. set_box_sizing ( BoxSizing :: BorderBox ) ;
519- child. set_aspect_ratio ( Some ( 1 . / 1. ) ) ;
548+ child. set_aspect_ratio ( Some ( 2 . / 1. ) ) ;
520549 container. append_child ( convert_node_ref_to_ptr ( child) ) ;
521550
522551 let child2 = as_ref ( Node :: new_ptr ( ) ) ;
@@ -526,7 +555,7 @@ pub fn aspect_ratio_block_size_with_box_sizing() {
526555 child2. set_padding_left ( DefLength :: Points ( Len :: from_f32 ( 30. ) ) ) ;
527556 child2. set_border_left ( DefLength :: Points ( Len :: from_f32 ( 20. ) ) ) ;
528557 child2. set_box_sizing ( BoxSizing :: PaddingBox ) ;
529- child2. set_aspect_ratio ( Some ( 1 . / 1. ) ) ;
558+ child2. set_aspect_ratio ( Some ( 2 . / 1. ) ) ;
530559 container. append_child ( convert_node_ref_to_ptr ( child2) ) ;
531560
532561 let child3 = as_ref ( Node :: new_ptr ( ) ) ;
@@ -535,7 +564,7 @@ pub fn aspect_ratio_block_size_with_box_sizing() {
535564 child3. set_width ( DefLength :: Points ( Len :: from_f32 ( 50. ) ) ) ;
536565 child3. set_padding_left ( DefLength :: Points ( Len :: from_f32 ( 30. ) ) ) ;
537566 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. ) ) ;
539568 container. append_child ( convert_node_ref_to_ptr ( child3) ) ;
540569
541570 root. layout (
@@ -556,11 +585,11 @@ pub fn aspect_ratio_block_size_with_box_sizing() {
556585 ) ;
557586
558587 assert_eq ! ( child. layout_position( ) . width, 50. ) ;
559- assert_eq ! ( child. layout_position( ) . height, 50 .) ;
588+ assert_eq ! ( child. layout_position( ) . height, 25 .) ;
560589 assert_eq ! ( child2. layout_position( ) . width, 80. ) ;
561- assert_eq ! ( child2. layout_position( ) . height, 50 .) ;
590+ assert_eq ! ( child2. layout_position( ) . height, 25 .) ;
562591 assert_eq ! ( child3. layout_position( ) . width, 100. ) ;
563- assert_eq ! ( child3. layout_position( ) . height, 50 .) ;
592+ assert_eq ! ( child3. layout_position( ) . height, 25 .) ;
564593 }
565594}
566595
@@ -581,7 +610,7 @@ pub fn aspect_ratio_block_size_with_box_sizing_and_writing_mode() {
581610 child. set_padding_top ( DefLength :: Points ( Len :: from_f32 ( 30. ) ) ) ;
582611 child. set_border_top ( DefLength :: Points ( Len :: from_f32 ( 20. ) ) ) ;
583612 child. set_box_sizing ( BoxSizing :: BorderBox ) ;
584- child. set_aspect_ratio ( Some ( 1 . / 1. ) ) ;
613+ child. set_aspect_ratio ( Some ( 2 . / 1. ) ) ;
585614 container. append_child ( convert_node_ref_to_ptr ( child) ) ;
586615
587616 let child2 = as_ref ( Node :: new_ptr ( ) ) ;
@@ -591,7 +620,7 @@ pub fn aspect_ratio_block_size_with_box_sizing_and_writing_mode() {
591620 child2. set_padding_top ( DefLength :: Points ( Len :: from_f32 ( 30. ) ) ) ;
592621 child2. set_border_top ( DefLength :: Points ( Len :: from_f32 ( 20. ) ) ) ;
593622 child2. set_box_sizing ( BoxSizing :: PaddingBox ) ;
594- child2. set_aspect_ratio ( Some ( 1 . / 1. ) ) ;
623+ child2. set_aspect_ratio ( Some ( 2 . / 1. ) ) ;
595624 container. append_child ( convert_node_ref_to_ptr ( child2) ) ;
596625
597626 let child3 = as_ref ( Node :: new_ptr ( ) ) ;
@@ -600,7 +629,7 @@ pub fn aspect_ratio_block_size_with_box_sizing_and_writing_mode() {
600629 child3. set_height ( DefLength :: Points ( Len :: from_f32 ( 50. ) ) ) ;
601630 child3. set_padding_top ( DefLength :: Points ( Len :: from_f32 ( 30. ) ) ) ;
602631 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. ) ) ;
604633 container. append_child ( convert_node_ref_to_ptr ( child3) ) ;
605634
606635 root. layout (
@@ -620,11 +649,11 @@ pub fn aspect_ratio_block_size_with_box_sizing_and_writing_mode() {
620649 )
621650 ) ;
622651
623- assert_eq ! ( child. layout_position( ) . width, 50 .) ;
652+ assert_eq ! ( child. layout_position( ) . width, 100 .) ;
624653 assert_eq ! ( child. layout_position( ) . height, 50. ) ;
625- assert_eq ! ( child2. layout_position( ) . width, 50 .) ;
654+ assert_eq ! ( child2. layout_position( ) . width, 100 .) ;
626655 assert_eq ! ( child2. layout_position( ) . height, 80. ) ;
627- assert_eq ! ( child3. layout_position( ) . width, 50 .) ;
656+ assert_eq ! ( child3. layout_position( ) . width, 100 .) ;
628657 assert_eq ! ( child3. layout_position( ) . height, 100. ) ;
629658 }
630659}
0 commit comments