Search in sources :

Example 1 with CSSCharsetRuleImpl

use of com.gargoylesoftware.css.dom.CSSCharsetRuleImpl in project htmlunit by HtmlUnit.

the class CSSStyleSheet method refreshCssRules.

private void refreshCssRules() {
    if (cssRules_ == null) {
        return;
    }
    cssRules_.clearRules();
    cssRulesIndexFix_.clear();
    final CSSRuleListImpl ruleList = getWrappedSheet().getCssRules();
    final List<AbstractCSSRuleImpl> rules = ruleList.getRules();
    int pos = 0;
    for (final AbstractCSSRuleImpl rule : rules) {
        if (rule instanceof CSSCharsetRuleImpl) {
            cssRulesIndexFix_.add(pos);
            continue;
        }
        final com.gargoylesoftware.htmlunit.javascript.host.css.CSSRule cssRule = com.gargoylesoftware.htmlunit.javascript.host.css.CSSRule.create(this, rule);
        if (null == cssRule) {
            cssRulesIndexFix_.add(pos);
        } else {
            cssRules_.addRule(cssRule);
        }
        pos++;
    }
    // reset our index also
    getWrappedSheet().resetRuleIndex();
}
Also used : AbstractCSSRuleImpl(com.gargoylesoftware.css.dom.AbstractCSSRuleImpl) CSSCharsetRuleImpl(com.gargoylesoftware.css.dom.CSSCharsetRuleImpl) CSSRuleListImpl(com.gargoylesoftware.css.dom.CSSRuleListImpl)

Example 2 with CSSCharsetRuleImpl

use of com.gargoylesoftware.css.dom.CSSCharsetRuleImpl in project htmlunit by HtmlUnit.

the class CSSGroupingRule method refreshCssRules.

private void refreshCssRules() {
    if (cssRules_ == null) {
        return;
    }
    cssRules_.clearRules();
    cssRulesIndexFix_.clear();
    final CSSRuleListImpl ruleList = getGroupingRule().getCssRules();
    final List<AbstractCSSRuleImpl> rules = ruleList.getRules();
    int pos = 0;
    for (final AbstractCSSRuleImpl rule : rules) {
        if (rule instanceof CSSCharsetRuleImpl) {
            cssRulesIndexFix_.add(pos);
            continue;
        }
        final CSSRule cssRule = CSSRule.create(getParentStyleSheet(), rule);
        if (null == cssRule) {
            cssRulesIndexFix_.add(pos);
        } else {
            cssRules_.addRule(cssRule);
        }
        pos++;
    }
}
Also used : AbstractCSSRuleImpl(com.gargoylesoftware.css.dom.AbstractCSSRuleImpl) CSSCharsetRuleImpl(com.gargoylesoftware.css.dom.CSSCharsetRuleImpl) CSSRuleListImpl(com.gargoylesoftware.css.dom.CSSRuleListImpl)

Aggregations

AbstractCSSRuleImpl (com.gargoylesoftware.css.dom.AbstractCSSRuleImpl)2 CSSCharsetRuleImpl (com.gargoylesoftware.css.dom.CSSCharsetRuleImpl)2 CSSRuleListImpl (com.gargoylesoftware.css.dom.CSSRuleListImpl)2