if (shortcutTextValue != null) {
// this is never null.
ShortcutProperties shortcutProps =
menu.getShortcutProperties();
ElementDetails elementDetails = menu.getElementDetails();
if (elementDetails != null) {
SpanAttributes attributes = new SpanAttributes();
// Should only render out a surrounding span
// element if the device supports it.
if (shortcutProps.supportsSpan()) {
// Create span attributes from the menu's
// attributes. There are two mechanisms used
// here to support real css and the css
// emulation provided by MCS. The style class
// VE-... is used for devices that support css
// and the css renderers need to ensure they
// generate appropriate style rules. The
// pseudo element is used by those protocols
// that work through css emulation.
attributes.setId(elementDetails.getId());
// Need to explicitly set the display to inline
// (even though the shortcut should use the
// menu styles, we know display should always
// be inline in this case).
final Styles styles =
elementDetails.getStyles().copy();
styles.getPropertyValues().setSpecifiedValue(
StylePropertyDetails.DISPLAY,
StyleKeywords.INLINE);
// The tag name and style class are
// conditionally added into the attributes
// because CSS emulation requires the tag name
// but no descendent selector in order to work
// correctly while real CSS supporting protocols
// would create too many style classes on the
// shortcut if the tag is specified and would
// not generate the required markup without the
// style class.
if (customisation.supportsStyleSheets()) {
attributes.setTagName(null);
attributes.setStyles(styles);
} else {
attributes.setTagName(
elementDetails.getElementName());
attributes.setStyles(styles);
}
span.openSpan(domBuffer, attributes);
}