/** {@inheritDoc} */
  @Override
  public String getCssText(final CSSFormat format) {
    final StringBuilder sb = new StringBuilder("@media ");

    sb.append(((MediaListImpl) getMedia()).getMediaText(format));
    sb.append(" {");
    for (int i = 0; i < getCssRules().getLength(); i++) {
      final CSSRule rule = getCssRules().item(i);
      sb.append(rule.getCssText()).append(" ");
    }
    sb.append("}");
    return sb.toString();
  }
Esempio n. 2
0
 /**
  * Creates a CSSRule according to the specified rule type.
  *
  * @param stylesheet the Stylesheet of this rule
  * @param rule the wrapped rule
  * @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);
     default:
       throw new UnsupportedOperationException(
           "CSSRule " + rule.getClass().getName() + " is not yet supported:" + rule.getCssText());
   }
 }
Esempio n. 3
0
 /**
  * Returns the parsable textual representation of the rule. This reflects the current state of the
  * rule and not its initial value.
  *
  * @return the parsable textual representation of the rule.
  */
 @JsxGetter({@WebBrowser(FF), @WebBrowser(value = IE, minVersion = 11)})
 public String getCssText() {
   return rule_.getCssText();
 }