for (int i = 0; i < len - 1; i++) {
int idx = i;
int min = Integer.MAX_VALUE;
for (int j = i; j < len; j++) {
StyleRule r = (StyleRule)rules.get(j);
SelectorList sl = r.getSelectorList();
int spec = 0;
int slen = sl.getLength();
for (int k = 0; k < slen; k++) {
ExtendedSelector s = (ExtendedSelector)sl.item(k);
if (s.match(elt, pseudo)) {
int sp = s.getSpecificity();
if (sp > spec) {
spec = sp;
}