@@ -457,6 +457,11 @@ impl TextSpan {
457457
458458 data. set_text_format ( tf) ;
459459
460+ // [KJ] Looks like you cannot get any value other than display:block
461+ // when parsing HTML. This property is being applied during parsing
462+ // and not styling, so that kinda makes sense... I guess?
463+ data. display = TextDisplay :: Block ;
464+
460465 data
461466 }
462467
@@ -672,6 +677,9 @@ impl FormatSpans {
672677 let mut p_open = false ;
673678 let mut last_closed_font: Option < TextSpanFont > = None ;
674679
680+ // For applying display: block at the end of the tag
681+ let mut display_block = false ;
682+
675683 let mut reader = Reader :: from_reader ( & raw_bytes[ ..] ) ;
676684 let reader_config = reader. config_mut ( ) ;
677685 reader_config. expand_empty_elements = true ;
@@ -919,10 +927,18 @@ impl FormatSpans {
919927 }
920928 }
921929 tag => {
922- // TODO Add 'display' style support, Flash adds a newline on 'display: block'
930+ // Flash Player applies "display" only when the style is defined.
931+ // For unstyled tags, display: inline is assumed.
932+ format. display = None ;
933+
923934 format = apply_style ( style_sheet, format, WStr :: from_units ( tag) ) ;
935+
936+ if let Some ( TextDisplay :: Block | TextDisplay :: None ) = format. display {
937+ display_block = true ;
938+ }
924939 }
925940 }
941+
926942 opened_starts. push ( opened_buffer. len ( ) ) ;
927943 opened_buffer. extend ( tag_name) ;
928944 format_stack. push ( format) ;
@@ -931,6 +947,10 @@ impl FormatSpans {
931947 let e = decode_to_wstr ( & e. into_inner ( ) ) ;
932948 let e = process_html_entity ( & e) . unwrap_or ( e) ;
933949 let format = format_stack. last ( ) . unwrap ( ) . clone ( ) ;
950+ if let Some ( TextDisplay :: None ) = format. display {
951+ break ' text;
952+ }
953+
934954 if swf_version <= 7 && e. trim ( ) . is_empty ( ) {
935955 // SWFs version 6,7 ignore whitespace-only text.
936956 // But whitespace is preserved when there
@@ -960,6 +980,13 @@ impl FormatSpans {
960980 None => continue ,
961981 }
962982
983+ if display_block {
984+ display_block = false ;
985+ let format = format_stack. last ( ) . unwrap ( ) . clone ( ) ;
986+ text. push_str ( WStr :: from_units ( b"\r " ) ) ;
987+ spans. push ( TextSpan :: with_length_and_format ( 1 , & format) ) ;
988+ }
989+
963990 match tag_name {
964991 b"br" | b"sbr" => {
965992 // Skip pop from `format_stack`.
0 commit comments