org.w3c.dom.css.CSSStyleSheet Java Examples
The following examples show how to use
org.w3c.dom.css.CSSStyleSheet.
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: CssParser.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Parses a CSS resource and get the CSSStyleSheet as the output. * * @param source * the source of the CSS resource * @return the CSSStyleSheet if succeed * @throws IOException * if the resource is not well-located */ public CSSStyleSheet parseStyleSheet( InputSource source ) throws IOException { CssHandler handler = new CssHandler( ); parser.setDocumentHandler( handler ); parser.setErrorHandler( errorHandler ); try { parser.parseStyleSheet( source ); } catch ( StringIndexOutOfBoundsException e ) { throw new CSSException( CSSException.SAC_SYNTAX_ERR ); } return (StyleSheet) handler.getRoot( ); }
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, List<CSSStyleSheet> sheets) { for (CSSStyleSheet sheet : sheets) if (isScreenMedia(sheet.getMedia())) { style = processStyles(null, clazz, style, sheet.getCssRules(), Selector.SAC_ELEMENT_NODE_SELECTOR); style = processStyles(tag, clazz, style, sheet.getCssRules(), Selector.SAC_ELEMENT_NODE_SELECTOR); style = processStyles(tag, clazz, style, sheet.getCssRules(), Selector.SAC_CONDITIONAL_SELECTOR); } return style; }
Example #3
Source File: Cache.java From HtmlUnit-Android with Apache License 2.0 | 5 votes |
/** * Returns the cached parsed version of the specified CSS snippet. If there is no * corresponding cached stylesheet, this method returns {@code null}. * * @param css the CSS snippet whose cached stylesheet is sought * @return the cached stylesheet corresponding to the specified CSS snippet */ public CSSStyleSheet getCachedStyleSheet(final String css) { final Entry cachedEntry = entries_.get(css); if (cachedEntry == null) { return null; } synchronized (entries_) { cachedEntry.touch(); } return (CSSStyleSheet) cachedEntry.value_; }
Example #4
Source File: StyleRule.java From birt with Eclipse Public License 1.0 | 4 votes |
public CSSStyleSheet getParentStyleSheet( ) { return null; }
Example #5
Source File: UnSupportedRule.java From birt with Eclipse Public License 1.0 | 4 votes |
public CSSStyleSheet getParentStyleSheet( ) { return null; }
Example #6
Source File: Cache.java From HtmlUnit-Android with Apache License 2.0 | 2 votes |
/** * Caches the parsed version of the specified CSS snippet. We key the cache based on CSS snippets (rather * than requests and responses as is done above) because a) this allows us to cache inline CSS, b) CSS is * extremely expensive to parse, so we want to avoid it as much as possible, c) CSS files aren't usually * nearly as large as JavaScript files, so memory bloat won't be too bad, and d) caching on requests and * responses requires checking dynamicity (see {@link #isCacheableContent(WebResponse)}), and headers often * aren't set up correctly, disallowing caching when in fact it should be allowed. * * @param css the CSS snippet from which <tt>styleSheet</tt> is derived * @param styleSheet the parsed version of <tt>css</tt> */ public void cache(final String css, final CSSStyleSheet styleSheet) { final Entry entry = new Entry(css, null, styleSheet); entries_.put(entry.key_, entry); deleteOverflow(); }