[css-grid] Rewrite the auto-placement algorithm to be clearer, and fix the previously-found issues in it.

--HG--
extra : rebase_source : 401b59d179fc8f82f91cccee867e8d4e326f4a71