]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Third phase of performance improvement.
authorFinn Bock <bckfnn@apache.org>
Tue, 19 Oct 2004 21:51:54 +0000 (21:51 +0000)
committerFinn Bock <bckfnn@apache.org>
Tue, 19 Oct 2004 21:51:54 +0000 (21:51 +0000)
- Split the border/padding features of InlineStackingLM out into a
InlineLM which is the LM for fo:inline.

PR: 31699

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198075 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/InlineLayoutManager.java [new file with mode: 0755]
src/java/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java

diff --git a/src/java/org/apache/fop/layoutmgr/InlineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/InlineLayoutManager.java
new file mode 100755 (executable)
index 0000000..642815e
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.layoutmgr;
+
+
+import org.apache.fop.fo.flow.Inline;
+import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
+import org.apache.fop.fo.properties.CommonMarginInline;
+import org.apache.fop.fo.properties.SpaceProperty;
+import org.apache.fop.traits.MinOptMax;
+import org.apache.fop.traits.SpaceVal;
+
+/**
+ * LayoutManager for objects which stack children in the inline direction,
+ * such as Inline or Line
+ */
+public class InlineLayoutManager extends InlineStackingLayoutManager {
+    private Inline fobj;
+
+    private CommonMarginInline inlineProps = null;
+    private CommonBorderPaddingBackground borderProps = null;
+
+    /**
+     * Create an inline layout manager.
+     * This is used for fo's that create areas that
+     * contain inline areas.
+     *
+     * @param node the formatting object that creates the area
+     */
+    public InlineLayoutManager(Inline node) {
+        super(node);
+        fobj = node;
+    }
+    
+    /**
+     * @see org.apache.fop.layoutmgr.AbstractLayoutManager#initProperties()
+     */
+    protected void initProperties() {
+        super.initProperties();
+        inlineProps = fobj.getCommonMarginInline();
+        borderProps = fobj.getCommonBorderPaddingBackground();
+        int iPad = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false);
+        iPad += borderProps.getBorderWidth(CommonBorderPaddingBackground.BEFORE,
+                                             false);
+        iPad += borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false);
+        iPad += borderProps.getBorderWidth(CommonBorderPaddingBackground.AFTER, false);
+        extraBPD = new MinOptMax(iPad);
+    }
+
+    protected MinOptMax getExtraIPD(boolean bNotFirst, boolean bNotLast) {
+        int iBP = borderProps.getPadding(CommonBorderPaddingBackground.START,
+                                           bNotFirst);
+        iBP += borderProps.getBorderWidth(CommonBorderPaddingBackground.START,
+                                            bNotFirst);
+        iBP += borderProps.getPadding(CommonBorderPaddingBackground.END, bNotLast);
+        iBP += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, bNotLast);
+        return new MinOptMax(iBP);
+    }
+
+
+    protected boolean hasLeadingFence(boolean bNotFirst) {
+        int iBP = borderProps.getPadding(CommonBorderPaddingBackground.START,
+                                           bNotFirst);
+        iBP += borderProps.getBorderWidth(CommonBorderPaddingBackground.START,
+                                            bNotFirst);
+        return (iBP > 0);
+    }
+
+    protected boolean hasTrailingFence(boolean bNotLast) {
+        int iBP = borderProps.getPadding(CommonBorderPaddingBackground.END, bNotLast);
+        iBP += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, bNotLast);
+        return (iBP > 0);
+    }
+
+    protected SpaceProperty getSpaceStart() {
+        return inlineProps.spaceStart;
+    }
+    protected SpaceProperty getSpaceEnd() {
+        return inlineProps.spaceEnd;
+    }
+    
+
+    /**
+     * Return value indicating whether the next area to be generated could
+     * start a new line. This should only be called in the "START" condition
+     * if a previous inline BP couldn't end the line.
+     * Return true if any space-start, border-start or padding-start, else
+     * propagate to first child LM
+     */
+    public boolean canBreakBefore(LayoutContext context) {
+        if (new SpaceVal(inlineProps.spaceStart).getSpace().min > 0 || hasLeadingFence(false)) {
+            return true;
+        }
+        return super.canBreakBefore(context);
+    }
+    
+    protected void setTraits(boolean bNotFirst, boolean bNotLast) {
+        
+        // Add border and padding to current area and set flags (FIRST, LAST ...)
+        TraitSetter.setBorderPaddingTraits(getCurrentArea(),
+                                           borderProps, bNotFirst, bNotLast);
+
+        if (borderProps != null) {
+            TraitSetter.addBorders(getCurrentArea(), borderProps);
+            TraitSetter.addBackground(getCurrentArea(), borderProps);
+        }
+    }
+
+}
+
index afc4968d4edda8993e95e41d48a873193395f039..5b6bf5002e12bc269054d955d4ff5602fa0f93ac 100644 (file)
@@ -26,8 +26,6 @@ import java.util.HashMap;
 
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyManager;
-import org.apache.fop.fo.properties.CommonBorderAndPadding;
-import org.apache.fop.fo.properties.CommonBackground;
 import org.apache.fop.traits.InlineProps;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.inline.InlineArea;
@@ -66,12 +64,10 @@ public class InlineStackingLayoutManager extends AbstractLayoutManager {
     /**
      * Size of border and padding in BPD (ie, before and after).
      */
-    private MinOptMax extraBPD;
+    protected MinOptMax extraBPD;
 
 
     private InlineProps inlineProps = null;
-    private CommonBorderAndPadding borderProps = null;
-    private CommonBackground backgroundProps;
 
     private Area currentArea; // LineArea or InlineParent
 
@@ -103,16 +99,7 @@ public class InlineStackingLayoutManager extends AbstractLayoutManager {
     protected void initProperties() {
         PropertyManager pm = fobj.getPropertyManager();
         inlineProps = pm.getInlineProps();
-        borderProps = pm.getBorderAndPadding();
-        // Calculdate border and padding size in BPD
-        int iPad = borderProps.getPadding(CommonBorderAndPadding.BEFORE, false);
-        iPad += borderProps.getBorderWidth(CommonBorderAndPadding.BEFORE,
-                                             false);
-        iPad += borderProps.getPadding(CommonBorderAndPadding.AFTER, false);
-        iPad += borderProps.getBorderWidth(CommonBorderAndPadding.AFTER, false);
-        extraBPD = new MinOptMax(iPad);
-
-        backgroundProps = pm.getBackgroundProps();
+        extraBPD = new MinOptMax(0);
     }
 
     /**
@@ -135,28 +122,16 @@ public class InlineStackingLayoutManager extends AbstractLayoutManager {
     }
 
     private MinOptMax getExtraIPD(boolean bNotFirst, boolean bNotLast) {
-        int iBP = borderProps.getPadding(CommonBorderAndPadding.START,
-                                           bNotFirst);
-        iBP += borderProps.getBorderWidth(CommonBorderAndPadding.START,
-                                            bNotFirst);
-        iBP += borderProps.getPadding(CommonBorderAndPadding.END, bNotLast);
-        iBP += borderProps.getBorderWidth(CommonBorderAndPadding.END, bNotLast);
-        return new MinOptMax(iBP);
+        return new MinOptMax(0);
     }
 
 
     protected boolean hasLeadingFence(boolean bNotFirst) {
-        int iBP = borderProps.getPadding(CommonBorderAndPadding.START,
-                                           bNotFirst);
-        iBP += borderProps.getBorderWidth(CommonBorderAndPadding.START,
-                                            bNotFirst);
-        return (iBP > 0);
+        return false;
     }
 
     protected boolean hasTrailingFence(boolean bNotLast) {
-        int iBP = borderProps.getPadding(CommonBorderAndPadding.END, bNotLast);
-        iBP += borderProps.getBorderWidth(CommonBorderAndPadding.END, bNotLast);
-        return (iBP > 0);
+        return false;
     }
 
     /**
@@ -521,17 +496,6 @@ public class InlineStackingLayoutManager extends AbstractLayoutManager {
             context.getTrailingSpace().addSpace(inlineProps.spaceEnd);
         }
 
-        // Add border and padding to current area and set flags (FIRST, LAST ...)
-        TraitSetter.setBorderPaddingTraits(getCurrentArea(),
-                                           borderProps, bAreaCreated, !bIsLast);
-
-        if (borderProps != null) {
-            TraitSetter.addBorders(getCurrentArea(), borderProps);
-        }
-        if (backgroundProps != null) {
-            TraitSetter.addBackground(getCurrentArea(), backgroundProps);
-        }
-
         parentLM.addChild(getCurrentArea());
         context.setFlags(LayoutContext.LAST_AREA, bIsLast);
         bAreaCreated = true;