<!DOCTYPE html>
<html>
<head>
<title>Testing Widows and Orphans</title>
<script src="../../resources/js-test-pre.js"></script>
<style>
body.hide-containers .container, body.hide-containers h3 {
    display: none;
}

.region {
    height: 200px;
    -webkit-region-fragment: break;
    display: inline-block;
}

.region0 {
    width: 150px;
}

.region1 {
    width: 200px;
}

.region2 {
    width: 150px;
}

.container {
    width: 600px;
    height: 200px;
    line-height: 20px; /* 10 lines per page */
    font-size: 16px;
    margin: 0 0 20px 0;
    padding: 0;
    overflow: hidden;
}

.block {
    margin: 0 0 15px 0;
    padding: 0;
}

.top {
    color: red;
}

.bottom {
    color: green;
}
</style>
<script>

description("Testing widows and orphans. Any green lines should be at the bottom of regions, and any red lines should be at the top of regions.");

if (window.testRunner)
    testRunner.dumpAsText();

function createRegions(id, container)
{
    for (var i = 0; i < 3; ++i) {
        var element = document.createElement("div");
        element.className = "region region" + i;
        element.style.webkitFlowFrom = id;

        container.appendChild(element);
    }
}

function createTestContainer(id, description, blocks)
{
    var label = document.createElement("h3");
    label.textContent = id + " - " + description;
    document.body.appendChild(label);
    var element = document.createElement("div");
    element.className = "container";
    element.id = id;

    createRegions(id, element);

    for (var i = 1; i <= blocks.length; ++i) {
        var block = document.createElement("div");
        block.className = "block";
        var numLines = blocks[i-1];
        for (var j = 1; j <= numLines; ++j) {
            var line = document.createElement("span");
            line.id = id + "-block-" + i + "-line-" + j;
            line.textContent = "Block " + i + " Line " + j;
            block.appendChild(line);
            block.appendChild(document.createElement("br"));
        }
        block.style.webkitFlowInto = id;
        element.appendChild(block);
    }
    document.body.appendChild(element);
    return element;
}

function markTopLine(containerId, blockNumber, lineNumber)
{
    var element = document.getElementById(containerId + "-block-" + blockNumber + "-line-" + lineNumber);
    element.className = "top";
}

function markBottomLine(containerId, blockNumber, lineNumber)
{
    var element = document.getElementById(containerId + "-block-" + blockNumber + "-line-" + lineNumber);
    element.className = "bottom";
}

function testIsFirstInRegion(containerId, blockNumber, lineNumber)
{
    var topOfContainer = document.getElementById(containerId).getBoundingClientRect().top;
    var topOfLine = document.getElementById(containerId + "-block-" + blockNumber + "-line-" + lineNumber).getBoundingClientRect().top;

    if (Math.abs(topOfContainer - topOfLine) < 5) // Give 5 pixels to account for subpixel layout.
        testPassed(containerId + " Block " + blockNumber + " Line " + lineNumber + " is correct.");
    else
        testFailed(containerId + " Block " + blockNumber + " Line " + lineNumber + " wasn't at the top of the region.");
}

function runTest()
{
    var container;

    createTestContainer("test1", "Normal breaking", [5, 6, 5, 5]);

    markTopLine("test1", 1, 1);
    markBottomLine("test1", 2, 4);
    markTopLine("test1", 2, 5);
    markBottomLine("test1", 4, 1);
    markTopLine("test1", 4, 2);

    testIsFirstInRegion("test1", 1, 1);
    testIsFirstInRegion("test1", 2, 5);
    testIsFirstInRegion("test1", 4, 2);

    container = createTestContainer("test2", "Basic Orphan", [8, 6]);
    container.style.orphans = 2;

    markTopLine("test2", 1, 1);
    markBottomLine("test2", 1, 8); // Orphan break happens here.
    markTopLine("test2", 2, 1);

    testIsFirstInRegion("test2", 1, 1);
    testIsFirstInRegion("test2", 2, 1);

    container = createTestContainer("test3", "Basic Widow", [4, 6, 3]);
    container.style.widows = 2;

    markTopLine("test3", 1, 1);
    markBottomLine("test3", 2, 4); // Widow break happens here.
    markTopLine("test3", 2, 5);

    testIsFirstInRegion("test3", 1, 1);
    testIsFirstInRegion("test3", 2, 5);

    container = createTestContainer("test4", "Orphans causing Widows", [8, 6, 4, 4]);
    container.style.orphans = 2;
    container.style.widows = 2;

    markTopLine("test4", 1, 1);
    markBottomLine("test4", 1, 8); // Orphan break happens here.
    markTopLine("test4", 2, 1);
    markBottomLine("test4", 3, 2); // And that creates a widow forcing a break here.
    markTopLine("test4", 3, 3);

    testIsFirstInRegion("test4", 1, 1);
    testIsFirstInRegion("test4", 2, 1);
    testIsFirstInRegion("test4", 3, 3);

    container = createTestContainer("test5", "Widows blocked by Orphan rule", [7, 3, 4]);
    container.style.orphans = 2;
    container.style.widows = 2;

    markTopLine("test5", 1, 1);
    markBottomLine("test5", 2, 2); // This line should not move - protected by orphaning.
    markTopLine("test5", 2, 3); // This line won't be un-widowed - blocked by orphaning.

    testIsFirstInRegion("test5", 1, 1);
    testIsFirstInRegion("test5", 2, 3);

    container = createTestContainer("test6", "Ridiculous values", [7, 7, 7, 7]);
    container.style.orphans = 100;
    container.style.widows = 100;

    markTopLine("test6", 1, 1);
    markBottomLine("test6", 1, 7); // Orphan break happens here.
    markTopLine("test6", 2, 1); // Adopted.
    markBottomLine("test6", 2, 7); // Orphan break.
    markTopLine("test6", 3, 1); // Adopted.

    testIsFirstInRegion("test6", 1, 1);
    testIsFirstInRegion("test6", 2, 1);
    testIsFirstInRegion("test6", 3, 1);

    if (window.testRunner) {
        // Hide all the containers and leave just the test results for text output.
        document.body.className = "hide-containers";
    }

    isSuccessfullyParsed();
}

window.addEventListener("load", runTest, false);
</script>
</head>
<body>
</body>
</html>
