#94476Unify autoSizeMax logic
Description
The same logic for getting the size is implemented 5 times with sometimes a slightly different approach.
The same logic for getting the size is implemented 5 times with sometimes a slightly different approach.