@@ -171,10 +171,19 @@ where
171171 // | | (on successful return) | +_4 |
172172 // +-+----------------------------------+------------+
173173
174- write ! (
175- w,
176- r#"<table border="1" cellborder="1" cellspacing="0" cellpadding="3" sides="rb">"# ,
177- ) ?;
174+ // N.B., Some attributes (`align`, `balign`) are repeated on parent elements and their
175+ // children. This is because `xdot` seemed to have a hard time correctly propagating
176+ // attributes. Make sure to test the output before trying to remove the redundancy.
177+ // Notably, `align` was found to have no effect when applied only to <table>.
178+
179+ let table_fmt = concat ! (
180+ " border=\" 1\" " ,
181+ " cellborder=\" 1\" " ,
182+ " cellspacing=\" 0\" " ,
183+ " cellpadding=\" 3\" " ,
184+ " sides=\" rb\" " ,
185+ ) ;
186+ write ! ( w, r#"<table{fmt}>"# , fmt = table_fmt) ?;
178187
179188 // A + B: Block header
180189 if self . state_formatter . column_names ( ) . is_empty ( ) {
@@ -186,7 +195,7 @@ where
186195 // C: Entry state
187196 self . bg = Background :: Light ;
188197 self . results . seek_to_block_start ( block) ;
189- self . write_row_with_full_state ( w, "" , "(on_entry )" ) ?;
198+ self . write_row_with_full_state ( w, "" , "(on entry )" ) ?;
190199
191200 // D: Statement transfer functions
192201 for ( i, statement) in body[ block] . statements . iter ( ) . enumerate ( ) {
@@ -212,7 +221,7 @@ where
212221 self . write_row ( w, "" , "(on successful return)" , |this, w, fmt| {
213222 write ! (
214223 w,
215- r#"<td colspan="{colspan}" {fmt} align="left">"# ,
224+ r#"<td balign="left" colspan="{colspan}" {fmt} align="left">"# ,
216225 colspan = num_state_columns,
217226 fmt = fmt,
218227 ) ?;
@@ -311,7 +320,9 @@ where
311320 f : impl FnOnce ( & mut Self , & mut W , & str ) -> io:: Result < ( ) > ,
312321 ) -> io:: Result < ( ) > {
313322 let bg = self . toggle_background ( ) ;
314- let fmt = format ! ( "sides=\" tl\" {}" , bg. attr( ) ) ;
323+ let valign = if mir. starts_with ( "(on " ) && mir != "(on entry)" { "bottom" } else { "top" } ;
324+
325+ let fmt = format ! ( "valign=\" {}\" sides=\" tl\" {}" , valign, bg. attr( ) ) ;
315326
316327 write ! (
317328 w,
@@ -345,7 +356,7 @@ where
345356 colspan = this. num_state_columns( ) ,
346357 fmt = fmt,
347358 ) ?;
348- pretty_print_state_elems ( w, analysis, state. iter ( ) , "," , LIMIT_40_ALIGN_1 ) ?;
359+ pretty_print_state_elems ( w, analysis, state. iter ( ) , ", " , LIMIT_30_ALIGN_1 ) ?;
349360 write ! ( w, "}}</td>" )
350361 } )
351362 }
@@ -416,7 +427,7 @@ where
416427 }
417428
418429 self . prev_loc = location;
419- write ! ( w, r#"<td {fmt} align="left">"# , fmt = fmt) ?;
430+ write ! ( w, r#"<td {fmt} balign="left" align="left">"# , fmt = fmt) ?;
420431 results. seek_after ( location) ;
421432 let curr_state = results. get ( ) ;
422433 write_diff ( & mut w, results. analysis ( ) , & self . prev_state , curr_state) ?;
@@ -524,12 +535,12 @@ where
524535 for set in & [ & block_trans. gen , & block_trans. kill ] {
525536 write ! (
526537 w,
527- r#"<td {fmt} rowspan="{rowspan}" align="center ">"# ,
538+ r#"<td {fmt} rowspan="{rowspan}" balign="left" align="left ">"# ,
528539 fmt = fmt,
529540 rowspan = rowspan
530541 ) ?;
531542
532- pretty_print_state_elems ( & mut w, results. analysis ( ) , set. iter ( ) , " \n " , None ) ?;
543+ pretty_print_state_elems ( & mut w, results. analysis ( ) , set. iter ( ) , BR_LEFT , None ) ?;
533544 write ! ( w, "</td>" ) ?;
534545 }
535546
@@ -561,25 +572,28 @@ fn write_diff<A: Analysis<'tcx>>(
561572
562573 if !set. is_empty ( ) {
563574 write ! ( w, r#"<font color="darkgreen">+"# ) ?;
564- pretty_print_state_elems ( w, analysis, set. iter ( ) , "," , LIMIT_40_ALIGN_1 ) ?;
575+ pretty_print_state_elems ( w, analysis, set. iter ( ) , ", " , LIMIT_30_ALIGN_1 ) ?;
565576 write ! ( w, r#"</font>"# ) ?;
566577 }
567578
568579 if !set. is_empty ( ) && !clear. is_empty ( ) {
569- write ! ( w, "<br/>" ) ?;
580+ write ! ( w, "{}" , BR_LEFT ) ?;
570581 }
571582
572583 if !clear. is_empty ( ) {
573584 write ! ( w, r#"<font color="red">-"# ) ?;
574- pretty_print_state_elems ( w, analysis, clear. iter ( ) , "," , LIMIT_40_ALIGN_1 ) ?;
585+ pretty_print_state_elems ( w, analysis, clear. iter ( ) , ", " , LIMIT_30_ALIGN_1 ) ?;
575586 write ! ( w, r#"</font>"# ) ?;
576587 }
577588
578589 Ok ( ( ) )
579590}
580591
592+ const BR_LEFT : & ' static str = r#"<br align="left"/>"# ;
593+ const BR_LEFT_SPACE : & ' static str = r#"<br align="left"/> "# ;
594+
581595/// Line break policy that breaks at 40 characters and starts the next line with a single space.
582- const LIMIT_40_ALIGN_1 : Option < LineBreak > = Some ( LineBreak { sequence : "<br/> " , limit : 40 } ) ;
596+ const LIMIT_30_ALIGN_1 : Option < LineBreak > = Some ( LineBreak { sequence : BR_LEFT_SPACE , limit : 30 } ) ;
583597
584598struct LineBreak {
585599 sequence : & ' static str ,
0 commit comments