Interface CSSHandler

All Known Subinterfaces:
CSSParser.DeclarationRuleHandler
All Known Implementing Classes:
EmptyCSSHandler

public interface CSSHandler
A CSS event handler for low-level parsing.

Based on SAC's DocumentHandler interface by Philippe Le Hegaret.

  • Method Details

    • parseStart

      void parseStart(ParserControl parserctl)
      Receive notification of the beginning of the parse process.

      The CSS parser will invoke this method only once, before any other methods in this interface, and only when one of the parseStyleSheet, parseRule or parseStyleDeclaration methods were called.

      Parameters:
      parserctl - an object that allows convenient access to certain parser functionalities.
    • endOfStream

      void endOfStream()
      Receive notification of the end of the stream being parsed.

      The CSS parser will invoke this method only once, and it will be the last method invoked during the parse. The parser shall not invoke this method unless it has reached the end of input.

    • comment

      void comment(String text, boolean precededByLF)
      Receive notification of a comment. If the comment appears in a declaration (e.g. color: /* comment */ blue;), the parser notifies the comment before the declaration.
      Parameters:
      text - The comment.
      precededByLF - true if a Line Feed character was found since the previous event.
    • ignorableAtRule

      void ignorableAtRule(String atRule)
      Receive notification of an unknown @-rule not supported by this parser.
      Parameters:
      atRule - The complete @-rule.
    • namespaceDeclaration

      void namespaceDeclaration(String prefix, String uri)
      Receive notification of a namespace declaration.
      Parameters:
      prefix - null if this is the default namespace
      uri - The URI for this namespace.
    • importStyle

      void importStyle(String uri, MediaQueryList media, String defaultNamespaceURI)
      Receive notification of a import rule in the style sheet.
      Parameters:
      uri - The URI of the imported style sheet.
      media - The intended destination media for style information.
      defaultNamespaceURI - The default namespace URI for the imported style sheet.
    • startMedia

      void startMedia(MediaQueryList media)
      Receive notification of the beginning of a media rule.

      The Parser will invoke this method at the beginning of every media rule in the style sheet. There will be a corresponding endMedia() event for every startMedia() event.

      Parameters:
      media - The intended destination media for style information.
    • endMedia

      void endMedia(MediaQueryList media)
      Receive notification of the end of a media rule.
      Parameters:
      media - The intended destination media for style information.
    • startPage

      void startPage(PageSelectorList pageSelectorList)
      Receive notification of the beginning of a page rule.

      The Parser will invoke this method at the beginning of every page rule in the style sheet. There will be a corresponding endPage() event for every startPage() event.

      Parameters:
      pageSelectorList - the page selector list (if any, null otherwise)
    • endPage

      void endPage(PageSelectorList pageSelectorList)
      Receive notification of the end of a page rule.
      Parameters:
      pageSelectorList - the page selector list (if any, null otherwise)
    • startMargin

      void startMargin(String name)
      Receive notification of the beginning of a margin-box rule.

      The Parser will invoke this method at the beginning of every margin rule in the style sheet. There will be a corresponding endMargin() event for every startMargin() event.

      Parameters:
      name - the name of the rule.
    • endMargin

      void endMargin()
      Receive notification of the end of a margin rule.
    • startFontFace

      void startFontFace()
      Receive notification of the beginning of a font face rule.

      The Parser will invoke this method at the beginning of every font face statement in the style sheet. There will be a corresponding endFontFace() event for every startFontFace() event.

    • endFontFace

      void endFontFace()
      Receive notification of the end of a font face rule.
    • startCounterStyle

      void startCounterStyle(String name)
      Start a @counter-style rule.
      Parameters:
      name - the counter-style name.
    • endCounterStyle

      void endCounterStyle()
      End of @counter-style rule.
    • startKeyframes

      void startKeyframes(String name)
      Start a @keyframes rule.
      Parameters:
      name - the keyframes name.
    • endKeyframes

      void endKeyframes()
      End of @keyframes rule.
    • startKeyframe

      void startKeyframe(LexicalUnit keyframeSelector)
      Start a @keyframe.
      Parameters:
      keyframeSelector - the keyframe selector.
    • endKeyframe

      void endKeyframe()
      End of @keyframe.
    • startFontFeatures

      void startFontFeatures(String[] familyName)
      Start a font feature values rule.
      Parameters:
      familyName - the font family names.
    • endFontFeatures

      void endFontFeatures()
      End of font feature values rule.
    • startFeatureMap

      void startFeatureMap(String mapName)
      Start a feature map.
      Parameters:
      mapName - the map name.
    • endFeatureMap

      void endFeatureMap()
      End of feature map.
    • startProperty

      void startProperty(String name)
      Start a @property rule.
      Parameters:
      name - the custom property name.
    • endProperty

      void endProperty(boolean discard)
      End of @property rule.
      Parameters:
      discard - if true, the rule should be discarded.
    • startSupports

      void startSupports(BooleanCondition condition)
      Receive notification of the beginning of a supports rule.

      The Parser will invoke this method at the beginning of every supports rule in the style sheet. There will be a corresponding endSupports() event for every startSupports() event.

      Parameters:
      condition - the supports condition.
    • endSupports

      void endSupports(BooleanCondition condition)
      Receive notification of the end of a supports rule.
      Parameters:
      condition - the supports condition.
    • startSelector

      void startSelector(SelectorList selectors)
      Receive notification of the beginning of a style rule.
      Parameters:
      selectors - the intended selectors for next declarations.
    • endSelector

      void endSelector(SelectorList selectors)
      Receive notification of the end of a style rule.
      Parameters:
      selectors - the intended selectors for the previous declarations.
    • startViewport

      default void startViewport()
      Start a @viewport rule.

      Note: @viewport rules were removed by W3C in February 2020.

    • endViewport

      default void endViewport()
      End of @viewport rule.
    • property

      void property(String name, LexicalUnit value, boolean important)
      Receive notification of a property declaration.
      Parameters:
      name - the name of the property.
      value - the value of the property.
      important - is this property important ?
    • lexicalProperty

      void lexicalProperty(String name, LexicalUnit value, boolean important)
      Receive notification of a property declaration that must be processed as a lexical value.
      Parameters:
      name - the name of the property.
      value - the value of the property.
      important - is this property important ?
    • getStyleSheet

      default CSSStyleSheet<?> getStyleSheet()
      Obtain the style sheet.
      Returns:
      a reference to the style sheet, or null if it couldn't be obtained.