This protects the TableView from borking on some more invalid HTML, like
the one on GNU Classpath's website.
2006-12-06 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/text/html/TableView.java
(RowView.layoutMajorAxis): Check column index for invalid value.
(updateGrid): Check column index for invalid value.
/Roman
Index: javax/swing/text/html/TableView.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/html/TableView.java,v
retrieving revision 1.14
diff -u -1 -5 -r1.14 TableView.java
--- javax/swing/text/html/TableView.java 6 Dec 2006 19:36:08 -0000 1.14
+++ javax/swing/text/html/TableView.java 6 Dec 2006 19:49:53 -0000
@@ -171,33 +171,34 @@
}
}
}
}
}
/**
* Lays out the columns in this row.
*/
protected void layoutMajorAxis(int targetSpan, int axis, int[] offsets,
int spans[])
{
updateGrid();
int numCols = offsets.length;
int realColumn = 0;
+ int colCount = getViewCount();
for (int i = 0; i < numColumns;)
{
- if (! overlap[i])
+ if (! overlap[i] && realColumn < colCount)
{
View v = getView(realColumn);
if (v instanceof CellView)
{
CellView cv = (CellView) v;
offsets[realColumn] = columnOffsets[i];
spans[realColumn] = 0;
for (int j = 0; j < cv.colSpan; j++, i++)
{
spans[realColumn] += columnSpans[i];
if (j < cv.colSpan - 1)
spans[realColumn] += cellSpacing;
}
}
realColumn++;
@@ -773,61 +774,66 @@
}
maxColumns = Math.max(numCols, maxColumns);
}
numColumns = maxColumns;
columnWidths = new Length[maxColumns];
int[] rowSpans = new int[maxColumns];
for (int r = 0; r < numRows; r++)
{
View view = getView(r);
if (view instanceof RowView)
{
RowView rowView = (RowView) view;
rowView.rowIndex = r;
rowView.overlap = new boolean[maxColumns];
int colIndex = 0;
+ int colCount = rowView.getViewCount();
for (int c = 0; c < maxColumns;)
{
if (rowSpans[c] > 0)
{
rowSpans[c]--;
rowView.overlap[c] = true;
c++;
}
- else
+ else if (colIndex < colCount)
{
View v = rowView.getView(colIndex);
colIndex++;
if (v instanceof CellView)
{
CellView cv = (CellView) v;
Object o =
cv.getAttributes().getAttribute(CSS.Attribute.WIDTH);
if (o != null && columnWidths[c] == null
&& o instanceof Length)
{
columnWidths[c]= (Length) o;
columnWidths[c].setFontBases(emBase, exBase);
}
int rs = cv.rowSpan - 1;
for (int col = cv.colSpan - 1; col >= 0; col--)
{
rowSpans[c] = rs;
c++;
}
}
}
+ else
+ {
+ c++;
+ }
}
}
}
columnRequirements = new SizeRequirements[maxColumns];
for (int i = 0; i < maxColumns; i++)
columnRequirements[i] = new SizeRequirements();
columnOffsets = new int[maxColumns];
columnSpans = new int[maxColumns];
gridValid = true;
}
}
/**
* Overridden to restrict the table width to the preferred size.