Search in sources :

Example 6 with CSSOMParser

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

the class CSSStyleSheetImpl method setMediaText.

/**
 * Set the media text.
 *
 * @param mediaText the new media text
 */
public void setMediaText(final String mediaText) {
    if (mediaText == null || mediaText.length() == 0) {
        final MediaQueryList sml = new MediaQueryList();
        sml.add(new MediaQuery(null));
        media_ = new MediaListImpl(sml);
        return;
    }
    try {
        final CSSOMParser parser = new CSSOMParser();
        final MediaQueryList sml = parser.parseMedia(mediaText);
        media_ = new MediaListImpl(sml);
    } catch (final IOException e) {
    // TODO handle exception
    }
}
Also used : CSSOMParser(com.gargoylesoftware.css.parser.CSSOMParser) MediaQuery(com.gargoylesoftware.css.parser.media.MediaQuery) MediaQueryList(com.gargoylesoftware.css.parser.media.MediaQueryList) IOException(java.io.IOException)

Example 7 with CSSOMParser

use of com.gargoylesoftware.css.parser.CSSOMParser 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 8 with CSSOMParser

use of com.gargoylesoftware.css.parser.CSSOMParser 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 9 with CSSOMParser

use of com.gargoylesoftware.css.parser.CSSOMParser 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 10 with CSSOMParser

use of com.gargoylesoftware.css.parser.CSSOMParser 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)

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