You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Vincent Hennebert <vh...@gmail.com> on 2009/07/07 13:54:38 UTC
Re: svn commit: r790166 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr:
AbstractBreaker.java PageBreaker.java PageBreakingAlgorithm.java
Hi Andreas,
The changes generally look good. I just have two small questions:
> Author: adelmelle
> Date: Wed Jul 1 13:52:20 2009
> New Revision: 790166
>
> URL: http://svn.apache.org/viewvc?rev=790166&view=rev
> Log:
> Further cleanup/readability improvements
>
> @@ -550,31 +563,33 @@
> if (element.isBox()) {
> // element is a box
> splitLength += element.getW();
> - bPrevIsBox = true;
> + boxPreceding = true;
> } else if (element.isGlue()) {
> // element is a glue
> - if (bPrevIsBox) {
> + if (boxPreceding) {
> // end of the sub-sequence
> index = noteListIterator.previousIndex();
> break;
> }
> - bPrevIsBox = false;
> + boxPreceding = false;
> splitLength += element.getW();
> } else {
> // element is a penalty
> - if (element.getP() < KnuthElement.INFINITE) {
> + //if (element.getP() < KnuthElement.INFINITE) {
> // end of the sub-sequence
> index = noteListIterator.previousIndex();
> break;
> - }
> + //}
Why did you comment out the test? Unless I missed something that may
result into regressions with some test cases.
<snip/>
> + /** {@inheritDoc} */
> protected int filterActiveNodes() {
> // leave only the active node with fewest total demerits
> KnuthNode bestActiveNode = null;
> @@ -849,11 +880,17 @@
> }
> }
> }
> - return bestActiveNode.line;
> + return (bestActiveNode == null) ? -1 : bestActiveNode.line;
Why did you add this test? Did you run into NPE with some test cases?
Thanks,
Vincent
Re: svn commit: r790166 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr: AbstractBreaker.java PageBreaker.java PageBreakingAlgorithm.java
Posted by Andreas Delmelle <an...@telenet.be>.
On 07 Jul 2009, at 17:22, Vincent Hennebert wrote:
>
> Ok. To be honest I don’t remember why I did that. Probably a cheap
> attempt to make a failing test case with footnotes pass again. At any
> rate this will have to be checked. I’m wondering what’s supposed to
> happen if there is no legal break in the sequence.
I think it was necessary because the keep-implementation possibly
inserts penalties with value INFINITE, but those may still be
considered as a legal break. If the penalty corresponds to a
keep.within-page, the breakpoint may still be considered as a mere
column-break.
BTW: I've considered your suggestion of using penalties with value 0,
but the downside seems to be that those would always be considered as
a legal break by the default implementation in BreakingAlgorithm.
For penalties corresponding to page-, or column-keeps I have relocated
the special treatment to PageBreakingAlgorithm.handlePenaltyAt(), so
where you had initially added a check 'breakClass != EN_LINE', the
additional method now allows to move that check to the class where it
belongs.
>>>>
>>>> - return bestActiveNode.line;
>>>> + return (bestActiveNode == null) ? -1 :
>>>> bestActiveNode.line;
>>>
>>> Why did you add this test? Did you run into NPE with some test
>>> cases?
>>
>> Not yet, but IntelliJ IDEA always marks dereferences that possibly
>> lead
>> to NPEs as a warning. Better safe than sorry, I guess...
>
> I don’t agree. The check should be added only if it corresponds to
> a valid situation that may occur when calling this method. Otherwise
> it
> should be replaced with an earlier ‘assert bestActiveNode != null’.
> And
> given that, in the calling findBreakingPoints method, there is a
> special
> return statement when the number of active nodes falls to 0, I suspect
> that we are in the latter case.
Makes sense. I'll take care of changing it to an 'assert'.
Regards
Andreas Delmelle
e-mail: andreas.delmelle.AT.telenet.be
Skype: adlm0608
Jabber: mandreas@jabber.org
Re: svn commit: r790166 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr:
AbstractBreaker.java PageBreaker.java PageBreakingAlgorithm.java
Posted by Vincent Hennebert <vh...@gmail.com>.
Hi Andreas,
Andreas Delmelle wrote:
> On 07 Jul 2009, at 13:54, Vincent Hennebert wrote:
>
> Hi Vincent,
>
>>> splitLength += element.getW();
>>> } else {
>>> // element is a penalty
>>> - if (element.getP() < KnuthElement.INFINITE) {
>>> + //if (element.getP() < KnuthElement.INFINITE) {
>>> // end of the sub-sequence
>>> index = noteListIterator.previousIndex();
>>> break;
>>> - }
>>> + //}
>>
>> Why did you comment out the test? Unless I missed something that may
>> result into regressions with some test cases.
>
> Aargh... Spent so much time sorting out which changes could already be
> committed and still...
> Checked, and this should actually be part of the column-keeps
> implementation. It was part of your original patch. I'll undo this
> change asap.
Ok. To be honest I don’t remember why I did that. Probably a cheap
attempt to make a failing test case with footnotes pass again. At any
rate this will have to be checked. I’m wondering what’s supposed to
happen if there is no legal break in the sequence.
>>>
>>> - return bestActiveNode.line;
>>> + return (bestActiveNode == null) ? -1 : bestActiveNode.line;
>>
>> Why did you add this test? Did you run into NPE with some test cases?
>
> Not yet, but IntelliJ IDEA always marks dereferences that possibly lead
> to NPEs as a warning. Better safe than sorry, I guess...
I don’t agree. The check should be added only if it corresponds to
a valid situation that may occur when calling this method. Otherwise it
should be replaced with an earlier ‘assert bestActiveNode != null’. And
given that, in the calling findBreakingPoints method, there is a special
return statement when the number of active nodes falls to 0, I suspect
that we are in the latter case.
That kind of change may make it very difficult to trace the origin of
bugs. I very much prefer to have a NPE rather than a non-sensical
default value that is silently returned, leading to the application
finishing normally, yet with a wrong rendering. At least the NPE gives
some indication of where to start looking. Sort of fail-fast behaviour.
Thanks,
Vincent
Re: svn commit: r790166 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr: AbstractBreaker.java PageBreaker.java PageBreakingAlgorithm.java
Posted by Andreas Delmelle <an...@telenet.be>.
On 07 Jul 2009, at 13:54, Vincent Hennebert wrote:
Hi Vincent,
>> splitLength += element.getW();
>> } else {
>> // element is a penalty
>> - if (element.getP() <
>> KnuthElement.INFINITE) {
>> + //if (element.getP() <
>> KnuthElement.INFINITE) {
>> // end of the sub-sequence
>> index = noteListIterator.previousIndex();
>> break;
>> - }
>> + //}
>
> Why did you comment out the test? Unless I missed something that may
> result into regressions with some test cases.
Aargh... Spent so much time sorting out which changes could already be
committed and still...
Checked, and this should actually be part of the column-keeps
implementation. It was part of your original patch. I'll undo this
change asap.
>>
>> - return bestActiveNode.line;
>> + return (bestActiveNode == null) ? -1 : bestActiveNode.line;
>
> Why did you add this test? Did you run into NPE with some test cases?
Not yet, but IntelliJ IDEA always marks dereferences that possibly
lead to NPEs as a warning. Better safe than sorry, I guess...
Regards
Andreas
Andreas Delmelle
e-mail: andreas.delmelle.AT.telenet.be
Skype: adlm0608
Jabber: mandreas@jabber.org