Parses the CSS at the specified input source. If anything at all goes wrong, this method returns an empty stylesheet. @param source the source from which to retrieve the CSS to be parsed @param client the client @return the stylesheet parsed from the specified input source
(final InputSource source, final WebClient client)
| 1047 | * @return the stylesheet parsed from the specified input source |
| 1048 | */ |
| 1049 | private static CSSStyleSheetImpl parseCSS(final InputSource source, final WebClient client) { |
| 1050 | CSSStyleSheetImpl ss; |
| 1051 | |
| 1052 | // use a pooled parser, if any available to avoid expensive recreation |
| 1053 | try (PooledCSS3Parser pooledParser = client.getCSS3Parser()) { |
| 1054 | final CSSErrorHandler errorHandler = client.getCssErrorHandler(); |
| 1055 | final CSSOMParser parser = new CSSOMParser(pooledParser); |
| 1056 | parser.setErrorHandler(errorHandler); |
| 1057 | ss = parser.parseStyleSheet(source, null); |
| 1058 | } |
| 1059 | catch (final Throwable ex) { |
| 1060 | if (LOG.isErrorEnabled()) { |
| 1061 | LOG.error("Error parsing CSS from '" + toString(source) + "': " + ex.getMessage(), ex); |
| 1062 | } |
| 1063 | ss = new CSSStyleSheetImpl(); |
| 1064 | } |
| 1065 | return ss; |
| 1066 | } |
| 1067 | |
| 1068 | /** |
| 1069 | * Parses the given media string. If anything at all goes wrong, this |
no test coverage detected