- All Implemented Interfaces:
ExtendedCSSStyleSheet<AbstractCSSRule>,Cloneable,CSSStyleSheet,StyleSheet
- Direct Known Subclasses:
BaseDocumentCSSStyleSheet,DOMCSSStyleSheet
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseCSSStyleSheet(String title, MediaQueryList media, AbstractCSSRule ownerRule, byte origin) Constructs a style sheet. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddLocalRule(CSSRule cssrule) Inserts a local rule in the current insertion point (generally after the last rule).voidaddRule(AbstractCSSRule cssrule) Inserts a rule in the current insertion point (generally after the last rule).voidAdds the rules contained by the supplied style sheet, if that sheet is not disabled.protected voidcopyAllTo(BaseCSSStyleSheet myCopy) protected voidcopyFieldsTo(BaseCSSStyleSheet myCopy) protected voidcopyRulesTo(BaseCSSStyleSheet myCopy) createCounterStyleRule(String name) Create a CSSCounterStyleRule compatible with this implementation.Create a CSS Font Face rule compatible with this implementation.createFontFeatureValuesRule(String[] fontFamily) Create a CSSFontFeatureValuesRule compatible with this implementation.createImportRule(MediaQueryList mediaList, String href) Create a CSS import rule compatible with this implementation.createKeyframesRule(String keyframesName) Create a CSSKeyframesRule compatible with this implementation.createMarginRule(String name) Create a CSS margin rule compatible with this implementation.createMediaRule(MediaQueryList mediaList) Create a CSS media rule.createNamespaceRule(String prefix, String namespaceUri) Create a CSS namespace rule compatible with this implementation.Create a CSS page rule compatible with this implementation.Create a CSS style declaration compatible with this implementation.protected BaseCSSStyleDeclarationCreate a CSS style rule.Create a CSSSupportsRule compatible with this implementation.Create a CSS unknown rule.Create a CSSViewportRule compatible with this implementation.voiddeleteRule(int index) Deletes a rule from the style sheet.Gets the collection of all CSS rules contained within the style sheet.booleanprotected ErrorHandlerGets the error handler for this style sheet.getHref()getMedia()Get the destination media for this sheet.protected StringgetNamespacePrefix(String uri) Gets the namespace prefix associated to the given URI.byteGet the origin of this sheet.getRulesForProperty(String longhandPropertyName) Returns a list of rules that apply to a style where the given longhand property is set (either explicitly or through a shorthand).Selector[]getSelectorsForProperty(String longhandPropertyName) Returns an array of selectors that apply to a style where the given longhand property is set (either explicitly or through a shorthand).Selector[]getSelectorsForPropertyValue(String propertyName, String declaredValue) Returns an array of selectors that apply to a style where the given property was explicitly set to the given declared value.abstract BaseCSSStyleSheetFactoryGet the stylesheet factory used to produce this sheet.protected StringgetType()protected booleanHas this style sheet defined a default namespace ?booleanCheck whether this sheet contains rules that have errors or warnings reported to their handlers.intinsertRule(String rule, int index) Used to insert a new rule into the style sheet.booleanloadStyleSheet(URL url, String referrerPolicy) Load the styles fromurlinto this style sheet.booleanparseStyleSheet(InputSource source) Parses a style sheet.booleanparseStyleSheet(InputSource source, boolean ignoreComments) Parses a style sheet.protected voidregisterNamespace(CSSNamespaceRule nsrule) voidsetDisabled(boolean disabled) voidprotected voidsetMedia(MediaQueryList media) Set the destination media for this sheet.protected voidReturns a minified parsable representation of the rule list of this sheet.toString()Returns a serialization of this style sheet in the form of aSTYLEelement with its attributes and content.protected voidunregisterNamespace(String namespaceURI) Methods inherited from class io.sf.carte.doc.style.css.om.AbstractCSSStyleSheet
clone, openConnection, parseRelAttributeMethods inherited from class io.sf.carte.doc.style.css.om.AbstractStyleSheet
getTitle, setTitleMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.w3c.dom.stylesheets.StyleSheet
getTitle
-
Constructor Details
-
BaseCSSStyleSheet
protected BaseCSSStyleSheet(String title, MediaQueryList media, AbstractCSSRule ownerRule, byte origin) Constructs a style sheet.- Parameters:
title- the advisory title.media- the media this sheet is for.ownerRule- the owner rule.origin- the sheet origin.
-
-
Method Details
-
copyAllTo
-
copyFieldsTo
-
copyRulesTo
-
getStyleSheetFactory
Get the stylesheet factory used to produce this sheet.- Specified by:
getStyleSheetFactoryin interfaceExtendedCSSStyleSheet<AbstractCSSRule>- Specified by:
getStyleSheetFactoryin classAbstractCSSStyleSheet- Returns:
- the stylesheet factory.
-
getOwnerRule
- Specified by:
getOwnerRulein interfaceCSSStyleSheet- Specified by:
getOwnerRulein classAbstractCSSStyleSheet
-
getOwnerNode
-
getMedia
Description copied from interface:ExtendedCSSStyleSheetGet the destination media for this sheet.- Returns:
- the media query list.
-
setMedia
Description copied from class:AbstractStyleSheetSet the destination media for this sheet.- Specified by:
setMediain classAbstractStyleSheet- Parameters:
media- the destination media.- Throws:
DOMException- if themediais invalid.
-
getOrigin
public byte getOrigin()Description copied from class:AbstractCSSStyleSheetGet the origin of this sheet.- Specified by:
getOriginin classAbstractCSSStyleSheet- Returns:
- the origin of this sheet.
-
getCssRules
Description copied from interface:ExtendedCSSStyleSheetGets the collection of all CSS rules contained within the style sheet.- Specified by:
getCssRulesin interfaceCSSStyleSheet- Specified by:
getCssRulesin interfaceExtendedCSSStyleSheet<AbstractCSSRule>- Specified by:
getCssRulesin classAbstractCSSStyleSheet- Returns:
- the list of all CSS rules contained within the style sheet.
-
insertRule
Used to insert a new rule into the style sheet. The new rule now becomes part of the cascade.- Parameters:
rule- 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@importrule 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.
-
addRule
Inserts a rule in the current insertion point (generally after the last rule).- Parameters:
cssrule- the rule to be inserted.- Throws:
DOMException- NAMESPACE_ERR if the rule could not be added due to a namespace-related error.
-
registerNamespace
- Specified by:
registerNamespacein classAbstractCSSStyleSheet
-
unregisterNamespace
- Specified by:
unregisterNamespacein classAbstractCSSStyleSheet
-
addLocalRule
Inserts a local rule in the current insertion point (generally after the last rule).- Parameters:
cssrule- the rule to be inserted.
-
deleteRule
Deletes a rule from the style sheet.- Parameters:
index- The index within the style sheet's rule list of the rule to remove.- Throws:
DOMException- INDEX_SIZE_ERR: Raised if the specified index does not correspond to a rule in the style sheet's rule list.
NAMESPACE_ERR: Raised if the rule is a namespace rule and this style sheet contains style rules with that namespace.
-
addStyleSheet
Adds the rules contained by the supplied style sheet, if that sheet is not disabled.If the provided sheet does not target all media, a media rule is created.
- Specified by:
addStyleSheetin interfaceExtendedCSSStyleSheet<AbstractCSSRule>- Specified by:
addStyleSheetin classAbstractCSSStyleSheet- Parameters:
sheet- the sheet whose rules are to be added.
-
createCounterStyleRule
Description copied from interface:ExtendedCSSStyleSheetCreate a CSSCounterStyleRule compatible with this implementation.- Parameters:
name- the counter-style name.- Returns:
- a CSSCounterStyleRule object.
-
createFontFaceRule
Description copied from interface:ExtendedCSSStyleSheetCreate a CSS Font Face rule compatible with this implementation.- Specified by:
createFontFaceRulein interfaceExtendedCSSStyleSheet<AbstractCSSRule>- Specified by:
createFontFaceRulein classAbstractCSSStyleSheet- Returns:
- a CSS Font Face rule object.
-
createFontFeatureValuesRule
Description copied from interface:ExtendedCSSStyleSheetCreate a CSSFontFeatureValuesRule compatible with this implementation.- Parameters:
fontFamily- the font family.- Returns:
- a CSSFontFeatureValuesRule object.
-
createImportRule
Description copied from interface:ExtendedCSSStyleSheetCreate a CSS import rule compatible with this implementation.- Specified by:
createImportRulein interfaceExtendedCSSStyleSheet<AbstractCSSRule>- Specified by:
createImportRulein classAbstractCSSStyleSheet- Parameters:
mediaList- a list of media types for which the new import rule may be used.href- the URI from which to import the sheet.- Returns:
- a CSS import rule.
-
createKeyframesRule
Description copied from interface:ExtendedCSSStyleSheetCreate a CSSKeyframesRule compatible with this implementation.- Parameters:
keyframesName- the name of the keyframes.- Returns:
- a CSSKeyframesRule object.
-
createMarginRule
Description copied from interface:ExtendedCSSStyleSheetCreate a CSS margin rule compatible with this implementation.- Parameters:
name- the margin rule name.- Returns:
- a CSS margin rule.
-
createMediaRule
Description copied from interface:ExtendedCSSStyleSheetCreate a CSS media rule.- Specified by:
createMediaRulein interfaceExtendedCSSStyleSheet<AbstractCSSRule>- Specified by:
createMediaRulein classAbstractCSSStyleSheet- Parameters:
mediaList- a list of media types for the new rule.- Returns:
- a CSS media rule.
-
createNamespaceRule
Description copied from interface:ExtendedCSSStyleSheetCreate a CSS namespace rule compatible with this implementation.- Parameters:
prefix- the namespace prefix.namespaceUri- the namespace URI.- Returns:
- a CSS namespace rule.
-
createPageRule
Description copied from interface:ExtendedCSSStyleSheetCreate a CSS page rule compatible with this implementation.- Specified by:
createPageRulein interfaceExtendedCSSStyleSheet<AbstractCSSRule>- Specified by:
createPageRulein classAbstractCSSStyleSheet- Returns:
- a CSS page rule.
-
createStyleRule
Description copied from interface:ExtendedCSSStyleSheetCreate a CSS style rule.- Specified by:
createStyleRulein interfaceExtendedCSSStyleSheet<AbstractCSSRule>- Specified by:
createStyleRulein classAbstractCSSStyleSheet- Returns:
- a CSS style rule.
-
createSupportsRule
Description copied from interface:ExtendedCSSStyleSheetCreate a CSSSupportsRule compatible with this implementation.- Specified by:
createSupportsRulein interfaceExtendedCSSStyleSheet<AbstractCSSRule>- Specified by:
createSupportsRulein classAbstractCSSStyleSheet- Returns:
- a CSSSupportsRule object.
-
createViewportRule
Description copied from interface:ExtendedCSSStyleSheetCreate a CSSViewportRule compatible with this implementation.- Specified by:
createViewportRulein interfaceExtendedCSSStyleSheet<AbstractCSSRule>- Specified by:
createViewportRulein classAbstractCSSStyleSheet- Returns:
- a CSSViewportRule object.
-
createUnknownRule
Description copied from interface:ExtendedCSSStyleSheetCreate a CSS unknown rule.Its contents can be set with
CSSRule.setCssText(String). Be careful to set a text that is compatible with a CSS rule, with an ending semicolon or balanced curly brackets, otherwise its serialization may break the style sheet serialization.- Specified by:
createUnknownRulein interfaceExtendedCSSStyleSheet<AbstractCSSRule>- Specified by:
createUnknownRulein classAbstractCSSStyleSheet- Returns:
- a CSS unknown rule.
-
createStyleDeclaration
- Specified by:
createStyleDeclarationin classAbstractCSSStyleSheet
-
createStyleDeclaration
Description copied from interface:ExtendedCSSStyleSheetCreate a CSS style declaration compatible with this implementation.- Specified by:
createStyleDeclarationin interfaceExtendedCSSStyleSheet<AbstractCSSRule>- Specified by:
createStyleDeclarationin classAbstractCSSStyleSheet- Returns:
- a CSS style declaration.
-
hasRuleErrorsOrWarnings
public boolean hasRuleErrorsOrWarnings()Description copied from interface:ExtendedCSSStyleSheetCheck whether this sheet contains rules that have errors or warnings reported to their handlers.- Returns:
trueif this sheet contains rules that have errors or warnings.
-
getErrorHandler
Description copied from interface:ExtendedCSSStyleSheetGets the error handler for this style sheet.- Returns:
- the error handler.
-
getDocumentErrorHandler
- Specified by:
getDocumentErrorHandlerin classAbstractStyleSheet
-
getType
-
getNamespacePrefix
Gets the namespace prefix associated to the given URI.- Specified by:
getNamespacePrefixin classAbstractCSSStyleSheet- Parameters:
uri- the namespace URI string.- Returns:
- the namespace prefix, or null if the URI is not known.
-
hasDefaultNamespace
protected boolean hasDefaultNamespace()Has this style sheet defined a default namespace ?- Specified by:
hasDefaultNamespacein classAbstractCSSStyleSheet- Returns:
trueif a default namespace was defined,falseotherwise.
-
getDisabled
public boolean getDisabled() -
setDisabled
public void setDisabled(boolean disabled) -
getParentStyleSheet
- Specified by:
getParentStyleSheetin interfaceStyleSheet- Specified by:
getParentStyleSheetin classAbstractCSSStyleSheet
-
setParentStyleSheet
- Specified by:
setParentStyleSheetin classAbstractCSSStyleSheet
-
getHref
-
setHref
- Specified by:
setHrefin classAbstractCSSStyleSheet
-
loadStyleSheet
Load the styles fromurlinto this style sheet.- Specified by:
loadStyleSheetin classAbstractCSSStyleSheet- Parameters:
url- the url to load the style sheet from.referrerPolicy- the content of thereferrerpolicycontent attribute, if any, or the empty string.- Returns:
trueif the SAC parser reported no errors or fatal errors,falseotherwise.- Throws:
DOMException- if there is a serious problem parsing the style sheet.IOException- if a problem appears fetching the url contents.
-
getRulesForProperty
Returns a list of rules that apply to a style where the given longhand property is set (either explicitly or through a shorthand).Grouping rules are scanned too, regardless of the medium or condition.
- Parameters:
longhandPropertyName- the longhand property name.- Returns:
- the list of rules, or
nullif no rules declare that property, or the property is a shorthand.
-
getSelectorsForProperty
Returns an array of selectors that apply to a style where the given longhand property is set (either explicitly or through a shorthand).Grouping rules are scanned too, regardless of the medium or condition.
- Parameters:
longhandPropertyName- the longhand property name.- Returns:
- the array of selectors, or
nullif no rules declare that property, or the property is a shorthand.
-
getSelectorsForPropertyValue
Returns an array of selectors that apply to a style where the given property was explicitly set to the given declared value.Media rules are scanned too, regardless of the specific medium.
Beware that using this method with computed instead of declared values may not give the expected results.
- Parameters:
propertyName- the property name.declaredValue- the property's declared value.- Returns:
- the array of selectors, or
nullif no rules contain that property-value pair.
-
getTargetMedium
-
toMinifiedString
Description copied from class:AbstractStyleSheetReturns a minified parsable representation of the rule list of this sheet.- Specified by:
toMinifiedStringin classAbstractStyleSheet- Returns:
- a minified parsable representation of the rule list of this sheet.
-
toString
-
toStyleString
Description copied from class:AbstractStyleSheetReturns a serialization of this style sheet in the form of aSTYLEelement with its attributes and content.- Specified by:
toStyleStringin classAbstractStyleSheet- Returns:
- an HTML
STYLEelement representing this style sheet.
-
parseStyleSheet
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.To create a sheet, see
CSSStyleSheetFactory.createStyleSheet(String,MediaQueryList)- Specified by:
parseStyleSheetin interfaceExtendedCSSStyleSheet<AbstractCSSRule>- Specified by:
parseStyleSheetin classAbstractCSSStyleSheet- Parameters:
source- the SAC input source.- Returns:
trueif the SAC parser reported no errors or fatal errors, false otherwise.- Throws:
DOMException- if a problem is found parsing the sheet.IOException- if a problem is found reading the sheet.
-
parseStyleSheet
public boolean parseStyleSheet(InputSource source, boolean ignoreComments) throws DOMException, IOException 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
ignoreCommentsis false, the comments preceding a rule will be available throughAbstractCSSRule.getPrecedingComments().This method resets the state of this sheet's error handler.
To create a sheet, see
CSSStyleSheetFactory.createStyleSheet(String,MediaQueryList)- Specified by:
parseStyleSheetin interfaceExtendedCSSStyleSheet<AbstractCSSRule>- Specified by:
parseStyleSheetin classAbstractCSSStyleSheet- Parameters:
source- the SAC input source.ignoreComments- true if comments have to be ignored.- Returns:
trueif the SAC parser reported no errors or fatal errors, false otherwise.- Throws:
DOMException- if a problem is found parsing the sheet.IOException- if a problem is found reading the sheet.
-