| XXX Originally in insync.
Element for <table> elements. We need some extra state here to
be able to automatically handle CSS styling of tables missing tbody
elements.
The problem is that a html document like this:
<style>tbody {background: red}</style>
<table><tr><td>Hello</td></tr></table>
should have a red background. That's because a <tbody> element should
"automatically" be inserted in the table. I first tried an approach
where I actually inserted <tbody> elements during the parse, but
this didn't work right -- doing insertBefore calls during Xerces parse
caused the structure of the document to be wrong because it doesn't
seem to look at the return value from insertBefore. So I then changed
the code to try to "patch up" the table during the box creation phase;
this had the problem that the screen would refresh multiple times since
layout would be invalidated while rendering the page (table has changed)
and besides, I would have to acquire a write lock since I was modifying
the source dom (except for JSF-rendered tables in DocumentFragments);
and each write unlock would cause a flush, so documents with multiple
tables would cause multiple flushes. I then switched to a write lock
for the entire phase -- but this was getting to be a big ugly solution.
So I instead went for the following scheme:
When a <table> element is created, create a special subclass of
RaveElement for it. This subclass tracks the "tbody" child, if any.
On insert, any <tr> elements inserted directly on the table are put
in a "secret" tbody element. The tbody element is secret in that it
is not added to the DOM itself, but it is however linked stylewise
via the setStyleParent, such that my modified Batik CSS parser will
follow the style parent link for the <tr> to jump to the <tbody> first,
then the <table>, instead of directly to the <table>. This will cause
the (unconnected) <tbody> element to be styled too, and as a result,
the proper CSS inheritance and treatment of the <tbody> tag works.
author: Tor Norbye |