Skip to content

Commit 75a79d1

Browse files
committed
Remove redundant interface extension for form field classes
It was only there for compatibility over the past time. Now the form elements are supported via native inline-block functionality in layout DEVSIX-3495 Autoported commit. Original commit hash: [90f78d80] Manual files: src/main/java/com/itextpdf/html2pdf/attach/impl/layout/form/renderer/AbstractFormFieldRenderer.java
1 parent adc4b7a commit 75a79d1

File tree

7 files changed

+52
-51
lines changed

7 files changed

+52
-51
lines changed

itext/itext.html2pdf/itext/html2pdf/attach/impl/layout/form/element/IFormField.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,8 @@ source product.
4444
using iText.Layout.Element;
4545

4646
namespace iText.Html2pdf.Attach.Impl.Layout.Form.Element {
47-
/// <summary>
48-
/// Interface extending the
49-
/// <see cref="iText.Layout.Element.ILeafElement"/>
50-
/// interface in the context of form fields.
51-
/// </summary>
52-
public interface IFormField : ILeafElement, IBlockElement {
47+
/// <summary>Common interface for HTML form elements</summary>
48+
public interface IFormField : IBlockElement {
5349
/// <summary>Gets the id.</summary>
5450
/// <returns>the id</returns>
5551
String GetId();

itext/itext.html2pdf/itext/html2pdf/attach/impl/layout/form/renderer/AbstractFormFieldRenderer.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ namespace iText.Html2pdf.Attach.Impl.Layout.Form.Renderer {
6262
/// <see cref="iText.Layout.Renderer.BlockRenderer"/>
6363
/// for form fields.
6464
/// </summary>
65-
public abstract class AbstractFormFieldRenderer : BlockRenderer, ILeafElementRenderer {
65+
public abstract class AbstractFormFieldRenderer : BlockRenderer {
6666
/// <summary>The flat renderer.</summary>
6767
protected internal IRenderer flatRenderer;
6868

@@ -166,17 +166,6 @@ public override void DrawChildren(DrawContext drawContext) {
166166
drawContext.GetCanvas().RestoreState();
167167
}
168168

169-
public virtual float GetAscent() {
170-
float? baseline = GetLastYLineRecursively();
171-
return baseline != null ? occupiedArea.GetBBox().GetTop() - (float)baseline : occupiedArea.GetBBox().GetHeight
172-
();
173-
}
174-
175-
public virtual float GetDescent() {
176-
float? baseline = GetLastYLineRecursively();
177-
return baseline != null ? occupiedArea.GetBBox().GetBottom() - (float)baseline : 0;
178-
}
179-
180169
/* (non-Javadoc)
181170
* @see com.itextpdf.layout.renderer.BlockRenderer#getMinMaxWidth(float)
182171
*/

itext/itext.html2pdf/itext/html2pdf/attach/impl/tags/LiTagWorker.cs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -125,26 +125,34 @@ public virtual bool ProcessTagChild(ITagWorker childTagWorker, ProcessorContext
125125
return true;
126126
}
127127
else {
128-
if (childTagWorker is SpanTagWorker) {
129-
bool allChildrenProcessed = true;
130-
foreach (IPropertyContainer propertyContainer in ((SpanTagWorker)childTagWorker).GetAllElements()) {
131-
if (propertyContainer is ILeafElement) {
132-
inlineHelper.Add((ILeafElement)propertyContainer);
133-
}
134-
else {
135-
if (propertyContainer is IBlockElement && CssConstants.INLINE_BLOCK.Equals(((SpanTagWorker)childTagWorker)
136-
.GetElementDisplay(propertyContainer))) {
137-
inlineHelper.Add((IBlockElement)propertyContainer);
128+
if (childTagWorker is IDisplayAware && (CssConstants.INLINE_BLOCK.Equals(((IDisplayAware)childTagWorker).GetDisplay
129+
()) || CssConstants.INLINE.Equals(((IDisplayAware)childTagWorker).GetDisplay())) && element is IBlockElement
130+
) {
131+
inlineHelper.Add((IBlockElement)element);
132+
return true;
133+
}
134+
else {
135+
if (childTagWorker is SpanTagWorker) {
136+
bool allChildrenProcessed = true;
137+
foreach (IPropertyContainer propertyContainer in ((SpanTagWorker)childTagWorker).GetAllElements()) {
138+
if (propertyContainer is ILeafElement) {
139+
inlineHelper.Add((ILeafElement)propertyContainer);
138140
}
139141
else {
140-
allChildrenProcessed = ProcessChild(propertyContainer) && allChildrenProcessed;
142+
if (propertyContainer is IBlockElement && CssConstants.INLINE_BLOCK.Equals(((SpanTagWorker)childTagWorker)
143+
.GetElementDisplay(propertyContainer))) {
144+
inlineHelper.Add((IBlockElement)propertyContainer);
145+
}
146+
else {
147+
allChildrenProcessed = ProcessChild(propertyContainer) && allChildrenProcessed;
148+
}
141149
}
142150
}
151+
return allChildrenProcessed;
152+
}
153+
else {
154+
return ProcessChild(childTagWorker.GetElementResult());
143155
}
144-
return allChildrenProcessed;
145-
}
146-
else {
147-
return ProcessChild(childTagWorker.GetElementResult());
148156
}
149157
}
150158
}

itext/itext.html2pdf/itext/html2pdf/attach/impl/tags/PTagWorker.cs

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -144,38 +144,46 @@ public virtual bool ProcessTagChild(ITagWorker childTagWorker, ProcessorContext
144144
return true;
145145
}
146146
else {
147-
if (IsBlockWithDisplay(childTagWorker, element, CssConstants.INLINE_BLOCK, false)) {
147+
if (childTagWorker is IDisplayAware && (CssConstants.INLINE_BLOCK.Equals(((IDisplayAware)childTagWorker).GetDisplay
148+
()) || CssConstants.INLINE.Equals(((IDisplayAware)childTagWorker).GetDisplay())) && element is IBlockElement
149+
) {
148150
inlineHelper.Add((IBlockElement)element);
149151
return true;
150152
}
151153
else {
152-
if (IsBlockWithDisplay(childTagWorker, element, CssConstants.BLOCK, false)) {
153-
IPropertyContainer propertyContainer = childTagWorker.GetElementResult();
154-
ProcessBlockElement((IBlockElement)propertyContainer);
154+
if (IsBlockWithDisplay(childTagWorker, element, CssConstants.INLINE_BLOCK, false)) {
155+
inlineHelper.Add((IBlockElement)element);
155156
return true;
156157
}
157158
else {
158-
if (childTagWorker is SpanTagWorker) {
159-
bool allChildrenProcessed = true;
160-
foreach (IPropertyContainer propertyContainer in ((SpanTagWorker)childTagWorker).GetAllElements()) {
161-
if (propertyContainer is ILeafElement) {
162-
inlineHelper.Add((ILeafElement)propertyContainer);
163-
}
164-
else {
165-
if (IsBlockWithDisplay(childTagWorker, propertyContainer, CssConstants.INLINE_BLOCK, true)) {
166-
inlineHelper.Add((IBlockElement)propertyContainer);
159+
if (IsBlockWithDisplay(childTagWorker, element, CssConstants.BLOCK, false)) {
160+
IPropertyContainer propertyContainer = childTagWorker.GetElementResult();
161+
ProcessBlockElement((IBlockElement)propertyContainer);
162+
return true;
163+
}
164+
else {
165+
if (childTagWorker is SpanTagWorker) {
166+
bool allChildrenProcessed = true;
167+
foreach (IPropertyContainer propertyContainer in ((SpanTagWorker)childTagWorker).GetAllElements()) {
168+
if (propertyContainer is ILeafElement) {
169+
inlineHelper.Add((ILeafElement)propertyContainer);
167170
}
168171
else {
169-
if (IsBlockWithDisplay(childTagWorker, propertyContainer, CssConstants.BLOCK, true)) {
170-
ProcessBlockElement((IBlockElement)propertyContainer);
172+
if (IsBlockWithDisplay(childTagWorker, propertyContainer, CssConstants.INLINE_BLOCK, true)) {
173+
inlineHelper.Add((IBlockElement)propertyContainer);
171174
}
172175
else {
173-
allChildrenProcessed = false;
176+
if (IsBlockWithDisplay(childTagWorker, propertyContainer, CssConstants.BLOCK, true)) {
177+
ProcessBlockElement((IBlockElement)propertyContainer);
178+
}
179+
else {
180+
allChildrenProcessed = false;
181+
}
174182
}
175183
}
176184
}
185+
return allChildrenProcessed;
177186
}
178-
return allChildrenProcessed;
179187
}
180188
}
181189
}

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bfcd257de0ac1096659977fa32a7f64a3143e216
1+
90f78d80f8aea30b118152aca1eaff123b0e7ce3

0 commit comments

Comments
 (0)