Class PseudoClassSelector

Direct Known Subclasses:
FunctionPseudoClassSelector, SimplePseudoClassSelector

public abstract class PseudoClassSelector extends SimpleSelector
A "pseudo class selector" matches an element based on criteria which are not directly encoded in the element.
Author:
Werner Randelshofer
  • Constructor Details

    • PseudoClassSelector

      public PseudoClassSelector(@Nullable SourceLocator sourceLocator)
  • Method Details

    • getSpecificity

      public final int getSpecificity()
      Description copied from class: Selector
      Returns the specificity of this selector.

      A selector's specificity is calculated as follows:

      • count the number of ID selectors in the selector (= a)
      • count the number of class selectors, attributes selectors, and pseudo-classes in the selector (= b)
      • count the number of type selectors and pseudo-elements in the selector (= c)
      • ignore the universal selector

      Selectors inside the negation pseudo-class are counted like any other, but the negation itself does not count as a pseudo-class.

      Concatenating the three numbers a-b-c (in a number system with a large base) gives the specificity.

      In this implementation we compute specificity with specificity=100*a+10*b+c.

      References:

      CSS Syntax Selectors Level 3, Chapter 9. Calculating a selector's specificity
      w3.org
      Specified by:
      getSpecificity in class Selector
      Returns:
      the specificity