Specifying CSS layout with reference attribute grammars
Scott Buckley, Anthony M. Sloane, Matthew Roberts · 2016
Layout for web documents is a complex process described by the lengthy prose Cascading Style Sheets (CSS) specification. It is difficult to ensure that implementations match this specification. We show how an implementation can more closely match the specification by using attribute grammars to define layout computations. Particularly, we show how high-level patterns encode the terminology of the specification, discriminating between elements using the same language as in the specification. We also present a new method of injecting artificial structure into an existing tree using reference attribute grammars. The result is a high-level executable specification for CSS layout that can form the basis for a full declarative implementation.