@ARTICLE{pldi23-medea, title = "{Conflict-Driven} Synthesis for Layout Engines", author = "Liu, Junrui and Chen, Yanju and Atkinson, Eric and Feng, Yu and Bodik, Rastislav", abstract = "Modern web browsers rely on layout engines to convert HTML documents to layout trees that specify color, size, and position. However, existing layout engines are notoriously difficult to maintain because of the complexity of web standards. This is especially true for incremental layout engines, which are designed to improve performance by updating only the parts of the layout tree that need to be changed. In this paper, we propose Medea, a new framework for automatically generating incremental layout engines. Medea separates the specification of the layout engine from its incremental implementation, and guarantees correctness through layout engine synthesis. The synthesis is driven by a new iterative algorithm based on detecting conflicts that prevent optimality of the incremental algorithm. We evaluated Medea on a fragment of HTML layout that includes challenging features such as margin collapse, floating layout, and absolute positioning. Medea successfully synthesized an incremental layout engine for this fragment. The synthesized layout engine is both correct and efficient. In particular, we demonstrated that it avoids real-world bugs that have been reported in the layout engines of Chrome, Firefox, and Safari. The incremental layout engine synthesized by Medea is up to 1.82$\times$ faster than a naive incremental baseline. We also demonstrated that our conflict-driven algorithm produces engines that are 2.74$\times$ faster than a baseline without conflict analysis.", journal = "Proc. ACM Program. Lang.", publisher = "Association for Computing Machinery", volume = 7, number = "PLDI", month = jun, year = 2023, address = "New York, NY, USA", keywords = "program synthesis" }