You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ad...@apache.org on 2008/01/27 14:35:40 UTC
svn commit: r615598 - in /xmlgraphics/fop/trunk:
src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java status.xml
Author: adelmelle
Date: Sun Jan 27 05:35:39 2008
New Revision: 615598
URL: http://svn.apache.org/viewvc?rev=615598&view=rev
Log:
Bugzilla #44286:
Fixed a memory-leak in XMLWhiteSpaceHandler.
Submitted by: Stefan Ziel <stefan.ziel.at.claninfo.ch>
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java
xmlgraphics/fop/trunk/status.xml
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java?rev=615598&r1=615597&r2=615598&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java Sun Jan 27 05:35:39 2008
@@ -68,12 +68,9 @@
/** Counter, increased every time a non-white-space is encountered */
private int nonWhiteSpaceCount;
- private Block currentBlock;
- private FObj currentFO;
private int linefeedTreatment;
private int whiteSpaceTreatment;
private int whiteSpaceCollapse;
- private FONode nextChild;
private boolean endOfBlock;
private boolean nextChildIsBlockLevel;
private RecursiveCharIterator charIter;
@@ -87,19 +84,28 @@
* firstTextNode
* @param fo the FO for which to handle white-space
* @param firstTextNode the node at which to start
+ * @param nextChild the node that will be added to the list
+ * after firstTextNode
*/
- public void handleWhiteSpace(FObjMixed fo, FONode firstTextNode) {
+ public void handleWhiteSpace(FObjMixed fo, FONode firstTextNode, FONode nextChild) {
+ Block currentBlock = null;
int foId = fo.getNameId();
if (foId == Constants.FO_BLOCK) {
- if (nextChild != null && currentBlock != null) {
- /* if already in a block, push the current block
- * onto the stack of nested blocks
- */
- nestedBlockStack.push(currentBlock);
- }
currentBlock = (Block) fo;
+ if (nestedBlockStack.isEmpty() || fo != nestedBlockStack.peek()) {
+ if (nextChild != null) {
+ /* if already in a block, push the current block
+ * onto the stack of nested blocks
+ */
+ nestedBlockStack.push(currentBlock);
+ }
+ } else {
+ if (nextChild == null) {
+ nestedBlockStack.pop();
+ }
+ }
} else if (foId == Constants.FO_RETRIEVE_MARKER) {
/* look for the nearest block ancestor, if any */
FONode ancestor = fo;
@@ -111,6 +117,8 @@
if (ancestor.getNameId() == Constants.FO_BLOCK) {
currentBlock = (Block) ancestor;
}
+ } else if (!nestedBlockStack.isEmpty()) {
+ currentBlock = (Block) nestedBlockStack.peek();
}
if (currentBlock != null) {
@@ -123,8 +131,6 @@
whiteSpaceTreatment = Constants.EN_IGNORE_IF_SURROUNDING_LINEFEED;
}
- currentFO = fo;
-
if (firstTextNode == null) {
//nothing to do but initialize related properties
return;
@@ -133,20 +139,20 @@
charIter = new RecursiveCharIterator(fo, firstTextNode);
inWhiteSpace = false;
- if (currentFO == currentBlock
+ if (fo == currentBlock
|| currentBlock == null
|| (foId == Constants.FO_RETRIEVE_MARKER
- && currentFO.getParent() == currentBlock)) {
+ && fo.getParent() == currentBlock)) {
afterLinefeed = (
(firstTextNode == fo.firstChild)
|| (firstTextNode.siblings[0].getNameId()
== Constants.FO_BLOCK));
}
- endOfBlock = (nextChild == null && currentFO == currentBlock);
+ endOfBlock = (nextChild == null && fo == currentBlock);
if (nextChild != null) {
- int nextChildId = this.nextChild.getNameId();
+ int nextChildId = nextChild.getNameId();
nextChildIsBlockLevel = (
nextChildId == Constants.FO_BLOCK
|| nextChildId == Constants.FO_TABLE_AND_CAPTION
@@ -159,7 +165,7 @@
handleWhiteSpace();
- if (currentFO == currentBlock
+ if (fo == currentBlock
&& pendingInlines != null
&& !pendingInlines.isEmpty()) {
/* current FO is a block, and has pending inlines */
@@ -183,7 +189,7 @@
}
if (nextChild == null) {
- if (currentFO != currentBlock) {
+ if (fo != currentBlock) {
/* current FO is not a block, and is about to end */
if (nonWhiteSpaceCount > 0 && pendingInlines != null) {
/* there is non-white-space text between the pending
@@ -204,7 +210,6 @@
} else {
currentBlock = null;
}
- currentFO = null;
charIter = null;
}
}
@@ -218,10 +223,8 @@
* @param nextChild the child-node that will be added to the list after
* the last text-node
*/
- public void handleWhiteSpace(FObjMixed fo, FONode firstTextNode, FONode nextChild) {
- this.nextChild = nextChild;
- handleWhiteSpace(fo, firstTextNode);
- this.nextChild = null;
+ public void handleWhiteSpace(FObjMixed fo, FONode firstTextNode) {
+ handleWhiteSpace(fo, firstTextNode, null);
}
private void handleWhiteSpace() {
Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=615598&r1=615597&r2=615598&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Sun Jan 27 05:35:39 2008
@@ -28,6 +28,9 @@
<changes>
<release version="FOP Trunk">
+ <action context="Code" dev="AD" type="fix" fixes-bug="44286" due-to="Stefan Ziel">
+ Fixed a memory-leak in XMLWhiteSpaceHandler.
+ </action>
<action context="Layout" dev="VH" type="fix" fixes-bug="44289">
Fixed the resolution of borders when header/footer is omitted at page breaks.
</action>
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org