Class HtmlPage.DomHtmlAttributeChangeListenerImpl
- All Implemented Interfaces:
Serializable,DomChangeListener,HtmlAttributeChangeListener
- Enclosing class:
HtmlPage
Listens for changes anywhere in the document and evicts cached computed styles whenever something relevant changes. Note that the very lazy way of doing this (completely clearing the cache every time something happens) results in very meager performance gains. In order to get good (but still correct) performance, we need to be a little smarter.
CSS 2.1 has the following selector types (where "SN" is shorthand for "the selected node"):
- Universal (i.e. "*"): Affected by the removal of SN from the document.
- Type (i.e. "div"): Affected by the removal of SN from the document.
- Descendant (i.e. "div span"): Affected by changes to SN or to any of its ancestors.
- Child (i.e. "div > span"): Affected by changes to SN or to its parent.
- Adjacent Sibling (i.e. "table + p"): Affected by changes to SN or its previous sibling.
- Attribute (i.e. "div.up, div[class~=up]"): Affected by changes to an attribute of SN.
- ID (i.e. "#header): Affected by changes to the
idattribute of SN. - Pseudo-Elements and Pseudo-Classes (i.e. "p:first-child"): Affected by changes to parent.
Together, these rules dictate that the smart (but still lazy) way of removing elements from the computed style cache is as follows -- whenever a node changes in any way, the cache needs to be cleared of styles for nodes which:
- are actually the same node as the node that changed
- are siblings of the node that changed
- are descendants of the node that changed
Additionally, whenever a style node or a link node
with rel=stylesheet is added or
removed, all elements should be removed from the computed style cache.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidNotification that a new attribute was added to the HtmlElement.voidNotification that an existing attribute has been removed from the HtmlElement.voidNotification that an attribute on the HtmlElement has been replaced.voidnodeAdded(DomChangeEvent event) Notification that a new node was added.private voidnodeChanged(DomNode changedNode, String attribName) voidnodeDeleted(DomChangeEvent event) Notification that a new node was deleted.
-
Constructor Details
-
DomHtmlAttributeChangeListenerImpl
DomHtmlAttributeChangeListenerImpl()
-
-
Method Details
-
nodeAdded
Notification that a new node was added. Called after the node is added.- Specified by:
nodeAddedin interfaceDomChangeListener- Parameters:
event- the node addition event
-
nodeDeleted
Notification that a new node was deleted. Called after the node is deleted.- Specified by:
nodeDeletedin interfaceDomChangeListener- Parameters:
event- the node deletion event
-
attributeAdded
Notification that a new attribute was added to the HtmlElement. Called after the attribute is added.- Specified by:
attributeAddedin interfaceHtmlAttributeChangeListener- Parameters:
event- the attribute change event
-
attributeRemoved
Notification that an existing attribute has been removed from the HtmlElement. Called after the attribute is removed.- Specified by:
attributeRemovedin interfaceHtmlAttributeChangeListener- Parameters:
event- the attribute change event
-
attributeReplaced
Notification that an attribute on the HtmlElement has been replaced. Called after the attribute is replaced.- Specified by:
attributeReplacedin interfaceHtmlAttributeChangeListener- Parameters:
event- the attribute change event
-
nodeChanged
-