Commit 160ba786 authored by eric@webkit.org's avatar eric@webkit.org

2010-02-17 Hayato Ito <hayato@chromium.org>

        Reviewed by Eric Seidel.

        Support CSS page-break-inside with a value of 'avoid'.

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

        * printing/page-break-inside-expected.txt: Added.
        * printing/page-break-inside.html: Added.
        * printing/script-tests/page-break-inside.js: Added.
        (createParagraph):
        (pageNumber):
2010-02-17  Hayato Ito  <hayato@chromium.org>

        Reviewed by Eric Seidel.

        Support CSS page-break-inside with a value of 'avoid'.

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

        Test: printing/page-break-inside.html

        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::paintChildren):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54929 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b96f638b
2010-02-17 Hayato Ito <hayato@chromium.org>
Reviewed by Eric Seidel.
Support CSS page-break-inside with a value of 'avoid'.
https://bugs.webkit.org/show_bug.cgi?id=34080
* printing/page-break-inside-expected.txt: Added.
* printing/page-break-inside.html: Added.
* printing/script-tests/page-break-inside.js: Added.
(createParagraph):
(pageNumber):
2010-02-17 Fumitoshi Ukai <ukai@chromium.org>
Reviewed by Alexey Proskuryakov.
......
Test for page-break-inside:avoid
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS pageNumber('page1') is 1
PASS pageNumber('page2') is 2
PASS pageNumber('page3-1') is 3
PASS pageNumber('page3-2') is 3
PASS pageNumber('page4') is 4
PASS pageNumber('page5') is 5
PASS pageNumber('page6') is 6
PASS pageNumber('page7') is 7
PASS pageNumber('page9') is 9
PASS pageNumber('page10-1') is 10
PASS pageNumber('page10-2') is 10
PASS pageNumber('page11') is 11
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
<script src="../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<div id="sandbox"></div>
<script src="script-tests/page-break-inside.js"></script>
<script src="../fast/js/resources/js-test-post.js"></script>
</body>
</html>
description("Test for page-break-inside:avoid");
function createParagraph(id, height)
{
var element = document.createElement("div");
element.id = id;
element.style.height = height;
element.appendChild(document.createTextNode("foobar"));
document.getElementById("sandbox").appendChild(element);
return element;
}
var pageHeightInPixels = 1000;
function pageNumber(id) {
return layoutTestController.pageNumberForElementById(id, 1000, pageHeightInPixels);
}
createParagraph("page1", 900).style.pageBreakBefore = "always";
createParagraph("page2", 900).style.pageBreakInside = "avoid";
createParagraph("page3-1", 900).style.pageBreakBefore = "always";
createParagraph("page3-2", 100).style.pageBreakInside = "avoid";
createParagraph("page4", 900).style.pageBreakBefore = "always";
createParagraph("page5", 101).style.pageBreakInside = "avoid";
createParagraph("page6", 100).style.pageBreakBefore = "always";
createParagraph("page7", 2100).style.pageBreakInside = "avoid";
createParagraph("page9", 100);
createParagraph("page10-1", 100).style.pageBreakBefore = "always";
createParagraph("page10-2", 100).style.pageBreakAfter = "always";
// Make sure page-break only happens once, not twice.
createParagraph("page11", 900).style.pageBreakInside = "avoid";
// Before calling "shouldBe" tests, sets "display: none" style to |console| element so that the results of pageNumber should not be affected.
// FIXME: Use functions defined in printing/resources/paged-media-test-utils.js instead of this hack.
document.getElementById("console").style.display = 'none';
shouldBe("pageNumber('page1')", "1");
shouldBe("pageNumber('page2')", "2");
shouldBe("pageNumber('page3-1')", "3");
shouldBe("pageNumber('page3-2')", "3");
shouldBe("pageNumber('page4')", "4");
shouldBe("pageNumber('page5')", "5");
shouldBe("pageNumber('page6')", "6");
shouldBe("pageNumber('page7')", "7");
shouldBe("pageNumber('page9')", "9");
shouldBe("pageNumber('page10-1')", "10");
shouldBe("pageNumber('page10-2')", "10");
shouldBe("pageNumber('page11')", "11");
document.getElementById("console").style.display = 'block';
document.body.removeChild(document.getElementById("sandbox"));
var successfullyParsed = true;
2010-02-17 Hayato Ito <hayato@chromium.org>
Reviewed by Eric Seidel.
Support CSS page-break-inside with a value of 'avoid'.
https://bugs.webkit.org/show_bug.cgi?id=34080
Test: printing/page-break-inside.html
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::paintChildren):
2010-02-17 Fumitoshi Ukai <ukai@chromium.org>
Reviewed by Alexey Proskuryakov.
......
......@@ -1664,6 +1664,16 @@ void RenderBlock::paintChildren(PaintInfo& paintInfo, int tx, int ty)
return;
}
// Check for page-break-inside: avoid, and it it's set, break and bail.
if (isPrinting && !childrenInline() && child->style()->pageBreakInside() == PBAVOID
&& inRootBlockContext()
&& ty + child->y() > paintInfo.rect.y()
&& ty + child->y() < paintInfo.rect.bottom()
&& ty + child->y() + child->height() > paintInfo.rect.bottom()) {
view()->setBestTruncatedAt(ty + child->y(), this, true);
return;
}
if (!child->hasSelfPaintingLayer() && !child->isFloating())
child->paint(info, tx, ty);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment