Commit 842ea8f4 authored by Robert Hogan's avatar Robert Hogan Committed by Commit Bot

Implement relative positioning on table elements

Bug: 417223
Change-Id: I4decce9019f69a35b1c5fefcdbb19d14e480ec36
Reviewed-on: https://chromium-review.googlesource.com/755714Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Commit-Queue: Robert Hogan <robhogan@gmail.com>
Cr-Commit-Position: refs/heads/master@{#516250}
parent a2a5b471
<!DOCTYPE html>
<title>Reference for position:relative top constraint should behave correctly for table part elements</title>
<style>
table {
border-collapse:collapse;
}
td {
padding: 0;
}
td > div {
height: 50px;
width: 50px;
}
.group {
display: inline-block;
position: relative;
width: 150px;
height: 200px;
}
.indicator {
position: absolute;
background-color: green;
left: 100px;
height: 50px;
width: 50px;
}
</style>
<div class="group">
<div>
<div class="indicator"></div>
</div>
</div>
<div>You should see a green box above. No red should be visible.</div>
<!DOCTYPE html>
<title>position:relative top constraint should behave correctly for &lt;tr&gt; elements</title>
<link rel="match" href="position-relative-table-left-ref.html" />
<link rel="help" href="https://www.w3.org/TR/css-position-3/#rel-pos" />
<meta name="assert" content="This test checks that the position:relative top constraint behaves correctly for &lt;tbody&gt; elements" />
<style>
table {
border-collapse:collapse;
}
td {
padding: 0;
}
td > div {
height: 50px;
width: 50px;
}
.group {
display: inline-block;
position: relative;
width: 150px;
height: 200px;
}
.indicator {
position: absolute;
background-color: red;
left: 100px;
height: 50px;
width: 50px;
}
.relative {
position: relative;
left: 50px;
background-color: green;
}
.absolute {
position: absolute;
left: 50px;
background-color: green;
}
</style>
<div class="group">
<div>
<div class="indicator"></div>
<table>
<tbody class="relative">
<tr><td><div class="absolute"></div></td></tr>
</tbody>
</table>
</div>
</div>
<div>You should see a green box above. No red should be visible.</div>
<!DOCTYPE html>
<title>position:relative top constraint should behave correctly for &lt;tbody&gt; elements</title>
<link rel="match" href="position-relative-table-left-ref.html" />
<link rel="help" href="https://www.w3.org/TR/css-position-3/#rel-pos" />
<meta name="assert" content="This test checks that the position:relative top constraint behaves correctly for &lt;tbody&gt; elements" />
<style>
table {
border-collapse:collapse;
}
td {
padding: 0;
}
td > div {
height: 50px;
width: 50px;
}
.group {
display: inline-block;
position: relative;
width: 150px;
height: 200px;
}
.indicator {
position: absolute;
background-color: red;
left: 100px;
height: 50px;
width: 50px;
}
.relative {
position: relative;
left: 100px;
background-color: green;
}
</style>
<div class="group">
<div>
<div class="indicator"></div>
<table>
<tbody class="relative">
<tr><td><div></div></td></tr>
</tbody>
</table>
</div>
</div>
<div>You should see a green box above. No red should be visible.</div>
<!DOCTYPE html>
<title>position:relative top constraint should behave correctly for &lt;tbody&gt; elements</title>
<link rel="match" href="position-relative-table-top-ref.html" />
<link rel="help" href="https://www.w3.org/TR/css-position-3/#rel-pos" />
<meta name="assert" content="This test checks that the position:relative top constraint behaves correctly for &lt;tbody&gt; elements" />
<style>
table {
border-collapse:collapse;
}
td {
padding: 0;
}
td > div {
height: 50px;
width: 50px;
}
.group {
display: inline-block;
position: relative;
width: 150px;
height: 200px;
}
.indicator {
position: absolute;
background-color: red;
left: 0;
top: 100px;
height: 50px;
width: 50px;
}
.relative {
position: relative;
top: 50px;
background-color: green;
}
.absolute {
position: absolute;
top: 50px;
background-color: green;
}
</style>
<div class="group">
<div>
<div class="indicator"></div>
<table>
<tbody class="relative">
<tr><td><div class="absolute"></div></td></tr>
</tbody>
</table>
</div>
</div>
<div>You should see a green box above. No red should be visible.</div>
<!DOCTYPE html>
<title>position:relative top constraint should behave correctly for &lt;tbody&gt; elements</title>
<link rel="match" href="position-relative-table-top-ref.html" />
<link rel="help" href="https://www.w3.org/TR/css-position-3/#rel-pos" />
<meta name="assert" content="This test checks that the position:relative top constraint behaves correctly for &lt;tbody&gt; elements" />
<style>
table {
border-collapse:collapse;
}
td {
padding: 0;
}
td > div {
height: 50px;
width: 50px;
}
.group {
display: inline-block;
position: relative;
width: 150px;
height: 200px;
}
.indicator {
position: absolute;
background-color: red;
left: 0;
top: 100px;
height: 50px;
width: 50px;
}
.relative {
position: relative;
top: 100px;
background-color: green;
}
</style>
<div class="group">
<div>
<div class="indicator"></div>
<table>
<tbody class="relative">
<tr><td><div></div></td></tr>
</tbody>
</table>
</div>
</div>
<div>You should see a green box above. No red should be visible.</div>
<!DOCTYPE html>
<title>position:relative top constraint should behave correctly for &lt;td&gt; elements</title>
<link rel="match" href="position-relative-table-left-ref.html" />
<link rel="help" href="https://www.w3.org/TR/css-position-3/#rel-pos" />
<meta name="assert" content="This test checks that the position:relative top constraint behaves correctly for &lt;td&gt; elements" />
<style>
table {
border-collapse:collapse;
}
td {
padding: 0;
}
td > div {
height: 50px;
width: 50px;
}
.group {
display: inline-block;
position: relative;
width: 150px;
height: 200px;
}
.indicator {
position: absolute;
background-color: red;
left: 100px;
height: 50px;
width: 50px;
}
.relative {
position: relative;
left: 100px;
background-color: green;
}
</style>
<div class="group">
<div>
<div class="indicator"></div>
<table>
<tbody>
<tr><td class="relative"><div></div></td></tr>
<tr><td><div></div></td></tr>
<tr><td><div></div></td></tr>
<tr><td><div></div></td></tr>
</tbody>
</table>
</div>
</div>
<div>You should see a green box above. No red should be visible.</div>
<!DOCTYPE html>
<title>position:relative top constraint should behave correctly for &lt;td&gt; elements</title>
<link rel="match" href="position-relative-table-top-ref.html" />
<link rel="help" href="https://www.w3.org/TR/css-position-3/#rel-pos" />
<meta name="assert" content="This test checks that the position:relative top constraint behaves correctly for &lt;td&gt; elements" />
<style>
table {
border-collapse:collapse;
}
td {
padding: 0;
}
td > div {
height: 50px;
width: 50px;
}
.group {
display: inline-block;
position: relative;
width: 150px;
height: 200px;
}
.indicator {
position: absolute;
background-color: red;
left: 0;
top: 100px;
height: 50px;
width: 50px;
}
.relative {
position: relative;
top: 100px;
background-color: green;
}
</style>
<div class="group">
<div>
<div class="indicator"></div>
<table>
<tbody>
<tr><td class="relative"><div></div></td></tr>
<tr><td><div></div></td></tr>
<tr><td><div></div></td></tr>
<tr><td><div></div></td></tr>
</tbody>
</table>
</div>
</div>
<div>You should see a green box above. No red should be visible.</div>
<!DOCTYPE html>
<title>position:relative top constraint should behave correctly for &lt;tfoot&gt; elements</title>
<link rel="match" href="position-relative-table-left-ref.html" />
<link rel="help" href="https://www.w3.org/TR/css-position-3/#rel-pos" />
<meta name="assert" content="This test checks that the position:relative top constraint behaves correctly for &lt;tfoot&gt; elements" />
<style>
table {
border-collapse:collapse;
}
td {
padding: 0;
}
td > div {
height: 50px;
width: 50px;
}
.group {
display: inline-block;
position: relative;
width: 150px;
height: 200px;
}
.indicator {
position: absolute;
background-color: red;
left: 100px;
height: 50px;
width: 50px;
}
.relative {
position: relative;
left: 50px;
background-color: green;
}
.absolute {
position: absolute;
left: 50px;
background-color: green;
}
</style>
<div class="group">
<div>
<div class="indicator"></div>
<table>
<tfoot class="relative">
<tr><td><div class="absolute"></div></td></tr>
</tfoot>
</table>
</div>
</div>
<div>You should see a green box above. No red should be visible.</div>
<!DOCTYPE html>
<title>position:relative top constraint should behave correctly for &lt;tfoot&gt; elements</title>
<link rel="match" href="position-relative-table-left-ref.html" />
<link rel="help" href="https://www.w3.org/TR/css-position-3/#rel-pos" />
<meta name="assert" content="This test checks that the position:relative top constraint behaves correctly for &lt;tfoot&gt; elements" />
<style>
table {
border-collapse:collapse;
}
td {
padding: 0;
}
td > div {
height: 50px;
width: 50px;
}
.group {
display: inline-block;
position: relative;
width: 150px;
height: 200px;
}
.indicator {
position: absolute;
background-color: red;
left: 100px;
height: 50px;
width: 50px;
}
.relative {
position: relative;
left: 100px;
background-color: green;
}
</style>
<div class="group">
<div>
<div class="indicator"></div>
<table>
<tfoot class="relative">
<tr><td><div></div></td></tr>
</tfoot>
</table>
</div>
</div>
<div>You should see a green box above. No red should be visible.</div>
<!DOCTYPE html>
<title>position:relative top constraint should behave correctly for &lt;tfoot&gt; elements</title>
<link rel="match" href="position-relative-table-tfoot-top-ref.html" />
<link rel="help" href="https://www.w3.org/TR/css-position-3/#rel-pos" />
<meta name="assert" content="This test checks that the position:relative top constraint behaves correctly for &lt;tfoot&gt; elements" />
<style>
table {
border-collapse:collapse;
}
td {
padding: 0;
}
td > div {
height: 50px;
width: 50px;
}
.group {
display: inline-block;
position: relative;
width: 150px;
height: 200px;
}
.indicator {
position: absolute;
background-color: red;
left: 0;
top: 150px;
height: 50px;
width: 50px;
}
.relative {
position: relative;
top: 50px;
background-color: green;
}
.absolute {
position: absolute;
top: 50px;
background-color: green;
}
</style>
<div class="group">
<div>
<div class="indicator"></div>
<table>
<tbody>
<tr><td><div></div></td></tr>
</tbody>
<tfoot class="relative">
<tr><td><div class="absolute"></div></td></tr>
</tfoot>
</table>
</div>
</div>
<div>You should see a green box above. No red should be visible.</div>
<!DOCTYPE html>
<style>
table {
border-collapse:collapse;
}
td {
padding: 0;
}
td > div {
height: 50px;
width: 50px;
}
.group {
display: inline-block;
position: relative;
width: 150px;
height: 200px;
}
.indicator {
position: absolute;
background-color: green;
left: 0;
top: 150px;
height: 50px;
width: 50px;
}
</style>
<div class="group">
<div>
<div class="indicator"></div>
</div>
</div>
<div>You should see a green box above. No red should be visible.</div>
<!DOCTYPE html>
<title>position:relative top constraint should behave correctly for &lt;tfoot&gt; elements</title>
<link rel="match" href="position-relative-table-tfoot-top-ref.html" />
<link rel="help" href="https://www.w3.org/TR/css-position-3/#rel-pos" />
<meta name="assert" content="This test checks that the position:relative top constraint behaves correctly for &lt;tfoot&gt; elements" />
<style>
table {
border-collapse:collapse;
}
td {
padding: 0;
}
td > div {
height: 50px;
width: 50px;
}
.group {
display: inline-block;
position: relative;
width: 150px;
height: 200px;
}
.indicator {
position: absolute;
background-color: red;
left: 0;
top: 150px;
height: 50px;
width: 50px;
}
.relative {
position: relative;
top: 100px;
background-color: green;
}
</style>
<div class="group">
<div>
<div class="indicator"></div>
<table>
<tbody>
<tr><td><div></div></td></tr>
</tbody>
<tfoot class="relative">
<tr><td><div></div></td></tr>
</tfoot>
</table>
</div>
</div>
<div>You should see a green box above. No red should be visible.</div>
<!DOCTYPE html>
<title>position:relative top constraint should behave correctly for &lt;thead&gt; elements</title>
<link rel="match" href="position-relative-table-left-ref.html" />
<link rel="help" href="https://www.w3.org/TR/css-position-3/#rel-pos" />
<meta name="assert" content="This test checks that the position:relative top constraint behaves correctly for &lt;thead&gt; elements" />
<style>
table {
border-collapse:collapse;
}
td {
padding: 0;
}
td > div {
height: 50px;
width: 50px;
}
.group {
display: inline-block;
position: relative;
width: 150px;
height: 200px;
}
.indicator {
position: absolute;
background-color: red;
left: 100px;
height: 50px;
width: 50px;
}
.relative {
position: relative;
left: 50px;
background-color: green;
}
.absolute {
position: absolute;
left: 50px;
background-color: green;
}
</style>
<div class="group">
<div>
<div class="indicator"></div>
<table>
<thead class="relative">
<tr><td><div class="absolute"></div></td></tr>
</thead>
</table>
</div>
</div>
<div>You should see a green box above. No red should be visible.</div>
<!DOCTYPE html>
<title>position:relative top constraint should behave correctly for &lt;thead&gt; elements</title>
<link rel="match" href="position-relative-table-left-ref.html" />
<link rel="help" href="https://www.w3.org/TR/css-position-3/#rel-pos" />
<meta name="assert" content="This test checks that the position:relative top constraint behaves correctly for &lt;thead&gt; elements" />
<style>
table {
border-collapse:collapse;
}
td {
padding: 0;
}
td > div {
height: 50px;
width: 50px;
}
.group {
display: inline-block;
position: relative;
width: 150px;
height: 200px;
}
.indicator {
position: absolute;
background-color: red;
left: 100px;
height: 50px;
width: 50px;
}
.relative {
position: relative;
left: 100px;
background-color: green;
}
</style>
<div class="group">
<div>
<div class="indicator"></div>
<table>
<thead class="relative">
<tr><td><div></div></td></tr>
</thead>
</table>
</div>
</div>
<div>You should see a green box above. No red should be visible.</div>
<!DOCTYPE html>
<title>position:relative top constraint should behave correctly for &lt;thead&gt; elements</title>
<link rel="match" href="position-relative-table-top-ref.html" />
<link rel="help" href="https://www.w3.org/TR/css-position-3/#rel-pos" />
<meta name="assert" content="This test checks that the position:relative top constraint behaves correctly for &lt;thead&gt; elements" />
<style>
table {
border-collapse:collapse;
}
td {
padding: 0;
}
td > div {
height: 50px;
width: 50px;
}
.group {
display: inline-block;
position: relative;
width: 150px;
height: 200px;
}
.indicator {
position: absolute;
background-color: red;
left: 0;
top: 100px;
height: 50px;
width: 50px;
}
.relative {
position: relative;
top: 50px;
background-color: green;
}
.absolute {
position: absolute;
top: 50px;
background-color: green;
}
</style>
<div class="group">
<div>
<div class="indicator"></div>
<table>
<thead class="relative">
<tr><td><div class="absolute"></div></td></tr>
</thead>
<tbody>
<tr><td><div></div></td></tr>
</tbody>
</table>
</div>
</div>
<div>You should see a green box above. No red should be visible.</div>
<!DOCTYPE html>
<title>position:relative top constraint should behave correctly for &lt;thead&gt; elements</title>
<link rel="match" href="position-relative-table-top-ref.html" />
<link rel="help" href="https://www.w3.org/TR/css-position-3/#rel-pos" />
<meta name="assert" content="This test checks that the position:relative top constraint behaves correctly for &lt;thead&gt; elements" />
<style>
table {
border-collapse:collapse;
}
td {
padding: 0;
}
td > div {
height: 50px;
width: 50px;
}
.group {
display: inline-block;
position: relative;
width: 150px;
height: 200px;
}
.indicator {
position: absolute;
background-color: red;
left: 0;
top: 100px;
height: 50px;
width: 50px;
}
.relative {
position: relative;
top: 100px;
background-color: green;
}
</style>
<div class="group">
<div>
<div class="indicator"></div>
<table>
<thead class="relative">
<tr><td><div></div></td></tr>
</thead>
<tbody>
<tr><td><div></div></td></tr>
</tbody>
</table>
</div>
</div>
<div>You should see a green box above. No red should be visible.</div>
<!DOCTYPE html>
<title>Reference for position:relative top constraint should behave correctly for table part elements</title>
<style>
table {
border-collapse:collapse;
}
td {
padding: 0;
}
td > div {
height: 50px;
width: 50px;
}
.group {
display: inline-block;
position: relative;
width: 150px;
height: 200px;
}
.indicator {
position: absolute;
background-color: green;
left: 0;
top: 100px;
height: 50px;
width: 50px;
}
</style>
<div class="group">
<div>
<div class="indicator"></div>
</div>
</div>
<div>You should see a green box above. No red should be visible.</div>
<!DOCTYPE html>
<title>position:relative top constraint should behave correctly for &lt;tr&gt; elements</title>
<link rel="match" href="position-relative-table-left-ref.html" />
<link rel="help" href="https://www.w3.org/TR/css-position-3/#rel-pos" />
<meta name="assert" content="This test checks that the position:relative top constraint behaves correctly for &lt;tr&gt; elements" />
<style>
table {
border-collapse:collapse;
}
td {
padding: 0;
}
td > div {
height: 50px;
width: 50px;
}
.group {
display: inline-block;
position: relative;
width: 150px;
height: 200px;
}
.indicator {
position: absolute;
background-color: red;
left: 100px;
height: 50px;
width: 50px;
}
.relative {
position: relative;
left: 50px;
background-color: green;
}
.absolute {
position: absolute;
left: 50px;
background-color: green;
}
</style>
<div class="group">
<div>
<div class="indicator"></div>
<table>
<tbody>
<tr class="relative"><td><div class="absolute"></div></td></tr>
<tr><td><div></div></td></tr>
<tr><td><div></div></td></tr>
<tr><td><div></div></td></tr>
</tbody>
</table>
</div>
</div>
<div>You should see a green box above. No red should be visible.</div>
<!DOCTYPE html>
<title>position:relative top constraint should behave correctly for &lt;tr&gt; elements</title>
<link rel="match" href="position-relative-table-left-ref.html" />
<link rel="help" href="https://www.w3.org/TR/css-position-3/#rel-pos" />
<meta name="assert" content="This test checks that the position:relative top constraint behaves correctly for &lt;tr&gt; elements" />
<style>
table {
border-collapse:collapse;
}
td {
padding: 0;
}
td > div {
height: 50px;
width: 50px;
}
.group {
display: inline-block;
position: relative;
width: 150px;
height: 200px;
}
.indicator {
position: absolute;
background-color: red;
left: 100px;
height: 50px;
width: 50px;
}
.relative {
position: relative;
left: 100px;
background-color: green;
}
</style>
<div class="group">
<div>
<div class="indicator"></div>
<table>
<tbody>
<tr class="relative"><td><div></div></td></tr>
<tr><td><div></div></td></tr>
<tr><td><div></div></td></tr>
<tr><td><div></div></td></tr>
</tbody>
</table>
</div>
</div>
<div>You should see a green box above. No red should be visible.</div>
<!DOCTYPE html>
<title>position:relative top constraint should behave correctly for &lt;tr&gt; elements</title>
<link rel="match" href="position-relative-table-top-ref.html" />
<link rel="help" href="https://www.w3.org/TR/css-position-3/#rel-pos" />
<meta name="assert" content="This test checks that the position:relative top constraint behaves correctly for &lt;tr&gt; elements" />
<style>
table {
border-collapse:collapse;
}
td {
padding: 0;
}
td > div {
height: 50px;
width: 50px;
}
.group {
display: inline-block;
position: relative;
width: 150px;
height: 200px;
}
.indicator {
position: absolute;
background-color: red;
left: 0;
top: 100px;
height: 50px;
width: 50px;
}
.relative {
position: relative;
top: 50px;
}
.absolute {
position: absolute;
top: 50px;
background-color: green;
}
</style>
<div class="group">
<div>
<div class="indicator"></div>
<table>
<tbody>
<tr class="relative"><td><div class="absolute"></div></td></tr>
<tr><td><div></div></td></tr>
<tr><td><div></div></td></tr>
<tr><td><div></div></td></tr>
</tbody>
</table>
</div>
</div>
<div>You should see a green box above. No red should be visible.</div>
<!DOCTYPE html>
<title>position:relative top constraint should behave correctly for &lt;tr&gt; elements</title>
<link rel="match" href="position-relative-table-top-ref.html" />
<link rel="help" href="https://www.w3.org/TR/css-position-3/#rel-pos" />
<meta name="assert" content="This test checks that the position:relative top constraint behaves correctly for &lt;tr&gt; elements" />
<style>
table {
border-collapse:collapse;
}
td {
padding: 0;
}
td > div {
height: 50px;
width: 50px;
}
.group {
display: inline-block;
position: relative;
width: 150px;
height: 200px;
}
.indicator {
position: absolute;
background-color: red;
left: 0;
top: 100px;
height: 50px;
width: 50px;
}
.relative {
position: relative;
top: 100px;
background-color: green;
}
</style>
<div class="group">
<div>
<div class="indicator"></div>
<table>
<tbody>
<tr class="relative"><td><div></div></td></tr>
<tr><td><div></div></td></tr>
<tr><td><div></div></td></tr>
<tr><td><div></div></td></tr>
</tbody>
</table>
</div>
</div>
<div>You should see a green box above. No red should be visible.</div>
......@@ -328,7 +328,7 @@ static void AdjustStyleForDisplay(ComputedStyle& style,
style.GetWritingMode() != layout_parent_style.GetWritingMode())
style.SetDisplay(EDisplay::kInlineBlock);
// We do not honor position: relative or sticky for table rows, headers, and
// We do not honor position: sticky for table rows, headers, and
// footers. This is correct for position: relative in CSS2.1 (and caused a
// crash in containingBlock() on some sites) and position: sticky is defined
// as following position: relative behavior for table elements. It is
......@@ -337,7 +337,7 @@ static void AdjustStyleForDisplay(ComputedStyle& style,
style.Display() == EDisplay::kTableRowGroup ||
style.Display() == EDisplay::kTableFooterGroup ||
style.Display() == EDisplay::kTableRow) &&
style.HasInFlowPosition())
style.GetPosition() == EPosition::kSticky)
style.SetPosition(EPosition::kStatic);
// Cannot support position: sticky for table columns and column groups because
......
......@@ -139,7 +139,7 @@ class CORE_EXPORT LayoutTableRow final : public LayoutTableBoxComponent {
PaintLayerType LayerTypeRequired() const override {
if (HasTransformRelatedProperty() || HasHiddenBackface() || HasClipPath() ||
CreatesGroup() || Style()->ShouldCompositeForCurrentAnimations() ||
IsStickyPositioned())
IsInFlowPositioned())
return kNormalPaintLayer;
if (HasOverflowClip())
......
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