Class CssSelector

java.lang.Object
com.itextpdf.styledxmlparser.css.selector.AbstractCssSelector
com.itextpdf.styledxmlparser.css.selector.CssSelector
All Implemented Interfaces:
ICssSelector

public class CssSelector extends AbstractCssSelector
ICssSelector implementation for CSS selectors.
  • Constructor Details

    • CssSelector

      public CssSelector (List<ICssSelectorItem> selectorItems)
      Creates a new CssSelector instance.
      Parameters:
      selectorItems - the selector items
    • CssSelector

      public CssSelector (String selector)
      Creates a new CssSelector instance.
      Parameters:
      selector - the selector
  • Method Details

    • matches

      public boolean matches (INode element)
      Description copied from interface: ICssSelector
      Checks if a node matches the selector.
      Parameters:
      element - the node
      Returns:
      true, if the selector is a match for the node
    • matchesWithinScope

      public boolean matchesWithinScope (INode element, INode scope)
      Checks if the node matches this selector, but limits ancestor traversal so that it never goes above the provided scope node.

      This is primarily used to implement :has(...) correctly: when matching a candidate descendant against an argument selector, ancestor combinators must not escape the :has() scope element.

      Parameters:
      element - the element to match
      scope - the scope boundary (inclusive). If null, behaves like matches(INode).
      Returns:
      true if the element matches within the given scope, false otherwise
    • notMatches

      public boolean notMatches (INode element)
      Checks if the node not matches all the selectors.
      Parameters:
      element - the node
      Returns:
      true, if node doesn't match all the selectors