Class CSSStyleSheet

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.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.
    See Also:
    MSDN doc, Serialized Form
    • Nested Class Summary

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

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

      Fields 
      Modifier and Type Field Description
      private CSSRuleList cssRules_
      The collection of rules defined in this style sheet.
      private java.util.List<java.lang.Integer> cssRulesIndexFix_  
      private static org.apache.commons.logging.Log LOG  
      private CssStyleSheet styleSheet_
      The parsed stylesheet which this host object wraps.
      • 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
      CSSStyleSheet()
      Creates a new empty stylesheet.
      CSSStyleSheet​(HTMLElement element, java.lang.String styleSheet, java.lang.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, java.lang.String uri)
      Creates a new stylesheet representing the CSS stylesheet for the specified input source.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      int addRule​(java.lang.String selector, java.lang.String rule)
      Adds a new rule.
      void deleteRule​(int position)
      Deletes an existing rule.
      private int fixIndex​(int index)  
      CSSRuleList getCssRules()
      Returns the collection of rules defined in this style sheet.
      CssStyleSheet getCssStyleSheet()
      Returns the wrapped stylesheet.
      CSSRuleList getRules()
      Retrieves the collection of rules defined in this style sheet.
      java.lang.String getUri()
      Returns this stylesheet's URI (used to resolved contained @import rules).
      private void initCssRules()  
      int insertRule​(java.lang.String rule, int position)
      Inserts a new rule.
      void jsConstructor()
      Creates a new empty stylesheet.
      private void refreshCssRules()  
      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 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 java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOG

        private static final org.apache.commons.logging.Log LOG
      • styleSheet_

        private CssStyleSheet styleSheet_
        The parsed stylesheet which this host object wraps.
      • cssRules_

        private CSSRuleList cssRules_
        The collection of rules defined in this style sheet.
      • cssRulesIndexFix_

        private java.util.List<java.lang.Integer> cssRulesIndexFix_
    • Constructor Detail

      • CSSStyleSheet

        public CSSStyleSheet()
        Creates a new empty stylesheet.
      • CSSStyleSheet

        public CSSStyleSheet​(HTMLElement element,
                             org.htmlunit.cssparser.parser.InputSource source,
                             java.lang.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,
                             java.lang.String styleSheet,
                             java.lang.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 Detail

      • 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​(java.lang.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:
        DOM level 2
      • refreshCssRules

        private void refreshCssRules()
      • fixIndex

        private int fixIndex​(int index)
      • deleteRule

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

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

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

        public java.lang.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)
      • initCssRules

        private void initCssRules()