MaikJaek / flying-saucer

Automatically exported from code.google.com/p/flying-saucer
0 stars 0 forks source link

ClassCastException when absolute positioning a table css #162

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Found an interesting error today.

Given the following input:

<html>
<head>
  <title>HELLO</title>
  <style type="text/css">
  #test {position:absolute; right:70px;}  
</style>
</head>
<body>
<table>
<tr>
<th>hello</th>
<td id='test'>hello</td>
</tr>
</table>
</body>
</html>

The render fails with this exception:

org.xhtmlrenderer.render.AnonymousBlockBox cannot be cast to 
org.xhtmlrenderer.newtable.TableCellBox
java.lang.ClassCastException: org.xhtmlrenderer.render.AnonymousBlockBox cannot 
be cast to org.xhtmlrenderer.newtable.TableCellBox
    at org.xhtmlrenderer.newtable.TableSectionBox.recalcCells(TableSectionBox.java:83)
    at org.xhtmlrenderer.newtable.TableBox.recalcSections(TableBox.java:198)
    at org.xhtmlrenderer.newtable.TableBox.calcMinMaxWidth(TableBox.java:153)
    at org.xhtmlrenderer.newtable.TableBox.layout(TableBox.java:215)
    at org.xhtmlrenderer.layout.BlockBoxing.layoutBlockChild0(BlockBoxing.java:293)
    at org.xhtmlrenderer.layout.BlockBoxing.layoutBlockChild(BlockBoxing.java:271)
    at org.xhtmlrenderer.layout.BlockBoxing.layoutContent(BlockBoxing.java:89)
    at org.xhtmlrenderer.render.BlockBox.layoutChildren(BlockBox.java:922)
    at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:802)
    at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:732)
    at org.xhtmlrenderer.layout.BlockBoxing.layoutBlockChild0(BlockBoxing.java:293)
    at org.xhtmlrenderer.layout.BlockBoxing.layoutBlockChild(BlockBoxing.java:271)
    at org.xhtmlrenderer.layout.BlockBoxing.layoutContent(BlockBoxing.java:89)
    at org.xhtmlrenderer.render.BlockBox.layoutChildren(BlockBox.java:922)
    at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:802)
    at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:732)
    at org.xhtmlrenderer.pdf.ITextRenderer.layout(ITextRenderer.java:209)

If I remove the absolute positioning, it renders fine.  Is this a bug or 
expected behaviour given that absolute positioning a table cell is rather 
strange (but what one of our users wants to do!).

Original issue reported on code.google.com by ohea...@gmail.com on 20 Jul 2011 at 9:15

GoogleCodeExporter commented 8 years ago
I am also facing the similar issue. If I remove position: absolute;, it renders 
fine. Is there anyway to fix this issue ?

Original comment by kaleeswaran14 on 29 Feb 2012 at 11:01

GoogleCodeExporter commented 8 years ago
related to issue 144
related to issue 192
potential fix at https://github.com/flyingsaucerproject/flyingsaucer/pull/19

Original comment by robd...@gmail.com on 13 Nov 2012 at 7:25

GoogleCodeExporter commented 8 years ago
This issue is still present in 9.0.4. I just tested the given example and it 
raised the following exception:

org.xhtmlrenderer.render.AnonymousBlockBox cannot be cast to 
org.xhtmlrenderer.newtable.TableCellBox
    at org.xhtmlrenderer.newtable.TableSectionBox.recalcCells(TableSectionBox.java:83)
    at org.xhtmlrenderer.newtable.TableBox.recalcSections(TableBox.java:204)
    at org.xhtmlrenderer.newtable.TableBox.calcMinMaxWidth(TableBox.java:154)
    at org.xhtmlrenderer.newtable.TableBox.layout(TableBox.java:221)
    at org.xhtmlrenderer.layout.BlockBoxing.layoutBlockChild0(BlockBoxing.java:321)
    at org.xhtmlrenderer.layout.BlockBoxing.layoutBlockChild(BlockBoxing.java:299)
    at org.xhtmlrenderer.layout.BlockBoxing.layoutContent(BlockBoxing.java:90)
    at org.xhtmlrenderer.render.BlockBox.layoutChildren(BlockBox.java:930)
    at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:810)
    at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:739)
    at org.xhtmlrenderer.layout.BlockBoxing.layoutBlockChild0(BlockBoxing.java:321)
    at org.xhtmlrenderer.layout.BlockBoxing.layoutBlockChild(BlockBoxing.java:299)
    at org.xhtmlrenderer.layout.BlockBoxing.layoutContent(BlockBoxing.java:90)
    at org.xhtmlrenderer.render.BlockBox.layoutChildren(BlockBox.java:930)
    at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:810)
    at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:739)
    at org.xhtmlrenderer.pdf.ITextRenderer.layout(ITextRenderer.java:207)

Original comment by sebastia...@googlemail.com on 9 Oct 2013 at 2:54