use of com.gargoylesoftware.css.dom.MediaListImpl in project htmlunit by HtmlUnit.
the class CSSMediaRule method getMedia.
/**
* Returns the media types that the imported CSS style sheet applies to.
* @return the media types that the imported CSS style sheet applies to
*/
@JsxGetter
public MediaList getMedia() {
if (media_ == null) {
final CSSStyleSheet parent = getParentStyleSheet();
final MediaListImpl ml = getMediaRule().getMediaList();
media_ = new MediaList(parent, ml);
}
return media_;
}
use of com.gargoylesoftware.css.dom.MediaListImpl in project LoboEvolution by LoboEvolution.
the class MediaQueryListImpl method isMatches.
/**
* <p>isMatches.</p>
*
* @return a boolean.
* @throws java.lang.Exception if any.
*/
public boolean isMatches() throws Exception {
final String processedText = CSSUtilities.preProcessCss(media);
MediaListImpl media = CSSUtilities.parseMedia(processedText);
return StyleSheetAggregator.isActive(window, media);
}
use of com.gargoylesoftware.css.dom.MediaListImpl in project htmlunit by HtmlUnit.
the class CSSStyleSheet method parseMedia.
/**
* Parses the given media string. If anything at all goes wrong, this
* method returns an empty MediaList list.
*
* @param source the source from which to retrieve the media to be parsed
* @return the media parsed from the specified input source
*/
static MediaListImpl parseMedia(final CSSErrorHandler errorHandler, final String mediaString) {
MediaListImpl media = media_.get(mediaString);
if (media != null) {
return media;
}
try {
final CSSOMParser parser = new CSSOMParser(new CSS3Parser());
parser.setErrorHandler(errorHandler);
media = new MediaListImpl(parser.parseMedia(mediaString));
media_.put(mediaString, media);
return media;
} catch (final Exception e) {
if (LOG.isErrorEnabled()) {
LOG.error("Error parsing CSS media from '" + mediaString + "': " + e.getMessage(), e);
}
}
media = new MediaListImpl(null);
media_.put(mediaString, media);
return media;
}
use of com.gargoylesoftware.css.dom.MediaListImpl in project htmlunit by HtmlUnit.
the class CSSImportRule method getMedia.
/**
* Returns the media types that the imported CSS style sheet applies to.
* @return the media types that the imported CSS style sheet applies to
*/
@JsxGetter
public MediaList getMedia() {
if (media_ == null) {
final CSSStyleSheet parent = getParentStyleSheet();
final MediaListImpl ml = getImportRule().getMedia();
media_ = new MediaList(parent, ml);
}
return media_;
}
Aggregations