From b3d83dcfc5b3f6fac20d9368b3022f867997fb94 Mon Sep 17 00:00:00 2001 From: Andrei Solntsev Date: Thu, 24 Oct 2024 19:53:39 +0300 Subject: [PATCH] [refactor] make fields of RectPropertySet private unfortunatelly, I could not make the final because the setters are actually used. :( --- .../css/style/derived/BorderPropertySet.java | 12 +++++------ .../css/style/derived/RectPropertySet.java | 20 +++++-------------- 2 files changed, 11 insertions(+), 21 deletions(-) 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 cb56c52bc..1b68fcbc2 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 @@ -192,23 +192,23 @@ public static BorderPropertySet newInstance( @Override public String toString() { - return "BorderPropertySet[top=%s,right=%s,bottom=%s,left=%s]".formatted(_top, _right, _bottom, _left); + return "BorderPropertySet[top=%s,right=%s,bottom=%s,left=%s]".formatted(top(), right(), bottom(), left()); } public boolean noTop() { - return styles.top() == NONE || (int) _top == 0; + return styles.top() == NONE || (int) top() == 0; } public boolean noRight() { - return styles.right() == NONE || (int) _right == 0; + return styles.right() == NONE || (int) right() == 0; } public boolean noBottom() { - return styles.bottom() == NONE || (int) _bottom == 0; + return styles.bottom() == NONE || (int) bottom() == 0; } public boolean noLeft() { - return styles.left() == NONE || (int) _left == 0; + return styles.left() == NONE || (int) left() == 0; } public IdentValue topStyle() { @@ -285,7 +285,7 @@ public BorderPropertySet normalizedInstance(Rectangle bounds) { new BorderRadiusCorner(factor * corners.bottomRight().getMaxLeft(bounds.height), factor * corners.bottomRight().getMaxRight(bounds.width)), new BorderRadiusCorner(factor * corners.bottomLeft().getMaxLeft(bounds.width), factor * corners.bottomLeft().getMaxRight(bounds.height)) ); - return new BorderPropertySet(_top, _right, _bottom, _left, + return new BorderPropertySet(top(), right(), bottom(), left(), styles, normalizedCorners, colors diff --git a/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/style/derived/RectPropertySet.java b/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/style/derived/RectPropertySet.java index 32527c6cc..e05619790 100644 --- a/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/style/derived/RectPropertySet.java +++ b/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/style/derived/RectPropertySet.java @@ -9,17 +9,12 @@ * some rectangular area, and per-side thickness. */ public class RectPropertySet { - // HACK public static final RectPropertySet ALL_ZEROS = new RectPropertySet(0, 0, 0, 0); - protected float _top; - protected float _right; - protected float _bottom; - protected float _left; - - protected RectPropertySet() { - _top = _right = _bottom = _left = 0f; - } + private float _top; + private float _right; + private float _bottom; + private float _left; public RectPropertySet( float top, @@ -98,12 +93,7 @@ public void setLeft(float _left) { } public RectPropertySet copyOf() { - RectPropertySet newRect = new RectPropertySet(); - newRect._top = _top; - newRect._right = _right; - newRect._bottom = _bottom; - newRect._left = _left; - return newRect; + return new RectPropertySet(_top, _right, _bottom, _left); } public boolean isAllZeros() {