public class CssStyleSheet extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
static String |
ABSOLUTE
"absolute".
|
static String |
AUTO
"auto".
|
static String |
BLOCK
"block".
|
static Set<String> |
CSS2_PSEUDO_CLASSES
Set of CSS2 pseudo class names.
|
static Set<String> |
CSS4_PSEUDO_CLASSES
Set of CSS4 pseudo class names.
|
static String |
FIXED
"fixed".
|
static String |
INHERIT
"inherit".
|
static String |
INITIAL
"initial".
|
static String |
INLINE
"inline".
|
static String |
NONE
"none".
|
static String |
RELATIVE
"relative".
|
static String |
REPEAT
"repeat".
|
static String |
SCROLL
"scroll".
|
static String |
STATIC
"static".
|
Constructor and Description |
---|
CssStyleSheet(HtmlElement element,
org.htmlunit.cssparser.dom.CSSStyleSheetImpl wrapped,
String uri)
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.
|
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 |
---|---|
CssStyleSheet |
getImportedStyleSheet(org.htmlunit.cssparser.dom.CSSImportRuleImpl importRule) |
String |
getUri()
Returns this stylesheet's URI (used to resolved contained @import rules).
|
org.htmlunit.cssparser.dom.CSSStyleSheetImpl |
getWrappedSheet()
Returns the wrapped stylesheet.
|
boolean |
isActive()
Returns
true if this stylesheet is active, based on the media types it is associated with (if any). |
static boolean |
isActive(org.htmlunit.cssparser.dom.MediaListImpl mediaList,
WebWindow webWindow)
Returns whether the specified
MediaList is active or not. |
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,
DomElement element,
String pseudoElement)
Modifies the specified style object by adding any style rules which apply to the specified
element.
|
static org.htmlunit.cssparser.dom.MediaListImpl |
parseMedia(String mediaString,
WebClient webClient)
Parses the given media string.
|
static boolean |
selects(BrowserVersion browserVersion,
org.htmlunit.cssparser.parser.selector.Selector selector,
DomElement element,
String pseudoElement,
boolean fromQuerySelectorAll,
boolean throwOnSyntax)
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(org.htmlunit.cssparser.parser.selector.SelectorList selectorList,
DomNode domNode)
Validates the list of selectors.
|
static void |
validateSelectors(org.htmlunit.cssparser.parser.selector.SelectorList selectorList,
int documentMode,
DomNode domNode)
Deprecated.
as of version 4.5.0; use
validateSelectors(SelectorList, DomNode) instead |
public static final String NONE
public static final String AUTO
public static final String STATIC
public static final String INHERIT
public static final String INITIAL
public static final String RELATIVE
public static final String FIXED
public static final String ABSOLUTE
public static final String REPEAT
public static final String BLOCK
public static final String INLINE
public static final String SCROLL
public static final Set<String> CSS2_PSEUDO_CLASSES
public CssStyleSheet(HtmlElement element, org.htmlunit.cssparser.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, org.htmlunit.cssparser.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 org.htmlunit.cssparser.dom.CSSStyleSheetImpl getWrappedSheet()
public String getUri()
public boolean isEnabled()
true
if this stylesheet is enabled.true
if this stylesheet is enabledpublic void setEnabled(boolean enabled)
enabled
- enabled or notpublic 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, org.htmlunit.cssparser.parser.selector.Selector selector, DomElement element, String pseudoElement, boolean fromQuerySelectorAll, boolean throwOnSyntax)
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)
throwOnSyntax
- throw exception if the selector syntax is incorrecttrue
if it does apply, false
if it doesn't applypublic static org.htmlunit.cssparser.dom.MediaListImpl parseMedia(String mediaString, WebClient webClient)
mediaString
- the source from which to retrieve the media to be parsedwebClient
- the WebClient
to be used@Deprecated public static void validateSelectors(org.htmlunit.cssparser.parser.selector.SelectorList selectorList, int documentMode, DomNode domNode) throws org.htmlunit.cssparser.parser.CSSException
validateSelectors(SelectorList, DomNode)
insteadselectorList
- the selectorsdocumentMode
- see Document.getDocumentMode()
domNode
- the dom node the query should work onorg.htmlunit.cssparser.parser.CSSException
- if a selector is invalidpublic static void validateSelectors(org.htmlunit.cssparser.parser.selector.SelectorList selectorList, DomNode domNode) throws org.htmlunit.cssparser.parser.CSSException
selectorList
- the selectorsdomNode
- the dom node the query should work onorg.htmlunit.cssparser.parser.CSSException
- if a selector is invalidpublic CssStyleSheet getImportedStyleSheet(org.htmlunit.cssparser.dom.CSSImportRuleImpl importRule)
importRule
- the CSSImportRuleImpl
that imports the CssStyleSheet
CssStyleSheet
imported by this rulepublic 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 static boolean isActive(org.htmlunit.cssparser.dom.MediaListImpl mediaList, WebWindow webWindow)
MediaList
is active or not.public void modifyIfNecessary(ComputedCssStyleDeclaration style, DomElement 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
)Copyright © 2002–2024 Gargoyle Software Inc.. All rights reserved.