Package org.lobobrowser.html.domimpl
Class HTMLDocumentImpl
java.lang.Object
org.lobobrowser.js.AbstractScriptableDelegate
org.lobobrowser.html.domimpl.NodeImpl
org.lobobrowser.html.domimpl.HTMLDocumentImpl
- All Implemented Interfaces:
ModelNode
,ScriptableDelegate
,Document
,HTMLDocument
,Node
,DocumentView
Implementation of the W3C
HTMLDocument
interface.-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class org.lobobrowser.html.domimpl.NodeImpl
document, nodeList, notificationsSuspended, parentNode, treeLock, uiNode
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
ConstructorsConstructorDescriptionHTMLDocumentImpl
(HtmlRendererContext rcontext) HTMLDocumentImpl
(UserAgentContext ucontext) HTMLDocumentImpl
(UserAgentContext ucontext, HtmlRendererContext rcontext, WritableLineReader reader, String documentURI) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a document notification listener, which is informed about changes to the document.void
Informs listeners that the whole document has been invalidated.void
allInvalidated
(boolean forgetRenderStates) void
close()
Closes a document stream opened byopen()
and forces rendering.createAttribute
(String name) createAttributeNS
(String namespaceURI, String qualifiedName) createCDATASection
(String data) createComment
(String data) createElement
(String tagName) createElementNS
(String namespaceURI, String qualifiedName) createEntityReference
(String name) createProcessingInstruction
(String target, String data) protected RenderState
createRenderState
(RenderState prevRenderState) protected Node
Should create a node with some cloned properties, like the node name, but not attributes or children.createTextNode
(String data) void
A collection of all the anchor (A
) elements in a document with a value for thename
attribute.A collection of all theOBJECT
elements that include applets andAPPLET
(deprecated) elements in a document.getBody()
The element that contains the content for the document.This mutable string attribute denotes persistent state information that (1) is associated with the current frame or document and (2) is composed of information described by thecookies
non-terminal of [IETF RFC 2965], Section 4.2.2.The defaultAbstractView
for thisDocument
, ornull
if none available.The domain name of the server that served the document, ornull
if the server cannot be identified by a domain name.getElementById
(String elementId) getElementsByName
(String elementName) Gets the collection of elements whosename
attribute iselementName
.getElementsByTagName
(String tagname) Gets all elements that match the given tag name.getElementsByTagNameNS
(String namespaceURI, String localName) getForms()
A collection of all the forms of a document.final URL
getFullURL
(String uri) final HtmlRendererContext
A collection of all theIMG
elements in a document.getLinks()
A collection of allAREA
elements and anchor (A
) elements in a document with a value for thehref
attribute.Gets an immutable set of locales previously set for this document.final Location
short
org.mozilla.javascript.Function
Returns the URI [IETF RFC 2396] of the page that linked to this page.boolean
Gets the text content of this node and its descendents.getTitle()
The title of a document as specified by theTITLE
element in the head of the document.getURL()
The absolute URI [IETF RFC 2396] of the document.boolean
importNode
(Node importedNode, boolean deep) void
invalidated
(NodeImpl node) This is called when the node has changed, but it is unclear if it's a size change or a look change.void
load()
Loads the document from the reader provided when the current instance ofHTMLDocumentImpl
was constructed.void
load
(boolean closeReader) protected void
loadImage
(String relativeUri, ImageListener imageListener) Loads images asynchronously such that they are shared if loaded simultaneously from the same URI.void
lookInvalidated
(NodeImpl node) Called if something such as a color or decoration has changed.void
nodeLoaded
(NodeImpl node) void
void
open()
Open a document stream for writing.void
Changed if the position of the node in a parent has changed.void
renameNode
(Node n, String namespaceURI, String qualifiedName) void
setBaseURI
(String value) void
setBody
(HTMLElement body) The element that contains the content for the document.void
This mutable string attribute denotes persistent state information that (1) is associated with the current frame or document and (2) is composed of information described by thecookies
non-terminal of [IETF RFC 2965], Section 4.2.2.void
setDefaultTarget
(String value) void
setDoctype
(DocumentType doctype) void
setDocumentURI
(String documentURI) void
void
setLocales
(Set locales) Sets the locales of the document.void
setLocation
(String location) void
setNodeValue
(String nodeValue) void
setOnloadHandler
(org.mozilla.javascript.Function onloadHandler) void
setReferrer
(String value) void
setStrictErrorChecking
(boolean strictErrorChecking) void
setTextContent
(String textContent) void
The title of a document as specified by theTITLE
element in the head of the document.setUserData
(String key, Object data, UserDataHandler handler) void
setXmlStandalone
(boolean xmlStandalone) void
setXmlVersion
(String xmlVersion) void
sizeInvalidated
(NodeImpl node) void
structureInvalidated
(NodeImpl node) This is called when children of the node might have changed.void
Write a string of text to a document stream opened byopen()
.void
Write a string of text followed by a newline character to a document stream opened byopen()
.Methods inherited from class org.lobobrowser.html.domimpl.NodeImpl
appendChild, appendInnerHTMLImpl, appendInnerTextImpl, cloneNode, compareDocumentPosition, equalAttributes, findUINode, forgetRenderState, getAlignmentX, getAlignmentY, getAttributes, getChildNodes, getChildren, getChildrenArray, getDescendents, getDocumentItem, getFeature, getFirstChild, getInnerHTML, getInnerText, getLastChild, getNamespaceURI, getNextSibling, getNodeList, getOwnerDocument, getParentModelNode, getParentNode, getParentRenderState, getPrefix, getPreviousSibling, getRenderState, getUINode, getUserData, hasAttributes, hasChildNodes, htmlEncodeChildText, informDocumentInvalid, informExternalScriptLoading, informInvalid, informLayoutInvalid, informLookInvalid, informNodeLoaded, informPositionInvalid, informSizeInvalid, informStructureInvalid, insertAfter, insertAt, insertBefore, isDefaultNamespace, isEqualNode, isEqualOrDescendentOf, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeAllChildren, removeAllChildrenImpl, removeChild, removeChildAt, removeChildren, removeChildrenImpl, replaceAdjacentTextNodes, replaceAdjacentTextNodes, replaceChild, setDocumentItem, setPrefix, setUINode, toString, warn, warn
Methods inherited from class org.lobobrowser.js.AbstractScriptableDelegate
getScriptable, setScriptable
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, cloneNode, compareDocumentPosition, getAttributes, getChildNodes, getFeature, getFirstChild, getLastChild, getNamespaceURI, getNextSibling, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setPrefix
-
Constructor Details
-
HTMLDocumentImpl
-
HTMLDocumentImpl
-
HTMLDocumentImpl
public HTMLDocumentImpl(UserAgentContext ucontext, HtmlRendererContext rcontext, WritableLineReader reader, String documentURI)
-
-
Method Details
-
getLocales
Gets an immutable set of locales previously set for this document. -
setLocales
Sets the locales of the document. This helps determine whether specific fonts can display text in the languages of all the locales.- Parameters:
locales
- An immutable set ofjava.util.Locale
instances.
-
getDocumentURL
- Overrides:
getDocumentURL
in classNodeImpl
-
getBaseURI
- Specified by:
getBaseURI
in interfaceNode
- Overrides:
getBaseURI
in classNodeImpl
-
setBaseURI
-
getDefaultTarget
-
setDefaultTarget
-
getDefaultView
Description copied from interface:DocumentView
The defaultAbstractView
for thisDocument
, ornull
if none available.- Specified by:
getDefaultView
in interfaceDocumentView
-
getTextContent
Description copied from class:NodeImpl
Gets the text content of this node and its descendents.- Specified by:
getTextContent
in interfaceNode
- Overrides:
getTextContent
in classNodeImpl
- Throws:
DOMException
-
setTextContent
- Specified by:
setTextContent
in interfaceNode
- Overrides:
setTextContent
in classNodeImpl
- Throws:
DOMException
-
getTitle
Description copied from interface:HTMLDocument
The title of a document as specified by theTITLE
element in the head of the document.- Specified by:
getTitle
in interfaceHTMLDocument
-
setTitle
Description copied from interface:HTMLDocument
The title of a document as specified by theTITLE
element in the head of the document.- Specified by:
setTitle
in interfaceHTMLDocument
-
getReferrer
Description copied from interface:HTMLDocument
Returns the URI [IETF RFC 2396] of the page that linked to this page. The value is an empty string if the user navigated to the page directly (not through a link, but, for example, via a bookmark).- Specified by:
getReferrer
in interfaceHTMLDocument
-
setReferrer
-
getDomain
Description copied from interface:HTMLDocument
The domain name of the server that served the document, ornull
if the server cannot be identified by a domain name.- Specified by:
getDomain
in interfaceHTMLDocument
-
setDomain
-
getBody
Description copied from interface:HTMLDocument
The element that contains the content for the document. In documents withBODY
contents, returns theBODY
element. In frameset documents, this returns the outermostFRAMESET
element.- Specified by:
getBody
in interfaceHTMLDocument
-
getImages
Description copied from interface:HTMLDocument
A collection of all theIMG
elements in a document. The behavior is limited toIMG
elements for backwards compatibility. As suggested by [HTML 4.01], to include images, authors may use theOBJECT
element or theIMG
element. Therefore, it is recommended not to use this attribute to find the images in the document butgetElementsByTagName
with HTML 4.01 orgetElementsByTagNameNS
with XHTML 1.0.- Specified by:
getImages
in interfaceHTMLDocument
-
getApplets
Description copied from interface:HTMLDocument
A collection of all theOBJECT
elements that include applets andAPPLET
(deprecated) elements in a document.- Specified by:
getApplets
in interfaceHTMLDocument
-
getLinks
Description copied from interface:HTMLDocument
A collection of allAREA
elements and anchor (A
) elements in a document with a value for thehref
attribute.- Specified by:
getLinks
in interfaceHTMLDocument
-
getForms
Description copied from interface:HTMLDocument
A collection of all the forms of a document.- Specified by:
getForms
in interfaceHTMLDocument
-
getFrames
-
getAnchors
Description copied from interface:HTMLDocument
A collection of all the anchor (A
) elements in a document with a value for thename
attribute. For reasons of backward compatibility, the returned set of anchors only contains those anchors created with thename
attribute, not those created with theid
attribute. Note that in [XHTML 1.0], thename
attribute (see section 4.10) has no semantics and is only present for legacy user agents: theid
attribute is used instead. Users should prefer the iterator mechanisms provided by [DOM Level 2 Traversal] instead.- Specified by:
getAnchors
in interfaceHTMLDocument
-
getCookie
Description copied from interface:HTMLDocument
This mutable string attribute denotes persistent state information that (1) is associated with the current frame or document and (2) is composed of information described by thecookies
non-terminal of [IETF RFC 2965], Section 4.2.2.
If no persistent state information is available for the current frame or document document, then this property's value is an empty string.
When this attribute is read, all cookies are returned as a single string, with each cookie's name-value pair concatenated into a list of name-value pairs, each list item being separated by a ';' (semicolon).
When this attribute is set, the value it is set to should be a string that adheres to thecookie
non-terminal of [IETF RFC 2965]; that is, it should be a single name-value pair followed by zero or more cookie attribute values. If no domain attribute is specified, then the domain attribute for the new value defaults to the host portion of an absolute URI [IETF RFC 2396] of the current frame or document. If no path attribute is specified, then the path attribute for the new value defaults to the absolute path portion of the URI [IETF RFC 2396] of the current frame or document. If no max-age attribute is specified, then the max-age attribute for the new value defaults to a user agent defined value. If a cookie with the specified name is already associated with the current frame or document, then the new value as well as the new attributes replace the old value and attributes. If a max-age attribute of 0 is specified for the new value, then any existing cookies of the specified name are removed from the cookie storage. See [IETF RFC 2965] for the semantics of persistent state item attribute value pairs. The precise nature of a user agent session is not defined by this specification.- Specified by:
getCookie
in interfaceHTMLDocument
-
setCookie
Description copied from interface:HTMLDocument
This mutable string attribute denotes persistent state information that (1) is associated with the current frame or document and (2) is composed of information described by thecookies
non-terminal of [IETF RFC 2965], Section 4.2.2.
If no persistent state information is available for the current frame or document document, then this property's value is an empty string.
When this attribute is read, all cookies are returned as a single string, with each cookie's name-value pair concatenated into a list of name-value pairs, each list item being separated by a ';' (semicolon).
When this attribute is set, the value it is set to should be a string that adheres to thecookie
non-terminal of [IETF RFC 2965]; that is, it should be a single name-value pair followed by zero or more cookie attribute values. If no domain attribute is specified, then the domain attribute for the new value defaults to the host portion of an absolute URI [IETF RFC 2396] of the current frame or document. If no path attribute is specified, then the path attribute for the new value defaults to the absolute path portion of the URI [IETF RFC 2396] of the current frame or document. If no max-age attribute is specified, then the max-age attribute for the new value defaults to a user agent defined value. If a cookie with the specified name is already associated with the current frame or document, then the new value as well as the new attributes replace the old value and attributes. If a max-age attribute of 0 is specified for the new value, then any existing cookies of the specified name are removed from the cookie storage. See [IETF RFC 2965] for the semantics of persistent state item attribute value pairs. The precise nature of a user agent session is not defined by this specification.- Specified by:
setCookie
in interfaceHTMLDocument
- Throws:
DOMException
- SYNTAX_ERR: If the new value does not adhere to the cookie syntax specified by [IETF RFC 2965].
-
open
public void open()Description copied from interface:HTMLDocument
Open a document stream for writing. If a document exists in the target, this method clears it. This method and the ones following allow a user to add to or replace the structure model of a document using strings of unparsed HTML. At the time of writing alternate methods for providing similar functionality for both HTML and XML documents were being considered (see [DOM Level 3 Load and Save]).- Specified by:
open
in interfaceHTMLDocument
-
load
Loads the document from the reader provided when the current instance ofHTMLDocumentImpl
was constructed. It then closes the reader. -
load
public void load(boolean closeReader) throws IOException, SAXException, UnsupportedEncodingException -
close
public void close()Description copied from interface:HTMLDocument
Closes a document stream opened byopen()
and forces rendering.- Specified by:
close
in interfaceHTMLDocument
-
write
Description copied from interface:HTMLDocument
Write a string of text to a document stream opened byopen()
. Note that the function will produce a document which is not necessarily driven by a DTD and therefore might be produce an invalid result in the context of the document.- Specified by:
write
in interfaceHTMLDocument
- Parameters:
text
- The string to be parsed into some structure in the document structure model.
-
writeln
Description copied from interface:HTMLDocument
Write a string of text followed by a newline character to a document stream opened byopen()
. Note that the function will produce a document which is not necessarily driven by a DTD and therefore might be produce an invalid result in the context of the document- Specified by:
writeln
in interfaceHTMLDocument
- Parameters:
text
- The string to be parsed into some structure in the document structure model.
-
getElementsByName
Gets the collection of elements whosename
attribute iselementName
.- Specified by:
getElementsByName
in interfaceHTMLDocument
- Parameters:
elementName
- Thename
attribute value for an element.- Returns:
- The matching elements.
-
getDoctype
- Specified by:
getDoctype
in interfaceDocument
-
setDoctype
-
getDocumentElement
- Specified by:
getDocumentElement
in interfaceDocument
-
createElement
- Specified by:
createElement
in interfaceDocument
- Throws:
DOMException
-
createDocumentFragment
- Specified by:
createDocumentFragment
in interfaceDocument
-
createTextNode
- Specified by:
createTextNode
in interfaceDocument
-
createComment
- Specified by:
createComment
in interfaceDocument
-
createCDATASection
- Specified by:
createCDATASection
in interfaceDocument
- Throws:
DOMException
-
createProcessingInstruction
public ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException - Specified by:
createProcessingInstruction
in interfaceDocument
- Throws:
DOMException
-
createAttribute
- Specified by:
createAttribute
in interfaceDocument
- Throws:
DOMException
-
createEntityReference
- Specified by:
createEntityReference
in interfaceDocument
- Throws:
DOMException
-
getElementsByTagName
Gets all elements that match the given tag name.- Specified by:
getElementsByTagName
in interfaceDocument
- Parameters:
tagname
- The element tag name or an asterisk character (*) to match all elements.
-
importNode
- Specified by:
importNode
in interfaceDocument
- Throws:
DOMException
-
createElementNS
- Specified by:
createElementNS
in interfaceDocument
- Throws:
DOMException
-
createAttributeNS
- Specified by:
createAttributeNS
in interfaceDocument
- Throws:
DOMException
-
getElementsByTagNameNS
- Specified by:
getElementsByTagNameNS
in interfaceDocument
-
getElementById
- Specified by:
getElementById
in interfaceDocument
-
namedItem
-
getInputEncoding
- Specified by:
getInputEncoding
in interfaceDocument
-
getXmlEncoding
- Specified by:
getXmlEncoding
in interfaceDocument
-
getXmlStandalone
public boolean getXmlStandalone()- Specified by:
getXmlStandalone
in interfaceDocument
-
setXmlStandalone
- Specified by:
setXmlStandalone
in interfaceDocument
- Throws:
DOMException
-
getXmlVersion
- Specified by:
getXmlVersion
in interfaceDocument
-
setXmlVersion
- Specified by:
setXmlVersion
in interfaceDocument
- Throws:
DOMException
-
getStrictErrorChecking
public boolean getStrictErrorChecking()- Specified by:
getStrictErrorChecking
in interfaceDocument
-
setStrictErrorChecking
public void setStrictErrorChecking(boolean strictErrorChecking) - Specified by:
setStrictErrorChecking
in interfaceDocument
-
getDocumentURI
- Specified by:
getDocumentURI
in interfaceDocument
-
setDocumentURI
- Specified by:
setDocumentURI
in interfaceDocument
-
adoptNode
- Specified by:
adoptNode
in interfaceDocument
- Throws:
DOMException
-
getDomConfig
- Specified by:
getDomConfig
in interfaceDocument
-
normalizeDocument
public void normalizeDocument()- Specified by:
normalizeDocument
in interfaceDocument
-
renameNode
- Specified by:
renameNode
in interfaceDocument
- Throws:
DOMException
-
getImplementation
- Specified by:
getImplementation
in interfaceDocument
-
getLocalName
- Specified by:
getLocalName
in interfaceNode
- Specified by:
getLocalName
in classNodeImpl
-
getNodeName
- Specified by:
getNodeName
in interfaceNode
- Specified by:
getNodeName
in classNodeImpl
-
getNodeType
public short getNodeType()- Specified by:
getNodeType
in interfaceNode
- Specified by:
getNodeType
in classNodeImpl
-
getNodeValue
- Specified by:
getNodeValue
in interfaceNode
- Specified by:
getNodeValue
in classNodeImpl
- Throws:
DOMException
-
setNodeValue
- Specified by:
setNodeValue
in interfaceNode
- Specified by:
setNodeValue
in classNodeImpl
- Throws:
DOMException
-
getHtmlRendererContext
- Overrides:
getHtmlRendererContext
in classNodeImpl
-
getUserAgentContext
- Overrides:
getUserAgentContext
in classNodeImpl
-
getFullURL
- Specified by:
getFullURL
in interfaceModelNode
- Overrides:
getFullURL
in classNodeImpl
-
getLocation
-
setLocation
-
getURL
Description copied from interface:HTMLDocument
The absolute URI [IETF RFC 2396] of the document.- Specified by:
getURL
in interfaceHTMLDocument
-
setBody
Description copied from interface:HTMLDocument
The element that contains the content for the document. In documents withBODY
contents, returns theBODY
element. In frameset documents, this returns the outermostFRAMESET
element.- Specified by:
setBody
in interfaceHTMLDocument
-
allInvalidated
public void allInvalidated(boolean forgetRenderStates) -
getStyleSheets
-
addDocumentNotificationListener
Adds a document notification listener, which is informed about changes to the document.- Parameters:
listener
- An instance ofDocumentNotificationListener
.
-
removeDocumentNotificationListener
-
sizeInvalidated
-
lookInvalidated
Called if something such as a color or decoration has changed. This would be something which does not affect the rendered size, and can be revalidated with a simple repaint.- Parameters:
node
-
-
positionInParentInvalidated
Changed if the position of the node in a parent has changed.- Parameters:
node
-
-
invalidated
This is called when the node has changed, but it is unclear if it's a size change or a look change. An attribute change should trigger this.- Parameters:
node
-
-
structureInvalidated
This is called when children of the node might have changed.- Parameters:
node
-
-
nodeLoaded
-
externalScriptLoading
-
allInvalidated
public void allInvalidated()Informs listeners that the whole document has been invalidated. -
createRenderState
- Overrides:
createRenderState
in classNodeImpl
-
loadImage
Loads images asynchronously such that they are shared if loaded simultaneously from the same URI. Informs the listener immediately if an image is already known.- Parameters:
relativeUri
-imageListener
-
-
getOnloadHandler
public org.mozilla.javascript.Function getOnloadHandler() -
setOnloadHandler
public void setOnloadHandler(org.mozilla.javascript.Function onloadHandler) -
setUserData
- Specified by:
setUserData
in interfaceNode
- Overrides:
setUserData
in classNodeImpl
-
createSimilarNode
Description copied from class:NodeImpl
Should create a node with some cloned properties, like the node name, but not attributes or children.- Specified by:
createSimilarNode
in classNodeImpl
-