If halign=fill, force adjustment to height-for-width. If valign=fill, force adjustment to width-for-height. Otherwise look at request mode. This way we don't try to adapt the filled dimension and only adjust the one that is not set to fill.
This could lead to the wrong values being passed and computing invalid sizes which would then lead to very unhappy code. Test included.