Search in sources :

Example 16 with CSSOMParser

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

the class CSSImportRuleImpl 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 import rule
        if (r instanceof CSSImportRuleImpl) {
            href_ = ((CSSImportRuleImpl) r).href_;
            media_ = ((CSSImportRuleImpl) r).media_;
        } else {
            throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, DOMException.EXPECTING_IMPORT_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 17 with CSSOMParser

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

the class CSSPageRuleImpl 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 page rule
        if (r instanceof CSSPageRuleImpl) {
            pseudoPage_ = ((CSSPageRuleImpl) r).pseudoPage_;
            style_ = ((CSSPageRuleImpl) r).style_;
        } else {
            throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, DOMException.EXPECTING_PAGE_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 18 with CSSOMParser

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

the class CSSStyleDeclarationImpl method setCssText.

/**
 * Sets the css text.
 * @param cssText the new css text
 * @param cssErrorHandler the CSSErrorHandler to be used
 * @throws DOMException in case of error
 */
public void setCssText(final String cssText, final CSSErrorHandler cssErrorHandler) throws DOMException {
    try {
        final CSSOMParser parser = new CSSOMParser();
        parser.setErrorHandler(cssErrorHandler);
        properties_.clear();
        parser.parseStyleDeclaration(this, cssText);
    } catch (final Exception e) {
        throw new DOMException(DOMException.SYNTAX_ERR, DOMException.SYNTAX_ERROR, e.getMessage());
    }
}
Also used : CSSOMParser(com.gargoylesoftware.css.parser.CSSOMParser)

Example 19 with CSSOMParser

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

the class CSSValueImpl method setCssText.

/**
 * Sets the css text.
 *
 * @param cssText the new css text
 * @throws org.w3c.dom.DOMException in case of error
 */
public void setCssText(final String cssText) throws DOMException {
    try {
        final CSSOMParser parser = new CSSOMParser();
        final CSSValueImpl v2 = parser.parsePropertyValue(cssText);
        value_ = v2.value_;
    } catch (final Exception e) {
        throw new DOMException(DOMException.SYNTAX_ERR, DOMException.SYNTAX_ERROR, e.getMessage());
    }
}
Also used : CSSOMParser(com.gargoylesoftware.css.parser.CSSOMParser)

Example 20 with CSSOMParser

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

the class MediaListImpl method setMediaText.

/**
 * Parses the given media text.
 *
 * @param mediaText text to be parsed
 * @throws org.w3c.dom.DOMException in case of error
 */
public void setMediaText(final String mediaText) throws DOMException {
    try {
        final CSSOMParser parser = new CSSOMParser();
        parser.setErrorHandler(ThrowCssExceptionErrorHandler.INSTANCE);
        final MediaQueryList sml = parser.parseMedia(mediaText);
        setMediaList(sml);
    } catch (final CSSParseException e) {
        throw new DOMException(DOMException.SYNTAX_ERR, e.getLocalizedMessage());
    } catch (final IOException e) {
        throw new DOMException(DOMException.NOT_FOUND_ERR, e.getLocalizedMessage());
    }
}
Also used : DOMException(org.w3c.dom.DOMException) CSSParseException(com.gargoylesoftware.css.parser.CSSParseException) CSSOMParser(com.gargoylesoftware.css.parser.CSSOMParser) MediaQueryList(com.gargoylesoftware.css.parser.media.MediaQueryList) IOException(java.io.IOException)

Aggregations

CSSOMParser (com.gargoylesoftware.css.parser.CSSOMParser)26 IOException (java.io.IOException)16 CSSException (com.gargoylesoftware.css.parser.CSSException)14 CSS3Parser (com.gargoylesoftware.css.parser.javacc.CSS3Parser)10 CSSErrorHandler (com.gargoylesoftware.css.parser.CSSErrorHandler)4 CSSParseException (com.gargoylesoftware.css.parser.CSSParseException)4 SelectorList (com.gargoylesoftware.css.parser.selector.SelectorList)4 CSSStyleDeclarationImpl (com.gargoylesoftware.css.dom.CSSStyleDeclarationImpl)2 DOMException (com.gargoylesoftware.css.dom.DOMException)2 InputSource (com.gargoylesoftware.css.parser.InputSource)2 MediaQueryList (com.gargoylesoftware.css.parser.media.MediaQueryList)2 HTMLDocument (com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 DOMException (org.w3c.dom.DOMException)2 CSSStyleSheetImpl (com.gargoylesoftware.css.dom.CSSStyleSheetImpl)1 MediaListImpl (com.gargoylesoftware.css.dom.MediaListImpl)1 MediaQuery (com.gargoylesoftware.css.parser.media.MediaQuery)1 SelectorListImpl (com.gargoylesoftware.css.parser.selector.SelectorListImpl)1 FailingHttpStatusCodeException (com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException)1 DisabledElement (com.gargoylesoftware.htmlunit.html.DisabledElement)1