diff --git a/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/style/derived/BorderPropertySet.java b/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/style/derived/BorderPropertySet.java index c4defe2f8..7c6b2f415 100644 --- a/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/style/derived/BorderPropertySet.java +++ b/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/style/derived/BorderPropertySet.java @@ -1,5 +1,6 @@ package org.xhtmlrenderer.css.style.derived; +import com.google.errorprone.annotations.CheckReturnValue; import com.google.errorprone.annotations.InlineMe; import org.jspecify.annotations.Nullable; import org.xhtmlrenderer.css.constants.CSSName; @@ -38,11 +39,11 @@ */ public class BorderPropertySet extends RectPropertySet { private static final Corners NO_CORNERS = new Corners(BorderRadiusCorner.UNDEFINED, BorderRadiusCorner.UNDEFINED, BorderRadiusCorner.UNDEFINED, BorderRadiusCorner.UNDEFINED); - private static final Styles NO_STYLES = new Styles(HIDDEN, HIDDEN, HIDDEN, HIDDEN); + private static final Styles NO_STYLES = new Styles(null, null, null, null); private static final Colors NO_COLORS = new Colors(TRANSPARENT, TRANSPARENT, TRANSPARENT, TRANSPARENT); public static final BorderPropertySet EMPTY_BORDER = new BorderPropertySet(0.0f, 0.0f, 0.0f, 0.0f, NO_STYLES, NO_CORNERS, NO_COLORS); - private record Styles(IdentValue top, IdentValue right, IdentValue bottom, IdentValue left) { + private record Styles(@Nullable IdentValue top, @Nullable IdentValue right, @Nullable IdentValue bottom, @Nullable IdentValue left) { private boolean hasHidden() { return top == HIDDEN || right == HIDDEN || bottom == HIDDEN || left == HIDDEN; } @@ -211,18 +212,26 @@ public boolean noLeft() { return styles.left() == NONE || (int) left() == 0; } + @Nullable + @CheckReturnValue public IdentValue topStyle() { return styles.top(); } + @Nullable + @CheckReturnValue public IdentValue rightStyle() { return styles.right(); } + @Nullable + @CheckReturnValue public IdentValue bottomStyle() { return styles.bottom(); } + @Nullable + @CheckReturnValue public IdentValue leftStyle() { return styles.left(); } diff --git a/flying-saucer-core/src/main/java/org/xhtmlrenderer/newtable/CollapsedBorderValue.java b/flying-saucer-core/src/main/java/org/xhtmlrenderer/newtable/CollapsedBorderValue.java index 6e8b02ac6..55b22864a 100644 --- a/flying-saucer-core/src/main/java/org/xhtmlrenderer/newtable/CollapsedBorderValue.java +++ b/flying-saucer-core/src/main/java/org/xhtmlrenderer/newtable/CollapsedBorderValue.java @@ -19,23 +19,26 @@ */ package org.xhtmlrenderer.newtable; +import com.google.errorprone.annotations.CheckReturnValue; +import org.jspecify.annotations.Nullable; import org.xhtmlrenderer.css.constants.IdentValue; import org.xhtmlrenderer.css.parser.FSColor; import org.xhtmlrenderer.css.style.derived.BorderPropertySet; /** * This class encapsulates all information related to a particular border side - * along with an overall precedence (e.g. cell borders take precendence over + * along with an overall precedence (e.g. cell borders take precedence over * row borders). It is used when comparing overlapping borders when calculating * collapsed borders. */ public class CollapsedBorderValue { + @Nullable private final IdentValue _style; private final int _width; private final FSColor _color; private final int _precedence; - public CollapsedBorderValue(IdentValue style, int width, FSColor color, int precedence) { + public CollapsedBorderValue(@Nullable IdentValue style, int width, FSColor color, int precedence) { _style = style; _width = width; _color = color; @@ -46,49 +49,61 @@ public FSColor color() { return _color; } + @Nullable + @CheckReturnValue public IdentValue style() { return _style; } + @CheckReturnValue public int width() { return _width; } + @CheckReturnValue public CollapsedBorderValue withWidth(int width) { return new CollapsedBorderValue(_style, width, _color, _precedence); } + @CheckReturnValue public int precedence() { return _precedence; } + @CheckReturnValue public boolean defined() { return _style != null; } + @CheckReturnValue public boolean exists() { return _style != null && _style != IdentValue.NONE && _style != IdentValue.HIDDEN; } + @CheckReturnValue public boolean hidden() { return _style == IdentValue.HIDDEN; } + @CheckReturnValue public static CollapsedBorderValue borderLeft(BorderPropertySet border, int precedence) { return new CollapsedBorderValue( border.leftStyle(), (int)border.left(), border.leftColor(), precedence); } + @CheckReturnValue public static CollapsedBorderValue borderRight(BorderPropertySet border, int precedence) { return new CollapsedBorderValue( border.rightStyle(), (int)border.right(), border.rightColor(), precedence); } + @CheckReturnValue public static CollapsedBorderValue borderTop(BorderPropertySet border, int precedence) { return new CollapsedBorderValue( border.topStyle(), (int)border.top(), border.topColor(), precedence); } + @CheckReturnValue public static CollapsedBorderValue borderBottom(BorderPropertySet border, int precedence) { return new CollapsedBorderValue( border.bottomStyle(), (int)border.bottom(), border.bottomColor(), precedence);