Search in sources :

Example 6 with CSSException

use of com.gargoylesoftware.css.parser.CSSException in project LoboEvolution by LoboEvolution.

the class CSSUnknownRuleImpl method setCssText.

/**
 * {@inheritDoc}
 */
@Override
public void setCssText(final String cssText) throws DOMException {
    try {
        final CSSOMParser parser = new CSSOMParser();
        final AbstractCSSRuleImpl r = parser.parseRule(cssText);
        // The rule must be an unknown rule
        if (r instanceof CSSUnknownRuleImpl) {
            text_ = ((CSSUnknownRuleImpl) r).text_;
        } else {
            throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, DOMException.EXPECTING_FONT_FACE_RULE);
        }
    } catch (final CSSException e) {
        throw new DOMException(DOMException.SYNTAX_ERR, DOMException.SYNTAX_ERROR, e.getMessage());
    } catch (final IOException e) {
        throw new DOMException(DOMException.SYNTAX_ERR, DOMException.SYNTAX_ERROR, e.getMessage());
    }
}
Also used : CSSOMParser(com.gargoylesoftware.css.parser.CSSOMParser) CSSException(com.gargoylesoftware.css.parser.CSSException) IOException(java.io.IOException)

Example 7 with CSSException

use of com.gargoylesoftware.css.parser.CSSException in project LoboEvolution by LoboEvolution.

the class CSSFontFaceRuleImpl method setCssText.

/**
 * {@inheritDoc}
 */
@Override
public void setCssText(final String cssText) throws DOMException {
    try {
        final CSSOMParser parser = new CSSOMParser();
        final AbstractCSSRuleImpl r = parser.parseRule(cssText);
        // The rule must be a font face rule
        if (r instanceof CSSFontFaceRuleImpl) {
            style_ = ((CSSFontFaceRuleImpl) r).style_;
        } else {
            throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, DOMException.EXPECTING_FONT_FACE_RULE);
        }
    } catch (final CSSException e) {
        throw new DOMException(DOMException.SYNTAX_ERR, DOMException.SYNTAX_ERROR, e.getMessage());
    } catch (final IOException e) {
        throw new DOMException(DOMException.SYNTAX_ERR, DOMException.SYNTAX_ERROR, e.getMessage());
    }
}
Also used : CSSOMParser(com.gargoylesoftware.css.parser.CSSOMParser) CSSException(com.gargoylesoftware.css.parser.CSSException) IOException(java.io.IOException)

Example 8 with CSSException

use of com.gargoylesoftware.css.parser.CSSException in project LoboEvolution by LoboEvolution.

the class CSSMediaRuleImpl method setCssText.

/**
 * {@inheritDoc}
 */
@Override
public void setCssText(final String cssText) throws DOMException {
    try {
        final CSSOMParser parser = new CSSOMParser();
        final AbstractCSSRuleImpl r = parser.parseRule(cssText);
        // The rule must be a media rule
        if (r instanceof CSSMediaRuleImpl) {
            mediaList_ = ((CSSMediaRuleImpl) r).mediaList_;
            cssRules_ = ((CSSMediaRuleImpl) r).cssRules_;
        } else {
            throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, DOMException.EXPECTING_MEDIA_RULE);
        }
    } catch (final CSSException e) {
        throw new DOMException(DOMException.SYNTAX_ERR, DOMException.SYNTAX_ERROR, e.getMessage());
    } catch (final IOException e) {
        throw new DOMException(DOMException.SYNTAX_ERR, DOMException.SYNTAX_ERROR, e.getMessage());
    }
}
Also used : CSSOMParser(com.gargoylesoftware.css.parser.CSSOMParser) CSSException(com.gargoylesoftware.css.parser.CSSException) IOException(java.io.IOException)

Example 9 with CSSException

use of com.gargoylesoftware.css.parser.CSSException in project LoboEvolution by LoboEvolution.

the class CSSStyleRuleImpl method setSelectorText.

/**
 * Sets the selector text.
 * @param selectorText the new selector text
 * @throws DOMException in clase of error
 */
public void setSelectorText(final String selectorText) throws DOMException {
    try {
        final CSSOMParser parser = new CSSOMParser();
        selectors_ = parser.parseSelectors(selectorText);
    } catch (final CSSException e) {
        throw new DOMException(DOMException.SYNTAX_ERR, e.getMessage());
    } catch (final IOException e) {
        throw new DOMException(DOMException.SYNTAX_ERR, e.getMessage());
    }
}
Also used : CSSOMParser(com.gargoylesoftware.css.parser.CSSOMParser) CSSException(com.gargoylesoftware.css.parser.CSSException) IOException(java.io.IOException)

Example 10 with CSSException

use of com.gargoylesoftware.css.parser.CSSException in project yacy_grid_loader by yacy.

the class HtmlUnitLoader method getClient.

public static WebClient getClient(String userAgent) {
    WebClient webClient = new WebClient(getBrowser(userAgent));
    WebClientOptions options = webClient.getOptions();
    options.setJavaScriptEnabled(true);
    options.setCssEnabled(false);
    options.setPopupBlockerEnabled(true);
    options.setRedirectEnabled(true);
    options.setDownloadImages(false);
    options.setGeolocationEnabled(false);
    options.setPrintContentOnFailingStatusCode(false);
    options.setThrowExceptionOnScriptError(false);
    options.setMaxInMemory(0);
    options.setHistoryPageCacheLimit(0);
    options.setHistorySizeLimit(0);
    // ProxyConfig proxyConfig = new ProxyConfig();
    // proxyConfig.setProxyHost("127.0.0.1");
    // proxyConfig.setProxyPort(Service.getPort());
    // options.setProxyConfig(proxyConfig);
    // this might be a bit large, is regulated with throttling and client cache clear in short memory status
    webClient.getCache().setMaxSize(10000);
    webClient.setIncorrectnessListener(new IncorrectnessListener() {

        @Override
        public void notify(String arg0, Object arg1) {
        }
    });
    webClient.setCssErrorHandler(new CSSErrorHandler() {

        @Override
        public void warning(CSSParseException exception) throws CSSException {
        }

        @Override
        public void error(CSSParseException exception) throws CSSException {
        }

        @Override
        public void fatalError(CSSParseException exception) throws CSSException {
        }
    });
    webClient.setJavaScriptErrorListener(new JavaScriptErrorListener() {

        @Override
        public void timeoutError(HtmlPage arg0, long arg1, long arg2) {
        }

        @Override
        public void scriptException(HtmlPage arg0, ScriptException arg1) {
        }

        @Override
        public void malformedScriptURL(HtmlPage arg0, String arg1, MalformedURLException arg2) {
        }

        @Override
        public void loadScriptError(HtmlPage arg0, URL arg1, Exception arg2) {
        }

        @Override
        public void warn(String message, String sourceName, int line, String lineSource, int lineOffset) {
        }
    });
    webClient.setHTMLParserListener(new HTMLParserListener() {

        @Override
        public void error(String message, URL url, String html, int line, int column, String key) {
        }

        @Override
        public void warning(String message, URL url, String html, int line, int column, String key) {
        }
    });
    return webClient;
}
Also used : HTMLParserListener(com.gargoylesoftware.htmlunit.html.parser.HTMLParserListener) WebClientOptions(com.gargoylesoftware.htmlunit.WebClientOptions) MalformedURLException(java.net.MalformedURLException) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) WebClient(com.gargoylesoftware.htmlunit.WebClient) IncorrectnessListener(com.gargoylesoftware.htmlunit.IncorrectnessListener) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) CSSParseException(com.gargoylesoftware.css.parser.CSSParseException) CSSException(com.gargoylesoftware.css.parser.CSSException) ScriptException(com.gargoylesoftware.htmlunit.ScriptException) JavaScriptErrorListener(com.gargoylesoftware.htmlunit.javascript.JavaScriptErrorListener) ScriptException(com.gargoylesoftware.htmlunit.ScriptException) CSSParseException(com.gargoylesoftware.css.parser.CSSParseException) CSSErrorHandler(com.gargoylesoftware.css.parser.CSSErrorHandler) CSSException(com.gargoylesoftware.css.parser.CSSException)

Aggregations

CSSException (com.gargoylesoftware.css.parser.CSSException)18 IOException (java.io.IOException)16 CSSOMParser (com.gargoylesoftware.css.parser.CSSOMParser)13 SelectorList (com.gargoylesoftware.css.parser.selector.SelectorList)5 CSSErrorHandler (com.gargoylesoftware.css.parser.CSSErrorHandler)3 CSSParseException (com.gargoylesoftware.css.parser.CSSParseException)3 CSS3Parser (com.gargoylesoftware.css.parser.javacc.CSS3Parser)3 Selector (com.gargoylesoftware.css.parser.selector.Selector)3 BrowserVersion (com.gargoylesoftware.htmlunit.BrowserVersion)3 DomElement (com.gargoylesoftware.htmlunit.html.DomElement)2 DomNode (com.gargoylesoftware.htmlunit.html.DomNode)2 HtmlElement (com.gargoylesoftware.htmlunit.html.HtmlElement)2 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)2 HTMLDocument (com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 IncorrectnessListener (com.gargoylesoftware.htmlunit.IncorrectnessListener)1 ScriptException (com.gargoylesoftware.htmlunit.ScriptException)1 WebClient (com.gargoylesoftware.htmlunit.WebClient)1 WebClientOptions (com.gargoylesoftware.htmlunit.WebClientOptions)1 DisabledElement (com.gargoylesoftware.htmlunit.html.DisabledElement)1