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:
Serializable
,Cloneable
,org.htmlunit.corejs.javascript.ConstProperties
,org.htmlunit.corejs.javascript.debug.DebuggableObject
,org.htmlunit.corejs.javascript.Scriptable
,org.htmlunit.corejs.javascript.SymbolScriptable
A JavaScript object for
CSSStyleSheet
.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate CSSRuleList
The collection of rules defined in this style sheet.private static final org.apache.commons.logging.Log
private CssStyleSheet
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
ConstructorsConstructorDescriptionCreates 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 TypeMethodDescriptionint
Adds a new rule.void
deleteRule
(int position) Deletes an existing rule.private int
fixIndex
(int index) Returns the collection of rules defined in this style sheet.Returns the wrapped stylesheet.getRules()
Retrieves the collection of rules defined in this style sheet.getUri()
Returns this stylesheet's URI (used to resolved contained @import rules).private void
int
insertRule
(String rule, int position) Inserts a new rule.void
Creates a new empty stylesheet.private void
void
removeRule
(int position) Deletes an existing rule.static void
validateSelectors
(org.htmlunit.cssparser.parser.selector.SelectorList selectorList, int documentMode, DomNode domNode) Deprecated.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 Details
-
LOG
private static final org.apache.commons.logging.Log LOG -
styleSheet_
The parsed stylesheet which this host object wraps. -
cssRules_
The collection of rules defined in this style sheet. -
cssRulesIndexFix_
-
-
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 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
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 Details
-
jsConstructor
public void jsConstructor()Creates a new empty stylesheet.- Overrides:
jsConstructor
in classStyleSheet
-
getCssStyleSheet
Returns the wrapped stylesheet.- Returns:
- the wrapped stylesheet
-
getRules
Retrieves the collection of rules defined in this style sheet.- Returns:
- the collection of rules defined in this style sheet
-
getCssRules
Returns the collection of rules defined in this style sheet.- Returns:
- the collection of rules defined in this style sheet
-
insertRule
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:
-
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:
-
addRule
Adds a new rule.- Parameters:
selector
- the selector namerule
- 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
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()
-
CssStyleSheet.validateSelectors(org.htmlunit.cssparser.parser.selector.SelectorList, int, DomNode)
instead