private void parseSelectors(CSSStyleSheet css,List result) {
CSSRuleList ruleList = css.getCssRules();
for (int j = 0; j < ruleList.getLength(); j++) {
CSSRule rule = ruleList.item(j);
if (rule == null) {
continue;
}
if (rule.getType() == CSSRule.STYLE_RULE) {
CSSStyleRule cssRule = (CSSStyleRule) rule;
CSSStyleDeclaration decl = cssRule.getStyle();
StringTokenizer selectorsToken = new StringTokenizer(cssRule.getSelectorText(),",", false);
while (selectorsToken.hasMoreTokens()) {
String selector = selectorsToken.nextToken().trim();
CElement element = getElements(selector);
if (element != null) {
result.add(new CStyle(element,decl));
}
}
} // end if
else if (rule.getType() == CSSRule.IMPORT_RULE) {
CSSStyleSheet importCSS = ((CSSImportRule) rule).getStyleSheet();
parseSelectors(importCSS,result);
} // end else if
}
}