Marcin Ziąbek пре 1 година
родитељ
комит
b36e46dc28

+ 2 - 1
Source/QuestPDF/Elements/AspectRatio.cs

@@ -1,5 +1,6 @@
 using System;
 using QuestPDF.Drawing;
+using QuestPDF.Helpers;
 using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
@@ -16,7 +17,7 @@ namespace QuestPDF.Elements
             if (Ratio == 0)
                 return SpacePlan.FullRender(0, 0);
  
-            if (Child.Measure(Size.Zero).Type == SpacePlanType.Empty)
+            if (Child.IsEmpty())
                 return SpacePlan.Empty();
             
             var targetSize = GetTargetSize(availableSpace);

+ 2 - 1
Source/QuestPDF/Elements/Constrained.cs

@@ -1,5 +1,6 @@
 using System;
 using QuestPDF.Drawing;
+using QuestPDF.Helpers;
 using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
@@ -18,7 +19,7 @@ namespace QuestPDF.Elements
         
         internal override SpacePlan Measure(Size availableSpace)
         {
-            if (!EnforceSizeWhenEmpty && Child.Measure(Size.Zero).Type == SpacePlanType.Empty)
+            if (!EnforceSizeWhenEmpty && Child.IsEmpty())
                 return SpacePlan.Empty();
             
             if (MinWidth > availableSpace.Width + Size.Epsilon)

+ 2 - 4
Source/QuestPDF/Elements/Padding.cs

@@ -1,5 +1,6 @@
 using System;
 using QuestPDF.Drawing;
+using QuestPDF.Helpers;
 using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
@@ -16,10 +17,7 @@ namespace QuestPDF.Elements
             var internalSpace = InternalSpace(availableSpace);
 
             if (internalSpace.Width < -Size.Epsilon || internalSpace.Height < -Size.Epsilon)
-            {
-                var isEmpty = Child.Measure(Size.Zero).Type == SpacePlanType.Empty;
-                return isEmpty ? SpacePlan.Empty() : SpacePlan.Wrap();
-            }
+                return Child.IsEmpty() ? SpacePlan.Empty() : SpacePlan.Wrap();
             
             var measure = base.Measure(internalSpace);
 

+ 6 - 0
Source/QuestPDF/Helpers/Helpers.cs

@@ -4,6 +4,7 @@ using System.IO;
 using System.Linq.Expressions;
 using System.Reflection;
 using System.Text.RegularExpressions;
+using QuestPDF.Drawing;
 using QuestPDF.Infrastructure;
 using QuestPDF.Skia;
 
@@ -65,6 +66,11 @@ namespace QuestPDF.Helpers
         {
             return size.Width < -Size.Epsilon || size.Height < -Size.Epsilon;
         }
+
+        internal static bool IsEmpty(this Element element)
+        {
+            return element.Measure(Size.Zero).Type == SpacePlanType.Empty;
+        }
         
         internal static int ToQualityValue(this ImageCompressionQuality quality)
         {