Skip to content

Commit 1a400fc

Browse files
SnipxIdamkinI
authored andcommitted
Make the CSS API more convenient to use
Autoported commit. Original commit hash: [f94218926]
1 parent 5ac794d commit 1a400fc

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

itext/itext.html2pdf/itext/html2pdf/css/CssNestedAtRule.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,5 +127,9 @@ public override String ToString() {
127127
sb.Append("\n}");
128128
return sb.ToString();
129129
}
130+
131+
public virtual String GetRuleParameters() {
132+
return ruleParameters;
133+
}
130134
}
131135
}

itext/itext.html2pdf/itext/html2pdf/css/CssRuleSet.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,28 @@ public class CssRuleSet : CssStatement {
6868
/// <summary>
6969
/// Creates a new
7070
/// <see cref="CssRuleSet"/>
71-
/// .
71+
/// from selector and raw list of declarations.
72+
/// The declarations are split into normal and important under the hood.
73+
/// To construct the
74+
/// <see cref="CssRuleSet"/>
75+
/// instance from normal and important declarations, see
76+
/// <see cref="CssRuleSet(iText.Html2pdf.Css.Selector.ICssSelector, System.Collections.Generic.IList{E}, System.Collections.Generic.IList{E})
77+
/// "/>
7278
/// </summary>
7379
/// <param name="selector">the CSS selector</param>
7480
/// <param name="declarations">the CSS declarations</param>
7581
public CssRuleSet(ICssSelector selector, IList<CssDeclaration> declarations) {
7682
this.selector = selector;
7783
this.normalDeclarations = new List<CssDeclaration>();
7884
this.importantDeclarations = new List<CssDeclaration>();
79-
SplitDeclarationsIntoNormalAndImportant(declarations);
85+
SplitDeclarationsIntoNormalAndImportant(declarations, normalDeclarations, importantDeclarations);
86+
}
87+
88+
public CssRuleSet(ICssSelector selector, IList<CssDeclaration> normalDeclarations, IList<CssDeclaration> importantDeclarations
89+
) {
90+
this.selector = selector;
91+
this.normalDeclarations = normalDeclarations;
92+
this.importantDeclarations = importantDeclarations;
8093
}
8194

8295
/* (non-Javadoc)
@@ -137,7 +150,8 @@ public virtual IList<CssDeclaration> GetImportantDeclarations() {
137150

138151
/// <summary>Split CSS declarations into normal and important CSS declarations.</summary>
139152
/// <param name="declarations">the declarations</param>
140-
private void SplitDeclarationsIntoNormalAndImportant(IList<CssDeclaration> declarations) {
153+
private static void SplitDeclarationsIntoNormalAndImportant(IList<CssDeclaration> declarations, IList<CssDeclaration
154+
> normalDeclarations, IList<CssDeclaration> importantDeclarations) {
141155
foreach (CssDeclaration declaration in declarations) {
142156
int exclIndex = declaration.GetExpression().IndexOf('!');
143157
if (exclIndex > 0 && iText.IO.Util.StringUtil.Match(importantMatcher, declaration.GetExpression()).Success

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
80e7849f8290776ac459c3c64f5e907c7768645b
1+
f942189265fb4cac4af5c742ac152b011d149118

0 commit comments

Comments
 (0)