@@ -216,7 +216,7 @@ float[] autoLayout(float[] minWidths, float[] maxWidths) {
216
216
//TODO add colgroup information.
217
217
for (int i = 0 ; i < numberOfColumns ; i ++) {
218
218
UnitValue colWidth = getTable ().getColumnWidth (i );
219
- if (colWidth .getValue () >= 0 ) {
219
+ if (colWidth != null && colWidth .getValue () > 0 ) {
220
220
if (colWidth .isPercentValue ()) {
221
221
if (!widths [i ].isPercent ) {
222
222
if (widths [i ].isFixed && widths [i ].width > widths [i ].min ) {
@@ -341,7 +341,7 @@ float[] autoLayout(float[] minWidths, float[] maxWidths) {
341
341
//sum of non fixed non percent columns.
342
342
for (int i = 0 ; i < numberOfColumns ; i ++) {
343
343
if (widths [i ].isPercent ) {
344
- if (tableWidth * widths [i ].width >= widths [i ].min ) {
344
+ if (tableWidth * widths [i ].width / 100 >= widths [i ].min ) {
345
345
widths [i ].finalWidth = tableWidth * widths [i ].width / 100 ;
346
346
totalPercent += widths [i ].finalWidth ;
347
347
} else {
@@ -451,10 +451,9 @@ float[] fixedLayout() {
451
451
UnitValue cellWidth = getCellWidth (cell , true );
452
452
if (cellWidth != null ) {
453
453
assert cellWidth .getValue () >= 0 ;
454
- float width = cellWidth .getValue ();
455
- if (cellWidth .isPercentValue ()) {
456
- width = tableWidth * width / 100 ;
457
- }
454
+ float width = cellWidth .isPercentValue ()
455
+ ? tableWidth * cellWidth .getValue () / 100
456
+ : cellWidth .getValue ();
458
457
int colspan = cell .getModelElement ().getColspan ();
459
458
for (int j = 0 ; j < colspan ; j ++) {
460
459
columnWidths [i + j ] = width / colspan ;
@@ -702,11 +701,16 @@ public String toString() {
702
701
}
703
702
}
704
703
704
+ static private final UnitValue ZeroWidth = UnitValue .createPointValue (0 );
705
+
705
706
//TODO DEVSIX-1174, box-sizing property
706
707
UnitValue getCellWidth (CellRenderer cell , boolean zeroIsValid ) {
707
708
UnitValue widthValue = cell .<UnitValue >getProperty (Property .WIDTH );
708
709
if (widthValue == null || widthValue .getValue () < 0 ) return null ;
709
- if (!zeroIsValid && widthValue .getValue () == 0 ) return null ;
710
+ //zero has special meaning in fixed layout, we shall not add padding to zero value
711
+ if (widthValue .getValue () == 0 ) {
712
+ return zeroIsValid ? ZeroWidth : null ;
713
+ }
710
714
if (widthValue == null || widthValue .isPercentValue ()) {
711
715
return widthValue ;
712
716
} else {
0 commit comments