Interface ExtendedCSSStyleSheet<R extends ExtendedCSSRule>

All Superinterfaces:
CSSStyleSheet, StyleSheet
All Known Subinterfaces:
DocumentCSSStyleSheet
All Known Implementing Classes:
AbstractCSSStyleSheet, BaseCSSStyleSheet, BaseDocumentCSSStyleSheet, DOMCSSStyleSheet, DOMDocumentCSSStyleSheet

public interface ExtendedCSSStyleSheet<R extends ExtendedCSSRule> extends CSSStyleSheet
A style sheet.

This extension to the W3C interface adds utility as well as factory methods. The factory methods create rules that have the same origin specificity (like 'author' or 'user') as this style sheet.

  • Method Details

    • addRule

      void addRule(R cssrule) throws DOMException
      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.
    • addStyleSheet

      void addStyleSheet(AbstractCSSStyleSheet sheet)
      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.

      Parameters:
      sheet - the sheet whose rules are to be added.
    • getCssRules

      ExtendedCSSRuleList<R> getCssRules()
      Gets the collection of all CSS rules contained within the style sheet.
      Specified by:
      getCssRules in interface CSSStyleSheet
      Returns:
      the list of all CSS rules contained within the style sheet.
    • getMedia

      MediaQueryList getMedia()
      Get the destination media for this sheet.
      Specified by:
      getMedia in interface StyleSheet
      Returns:
      the media query list.
    • clone

      Clone this style sheet.
      Returns:
      the cloned style sheet.
    • createCounterStyleRule

      CSSCounterStyleRule createCounterStyleRule(String name) throws DOMException
      Create a CSSCounterStyleRule compatible with this implementation.
      Parameters:
      name - the counter-style name.
      Returns:
      a CSSCounterStyleRule object.
      Throws:
      DOMException - if the name is invalid.
    • createFontFaceRule

      ExtendedCSSFontFaceRule createFontFaceRule()
      Create a CSS Font Face rule compatible with this implementation.
      Returns:
      a CSS Font Face rule object.
    • createFontFeatureValuesRule

      CSSFontFeatureValuesRule createFontFeatureValuesRule(String[] fontFamily)
      Create a CSSFontFeatureValuesRule compatible with this implementation.
      Parameters:
      fontFamily - the font family.
      Returns:
      a CSSFontFeatureValuesRule object.
    • createImportRule

      CSSImportRule createImportRule(MediaQueryList mediaList, String href)
      Create a CSS import rule compatible with this implementation.
      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

      CSSKeyframesRule createKeyframesRule(String keyframesName)
      Create a CSSKeyframesRule compatible with this implementation.
      Parameters:
      keyframesName - the name of the keyframes.
      Returns:
      a CSSKeyframesRule object.
    • createMarginRule

      CSSMarginRule createMarginRule(String name)
      Create a CSS margin rule compatible with this implementation.
      Parameters:
      name - the margin rule name.
      Returns:
      a CSS margin rule.
    • createMediaRule

      ExtendedCSSMediaRule createMediaRule(MediaQueryList mediaList)
      Create a CSS media rule.
      Parameters:
      mediaList - a list of media types for the new rule.
      Returns:
      a CSS media rule.
    • createNamespaceRule

      CSSNamespaceRule createNamespaceRule(String prefix, String namespaceUri)
      Create a CSS namespace rule compatible with this implementation.
      Parameters:
      prefix - the namespace prefix.
      namespaceUri - the namespace URI.
      Returns:
      a CSS namespace rule.
      Throws:
      DOMException - INVALID_ACCESS_ERR: if the prefix or the URI are null.
    • createPageRule

      ExtendedCSSPageRule createPageRule()
      Create a CSS page rule compatible with this implementation.
      Returns:
      a CSS page rule.
    • createStyleRule

      CSSStyleDeclarationRule createStyleRule()
      Create a CSS style rule.
      Returns:
      a CSS style rule.
    • createSupportsRule

      CSSSupportsRule createSupportsRule()
      Create a CSSSupportsRule compatible with this implementation.
      Returns:
      a CSSSupportsRule object.
    • createViewportRule

      CSSDeclarationRule createViewportRule()
      Create a CSSViewportRule compatible with this implementation.
      Returns:
      a CSSViewportRule object.
    • createStyleDeclaration

      CSSStyleDeclaration createStyleDeclaration()
      Create a CSS style declaration compatible with this implementation.
      Returns:
      a CSS style declaration.
    • createUnknownRule

      CSSUnknownRule createUnknownRule()
      Create 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.

      Returns:
      a CSS unknown rule.
    • getErrorHandler

      SheetErrorHandler getErrorHandler()
      Gets the error handler for this style sheet.
      Returns:
      the error handler.
    • hasRuleErrorsOrWarnings

      boolean hasRuleErrorsOrWarnings()
      Check whether this sheet contains rules that have errors or warnings reported to their handlers.
      Returns:
      true if this sheet contains rules that have errors or warnings.
    • getRulesForProperty

      ExtendedCSSRuleList<? extends ExtendedCSSRule> 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).

      Grouping rules are scanned too, regardless of the medium or condition.

      Parameters:
      longhandPropertyName - the longhand property name.
      Returns:
      the list of rules, or null if no rules declare that property, or the property is a shorthand.
    • getSelectorsForProperty

      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).

      Grouping rules are scanned too, regardless of the medium or condition.

      Parameters:
      longhandPropertyName - the longhand property name.
      Returns:
      the array of selectors, or null if no rules declare that property, or the property is a shorthand.
    • getStyleSheetFactory

      CSSStyleSheetFactory getStyleSheetFactory()
      Get the style sheet factory used to produce this sheet.
      Returns:
      the style sheet factory.
    • parseStyleSheet

      boolean parseStyleSheet(InputSource source) throws DOMException, IOException
      Parses a source into this style sheet.

      If this style sheet is not empty, the rules from the parsed source will be added at the end of the rule list.

      The comments preceding a rule will be available through AbstractCSSRule.getPrecedingComments().

      Parameters:
      source - the SAC input source.
      Returns:
      true if the SAC parser reported no errors or fatal errors, false otherwise.
      Throws:
      DOMException - if a DOM problem is found parsing the sheet.
      CSSException - if a non-DOM problem is found parsing the sheet.
      IOException - if a problem is found reading the sheet.
    • parseStyleSheet

      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 ignoreComments is false, the comments preceding a rule will be available through AbstractCSSRule.getPrecedingComments().

      To create a sheet, see CSSStyleSheetFactory.createStyleSheet(String,MediaQueryList)

      Parameters:
      source - the SAC input source.
      ignoreComments - true if comments have to be ignored.
      Returns:
      true if 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.