protected boolean canOptimizeStyle(TransCell containingCell) {
Element t = containingCell.getParent().getElement();
Element c = containingCell.getElement();
String rowspan = c.getAttributeValue("rowspan");
String colspan = c.getAttributeValue("colspan");
TransTableHelper h = TransTableHelper.getInstance();
// Note that these tests are in "expense" order so common, simple
// failures are detected before expending too much processing on
// the more complex checks
boolean canOptimize = (table.getAttributeValue("colwidths") == null) &&
(t.getAttributeValue("colwidths") == null) &&
(table.getAttributeValue("bgimage") == null) &&
(t.getAttributeValue("bgimage") == null) &&
(c.getAttributeValue("tabindex") == null) &&
(c.getAttributeValue("id") == null) &&
h.isZero(c.getAttributeValue("width")) &&
h.isZero(c.getAttributeValue("height")) &&
h.isZero(table.getAttributeValue("width")) &&
h.isZero(table.getAttributeValue("height")) &&
((rowspan == null) || "1".equals(rowspan)) &&
((colspan == null) || "1".equals(colspan)) &&
h.match(table, t, "rowgap") &&
h.match(table, t, "colgap") &&
h.match(table, t, "update") &&
!h.tableContains(table, getFactory(), "onevent", false) &&
!h.tableContains(t, getFactory(), "onevent", false) &&
!h.tableHasId(table, getFactory(), false);
if (canOptimize) {
PropertyValues outerCellProps = null;
PropertyValues tableProps = null;
StyleValue outerCellWidth = null;
StyleValue outerCellHeight = null;
StyleValue tableWidth = null;
StyleValue tableHeight = null;
if (c.getStyles() != null) {
outerCellProps = c.getStyles().getPropertyValues();
outerCellWidth = outerCellProps.getComputedValue(
StylePropertyDetails.WIDTH);
outerCellHeight = outerCellProps.getComputedValue(
StylePropertyDetails.HEIGHT);
}
if (table.getStyles() != null) {
tableProps = table.getStyles().getPropertyValues();
tableWidth = tableProps.getComputedValue(
StylePropertyDetails.WIDTH);
tableHeight = tableProps.getComputedValue(
StylePropertyDetails.HEIGHT);
}
canOptimize = canOptimize &&
(tableProps == null ||
(tableWidth == null ||
h.isStyleValueZero(tableWidth)) &&
(tableHeight == null || h.isStyleValueZero(tableHeight))) &&
(outerCellProps == null ||
(outerCellWidth == null ||
h.isStyleValueZero(outerCellWidth)) &&
(outerCellHeight == null ||
h.isStyleValueZero(outerCellHeight)));
}
return canOptimize;
}