Notes on the collapsing border model

Painting the borders for the separate border model is relatively simple. For the collapsing border model this can become complicated. The following is an attempt to analyze how the borders should be painted in this model. The sequence of images should also help identify what information besides the traits defined in the XSL-FO spec are necessary to properly paint the individual borders.

1. A part of a table (grid lines)

2. Resolution of the individual borders according to the rules in the FO spec

3. 33. Inner and outer join points (where the individual borders meet)

Each join point together with the intersecting points of the basic table grid lines (see 1) for form the edges of a polygon which is used to clip the border line. In PDF the border line can simply be painted as a line. This line is clipped by a polygon with 6 points (4 join points plus 2 grid line intersection points).

TODO Find out what strategy to use for painting the border.

  • Strategy 1: Each cell paints its own 4 partial (half) border lines (each clipped at the grid lines) in which case it only needs to know it own 4 join points and can use a trapezoid (polygon with 4 points) for clipping. This is relatively simple to implement but it might result in the borders not looking good because the same border line is painted twice with 2 clipping polygons complementing each other. One difficulty in this approach are the outer borders of a table. The renderer needs an information which border sides represent the outer border of the table in which case the clipping polygon has to be extended beyond the cell area which makes a 6 point clipping polygon necessary. But in contrast to strategy 2 there's no need for information that belongs to neighbouring cells.
  • Strategy 2: Cells are assigned a specific subset of border lines to paint. Example: All cells of the first row paint "before" borders, all cells of the first column paint paint the "start" borders, all cells paint "end" and "after" borders. Problem with this approach is the additional info necessary to create the right clip polygon and handling empty cells.

4. Resulting borders

5. Final result

Spanned cells

A border line of a spanned cell may be adjacent to several neighbouring cells which may have different border widths. When doing border resolution this means you can't look at already spanned cells but only at cell slots. This has also a consequence for border painting depending on the painting strategy (see above). If strategy 1 is used the LM has to create separate areas for borders if a cell is spanned. The border traits cannot simply be set on the normal cell areas.

As the image above suggests the padding rectangle cannot simply be calculated using the cell's own border properties. If we'd do that the content rect might overlap with a border line producing ugly results. This means that the padding rectangle has to be calculated from the already resolved borders. The effective border width for this calculation is half the width of the widest border line in a segment.


  • No labels