haikuwebkit/LayoutTests/fast/layoutformattingcontext/table-space-shinking-mixed-...

36 lines
1.2 KiB
HTML
Raw Permalink Normal View History

[LFC][TFC] Add support for shrinking over-constrained columns based on the width type priority list https://bugs.webkit.org/show_bug.cgi?id=227426 Reviewed by Antti Koivisto. Source/WebCore: Let's take the priority list into use when shrinking the columns in an over-constrained context. e.g. <div style="width: 100px"> <table><tr><td style="width: 90%""></td><td style="width: 400px;"></td><td style="width: 100px;"></td></tr></table> </div> While the second and the third columns have the preferred width of 400px and 100px respectively, we can't accommodate them as the containing block (<div>) sets a 100px horizontal constraint on the table content and the first column already takes up 90px space. Now we start shrinking the columns using the following priority list: auto < relative < fixed < percent (ignoring the actual column order). The preferred width of the table (assume 0px border spacing and padding) is 90px + 400px + 100px. It produces a -490px available space. This negative space needs to be distributed among the columns staring with the fixed sized ones. The fixed sized columns have a flex space of 500px which covers the -490px gap. Based on their 4:1 distribution ratio, they'll end up with 8px and 2px and the percent column stays at 90px. Tests: fast/layoutformattingcontext/table-space-shinking-mixed-width-type-simple.html fast/layoutformattingcontext/table-space-shinking-mixed-width-type-simple2.html * layout/formattingContexts/table/TableLayout.cpp: (WebCore::Layout::distributeAvailableSpace): (WebCore::Layout::TableFormattingContext::TableLayout::distributedHorizontalSpace): (WebCore::Layout::TableFormattingContext::TableLayout::distributedVerticalSpace): LayoutTests: * fast/layoutformattingcontext/table-space-shinking-mixed-width-type-simple-expected.html: Added. * fast/layoutformattingcontext/table-space-shinking-mixed-width-type-simple.html: Added. * fast/layoutformattingcontext/table-space-shinking-mixed-width-type-simple2-expected.html: Added. * fast/layoutformattingcontext/table-space-shinking-mixed-width-type-simple2.html: Added. Canonical link: https://commits.webkit.org/239194@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279318 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-27 19:16:51 +00:00
<!DOCTYPE html> <!-- webkit-test-runner [ LayoutFormattingContextEnabled=true LayoutFormattingContextIntegrationEnabled=false ] -->
<style>
body {
font-size: 16px;
overflow: hidden;
}
table {
border-spacing: 0px;
}
td {
height: 20px;
padding: 0px;
background-color: blue;
white-space: pre-wrap;
}
td:nth-child(odd) {
background-color: green;
}
div {
height: 20px;
}
</style>
<div style="width: 200px; height: auto;">
<table><tr><td style="width: 300px;"></td><td style="width: 400px;"></td><td style="width: 30%;"></td></tr></table>
<table><tr><td style="width: 400px;"></td><td style="width: 500px;"></td><td style="width: 40%;"></td></tr></table>
<table><tr><td style="width: 500px;"></td><td style="width: 600px;"></td><td style="width: 50%;"></td></tr></table>
<table><tr><td style="width: 600px;"></td><td style="width: 500px;"></td><td style="width: 60%;"></td></tr></table>
<table><tr><td style="width: 700px;"></td><td style="width: 400px;"></td><td style="width: 70%;"></td></tr></table>
<table><tr><td style="width: 800px;"></td><td style="width: 300px;"></td><td style="width: 80%;"></td></tr></table>
<table><tr><td style="width: 900px;"></td><td style="width: 200px;"></td><td style="width: 90%;"></td></tr></table>
</div>