Example usage for org.w3c.dom.css CSSUnknownRule getCssText

List of usage examples for org.w3c.dom.css CSSUnknownRule getCssText

Introduction

In this page you can find the example usage for org.w3c.dom.css CSSUnknownRule getCssText.

Prototype

public String getCssText();

Source Link

Document

The parsable textual representation of the rule.

Usage

From source file:com.gargoylesoftware.htmlunit.javascript.host.css.CSSRule.java

/**
 * Creates a CSSRule according to the specified rule type.
 * @param stylesheet the Stylesheet of this rule
 * @param rule the wrapped rule//  w w w .jav a  2 s. c o  m
 * @return a CSSRule subclass according to the rule type
 */
public static CSSRule create(final CSSStyleSheet stylesheet, final org.w3c.dom.css.CSSRule rule) {
    switch (rule.getType()) {
    case STYLE_RULE:
        return new CSSStyleRule(stylesheet, (org.w3c.dom.css.CSSStyleRule) rule);
    case IMPORT_RULE:
        return new CSSImportRule(stylesheet, (org.w3c.dom.css.CSSImportRule) rule);
    case CHARSET_RULE:
        return new CSSCharsetRule(stylesheet, (org.w3c.dom.css.CSSCharsetRule) rule);
    case MEDIA_RULE:
        return new CSSMediaRule(stylesheet, (org.w3c.dom.css.CSSMediaRule) rule);
    case FONT_FACE_RULE:
        return new CSSFontFaceRule(stylesheet, (org.w3c.dom.css.CSSFontFaceRule) rule);
    case UNKNOWN_RULE:
        final org.w3c.dom.css.CSSUnknownRule unknownRule = (org.w3c.dom.css.CSSUnknownRule) rule;
        if (unknownRule.getCssText().startsWith("@keyframes")) {
            return new CSSKeyframesRule(stylesheet, (org.w3c.dom.css.CSSUnknownRule) rule);
        }
        LOG.warn("Unknown CSSRule " + rule.getClass().getName() + " is not yet supported; rule content: '"
                + rule.getCssText() + "'");
        break;
    default:
        LOG.warn("CSSRule " + rule.getClass().getName() + " is not yet supported; rule content: '"
                + rule.getCssText() + "'");
    }

    return null;
}