1010// - Sun Tsu,
1111// "The Art of War"
1212
13- using System ;
14- using System . Collections . Generic ;
15- using System . ComponentModel . DataAnnotations ;
16- using System . Linq ;
17- using System . Threading . Tasks ;
1813using PeachPDF . Html . Adapters ;
1914using PeachPDF . Html . Adapters . Entities ;
2015using PeachPDF . Html . Core . Entities ;
2116using PeachPDF . Html . Core . Parse ;
2217using PeachPDF . Html . Core . Utils ;
18+ using System ;
19+ using System . Collections . Generic ;
20+ using System . Linq ;
21+ using System . Threading . Tasks ;
2322
2423namespace PeachPDF . Html . Core . Dom
2524{
@@ -28,18 +27,11 @@ namespace PeachPDF.Html.Core.Dom
2827 /// </summary>
2928 internal sealed class CssLayoutEngineTable
3029 {
31- #region Fields and Consts
32-
3330 /// <summary>
3431 /// the main box of the table
3532 /// </summary>
3633 private readonly CssBox _tableBox ;
3734
38- /// <summary>
39- ///
40- /// </summary>
41- private CssBox ? _caption ;
42-
4335 private CssBox ? _headerBox ;
4436
4537 private CssBox ? _footerBox ;
@@ -67,9 +59,6 @@ internal sealed class CssLayoutEngineTable
6759
6860 private double [ ] ? _columnMinWidths ;
6961
70- #endregion
71-
72-
7362 /// <summary>
7463 /// Init.
7564 /// </summary>
@@ -194,7 +183,6 @@ private void AssignBoxKinds()
194183 switch ( box . Display )
195184 {
196185 case CssConstants . TableCaption :
197- _caption = box ;
198186 break ;
199187 case CssConstants . TableRow :
200188 _bodyRows . Add ( box ) ;
@@ -626,7 +614,7 @@ private async ValueTask LayoutCells(RGraphics g)
626614 var maxBottom = 0d ;
627615 var currentRow = 0 ;
628616
629- Dictionary < int , List < CssBox > > rowSpannedBoxes = new Dictionary < int , List < CssBox > > ( ) ;
617+ Dictionary < int , List < CssBox > > rowSpannedBoxes = new ( ) ;
630618
631619 for ( var i = 0 ; i < _allRows . Count ; i ++ )
632620 {
@@ -705,7 +693,7 @@ private async ValueTask LayoutCells(RGraphics g)
705693 }
706694
707695 // If one cell crosses page borders then don't need to check other cells in the row
708- if ( _tableBox . PageBreakInside != CssConstants . Avoid ) continue ;
696+ if ( _tableBox . PageBreakInside is CssConstants . Avoid ) continue ;
709697
710698 breakPage = cell . BreakPage ( ) ;
711699 if ( ! breakPage ) continue ;
@@ -823,13 +811,10 @@ private static int GetRowSpan(CssBox b)
823811 /// <param name="g">Device to use</param>
824812 private static async ValueTask MeasureWords ( CssBox box , RGraphics g )
825813 {
826- if ( box != null )
814+ foreach ( var childBox in box . Boxes )
827815 {
828- foreach ( var childBox in box . Boxes )
829- {
830- await childBox . MeasureWordsSize ( g ) ;
831- await MeasureWords ( childBox , g ) ;
832- }
816+ await childBox . MeasureWordsSize ( g ) ;
817+ await MeasureWords ( childBox , g ) ;
833818 }
834819 }
835820
@@ -840,7 +825,7 @@ private static async ValueTask MeasureWords(CssBox box, RGraphics g)
840825 /// <returns></returns>
841826 private bool CanReduceWidth ( )
842827 {
843- for ( int i = 0 ; i < _columnWidths ! . Length ; i ++ )
828+ for ( var i = 0 ; i < _columnWidths ! . Length ; i ++ )
844829 {
845830 if ( CanReduceWidth ( i ) )
846831 {
@@ -963,7 +948,7 @@ private double GetWidthSum()
963948 {
964949 double f = 0f ;
965950
966- foreach ( double t in _columnWidths ! )
951+ foreach ( var t in _columnWidths ! )
967952 {
968953 if ( double . IsNaN ( t ) )
969954 throw new Exception ( "CssTable Algorithm error: There's a NaN in column widths" ) ;
@@ -986,7 +971,7 @@ private double GetWidthSum()
986971 /// <param name="b"></param>
987972 private static int GetSpan ( CssBox b )
988973 {
989- double f = CssValueParser . ParseNumber ( b . GetAttribute ( "span" ) , 1 ) ;
974+ var f = CssValueParser . ParseNumber ( b . GetAttribute ( "span" ) , 1 ) ;
990975
991976 return Math . Max ( 1 , Convert . ToInt32 ( f ) ) ;
992977 }
0 commit comments