Interface CSSDocument

All Superinterfaces:
CSSNode, Document, DocumentCSS, DocumentStyle, Node
All Known Implementing Classes:
DOMDocument, HTMLDocument, StylableDocumentWrapper

public interface CSSDocument extends Document, DocumentCSS, DocumentStyle, CSSNode
A CSS-enabled Document.
  • Method Details

    • createElement

      CSSElement createElement(String tagName) throws DOMException
      Creates an element of the type specified.

      The presence of IMPLIED attributes is implementation-dependent.

      Specified by:
      createElement in interface Document
      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

      CSSElement createElementNS(String namespaceURI, String qualifiedName) throws DOMException
      Specified by:
      createElementNS in interface Document
      Throws:
      DOMException
    • 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 and QUIRKS.

      QUIRKS and STRICT 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 interface Document
      Returns:
      the document element.
    • getElementById

      CSSElement getElementById(String elementId)
      Specified by:
      getElementById in interface Document
    • getStyleSheets

      CSSStyleSheetList<? extends ExtendedCSSRule> 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 interface 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

      void setSelectedStyleSheetSet(String name)
      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

      void enableStyleSheetsForSet(String name)
      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.
    • getOverrideStyle

      ExtendedCSSStyleDeclaration getOverrideStyle(Element elt, String pseudoElt)
      Gets the override style declaration for an element and pseudo-element.

      The getOverrideStyle method provides a mechanism through which a DOM author could effect immediate change to the style of an element without modifying the explicitly linked style sheets of a document or the inline style of elements.

      The override style sheet comes after the author style sheet in the cascade algorithm. DOM Level 2.

      Specified by:
      getOverrideStyle in interface DocumentCSS
      Parameters:
      elt - the element.
      pseudoElt - the pseudo-element, or null if none.
      Returns:
      the override style sheet for the given element and pseudo-element.
    • 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

      void setTargetMedium(String medium) throws CSSMediaException
      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.
    • 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

      boolean isSafeOrigin(URL linkedURL)
      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

      boolean isAuthorizedOrigin(URL url)
      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

      URL getURL(String uri) throws MalformedURLException
      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

      URLConnection openConnection(URL url) throws IOException
      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

      boolean isVisitedURI(String href)
      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 SAC or rule error or warning, false otherwise.