JavaScript is disabled on your browser.
Skip navigation links
org.htmlunit.css

Class CssStyleSheet

  • All Implemented Interfaces:
    Serializable


    public class CssStyleSheet
    extends Object
    implements Serializable 
    A css StyleSheet.
    Author:
    Marc Guillemot, Daniel Gredler, Ahmed Ashour, Ronald Brill, Guy Burton, Frank Danek, Carsten Steul, Sven Strickroth
    See Also:
    Serialized Form
    • Constructor Detail

      • CssStyleSheet

        public CssStyleSheet(HtmlElement element,
         org.htmlunit.cssparser.parser.InputSource source,
         String uri)
        Creates a new stylesheet representing the CSS stylesheet for the specified input source.
        Parameters:
        element - the owning node
        source - the input source which contains the CSS stylesheet which this stylesheet host object represents
        uri - this stylesheet's URI (used to resolved contained @import rules)
      • CssStyleSheet

        public CssStyleSheet(HtmlElement element,
         String styleSheet,
         String uri)
        Creates a new stylesheet representing the CSS stylesheet for the specified input source.
        Parameters:
        element - the owning node
        styleSheet - the source which contains the CSS stylesheet which this stylesheet host object represents
        uri - this stylesheet's URI (used to resolved contained @import rules)
      • CssStyleSheet

        public CssStyleSheet(HtmlElement element,
         org.htmlunit.cssparser.dom.CSSStyleSheetImpl wrapped,
         String uri)
        Creates a new stylesheet representing the specified CSS stylesheet.
        Parameters:
        element - the owning node
        wrapped - the CSS stylesheet which this stylesheet host object represents
        uri - this stylesheet's URI (used to resolved contained @import rules)
    • Method Detail

      • getUri

        public String getUri()
        Returns this stylesheet's URI (used to resolved contained @import rules). For inline styles this is the page uri.
        Returns:
        this stylesheet's URI (used to resolved contained @import rules)
      • isEnabled

        public boolean isEnabled()
        Returns true if this stylesheet is enabled.
        Returns:
        true if this stylesheet is enabled
      • setEnabled

        public void setEnabled(boolean enabled)
        Sets whether this sheet is enabled or not.
        Parameters:
        enabled - enabled or not
      • loadStylesheet

        public static CssStyleSheet loadStylesheet(HtmlElement element,
         HtmlLink link,
         String url)
        Loads the stylesheet at the specified link or href.
        Parameters:
        element - the parent DOM element
        link - the stylesheet's link (may be null if a url is specified)
        url - the stylesheet's url (may be null if a link is specified)
        Returns:
        the loaded stylesheet
      • selects

        public static boolean selects(BrowserVersion browserVersion,
         org.htmlunit.cssparser.parser.selector.Selector selector,
         DomElement element,
         String pseudoElement,
         boolean fromQuerySelectorAll,
         boolean throwOnSyntax)
        Returns true if the specified selector selects the specified element.
        Parameters:
        browserVersion - the browser version
        selector - the selector to test
        element - the element to test
        pseudoElement - the pseudo element to match, (can be null)
        fromQuerySelectorAll - whether this is called from DomNode.querySelectorAll(String)
        throwOnSyntax - throw exception if the selector syntax is incorrect
        Returns:
        true if it does apply, false if it doesn't apply
      • parseMedia

        public static org.htmlunit.cssparser.dom.MediaListImpl parseMedia(String mediaString,
         WebClient webClient)
        Parses the given media string. If anything at all goes wrong, this method returns an empty MediaList list.
        Parameters:
        mediaString - the source from which to retrieve the media to be parsed
        webClient - the WebClient to be used
        Returns:
        the media parsed from the specified input source
      • isActive

        public boolean isActive()
        Returns true if this stylesheet is active, based on the media types it is associated with (if any).
        Returns:
        true if this stylesheet is active, based on the media types it is associated with (if any)
      • modifyIfNecessary

        public void modifyIfNecessary(ComputedCssStyleDeclaration style,
         DomElement element,
         String pseudoElement)
        Modifies the specified style object by adding any style rules which apply to the specified element.
        Parameters:
        style - the style to modify
        element - the element to which style rules must apply in order for them to be added to the specified style
        pseudoElement - a string specifying the pseudo-element to match (may be null)
Skip navigation links

Copyright © 2002–2025 Gargoyle Software Inc.. All rights reserved.

AltStyle によって変換されたページ (->オリジナル) /