public class CSSStyleSheet extends StyleSheet
CSSStyleSheet
.Constructor and Description |
---|
CSSStyleSheet()
Creates a new empty stylesheet.
|
CSSStyleSheet(HTMLElement element,
com.gargoylesoftware.css.dom.CSSStyleSheetImpl wrapped,
String uri)
Creates a new stylesheet representing the specified CSS stylesheet.
|
CSSStyleSheet(HTMLElement element,
com.gargoylesoftware.css.parser.InputSource source,
String uri)
Creates a new stylesheet representing the CSS stylesheet for the specified input source.
|
CSSStyleSheet(HTMLElement element,
String styleSheet,
String uri)
Creates a new stylesheet representing the CSS stylesheet for the specified input source.
|
Modifier and Type | Method and Description |
---|---|
int |
addRule(String selector,
String rule)
Adds a new rule.
|
void |
deleteRule(int position)
Deletes an existing rule.
|
CSSRuleList |
getCssRules()
Returns the collection of rules defined in this style sheet.
|
String |
getHref()
Returns the URL of the stylesheet.
|
HTMLElement |
getOwnerNode()
Returns the owner node.
|
HTMLElement |
getOwningElement()
Returns the owner element, same as
getOwnerNode() . |
CSSRuleList |
getRules()
Retrieves the collection of rules defined in this style sheet.
|
String |
getUri()
Returns this stylesheet's URI (used to resolved contained @import rules).
|
com.gargoylesoftware.css.dom.CSSStyleSheetImpl |
getWrappedSheet()
Returns the wrapped stylesheet.
|
int |
insertRule(String rule,
int position)
Inserts a new rule.
|
boolean |
isActive()
Returns
true if this stylesheet is active, based on the media types it is associated with (if any). |
boolean |
isEnabled()
Returns
true if this stylesheet is enabled. |
static CSSStyleSheet |
loadStylesheet(HTMLElement element,
HtmlLink link,
String url)
Loads the stylesheet at the specified link or href.
|
void |
modifyIfNecessary(ComputedCSSStyleDeclaration style,
Element element,
String pseudoElement)
Modifies the specified style object by adding any style rules which apply to the specified
element.
|
com.gargoylesoftware.css.parser.selector.SelectorList |
parseSelectors(String source)
Parses the selectors at the specified input source.
|
void |
removeRule(int position)
Deletes an existing rule.
|
static boolean |
selects(BrowserVersion browserVersion,
com.gargoylesoftware.css.parser.selector.Selector selector,
DomElement element,
String pseudoElement,
boolean fromQuerySelectorAll)
Returns
true if the specified selector selects the specified element. |
void |
setEnabled(boolean enabled)
Sets whether this sheet is enabled or not.
|
static void |
validateSelectors(com.gargoylesoftware.css.parser.selector.SelectorList selectorList,
int documentMode,
DomNode domNode)
Validates the list of selectors.
|
clone, equivalentValues, get, getBrowserVersion, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, getWithPreemption, has, hasInstance, initParentScope, makeScriptableFor, setCaseSensitive, setDomNode, setDomNode, setHtmlElement
defineFunctionProperties, defineProperty, getClassName, put, setClassName, setParentScope
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isReadOnlySettable, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setPrototype, size
public CSSStyleSheet()
public CSSStyleSheet(HTMLElement element, com.gargoylesoftware.css.parser.InputSource source, String uri)
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)public CSSStyleSheet(HTMLElement element, String styleSheet, String uri)
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)public CSSStyleSheet(HTMLElement element, com.gargoylesoftware.css.dom.CSSStyleSheetImpl wrapped, String uri)
element
- the owning nodewrapped
- the CSS stylesheet which this stylesheet host object representsuri
- this stylesheet's URI (used to resolved contained @import rules)public com.gargoylesoftware.css.dom.CSSStyleSheetImpl getWrappedSheet()
public void modifyIfNecessary(ComputedCSSStyleDeclaration style, Element element, String pseudoElement)
style
- the style to modifyelement
- the element to which style rules must apply in order for them to be added to
the specified stylepseudoElement
- a string specifying the pseudo-element to match (may be null
)public static CSSStyleSheet loadStylesheet(HTMLElement element, HtmlLink link, String url)
element
- the parent DOM elementlink
- 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)public static boolean selects(BrowserVersion browserVersion, com.gargoylesoftware.css.parser.selector.Selector selector, DomElement element, String pseudoElement, boolean fromQuerySelectorAll)
true
if the specified selector selects the specified element.browserVersion
- the browser versionselector
- the selector to testelement
- the element to testpseudoElement
- the pseudo element to match, (can be null
)fromQuerySelectorAll
- whether this is called from DomNode.querySelectorAll(String)
true
if it does apply, false
if it doesn't applypublic com.gargoylesoftware.css.parser.selector.SelectorList parseSelectors(String source)
source
- the source from which to retrieve the selectors to be parsedpublic HTMLElement getOwnerNode()
public HTMLElement getOwningElement()
getOwnerNode()
.public CSSRuleList getRules()
public CSSRuleList getCssRules()
public String getHref()
public int insertRule(String rule, int position)
rule
- the CSS ruleposition
- the position at which to insert the rulepublic void deleteRule(int position)
position
- the position of the rule to be deletedpublic int addRule(String selector, String rule)
selector
- the selector namerule
- the rulepublic void removeRule(int position)
position
- the position of the rule to be deletedpublic String getUri()
public boolean isActive()
true
if this stylesheet is active, based on the media types it is associated with (if any).true
if this stylesheet is active, based on the media types it is associated with (if any)public boolean isEnabled()
true
if this stylesheet is enabled.true
if this stylesheet is enabledpublic void setEnabled(boolean enabled)
enabled
- enabled or notpublic static void validateSelectors(com.gargoylesoftware.css.parser.selector.SelectorList selectorList, int documentMode, DomNode domNode) throws com.gargoylesoftware.css.parser.CSSException
selectorList
- the selectorsdocumentMode
- see Document.getDocumentMode()
domNode
- the dom node the query should work oncom.gargoylesoftware.css.parser.CSSException
- if a selector is invalidCopyright © 2002–2020 Gargoyle Software Inc.. All rights reserved.