JDK-5092058 : HTML table is corrupted
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,windows_nt
  • CPU: generic,x86
  • Submitted: 2004-08-25
  • Updated: 2004-12-11
  • Resolved: 2004-12-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6
5.0u2Fixed 6 b16Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
I have a simple Swing application with a JEditorPane. Upon construction, I give the JEditorPane a particular HTML page to show. Some of the text in the table is corrupted such that multiple lines of the table appear overlapped. Resizing the JFrame sometimes helps and sometimes doesn't - seems to depend on how you resize it.

To reproduce:
Run the attached test case, OverlapTest.java (requires the attached owners.html).

I've attached the test case, the HTML in question, and also a screen shot of the behavior (overlap.bmp).

I can't say for sure, but I seem to recall this happening *occasionally* in 1.4.2. In tiger, it happens almost every time I launch the application.

I'm not sure if it's relevant but my system is a dual CPU Windows NT 4 box. Note that I'm doing everything (including creating the GUI) on the EDT.

Comments
SUGGESTED FIX ###@###.### 2004-12-07 02:46:43 GMT
07-12-2004

EVALUATION It does not happen all the time. I was able to reproduce it only on time of more then 20 attempts >Some of the text in the table is corrupted such that multiple lines of the table appear overlapped. Some of the text is painted twice. Once overlapped and second time in a correct spot. ###@###.### 2004-08-26 this bug is not a showstopper of tiger. will work on this bug for the next release ###@###.### 2004-08-27 As I said, on my dual CPU machine, this is always reproducible. ###@###.### 2004-08-30 ======================================================================== This bug has quite a long history. Here are other manifestations of this problem: 4519711 Text is echoed at the top of a JTextPane inside a JScrollPane in a JnternalFrame 4624515 Invisible JTextPane shows formatted text incorrectly 4684377 JEditorPane garbles HTML Table content's display 4765331 JEditorPane editing: Ctrl-A + Delete on wrapped HTML throws BadLocationException 6198175 JCK15fcs JEditorPaneTests0003 messes up intermittently due to apparent Swing problem The root cause of the bug is FlowView in some cases does not layout itself on insert/remove/changeUpdate Only after layout FlowView is valid and consistent with Document model. When view hierarchy and document model are not in sync all kind of bad things might happen. Fix for 4624515 [Invisible JTextPane shows formatted text incorrectly called ] marked FlowView's layout as invalid on insert/remove/changeUpdate In many cases it does not trigger layout because parent's layout is not marked as invalid. We need to call preferenceChanged to get FlowView relayouted. More details. there are two threads working with JEditorPane: parsing thread : loading, parsing, Document and Views creation event dispatch thread : doing layout paints, etc. These threads are working in parallel and some locking is involved to make sure model stays consistent. Here is what happens in the bug example parse thread : EDT thread : handles <tr><td> Igor Kushnirskiy creates TableView.TableRow TableView.TableCell Paragraph InlineView Paragraph needs to be layouted to sync Views and Document ------------------------------> layouts everything which needs to be layouted doing layout for Paragraph raws are created Views and document are in sync; <----------------------------- handles \n</td> idk ... creates InlineView TableView.TableCell Paragraph InlineView Pargraph view is not in sync with Document anymore. Paragraph layout is marked as invalid -----------------------------> There is invalid layout somewhere in the views hierarchy. We do not know about it. We paint and work with incorrect Views. For this bug we end up with InlineView referencing Element which is not part of Document model anymore. That element starts on the start of the raw and ends on the end of raw. That is why text is painted twice. If layout on EDT does not happen in between of cell handling everything looks fine if it does there is a garbled html rendering. Suggested fix: *** /tmp/geta15693 Mon Dec 6 21:17:27 2004 --- FlowView.java Mon Dec 6 21:16:07 2004 *************** *** 334,341 **** host.repaint(alloc.x, alloc.y, alloc.width, alloc.height); } } else { ! fv.layoutChanged(View.X_AXIS); ! fv.layoutChanged(View.Y_AXIS); } } --- 334,340 ---- host.repaint(alloc.x, alloc.y, alloc.width, alloc.height); } } else { ! fv.preferenceChanged(null, true, true); } } *************** *** 354,361 **** host.repaint(alloc.x, alloc.y, alloc.width, alloc.height); } } else { ! fv.layoutChanged(View.X_AXIS); ! fv.layoutChanged(View.Y_AXIS); } } --- 353,359 ---- host.repaint(alloc.x, alloc.y, alloc.width, alloc.height); } } else { ! fv.preferenceChanged(null, true, true); } } *************** *** 376,383 **** host.repaint(alloc.x, alloc.y, alloc.width, alloc.height); } } else { ! fv.layoutChanged(View.X_AXIS); ! fv.layoutChanged(View.Y_AXIS); } } --- 374,380 ---- host.repaint(alloc.x, alloc.y, alloc.width, alloc.height); } } else { ! fv.preferenceChanged(null, true, true); } } ###@###.### 2004-12-07 02:47:17 GMT ===================== some more clarification: >The fix calls fv.preferenceChanged(null, true, true); only when alloc != null >What triggers the layout when alloc != null. That was this way for ever. When alloc != null. LogicalView.insertUpdate triggers the layout. See View.insertUpdate and View.updateLayout. ###@###.### 2004-12-07 18:53:29 GMT
07-12-2004