Пример #1
0
 @Nonnull
 private CSSSupportsRule _createSupportsRule(@Nonnull final CSSNode aNode) {
   _expectNodeType(aNode, ECSSNodeType.SUPPORTSRULE);
   final CSSSupportsRule ret = new CSSSupportsRule();
   ret.setSourceLocation(aNode.getSourceLocation());
   for (final CSSNode aChildNode : aNode) {
     if (ECSSNodeType.SUPPORTSCONDITION.isNode(aChildNode, m_eVersion)) {
       for (final CSSNode aChildChildNode : aChildNode) {
         final ICSSSupportsConditionMember aMember =
             _createSupportsConditionMemberRecursive(aChildChildNode);
         if (aMember != null) ret.addSupportConditionMember(aMember);
       }
     } else if (ECSSNodeType.STYLERULE.isNode(aChildNode, m_eVersion))
       ret.addRule(_createStyleRule(aChildNode));
     else if (ECSSNodeType.MEDIARULE.isNode(aChildNode, m_eVersion))
       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 supports-rule child: " + ECSSNodeType.getNodeName(aChildNode, m_eVersion));
   }
   return ret;
 }
Пример #2
0
 @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;
 }
Пример #3
0
 @Nonnull
 public CascadingStyleSheet createCascadingStyleSheetFromNode(@Nonnull final CSSNode aNode) {
   _expectNodeType(aNode, ECSSNodeType.ROOT);
   final CascadingStyleSheet ret = new CascadingStyleSheet();
   ret.setSourceLocation(aNode.getSourceLocation());
   for (final CSSNode aChildNode : aNode) {
     if (ECSSNodeType.CHARSET.isNode(aChildNode, m_eVersion)) {
       // Ignore because this was handled when reading!
     } else if (ECSSNodeType.IMPORTRULE.isNode(aChildNode, m_eVersion))
       ret.addImportRule(_createImportRule(aChildNode));
     else if (ECSSNodeType.NAMESPACERULE.isNode(aChildNode, m_eVersion))
       ret.addNamespaceRule(_createNamespaceRule(aChildNode));
     else if (ECSSNodeType.STYLERULE.isNode(aChildNode, m_eVersion))
       ret.addRule(_createStyleRule(aChildNode));
     else if (ECSSNodeType.PAGERULE.isNode(aChildNode, m_eVersion))
       ret.addRule(_createPageRule(aChildNode));
     else if (ECSSNodeType.MEDIARULE.isNode(aChildNode, m_eVersion))
       ret.addRule(_createMediaRule(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.UNKNOWNRULE.isNode(aChildNode, m_eVersion)) {
       // Unknown rule indicates either
       // 1. a parsing error
       // 2. a non-standard rule
       ret.addRule(_createUnknownRule(aChildNode));
     } else
       s_aLogger.error(
           "Unsupported child of "
               + ECSSNodeType.getNodeName(aNode, m_eVersion)
               + ": "
               + ECSSNodeType.getNodeName(aChildNode, m_eVersion));
   }
   return ret;
 }