checkIdentLengthOrPercentType(cssName, first);
if (second == null) {
if (isLength(first) || first.getPrimitiveType() == CSSPrimitiveValue.CSS_PERCENTAGE) {
List responseValues = new ArrayList(2);
responseValues.add(first);
responseValues.add(new PropertyValue(
CSSPrimitiveValue.CSS_PERCENTAGE, 50.0f, "50%"));
return Collections.singletonList(new PropertyDeclaration(
CSSName.BACKGROUND_POSITION,
new PropertyValue(responseValues), important, origin));
}
} else {
checkIdentLengthOrPercentType(cssName, second);
}
IdentValue firstIdent = null;
if (first.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) {
firstIdent = checkIdent(cssName, first);
checkValidity(cssName, getAllowed(), firstIdent);
}
IdentValue secondIdent = null;
if (second == null) {
secondIdent = IdentValue.CENTER;
} else if (second.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) {
secondIdent = checkIdent(cssName, second);
checkValidity(cssName, getAllowed(), secondIdent);
}
if (firstIdent == null && secondIdent == null) {
return Collections.singletonList(new PropertyDeclaration(
CSSName.BACKGROUND_POSITION, new PropertyValue(values), important, origin));
} else if (firstIdent != null && secondIdent != null) {
if (firstIdent == IdentValue.TOP || firstIdent == IdentValue.BOTTOM ||
secondIdent == IdentValue.LEFT || secondIdent == IdentValue.RIGHT) {
IdentValue temp = firstIdent;
firstIdent = secondIdent;
secondIdent = temp;
}
checkIdentPosition(cssName, firstIdent, secondIdent);
return createTwoPercentValueResponse(
getPercentForIdent(firstIdent),
getPercentForIdent(secondIdent),
important,
origin);
} else {
checkIdentPosition(cssName, firstIdent, secondIdent);
List responseValues = new ArrayList(2);
if (firstIdent == null) {
responseValues.add(first);
responseValues.add(createValueForIdent(secondIdent));
} else {
responseValues.add(createValueForIdent(firstIdent));
responseValues.add(second);
}
return Collections.singletonList(new PropertyDeclaration(
CSSName.BACKGROUND_POSITION,
new PropertyValue(responseValues), important, origin));
}
}