if (logger.isDebugEnabled()) {
logger.debug("Configuring CSS for device '" +
device.getName() + "'");
}
final DefaultCSSVersion cssVersion;
// Initialise the CSS version from the device.
String styleSheetVersion = device.getStyleSheetVersion();
// If the device has a style sheet version.
if (styleSheetVersion != null) {
// Then use it.
// Find the ancestor devices which share the same style sheet
// version. These are the ones that we may inherit individual
// property definitions from.
calculateAncestors(device, styleSheetVersion);
if (DevicePolicyConstants.CSS_MOBILE_PROFILE1.equals(
styleSheetVersion)) {
cssVersion =
new ManualCSSMobileVersionFactory().createCSSVersion();
} else if (DevicePolicyConstants.CSS1.equals(
styleSheetVersion)) {
cssVersion =
new ManualCSS1VersionFactory().createCSSVersion();
} else if (DevicePolicyConstants.CSS_WAP.equals(styleSheetVersion)) {
cssVersion =
new ManualCSSWAPVersionFactory().createCSSVersion();
} else if (DevicePolicyConstants.CSS2.equals(styleSheetVersion)) {
cssVersion =
new ManualCSS2VersionFactory().createCSSVersion();
} else {
// Should never happen, as getStyleSheetVersion constrains the
// results to ones that we know about.
throw new IllegalStateException("Unexpected device style " +
"sheet version '" + styleSheetVersion + "'");
}
if (logger.isDebugEnabled()) {
logger.debug("Using style sheet version '" +
styleSheetVersion + "'");
}
initialiseStyleProperties(device, cssVersion);
initialiseStyleShorthands(device, cssVersion);
initialiseAliases(device, cssVersion);
initialiseStyleSyntaxes(device, cssVersion);
initialiseStylePseudoSelectors(device, cssVersion);
CSSSupportConfigurator cssSupport =
new CSSSupportConfigurator(device);
cssVersion.setRemappableElements(
cssSupport.getFallbackAttributeExpressions());
cssVersion.markImmutable();
configuration.setCssVersion(cssVersion);
}
// else the device had no style sheet version set, or had it set to
// "None". We can just leave the css version as null in this case,
// as it only affects rendering at this stage, which we assume will