public boolean isAbsoluteWidth() { return valueByName(CSSName.WIDTH).hasAbsoluteUnit(); }
public boolean hasAbsoluteUnit(CSSName cssName) { boolean isAbs = false; try { isAbs = valueByName(cssName).hasAbsoluteUnit(); } catch (Exception e) { XRLog.layout(Level.WARNING, "Property " + cssName + " has an assignment we don't understand, " + "and can't tell if it's an absolute unit or not. Assuming it is not. Exception was: " + e.getMessage()); isAbs = false; } return isAbs; }
public boolean hasAbsoluteUnit(CSSName cssName) { boolean isAbs = false; try { isAbs = valueByName(cssName).hasAbsoluteUnit(); } catch (Exception e) { XRLog.layout(Level.WARNING, "Property " + cssName + " has an assignment we don't understand, " + "and can't tell if it's an absolute unit or not. Assuming it is not. Exception was: " + e.getMessage()); isAbs = false; } return isAbs; }
public Length asLength(CssContext c, CSSName cssName) { Length result = new Length(); FSDerivedValue value = valueByName(cssName); if (value instanceof LengthValue || value instanceof NumberValue) { if (value.hasAbsoluteUnit()) { result.setValue((int) value.getFloatProportionalTo(cssName, 0, c)); result.setType(Length.FIXED); } else { result.setValue((int) value.asFloat()); result.setType(Length.PERCENT); } } return result; }
public Length asLength(CssContext c, CSSName cssName) { Length result = new Length(); FSDerivedValue value = valueByName(cssName); if (value instanceof LengthValue || value instanceof NumberValue) { if (value.hasAbsoluteUnit()) { result.setValue((int) value.getFloatProportionalTo(cssName, 0, c)); result.setType(Length.FIXED); } else { result.setValue((int) value.asFloat()); result.setType(Length.PERCENT); } } return result; }
private void recalcMargin(LayoutContext c) { if (isTopMarginCalculated() && isBottomMarginCalculated()) { return; } // Check if we're a potential candidate upfront to avoid expensive // getStyleMargin(c, false) call FSDerivedValue topMargin = getStyle().valueByName(CSSName.MARGIN_TOP); boolean resetTop = topMargin instanceof LengthValue && ! topMargin.hasAbsoluteUnit(); FSDerivedValue bottomMargin = getStyle().valueByName(CSSName.MARGIN_BOTTOM); boolean resetBottom = bottomMargin instanceof LengthValue && ! bottomMargin.hasAbsoluteUnit(); if (! resetTop && ! resetBottom) { return; } RectPropertySet styleMargin = getStyleMargin(c, false); RectPropertySet workingMargin = getMargin(c); // A shrink-to-fit calculation may have set incorrect values for // percentage margins (as the containing block width // hasn't been calculated yet). Reset top and bottom margins // in this case. if (! isTopMarginCalculated() && styleMargin.top() != workingMargin.top()) { setMarginTop(c, (int) styleMargin.top()); } if (! isBottomMarginCalculated() && styleMargin.bottom() != workingMargin.bottom()) { setMarginBottom(c, (int) styleMargin.bottom()); } }
private void recalcMargin(LayoutContext c) { if (isTopMarginCalculated() && isBottomMarginCalculated()) { return; } // Check if we're a potential candidate upfront to avoid expensive // getStyleMargin(c, false) call FSDerivedValue topMargin = getStyle().valueByName(CSSName.MARGIN_TOP); boolean resetTop = topMargin instanceof LengthValue && ! topMargin.hasAbsoluteUnit(); FSDerivedValue bottomMargin = getStyle().valueByName(CSSName.MARGIN_BOTTOM); boolean resetBottom = bottomMargin instanceof LengthValue && ! bottomMargin.hasAbsoluteUnit(); if (! resetTop && ! resetBottom) { return; } RectPropertySet styleMargin = getStyleMargin(c, false); RectPropertySet workingMargin = getMargin(c); // A shrink-to-fit calculation may have set incorrect values for // percentage margins (as the containing block width // hasn't been calculated yet). Reset top and bottom margins // in this case. if (! isTopMarginCalculated() && styleMargin.top() != workingMargin.top()) { setMarginTop(c, (int) styleMargin.top()); } if (! isBottomMarginCalculated() && styleMargin.bottom() != workingMargin.bottom()) { setMarginBottom(c, (int) styleMargin.bottom()); } }