@Nonnull private CSSMediaRule _createMediaRule(@Nonnull final CSSNode aNode) { _expectNodeType(aNode, ECSSNodeType.MEDIARULE); final CSSMediaRule ret = new CSSMediaRule(); ret.setSourceLocation(aNode.getSourceLocation()); for (final CSSNode aChildNode : aNode) { if (ECSSNodeType.MEDIALIST.isNode(aChildNode, m_eVersion)) { for (final CSSNode aMediaListChildNode : aChildNode) ret.addMediaQuery(_createMediaQuery(aMediaListChildNode)); } else if (ECSSNodeType.STYLERULE.isNode(aChildNode, m_eVersion)) ret.addRule(_createStyleRule(aChildNode)); else if (ECSSNodeType.MEDIARULE.isNode(aChildNode, m_eVersion)) { // Nested media rules are OK! ret.addRule(_createMediaRule(aChildNode)); } else if (ECSSNodeType.PAGERULE.isNode(aChildNode, m_eVersion)) ret.addRule(_createPageRule(aChildNode)); else if (ECSSNodeType.FONTFACERULE.isNode(aChildNode, m_eVersion)) ret.addRule(_createFontFaceRule(aChildNode)); else if (ECSSNodeType.KEYFRAMESRULE.isNode(aChildNode, m_eVersion)) ret.addRule(_createKeyframesRule(aChildNode)); else if (ECSSNodeType.VIEWPORTRULE.isNode(aChildNode, m_eVersion)) ret.addRule(_createViewportRule(aChildNode)); else if (ECSSNodeType.SUPPORTSRULE.isNode(aChildNode, m_eVersion)) ret.addRule(_createSupportsRule(aChildNode)); else if (!ECSSNodeType.isErrorNode(aChildNode, m_eVersion)) s_aLogger.error( "Unsupported media-rule child: " + ECSSNodeType.getNodeName(aChildNode, m_eVersion)); } return ret; }
protected void processRules(List<ICSSTopLevelRule> icssTopLevelRules) { for (ICSSTopLevelRule icssTopLevelRule : icssTopLevelRules) { if (icssTopLevelRule instanceof CSSMediaRule) { CSSMediaRule cssMediaRule = (CSSMediaRule) icssTopLevelRule; processRules(cssMediaRule.getAllRules()); } else if (icssTopLevelRule instanceof CSSStyleRule) { processRule((CSSStyleRule) icssTopLevelRule); } } }