[Webkit-unassigned] [Bug 34155] Support CSS page-break-{before/after} with a value of 'avoid'.

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu May 6 04:32:25 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=34155





--- Comment #1 from Hayato Ito <hayato at chromium.org>  2010-05-06 04:32:25 PST ---
I'd like to update the status.

In current WebCore, it seems that the position of page breaks are determined in
'greedy' manner, without looking ahead entire web page. I tried to support
'page-break-xx: avoid', but found that it is difficult to support these rules
within current approach.

So I've decided to take the following new approach:

1. Collect every candidates of page breaks in entire web page beforehand in
printing time. Each candidate represents a place where page break might occur
and must meet the condition of 'Allowed page breaks' defined in
http://dev.w3.org/csswg/css3-page/#allowed-pg-brk
2. Give a score to each candidate using some dynamic programming techniques.
For example, if a candidate has a CSS property: {page-break-before: always}, we
add a large positive score to the score.

  Pseudo code should be like that:

   Vector<Candidate> pageBreakCandidates;

   for (i = 0; i < pageBreakCandidates.size(); ++i) {
     pageBreakCandidates[i].score = initail value.
     for (j = 0; j < i; ++j) {
        score = pageBreakCandidates[j].score + calScore(i, j);
        if (score > pageBreakCandidates[i].score) {
           pageBreakCandidates[i].score = score;
           pageBreakCandidates[i].previsou = j;
        }
     }
  }

3 - Pick up set of candidates which maximizes the final score of last page
break.


Pros:
- Not only supporting 'page-break-xx: avoid', but also it would be easy to
support other CSS property related to page break, such as orphan, widow (See
https://bugs.webkit.org/show_bug.cgi?id=9410).  All we have to do is to add new
scoring rule in calScore.

Cons:
- Speed. This approach takes O(n^2) (n = number of allowable pagebreaks) in
computing score of each candidate in theory. It matters only when printing
time. This does not affect normail rendering phase. We need some measurement to
know whether it really matters or not.
- Compatibility. We break compatibility because we try to place page breaks
only at *allowed* position. Current WebCore does not try to do that. It seems
that only Opera try to do that. Needs more investigation.

I'll post a patch in a few weeks. Maybe I have to touch also multi column
layout code because it depends on page break code.
Please let me know if you have any comments or ideas. Thank you.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list