Skip to content

Commit

Permalink
Avoiding writing layout-modified ComputedStyle back to Node
Browse files Browse the repository at this point in the history
The base-computed-style-optimization expects that the cached base
style (as produced by StyleResolver) is the same style we would get
if we produced the style from scratch. However, this assumption does
not hold for certain legacy LayoutObjects, where the ComputedStyle
is modified outside of style recalc, during DidStyleChange,.

Writing that modified ComputedStyle back to the Node is also a
correctness issue: we end up with the wrong output from
getComputedStyle.

This CL changes non-TextAutoSizer calls of
SetModifiedStyleOutsideStyleRecalc (writes ComputedStyle back to
Node), to just SetStyle (does not write ComputedStyle back to Node).

In order to ensure that we don't skip a critical DidStyleChange call,
we force ApplyStyleChanges::kYes during Element::RecalcOwnStyle, if
the LayoutObject::SetStyle happens on a relevant legacy LayoutObject
under the conditions that would require a style-fixup in
DidStyleChange. Duplicating those conditions there is not ideal, but
that problem will automatically go away once the legacy code is
removed.

Fixed: 1307976
Change-Id: I8461c9d53e6e316f1bcd8a0002640b56b4cf0f87
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3620574
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/main@{#999325}
  • Loading branch information
andruud authored and chromium-wpt-export-bot committed May 4, 2022
1 parent 34cafd7 commit 19666e5
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
24 changes: 24 additions & 0 deletions css/css-tables/table-cell-writing-mode-computed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<title>Computed value of orthogonal writing-mode on table cell</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
<link rel="help" href="https://www.w3.org/TR/css-tables-3">
<link rel="help" href="https://crbug.com/1307976">
<style>
td {
writing-mode: vertical-lr;
}
</style>

<table>
<tr>
<td>Test</td>
</tr>
</table>

<script>
test(() => {
let td = document.querySelector('td');
assert_equals(getComputedStyle(td).writingMode, 'vertical-lr');
}, 'Computed value of orthogonal writing-mode on table cell');
</script>
31 changes: 31 additions & 0 deletions css/css-tables/table-position-sticky-computed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<title>Computed value of position:sticky for table elements</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
<link rel="help" href="https://www.w3.org/TR/css-tables-3">
<link rel="help" href="https://crbug.com/1307976">
<style>
table * {
position: sticky;
}
</style>

<table>
<thead>
</thead>
<tbody>
<tr>
<td>Test</td>
</tr>
</tbody>
<tfoot>
</tfoot>
</table>

<script>
for (let element of document.querySelectorAll('table *')) {
test(() => {
assert_equals(getComputedStyle(element).position, 'sticky');
}, `Computed value of position:sticky on ${element.tagName}`);
}
</script>

0 comments on commit 19666e5

Please sign in to comment.