Class CalculatedStyle

java.lang.Object
org.xhtmlrenderer.css.style.CalculatedStyle
Direct Known Subclasses:
EmptyStyle

@ParametersAreNonnullByDefault public class CalculatedStyle extends Object
A set of properties that apply to a single Element, derived from all matched properties following the rules for CSS cascade, inheritance, importance, specificity and sequence. A derived style is just like a style but (presumably) has additional information that allows relative properties to be assigned values, e.g. font attributes. Property values are fully resolved when this style is created. A property retrieved by name should always have only one value in this class (e.g. one-one map). Any methods to retrieve property values from an instance of this class require a valid CssContext be given to it, for some cases of property resolution. Generally, a programmer will not use this class directly, but will retrieve properties using a StyleReference implementation.
  • Field Details

    • _parent

      private final CalculatedStyle _parent
      The parent-style we inherit from
    • _border

      private BorderPropertySet _border
    • _margin

      private RectPropertySet _margin
    • _padding

      private RectPropertySet _padding
    • _lineHeight

      private float _lineHeight
    • _lineHeightResolved

      private boolean _lineHeightResolved
    • _FSFont

      private FSFont _FSFont
    • _FSFontMetrics

      private FSFontMetrics _FSFontMetrics
    • _marginsAllowed

      private boolean _marginsAllowed
    • _paddingAllowed

      private boolean _paddingAllowed
    • _bordersAllowed

      private boolean _bordersAllowed
    • _backgroundSize

      private BackgroundSize _backgroundSize
    • _childCache

      private final Map<String,CalculatedStyle> _childCache
      Cache child styles of this style that have the same cascaded properties
    • _derivedValuesById

      private final FSDerivedValue[] _derivedValuesById
      Our main array of property values defined in this style, keyed by the CSSName assigned ID.
    • _font

      private FontSpecification _font
      The derived Font for this style
    • LEFT

      public static final int LEFT
      See Also:
    • TOP

      public static final int TOP
      See Also:
    • BOTTOM

      public static final int BOTTOM
      See Also:
  • Constructor Details

    • CalculatedStyle

      private CalculatedStyle(@Nullable CalculatedStyle parent)
    • CalculatedStyle

      protected CalculatedStyle()
      Default constructor; as the instance is immutable after use, don't use this for class instantiation externally.
    • CalculatedStyle

      private CalculatedStyle(CalculatedStyle parent, CascadedStyle matched)
      Constructor for the CalculatedStyle object. To get a derived style, use the Styler objects getDerivedStyle which will cache styles
  • Method Details

    • checkPaddingAllowed

      private boolean checkPaddingAllowed(IdentValue display)
    • isTable

      private static boolean isTable(IdentValue display)
    • checkMarginsAllowed

      private static boolean checkMarginsAllowed(IdentValue display)
    • checkBordersAllowed

      private static boolean checkBordersAllowed(IdentValue display)
    • deriveStyle

      public CalculatedStyle deriveStyle(CascadedStyle matched)
      derives a child style from this style.

      depends on the ability to return the identical CascadedStyle each time a child style is needed

      Parameters:
      matched - the CascadedStyle to apply
      Returns:
      The derived child style
    • getParent

      public CalculatedStyle getParent()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • asColor

      public FSColor asColor(CSSName cssName)
    • asFloat

      public float asFloat(CSSName cssName)
    • asString

      public String asString(CSSName cssName)
    • asStringArray

      public String[] asStringArray(CSSName cssName)
    • setDefaultValue

      public void setDefaultValue(CSSName cssName, FSDerivedValue fsDerivedValue)
    • hasAbsoluteUnit

      public boolean hasAbsoluteUnit(CSSName cssName)
    • isIdent

      public boolean isIdent(CSSName cssName, IdentValue val)
      Gets the ident attribute of the CalculatedStyle object
    • getIdent

      public IdentValue getIdent(CSSName cssName)
      Gets the ident attribute of the CalculatedStyle object
    • getDisplay

      public IdentValue getDisplay()
    • getColor

      public FSColor getColor()
      Convenience property accessor; returns a Color initialized with the foreground color Uses the actual value (computed actual value) for this element.
      Returns:
      The color value
    • getBackgroundColor

      public FSColor getBackgroundColor()
      Convenience property accessor; returns a Color initialized with the background color value; Uses the actual value (computed actual value) for this element.
      Returns:
      The backgroundColor value
    • getBackgroundSize

      public BackgroundSize getBackgroundSize()
    • createBackgroundSize

      private BackgroundSize createBackgroundSize()
    • getBackgroundPosition

      public BackgroundPosition getBackgroundPosition()
    • getCounterReset

      public List<CounterData> getCounterReset()
    • getCounterIncrement

      public List<CounterData> getCounterIncrement()
    • getBorder

      public BorderPropertySet getBorder(CssContext ctx)
    • getFont

      public FontSpecification getFont(CssContext ctx)
    • getFontSpecification

      public FontSpecification getFontSpecification()
    • resolveAbsoluteFontSize

      private IdentValue resolveAbsoluteFontSize()
    • getFloatPropertyProportionalTo

      public float getFloatPropertyProportionalTo(CSSName cssName, float baseValue, CssContext ctx)
    • getFloatPropertyProportionalWidth

      public float getFloatPropertyProportionalWidth(CSSName cssName, float parentWidth, CssContext ctx)
    • getFloatPropertyProportionalHeight

      public float getFloatPropertyProportionalHeight(CSSName cssName, float parentHeight, CssContext ctx)
    • getLineHeight

      public float getLineHeight(CssContext ctx)
    • getMarginRect

      public RectPropertySet getMarginRect(float cbWidth, CssContext ctx)
      Convenience property accessor; returns a Border initialized with the four-sided margin width. Uses the actual value (computed actual value) for this element.
      Returns:
      The marginWidth value
    • getMarginRect

      public RectPropertySet getMarginRect(float cbWidth, CssContext ctx, boolean useCache)
    • getPaddingRect

      public RectPropertySet getPaddingRect(float cbWidth, CssContext ctx, boolean useCache)
      Convenience property accessor; returns a Border initialized with the four-sided padding width. Uses the actual value (computed actual value) for this element.
      Returns:
      The paddingWidth value
    • getPaddingRect

      public RectPropertySet getPaddingRect(float cbWidth, CssContext ctx)
    • getStringProperty

      public String getStringProperty(CSSName cssName)
    • isLength

      public boolean isLength(CSSName cssName)
    • isLengthOrNumber

      public boolean isLengthOrNumber(CSSName cssName)
    • valueByName

      public FSDerivedValue valueByName(CSSName cssName)
      Returns a FSDerivedValue by name. Because we are a derived style, the property will already be resolved at this point.
      Parameters:
      cssName - The CSS property name, e.g. "font-family"
    • derive

      private void derive(CascadedStyle matched)

      Implements cascade/inherit/important logic. This should result in the element for this style having a value for *each and every* (visual) property in the CSS2 spec. The implementation is based on the notion that the matched styles are given to us in a perfectly sorted order, such that properties appearing later in the rule-set always override properties appearing earlier. It also assumes that all properties in the CSS2 spec are defined somewhere across all the matched styles; for example, that the full-property set is given in the user-agent CSS that is always loaded with styles. The current implementation makes no attempt to check either of these assumptions. When this method exits, the derived property list for this class will be populated with the properties defined for this element, properly cascaded.

    • deriveValue

      private FSDerivedValue deriveValue(CSSName cssName, CSSPrimitiveValue value)
    • genStyleKey

      private String genStyleKey()
    • getCachedPadding

      public RectPropertySet getCachedPadding()
    • getPaddingProperty

      private static RectPropertySet getPaddingProperty(CalculatedStyle style, float cbWidth, CssContext ctx, boolean useCache)
    • getMarginProperty

      private static RectPropertySet getMarginProperty(CalculatedStyle style, float cbWidth, CssContext ctx, boolean useCache)
    • newRectInstance

      private static RectPropertySet newRectInstance(CalculatedStyle style, CSSName.CSSSideProperties sides, float cbWidth, CssContext ctx)
    • getBorderProperty

      private static BorderPropertySet getBorderProperty(CalculatedStyle style, CssContext ctx)
    • getMarginBorderPadding

      public int getMarginBorderPadding(CssContext cssCtx, int cbWidth, int which)
    • getWhitespace

      public IdentValue getWhitespace()
    • getFSFont

      public FSFont getFSFont(CssContext cssContext)
    • getFSFontMetrics

      public FSFontMetrics getFSFontMetrics(CssContext c)
    • getWordWrap

      public IdentValue getWordWrap()
    • getHyphens

      public IdentValue getHyphens()
    • isClearLeft

      public boolean isClearLeft()
    • isClearRight

      public boolean isClearRight()
    • isCleared

      public boolean isCleared()
    • getBackgroundRepeat

      public IdentValue getBackgroundRepeat()
    • getBackgroundAttachment

      public IdentValue getBackgroundAttachment()
    • isFixedBackground

      public boolean isFixedBackground()
    • isInline

      public boolean isInline()
    • isInlineBlock

      public boolean isInlineBlock()
    • isTable

      public boolean isTable()
    • isInlineTable

      public boolean isInlineTable()
    • isUnderTableLayout

      public boolean isUnderTableLayout()
    • isTableCell

      public boolean isTableCell()
    • isTableSection

      public boolean isTableSection()
    • isTableCaption

      public boolean isTableCaption()
    • isTableHeader

      public boolean isTableHeader()
    • isTableFooter

      public boolean isTableFooter()
    • isTableRow

      public boolean isTableRow()
    • isDisplayNone

      public boolean isDisplayNone()
    • isSpecifiedAsBlock

      public boolean isSpecifiedAsBlock()
    • isBlockEquivalent

      public boolean isBlockEquivalent()
    • isLaidOutInInlineContext

      public boolean isLaidOutInInlineContext()
    • isNeedAutoMarginResolution

      public boolean isNeedAutoMarginResolution()
    • isAbsolute

      public boolean isAbsolute()
    • isFixed

      public boolean isFixed()
    • isFloated

      public boolean isFloated()
    • isFloatedLeft

      public boolean isFloatedLeft()
    • isFloatedRight

      public boolean isFloatedRight()
    • isRelative

      public boolean isRelative()
    • isPositionedOrFloated

      public boolean isPositionedOrFloated()
    • isPositioned

      public boolean isPositioned()
    • isAutoWidth

      public boolean isAutoWidth()
    • isAbsoluteWidth

      public boolean isAbsoluteWidth()
    • isAutoHeight

      public boolean isAutoHeight()
    • isAutoLeftMargin

      public boolean isAutoLeftMargin()
    • isAutoRightMargin

      public boolean isAutoRightMargin()
    • isAutoZIndex

      public boolean isAutoZIndex()
    • establishesBFC

      public boolean establishesBFC()
    • requiresLayer

      public boolean requiresLayer()
    • isRunning

      public boolean isRunning()
    • getRunningName

      public String getRunningName()
    • isOverflowApplies

      public boolean isOverflowApplies()
    • isOverflowVisible

      public boolean isOverflowVisible()
    • isHorizontalBackgroundRepeat

      public boolean isHorizontalBackgroundRepeat()
    • isVerticalBackgroundRepeat

      public boolean isVerticalBackgroundRepeat()
    • isTopAuto

      public boolean isTopAuto()
    • isBottomAuto

      public boolean isBottomAuto()
    • isListItem

      public boolean isListItem()
    • isVisible

      public boolean isVisible()
    • isForcePageBreakBefore

      public boolean isForcePageBreakBefore()
    • isForcePageBreakAfter

      public boolean isForcePageBreakAfter()
    • isAvoidPageBreakInside

      public boolean isAvoidPageBreakInside()
    • createAnonymousStyle

      public CalculatedStyle createAnonymousStyle(IdentValue display)
    • mayHaveFirstLine

      public boolean mayHaveFirstLine()
    • mayHaveFirstLetter

      public boolean mayHaveFirstLetter()
    • isNonFlowContent

      public boolean isNonFlowContent()
    • isMayCollapseMarginsWithChildren

      public boolean isMayCollapseMarginsWithChildren()
    • isAbsFixedOrInlineBlockEquiv

      public boolean isAbsFixedOrInlineBlockEquiv()
    • isMaxWidthNone

      public boolean isMaxWidthNone()
    • isMaxHeightNone

      public boolean isMaxHeightNone()
    • isBorderBox

      public boolean isBorderBox()
    • getMinWidth

      public int getMinWidth(CssContext c, int cbWidth)
    • getMaxWidth

      public int getMaxWidth(CssContext c, int cbWidth)
    • getMinHeight

      public int getMinHeight(CssContext c, int cbHeight)
    • getMaxHeight

      public int getMaxHeight(CssContext c, int cbHeight)
    • isCollapseBorders

      public boolean isCollapseBorders()
    • getBorderHSpacing

      public int getBorderHSpacing(CssContext c)
    • getBorderVSpacing

      public int getBorderVSpacing(CssContext c)
    • getRowSpan

      public int getRowSpan()
    • getColSpan

      public int getColSpan()
    • asLength

      public Length asLength(CssContext c, CSSName cssName)
    • isShowEmptyCells

      public boolean isShowEmptyCells()
    • isHasBackground

      public boolean isHasBackground()
    • getTextDecorations

      public List<FSDerivedValue> getTextDecorations()
    • getCursor

      public Cursor getCursor()
    • isPaginateTable

      public boolean isPaginateTable()
    • isTextJustify

      public boolean isTextJustify()
    • isListMarkerInside

      public boolean isListMarkerInside()
    • isKeepWithInline

      public boolean isKeepWithInline()
    • isDynamicAutoWidth

      public boolean isDynamicAutoWidth()
    • isDynamicAutoWidthApplicable

      public boolean isDynamicAutoWidthApplicable()
    • isCanBeShrunkToFit

      public boolean isCanBeShrunkToFit()