Package com.openhtmltopdf.context
Class StyleReference
- java.lang.Object
-
- com.openhtmltopdf.context.StyleReference
-
public class StyleReference extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private SharedContext
_context
The Context this StyleReference operates in; used for property resolution.private org.w3c.dom.Document
_doc
private Matcher
_matcher
Instance of our element-styles matching class.private NamespaceHandler
_nsh
private StylesheetFactoryImpl
_stylesheetFactory
private UserAgentCallback
_uac
-
Constructor Summary
Constructors Constructor Description StyleReference(UserAgentCallback userAgent)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.util.Map<java.lang.String,CSSPrimitiveValue>
getCascadedPropertiesMap(org.w3c.dom.Element e)
Deprecated.CascadedStyle
getCascadedStyle(org.w3c.dom.Element e, boolean restyle)
Gets the CascadedStyle for an element.java.lang.String
getCSSForAllDescendants(org.w3c.dom.Element e)
Given an element, returns all selectors and their rulesets for its descendants.java.util.List<FontFaceRule>
getFontFaceRules()
PageInfo
getPageStyle(java.lang.String pageName, java.lang.String pseudoPage)
CascadedStyle
getPseudoElementStyle(org.w3c.dom.Node node, java.lang.String pseudoElement)
Gets the pseudoElementStyle attribute of the StyleReference objectCalculatedStyle
getRootElementStyle()
Gets the style of the root element, should be html tag.private java.util.List<StylesheetInfo>
getStylesheets()
Gets StylesheetInfos for all stylesheets and inline styles associated with the current document.boolean
isHoverStyled(org.w3c.dom.Element e)
private java.util.List<Stylesheet>
readAndParseAll(java.util.List<StylesheetInfo> infos, java.lang.String medium)
void
setDocumentContext(SharedContext context, NamespaceHandler nsh, org.w3c.dom.Document doc, UserInterface ui)
Sets the documentContext attribute of the StyleReference objectvoid
setSupportCMYKColors(boolean b)
void
setUserAgentCallback(UserAgentCallback userAgentCallback)
-
-
-
Field Detail
-
_context
private SharedContext _context
The Context this StyleReference operates in; used for property resolution.
-
_nsh
private NamespaceHandler _nsh
-
_doc
private org.w3c.dom.Document _doc
-
_stylesheetFactory
private final StylesheetFactoryImpl _stylesheetFactory
-
_matcher
private Matcher _matcher
Instance of our element-styles matching class. Will be null if new rules have been added since last match.
-
_uac
private UserAgentCallback _uac
-
-
Constructor Detail
-
StyleReference
public StyleReference(UserAgentCallback userAgent)
-
-
Method Detail
-
getRootElementStyle
public CalculatedStyle getRootElementStyle()
Gets the style of the root element, should be html tag.
-
setDocumentContext
public void setDocumentContext(SharedContext context, NamespaceHandler nsh, org.w3c.dom.Document doc, UserInterface ui)
Sets the documentContext attribute of the StyleReference object- Parameters:
context
- The new documentContext valuensh
- The new documentContext valuedoc
- The new documentContext valueui
-
-
readAndParseAll
private java.util.List<Stylesheet> readAndParseAll(java.util.List<StylesheetInfo> infos, java.lang.String medium)
-
isHoverStyled
public boolean isHoverStyled(org.w3c.dom.Element e)
-
getCascadedPropertiesMap
@Deprecated public java.util.Map<java.lang.String,CSSPrimitiveValue> getCascadedPropertiesMap(org.w3c.dom.Element e)
Deprecated.Returns a Map keyed by CSS property names (e.g. 'border-width'), and the assigned value as a SAC CSSValue instance. The properties should have been matched to the element when the Context was established for this StyleReference on the Document to which the Element belongs. Only used by broken DOM inspector.- Parameters:
e
- The DOM Element for which to find properties- Returns:
- Map of CSS property names to CSSValue instance assigned to it.
-
getPseudoElementStyle
public CascadedStyle getPseudoElementStyle(org.w3c.dom.Node node, java.lang.String pseudoElement)
Gets the pseudoElementStyle attribute of the StyleReference object- Parameters:
node
- PARAMpseudoElement
- PARAM- Returns:
- The pseudoElementStyle value
-
getCascadedStyle
public CascadedStyle getCascadedStyle(org.w3c.dom.Element e, boolean restyle)
Gets the CascadedStyle for an element. This must then be converted in the current context to a CalculatedStyle (use getDerivedStyle)- Parameters:
e
- The elementrestyle
-- Returns:
- The style value
-
getCSSForAllDescendants
public java.lang.String getCSSForAllDescendants(org.w3c.dom.Element e)
Given an element, returns all selectors and their rulesets for its descendants. Useful for getting the styles that should be applied to SVG, etc.
-
getPageStyle
public PageInfo getPageStyle(java.lang.String pageName, java.lang.String pseudoPage)
-
getStylesheets
private java.util.List<StylesheetInfo> getStylesheets()
Gets StylesheetInfos for all stylesheets and inline styles associated with the current document. Default (user agent) stylesheet and the inline style for the current media are loaded in the StyleSheetFactory by URI.- Returns:
- The stylesheets value
-
getFontFaceRules
public java.util.List<FontFaceRule> getFontFaceRules()
-
setUserAgentCallback
public void setUserAgentCallback(UserAgentCallback userAgentCallback)
-
setSupportCMYKColors
public void setSupportCMYKColors(boolean b)
-
-