LibWeb: Don't inflate margin-right for over-constrained blocks#8156
LibWeb: Don't inflate margin-right for over-constrained blocks#8156wakamex wants to merge 2 commits intoLadybirdBrowser:masterfrom
Conversation
|
Hello! One or more of the commit messages in this PR do not match the Ladybird code submission policy, please check the |
21c2a59 to
f4d3b98
Compare
Tests/LibWeb/Text/expected/css/getComputedStyle-overconstrained-margin.txt
Show resolved
Hide resolved
f4d3b98 to
2fb3fbf
Compare
638e56f to
875b0e1
Compare
|
@wakamex multiple tests are failing. Please check the test results locally and see if they need updating. |
|
Your pull request has conflicts that need to be resolved before it can be reviewed and merged. Make sure to rebase your branch on top of the latest |
875b0e1 to
c131700
Compare
This test currently fails: getComputedStyle().marginRight returns an inflated value (e.g. 400px instead of 0px) for blocks where width and both margins are explicitly set but don't fill the containing block. All other browsers return the declared value. See w3c/csswg-drafts#2328. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CSS 2.2 § 10.3.3 says to adjust margin-right to satisfy the constraint equation when a block's width and both margins are explicitly set. However, the inflated value serves no layout purpose (position is determined by margin-left, width is already set, siblings position independently) and all major browsers agree on not storing it. Since a706d0e switched getComputedStyle() to return used values for margins, this inflated margin-right now leaks through to the web via getComputedStyle().marginRight, disagreeing with Chrome, Firefox, and Safari. See w3c/csswg-drafts#2328. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
c131700 to
5908b2c
Compare
|
Fixed 2 of the 3 failing tests. 1 was a missing
also found a material change in the last |
getComputedStyle().marginRightreturns an inflated value for over-constrained blocks (e.g.400pxinstead of0px), disagreeing with Chrome, Firefox, and Safari.When a block's
width,margin-left, andmargin-rightare all explicitly set and don't fill the containing block, CSS 2.2 § 10.3.3 says to inflatemargin-rightto satisfy the constraint equation. Since a706d0e switchedgetComputedStyle()to return used values for margins, this inflated value now leaks to the web. All major browsers store the declared value instead — see CSSWG #2328.The inflated value serves no layout purpose: position is determined by
margin-left, width is already set, and siblings position independently.Reproducer (paste in DevTools console on any page):
First commit adds a failing test, second commit applies the fix and rebaselines 365 layout test expectations.
One WPT test flips from fail to pass in css/css-logical/inheritance.html. The
assert_not_inherited('margin-inline-end', '0px', '10px')now passes because the parent'smargin-inline-endno longer gets inflated as it's an over-constrained case.One WPT ref test is a genuine regression, as the existing "correct" solution relied on inflation: floats-wrap-bfc-outside-001.xht.
Fixes #4729
Supersedes #6606