Package io.sf.carte.doc.style.css
Interface CSSDocument
- All Known Implementing Classes:
DOMDocument
,HTMLDocument
,StylableDocumentWrapper
A CSS-enabled Document.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
The style computations operate under a compliance mode. -
Field Summary
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
-
Method Summary
Modifier and TypeMethodDescriptioncreateElement
(String tagName) Creates an element of the type specified.createElementNS
(String namespaceURI, String qualifiedName) void
Enables a style sheet set.Gets the Base URL of this Document.Gets the document's canvas for the current target medium.default String
Get the compatibility mode (compatMode
) attribute.Get the compliance mode of this document.Get the child node which is the document element of this document.getElementById
(String elementId) Gets the document-level error handler.Gets the style sheet set that was last selected.Get the referrer policy obtained through the 'Referrer-Policy' header or a meta element.Gets the title of the currently selected style sheet set.Gets the style database currently used to apply specific styles to this document.Gets the merged style sheet that applies to this document, resulting from the merge of the document's default style sheet, the document linked or embedded style sheets, and the non-important part of the user style sheet.CSSStyleSheetList<? extends CSSRule>
A list containing all the style sheets explicitly linked into or embedded in a document.Gets the list of available style set titles.This document's current target medium name (e.g.Gets an URL for the given URI, taking into account the Base URL if appropriate.boolean
Has any of the linked or embedded style sheets any error or warning ?boolean
isAuthorizedOrigin
(URL url) Determine whether the retrieval of the given URL is authorized.boolean
isSafeOrigin
(URL linkedURL) Is the provided URL a safe origin to load certain external resources?boolean
isVisitedURI
(String href) Has this URI been visited by the agent ?openConnection
(URL url) Opens a connection for the given URL.default void
Forces the cascade to be rebuilt the next time that a computed style is obtained.void
registerProperty
(CSSPropertyDefinition definition) Registers the definition of a custom property.void
Selects a style sheet set, disabling the other non-persistent sheet sets.void
setTargetMedium
(String medium) Set the medium that will be used to compute the styles of this document.Methods inherited from interface io.sf.carte.doc.style.css.CSSNode
getOwnerDocument
Methods inherited from interface org.w3c.dom.Document
adoptNode, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createEntityReference, createProcessingInstruction, createTextNode, getDoctype, getDocumentURI, getDomConfig, getElementsByTagName, getElementsByTagNameNS, getImplementation, getInputEncoding, getStrictErrorChecking, getXmlEncoding, getXmlStandalone, getXmlVersion, importNode, normalizeDocument, renameNode, setDocumentURI, setStrictErrorChecking, setXmlStandalone, setXmlVersion
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
-
Method Details
-
createElement
Creates an element of the type specified.The presence of
IMPLIED
attributes is implementation-dependent.- Specified by:
createElement
in interfaceDocument
- Parameters:
tagName
- the tag name of the element to create.- Returns:
- the new
CSSElement
. - Throws:
DOMException
- INVALID_CHARACTER_ERR if the name is not an XML valid name.
-
createElementNS
- Specified by:
createElementNS
in interfaceDocument
- Throws:
DOMException
-
getCompatMode
Get the compatibility mode (compatMode
) attribute.- Returns:
- the string "BackCompat" if document’s mode is
QUIRKS
, otherwise "CSS1Compat".
-
getComplianceMode
CSSDocument.ComplianceMode getComplianceMode()Get the compliance mode of this document.The styling in this document operate under a compliance mode. Two modes are supported:
STRICT
andQUIRKS
.QUIRKS
andSTRICT
differ in the matching of class and ID selectors, and the default user agent sheet is slightly different.- Returns:
- the compliance mode.
-
getDocumentElement
CSSElement getDocumentElement()Get the child node which is the document element of this document.- Specified by:
getDocumentElement
in interfaceDocument
- Returns:
- the document element.
-
getElementById
- Specified by:
getElementById
in interfaceDocument
-
getStyleSheets
CSSStyleSheetList<? extends CSSRule> getStyleSheets()A list containing all the style sheets explicitly linked into or embedded in a document. For HTML documents, this includes external style sheets, included via the HTML LINK element, and inline STYLE elements.- Specified by:
getStyleSheets
in interfaceorg.w3c.dom.stylesheets.DocumentStyle
-
getStyleSheetSets
DOMStringList getStyleSheetSets()Gets the list of available style set titles.- Returns:
- the list of available style set titles.
-
getSelectedStyleSheetSet
String getSelectedStyleSheetSet()Gets the title of the currently selected style sheet set.- Returns:
- the title of the currently selected style sheet, or the empty string if none is selected.
-
setSelectedStyleSheetSet
Selects a style sheet set, disabling the other non-persistent sheet sets. If the name is the empty string, all non-persistent sheets will be disabled. Otherwise, if the name does not match any of the sets, does nothing.- Parameters:
name
- the case-sensitive name of the set to select.
-
getLastStyleSheetSet
String getLastStyleSheetSet()Gets the style sheet set that was last selected.- Returns:
- the last selected style sheet set, or
null
if none.
-
enableStyleSheetsForSet
Enables a style sheet set. If the name does not match any of the sets, does nothing.- Parameters:
name
- the case-sensitive name of the set to enable.
-
registerProperty
Registers the definition of a custom property.- Parameters:
definition
- the definition.- See Also:
-
getStyleSheet
DocumentCSSStyleSheet getStyleSheet()Gets the merged style sheet that applies to this document, resulting from the merge of the document's default style sheet, the document linked or embedded style sheets, and the non-important part of the user style sheet. Does not include overriden styles nor the 'important' part of the user-defined style sheet.- Returns:
- the merged style sheet that applies to this document.
-
getStyleDatabase
StyleDatabase getStyleDatabase()Gets the style database currently used to apply specific styles to this document.- Returns:
- the style database.
-
setTargetMedium
Set the medium that will be used to compute the styles of this document.- Parameters:
medium
- the target medium.- Throws:
CSSMediaException
- if the document is unable to target the given medium.
-
getTargetMedium
String getTargetMedium()This document's current target medium name (e.g. 'screen').- Returns:
- the target medium name of this document.
-
getCanvas
CSSCanvas getCanvas()Gets the document's canvas for the current target medium.- Returns:
- the canvas, or null if the DeviceFactory does not support canvas for the current medium.
-
rebuildCascade
default void rebuildCascade()Forces the cascade to be rebuilt the next time that a computed style is obtained.This method should be called after you modify the styles in a way that is not detected by the library (like modifying a value).
-
getReferrerPolicy
String getReferrerPolicy()Get the referrer policy obtained through the 'Referrer-Policy' header or a meta element.- Returns:
- the referrer policy, or the empty string if none was specified.
-
isSafeOrigin
Is the provided URL a safe origin to load certain external resources?- Parameters:
linkedURL
- the URL of the external resource.- Returns:
true
if is a safe origin,false
otherwise.
-
isAuthorizedOrigin
Determine whether the retrieval of the given URL is authorized.This check is less restrictive than
isSafeOrigin(URL)
.- Parameters:
url
- the URL to check.- Returns:
true
if allowed.
-
getBaseURL
URL getBaseURL()Gets the Base URL of this Document.- Returns:
- the base URL, or null if no base URL could be determined.
-
getURL
Gets an URL for the given URI, taking into account the Base URL if appropriate.- Parameters:
uri
- the uri.- Returns:
- the absolute URL.
- Throws:
MalformedURLException
- if the uri was wrong.
-
openConnection
Opens a connection for the given URL.- Parameters:
url
- the URL to open a connection to.- Returns:
- the URL connection.
- Throws:
IOException
- if the connection could not be opened.
-
isVisitedURI
Has this URI been visited by the agent ?- Parameters:
href
- the URI.- Returns:
true
if visited,false
if not visited or the agent does not support history.
-
getErrorHandler
ErrorHandler getErrorHandler()Gets the document-level error handler.- Returns:
- the error handler.
-
hasStyleIssues
boolean hasStyleIssues()Has any of the linked or embedded style sheets any error or warning ?- Returns:
true
if any of the linked or embedded style sheets has any NSAC or rule error or warning,false
otherwise.
-