org.lobobrowser.html.domimpl

Class HTMLDocumentImpl

Implemented Interfaces:
Document, DocumentView, HTMLDocument, Node, ModelNode, ScriptableDelegate

public class HTMLDocumentImpl
extends NodeImpl
implements HTMLDocument, DocumentView

Implementation of the W3C HTMLDocument interface.

Nested Class Summary

class
HTMLDocumentImpl.CSSStyleSheetList

Field Summary

Fields inherited from class org.lobobrowser.html.domimpl.NodeImpl

document, logger, nodeList, notificationsSuspended, parentNode, treeLock, uiNode

Constructor Summary

HTMLDocumentImpl(HtmlRendererContext rcontext)
HTMLDocumentImpl(UserAgentContext ucontext)
HTMLDocumentImpl(UserAgentContext ucontext, HtmlRendererContext rcontext, WritableLineReader reader, String documentURI)

Method Summary

void
addDocumentNotificationListener(DocumentNotificationListener listener)
Adds a document notification listener, which is informed about changes to the document.
Node
adoptNode(Node source)
void
allInvalidated()
void
close()
Closes a document stream opened by open() and forces rendering.
Attr
createAttribute(String name)
Attr
createAttributeNS(String namespaceURI, String qualifiedName)
CDATASection
createCDATASection(String data)
Comment
createComment(String data)
DocumentFragment
createDocumentFragment()
Element
createElement(String tagName)
Element
createElementNS(String namespaceURI, String qualifiedName)
EntityReference
createEntityReference(String name)
ProcessingInstruction
createProcessingInstruction(String target, String data)
protected RenderState
createRenderState(RenderState prevRenderState)
protected Node
createSimilarNode()
Should create a node with some cloned properties, like the node name, but not attributes or children.
Text
createTextNode(String data)
void
externalScriptLoading(NodeImpl node)
HTMLCollection
getAnchors()
A collection of all the anchor (A) elements in a document with a value for the name attribute.
HTMLCollection
getApplets()
A collection of all the OBJECT elements that include applets and APPLET (deprecated) elements in a document.
String
getBaseURI()
HTMLElement
getBody()
The element that contains the content for the document.
String
getCookie()
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 the cookies non-terminal of [IETF RFC 2965], Section 4.2.2.
String
getDefaultTarget()
AbstractView
getDefaultView()
The default AbstractView for this Document, or null if none available.
DocumentType
getDoctype()
Element
getDocumentElement()
String
getDocumentURI()
URL
getDocumentURL()
DOMConfiguration
getDomConfig()
String
getDomain()
The domain name of the server that served the document, or null if the server cannot be identified by a domain name.
Element
getElementById(String elementId)
NodeList
getElementsByName(String elementName)
Gets the collection of elements whose name attribute is elementName.
NodeList
getElementsByTagName(String tagname)
Gets all elements that match the given tag name.
NodeList
getElementsByTagNameNS(String namespaceURI, String localName)
HTMLCollection
getForms()
A collection of all the forms of a document.
HTMLCollection
getFrames()
URL
getFullURL(String uri)
HtmlRendererContext
getHtmlRendererContext()
HTMLCollection
getImages()
A collection of all the IMG elements in a document.
DOMImplementation
getImplementation()
String
getInputEncoding()
HTMLCollection
getLinks()
A collection of all AREA elements and anchor ( A) elements in a document with a value for the href attribute.
String
getLocalName()
Location
getLocation()
String
getNodeName()
short
getNodeType()
String
getNodeValue()
Function
getOnloadHandler()
String
getReferrer()
Returns the URI [IETF RFC 2396] of the page that linked to this page.
boolean
getStrictErrorChecking()
Collection
getStyleSheets()
String
getTextContent()
Gets the text content of this node and its descendents.
String
getTitle()
The title of a document as specified by the TITLE element in the head of the document.
String
getURL()
The absolute URI [IETF RFC 2396] of the document.
UserAgentContext
getUserAgentContext()
String
getXmlEncoding()
boolean
getXmlStandalone()
String
getXmlVersion()
Node
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 it 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.
Element
namedItem(String name)
void
nodeLoaded(NodeImpl node)
void
normalizeDocument()
void
open()
Open a document stream for writing.
void
positionInParentInvalidated(NodeImpl node)
Changed if the position of the node in a parent has changed.
void
removeDocumentNotificationListener(DocumentNotificationListener listener)
Node
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
setCookie(String cookie)
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 the cookies non-terminal of [IETF RFC 2965], Section 4.2.2.
void
setDefaultTarget(String value)
void
setDoctype(DocumentType doctype)
void
setDocumentURI(String documentURI)
void
setDomain(String domain)
void
setLocation(String location)
void
setNodeValue(String nodeValue)
void
setOnloadHandler(Function onloadHandler)
void
setReferrer(String value)
void
setStrictErrorChecking(boolean strictErrorChecking)
void
setTextContent(String textContent)
void
setTitle(String title)
The title of a document as specified by the TITLE element in the head of the document.
Object
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(String text)
Write a string of text to a document stream opened by open().
void
writeln(String text)
Write a string of text followed by a newline character to a document stream opened by open().

Methods inherited from class org.lobobrowser.html.domimpl.NodeImpl

appendChild, appendInnerHTMLImpl, cloneNode, compareDocumentPosition, createRenderState, createSimilarNode, equalAttributes, findUINode, forgetRenderState, getAlignmentX, getAlignmentY, getAttributes, getBaseURI, getChildNodes, getChildren, getChildrenArray, getDescendents, getDocumentItem, getDocumentURL, getFeature, getFirstChild, getFullURL, getHtmlRendererContext, getInnerHTML, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeList, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentModelNode, getParentNode, getParentRenderState, getPrefix, getPreviousSibling, getRenderState, getTextContent, getUINode, getUserAgentContext, getUserData, hasAttributes, hasChildNodes, 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, setNodeValue, setPrefix, setTextContent, setUINode, setUserData, toString, warn, warn

Methods inherited from class org.lobobrowser.js.AbstractScriptableDelegate

getScriptable, setScriptable

Constructor Details

HTMLDocumentImpl

public HTMLDocumentImpl(HtmlRendererContext rcontext)

HTMLDocumentImpl

public HTMLDocumentImpl(UserAgentContext ucontext)

HTMLDocumentImpl

public HTMLDocumentImpl(UserAgentContext ucontext,
                        HtmlRendererContext rcontext,
                        WritableLineReader reader,
                        String documentURI)

Method Details

addDocumentNotificationListener

public void addDocumentNotificationListener(DocumentNotificationListener listener)
Adds a document notification listener, which is informed about changes to the document.
Parameters:
listener - An instance of DocumentNotificationListener.

adoptNode

public Node adoptNode(Node source)
            throws DOMException

allInvalidated

public void allInvalidated()

close

public void close()
Closes a document stream opened by open() and forces rendering.
Specified by:
close in interface HTMLDocument

createAttribute

public Attr createAttribute(String name)
            throws DOMException

createAttributeNS

public Attr createAttributeNS(String namespaceURI,
                              String qualifiedName)
            throws DOMException

createCDATASection

public CDATASection createCDATASection(String data)
            throws DOMException

createComment

public Comment createComment(String data)

createDocumentFragment

public DocumentFragment createDocumentFragment()

createElement

public Element createElement(String tagName)
            throws DOMException

createElementNS

public Element createElementNS(String namespaceURI,
                               String qualifiedName)
            throws DOMException

createEntityReference

public EntityReference createEntityReference(String name)
            throws DOMException

createProcessingInstruction

public ProcessingInstruction createProcessingInstruction(String target,
                                                         String data)
            throws DOMException

createRenderState

protected RenderState createRenderState(RenderState prevRenderState)
Overrides:
createRenderState in interface NodeImpl

createSimilarNode

protected Node createSimilarNode()
Should create a node with some cloned properties, like the node name, but not attributes or children.
Overrides:
createSimilarNode in interface NodeImpl

createTextNode

public Text createTextNode(String data)

externalScriptLoading

public void externalScriptLoading(NodeImpl node)

getAnchors

public HTMLCollection getAnchors()
A collection of all the anchor (A) elements in a document with a value for the name attribute. For reasons of backward compatibility, the returned set of anchors only contains those anchors created with the name attribute, not those created with the id attribute. Note that in [XHTML 1.0], the name attribute (see section 4.10) has no semantics and is only present for legacy user agents: the id attribute is used instead. Users should prefer the iterator mechanisms provided by [DOM Level 2 Traversal] instead.
Specified by:
getAnchors in interface HTMLDocument

getApplets

public HTMLCollection getApplets()
A collection of all the OBJECT elements that include applets and APPLET (deprecated) elements in a document.
Specified by:
getApplets in interface HTMLDocument

getBaseURI

public String getBaseURI()
Overrides:
getBaseURI in interface NodeImpl

getBody

public HTMLElement getBody()
The element that contains the content for the document. In documents with BODY contents, returns the BODY element. In frameset documents, this returns the outermost FRAMESET element.
Specified by:
getBody in interface HTMLDocument

getCookie

public String getCookie()
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 the cookies 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 the cookie 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 interface HTMLDocument

getDefaultTarget

public String getDefaultTarget()

getDefaultView

public AbstractView getDefaultView()
The default AbstractView for this Document, or null if none available.
Specified by:
getDefaultView in interface DocumentView

getDoctype

public DocumentType getDoctype()

getDocumentElement

public Element getDocumentElement()

getDocumentURI

public String getDocumentURI()

getDocumentURL

public URL getDocumentURL()
Overrides:
getDocumentURL in interface NodeImpl

getDomConfig

public DOMConfiguration getDomConfig()

getDomain

public String getDomain()
The domain name of the server that served the document, or null if the server cannot be identified by a domain name.
Specified by:
getDomain in interface HTMLDocument

getElementById

public Element getElementById(String elementId)

getElementsByName

public NodeList getElementsByName(String elementName)
Gets the collection of elements whose name attribute is elementName.
Specified by:
getElementsByName in interface HTMLDocument

getElementsByTagName

public NodeList getElementsByTagName(String tagname)
Gets all elements that match the given tag name.
Parameters:
tagname - The element tag name or an asterisk character (*) to match all elements.

getElementsByTagNameNS

public NodeList getElementsByTagNameNS(String namespaceURI,
                                       String localName)

getForms

public HTMLCollection getForms()
A collection of all the forms of a document.
Specified by:
getForms in interface HTMLDocument

getFrames

public HTMLCollection getFrames()

getFullURL

public final URL getFullURL(String uri)
Specified by:
getFullURL in interface ModelNode
Overrides:
getFullURL in interface NodeImpl

getHtmlRendererContext

public final HtmlRendererContext getHtmlRendererContext()
Overrides:
getHtmlRendererContext in interface NodeImpl

getImages

public HTMLCollection getImages()
A collection of all the IMG elements in a document. The behavior is limited to IMG elements for backwards compatibility. As suggested by [HTML 4.01], to include images, authors may use the OBJECT element or the IMG element. Therefore, it is recommended not to use this attribute to find the images in the document but getElementsByTagName with HTML 4.01 or getElementsByTagNameNS with XHTML 1.0.
Specified by:
getImages in interface HTMLDocument

getImplementation

public DOMImplementation getImplementation()

getInputEncoding

public String getInputEncoding()

getLinks

public HTMLCollection getLinks()
A collection of all AREA elements and anchor ( A) elements in a document with a value for the href attribute.
Specified by:
getLinks in interface HTMLDocument

getLocalName

public String getLocalName()
Overrides:
getLocalName in interface NodeImpl

getLocation

public final Location getLocation()

getNodeName

public String getNodeName()
Overrides:
getNodeName in interface NodeImpl

getNodeType

public short getNodeType()
Overrides:
getNodeType in interface NodeImpl

getNodeValue

public String getNodeValue()
            throws DOMException
Overrides:
getNodeValue in interface NodeImpl

getOnloadHandler

public Function getOnloadHandler()

getReferrer

public String getReferrer()
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 interface HTMLDocument

getStrictErrorChecking

public boolean getStrictErrorChecking()

getStyleSheets

public Collection getStyleSheets()

getTextContent

public String getTextContent()
            throws DOMException
Gets the text content of this node and its descendents.
Overrides:
getTextContent in interface NodeImpl

getTitle

public String getTitle()
The title of a document as specified by the TITLE element in the head of the document.
Specified by:
getTitle in interface HTMLDocument

getURL

public String getURL()
Specified by:
getURL in interface HTMLDocument

getUserAgentContext

public UserAgentContext getUserAgentContext()
Overrides:
getUserAgentContext in interface NodeImpl

getXmlEncoding

public String getXmlEncoding()

getXmlStandalone

public boolean getXmlStandalone()

getXmlVersion

public String getXmlVersion()

importNode

public Node importNode(Node importedNode,
                       boolean deep)
            throws DOMException

invalidated

public 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. An attribute change should trigger this.
Parameters:
node -

load

public void load()
            throws IOException,
                   SAXException,
                   UnsupportedEncodingException
Loads the document from the reader provided when it was constructed. It then closes the reader.

load

public void load(boolean closeReader)
            throws IOException,
                   SAXException,
                   UnsupportedEncodingException

loadImage

protected void loadImage(String relativeUri,
                         ImageListener imageListener)
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 -

lookInvalidated

public void lookInvalidated(NodeImpl node)
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 -

namedItem

public Element namedItem(String name)

nodeLoaded

public void nodeLoaded(NodeImpl node)

normalizeDocument

public void normalizeDocument()

open

public void open()
Specified by:
open in interface HTMLDocument

positionInParentInvalidated

public void positionInParentInvalidated(NodeImpl node)
Changed if the position of the node in a parent has changed.
Parameters:
node -

removeDocumentNotificationListener

public void removeDocumentNotificationListener(DocumentNotificationListener listener)

renameNode

public Node renameNode(Node n,
                       String namespaceURI,
                       String qualifiedName)
            throws DOMException

setBaseURI

public void setBaseURI(String value)

setBody

public void setBody(HTMLElement body)
The element that contains the content for the document. In documents with BODY contents, returns the BODY element. In frameset documents, this returns the outermost FRAMESET element.
Specified by:
setBody in interface HTMLDocument

setCookie

public void setCookie(String cookie)
            throws DOMException
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 the cookies 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 the cookie 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 interface HTMLDocument

setDefaultTarget

public void setDefaultTarget(String value)

setDoctype

public void setDoctype(DocumentType doctype)

setDocumentURI

public void setDocumentURI(String documentURI)

setDomain

public void setDomain(String domain)

setLocation

public void setLocation(String location)

setNodeValue

public void setNodeValue(String nodeValue)
            throws DOMException
Overrides:
setNodeValue in interface NodeImpl

setOnloadHandler

public void setOnloadHandler(Function onloadHandler)

setReferrer

public void setReferrer(String value)

setStrictErrorChecking

public void setStrictErrorChecking(boolean strictErrorChecking)

setTextContent

public void setTextContent(String textContent)
            throws DOMException
Overrides:
setTextContent in interface NodeImpl

setTitle

public void setTitle(String title)
The title of a document as specified by the TITLE element in the head of the document.
Specified by:
setTitle in interface HTMLDocument

setUserData

public Object setUserData(String key,
                          Object data,
                          UserDataHandler handler)
Overrides:
setUserData in interface NodeImpl

setXmlStandalone

public void setXmlStandalone(boolean xmlStandalone)
            throws DOMException

setXmlVersion

public void setXmlVersion(String xmlVersion)
            throws DOMException

sizeInvalidated

public void sizeInvalidated(NodeImpl node)

structureInvalidated

public void structureInvalidated(NodeImpl node)
This is called when children of the node might have changed.
Parameters:
node -

write

public void write(String text)
Write a string of text to a document stream opened by open(). 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 interface HTMLDocument
Parameters:
text - The string to be parsed into some structure in the document structure model.

writeln

public void writeln(String text)
Write a string of text followed by a newline character to a document stream opened by open(). 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 interface HTMLDocument
Parameters:
text - The string to be parsed into some structure in the document structure model.