Search in sources :

Example 1 with SelectorListImpl

use of com.gargoylesoftware.css.parser.selector.SelectorListImpl in project LoboEvolution by LoboEvolution.

the class CSS3Parser method selectorList.

public final SelectorList selectorList() throws ParseException {
    SelectorListImpl selList = new SelectorListImpl();
    Selector sel;
    sel = selector();
    selList.setLocator(sel.getLocator());
    label_42: while (true) {
        switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
            case COMMA:
                {
                    ;
                    break;
                }
            default:
                jj_la1[65] = jj_gen;
                break label_42;
        }
        jj_consume_token(COMMA);
        label_43: while (true) {
            switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
                case S:
                    {
                        ;
                        break;
                    }
                default:
                    jj_la1[66] = jj_gen;
                    break label_43;
            }
            jj_consume_token(S);
        }
        selList.add(sel);
        sel = selector();
        selList.setLocator(sel.getLocator());
    }
    selList.add(sel);
    return selList;
}
Also used : SelectorListImpl(com.gargoylesoftware.css.parser.selector.SelectorListImpl) PseudoElementSelector(com.gargoylesoftware.css.parser.selector.PseudoElementSelector) DescendantSelector(com.gargoylesoftware.css.parser.selector.DescendantSelector) SimpleSelector(com.gargoylesoftware.css.parser.selector.SimpleSelector) Selector(com.gargoylesoftware.css.parser.selector.Selector) DirectAdjacentSelector(com.gargoylesoftware.css.parser.selector.DirectAdjacentSelector) ElementSelector(com.gargoylesoftware.css.parser.selector.ElementSelector) ChildSelector(com.gargoylesoftware.css.parser.selector.ChildSelector) GeneralAdjacentSelector(com.gargoylesoftware.css.parser.selector.GeneralAdjacentSelector)

Example 2 with SelectorListImpl

use of com.gargoylesoftware.css.parser.selector.SelectorListImpl in project htmlunit by HtmlUnit.

the class CSSStyleSheet method parseSelectors.

/**
 * Parses the selectors at the specified input source. If anything at all goes wrong, this
 * method returns an empty selector list.
 *
 * @param source the source from which to retrieve the selectors to be parsed
 * @return the selectors parsed from the specified input source
 */
public SelectorList parseSelectors(final String source) {
    SelectorList selectors;
    try {
        final CSSErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler();
        final CSSOMParser parser = new CSSOMParser(new CSS3Parser());
        parser.setErrorHandler(errorHandler);
        selectors = parser.parseSelectors(source);
        // in case of error parseSelectors returns null
        if (null == selectors) {
            selectors = new SelectorListImpl();
        }
    } catch (final Throwable t) {
        if (LOG.isErrorEnabled()) {
            LOG.error("Error parsing CSS selectors from '" + source + "': " + t.getMessage(), t);
        }
        selectors = new SelectorListImpl();
    }
    return selectors;
}
Also used : SelectorListImpl(com.gargoylesoftware.css.parser.selector.SelectorListImpl) CSSErrorHandler(com.gargoylesoftware.css.parser.CSSErrorHandler) SelectorList(com.gargoylesoftware.css.parser.selector.SelectorList) CSSOMParser(com.gargoylesoftware.css.parser.CSSOMParser) CSS3Parser(com.gargoylesoftware.css.parser.javacc.CSS3Parser)

Aggregations

SelectorListImpl (com.gargoylesoftware.css.parser.selector.SelectorListImpl)2 CSSErrorHandler (com.gargoylesoftware.css.parser.CSSErrorHandler)1 CSSOMParser (com.gargoylesoftware.css.parser.CSSOMParser)1 CSS3Parser (com.gargoylesoftware.css.parser.javacc.CSS3Parser)1 ChildSelector (com.gargoylesoftware.css.parser.selector.ChildSelector)1 DescendantSelector (com.gargoylesoftware.css.parser.selector.DescendantSelector)1 DirectAdjacentSelector (com.gargoylesoftware.css.parser.selector.DirectAdjacentSelector)1 ElementSelector (com.gargoylesoftware.css.parser.selector.ElementSelector)1 GeneralAdjacentSelector (com.gargoylesoftware.css.parser.selector.GeneralAdjacentSelector)1 PseudoElementSelector (com.gargoylesoftware.css.parser.selector.PseudoElementSelector)1 Selector (com.gargoylesoftware.css.parser.selector.Selector)1 SelectorList (com.gargoylesoftware.css.parser.selector.SelectorList)1 SimpleSelector (com.gargoylesoftware.css.parser.selector.SimpleSelector)1