ASSIGNED Bug 34155
Support CSS page-break-{before/after} with a value of 'avoid'.
https://bugs.webkit.org/show_bug.cgi?id=34155
Summary Support CSS page-break-{before/after} with a value of 'avoid'.
Hayato Ito
Reported 2010-01-25 21:26:02 PST
Implement CSS page-break-{before/after} with a value of 'avoid', which is defined in http://www.w3.org/TR/CSS2/page.html#page-break-props Currently, only a value of 'always' is supported in both bases.
Attachments
Hayato Ito
Comment 1 2010-05-06 04:32:25 PDT
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.
David Latapie
Comment 2 2010-05-09 16:48:24 PDT
Ben Wells
Comment 3 2011-06-15 21:15:09 PDT
Updated status when triaging bugs, if this is no longer valid or is a dup either mark or let me know and I'll update.
Bob Lan
Comment 4 2016-02-22 16:54:05 PST
Note You need to log in before you can comment on or make changes to this bug.