Skip to content

Commit 070daa9

Browse files
committed
Process paragraph margins correctly. Fixes in overflow with floats processing. Delete unnecessary layout methods.
DEVSIX-992 Autoported commit. Original commit hash: [2b3980f]
1 parent 188d538 commit 070daa9

File tree

4 files changed

+25
-54
lines changed

4 files changed

+25
-54
lines changed

itext/itext.layout/itext/layout/element/BlockElement.cs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -353,34 +353,6 @@ public virtual T SetMinHeight(float minHeight) {
353353
return (T)(Object)this;
354354
}
355355

356-
/// <summary>Sets the overflow-x value.</summary>
357-
///
358-
/// <returns>this element</returns>
359-
public virtual T SetOverflowX(OverflowPropertyValue? overflow) {
360-
SetProperty(Property.OVERFLOW_X, overflow);
361-
return (T)(Object)this;
362-
}
363-
364-
/// <summary>Sets the overflow-y value.</summary>
365-
///
366-
/// <returns>this element</returns>
367-
public virtual T SetOverflowY(OverflowPropertyValue? overflow) {
368-
SetProperty(Property.OVERFLOW_Y, overflow);
369-
return (T)(Object)this;
370-
}
371-
372-
/// <summary>Gets the overflow-x value of the element.</summary>
373-
/// <returns>the overflow-x value of the element.</returns>
374-
public virtual OverflowPropertyValue? GetOverflowX() {
375-
return this.GetProperty<OverflowPropertyValue?>(Property.OVERFLOW_X);
376-
}
377-
378-
/// <summary>Gets the overflow-y value of the element.</summary>
379-
/// <returns>the overflow-y value of the element.</returns>
380-
public virtual OverflowPropertyValue? GetOverflowY() {
381-
return this.GetProperty<OverflowPropertyValue?>(Property.OVERFLOW_Y);
382-
}
383-
384356
public abstract AccessibilityProperties GetAccessibilityProperties();
385357

386358
public abstract PdfName GetRole();

itext/itext.layout/itext/layout/renderer/LineRenderer.cs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,17 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
7777
Rectangle layoutBox = layoutContext.GetArea().GetBBox().Clone();
7878
bool wasParentsHeightClipped = layoutContext.GetArea().IsClippedHeight();
7979
IList<Rectangle> floatRendererAreas = layoutContext.GetFloatRendererAreas();
80+
OverflowPropertyValue? oldXOverflow = null;
81+
bool wasXOverflowChanged = false;
8082
if (floatRendererAreas != null) {
83+
float layoutWidth = layoutBox.GetWidth();
8184
FloatingHelper.AdjustLineAreaAccordingToFloats(floatRendererAreas, layoutBox);
82-
if (0 != floatRendererAreas.Count) {
85+
if (layoutWidth > layoutBox.GetWidth()) {
86+
oldXOverflow = this.GetProperty<OverflowPropertyValue?>(Property.OVERFLOW_X);
87+
wasXOverflowChanged = true;
8388
SetProperty(Property.OVERFLOW_X, OverflowPropertyValue.FIT);
8489
}
8590
}
86-
// TODO
8791
occupiedArea = new LayoutArea(layoutContext.GetArea().GetPageNumber(), layoutBox.Clone().MoveUp(layoutBox.
8892
GetHeight()).SetHeight(0).SetWidth(0));
8993
float curWidth = 0;
@@ -175,15 +179,14 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
175179
// when floating span is split on other line;
176180
// TODO may be process floating spans as inline blocks always?
177181
if (childPos > 0) {
182+
oldXOverflow = this.GetProperty<OverflowPropertyValue?>(Property.OVERFLOW_X);
183+
wasXOverflowChanged = true;
178184
SetProperty(Property.OVERFLOW_X, OverflowPropertyValue.FIT);
179185
}
180186
if (overflowFloats.IsEmpty() && (!anythingPlaced || floatingBoxFullWidth <= bbox.GetWidth())) {
181187
childResult = childRenderer.Layout(new LayoutContext(new LayoutArea(layoutContext.GetArea().GetPageNumber(
182188
), layoutContext.GetArea().GetBBox().Clone(), wasParentsHeightClipped), null, floatRendererAreas));
183189
}
184-
if (childPos > 0) {
185-
DeleteOwnProperty(Property.OVERFLOW_X);
186-
}
187190
// Get back child width so that it's not lost
188191
if (childWidthWasReplaced) {
189192
if (childRendererHasOwnWidthProperty) {
@@ -272,13 +275,12 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
272275
}
273276
if (childResult == null) {
274277
if (childPos > 0) {
278+
oldXOverflow = this.GetProperty<OverflowPropertyValue?>(Property.OVERFLOW_X);
279+
wasXOverflowChanged = true;
275280
SetProperty(Property.OVERFLOW_X, OverflowPropertyValue.FIT);
276281
}
277282
childResult = childRenderer.Layout(new LayoutContext(new LayoutArea(layoutContext.GetArea().GetPageNumber(
278283
), bbox, wasParentsHeightClipped)));
279-
if (childPos > 0) {
280-
DeleteOwnProperty(Property.OVERFLOW_X);
281-
}
282284
}
283285
// Get back child width so that it's not lost
284286
if (childWidthWasReplaced) {
@@ -621,16 +623,13 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
621623
processed.AdjustChildrenYLine().TrimLast();
622624
result.SetMinMaxWidth(minMaxWidth);
623625
}
624-
if (floatRendererAreas != null) {
625-
if (0 != floatRendererAreas.Count) {
626-
DeleteOwnProperty(Property.OVERFLOW_X);
627-
// TODO
628-
if (null != result.GetSplitRenderer()) {
629-
result.GetSplitRenderer().DeleteOwnProperty(Property.OVERFLOW_X);
630-
}
631-
if (null != result.GetOverflowRenderer()) {
632-
result.GetOverflowRenderer().DeleteOwnProperty(Property.OVERFLOW_X);
633-
}
626+
if (wasXOverflowChanged) {
627+
SetProperty(Property.OVERFLOW_X, oldXOverflow);
628+
if (null != result.GetSplitRenderer()) {
629+
result.GetSplitRenderer().SetProperty(Property.OVERFLOW_X, oldXOverflow);
630+
}
631+
if (null != result.GetOverflowRenderer()) {
632+
result.GetOverflowRenderer().SetProperty(Property.OVERFLOW_X, oldXOverflow);
634633
}
635634
}
636635
return result;

itext/itext.layout/itext/layout/renderer/ParagraphRenderer.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,13 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
378378
previousDescent = processedRenderer.GetMaxDescent();
379379
}
380380
}
381+
float moveDown = lastLineBottomLeadingIndent;
382+
if ((null == overflowY || OverflowPropertyValue.FIT.Equals(overflowY)) && moveDown > occupiedArea.GetBBox(
383+
).GetY() - layoutBox.GetY()) {
384+
moveDown = occupiedArea.GetBBox().GetY() - layoutBox.GetY();
385+
}
386+
occupiedArea.GetBBox().MoveDown(moveDown);
387+
occupiedArea.GetBBox().SetHeight(occupiedArea.GetBBox().GetHeight() + moveDown);
381388
float overflowPartHeight = GetOverflowPartHeight(overflowY, layoutBox);
382389
if (marginsCollapsingEnabled) {
383390
if (childRenderers.Count > 0 && notAllKidsAreFloats) {
@@ -388,13 +395,6 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
388395
if (FloatingHelper.IsRendererFloating(this, floatPropertyValue)) {
389396
FloatingHelper.IncludeChildFloatsInOccupiedArea(floatRendererAreas, this);
390397
}
391-
float moveDown = lastLineBottomLeadingIndent;
392-
if ((null == overflowY || OverflowPropertyValue.FIT.Equals(overflowY)) && moveDown > occupiedArea.GetBBox(
393-
).GetY() - layoutBox.GetY()) {
394-
moveDown = occupiedArea.GetBBox().GetY() - layoutBox.GetY();
395-
}
396-
occupiedArea.GetBBox().MoveDown(moveDown);
397-
occupiedArea.GetBBox().SetHeight(occupiedArea.GetBBox().GetHeight() + moveDown);
398398
IRenderer overflowRenderer = null;
399399
float? blockMinHeight = RetrieveMinHeight();
400400
if (null != blockMinHeight && blockMinHeight > occupiedArea.GetBBox().GetHeight()) {

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
707e41a9d7acaca7287322b9d5f5df84df6dfc0e
1+
2b3980fe433a1ae12951c10f99b73f61207669e7

0 commit comments

Comments
 (0)