123 points · by yxlx · 10y ago · 18 comments
CSS parsing should be ok, but layout computation is hard, especially with all the latest specs. The graph presented in the article will be the size of a postage stamp on an aircraft carrier deck.
Take a look at the Cassowary constraint solver, btw: http://overconstrained.io/
> I'm writing them all by myself, still full of energy.
I wish the author the best of luck.
I've used this approach for css-layout[1] and in 2 weeks I got enough implemented to support most use cases we've needed to build mobile apps.
Also, Cassowary won't really help you there. It's going to take a much bigger effort to translate CSS into constraints than just reimplementing the steps themselves.
flex-box is a mostly self-contained and powerful spec (if i understand correctly).
however, when you don't need to account for floats, relative layout, mixed box-sizing, negative margins, complex overflow conditions and interaction with a ton of older specs, you vastly simplify the problem space for yourself.
it makes perfect sense for a modern system but is quite far from a general impl that can compute layout from html+css unconditionally. the article starts with:
"Once I got an X idea, but its implementation required a calculated DOM with all its styles and goodies"
so the goal is not "the most useful subset". flexbox is currently the least-used (& least supported) layout, so for the author's purposes which sounds like scraping existing markup would not help very much.
Just "my" two cents.