Skip to content

Commit 0289621

Browse files
ars18wrwiText-CI
authored andcommitted
Prevent null from being passed as occupied area in case of FULL
In case result is updated to be FULL, result's occupied area could be null: one should check the splitRenderer's occupied area instead. DEVSIX-5237 Autoported commit. Original commit hash: [79e8eb90e]
1 parent 25e2d01 commit 0289621

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

itext.tests/itext.layout.tests/itext/layout/renderer/FlexContainerRendererTest.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2020
You should have received a copy of the GNU Affero General Public License
2121
along with this program. If not, see <https://www.gnu.org/licenses/>.
2222
*/
23+
using iText.Kernel.Geom;
2324
using iText.Layout.Borders;
2425
using iText.Layout.Element;
26+
using iText.Layout.Layout;
2527
using iText.Layout.Properties;
2628
using iText.Test;
2729

@@ -152,6 +154,15 @@ public virtual void WidthSetToChildManyChildrenFlexRendererWithMinWidthTest() {
152154
NUnit.Framework.Assert.AreEqual(125F, flexRenderer.GetMinMaxWidth().GetMaxWidth(), EPS);
153155
}
154156

157+
[NUnit.Framework.Test]
158+
public virtual void DecreaseLayoutBoxAfterChildPlacementResultsOccupiedAreaNull() {
159+
FlexContainerRenderer splitRenderer = new FlexContainerRenderer(new Div());
160+
splitRenderer.occupiedArea = new LayoutArea(0, new Rectangle(0, 0));
161+
LayoutResult nothing = new LayoutResult(LayoutResult.NOTHING, null, splitRenderer, null);
162+
NUnit.Framework.Assert.IsNotNull(new FlexContainerRenderer(new Div()).GetOccupiedAreaInCaseNothingWasWrappedWithFull
163+
(nothing, splitRenderer));
164+
}
165+
155166
[NUnit.Framework.Test]
156167
public virtual void WidthSetToChildManyChildrenFlexRendererWithMinWidthBiggerThanMaxWidthTest() {
157168
FlexContainerRenderer flexRenderer = new FlexContainerRenderer(new Div());

itext/itext.layout/itext/layout/renderer/FlexContainerRenderer.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ internal override LayoutResult ProcessNotFullChildResult(LayoutContext layoutCon
198198
if (splitRenderer != null) {
199199
splitRenderer.SetChildRenderers(GetChildRenderers());
200200
}
201-
return new LayoutResult(LayoutResult.FULL, result.GetOccupiedArea(), splitRenderer, null, null);
201+
return new LayoutResult(LayoutResult.FULL, GetOccupiedAreaInCaseNothingWasWrappedWithFull(result, splitRenderer
202+
), splitRenderer, null, null);
202203
}
203204
else {
204205
ApplyPaddings(occupiedArea.GetBBox(), paddings, true);
@@ -215,6 +216,12 @@ internal override LayoutResult ProcessNotFullChildResult(LayoutContext layoutCon
215216
}
216217
}
217218

219+
// TODO DEVSIX-5238 Consider this fix (perhaps it should be improved or unified) while working on the ticket
220+
internal virtual LayoutArea GetOccupiedAreaInCaseNothingWasWrappedWithFull(LayoutResult result, IRenderer
221+
splitRenderer) {
222+
return null != result.GetOccupiedArea() ? result.GetOccupiedArea() : splitRenderer.GetOccupiedArea();
223+
}
224+
218225
internal override bool StopLayoutingChildrenIfChildResultNotFull(LayoutResult returnResult) {
219226
return returnResult.GetStatus() != LayoutResult.FULL;
220227
}

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9fadebfb114a7ee9ef9058a8b0c9deec71262210
1+
79e8eb90e75984beab3aa95b2aebeb8bd30e54da

0 commit comments

Comments
 (0)