diff options
author | sgeerken <devnull@localhost> | 2012-09-05 15:02:03 +0200 |
---|---|---|
committer | sgeerken <devnull@localhost> | 2012-09-05 15:02:03 +0200 |
commit | 60e562a0bb7329c6f6e9d66faad567cf660b01a4 (patch) | |
tree | 798c2599843451a2d6f51805b8d2b071ac63e1e5 | |
parent | df78d47c4845622e76fd719d15a0e060d999d318 (diff) |
Corrected comparison between too loose and too tight lines.
-rw-r--r-- | dw/textblock_linebreaking.cc | 13 | ||||
-rw-r--r-- | test/table-1.html | 21 |
2 files changed, 34 insertions, 0 deletions
diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc index 7559f38e..f2175803 100644 --- a/dw/textblock_linebreaking.cc +++ b/dw/textblock_linebreaking.cc @@ -154,6 +154,19 @@ bool Textblock::BadnessAndPenalty::lineCanBeBroken () int Textblock::BadnessAndPenalty::compareTo (BadnessAndPenalty *other) { + // First, a special condition: if a line is too tight, it will + // always be regarded as worse than a line, which is not too + // tight. Especially, lines too tight are worse than lines too + // loose. See test/table-1.html as a text case: the first line, + // which contains only the word "Short,", is too loose, but not + // breaking here would make the line too tight, making the text + // overwrap the available space. + + if (lineTooTight() && !other->lineTooTight()) + return 1; + if (!lineTooTight() && other->lineTooTight()) + return -1; + int thisNumInffinities = badnessInffinities () + penaltyInffinities (); int otherNumInffinities = other->badnessInffinities () + other->penaltyInffinities (); diff --git a/test/table-1.html b/test/table-1.html new file mode 100644 index 00000000..58635d2c --- /dev/null +++ b/test/table-1.html @@ -0,0 +1,21 @@ +<table> +<tr> +<td>Short, <span style="white-space: nowrap">then some more text, +which must not be broken.</span> +<td>This is a rather long text to increase the maximal paragraph +width. Sed ut perspiciatis, unde omnis iste natus error sit voluptatem +accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae +ab illo inventore veritatis et quasi architecto beatae vitae dicta +sunt, explicabo. nemo enim ipsam voluptatem, quia voluptas sit, +aspernatur aut odit aut fugit, sed quia consequuntur magni dolores +eos, qui ratione voluptatem sequi nesciunt, neque porro quisquam est, +qui dolorem ipsum, quia dolor sit, amet, consectetur, adipisci velit, +sed quia non numquam eius modi tempora incidunt, ut labore et dolore +magnam aliquam quaerat voluptatem. ut enim ad minima veniam, quis +nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut +aliquid ex ea commodi consequatur? quis autem vel eum iure +reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae +consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla +pariatur? +</tr> +</table> |