From 8c5aef924ae27549bac3d34057e5e36aaf0bca81 Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Mon, 28 Oct 2013 17:13:14 +0000 Subject: [PATCH] Slightly simplified looping through positions in addAreas git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_InlineContainer@1536424 13f79535-47bb-0310-9956-ffa450edef68 --- .../inline/InlineContainerLayoutManager.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java index 3688bcff0..a51d64c2c 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java @@ -154,16 +154,18 @@ public class InlineContainerLayoutManager extends AbstractLayoutManager implemen public void addAreas(PositionIterator posIter, LayoutContext context) { Position inlineContainerPosition = null; while (posIter.hasNext()) { - Position pos = posIter.next(); - if (pos.getLM() == this) { - inlineContainerPosition = pos; - } - } - if (inlineContainerPosition != null) { - SpaceResolver.performConditionalsNotification(childElements, 0, childElements.size() - 1, -1); - KnuthPossPosIter childPosIter = new KnuthPossPosIter(childElements); - AreaAdditionUtil.addAreas(this, childPosIter, context); + /* + * Should iterate only once, but hasNext must be called twice for its + * side-effects to apply and the iterator to switch to the next LM. + */ + assert inlineContainerPosition == null; + inlineContainerPosition = posIter.next(); + assert inlineContainerPosition.getLM() == this; } + assert inlineContainerPosition != null; + SpaceResolver.performConditionalsNotification(childElements, 0, childElements.size() - 1, -1); + KnuthPossPosIter childPosIter = new KnuthPossPosIter(childElements); + AreaAdditionUtil.addAreas(this, childPosIter, context); // boolean isLast = (context.isLastArea() && prevLM == lastChildLM); // context.setFlags(LayoutContext.LAST_AREA, isLast); -- 2.39.5