JFR9StyleResolvingGuide

In the flow-engine everything starts with a report-definition
and a data-source. The flow engine merges both parts to create the
actual renderable content.

1) User model

This is the document the user provides. As this document is provided
by humans, it is full of errors, incomplete and only contains the information
the user thinks that is important. In most cases, the
user model is not directly renderable.

The user-model contains both structural information and style
information.

In the Flow-Engine, the reporting layer always generates the user-model.
The model is passed into the layouting layer via the "InputFeed".

2) Computing the effective style

The input-feed forwards the constructed DOM to the "Normalizer" class.
This class maintains the DOM-tree (as far as it is needed for the style-rule selectors).

Every node that is processed in the "Normalizer" (Implementation:
ContentNormalizer) has all matching style-rules applied to the element.
The style-rule resolving process is defined by the selector preference
order. The more generic rules are applied first, and what they define
can be overridden by the more specific rules.

At the end of the style-resolving process (which happens fully inside
the class "StyleResolver"), every node of the user-model has a computed
value for all style-keys. All style-rules have been collapsed/merged
into a single map of <stylekey, value> entries.

3) Normalizing the user model

The user-model is (sadly) not renderable. In HTML it usually happily
mixes block-level and inline-level content, tables are incomplete and
so on. At a minimum, every text/CDATA element has to be wrapped into
a paragraph.

A CSS-compliant renderer now has to insert auto-generated nodes into
the user's DOM tree to make the content renderable.

http://www.w3.org/TR/REC-CSS2/visuren.html#anonymous-block-level

Every auto-generated node inherits the style from it's parent node
from the user-model. In LibLayout the auto-generated nodes also receive
style-information from the default-stylesheet. The default-stylesheet
contains the "hard-coded" fallback values for all elements.

(The default-styles can be found in the css-files contained in package
"org.jfree.layouting")

Inserting the missing elements to make the model renderable is done
in the "FastDisplayModelBuilder". The renderable model is called
"DisplayModel" in the CSS-terminology.

The normalizer is also allowed to remove nodes, that are invisible
or not renderable. (Empty <span> elements, elements with display:none,
script-elements etc.)

4) Rendering

This finally transforms the display-model into something renderable.
Whatever happens here, it takes the DisplayModel as input and produces
the operations that create valid PDF, Graphics2D or other renderings.

How this is done is beyond the scope of the layouting model.
In LibLayout that is the part that is totally broken and gives all the
crashes.