Class CSSEngine
java.lang.Object
org.apache.batik.css.engine.CSSEngine
- Direct Known Subclasses:
SVGCSSEngine
This is the base class for all the CSS engines.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classTo handle mutations of a CSSNavigableDocument.protected static classProvides an (empty) adapter for the DocumentHandler interface.protected classTo handle the element attributes modification in the associated document.protected classTo handle the modification of a CSSStyleSheetNode.protected classTo handle the insertion of a CSSStyleSheetNode in the associated document.protected classTo handle the removal of a CSSStyleSheetNode from the associated document.protected classTo handle the removal of a CSSStyleSheetNode from the associated document.static interfaceInterface for people interesting in having 'primary' properties set.protected classTo build a StyleDeclaration object.protected classTo parse a style declaration.protected classTo parse a style declaration and update a StyleMap.protected classTo parse a style sheet. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final int[]Used to fire a change event for all the properties.protected StringThe alternate stylesheet title.protected StringThe class attribute local name.protected StringThe class attribute namespace URI.protected intThe color property index.protected ParsedURLThe current base URI.protected CSSConditionFactoryThe CSS condition factory.protected CSSContextThe CSS context.protected CSSEngine.CSSNavigableDocumentHandlerListener for CSSNavigableDocument events.protected DocumentThe associated document.protected ParsedURLThe document URI.protected EventListenerThe DOMAttrModified event listener.protected EventListenerThe DOMCharacterDataModified event listener.protected EventListenerThe DOMNodeInserted event listener.protected EventListenerThe DOMNodeRemoved event listener.protected EventListenerThe DOMSubtreeModified event listener.protected CSSStylableElementThe current element.protected ListList of StyleMap objects, one for each @font-face rule encountered by this CSSEngine.protected intThe font-size property index.protected StringIntMapThe property/int mappings.protected booleanWhether the document is a CSSNavigableDocument.protected intThe line-height property index.protected static final CSSEngineListener[]protected ListThe listeners.protected org.w3c.css.sac.SACMediaListThe media to use to cascade properties.protected SetThe non CSS presentational hints.protected StringThe non CSS presentational hints namespace URI.protected ExtendedParserThe CSS parser.protected String[]The pseudo-element names.protected NodeThe right sibling of the last removed node.protected SetThe attributes found in stylesheets selectors.protected StringIntMapThe shorthand-property/int mappings.protected ShorthandManager[]The shorthand managers.protected CSSEngine.StyleDeclarationBuilderThe style declaration document handler used to build a StyleDeclaration object.The style declaration document handler.protected CSSEngine.StyleDeclarationUpdateHandlerThe style declaration update handler.protected StringThe style attribute local name.protected StringThe style attribute namespace URI.protected CSSEngine.StyleSheetDocumentHandlerThe style sheet document handler.protected ListThe DOM nodes which contains StyleSheets.protected booleanWhether a style sheet as been removed from the document.protected CSSEngineUserAgentThe user agent used for showing error messages.protected StyleSheetThe user-agent style-sheet.protected StyleSheetThe user style-sheet.protected ValueManager[]The value managers. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCSSEngine(Document doc, ParsedURL uri, ExtendedParser p, ValueManager[] vm, ShorthandManager[] sm, String[] pe, String sns, String sln, String cns, String cln, boolean hints, String hintsNS, CSSContext ctx) Creates a new CSSEngine. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a CSS engine listener.protected voidAdds event listeners to the document to track CSS changes.protected voidaddMatchingRules(List rules, StyleSheet ss, Element elt, String pseudo) Adds the rules matching the element/pseudo-element of given style sheet to the list.protected voidAdds the rules contained in the given list to a stylemap.voiddispose()Disposes the CSSEngine and all the attached resources.protected voiddisposeStyleMaps(Node node) Removes the style maps from each CSSStylableElement in the document.protected voidfindSelectorAttributes(Set attrs, StyleSheet ss) Finds the selector attributes in the given stylesheet.protected voidAn auxiliary method for getStyleSheets().protected voidfirePropertiesChangedEvent(Element target, int[] props) Fires a CSSEngineEvent, given a list of modified properties.getCascadedStyleMap(CSSStylableElement elt, String pseudo) Returns the cascaded style of the given element/pseudo-element.intReturns the color property index.getComputedStyle(CSSStylableElement elt, String pseudo, int propidx) Returns the computed style of the given element/pseudo for the property corresponding to the given index.Returns the current base-url.Returns the CSS context.protected static NodeReturns the CSS first child node of the given node.protected static NodeReturns the CSS next sibling node of the given node.static NodeReturns the CSS parent node of the given node.protected static NodeReturns the CSS previous sibling node of the given node.Returns the document associated with this engine.Gets the StyleMaps generated by @font-face rules encountered by this CSSEngine thus far.intReturns the font-size property index.intReturns the line-height property index.intReturns the number of properties.static CSSStylableElementReturns the next stylable parent of the given element.intgetPropertyIndex(String name) Returns the property index, or -1.getPropertyName(int idx) Returns the name of the property at the given index.intgetShorthandIndex(String name) Returns the shorthand property index, or -1.Returns the ShorthandManagers.Returns the document CSSStyleSheetNodes in a list.Returns the ValueManagers.protected voidhandleAttrModified(Element e, Attr attr, short attrChange, String prevValue, String newValue) Handles an attribute change in the document.protected voidHandles a character data modification in the document.protected voidHandles a node insertion in the document.protected voidHandles a node removal from the document.protected voidhandleSubtreeModified(Node ignored) Handles a subtree modification in the document.protected booleanReturns whether the DOM subtree rooted at the specified node contains aCSSStyleSheetNode.voidimportCascadedStyleMaps(Element src, CSSEngine srceng, Element dest) Recursively imports the cascaded style from a source element to an element of the current document.protected voidinlineStyleAttributeUpdated(CSSStylableElement elt, StyleMap style, short attrChange, String prevValue, String newValue) Called when the inline style of the given element has been updated.protected voidinvalidateProperties(Node node, int[] properties, boolean[] updated, boolean recascade) Invalidates all the properties of the given node.protected booleanmediaMatch(org.w3c.css.sac.SACMediaList ml) Whether the given media list matches the media list of this CSSEngine object.protected voidnonCSSPresentationalHintUpdated(CSSStylableElement elt, StyleMap style, String property, short attrChange, String newValue) Called when a non-CSS presentational hint has been updated.parsePropertyValue(CSSStylableElement elt, String prop, String value) Parses and creates a property value from elt.parseStyleDeclaration(CSSStylableElement elt, String value) Parses and creates a style declaration.parseStyleSheet(String rules, ParsedURL uri, String media) Parses and creates a new style-sheet.voidparseStyleSheet(StyleSheet ss, String rules, ParsedURL uri) Parses and fills the given style-sheet.voidparseStyleSheet(StyleSheet ss, ParsedURL uri) Parses and fills the given style-sheet.protected voidparseStyleSheet(StyleSheet ss, org.w3c.css.sac.InputSource is, ParsedURL uri) Parses and fills the given style-sheet.parseStyleSheet(ParsedURL uri, String media) Parses and creates a new style-sheet.parseStyleSheet(org.w3c.css.sac.InputSource is, ParsedURL uri, String media) Parses and creates a new style-sheet.protected voidpropagateChanges(Node node, int[] props, boolean recascade) Propagates the changes that occurs on the parent of the given node.protected voidputAuthorProperty(StyleMap dest, int idx, Value sval, boolean imp, short origin) Puts an author property from a style-map in another style-map, if possible.voidRemoves a CSS engine listener.protected voidRemoves the event listeners from the document.voidSets the alternate style-sheet title.voidsetCSSEngineUserAgent(CSSEngineUserAgent userAgent) voidsetMainProperties(CSSStylableElement elt, CSSEngine.MainPropertyReceiver dst, String pname, String value, boolean important) voidSets the media to use to compute the styles.voidSets the user agent style-sheet.voidSets the user style-sheet.protected voidSorts the rules matching the element/pseudo-element of given style sheet to the list.
-
Field Details
-
userAgent
The user agent used for showing error messages. -
cssContext
The CSS context. -
document
The associated document. -
documentURI
The document URI. -
indexes
The property/int mappings. -
shorthandIndexes
The shorthand-property/int mappings. -
valueManagers
The value managers. -
shorthandManagers
The shorthand managers. -
parser
The CSS parser. -
pseudoElementNames
The pseudo-element names. -
fontSizeIndex
protected int fontSizeIndexThe font-size property index. -
lineHeightIndex
protected int lineHeightIndexThe line-height property index. -
colorIndex
protected int colorIndexThe color property index. -
userAgentStyleSheet
The user-agent style-sheet. -
userStyleSheet
The user style-sheet. -
media
protected org.w3c.css.sac.SACMediaList mediaThe media to use to cascade properties. -
styleSheetNodes
The DOM nodes which contains StyleSheets. -
fontFaces
List of StyleMap objects, one for each @font-face rule encountered by this CSSEngine. -
styleNamespaceURI
The style attribute namespace URI. -
styleLocalName
The style attribute local name. -
classNamespaceURI
The class attribute namespace URI. -
classLocalName
The class attribute local name. -
nonCSSPresentationalHints
The non CSS presentational hints. -
nonCSSPresentationalHintsNamespaceURI
The non CSS presentational hints namespace URI. -
styleDeclarationDocumentHandler
The style declaration document handler. -
styleDeclarationUpdateHandler
The style declaration update handler. -
styleSheetDocumentHandler
The style sheet document handler. -
styleDeclarationBuilder
The style declaration document handler used to build a StyleDeclaration object. -
element
The current element. -
cssBaseURI
The current base URI. -
alternateStyleSheet
The alternate stylesheet title. -
domAttrModifiedListener
The DOMAttrModified event listener. -
domNodeInsertedListener
The DOMNodeInserted event listener. -
domNodeRemovedListener
The DOMNodeRemoved event listener. -
domSubtreeModifiedListener
The DOMSubtreeModified event listener. -
domCharacterDataModifiedListener
The DOMCharacterDataModified event listener. -
styleSheetRemoved
protected boolean styleSheetRemovedWhether a style sheet as been removed from the document. -
removedStylableElementSibling
The right sibling of the last removed node. -
listeners
The listeners. -
selectorAttributes
The attributes found in stylesheets selectors. -
ALL_PROPERTIES
protected final int[] ALL_PROPERTIESUsed to fire a change event for all the properties. -
cssConditionFactory
The CSS condition factory. -
LISTENER_ARRAY
-
-
Constructor Details
-
CSSEngine
protected CSSEngine(Document doc, ParsedURL uri, ExtendedParser p, ValueManager[] vm, ShorthandManager[] sm, String[] pe, String sns, String sln, String cns, String cln, boolean hints, String hintsNS, CSSContext ctx) Creates a new CSSEngine.- Parameters:
doc- The associated document.uri- The document URI.p- The CSS parser.vm- The property value managers.sm- The shorthand properties managers.pe- The pseudo-element names supported by the associated XML dialect. Must be null if no support for pseudo- elements is required.sns- The namespace URI of the style attribute.sln- The local name of the style attribute.cns- The namespace URI of the class attribute.cln- The local name of the class attribute.hints- Whether the CSS engine should support non CSS presentational hints.hintsNS- The hints namespace URI.ctx- The CSS context.
-
-
Method Details
-
getCSSParentNode
-
getCSSFirstChild
-
getCSSNextSibling
-
getCSSPreviousSibling
-
getParentCSSStylableElement
Returns the next stylable parent of the given element. -
addEventListeners
Adds event listeners to the document to track CSS changes. -
removeEventListeners
Removes the event listeners from the document. -
dispose
public void dispose()Disposes the CSSEngine and all the attached resources. -
disposeStyleMaps
Removes the style maps from each CSSStylableElement in the document. -
getCSSContext
Returns the CSS context. -
getDocument
Returns the document associated with this engine. -
getFontSizeIndex
public int getFontSizeIndex()Returns the font-size property index. -
getLineHeightIndex
public int getLineHeightIndex()Returns the line-height property index. -
getColorIndex
public int getColorIndex()Returns the color property index. -
getNumberOfProperties
public int getNumberOfProperties()Returns the number of properties. -
getPropertyIndex
Returns the property index, or -1. -
getShorthandIndex
Returns the shorthand property index, or -1. -
getPropertyName
Returns the name of the property at the given index. -
setCSSEngineUserAgent
-
getCSSEngineUserAgent
-
setUserAgentStyleSheet
Sets the user agent style-sheet. -
setUserStyleSheet
Sets the user style-sheet. -
getValueManagers
Returns the ValueManagers. -
getShorthandManagers
Returns the ShorthandManagers. -
getFontFaces
Gets the StyleMaps generated by @font-face rules encountered by this CSSEngine thus far. -
setMedia
Sets the media to use to compute the styles. -
setAlternateStyleSheet
Sets the alternate style-sheet title. -
importCascadedStyleMaps
-
getCSSBaseURI
Returns the current base-url. -
getCascadedStyleMap
Returns the cascaded style of the given element/pseudo-element.- Parameters:
elt- The stylable element.pseudo- Optional pseudo-element string (null if none).
-
getComputedStyle
Returns the computed style of the given element/pseudo for the property corresponding to the given index. -
getStyleSheetNodes
Returns the document CSSStyleSheetNodes in a list. This list is updated as the document is modified. -
findStyleSheetNodes
An auxiliary method for getStyleSheets(). -
findSelectorAttributes
Finds the selector attributes in the given stylesheet. -
setMainProperties
public void setMainProperties(CSSStylableElement elt, CSSEngine.MainPropertyReceiver dst, String pname, String value, boolean important) -
parsePropertyValue
Parses and creates a property value from elt.- Parameters:
elt- The element property is from.prop- The property name.value- The property value.
-
parseStyleDeclaration
Parses and creates a style declaration.- Parameters:
value- The style declaration text.
-
parseStyleSheet
Parses and creates a new style-sheet.- Parameters:
uri- The style-sheet URI.media- The target media of the style-sheet.- Throws:
DOMException
-
parseStyleSheet
public StyleSheet parseStyleSheet(org.w3c.css.sac.InputSource is, ParsedURL uri, String media) throws DOMException Parses and creates a new style-sheet.- Parameters:
is- The input source used to read the document.uri- The base URI.media- The target media of the style-sheet.- Throws:
DOMException
-
parseStyleSheet
Parses and fills the given style-sheet.- Parameters:
ss- The stylesheet to fill.uri- The base URI.- Throws:
DOMException
-
parseStyleSheet
Parses and creates a new style-sheet.- Parameters:
rules- The style-sheet rules to parse.uri- The style-sheet URI.media- The target media of the style-sheet.- Throws:
DOMException
-
parseStyleSheet
Parses and fills the given style-sheet.- Parameters:
ss- The stylesheet to fill.rules- The style-sheet rules to parse.uri- The base URI.- Throws:
DOMException
-
parseStyleSheet
protected void parseStyleSheet(StyleSheet ss, org.w3c.css.sac.InputSource is, ParsedURL uri) throws IOException Parses and fills the given style-sheet.- Parameters:
ss- The stylesheet to fill.uri- The base URI.- Throws:
IOException
-
putAuthorProperty
-
addMatchingRules
Adds the rules matching the element/pseudo-element of given style sheet to the list. -
addRules
-
sortRules
-
mediaMatch
protected boolean mediaMatch(org.w3c.css.sac.SACMediaList ml) Whether the given media list matches the media list of this CSSEngine object. -
addCSSEngineListener
Adds a CSS engine listener. -
removeCSSEngineListener
Removes a CSS engine listener. -
firePropertiesChangedEvent
Fires a CSSEngineEvent, given a list of modified properties. -
inlineStyleAttributeUpdated
protected void inlineStyleAttributeUpdated(CSSStylableElement elt, StyleMap style, short attrChange, String prevValue, String newValue) Called when the inline style of the given element has been updated. -
invalidateProperties
protected void invalidateProperties(Node node, int[] properties, boolean[] updated, boolean recascade) Invalidates all the properties of the given node. -
propagateChanges
Propagates the changes that occurs on the parent of the given node. Props is a list of known 'changed' properties. If recascade is true then the stylesheets will be applied again to see if the any new rules apply (or old rules don't apply). -
nonCSSPresentationalHintUpdated
protected void nonCSSPresentationalHintUpdated(CSSStylableElement elt, StyleMap style, String property, short attrChange, String newValue) Called when a non-CSS presentational hint has been updated. -
hasStyleSheetNode
Returns whether the DOM subtree rooted at the specified node contains aCSSStyleSheetNode. -
handleAttrModified
-
handleNodeInserted
Handles a node insertion in the document. -
handleNodeRemoved
Handles a node removal from the document. -
handleSubtreeModified
Handles a subtree modification in the document. todo the incoming Node is actually ignored (not used) here, but it seems caller-sites assume that it is used - is this done right?? -
handleCharacterDataModified
Handles a character data modification in the document.
-