Package org.htmlunit.javascript.host.css
Class CSSStyleSheet
- java.lang.Object
-
- org.htmlunit.corejs.javascript.ScriptableObject
-
- org.htmlunit.javascript.HtmlUnitScriptable
-
- org.htmlunit.javascript.host.css.StyleSheet
-
- org.htmlunit.javascript.host.css.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 forCSSStyleSheet
.- See Also:
- MSDN doc, Serialized Form
-
-
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.
-
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)
Deprecated.as of version 3.7.0; useCssStyleSheet.validateSelectors(org.htmlunit.cssparser.parser.selector.SelectorList, int, DomNode)
instead-
Methods inherited from class org.htmlunit.javascript.host.css.StyleSheet
getHref, getOwnerNode
-
Methods inherited from class org.htmlunit.javascript.HtmlUnitScriptable
clone, equivalentValues, get, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, getWithPreemption, has, hasInstance, initParentScope, makeScriptableFor, put, setClassName, setDomNode, setDomNode, setParentScope, setupPromise, setupRejectedPromise
-
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
-
-
-
-
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 nodesource
- the input source which contains the CSS stylesheet which this stylesheet host object representsuri
- 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 nodestyleSheet
- the source which contains the CSS stylesheet which this stylesheet host object representsuri
- 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 nodeparentScope
- the parent scopecssStyleSheet
- the CSS stylesheet which this stylesheet host object represents
-
-
Method Detail
-
jsConstructor
public void jsConstructor()
Creates a new empty stylesheet.- Overrides:
jsConstructor
in classStyleSheet
-
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 ruleposition
- 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 namerule
- 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 classStyleSheet
- 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
Deprecated.as of version 3.7.0; useCssStyleSheet.validateSelectors(org.htmlunit.cssparser.parser.selector.SelectorList, int, DomNode)
insteadValidates the list of selectors.- Parameters:
selectorList
- the selectorsdocumentMode
- seeDocument.getDocumentMode()
domNode
- the dom node the query should work on- Throws:
org.htmlunit.cssparser.parser.CSSException
- if a selector is invalid
-
initCssRules
private void initCssRules()
-
-