Class 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:
  • Constructor Details

    • BaseDocumentCSSStyleSheet

      protected BaseDocumentCSSStyleSheet(String medium, int origin)
  • Method Details

    • setHref

      public void setHref(String href)
      Overrides:
      setHref in class BaseCSSStyleSheet
    • getHref

      public String getHref()
      Specified by:
      getHref in interface StyleSheet
      Overrides:
      getHref in class BaseCSSStyleSheet
    • getOwnerNode

      public abstract CSSDocument getOwnerNode()
      Specified by:
      getOwnerNode in interface StyleSheet
      Overrides:
      getOwnerNode in class BaseCSSStyleSheet
    • setOwnerDocument

      public abstract void setOwnerDocument(CSSDocument ownerNode)
    • copyToTarget

      protected void copyToTarget(BaseDocumentCSSStyleSheet myCopy)
    • registerProperty

      public void registerProperty(CSSPropertyDefinition definition)
      Registers the definition of a custom property.
      Specified by:
      registerProperty in interface DocumentCSSStyleSheet
      Parameters:
      definition - the definition.
    • insertRule

      public int insertRule(String ruleText, int index) throws DOMException
      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 interface CSSStyleSheet
      Overrides:
      insertRule in class BaseCSSStyleSheet
      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

      public boolean parseStyleSheet(Reader reader, short commentMode) throws DOMException, IOException
      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 not COMMENTS_IGNORE, the comments preceding a rule shall be available through CSSRule.getPrecedingComments(), and if COMMENTS_AUTO was set also the trailing ones, through the method CSSRule.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 interface CSSStyleSheet<AbstractCSSRule>
      Overrides:
      parseStyleSheet in class BaseCSSStyleSheet
      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

      public String getTargetMedium()
      Gets the target medium for this sheet.
      Specified by:
      getTargetMedium in interface DocumentCSSStyleSheet
      Overrides:
      getTargetMedium in class BaseCSSStyleSheet
      Returns:
      the target medium, or null if is for all media.
    • getComputedStyle

      public abstract ComputedCSSStyle getComputedStyle(CSSElement elm, Condition pseudoElt)
      Gets the computed style for the given element and pseudo-element.
      Specified by:
      getComputedStyle in interface DocumentCSSStyleSheet
      Parameters:
      elm - the element.
      pseudoElt - the pseudo-element condition.
      Returns:
      the computed style declaration.
    • createComputedCSSStyle

      protected abstract ComputedCSSStyle createComputedCSSStyle()
    • clone

      public abstract BaseDocumentCSSStyleSheet clone()
      Clone this style sheet.
      Specified by:
      clone in interface CSSStyleSheet<AbstractCSSRule>
      Specified by:
      clone in interface DocumentCSSStyleSheet
      Specified by:
      clone in class AbstractCSSStyleSheet
      Returns:
      the cloned style sheet.
    • clone

      public abstract BaseDocumentCSSStyleSheet clone(String targetMedium)
      Clone this style sheet, but only preserving rules targeting the given medium.
      Specified by:
      clone in interface DocumentCSSStyleSheet
      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)