230 likes | 319 Views
Client/browser productivity language. Ras Bodik, Thibaud Hottelier , James Ide , and Doug Kimelman (IBM). Today…. Slow on handhelds. Clumsy everywhere. About 10 times slower than laptop [ Meyerovich et al.]. Summary. The status-quo and its flaws Bi-directional Constraints
E N D
Client/browser productivitylanguage Ras Bodik, Thibaud Hottelier, James Ide, and Doug Kimelman(IBM)
Today… Slow on handhelds Clumsy everywhere About 10 times slower than laptop [Meyerovich et al.]
Summary • The status-quo and its flaws • Bi-directional Constraints • Our language • Compilation using synthesis and attribute grammar.
Browser 101 DOM Tree CSS provides primitives: • Designers compose them. • Layout solved in ~5 passes. Scripting Layout Render
CSS is too restrictive Aspect ratio Example • In general, it is not possible to use both height and width in the same constraint. • Rationale: height=F(width)
Free The Constraints Let the designer express declaratively his intent via constraints. box.width = box.height Bi-directional constraints: • Conciseness • height=F(width) or width=F(height), as you want.
Bi-directional Constraints Redundancy in GUI: Multiple knobs/indicator for a single variable. Thus, many ways to update it. Scroll-Box R1(height, doc_height, slider_size) R2(doc_pos, slider_pos, height, doc_height) height With bi-directional constraints: ↑ doc_pos ↓ doc_height slider_size slider_pos
Issues With Today’s Stack DOM Tree (Some) Issues: • Limited expressiveness. → Hence, hacks, and clumsy workarounds. → Hence, not modular any more. • Not fast enough. Scripting Layout Render
Related Work On Solving • What would you do? • Use a generic solver • Cassowary [Badros]: Analyze documents online and figures out layout. • For performance, we want • Reduce runtime work by doing offline pre-computation. • Specialized solver.
Raising The Level of Abstraction • A single set of primitive will not suit all uses • Programmers define/build primitives • Scroll-box, Side-bar, Menu • Designers express layout using those. Side-Bar Scroll-box Image
In a Nutshell CSS
Summary & Challenges Ahead Our proposed solution is • Bi-directional constraints exposed to the designer. • Translated into directional constraints for fast solving. • Primitives are up to the user. We want all layout systems to be • Fast to solve. • Always well defined. Efficient solver for any kind of layout systems. • Compilation to attribute grammars • With synthesis of local evaluation rules.
Definitions A layout system is • A set of primitives (modules). • A grammar describing valid compositions. We get extra expressiveness. We get modularity. • Primitives can be reused across layout systems.
3-Tier Architecture Programmer Designer User/Client Instantiate P&G Render Tree Prtv: ScrollBox ScrollBox P&G Tree VBox Text VBox G :== ScrollBox | A A :== Vbox | Hbox | A| B B :== Image | Text Text Text Runtime inputs Solver Safety Check: Forall Tree in G, Forall Input in Tree, Tree(input) is Satisfiable And the solution can be found with propagation only.
Solving Generic Solver Modular solver P1 P2 G :== … Document: Static reasoning Dependencies Analysis Dependencies Prop Fun Calculation AG compiler Prop Fun Prop Fun Browser: Tree traversals Solution Solution
Remember… We have two things to do: • Produce a solver • Layout always well-defined (safety check) Let me do the safety check first…
Comfusy [Kuncak et al.] Comfusy: Complete Functional Synthesis • Find all propagation functions • Generate code for them Summary of Foo-Box Foo-Box R(x,y,z) Comfusy x y z X Y X(y,z)= z-y Y(z,x)=z-x Z(x,y)=x+y R(x,y,z) :== x=y+z Comfusy Z
Safety Check Reduction to reachability on hyper-graphs • Each primitive is a (non-)terminal. • Let G=(P1, P2, R, S) in Chomsky normal form. Build a hyper-graph representing the family of tree in G. • Primitives are summarized to hyper-graphs. • Connect them according the grammar. • Recursion translates into cycles. • Only consider propagation -> no search needed when solving Most interesting case is alternative in G. Let’s do that one.
Safety Check Again Compose the hyper graphs generated by Comfusy as follows: Let A → B, A → C, then we check reachability for: A R1(x,y) C R3(x,y) B R2(x,y) c a d b x y
Remember… We have two things to do: • Produce a solver • Layout always well-defined (safety check) The solver now...
Compilation to Attribute Grammar • We already to reachability on hyper-graphs for the safety check. • Extract tree traversals from that • Comfusy gives us code for each propagation step. • Schedule them using an AG evaluator. • Our group is working on parallel AG evaluator too.[Meyerovich et al.]
Future Work • Design-time parameters • Reactive semantics • Expressiveness/Speed Trade-off • Can the tree traversal of the solver depend on • Design-time parameters • Run-time inputs