Package org.htmlunit.html
Class DomElement
- java.lang.Object
-
- org.htmlunit.html.DomNode
-
- org.htmlunit.html.DomNamespaceNode
-
- org.htmlunit.html.DomElement
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,org.w3c.dom.Element
,org.w3c.dom.Node
- Direct Known Subclasses:
HtmlElement
public class DomElement extends DomNamespaceNode implements org.w3c.dom.Element
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
DomElement.ChildElementsIterator
An iterator over the DomElement children.-
Nested classes/interfaces inherited from class org.htmlunit.html.DomNode
DomNode.ChildIterator, DomNode.DescendantElementsIterator<T extends DomNode>
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ATTRIBUTE_NOT_DEFINED
Constant meaning that the specified attribute was not defined.static java.lang.String
ATTRIBUTE_VALUE_EMPTY
Constant meaning that the specified attribute was found but its value was empty.static java.lang.String
ID_ATTRIBUTE
id.static java.lang.String
NAME_ATTRIBUTE
name.static java.lang.String
SRC_ATTRIBUTE
src.static java.lang.String
TYPE_ATTRIBUTE
type.static java.lang.String
VALUE_ATTRIBUTE
value.-
Fields inherited from class org.htmlunit.html.DomNode
PROPERTY_ELEMENT, READY_STATE_COMPLETE, READY_STATE_INTERACTIVE, READY_STATE_LOADED, READY_STATE_LOADING, READY_STATE_UNINITIALIZED
-
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
-
-
Constructor Summary
Constructors Constructor Description DomElement(java.lang.String namespaceURI, java.lang.String qualifiedName, SgmlPage page, java.util.Map<java.lang.String,DomAttr> attributes)
Creates an instance of a DOM element that can have a namespace.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
blur()
Removes focus from this element.<P extends Page>
Pclick()
Simulates clicking on this element, returning the page in the window that has the focus after the element has been clicked.<P extends Page>
Pclick(boolean shiftKey, boolean ctrlKey, boolean altKey)
Simulates clicking on this element, returning the page in the window that has the focus after the element has been clicked.<P extends Page>
Pclick(boolean shiftKey, boolean ctrlKey, boolean altKey, boolean triggerMouseEvents)
Simulates clicking on this element, returning the page in the window that has the focus after the element has been clicked.<P extends Page>
Pclick(boolean shiftKey, boolean ctrlKey, boolean altKey, boolean triggerMouseEvents, boolean handleFocus, boolean ignoreVisibility, boolean disableProcessLabelAfterBubbling)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Simulates clicking on this element, returning the page in the window that has the focus after the element has been clicked.<P extends Page>
Pclick(org.htmlunit.javascript.host.event.Event event, boolean shiftKey, boolean ctrlKey, boolean altKey, boolean ignoreVisibility)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Simulates clicking on this element, returning the page in the window that has the focus after the element has been clicked.DomNode
cloneNode(boolean deep)
<P extends Page>
PdblClick()
Simulates double-clicking on this element, returning the page in the window that has the focus after the element has been clicked.<P extends Page>
PdblClick(boolean shiftKey, boolean ctrlKey, boolean altKey)
Simulates double-clicking on this element, returning the page in the window that has the focus after the element has been clicked.protected void
doClickFireChangeEvent()
This method implements the control onchange handler call during the click action.protected ScriptResult
doClickFireClickEvent(org.htmlunit.javascript.host.event.Event event)
This method implements the control onclick handler call during the click action.protected boolean
doClickStateUpdate(boolean shiftKey, boolean ctrlKey)
This method implements the control state update part of the click action.ScriptResult
fireEvent(java.lang.String eventType)
ScriptResult
fireEvent(org.htmlunit.javascript.host.event.Event event)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Fires the event on the element.void
focus()
Sets the focus on this element.java.lang.String
getAttribute(java.lang.String attributeName)
Returns the value of the attribute specified by name or an empty string.java.lang.String
getAttributeDirect(java.lang.String attributeName)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.DomAttr
getAttributeNode(java.lang.String name)
DomAttr
getAttributeNodeNS(java.lang.String namespaceURI, java.lang.String localName)
java.lang.String
getAttributeNS(java.lang.String namespaceURI, java.lang.String localName)
Returns the value of the attribute specified by namespace and local name or an empty string.org.w3c.dom.NamedNodeMap
getAttributes()
java.util.Map<java.lang.String,DomAttr>
getAttributesMap()
Returns the map holding the attributes, keyed by name.int
getChildElementCount()
Returns the current number of element nodes that are children of this element.java.lang.Iterable<DomElement>
getChildElements()
DomNodeList<HtmlElement>
getElementsByTagName(java.lang.String tagName)
DomNodeList<HtmlElement>
getElementsByTagNameNS(java.lang.String namespace, java.lang.String localName)
Not yet implemented.protected DomNode
getEventTargetElement()
Returns the event target element.DomElement
getFirstElementChild()
Returns the first child element node of this element. null if this element has no child elements.java.lang.String
getId()
DomElement
getLastElementChild()
Returns the last child element node of this element. null if this element has no child elements.java.lang.String
getNodeName()
short
getNodeType()
org.w3c.dom.TypeInfo
getSchemaTypeInfo()
Not yet implemented.org.htmlunit.css.StyleElement
getStyleElement(java.lang.String name)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Determines the StyleElement for the given name.org.htmlunit.css.StyleElement
getStyleElementCaseInSensitive(java.lang.String name)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Determines the StyleElement for the given name.java.util.LinkedHashMap<java.lang.String,org.htmlunit.css.StyleElement>
getStyleMap()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Returns a sorted map containing style elements, keyed on style element name.java.lang.String
getTagName()
Returns the tag name of this element.boolean
hasAttribute(java.lang.String attributeName)
Returns whether the attribute specified by name has a value.boolean
hasAttributeNS(java.lang.String namespaceURI, java.lang.String localName)
Returns whether the attribute specified by namespace and local name has a value.boolean
hasAttributes()
protected boolean
isAttributeCaseSensitive()
Indicates if the attribute names are case sensitive.protected boolean
isDisabledElementAndDisabled()
protected boolean
isEmptyXmlTagExpanded()
Indicates if a node without children should be written in expanded form as XML (i.e. with closing tag rather than with "/>")boolean
isMouseOver()
Returns whether the Mouse is currently over this element or not.protected boolean
isStateUpdateFirst()
Returnstrue
if state updates should be done before onclick event handling.boolean
matches(java.lang.String selectorString)
Returns true if the element would be selected by the specified selector string; otherwise, returns false.Page
mouseDown()
Simulates clicking the mouse on this element, returning the page which this element's window contains after the mouse click.Page
mouseDown(boolean shiftKey, boolean ctrlKey, boolean altKey, int button)
Simulates clicking the mouse on this element, returning the page which this element's window contains after the mouse click.Page
mouseMove()
Simulates moving the mouse over this element, returning the page which this element's window contains after the mouse move.Page
mouseMove(boolean shiftKey, boolean ctrlKey, boolean altKey, int button)
Simulates moving the mouse over this element, returning the page which this element's window contains after the mouse move.Page
mouseOut()
Simulates moving the mouse out of this element, returning the page which this element's window contains after the mouse move.Page
mouseOut(boolean shiftKey, boolean ctrlKey, boolean altKey, int button)
Simulates moving the mouse out of this element, returning the page which this element's window contains after the mouse move.Page
mouseOver()
Simulates moving the mouse over this element, returning the page which this element's window contains after the mouse move.Page
mouseOver(boolean shiftKey, boolean ctrlKey, boolean altKey, int button)
Simulates moving the mouse over this element, returning the page which this element's window contains after the mouse move.Page
mouseUp()
Simulates releasing the mouse click on this element, returning the page which this element's window contains after the mouse click release.Page
mouseUp(boolean shiftKey, boolean ctrlKey, boolean altKey, int button)
Simulates releasing the mouse click on this element, returning the page which this element's window contains after the mouse click release.protected void
preventDefault()
This method is called if the current fired event is canceled bypreventDefault()
in FireFox, or by returningfalse
in Internet Explorer.protected void
printOpeningTagContentAsXml(java.io.PrintWriter printWriter)
Prints the content between "<" and ">" (or "/>") in the output of the tag name and its attributes in XML format.protected void
printXml(java.lang.String indent, java.io.PrintWriter printWriter)
Recursively write the XML data for the node tree starting atnode
.protected boolean
propagateClickStateUpdateToParent()
void
removeAttribute(java.lang.String attributeName)
Removes an attribute specified by name from this element.org.w3c.dom.Attr
removeAttributeNode(org.w3c.dom.Attr attribute)
Not yet implemented.void
removeAttributeNS(java.lang.String namespaceURI, java.lang.String localName)
Removes an attribute specified by namespace and local name from this element.void
removeFocus()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Gets notified that it has lost the focus.java.lang.String
removeStyleAttribute(java.lang.String name)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Removes the specified style attribute, returning the value of the removed attribute.void
replaceStyleAttribute(java.lang.String name, java.lang.String value, java.lang.String priority)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Replaces the value of the named style attribute.Page
rightClick()
Simulates right clicking the mouse on this element, returning the page which this element's window contains after the mouse click.Page
rightClick(boolean shiftKey, boolean ctrlKey, boolean altKey)
Simulates right clicking the mouse on this element, returning the page which this element's window contains after the mouse click.void
setAttribute(java.lang.String attributeName, java.lang.String attributeValue)
Sets the value of the attribute specified by name.org.w3c.dom.Attr
setAttributeNode(org.w3c.dom.Attr attribute)
org.w3c.dom.Attr
setAttributeNodeNS(org.w3c.dom.Attr attribute)
Not yet implemented.void
setAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.String attributeValue)
Sets the value of the attribute specified by namespace and qualified name.protected void
setAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.String attributeValue, boolean notifyAttributeChangeListeners, boolean notifyMutationObservers)
Sets the value of the attribute specified by namespace and qualified name.void
setDefaults(org.htmlunit.css.ComputedCssStyleDeclaration style)
Callback method which allows different HTML element types to perform custom initialization of computed styles.void
setId(java.lang.String newId)
Sets the identifier this element.void
setIdAttribute(java.lang.String name, boolean isId)
Not yet implemented.void
setIdAttributeNode(org.w3c.dom.Attr idAttr, boolean isId)
Not yet implemented.void
setIdAttributeNS(java.lang.String namespaceURI, java.lang.String localName, boolean isId)
Not yet implemented.void
setInnerHtml(java.lang.String source)
Replaces all child elements of this element with the supplied value parsed as html.void
setNodeValue(java.lang.String value)
java.lang.String
toString()
Returns a string representation of this element.void
writeStyleToElement(java.util.Map<java.lang.String,org.htmlunit.css.StyleElement> styleMap)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.-
Methods inherited from class org.htmlunit.html.DomNamespaceNode
getLocalName, getLowercaseName, getNamespaceURI, getPrefix, getQualifiedName, processImportNode, setPrefix
-
Methods inherited from class org.htmlunit.html.DomNode
addCharacterDataChangeListener, addDomChangeListener, appendChild, asNormalizedText, asXml, basicRemove, checkChildHierarchy, closest, compareDocumentPosition, detach, fireCharacterDataChanged, fireNodeAdded, fireNodeDeleted, getAncestors, getBaseURI, getByXPath, getByXPath, getCanonicalXPath, getChildNodes, getChildren, getDescendants, getDomElementDescendants, getEndColumnNumber, getEndLineNumber, getFeature, getFirstByXPath, getFirstByXPath, getFirstChild, getHtmlElementDescendants, getHtmlPageOrNull, getIndex, getLastChild, getNextElementSibling, getNextSibling, getNodeValue, getOwnerDocument, getPage, getParentNode, getPreviousElementSibling, getPreviousSibling, getReadyState, getScriptableObject, getSelectorList, getStartColumnNumber, getStartLineNumber, getTextContent, getUserData, getVisibleText, handles, hasChildNodes, hasFeature, insertBefore, insertBefore, isAncestorOf, isAncestorOfAny, isAttachedToPage, isDefaultNamespace, isDisplayed, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, mayBeDisplayed, normalize, notifyIncorrectness, onAddedToDocumentFragment, onAddedToPage, onAllChildrenAddedToPage, parseHtmlSnippet, printChildrenAsXml, querySelector, querySelectorAll, quietlyRemoveAndMoveChildrenTo, remove, removeAllChildren, removeCharacterDataChangeListener, removeChild, removeDomChangeListener, replace, replaceChild, setEndLocation, setParentNode, setReadyState, setScriptableObject, setStartLocation, setTextContent, setUserData
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.w3c.dom.Node
appendChild, compareDocumentPosition, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setPrefix, setTextContent, setUserData
-
-
-
-
Field Detail
-
ID_ATTRIBUTE
public static final java.lang.String ID_ATTRIBUTE
id.- See Also:
- Constant Field Values
-
NAME_ATTRIBUTE
public static final java.lang.String NAME_ATTRIBUTE
name.- See Also:
- Constant Field Values
-
SRC_ATTRIBUTE
public static final java.lang.String SRC_ATTRIBUTE
src.- See Also:
- Constant Field Values
-
VALUE_ATTRIBUTE
public static final java.lang.String VALUE_ATTRIBUTE
value.- See Also:
- Constant Field Values
-
TYPE_ATTRIBUTE
public static final java.lang.String TYPE_ATTRIBUTE
type.- See Also:
- Constant Field Values
-
ATTRIBUTE_NOT_DEFINED
public static final java.lang.String ATTRIBUTE_NOT_DEFINED
Constant meaning that the specified attribute was not defined.
-
ATTRIBUTE_VALUE_EMPTY
public static final java.lang.String ATTRIBUTE_VALUE_EMPTY
Constant meaning that the specified attribute was found but its value was empty.
-
-
Constructor Detail
-
DomElement
public DomElement(java.lang.String namespaceURI, java.lang.String qualifiedName, SgmlPage page, java.util.Map<java.lang.String,DomAttr> attributes)
Creates an instance of a DOM element that can have a namespace.- Parameters:
namespaceURI
- the URI that identifies an XML namespacequalifiedName
- the qualified name of the element type to instantiatepage
- the page that contains this elementattributes
- a map ready initialized with the attributes for this element, ornull
. The map will be stored as is, not copied.
-
-
Method Detail
-
getNodeName
public java.lang.String getNodeName()
- Specified by:
getNodeName
in interfaceorg.w3c.dom.Node
-
getNodeType
public final short getNodeType()
- Specified by:
getNodeType
in interfaceorg.w3c.dom.Node
-
getTagName
public final java.lang.String getTagName()
Returns the tag name of this element.- Specified by:
getTagName
in interfaceorg.w3c.dom.Element
- Returns:
- the tag name of this element
-
hasAttributes
public final boolean hasAttributes()
- Specified by:
hasAttributes
in interfaceorg.w3c.dom.Node
- Overrides:
hasAttributes
in classDomNode
-
hasAttribute
public boolean hasAttribute(java.lang.String attributeName)
Returns whether the attribute specified by name has a value.- Specified by:
hasAttribute
in interfaceorg.w3c.dom.Element
- Parameters:
attributeName
- the name of the attribute- Returns:
- true if an attribute with the given name is specified on this element or has a default value, false otherwise.
-
replaceStyleAttribute
public void replaceStyleAttribute(java.lang.String name, java.lang.String value, java.lang.String priority)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Replaces the value of the named style attribute. If there is no style attribute with the specified name, a new one is added. If the specified value is an empty (or all whitespace) string, this method actually removes the named style attribute.- Parameters:
name
- the attribute name (delimiter-separated, not camel-cased)value
- the attribute valuepriority
- the new priority of the property;"important"
or the empty string if none.
-
removeStyleAttribute
public java.lang.String removeStyleAttribute(java.lang.String name)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Removes the specified style attribute, returning the value of the removed attribute.- Parameters:
name
- the attribute name (delimiter-separated, not camel-cased)- Returns:
- the removed value
-
getStyleElement
public org.htmlunit.css.StyleElement getStyleElement(java.lang.String name)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Determines the StyleElement for the given name.- Parameters:
name
- the name of the requested StyleElement- Returns:
- the StyleElement or null if not found
-
getStyleElementCaseInSensitive
public org.htmlunit.css.StyleElement getStyleElementCaseInSensitive(java.lang.String name)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Determines the StyleElement for the given name. This ignores the case of the name.- Parameters:
name
- the name of the requested StyleElement- Returns:
- the StyleElement or null if not found
-
getStyleMap
public java.util.LinkedHashMap<java.lang.String,org.htmlunit.css.StyleElement> getStyleMap()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Returns a sorted map containing style elements, keyed on style element name. We use aLinkedHashMap
map so that results are deterministic and are thus testable.- Returns:
- a sorted map containing style elements, keyed on style element name
-
printOpeningTagContentAsXml
protected void printOpeningTagContentAsXml(java.io.PrintWriter printWriter)
Prints the content between "<" and ">" (or "/>") in the output of the tag name and its attributes in XML format.- Parameters:
printWriter
- the writer to print in
-
printXml
protected void printXml(java.lang.String indent, java.io.PrintWriter printWriter)
Recursively write the XML data for the node tree starting atnode
.
-
isEmptyXmlTagExpanded
protected boolean isEmptyXmlTagExpanded()
Indicates if a node without children should be written in expanded form as XML (i.e. with closing tag rather than with "/>")- Returns:
false
by default
-
getAttribute
public java.lang.String getAttribute(java.lang.String attributeName)
Returns the value of the attribute specified by name or an empty string. If the result is an empty string then it will be eitherATTRIBUTE_NOT_DEFINED
if the attribute wasn't specified orATTRIBUTE_VALUE_EMPTY
if the attribute was specified but it was empty.- Specified by:
getAttribute
in interfaceorg.w3c.dom.Element
- Parameters:
attributeName
- the name of the attribute- Returns:
- the value of the attribute or
ATTRIBUTE_NOT_DEFINED
orATTRIBUTE_VALUE_EMPTY
-
getAttributeDirect
public java.lang.String getAttributeDirect(java.lang.String attributeName)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.- Parameters:
attributeName
- the name of the attribute- Returns:
- the value of the attribute or
ATTRIBUTE_NOT_DEFINED
orATTRIBUTE_VALUE_EMPTY
-
removeAttribute
public void removeAttribute(java.lang.String attributeName)
Removes an attribute specified by name from this element.- Specified by:
removeAttribute
in interfaceorg.w3c.dom.Element
- Parameters:
attributeName
- the attribute attributeName
-
removeAttributeNS
public final void removeAttributeNS(java.lang.String namespaceURI, java.lang.String localName)
Removes an attribute specified by namespace and local name from this element.- Specified by:
removeAttributeNS
in interfaceorg.w3c.dom.Element
- Parameters:
namespaceURI
- the URI that identifies an XML namespacelocalName
- the name within the namespace
-
removeAttributeNode
public final org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr attribute)
Not yet implemented.- Specified by:
removeAttributeNode
in interfaceorg.w3c.dom.Element
-
hasAttributeNS
public final boolean hasAttributeNS(java.lang.String namespaceURI, java.lang.String localName)
Returns whether the attribute specified by namespace and local name has a value.- Specified by:
hasAttributeNS
in interfaceorg.w3c.dom.Element
- Parameters:
namespaceURI
- the URI that identifies an XML namespacelocalName
- the name within the namespace- Returns:
- true if an attribute with the given name is specified on this element or has a default value, false otherwise.
-
getAttributesMap
public final java.util.Map<java.lang.String,DomAttr> getAttributesMap()
Returns the map holding the attributes, keyed by name.- Returns:
- the attributes map
-
getAttributes
public org.w3c.dom.NamedNodeMap getAttributes()
- Specified by:
getAttributes
in interfaceorg.w3c.dom.Node
- Overrides:
getAttributes
in classDomNode
-
setAttribute
public void setAttribute(java.lang.String attributeName, java.lang.String attributeValue)
Sets the value of the attribute specified by name.- Specified by:
setAttribute
in interfaceorg.w3c.dom.Element
- Parameters:
attributeName
- the name of the attributeattributeValue
- the value of the attribute
-
setAttributeNS
public void setAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.String attributeValue)
Sets the value of the attribute specified by namespace and qualified name.- Specified by:
setAttributeNS
in interfaceorg.w3c.dom.Element
- Parameters:
namespaceURI
- the URI that identifies an XML namespacequalifiedName
- the qualified name (prefix:local) of the attributeattributeValue
- the value of the attribute
-
setAttributeNS
protected void setAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.String attributeValue, boolean notifyAttributeChangeListeners, boolean notifyMutationObservers)
Sets the value of the attribute specified by namespace and qualified name.- Parameters:
namespaceURI
- the URI that identifies an XML namespacequalifiedName
- the qualified name (prefix:local) of the attributeattributeValue
- the value of the attributenotifyAttributeChangeListeners
- to notify the associatedHtmlAttributeChangeListener
snotifyMutationObservers
- to notifyMutationObserver
s or not
-
isAttributeCaseSensitive
protected boolean isAttributeCaseSensitive()
Indicates if the attribute names are case sensitive.- Returns:
true
-
getAttributeNS
public final java.lang.String getAttributeNS(java.lang.String namespaceURI, java.lang.String localName)
Returns the value of the attribute specified by namespace and local name or an empty string. If the result is an empty string then it will be eitherATTRIBUTE_NOT_DEFINED
if the attribute wasn't specified orATTRIBUTE_VALUE_EMPTY
if the attribute was specified but it was empty.- Specified by:
getAttributeNS
in interfaceorg.w3c.dom.Element
- Parameters:
namespaceURI
- the URI that identifies an XML namespacelocalName
- the name within the namespace- Returns:
- the value of the attribute or
ATTRIBUTE_NOT_DEFINED
orATTRIBUTE_VALUE_EMPTY
-
getAttributeNode
public DomAttr getAttributeNode(java.lang.String name)
- Specified by:
getAttributeNode
in interfaceorg.w3c.dom.Element
-
getAttributeNodeNS
public DomAttr getAttributeNodeNS(java.lang.String namespaceURI, java.lang.String localName)
- Specified by:
getAttributeNodeNS
in interfaceorg.w3c.dom.Element
-
writeStyleToElement
public void writeStyleToElement(java.util.Map<java.lang.String,org.htmlunit.css.StyleElement> styleMap)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.- Parameters:
styleMap
- the styles
-
getElementsByTagName
public DomNodeList<HtmlElement> getElementsByTagName(java.lang.String tagName)
- Specified by:
getElementsByTagName
in interfaceorg.w3c.dom.Element
-
getElementsByTagNameNS
public DomNodeList<HtmlElement> getElementsByTagNameNS(java.lang.String namespace, java.lang.String localName)
Not yet implemented.- Specified by:
getElementsByTagNameNS
in interfaceorg.w3c.dom.Element
-
getSchemaTypeInfo
public org.w3c.dom.TypeInfo getSchemaTypeInfo()
Not yet implemented.- Specified by:
getSchemaTypeInfo
in interfaceorg.w3c.dom.Element
-
setIdAttribute
public void setIdAttribute(java.lang.String name, boolean isId)
Not yet implemented.- Specified by:
setIdAttribute
in interfaceorg.w3c.dom.Element
-
setIdAttributeNS
public void setIdAttributeNS(java.lang.String namespaceURI, java.lang.String localName, boolean isId)
Not yet implemented.- Specified by:
setIdAttributeNS
in interfaceorg.w3c.dom.Element
-
setAttributeNode
public org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr attribute)
- Specified by:
setAttributeNode
in interfaceorg.w3c.dom.Element
-
setAttributeNodeNS
public org.w3c.dom.Attr setAttributeNodeNS(org.w3c.dom.Attr attribute)
Not yet implemented.- Specified by:
setAttributeNodeNS
in interfaceorg.w3c.dom.Element
-
setIdAttributeNode
public final void setIdAttributeNode(org.w3c.dom.Attr idAttr, boolean isId)
Not yet implemented.- Specified by:
setIdAttributeNode
in interfaceorg.w3c.dom.Element
-
cloneNode
public DomNode cloneNode(boolean deep)
-
getId
public final java.lang.String getId()
- Returns:
- the identifier of this element
-
setId
public final void setId(java.lang.String newId)
Sets the identifier this element.- Parameters:
newId
- the new identifier of this element
-
getFirstElementChild
public DomElement getFirstElementChild()
Returns the first child element node of this element. null if this element has no child elements.- Returns:
- the first child element node of this element. null if this element has no child elements
-
getLastElementChild
public DomElement getLastElementChild()
Returns the last child element node of this element. null if this element has no child elements.- Returns:
- the last child element node of this element. null if this element has no child elements
-
getChildElementCount
public int getChildElementCount()
Returns the current number of element nodes that are children of this element.- Returns:
- the current number of element nodes that are children of this element.
-
getChildElements
public final java.lang.Iterable<DomElement> getChildElements()
- Returns:
- an Iterable over the DomElement children of this object, i.e. excluding the non-element nodes
-
toString
public java.lang.String toString()
Returns a string representation of this element.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string representation of this element
-
click
public <P extends Page> P click() throws java.io.IOException
Simulates clicking on this element, returning the page in the window that has the focus after the element has been clicked. Note that the returned page may or may not be the same as the original page, depending on the type of element being clicked, the presence of JavaScript action listeners, etc.
This only clicks the element if it is visible and enabled (isDisplayed() & !isDisabled()). In case the element is not visible and/or disabled, only a log output is generated.
If you circumvent the visible/disabled check use click(shiftKey, ctrlKey, altKey, true, true, false)- Type Parameters:
P
- the page type- Returns:
- the page contained in the current window as returned by
WebClient.getCurrentWindow()
- Throws:
java.io.IOException
- if an IO error occurs
-
click
public <P extends Page> P click(boolean shiftKey, boolean ctrlKey, boolean altKey) throws java.io.IOException
Simulates clicking on this element, returning the page in the window that has the focus after the element has been clicked. Note that the returned page may or may not be the same as the original page, depending on the type of element being clicked, the presence of JavaScript action listeners, etc.
This only clicks the element if it is visible and enabled (isDisplayed() & !isDisabled()). In case the element is not visible and/or disabled, only a log output is generated.
If you circumvent the visible/disabled check use click(shiftKey, ctrlKey, altKey, true, true, false)- Type Parameters:
P
- the page type- Parameters:
shiftKey
-true
if SHIFT is pressed during the clickctrlKey
-true
if CTRL is pressed during the clickaltKey
-true
if ALT is pressed during the click- Returns:
- the page contained in the current window as returned by
WebClient.getCurrentWindow()
- Throws:
java.io.IOException
- if an IO error occurs
-
click
public <P extends Page> P click(boolean shiftKey, boolean ctrlKey, boolean altKey, boolean triggerMouseEvents) throws java.io.IOException
Simulates clicking on this element, returning the page in the window that has the focus after the element has been clicked. Note that the returned page may or may not be the same as the original page, depending on the type of element being clicked, the presence of JavaScript action listeners, etc.
This only clicks the element if it is visible and enabled (isDisplayed() & !isDisabled()). In case the element is not visible and/or disabled, only a log output is generated.
If you circumvent the visible/disabled check use click(shiftKey, ctrlKey, altKey, true, true, false)- Type Parameters:
P
- the page type- Parameters:
shiftKey
-true
if SHIFT is pressed during the clickctrlKey
-true
if CTRL is pressed during the clickaltKey
-true
if ALT is pressed during the clicktriggerMouseEvents
- if true trigger the mouse events also- Returns:
- the page contained in the current window as returned by
WebClient.getCurrentWindow()
- Throws:
java.io.IOException
- if an IO error occurs
-
isDisabledElementAndDisabled
protected boolean isDisabledElementAndDisabled()
- Returns:
- true if this is an
DisabledElement
and disabled
-
click
public <P extends Page> P click(boolean shiftKey, boolean ctrlKey, boolean altKey, boolean triggerMouseEvents, boolean handleFocus, boolean ignoreVisibility, boolean disableProcessLabelAfterBubbling) throws java.io.IOException
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Simulates clicking on this element, returning the page in the window that has the focus after the element has been clicked. Note that the returned page may or may not be the same as the original page, depending on the type of element being clicked, the presence of JavaScript action listeners, etc.- Type Parameters:
P
- the page type- Parameters:
shiftKey
-true
if SHIFT is pressed during the clickctrlKey
-true
if CTRL is pressed during the clickaltKey
-true
if ALT is pressed during the clicktriggerMouseEvents
- if true trigger the mouse events alsohandleFocus
- if true set the focus (and trigger the event)ignoreVisibility
- whether to ignore visibility or notdisableProcessLabelAfterBubbling
- ignore label processing- Returns:
- the page contained in the current window as returned by
WebClient.getCurrentWindow()
- Throws:
java.io.IOException
- if an IO error occurs
-
getEventTargetElement
protected DomNode getEventTargetElement()
Returns the event target element. This could be overridden by subclasses to have other targets. The default implementation returns 'this'.- Returns:
- the event target element.
-
click
public <P extends Page> P click(org.htmlunit.javascript.host.event.Event event, boolean shiftKey, boolean ctrlKey, boolean altKey, boolean ignoreVisibility) throws java.io.IOException
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Simulates clicking on this element, returning the page in the window that has the focus after the element has been clicked. Note that the returned page may or may not be the same as the original page, depending on the type of element being clicked, the presence of JavaScript action listeners, etc.- Type Parameters:
P
- the page type- Parameters:
event
- the click event usedshiftKey
-true
if SHIFT is pressed during the clickctrlKey
-true
if CTRL is pressed during the clickaltKey
-true
if ALT is pressed during the clickignoreVisibility
- whether to ignore visibility or not- Returns:
- the page contained in the current window as returned by
WebClient.getCurrentWindow()
- Throws:
java.io.IOException
- if an IO error occurs
-
doClickStateUpdate
protected boolean doClickStateUpdate(boolean shiftKey, boolean ctrlKey) throws java.io.IOException
This method implements the control state update part of the click action.The default implementation only calls doClickStateUpdate on parent's DomElement (if any). Subclasses requiring different behavior (like
HtmlSubmitInput
) will override this method.- Parameters:
shiftKey
-true
if SHIFT is pressedctrlKey
-true
if CTRL is pressed- Returns:
- true if doClickFireEvent method has to be called later on (to signal, that the value was changed)
- Throws:
java.io.IOException
- if an IO error occurs
-
propagateClickStateUpdateToParent
protected boolean propagateClickStateUpdateToParent()
- Returns:
- true or false
- See Also:
Usually the click is propagated to the parent. Overwrite if you like to disable this.
-
doClickFireChangeEvent
protected void doClickFireChangeEvent()
This method implements the control onchange handler call during the click action.
-
doClickFireClickEvent
protected ScriptResult doClickFireClickEvent(org.htmlunit.javascript.host.event.Event event)
This method implements the control onclick handler call during the click action.- Parameters:
event
- the click event used- Returns:
- the script result
-
dblClick
public <P extends Page> P dblClick() throws java.io.IOException
Simulates double-clicking on this element, returning the page in the window that has the focus after the element has been clicked. Note that the returned page may or may not be the same as the original page, depending on the type of element being clicked, the presence of JavaScript action listeners, etc. Note also thatclick()
is automatically called first.- Type Parameters:
P
- the page type- Returns:
- the page that occupies this element's window after the element has been double-clicked
- Throws:
java.io.IOException
- if an IO error occurs
-
dblClick
public <P extends Page> P dblClick(boolean shiftKey, boolean ctrlKey, boolean altKey) throws java.io.IOException
Simulates double-clicking on this element, returning the page in the window that has the focus after the element has been clicked. Note that the returned page may or may not be the same as the original page, depending on the type of element being clicked, the presence of JavaScript action listeners, etc. Note also thatclick(boolean, boolean, boolean)
is automatically called first.- Type Parameters:
P
- the page type- Parameters:
shiftKey
-true
if SHIFT is pressed during the double-clickctrlKey
-true
if CTRL is pressed during the double-clickaltKey
-true
if ALT is pressed during the double-click- Returns:
- the page that occupies this element's window after the element has been double-clicked
- Throws:
java.io.IOException
- if an IO error occurs
-
mouseOver
public Page mouseOver()
Simulates moving the mouse over this element, returning the page which this element's window contains after the mouse move. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.- Returns:
- the page which this element's window contains after the mouse move
-
mouseOver
public Page mouseOver(boolean shiftKey, boolean ctrlKey, boolean altKey, int button)
Simulates moving the mouse over this element, returning the page which this element's window contains after the mouse move. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.- Parameters:
shiftKey
-true
if SHIFT is pressed during the mouse movectrlKey
-true
if CTRL is pressed during the mouse movealtKey
-true
if ALT is pressed during the mouse movebutton
- the button code, must beMouseEvent.BUTTON_LEFT
,MouseEvent.BUTTON_MIDDLE
orMouseEvent.BUTTON_RIGHT
- Returns:
- the page which this element's window contains after the mouse move
-
mouseMove
public Page mouseMove()
Simulates moving the mouse over this element, returning the page which this element's window contains after the mouse move. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.- Returns:
- the page which this element's window contains after the mouse move
-
mouseMove
public Page mouseMove(boolean shiftKey, boolean ctrlKey, boolean altKey, int button)
Simulates moving the mouse over this element, returning the page which this element's window contains after the mouse move. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.- Parameters:
shiftKey
-true
if SHIFT is pressed during the mouse movectrlKey
-true
if CTRL is pressed during the mouse movealtKey
-true
if ALT is pressed during the mouse movebutton
- the button code, must beMouseEvent.BUTTON_LEFT
,MouseEvent.BUTTON_MIDDLE
orMouseEvent.BUTTON_RIGHT
- Returns:
- the page which this element's window contains after the mouse move
-
mouseOut
public Page mouseOut()
Simulates moving the mouse out of this element, returning the page which this element's window contains after the mouse move. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.- Returns:
- the page which this element's window contains after the mouse move
-
mouseOut
public Page mouseOut(boolean shiftKey, boolean ctrlKey, boolean altKey, int button)
Simulates moving the mouse out of this element, returning the page which this element's window contains after the mouse move. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.- Parameters:
shiftKey
-true
if SHIFT is pressed during the mouse movectrlKey
-true
if CTRL is pressed during the mouse movealtKey
-true
if ALT is pressed during the mouse movebutton
- the button code, must beMouseEvent.BUTTON_LEFT
,MouseEvent.BUTTON_MIDDLE
orMouseEvent.BUTTON_RIGHT
- Returns:
- the page which this element's window contains after the mouse move
-
mouseDown
public Page mouseDown()
Simulates clicking the mouse on this element, returning the page which this element's window contains after the mouse click. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.- Returns:
- the page which this element's window contains after the mouse click
-
mouseDown
public Page mouseDown(boolean shiftKey, boolean ctrlKey, boolean altKey, int button)
Simulates clicking the mouse on this element, returning the page which this element's window contains after the mouse click. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.- Parameters:
shiftKey
-true
if SHIFT is pressed during the mouse clickctrlKey
-true
if CTRL is pressed during the mouse clickaltKey
-true
if ALT is pressed during the mouse clickbutton
- the button code, must beMouseEvent.BUTTON_LEFT
,MouseEvent.BUTTON_MIDDLE
orMouseEvent.BUTTON_RIGHT
- Returns:
- the page which this element's window contains after the mouse click
-
mouseUp
public Page mouseUp()
Simulates releasing the mouse click on this element, returning the page which this element's window contains after the mouse click release. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.- Returns:
- the page which this element's window contains after the mouse click release
-
mouseUp
public Page mouseUp(boolean shiftKey, boolean ctrlKey, boolean altKey, int button)
Simulates releasing the mouse click on this element, returning the page which this element's window contains after the mouse click release. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.- Parameters:
shiftKey
-true
if SHIFT is pressed during the mouse click releasectrlKey
-true
if CTRL is pressed during the mouse click releasealtKey
-true
if ALT is pressed during the mouse click releasebutton
- the button code, must beMouseEvent.BUTTON_LEFT
,MouseEvent.BUTTON_MIDDLE
orMouseEvent.BUTTON_RIGHT
- Returns:
- the page which this element's window contains after the mouse click release
-
rightClick
public Page rightClick()
Simulates right clicking the mouse on this element, returning the page which this element's window contains after the mouse click. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.- Returns:
- the page which this element's window contains after the mouse click
-
rightClick
public Page rightClick(boolean shiftKey, boolean ctrlKey, boolean altKey)
Simulates right clicking the mouse on this element, returning the page which this element's window contains after the mouse click. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.- Parameters:
shiftKey
-true
if SHIFT is pressed during the mouse clickctrlKey
-true
if CTRL is pressed during the mouse clickaltKey
-true
if ALT is pressed during the mouse click- Returns:
- the page which this element's window contains after the mouse click
-
fireEvent
public ScriptResult fireEvent(java.lang.String eventType)
- Parameters:
eventType
- the event type (like "load", "click")- Returns:
- the execution result, or
null
if nothing is executed
-
fireEvent
public ScriptResult fireEvent(org.htmlunit.javascript.host.event.Event event)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Fires the event on the element. Nothing is done if JavaScript is disabled.- Parameters:
event
- the event to fire- Returns:
- the execution result, or
null
if nothing is executed
-
preventDefault
protected void preventDefault()
This method is called if the current fired event is canceled bypreventDefault()
in FireFox, or by returningfalse
in Internet Explorer.The default implementation does nothing.
-
focus
public void focus()
Sets the focus on this element.
-
blur
public void blur()
Removes focus from this element.
-
removeFocus
public void removeFocus()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Gets notified that it has lost the focus.
-
isStateUpdateFirst
protected boolean isStateUpdateFirst()
Returnstrue
if state updates should be done before onclick event handling. This method returnsfalse
by default, and is expected to be overridden to returntrue
by derived classes likeHtmlCheckBoxInput
.- Returns:
true
if state updates should be done before onclick event handling
-
isMouseOver
public boolean isMouseOver()
Returns whether the Mouse is currently over this element or not.- Returns:
- whether the Mouse is currently over this element or not
-
matches
public boolean matches(java.lang.String selectorString)
Returns true if the element would be selected by the specified selector string; otherwise, returns false.- Parameters:
selectorString
- the selector to test- Returns:
- true if the element would be selected by the specified selector string; otherwise, returns false.
-
setNodeValue
public void setNodeValue(java.lang.String value)
- Specified by:
setNodeValue
in interfaceorg.w3c.dom.Node
-
setDefaults
public void setDefaults(org.htmlunit.css.ComputedCssStyleDeclaration style)
Callback method which allows different HTML element types to perform custom initialization of computed styles. For example, body elements in most browsers have default values for their margins.- Parameters:
style
- the style to initialize
-
setInnerHtml
public void setInnerHtml(java.lang.String source) throws org.xml.sax.SAXException, java.io.IOException
Replaces all child elements of this element with the supplied value parsed as html.- Parameters:
source
- the new value for the contents of this element- Throws:
org.xml.sax.SAXException
- in case of errorjava.io.IOException
- in case of error
-
-