diff --git a/itext.tests/itext.styledxmlparser.tests/itext/styledxmlparser/css/resolve/shorthand/GapShorthandResolverTest.cs b/itext.tests/itext.styledxmlparser.tests/itext/styledxmlparser/css/resolve/shorthand/GapShorthandResolverTest.cs index 29fa43ce56..79c75e2ca2 100644 --- a/itext.tests/itext.styledxmlparser.tests/itext/styledxmlparser/css/resolve/shorthand/GapShorthandResolverTest.cs +++ b/itext.tests/itext.styledxmlparser.tests/itext/styledxmlparser/css/resolve/shorthand/GapShorthandResolverTest.cs @@ -131,6 +131,18 @@ public virtual void GapWithTwoValidValuesTest() { NUnit.Framework.Assert.AreEqual("15px", resolvedShorthand[1].GetExpression()); } + [NUnit.Framework.Test] + public virtual void GridGapWithTwoValidValuesTest() { + IShorthandResolver resolver = new GapShorthandResolver(CommonCssConstants.GRID_GAP); + String shorthand = "10px 15px"; + IList resolvedShorthand = resolver.ResolveShorthand(shorthand); + NUnit.Framework.Assert.AreEqual(2, resolvedShorthand.Count); + NUnit.Framework.Assert.AreEqual(CommonCssConstants.ROW_GAP, resolvedShorthand[0].GetProperty()); + NUnit.Framework.Assert.AreEqual("10px", resolvedShorthand[0].GetExpression()); + NUnit.Framework.Assert.AreEqual(CommonCssConstants.COLUMN_GAP, resolvedShorthand[1].GetProperty()); + NUnit.Framework.Assert.AreEqual("15px", resolvedShorthand[1].GetExpression()); + } + [NUnit.Framework.Test] [LogMessage(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.INVALID_CSS_PROPERTY_DECLARATION)] public virtual void GapWithValidAndInvalidValuesTest() { diff --git a/itext.tests/itext.styledxmlparser.tests/itext/styledxmlparser/css/validate/CssDeclarationValidationMasterTest.cs b/itext.tests/itext.styledxmlparser.tests/itext/styledxmlparser/css/validate/CssDeclarationValidationMasterTest.cs index 1e8a5d7312..66af6da2ad 100644 --- a/itext.tests/itext.styledxmlparser.tests/itext/styledxmlparser/css/validate/CssDeclarationValidationMasterTest.cs +++ b/itext.tests/itext.styledxmlparser.tests/itext/styledxmlparser/css/validate/CssDeclarationValidationMasterTest.cs @@ -426,6 +426,24 @@ public virtual void MulticolValidationTest() { .COLUMN_GAP, "10"))); } + [NUnit.Framework.Test] + public virtual void GridRowColumnGapTest() { + NUnit.Framework.Assert.IsTrue(CssDeclarationValidationMaster.CheckDeclaration(new CssDeclaration(CommonCssConstants + .GRID_ROW_GAP, "normal"))); + NUnit.Framework.Assert.IsTrue(CssDeclarationValidationMaster.CheckDeclaration(new CssDeclaration(CommonCssConstants + .GRID_COLUMN_GAP, "30px"))); + NUnit.Framework.Assert.IsTrue(CssDeclarationValidationMaster.CheckDeclaration(new CssDeclaration(CommonCssConstants + .GRID_ROW_GAP, "15%"))); + NUnit.Framework.Assert.IsTrue(CssDeclarationValidationMaster.CheckDeclaration(new CssDeclaration(CommonCssConstants + .GRID_ROW_GAP, "2em"))); + NUnit.Framework.Assert.IsTrue(CssDeclarationValidationMaster.CheckDeclaration(new CssDeclaration(CommonCssConstants + .GRID_COLUMN_GAP, "3rem"))); + NUnit.Framework.Assert.IsFalse(CssDeclarationValidationMaster.CheckDeclaration(new CssDeclaration(CommonCssConstants + .GRID_COLUMN_GAP, "-5em"))); + NUnit.Framework.Assert.IsFalse(CssDeclarationValidationMaster.CheckDeclaration(new CssDeclaration(CommonCssConstants + .GRID_ROW_GAP, "10"))); + } + [NUnit.Framework.Test] public virtual void ChangeValidatorTest() { try { diff --git a/itext/itext.kernel/itext/kernel/pdf/canvas/parser/data/ImageRenderInfo.cs b/itext/itext.kernel/itext/kernel/pdf/canvas/parser/data/ImageRenderInfo.cs index fb6fc08be2..c69e86f5ff 100644 --- a/itext/itext.kernel/itext/kernel/pdf/canvas/parser/data/ImageRenderInfo.cs +++ b/itext/itext.kernel/itext/kernel/pdf/canvas/parser/data/ImageRenderInfo.cs @@ -96,7 +96,7 @@ public ImageRenderInfo(Stack canvasTagHierarchy, CanvasGraphicsState /// /// with /// - /// ; + /// ; // Android-Conversion-Skip-Line (java.awt library isn't available on Android) /// /// /// diff --git a/itext/itext.styledxmlparser/itext/styledxmlparser/css/CommonCssConstants.cs b/itext/itext.styledxmlparser/itext/styledxmlparser/css/CommonCssConstants.cs index 9b69be2420..9ae275d296 100644 --- a/itext/itext.styledxmlparser/itext/styledxmlparser/css/CommonCssConstants.cs +++ b/itext/itext.styledxmlparser/itext/styledxmlparser/css/CommonCssConstants.cs @@ -331,12 +331,21 @@ static CommonCssConstants() { /// The Constant GRID_COLUMN_END. public const String GRID_COLUMN_END = "grid-column-end"; + /// The Constant GRID_COLUMN_GAP. + public const String GRID_COLUMN_GAP = "grid-column-gap"; + /// The Constant GRID_COLUMN_START. public const String GRID_COLUMN_START = "grid-column-start"; + /// The Constant GRID_GAP. + public const String GRID_GAP = "grid-gap"; + /// The Constant GRID_ROW_END. public const String GRID_ROW_END = "grid-row-end"; + /// The Constant GRID_ROW_GAP. + public const String GRID_ROW_GAP = "grid-row-gap"; + /// The Constant GRID_ROW_START. public const String GRID_ROW_START = "grid-row-start"; diff --git a/itext/itext.styledxmlparser/itext/styledxmlparser/css/resolve/shorthand/ShorthandResolverFactory.cs b/itext/itext.styledxmlparser/itext/styledxmlparser/css/resolve/shorthand/ShorthandResolverFactory.cs index 7477334e5d..b63a108341 100644 --- a/itext/itext.styledxmlparser/itext/styledxmlparser/css/resolve/shorthand/ShorthandResolverFactory.cs +++ b/itext/itext.styledxmlparser/itext/styledxmlparser/css/resolve/shorthand/ShorthandResolverFactory.cs @@ -52,7 +52,8 @@ static ShorthandResolverFactory() { shorthandResolvers.Put(CommonCssConstants.TEXT_DECORATION, new TextDecorationShorthandResolver()); shorthandResolvers.Put(CommonCssConstants.FLEX, new FlexShorthandResolver()); shorthandResolvers.Put(CommonCssConstants.FLEX_FLOW, new FlexFlowShorthandResolver()); - shorthandResolvers.Put(CommonCssConstants.GAP, new GapShorthandResolver()); + shorthandResolvers.Put(CommonCssConstants.GAP, new GapShorthandResolver(CommonCssConstants.GAP)); + shorthandResolvers.Put(CommonCssConstants.GRID_GAP, new GapShorthandResolver(CommonCssConstants.GRID_GAP)); shorthandResolvers.Put(CommonCssConstants.PLACE_ITEMS, new PlaceItemsShorthandResolver()); shorthandResolvers.Put(CommonCssConstants.COLUMNS, new ColumnsShorthandResolver()); shorthandResolvers.Put(CommonCssConstants.COLUMN_RULE, new ColumnRuleShortHandResolver()); diff --git a/itext/itext.styledxmlparser/itext/styledxmlparser/css/resolve/shorthand/impl/GapShorthandResolver.cs b/itext/itext.styledxmlparser/itext/styledxmlparser/css/resolve/shorthand/impl/GapShorthandResolver.cs index f78652b3ac..5cca4d3cc8 100644 --- a/itext/itext.styledxmlparser/itext/styledxmlparser/css/resolve/shorthand/impl/GapShorthandResolver.cs +++ b/itext/itext.styledxmlparser/itext/styledxmlparser/css/resolve/shorthand/impl/GapShorthandResolver.cs @@ -31,8 +31,39 @@ You should have received a copy of the GNU Affero General Public License using iText.StyledXmlParser.Css.Validate; namespace iText.StyledXmlParser.Css.Resolve.Shorthand.Impl { + /// + /// Shorthand resolver for gap shorthand properties, can be used for + /// different gap properties like + /// gap + /// or + /// grid-gap. + /// public class GapShorthandResolver : IShorthandResolver { - private static readonly ILogger LOGGER = ITextLogManager.GetLogger(typeof(GapShorthandResolver)); + private readonly String gapShorthandProperty; + + /// + /// Instantiates default + /// + /// for + /// gap + /// shorthand. + /// + public GapShorthandResolver() + : this(CommonCssConstants.GAP) { + } + + /// + /// Instantiates default + /// + /// for passed gap shorthand. + /// + /// the name of the gap shorthand property + public GapShorthandResolver(String gapShorthandProperty) { + this.gapShorthandProperty = gapShorthandProperty; + } + + private static readonly ILogger LOGGER = ITextLogManager.GetLogger(typeof(iText.StyledXmlParser.Css.Resolve.Shorthand.Impl.GapShorthandResolver + )); /// public virtual IList ResolveShorthand(String shorthandExpression) { @@ -43,11 +74,11 @@ public virtual IList ResolveShorthand(String shorthandExpression } if (CssTypesValidationUtils.ContainsInitialOrInheritOrUnset(shorthandExpression)) { return HandleExpressionError(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.INVALID_CSS_PROPERTY_DECLARATION - , CommonCssConstants.GAP, shorthandExpression); + , gapShorthandProperty, shorthandExpression); } if (String.IsNullOrEmpty(shorthandExpression)) { return HandleExpressionError(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.SHORTHAND_PROPERTY_CANNOT_BE_EMPTY - , CommonCssConstants.GAP, shorthandExpression); + , gapShorthandProperty, shorthandExpression); } String[] gapProps = iText.Commons.Utils.StringUtil.Split(shorthandExpression, " "); if (gapProps.Length == 1) { @@ -59,7 +90,7 @@ public virtual IList ResolveShorthand(String shorthandExpression } else { return HandleExpressionError(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.INVALID_CSS_PROPERTY_DECLARATION - , CommonCssConstants.GAP, shorthandExpression); + , gapShorthandProperty, shorthandExpression); } } } diff --git a/itext/itext.styledxmlparser/itext/styledxmlparser/css/validate/impl/CssDefaultValidator.cs b/itext/itext.styledxmlparser/itext/styledxmlparser/css/validate/impl/CssDefaultValidator.cs index f84facb810..0ebe0619e0 100644 --- a/itext/itext.styledxmlparser/itext/styledxmlparser/css/validate/impl/CssDefaultValidator.cs +++ b/itext/itext.styledxmlparser/itext/styledxmlparser/css/validate/impl/CssDefaultValidator.cs @@ -85,14 +85,16 @@ public CssDefaultValidator() { defaultValidators.Put(CommonCssConstants.LINE_HEIGHT, new MultiTypeDeclarationValidator(new CssNumberValueValidator (false), new CssLengthValueValidator(false), new CssPercentageValueValidator(false), normalValidator, inheritInitialUnsetValidator)); - defaultValidators.Put(CommonCssConstants.COLUMN_GAP, new MultiTypeDeclarationValidator(new CssLengthValueValidator - (false), new CssPercentageValueValidator(false), normalValidator)); + MultiTypeDeclarationValidator gapValidator = new MultiTypeDeclarationValidator(new CssLengthValueValidator + (false), new CssPercentageValueValidator(false), normalValidator, inheritInitialUnsetValidator); + defaultValidators.Put(CommonCssConstants.COLUMN_GAP, gapValidator); + defaultValidators.Put(CommonCssConstants.GRID_COLUMN_GAP, gapValidator); defaultValidators.Put(CommonCssConstants.COLUMN_WIDTH, new MultiTypeDeclarationValidator(new CssLengthValueValidator (false), new CssPercentageValueValidator(false), new CssEnumValidator(CommonCssConstants.AUTO))); defaultValidators.Put(CommonCssConstants.COLUMN_COUNT, new MultiTypeDeclarationValidator(new CssIntegerNumberValueValidator (false, false), new CssEnumValidator(CommonCssConstants.AUTO))); - defaultValidators.Put(CommonCssConstants.ROW_GAP, new MultiTypeDeclarationValidator(new CssLengthValueValidator - (false), new CssPercentageValueValidator(false), normalValidator, inheritInitialUnsetValidator)); + defaultValidators.Put(CommonCssConstants.ROW_GAP, gapValidator); + defaultValidators.Put(CommonCssConstants.GRID_ROW_GAP, gapValidator); defaultValidators.Put(CommonCssConstants.FLEX_GROW, new MultiTypeDeclarationValidator(new CssNumberValueValidator (false), inheritInitialUnsetValidator)); defaultValidators.Put(CommonCssConstants.FLEX_SHRINK, new MultiTypeDeclarationValidator(new CssNumberValueValidator diff --git a/port-hash b/port-hash index 72eaa47852..0bd73f67c3 100644 --- a/port-hash +++ b/port-hash @@ -1 +1 @@ -14594176c3df587ff53e54994152bf09ca64d596 +5a8f86d5e1ee424e95f9bae23d0ae30f8a971989