Class CSSStyleSheet

java.lang.Object
org.htmlunit.corejs.javascript.ScriptableObject
All Implemented Interfaces:
Serializable, Cloneable, org.htmlunit.corejs.javascript.ConstProperties, org.htmlunit.corejs.javascript.debug.DebuggableObject, org.htmlunit.corejs.javascript.Scriptable, org.htmlunit.corejs.javascript.SymbolScriptable

public class CSSStyleSheet extends StyleSheet
A JavaScript object for CSSStyleSheet.
Author:
Marc Guillemot, Daniel Gredler, Ahmed Ashour, Ronald Brill, Guy Burton, Frank Danek, Carsten Steul
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject

    org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator
  • Field Summary

    Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject

    CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST

    Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable

    NOT_FOUND
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new empty stylesheet.
    CSSStyleSheet(HTMLElement element, String styleSheet, String uri)
    Creates a new stylesheet representing the CSS stylesheet for the specified input source.
    CSSStyleSheet(HTMLElement element, org.htmlunit.corejs.javascript.Scriptable parentScope, CssStyleSheet cssStyleSheet)
    Creates a new stylesheet representing the specified CSS stylesheet.
    CSSStyleSheet(HTMLElement element, org.htmlunit.cssparser.parser.InputSource source, String uri)
    Creates a new stylesheet representing the CSS stylesheet for the specified input source.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    addRule(String selector, String rule)
    Adds a new rule.
    void
    deleteRule(int position)
    Deletes an existing rule.
    Returns the collection of rules defined in this style sheet.
    Returns the wrapped stylesheet.
    Retrieves the collection of rules defined in this style sheet.
    Returns this stylesheet's URI (used to resolved contained @import rules).
    int
    insertRule(String rule, int position)
    Inserts a new rule.
    void
    Creates a new empty stylesheet.
    void
    removeRule(int position)
    Deletes an existing rule.
    static void
    validateSelectors(org.htmlunit.cssparser.parser.selector.SelectorList selectorList, int documentMode, DomNode domNode)

    Methods inherited from class StyleSheet

    getHref, getOwnerNode

    Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject

    applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setPrototype, size

    Methods inherited from class Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CSSStyleSheet

      public CSSStyleSheet()
      Creates a new empty stylesheet.
    • 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.corejs.javascript.Scriptable parentScope, CssStyleSheet cssStyleSheet)
      Creates a new stylesheet representing the specified CSS stylesheet.
      Parameters:
      element - the owning node
      parentScope - the parent scope
      cssStyleSheet - the CSS stylesheet which this stylesheet host object represents
  • Method Details

    • jsConstructor

      public void jsConstructor()
      Creates a new empty stylesheet.
      Overrides:
      jsConstructor in class StyleSheet
    • getCssStyleSheet

      public CssStyleSheet getCssStyleSheet()
      Returns the wrapped stylesheet.
      Returns:
      the wrapped stylesheet
    • getRules

      public CSSRuleList getRules()
      Retrieves the collection of rules defined in this style sheet.
      Returns:
      the collection of rules defined in this style sheet
    • getCssRules

      public CSSRuleList getCssRules()
      Returns the collection of rules defined in this style sheet.
      Returns:
      the collection of rules defined in this style sheet
    • insertRule

      public int insertRule(String rule, int position)
      Inserts a new rule.
      Parameters:
      rule - the CSS rule
      position - the position at which to insert the rule
      Returns:
      the position of the inserted rule
      See Also:
    • deleteRule

      public void deleteRule(int position)
      Deletes an existing rule.
      Parameters:
      position - the position of the rule to be deleted
      See Also:
    • addRule

      public int addRule(String selector, String rule)
      Adds a new rule.
      Parameters:
      selector - the selector name
      rule - the rule
      Returns:
      always return -1 as of MSDN documentation
      See Also:
    • removeRule

      public void removeRule(int position)
      Deletes an existing rule.
      Parameters:
      position - the position of the rule to be deleted
      See Also:
    • getUri

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

      @Deprecated public static void validateSelectors(org.htmlunit.cssparser.parser.selector.SelectorList selectorList, int documentMode, DomNode domNode) throws org.htmlunit.cssparser.parser.CSSException
      Validates the list of selectors.
      Parameters:
      selectorList - the selectors
      documentMode - see Document.getDocumentMode()
      domNode - the dom node the query should work on
      Throws:
      org.htmlunit.cssparser.parser.CSSException - if a selector is invalid