java.lang.Object
io.sf.carte.doc.style.css.om.AbstractStyleSheet
io.sf.carte.doc.style.css.om.AbstractCSSStyleSheet
io.sf.carte.doc.style.css.om.BaseCSSStyleSheet
io.sf.carte.doc.style.css.om.BaseDocumentCSSStyleSheet
- All Implemented Interfaces:
CSSStyleSheet<AbstractCSSRule>
,DocumentCSSStyleSheet
,NamespacePrefixMap
,Parser.NamespaceMap
,SheetContext
,Serializable
,Cloneable
,CSSStyleSheet
,StyleSheet
- Direct Known Subclasses:
DOMDocumentCSSStyleSheet
public abstract class BaseDocumentCSSStyleSheet
extends BaseCSSStyleSheet
implements DocumentCSSStyleSheet, Cloneable
Base implementation for
DocumentCSSStyleSheet
.- See Also:
-
Field Summary
Fields inherited from interface io.sf.carte.doc.style.css.CSSStyleSheet
COMMENTS_AUTO, COMMENTS_IGNORE, COMMENTS_PRECEDING
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract BaseDocumentCSSStyleSheet
clone()
Clone this style sheet.abstract BaseDocumentCSSStyleSheet
Clone this style sheet, but only preserving rules targeting the given medium.protected ComputedCSSStyle
computeRevertedStyle
(ComputedCSSStyle style, SelectorMatcher matcher, Condition pseudoElt, BaseCSSStyleDeclaration inlineStyle, int origin) protected ComputedCSSStyle
computeStyle
(ComputedCSSStyle style, SelectorMatcher matcher, Condition pseudoElt, InlineStyle inlineStyle) Compute the style for an element.protected void
protected abstract ComputedCSSStyle
abstract ComputedCSSStyle
getComputedStyle
(CSSElement elm, Condition pseudoElt) Gets the computed style for the given element and pseudo-element.getHref()
abstract CSSDocument
Gets the target medium for this sheet.int
insertRule
(String ruleText, int index) Used to insert a new rule into the style sheet.boolean
parseStyleSheet
(Reader reader, short commentMode) Parses a style sheet.void
registerProperty
(CSSPropertyDefinition definition) Registers the definition of a custom property.void
abstract void
setOwnerDocument
(CSSDocument ownerNode) Methods inherited from class io.sf.carte.doc.style.css.om.BaseCSSStyleSheet
acceptDeclarationRuleVisitor, acceptDescriptorRuleVisitor, acceptStyleRuleVisitor, addLocalRule, addRule, addStyleSheet, copyAllTo, copyFieldsTo, copyRulesTo, createCounterStyleRule, createFontFaceRule, createFontFeatureValuesRule, createImportRule, createImportRule, createKeyframesRule, createMarginRule, createMediaRule, createNamespaceRule, createPageRule, createPropertyRule, createStyleDeclaration, createStyleDeclaration, createStyleRule, createSupportsRule, createSupportsRule, createSupportsRule, createUnknownRule, deleteRule, getCssRules, getDisabled, getDocumentErrorHandler, getErrorHandler, getFirstStyleRule, getMedia, getNamespacePrefix, getNamespaceURI, getOrigin, getOwnerRule, getParentStyleSheet, getRulesForProperty, getSelectorsForProperty, getSelectorsForPropertyValue, getStyleRules, getStyleSheetFactory, getType, hasDefaultNamespace, hasRuleErrorsOrWarnings, loadStyleSheet, registerNamespace, registerNamespacePrefix, setDisabled, setErrorHandler, setMedia, setParentStyleSheet, toMinifiedString, toString, toStyleString, unregisterNamespace
Methods inherited from class io.sf.carte.doc.style.css.om.AbstractCSSStyleSheet
hasFactoryFlag, openConnection, parseRelAttribute, parseStyleSheet
Methods inherited from class io.sf.carte.doc.style.css.om.AbstractStyleSheet
getTitle, setTitle
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.sf.carte.doc.style.css.CSSStyleSheet
addRule, addStyleSheet, createCounterStyleRule, createFontFaceRule, createFontFeatureValuesRule, createImportRule, createImportRule, createKeyframesRule, createMarginRule, createMediaRule, createNamespaceRule, createPageRule, createPropertyRule, createStyleDeclaration, createStyleRule, createSupportsRule, createSupportsRule, createSupportsRule, createUnknownRule, createViewportRule, getCssRules, getErrorHandler, getMedia, getRulesForProperty, getSelectorsForProperty, getStyleSheetFactory, hasRuleErrorsOrWarnings, parseStyleSheet
Methods inherited from interface org.w3c.dom.css.CSSStyleSheet
deleteRule, getOwnerRule
Methods inherited from interface org.w3c.dom.stylesheets.StyleSheet
getDisabled, getParentStyleSheet, getTitle, getType, setDisabled
-
Constructor Details
-
BaseDocumentCSSStyleSheet
-
-
Method Details
-
setHref
- Overrides:
setHref
in classBaseCSSStyleSheet
-
getHref
- Specified by:
getHref
in interfaceStyleSheet
- Overrides:
getHref
in classBaseCSSStyleSheet
-
getOwnerNode
- Specified by:
getOwnerNode
in interfaceStyleSheet
- Overrides:
getOwnerNode
in classBaseCSSStyleSheet
-
setOwnerDocument
-
copyToTarget
-
registerProperty
Registers the definition of a custom property.- Specified by:
registerProperty
in interfaceDocumentCSSStyleSheet
- Parameters:
definition
- the definition.
-
insertRule
Description copied from class:BaseCSSStyleSheet
Used to insert a new rule into the style sheet. The new rule now becomes part of the cascade.- Specified by:
insertRule
in interfaceCSSStyleSheet
- Overrides:
insertRule
in classBaseCSSStyleSheet
- Parameters:
ruleText
- The parsable text representing the rule. For rule sets this contains both the selector and the style declaration. For at-rules, this specifies both the at-identifier and the rule content.index
- The index within the style sheet's rule list of the rule before which to insert the specified rule. If the specified index is equal to the length of the style sheet's rule collection, the rule will be added to the end of the style sheet.- Returns:
- The index within the style sheet's rule collection of the newly inserted rule.
- Throws:
DOMException
- HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted at the specified index e.g. if an@import
rule is inserted after a standard rule set or other at-rule.
INDEX_SIZE_ERR: Raised if the specified index is not a valid insertion point.
NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is readonly.
SYNTAX_ERR: Raised if the specified rule has a syntax error and is unparsable.
-
parseStyleSheet
Description copied from class:BaseCSSStyleSheet
Parses a style sheet.If the style sheet is not empty, the rules from the parsed source will be added at the end of the rule list, with the same origin as the rule with a highest precedence origin.
If
commentMode
is notCOMMENTS_IGNORE
, the comments preceding a rule shall be available throughCSSRule.getPrecedingComments()
, and ifCOMMENTS_AUTO
was set also the trailing ones, through the methodCSSRule.getTrailingComments()
.This method resets the state of this sheet's error handler.
To create a sheet, see
CSSStyleSheetFactory.createStyleSheet(String,MediaQueryList)
- Specified by:
parseStyleSheet
in interfaceCSSStyleSheet<AbstractCSSRule>
- Overrides:
parseStyleSheet
in classBaseCSSStyleSheet
- Parameters:
reader
- the character stream containing the CSS sheet.commentMode
-0
if comments have to be ignored,1
if all comments are considered as preceding a rule,2
if the parser should try to figure out which comments are preceding and trailing a rule (auto mode).- Returns:
true
if the SAC parser reported no errors or fatal errors, false otherwise.- Throws:
DOMException
- if raised by the error handler.IOException
- if a problem is found reading the sheet.
-
getTargetMedium
Gets the target medium for this sheet.- Specified by:
getTargetMedium
in interfaceDocumentCSSStyleSheet
- Overrides:
getTargetMedium
in classBaseCSSStyleSheet
- Returns:
- the target medium, or null if is for all media.
-
getComputedStyle
Gets the computed style for the given element and pseudo-element.- Specified by:
getComputedStyle
in interfaceDocumentCSSStyleSheet
- Parameters:
elm
- the element.pseudoElt
- the pseudo-element condition.- Returns:
- the computed style declaration.
-
createComputedCSSStyle
-
clone
Clone this style sheet.- Specified by:
clone
in interfaceCSSStyleSheet<AbstractCSSRule>
- Specified by:
clone
in interfaceDocumentCSSStyleSheet
- Specified by:
clone
in classAbstractCSSStyleSheet
- Returns:
- the cloned style sheet.
-
clone
Clone this style sheet, but only preserving rules targeting the given medium.- Specified by:
clone
in interfaceDocumentCSSStyleSheet
- Parameters:
targetMedium
- the medium.- Returns:
- a medium-specific pseudo-clone of this sheet.
-
computeStyle
protected ComputedCSSStyle computeStyle(ComputedCSSStyle style, SelectorMatcher matcher, Condition pseudoElt, InlineStyle inlineStyle) Compute the style for an element.- Parameters:
style
- a base, empty style to be filled with the computed style.matcher
- the selector matcher.pseudoElt
- the pseudo-element.inlineStyle
- the inline style for the element.- Returns:
- the computed CSS style, or an empty style declaration if none applied or the sheet is disabled.
-
computeRevertedStyle
protected ComputedCSSStyle computeRevertedStyle(ComputedCSSStyle style, SelectorMatcher matcher, Condition pseudoElt, BaseCSSStyleDeclaration inlineStyle, int origin)
-