use of com.gargoylesoftware.htmlunit.javascript.host.html.HTMLLinkElement in project htmlunit by HtmlUnit.
the class HtmlLink method executeEvent.
private void executeEvent(final String type) {
final Object scriptable = getScriptableObject();
final HTMLLinkElement link = (HTMLLinkElement) scriptable;
final Event event = new Event(this, type);
link.executeEventLocally(event);
}
use of com.gargoylesoftware.htmlunit.javascript.host.html.HTMLLinkElement in project htmlunit by HtmlUnit.
the class HtmlLink method onAllChildrenAddedToPage.
/**
* {@inheritDoc}
*/
@Override
public void onAllChildrenAddedToPage(final boolean postponed) {
if (getOwnerDocument() instanceof XmlPage) {
return;
}
if (LOG.isDebugEnabled()) {
LOG.debug("Link node added: " + asXml());
}
if (!isStyleSheetLink()) {
if (LOG.isDebugEnabled()) {
LOG.debug("Link type '" + getRelAttribute() + "' not supported (" + asXml().replaceAll("[\\r\\n]", "") + ").");
}
return;
}
final WebClient webClient = getPage().getWebClient();
if (!webClient.getOptions().isCssEnabled()) {
if (LOG.isDebugEnabled()) {
LOG.debug("Stylesheet Link found but ignored because css support is disabled (" + asXml().replaceAll("[\\r\\n]", "") + ").");
}
return;
}
if (!webClient.isJavaScriptEngineEnabled()) {
if (LOG.isDebugEnabled()) {
LOG.debug("Stylesheet Link found but ignored because javascript engine is disabled (" + asXml().replaceAll("[\\r\\n]", "") + ").");
}
return;
}
final PostponedAction action = new PostponedAction(getPage(), "Loading of link " + this) {
@Override
public void execute() {
final HTMLLinkElement linkElem = HtmlLink.this.getScriptableObject();
// force loading, caching inside the link
linkElem.getSheet();
}
};
final AbstractJavaScriptEngine<?> engine = webClient.getJavaScriptEngine();
if (postponed) {
engine.addPostponedAction(action);
} else {
try {
action.execute();
} catch (final RuntimeException e) {
throw e;
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
}
Aggregations