<!DOCTYPE html>
<html>
<link href="resources/grid.css" rel="stylesheet">
<link href="resources/grid-alignment.css" rel="stylesheet">
<link href="../css-intrinsic-dimensions/resources/width-keyword-classes.css" rel=stylesheet>
<style>
.minWidthGrid {
    min-width: 100px;
    grid-template-columns: 50px;
    grid-template-rows: 40px;
}
.maxWidthGrid {
    max-width: 100px;
    grid-template-columns: 150px 50px;
    grid-template-rows: 40px;
}

.minWidthAutoGrid {
    min-width: 100px;
}

.maxWidthAutoGrid {
    max-width: 100px;
}
</style>
<script src="../../resources/check-layout.js"></script>
<body onload="checkLayout('.grid')">

<p>Test that min-width and max-width are accounted for when computing the grid element's preferred widths.</p>

<div class="constrainedContainer">
    <div class="grid minWidthGrid" data-expected-height="40" data-expected-width="100"></div>
    <div class="grid minWidthAutoGrid justifyContentStart justfyContentStart" data-expected-height="10" data-expected-width="100">
        <div class="sizedToGridArea firstRowFirstColumn" data-expected-height="10" data-expected-width="70">XXX XXX</div>
    </div>
    <!-- These 2 grids are sized after their containing block as width is 'auto'. We end up having the content overflow which is weird but the grid shouldn't shrink to fit by default. -->
    <div class="grid maxWidthGrid" data-expected-height="40" data-expected-width="10"></div>
    <div class="grid maxWidthAutoGrid" data-expected-height="10" data-expected-width="10">
        <div class="sizedToGridArea firstRowFirstColumn" data-expected-height="10" data-expected-width="110">XXXXXXXXXXX</div>
    </div>

    <div class="grid fit-content minWidthGrid" data-expected-height="40" data-expected-width="100"></div>
    <div class="grid fit-content maxWidthGrid" data-expected-height="40" data-expected-width="100"></div>

    <div class="grid max-content minWidthAutoGrid" data-expected-height="10" data-expected-width="110">
        <div class="sizedToGridArea firstRowFirstColumn" data-expected-height="10" data-expected-width="110">XXX XXX XXX</div>
    </div>
    <div class="grid min-content minWidthAutoGrid" data-expected-height="20" data-expected-width="100">
        <div class="sizedToGridArea firstRowFirstColumn" data-expected-height="20" data-expected-width="100">XXX XXX XXX</div>
    </div>

    <div class="grid max-content maxWidthAutoGrid" data-expected-height="20" data-expected-width="100">
        <div class="sizedToGridArea firstRowFirstColumn" data-expected-height="20" data-expected-width="100">XXXXX XXXXXX</div>
    </div>
    <div class="grid min-content maxWidthAutoGrid" data-expected-height="20" data-expected-width="60">
        <div class="sizedToGridArea firstRowFirstColumn" data-expected-height="20" data-expected-width="60">XXXXX XXXXXX</div>
    </div>
</div>

<div class="unconstrainedContainer">
    <div class="grid minWidthGrid" data-expected-height="40" data-expected-width="1000"></div>
    <div class="grid minWidthAutoGrid justifyContentStart" data-expected-height="10" data-expected-width="1000">
        <div class="sizedToGridArea firstRowFirstColumn" data-expected-height="10" data-expected-width="70">XXX XXX</div>
    </div>
    <div class="grid maxWidthGrid" data-expected-height="40" data-expected-width="100"></div>
    <div class="grid maxWidthAutoGrid" data-expected-height="20" data-expected-width="100">
        <div class="sizedToGridArea firstRowFirstColumn" data-expected-height="20" data-expected-width="100">XXXXX XXXXXX</div>
    </div>
    <div class="grid fit-content minWidthGrid" data-expected-height="40" data-expected-width="100"></div>
    <div class="grid fit-content maxWidthGrid" data-expected-height="40" data-expected-width="100"></div>

    <div class="grid max-content minWidthAutoGrid" data-expected-height="10" data-expected-width="110">
        <div class="sizedToGridArea firstRowFirstColumn" data-expected-height="10" data-expected-width="110">XXX XXX XXX</div>
    </div>
    <div class="grid min-content minWidthAutoGrid" data-expected-height="20" data-expected-width="100">
        <div class="sizedToGridArea firstRowFirstColumn" data-expected-height="20" data-expected-width="100">XXX XXX XXX</div>
    </div>

    <div class="grid max-content maxWidthAutoGrid" data-expected-height="20" data-expected-width="100">
        <div class="sizedToGridArea firstRowFirstColumn" data-expected-height="20" data-expected-width="100">XXXXX XXXXXX</div>
    </div>
    <div class="grid min-content maxWidthAutoGrid" data-expected-height="20" data-expected-width="60">
        <div class="sizedToGridArea firstRowFirstColumn" data-expected-height="20" data-expected-width="60">XXXXX XXXXXX</div>
    </div>
</div>

</body>
</html>
