gss / engine

GSS engine
http://gss.github.io
MIT License
2.87k stars 103 forks source link

iOS preferredMaxLayoutWidth #191

Open fabb opened 9 years ago

fabb commented 9 years ago

In AutoLayout on iOS there is an issue with ambigous intrinsic size for multiline text. There is an ugly workaround using preferredMaxLayoutWidth which lives beside the constraint solver, as it cannot deal with this kind of problem. How does GSS tackle this?

Inviz commented 9 years ago

For GSS multiline text is the same as single line. We remeasure intrinsic values and update the system until we find that system is solved. In complex situations it may take 2-3 reflows to get it right (a lot of nested centering).

GSS (ab)uses the fact that absolutely positioned multiline elements collapse their width. Indeed there's certain non-determenism in undersconstrained systems, e.g. when both height and width is intrinsic. We try to avoid it by leaving one axis constrained, while another is left intrinsic. Due to how CSS text flow works, in 99% we constrain width and measure height.