Skip to content

Commit 3b37433

Browse files
SnipxiText-CI
authored andcommitted
Deprecate CSS redundant rule class constructors that are more flexible than CSS specification
DEVSIX-3321
1 parent d9513c3 commit 3b37433

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

styled-xml-parser/src/main/java/com/itextpdf/styledxmlparser/css/CssFontFaceRule.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,20 @@ public class CssFontFaceRule extends CssNestedAtRule {
5555
*/
5656
private List<CssDeclaration> properties;
5757

58+
/**
59+
* Instantiates a new CSS font face rule.
60+
*/
61+
public CssFontFaceRule() {
62+
this("");
63+
}
64+
5865
/**
5966
* Instantiates a new CSS font face rule.
6067
*
6168
* @param ruleParameters the rule parameters
69+
* @deprecated Will be removed in 7.2. Use {@link #CssFontFaceRule()} instead
6270
*/
71+
@Deprecated
6372
public CssFontFaceRule(String ruleParameters) {
6473
super(CssRuleName.FONT_FACE, ruleParameters);
6574
}

styled-xml-parser/src/main/java/com/itextpdf/styledxmlparser/css/CssNestedAtRuleFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ public static CssNestedAtRule createNestedRule(String ruleDeclaration) {
9090
case CssRuleName.BOTTOM_CENTER:
9191
case CssRuleName.BOTTOM_RIGHT:
9292
case CssRuleName.BOTTOM_RIGHT_CORNER:
93-
return new CssMarginRule(ruleName, ruleParameters);
93+
return new CssMarginRule(ruleName);
9494
case CssRuleName.FONT_FACE:
95-
return new CssFontFaceRule(ruleParameters);
95+
return new CssFontFaceRule();
9696
default:
9797
return new CssNestedAtRule(ruleName, ruleParameters);
9898
}

styled-xml-parser/src/main/java/com/itextpdf/styledxmlparser/css/page/CssMarginRule.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,23 @@ public class CssMarginRule extends CssNestedAtRule {
5858
/** The page selectors. */
5959
private List<ICssSelector> pageSelectors;
6060

61+
/**
62+
* Creates a new {@link CssMarginRule} instance.
63+
*
64+
* @param ruleName the rule name
65+
*/
66+
public CssMarginRule(String ruleName) {
67+
this(ruleName, "");
68+
}
69+
6170
/**
6271
* Creates a new {@link CssMarginRule} instance.
6372
*
6473
* @param ruleName the rule name
6574
* @param ruleParameters the rule parameters
75+
* @deprecated Will be removed in 7.2. Use {@link #CssMarginRule(String)} instead
6676
*/
77+
@Deprecated
6778
public CssMarginRule(String ruleName, String ruleParameters) {
6879
super(ruleName, ruleParameters);
6980
}

styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssFontFaceRuleTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class CssFontFaceRuleTest extends ExtendedITextTest {
1414

1515
@Test
1616
public void verifyThatToStringProducesValidCss() {
17-
CssFontFaceRule fontFaceRule = new CssFontFaceRule("");
17+
CssFontFaceRule fontFaceRule = new CssFontFaceRule();
1818
List<CssDeclaration> declarations = new ArrayList<>();
1919
declarations.add(new CssDeclaration(CommonCssConstants.FONT_FAMILY, "test-font-family"));
2020
declarations.add(new CssDeclaration(CommonCssConstants.FONT_WEIGHT, CommonCssConstants.BOLD));

0 commit comments

Comments
 (0)