* @param element the elemen that should be resolved.
*/
public void resolveStyle(final LayoutElement element)
{
// this is a three stage process
final LayoutContext layoutContext = element.getLayoutContext();
final StyleKey[] keys = getKeys();
// Log.debug ("Resolving style for " +
// layoutContext.getTagName() + ":" +
// layoutContext.getPseudoElement());
// Stage 0: Initialize with the built-in defaults
// Stage 1a: Add the parent styles (but only the one marked as inheritable).
final LayoutElement parent = element.getParent();
final LayoutStyle initialStyle = getInitialStyle();
if (layoutContext.copyFrom(initialStyle) == false)
{
// ok, manual copy ..
Log.debug ("Failed to use fast-copy");
for (int i = 0; i < keys.length; i++)
{
final StyleKey key = keys[i];
layoutContext.setValue(key, initialStyle.getValue(key));
}
}
final LayoutStyle parentStyle;
if (parent != null)
{
parentStyle = parent.getLayoutContext();
final StyleKey[] inheritedKeys = getInheritedKeys();
for (int i = 0; i < inheritedKeys.length; i++)
{
final StyleKey key = inheritedKeys[i];
layoutContext.setValue(key, parentStyle.getValue(key));
}
}
else
{
parentStyle = initialStyle;
}
// Stage 1b: Find all matching stylesheets for the given element
performSelectionStep(element, layoutContext);
// Stage 1c: Add the contents of the style attribute, if there is one ..
// the libLayout style is always added: This is a computed style and the hook
// for a element neutral user defined tweaking ..
final AttributeMap attributes = layoutContext.getAttributes();
final Object libLayoutStyleValue = attributes.getAttribute
(Namespaces.LIBLAYOUT_NAMESPACE, "style");
// You cannot override element specific styles with that. So an HTML-style
// attribute has move value than a LibLayout-style attribute.
addStyleFromAttribute(element, libLayoutStyleValue);
if (strictStyleMode)
{
performStrictStyleAttr(element);
}
else
{
performCompleteStyleAttr(element);
}
// Stage 2: Compute the 'specified' set of values.
// Find all explicitly inherited styles and add them from the parent.
final CSSInheritValue inheritInstance = CSSInheritValue.getInstance();
for (int i = 0; i < keys.length; i++)
{
final StyleKey key = keys[i];
final Object value = layoutContext.getValue(key);
if (inheritInstance.equals(value))
{
layoutContext.setValue(key, parentStyle.getValue(key));
}
}
// Stage 3: Compute the computed value set.
ResolverFactory.getInstance().performResolve