     ] dip '[ _ + layout-word ] 3each ;
 
 M: paragraph layout*
-    wrap-paragraph dup line-y-coordinates
-    [ layout-line ] 2each ;
+    wrapped>> dup line-y-coordinates [ layout-line ] 2each ;
 
 M: paragraph baseline
-    wrap-paragraph [ f ] [
-        first words>>
-        [ key>> ] map
-        dup [ pref-dim ] map
-        measure-metrics drop
-    ] if-empty ;
+    wrapped>> [ f ] [ first baseline>> ] if-empty ;
 
 M: paragraph cap-height pack-cap-height ;
-    
+
 PRIVATE>

: gadget>word ( gadget -- word )
    [ ] [ pref-dim first ] [ word-break? ] tri <word> ;

TUPLE: line words height ;

: <line> ( words -- line )
    dup [ key>> ] map dup pref-dims measure-height line boa ;

: wrap-paragraph ( paragraph -- wrapped-paragraph )
    [ children>> [ gadget>word ] map ] [ margin>> ] bi
    dup wrap-words [ <line> ] map ;

: line-width ( wrapped-line -- n )
    [ break?>> ] trim-tail-slice [ width>> ] map-sum ;

INSTANCE: word-break-gadget word-break

! A gadget that arranges its children in a word-wrap style.
TUPLE: paragraph < gadget margin wrapped ;

: <paragraph> ( margin -- gadget )
    paragraph new
