org.w3c.dom.css.CSSRuleList Java Examples
The following examples show how to use
org.w3c.dom.css.CSSRuleList.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StyleParser.java From svgtoandroid with MIT License | 6 votes |
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(); } } } }
Example #2
Source File: HtmlHelper.java From FairEmail with GNU General Public License v3.0 | 5 votes |
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; }
Example #3
Source File: CSSStyleSheet.java From HtmlUnit-Android with Apache License 2.0 | 5 votes |
private void initCssRules() { if (cssRules_ == null) { cssRules_ = new com.gargoylesoftware.htmlunit.javascript.host.css.CSSRuleList(this); cssRulesIndexFix_ = new ArrayList<>(); refreshCssRules(); } }
Example #4
Source File: CSSStyleSheet.java From HtmlUnit-Android with Apache License 2.0 | 4 votes |
/** * 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(); }
Example #5
Source File: CSSStyleSheet.java From HtmlUnit-Android with Apache License 2.0 | 4 votes |
/** * 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_; }
Example #6
Source File: StyleSheet.java From birt with Eclipse Public License 1.0 | 4 votes |
public CSSRuleList getCssRules( ) { return null; }