// Assumed to run immediately after SplitRulesVisitor
assert x.getSelectors().size() == 1;
CssSelector sel = x.getSelectors().get(0);
if (canonicalRules.containsKey(sel.getSelector())) {
CssRule canonical = canonicalRules.get(sel.getSelector());
// Check everything between the canonical rule and this rule for common
// properties. If there are common properties, it would be unsafe to
// promote the rule.
boolean hasCommon = false;
int index = rulesInOrder.indexOf(canonical) + 1;
assert index != 0;
for (Iterator<CssRule> i = rulesInOrder.listIterator(index); i.hasNext()
&& !hasCommon;) {
hasCommon = haveCommonProperties(i.next(), x);
}
if (!hasCommon) {
// It's safe to promote the rule
canonical.getProperties().addAll(x.getProperties());
ctx.removeMe();
return false;
}
}