use of com.gargoylesoftware.htmlunit.SgmlPage in project htmlunit by HtmlUnit.
the class DomNamespaceNode method processImportNode.
/**
* {@inheritDoc}
*/
@Override
public void processImportNode(final Document doc) {
super.processImportNode(doc);
// if we are importing from a namespace-aware source
// we have to drop the XHtmlNamespace because we did this already
// for the HTML document itself
final SgmlPage page = (SgmlPage) doc.getDomNodeOrDie();
if (page.isHtmlPage() && !(page instanceof XHtmlPage) && Html.XHTML_NAMESPACE.equals(namespaceURI_)) {
namespaceURI_ = null;
}
}
use of com.gargoylesoftware.htmlunit.SgmlPage in project htmlunit by HtmlUnit.
the class HtmlElement method detach.
/**
* <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br>
*
* Detach this node from all relationships with other nodes.
* This is the first step of a move.
*/
@Override
protected void detach() {
final SgmlPage page = getPage();
if (!page.getWebClient().isJavaScriptEngineEnabled()) {
super.detach();
return;
}
final Object document = page.getScriptableObject();
if (document instanceof HTMLDocument) {
final HTMLDocument doc = (HTMLDocument) document;
final Object activeElement = doc.getActiveElement();
if (activeElement == getScriptableObject()) {
doc.setActiveElement(null);
if (hasFeature(HTMLELEMENT_REMOVE_ACTIVE_TRIGGERS_BLUR_EVENT)) {
((HtmlPage) page).setFocusedElement(null);
} else {
((HtmlPage) page).setElementWithFocus(null);
}
} else {
for (final DomNode child : getChildNodes()) {
if (activeElement == child.getScriptableObject()) {
doc.setActiveElement(null);
if (hasFeature(HTMLELEMENT_REMOVE_ACTIVE_TRIGGERS_BLUR_EVENT)) {
((HtmlPage) page).setFocusedElement(null);
} else {
((HtmlPage) page).setElementWithFocus(null);
}
break;
}
}
}
}
super.detach();
}
use of com.gargoylesoftware.htmlunit.SgmlPage in project htmlunit by HtmlUnit.
the class HtmlDateInput method setAttributeNS.
/**
* {@inheritDoc}
*/
@Override
protected void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue, final boolean notifyAttributeChangeListeners, final boolean notifyMutationObservers) {
super.setAttributeNS(namespaceURI, qualifiedName, attributeValue, notifyAttributeChangeListeners, notifyMutationObservers);
if ("value".equals(qualifiedName)) {
final SgmlPage page = getPage();
if (page != null && page.isHtmlPage()) {
int pos = 0;
if (!hasFeature(JS_INPUT_SET_VALUE_MOVE_SELECTION_TO_START)) {
pos = attributeValue.length();
}
setSelectionStart(pos);
setSelectionEnd(pos);
}
}
}
use of com.gargoylesoftware.htmlunit.SgmlPage in project htmlunit by HtmlUnit.
the class Image method jsConstructor.
/**
* JavaScript constructor.
*/
@Override
@JsxConstructor
public void jsConstructor() {
final SgmlPage page = (SgmlPage) getWindow().getWebWindow().getEnclosedPage();
final DomElement fake = page.getWebClient().getPageCreator().getHtmlParser().getFactory(HtmlImage.TAG_NAME).createElement(page, HtmlImage.TAG_NAME, null);
setDomNode(fake);
}
use of com.gargoylesoftware.htmlunit.SgmlPage in project htmlunit by HtmlUnit.
the class HtmlInput method executeOnChangeHandlerIfAppropriate.
/**
* Executes the onchange script code for this element if this is appropriate.
* This means that the element must have an onchange script, script must be enabled
* and the change in the element must not have been triggered by a script.
*
* @param htmlElement the element that contains the onchange attribute
* @return the page that occupies this window after this method completes (may or
* may not be the same as the original page)
*/
static Page executeOnChangeHandlerIfAppropriate(final HtmlElement htmlElement) {
final SgmlPage page = htmlElement.getPage();
final WebClient webClient = page.getWebClient();
if (!webClient.isJavaScriptEngineEnabled()) {
return page;
}
final AbstractJavaScriptEngine<?> engine = webClient.getJavaScriptEngine();
if (engine.isScriptRunning()) {
return page;
}
final ScriptResult scriptResult = htmlElement.fireEvent(Event.TYPE_CHANGE);
if (webClient.containsWebWindow(page.getEnclosingWindow())) {
// may be itself or a newly loaded one
return page.getEnclosingWindow().getEnclosedPage();
}
if (scriptResult != null) {
// current window doesn't exist anymore
return webClient.getCurrentWindow().getEnclosedPage();
}
return page;
}
Aggregations