@@ -1033,6 +1033,47 @@ public Rectangle getInnerAreaBBox() {
10331033 return rect ;
10341034 }
10351035
1036+ /**
1037+ * Applies margins of the renderer on the given rectangle
1038+ *
1039+ * @param rect a rectangle margins will be applied on.
1040+ * @param reverse indicates whether margins will be applied
1041+ * inside (in case of false) or outside (in case of true) the rectangle.
1042+ * @return a {@link Rectangle border box} of the renderer
1043+ * @see #getMargins
1044+ */
1045+ public Rectangle applyMargins (Rectangle rect , boolean reverse ) {
1046+ return this .applyMargins (rect , getMargins (), reverse );
1047+ }
1048+
1049+ /**
1050+ * Applies the border box of the renderer on the given rectangle
1051+ * If the border of a certain side is null, the side will remain as it was.
1052+ *
1053+ * @param rect a rectangle the border box will be applied on.
1054+ * @param reverse indicates whether the border box will be applied
1055+ * inside (in case of false) or outside (in case of false) the rectangle.
1056+ * @return a {@link Rectangle border box} of the renderer
1057+ * @see #getBorders
1058+ */
1059+ public Rectangle applyBorderBox (Rectangle rect , boolean reverse ) {
1060+ Border [] borders = getBorders ();
1061+ return applyBorderBox (rect , borders , reverse );
1062+ }
1063+
1064+ /**
1065+ * Applies paddings of the renderer on the given rectangle
1066+ *
1067+ * @param rect a rectangle paddings will be applied on.
1068+ * @param reverse indicates whether paddings will be applied
1069+ * inside (in case of false) or outside (in case of false) the rectangle.
1070+ * @return a {@link Rectangle border box} of the renderer
1071+ * @see #getPaddings
1072+ */
1073+ public Rectangle applyPaddings (Rectangle rect , boolean reverse ) {
1074+ return applyPaddings (rect , getPaddings (), reverse );
1075+ }
1076+
10361077 public boolean isFirstOnRootArea () {
10371078 return isFirstOnRootArea (false );
10381079 }
@@ -1043,24 +1084,24 @@ protected void applyDestinationsAndAnnotation(DrawContext drawContext) {
10431084 applyLinkAnnotation (drawContext .getDocument ());
10441085 }
10451086
1046- static boolean isBorderBoxSizing (IRenderer renderer ) {
1087+ protected static boolean isBorderBoxSizing (IRenderer renderer ) {
10471088 BoxSizingPropertyValue boxSizing = renderer .<BoxSizingPropertyValue >getProperty (Property .BOX_SIZING );
10481089 return boxSizing != null && boxSizing .equals (BoxSizingPropertyValue .BORDER_BOX );
10491090 }
10501091
1051- boolean isOverflowProperty (OverflowPropertyValue equalsTo , int overflowProperty ) {
1092+ protected boolean isOverflowProperty (OverflowPropertyValue equalsTo , int overflowProperty ) {
10521093 return isOverflowProperty (equalsTo , this .<OverflowPropertyValue >getProperty (overflowProperty ));
10531094 }
10541095
1055- static boolean isOverflowProperty (OverflowPropertyValue equalsTo , IRenderer renderer , int overflowProperty ) {
1096+ protected static boolean isOverflowProperty (OverflowPropertyValue equalsTo , IRenderer renderer , int overflowProperty ) {
10561097 return isOverflowProperty (equalsTo , renderer .<OverflowPropertyValue >getProperty (overflowProperty ));
10571098 }
10581099
1059- static boolean isOverflowProperty (OverflowPropertyValue equalsTo , OverflowPropertyValue rendererOverflowProperty ) {
1100+ protected static boolean isOverflowProperty (OverflowPropertyValue equalsTo , OverflowPropertyValue rendererOverflowProperty ) {
10601101 return equalsTo .equals (rendererOverflowProperty ) || equalsTo .equals (OverflowPropertyValue .FIT ) && rendererOverflowProperty == null ;
10611102 }
10621103
1063- static boolean isOverflowFit (OverflowPropertyValue rendererOverflowProperty ) {
1104+ protected static boolean isOverflowFit (OverflowPropertyValue rendererOverflowProperty ) {
10641105 return rendererOverflowProperty == null || OverflowPropertyValue .FIT .equals (rendererOverflowProperty );
10651106 }
10661107
@@ -1188,7 +1229,7 @@ protected Float retrieveMinWidth(float parentBoxWidth) {
11881229 *
11891230 * @param updatedWidthValue element's new fixed content box width.
11901231 */
1191- void updateWidth (UnitValue updatedWidthValue ) {
1232+ protected void updateWidth (UnitValue updatedWidthValue ) {
11921233 if (updatedWidthValue .isPointValue () && isBorderBoxSizing (this )) {
11931234 updatedWidthValue .setValue (updatedWidthValue .getValue () + calculatePaddingBorderWidth (this ));
11941235 }
@@ -1287,7 +1328,7 @@ private float[] calculateRadii(BorderRadius[] radii, Rectangle area, boolean hor
12871328 *
12881329 * @param updatedHeight element's new fixed content box height, shall be not null.
12891330 */
1290- void updateHeight (UnitValue updatedHeight ) {
1331+ protected void updateHeight (UnitValue updatedHeight ) {
12911332 if (isBorderBoxSizing (this ) && updatedHeight .isPointValue ()) {
12921333 updatedHeight .setValue (updatedHeight .getValue () + calculatePaddingBorderHeight (this ));
12931334
@@ -1343,8 +1384,7 @@ protected Float retrieveMaxHeight() {
13431384 *
13441385 * @param updatedMaxHeight element's new content box max-height, shall be not null.
13451386 */
1346-
1347- void updateMaxHeight (UnitValue updatedMaxHeight ) {
1387+ protected void updateMaxHeight (UnitValue updatedMaxHeight ) {
13481388 if (isBorderBoxSizing (this ) && updatedMaxHeight .isPointValue ()) {
13491389 updatedMaxHeight .setValue (updatedMaxHeight .getValue () + calculatePaddingBorderHeight (this ));
13501390
@@ -1393,7 +1433,7 @@ protected Float retrieveMinHeight() {
13931433 *
13941434 * @param updatedMinHeight element's new content box min-height, shall be not null.
13951435 */
1396- void updateMinHeight (UnitValue updatedMinHeight ) {
1436+ protected void updateMinHeight (UnitValue updatedMinHeight ) {
13971437 if (isBorderBoxSizing (this ) && updatedMinHeight .isPointValue ()) {
13981438 updatedMinHeight .setValue (updatedMinHeight .getValue () + calculatePaddingBorderHeight (this ));
13991439 }
@@ -1448,9 +1488,7 @@ protected Float getFirstYLineRecursively() {
14481488 }
14491489
14501490 protected Float getLastYLineRecursively () {
1451- if (isOverflowProperty (OverflowPropertyValue .HIDDEN , Property .OVERFLOW_X )
1452- || isOverflowProperty (OverflowPropertyValue .HIDDEN , Property .OVERFLOW_Y )) {
1453- // TODO may be this logic should also be based on BlockFormattingContextUtil?
1491+ if (!allowLastYLineRecursiveExtraction ()) {
14541492 return null ;
14551493 }
14561494 for (int i = childRenderers .size () - 1 ; i >= 0 ; i --) {
@@ -1465,17 +1503,9 @@ protected Float getLastYLineRecursively() {
14651503 return null ;
14661504 }
14671505
1468- /**
1469- * Applies margins of the renderer on the given rectangle
1470- *
1471- * @param rect a rectangle margins will be applied on.
1472- * @param reverse indicates whether margins will be applied
1473- * inside (in case of false) or outside (in case of true) the rectangle.
1474- * @return a {@link Rectangle border box} of the renderer
1475- * @see #getMargins
1476- */
1477- protected Rectangle applyMargins (Rectangle rect , boolean reverse ) {
1478- return this .applyMargins (rect , getMargins (), reverse );
1506+ protected boolean allowLastYLineRecursiveExtraction () {
1507+ return !isOverflowProperty (OverflowPropertyValue .HIDDEN , Property .OVERFLOW_X )
1508+ && !isOverflowProperty (OverflowPropertyValue .HIDDEN , Property .OVERFLOW_Y );
14791509 }
14801510
14811511 /**
@@ -1525,19 +1555,6 @@ protected UnitValue[] getPaddings() {
15251555 return getPaddings (this );
15261556 }
15271557
1528- /**
1529- * Applies paddings of the renderer on the given rectangle
1530- *
1531- * @param rect a rectangle paddings will be applied on.
1532- * @param reverse indicates whether paddings will be applied
1533- * inside (in case of false) or outside (in case of false) the rectangle.
1534- * @return a {@link Rectangle border box} of the renderer
1535- * @see #getPaddings
1536- */
1537- protected Rectangle applyPaddings (Rectangle rect , boolean reverse ) {
1538- return applyPaddings (rect , getPaddings (), reverse );
1539- }
1540-
15411558 /**
15421559 * Applies given paddings on the given rectangle
15431560 *
@@ -1567,21 +1584,6 @@ protected Rectangle applyPaddings(Rectangle rect, UnitValue[] paddings, boolean
15671584 return rect .applyMargins (paddings [0 ].getValue (), paddings [1 ].getValue (), paddings [2 ].getValue (), paddings [3 ].getValue (), reverse );
15681585 }
15691586
1570- /**
1571- * Applies the border box of the renderer on the given rectangle
1572- * If the border of a certain side is null, the side will remain as it was.
1573- *
1574- * @param rect a rectangle the border box will be applied on.
1575- * @param reverse indicates whether the border box will be applied
1576- * inside (in case of false) or outside (in case of false) the rectangle.
1577- * @return a {@link Rectangle border box} of the renderer
1578- * @see #getBorders
1579- */
1580- protected Rectangle applyBorderBox (Rectangle rect , boolean reverse ) {
1581- Border [] borders = getBorders ();
1582- return applyBorderBox (rect , borders , reverse );
1583- }
1584-
15851587 /**
15861588 * Applies the given border box (borders) on the given rectangle
15871589 *
0 commit comments