use of com.gargoylesoftware.css.parser.media.MediaQueryList in project LoboEvolution by LoboEvolution.
the class CSS3Parser method mediaRule.
//
// media
// : MEDIA_SYM S* medium [ COMMA S* medium ]* '{' S* ruleset* '}' S*
// ;
//
public final void mediaRule() throws ParseException {
boolean start = false;
MediaQueryList ml = new MediaQueryList();
Locator locator;
try {
jj_consume_token(MEDIA_SYM);
locator = createLocator(token);
label_9: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case S:
{
;
break;
}
default:
jj_la1[17] = jj_gen;
break label_9;
}
jj_consume_token(S);
}
mediaList(ml);
start = true;
handleStartMedia(ml, locator);
jj_consume_token(LBRACE);
label_10: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case S:
{
;
break;
}
default:
jj_la1[18] = jj_gen;
break label_10;
}
jj_consume_token(S);
}
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case IDENT:
case DOT:
case COLON:
case ASTERISK:
case LSQUARE:
case HASH:
case IMPORT_SYM:
case PAGE_SYM:
case MEDIA_SYM:
case ATKEYWORD:
{
mediaRuleList();
break;
}
default:
jj_la1[19] = jj_gen;
;
}
jj_consume_token(RBRACE);
} catch (CSSParseException e) {
getErrorHandler().error(e);
error_skipblock("ignoringRule", e);
} catch (ParseException e) {
CSSParseException cpe = toCSSParseException("invalidMediaRule", e);
getErrorHandler().error(cpe);
error_skipblock("ignoringRule", cpe);
} finally {
if (start) {
handleEndMedia(ml);
}
}
}
use of com.gargoylesoftware.css.parser.media.MediaQueryList 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
}
}
use of com.gargoylesoftware.css.parser.media.MediaQueryList in project LoboEvolution by LoboEvolution.
the class CSS3Parser method importRule.
//
// import
// : IMPORT_SYM S*
// [STRING|URI] S* [ medium [ COMMA S* medium]* ]? ';' S*
// ;
//
public final void importRule(final boolean nonImportRuleFoundBefore) throws ParseException {
Token t;
MediaQueryList ml = new MediaQueryList();
Locator locator;
try {
ParseException e = null;
if (nonImportRuleFoundBefore) {
e = generateParseException();
}
jj_consume_token(IMPORT_SYM);
locator = createLocator(token);
label_7: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case S:
{
;
break;
}
default:
jj_la1[13] = jj_gen;
break label_7;
}
jj_consume_token(S);
}
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case STRING:
{
t = jj_consume_token(STRING);
break;
}
case URI:
{
t = jj_consume_token(URI);
break;
}
default:
jj_la1[14] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
label_8: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case S:
{
;
break;
}
default:
jj_la1[15] = jj_gen;
break label_8;
}
jj_consume_token(S);
}
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case NOT:
case ONLY:
case IDENT:
case LROUND:
{
mediaList(ml);
break;
}
default:
jj_la1[16] = jj_gen;
;
}
jj_consume_token(SEMICOLON);
if (nonImportRuleFoundBefore) {
getErrorHandler().error(toCSSParseException("invalidImportRuleIgnored2", e));
} else {
handleImportStyle(unescape(t.image, false), ml, null, locator);
}
} catch (CSSParseException e) {
getErrorHandler().error(e);
error_skipAtRule();
} catch (ParseException e) {
getErrorHandler().error(toCSSParseException("invalidImportRule", e));
error_skipAtRule();
}
}
use of com.gargoylesoftware.css.parser.media.MediaQueryList in project LoboEvolution by LoboEvolution.
the class AbstractCSSParser method parseMedia.
/**
* Parse the given input source and return the media list.
* @param source the input source
* @return new media list
* @throws IOException in case of errors
*/
public MediaQueryList parseMedia(final InputSource source) throws IOException {
source_ = source;
ReInit(getCharStream(source));
final MediaQueryList ml = new MediaQueryList();
try {
mediaList(ml);
} catch (final ParseException e) {
getErrorHandler().error(toCSSParseException("invalidMediaList", e));
} catch (final TokenMgrError e) {
getErrorHandler().error(toCSSParseException(e));
} catch (final CSSParseException e) {
getErrorHandler().error(e);
}
return ml;
}
use of com.gargoylesoftware.css.parser.media.MediaQueryList 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());
}
}
Aggregations