Skip to content

Commit

Permalink
Fixes Sub6Resources#687 with a rowspan issue
Browse files Browse the repository at this point in the history
Also prevents crashes on edge cases where the rowspan or colspans are inconsistent/wrong
  • Loading branch information
erickok committed May 31, 2021
1 parent 25df803 commit 71138ac
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/src/layout_element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,14 @@ class TableLayoutElement extends LayoutElement {

// Place the cells in the rows/columns
final cells = <GridPlacement>[];
final columnRowOffset = List.generate(columnMax + 1, (_) => 0);
final columnRowOffset = List.generate(columnMax, (_) => 0);
int rowi = 0;
for (var row in rows) {
int columni = 0;
for (var child in row.children) {
if (columni > columnMax - 1 ) {
break;
}
while (columnRowOffset[columni] > 0) {
columnRowOffset[columni] = columnRowOffset[columni] - 1;
columni++;
Expand Down Expand Up @@ -131,14 +134,18 @@ class TableLayoutElement extends LayoutElement {
),
),
columnStart: columni,
columnSpan: child.colspan,
columnSpan: min(child.colspan, columnMax - columni),
rowStart: rowi,
rowSpan: child.rowspan,
rowSpan: min(child.rowspan, rows.length - rowi),
));
columnRowOffset[columni] = child.rowspan - 1;
columni += child.colspan;
}
}
while (columni < columnRowOffset.length) {
columnRowOffset[columni] = columnRowOffset[columni] - 1;
columni++;
}
rowi++;
}

Expand Down

0 comments on commit 71138ac

Please sign in to comment.