Re: [csswg-drafts] [css-text-4] Allow for paragraph-level line breaking

I'm currently experimenting with doing paragraph-level line-breaking in userland in the [tex-linebreak](https://github.com/robertknight/tex-linebreak) package. There is a [bookmarklet](https://github.com/robertknight/tex-linebreak#try-it-out) that you can use to try it out on existing content.

I'm using the Knuth-Plass algorithm with only some small modifications. The main issues and sources of overhead I've encountered with a user-space solution are:

- The difficulty of taking into account floats when determining line widths, especially since a float _outside_ a paragraph can affect the line widths of content _within_ the paragraph.
- The overhead of measuring text, depending on the browser. I'm using Canvas APIs. Chrome appears to be much faster than Firefox here (~40ms vs ~400ms for every `<p>` in the Wikipedia article on _London_ ). In either case, the library is repeating a lot of work that the browser has already done.
- DOM manipulation overhead for doing justification via inserted linebreak and span tags in stable Chrome. The overhead has disappeared entirely in Chrome Canary, so more research needed here.
- Insertion of DOM elements to alter the appearance of rendered text can change which selectors match. This mostly affects sites with poorly written CSS.

What I'm planning to do next is to take a look at the CSS Layout API to understand whether it is possible to use that to reduce the duplication of work.

-- 
GitHub Notification of comment by robertknight
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/672#issuecomment-385355999 using your GitHub account

Received on Monday, 30 April 2018 09:57:47 UTC