public StrictStyledDOMHelper(EntityResolver resolver,
String styleAttributeName) {
this.resolver = resolver;
this.styleAttributeName = styleAttributeName;
StyledDOMThemeExtractorFactory extractorFactory =
StyledDOMThemeExtractorFactory.getDefaultInstance();
final AssetResolver assetResolver = new AssetResolver() {
// javadoc inherited
public PolicyReference evaluateExpression(PolicyExpression expression) {
return null;
}
// javadoc inherited
public String resolveImage(PolicyReference reference) {
return null;
}
// javadoc inherited
public String resolveTranscodableImage(String transcodableUrl) {
return null;
}
// javadoc inherited
public String resolveVideo(PolicyReference reference) {
return null;
}
// Javadoc inherited.
public String resolveText(
PolicyReference reference,
EncodingCollection requiredEncodings) {
return null;
}
};
ExtractorContext context = new ExtractorContext() {
public AssetResolver getAssetResolver() {
return assetResolver;
}
public boolean generateTypeRules() {
return true;
}
public CSSVersion getCSSVersion() {
DefaultCSSVersion cssVersion =
new DefaultCSSVersion("testVersion");
cssVersion.markImmutable();
return cssVersion;
}
};
StylePropertyDefinitions definitions =
StylePropertyDetails.getDefinitions();
final List standardProperties = new ArrayList();
definitions.iterateStyleProperties(new StylePropertyIteratee() {
public IterationAction next(StyleProperty property) {
String name = property.getName();
// Ignore all the mcs specific properties as they will not be
// written out in the final output. The exception to this is
// the mcs-input-format property as that may be written out as
// -wap-input-... properties.
if (property == StylePropertyDetails.MCS_INPUT_FORMAT ||
!name.startsWith("mcs-")) {
standardProperties.add(property);
}
return IterationAction.CONTINUE;
}
});
PropertyDetailsSet detailsSet =
PropertyDetailsSetHelper.getDetailsSet(standardProperties);
ShorthandSet supportedShorthands = new MutableShorthandSet();
ExtractorConfigurationBuilder extractorBuilder =
extractorFactory.createConfigurationBuilder();
extractorBuilder.setDetailsSet(detailsSet);
extractorBuilder.setSupportedShorthands(supportedShorthands);
CSSCompiler compiler = StylingFactory.getDefaultInstance()
.createDeviceCSSCompiler(DeviceOutlook.OPTIMISTIC);
CompiledStyleSheet deviceStyleSheet = compiler.compile(
new StringReader(DevicePolicyConstants.DEFAULT_DISPLAY_CSS), null);
extractorBuilder.setDeviceStyleSheet(deviceStyleSheet);
ExtractorConfiguration configuration =
extractorBuilder.buildConfiguration();
optimizer = extractorFactory.createOptimizer(configuration, context);
}