org.w3c.dom.stylesheets.MediaList#org.w3c.dom.css.CSSRuleList源码实例Demo

下面列出了org.w3c.dom.stylesheets.MediaList#org.w3c.dom.css.CSSRuleList 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: svgtoandroid   文件: StyleParser.java
private void init() {
    if (style != null) {
        String styleContent = style.getValue().getText();
        if (styleContent != null && !styleContent.isEmpty()) {
            InputSource source = new InputSource(new StringReader(styleContent));
            CSSOMParser parser = new CSSOMParser(new SACParserCSS3());
            parser.setErrorHandler(new ParserErrorHandler());
            try {
                styleSheet = parser.parseStyleSheet(source, null, null);
                cssFormat = new CSSFormat().setRgbAsHex(true);

                CSSRuleList rules = styleSheet.getCssRules();
                for (int i = 0; i < rules.getLength(); i++) {
                    final CSSRule rule = rules.item(i);
                    if (rule instanceof CSSStyleRuleImpl) {
                        styleRuleMap.put(((CSSStyleRuleImpl) rule).getSelectorText(), (CSSStyleRuleImpl) rule);
                    }
                }

            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
 
源代码2 项目: FairEmail   文件: HtmlHelper.java
private static String processStyles(String tag, String clazz, String style, CSSRuleList rules, int stype) {
    for (int i = 0; rules != null && i < rules.getLength(); i++) {
        CSSRule rule = rules.item(i);
        switch (rule.getType()) {
            case CSSRule.STYLE_RULE:
                CSSStyleRuleImpl srule = (CSSStyleRuleImpl) rule;
                for (int j = 0; j < srule.getSelectors().getLength(); j++) {
                    Selector selector = srule.getSelectors().item(j);
                    if (selector.getSelectorType() != stype)
                        continue;
                    switch (selector.getSelectorType()) {
                        case Selector.SAC_ELEMENT_NODE_SELECTOR:
                            ElementSelectorImpl eselector = (ElementSelectorImpl) selector;
                            if (tag == null
                                    ? eselector.getLocalName() == null
                                    : tag.equals(eselector.getLocalName()))
                                style = mergeStyles(style, srule.getStyle().getCssText());
                            break;
                        case Selector.SAC_CONDITIONAL_SELECTOR:
                            ConditionalSelectorImpl cselector = (ConditionalSelectorImpl) selector;
                            if (cselector.getCondition().getConditionType() == SAC_CLASS_CONDITION) {
                                ClassConditionImpl ccondition = (ClassConditionImpl) cselector.getCondition();
                                if (clazz.equals(ccondition.getValue()))
                                    style = mergeStyles(style, srule.getStyle().getCssText());
                            }
                            break;
                    }
                }
                break;

            case CSSRule.MEDIA_RULE:
                CSSMediaRuleImpl mrule = (CSSMediaRuleImpl) rule;
                if (isScreenMedia(mrule.getMedia()))
                    style = processStyles(tag, clazz, style, mrule.getCssRules(), stype);
                break;
        }
    }
    return style;
}
 
源代码3 项目: HtmlUnit-Android   文件: CSSStyleSheet.java
private void initCssRules() {
    if (cssRules_ == null) {
        cssRules_ = new com.gargoylesoftware.htmlunit.javascript.host.css.CSSRuleList(this);
        cssRulesIndexFix_ = new ArrayList<>();
        refreshCssRules();
    }
}
 
源代码4 项目: HtmlUnit-Android   文件: CSSStyleSheet.java
/**
 * Retrieves the collection of rules defined in this style sheet.
 * @return the collection of rules defined in this style sheet
 */
@JsxGetter({IE, CHROME})
public com.gargoylesoftware.htmlunit.javascript.host.css.CSSRuleList getRules() {
    return getCssRules();
}
 
源代码5 项目: HtmlUnit-Android   文件: CSSStyleSheet.java
/**
 * Returns the collection of rules defined in this style sheet.
 * @return the collection of rules defined in this style sheet
 */
@JsxGetter
public com.gargoylesoftware.htmlunit.javascript.host.css.CSSRuleList getCssRules() {
    initCssRules();
    return cssRules_;
}
 
源代码6 项目: birt   文件: StyleSheet.java
public CSSRuleList getCssRules( )
{
	return null;
}