CSS shape-outside only works with floats and can't handle arbitrary draggable obstacles. Here, every single line has a different max-width, computed from the shape geometry. layoutNextLine() takes a per-line width and returns the exact text that fits. The reflow happens in pure JS arithmetic — no DOM measurement, no layout thrashing. Try doing this at 60fps with getBoundingClientRect.