MCPcopy Create free account
hub / github.com/HtmlUnit/htmlunit / parseCSS

Method parseCSS

src/main/java/org/htmlunit/css/CssStyleSheet.java:1049–1066  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

CssStyleSheetMethod · 0.95

Calls 6

toStringMethod · 0.95
getCSS3ParserMethod · 0.80
getCssErrorHandlerMethod · 0.80
getMessageMethod · 0.80
isErrorEnabledMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected