In CSS 2.1 sections 10.3.7 and 10.3.8, 'direction' beats 'auto' margins only when both margins are 'auto'. We implement this behavior when only one margin is 'auto'. Safari 3 gets it right. (Opera and IE don't; Opera 9.25 doesn't implement the direction-override at all; IE 7 doesn't implement auto margins.)
Steps to reproduce: load http://dbaron.org/css/test/2008/abs-pos-auto-margin
1. direction:ltr, wide, margin-left:auto should overflow the yellow box to the right
2. direction:rtl, wide, margin-right:auto should overflow the yellow box to the left
1. it overflows to the left
2. it overflows to the right
This should be a simple fix in nsHTMLReflowState::InitAbsoluteConstraints.
I actually hard-coded the buggy behavior described in this bug into the reference renderings in layout/reftests/box-properties/abspos-non-replaced-width-offset-margin-ref.html and layout/reftests/box-properties/abspos-replaced-width-offset-margin-ref.html ; these should be fixed when we fix this bug.
Is this still a bug?
The behavior described is still present; I haven't checked whether the spec has changed in the last 18 months.
Created attachment 493143 [details] [diff] [review]
This fixes the two tests mentioned above (which are also in the CSS 2.1 test suite, with no passing implementations, although every implementation I've checked fails differently).
I still need to (a) write tests for the vertical case (b) figure out whether that FIXME I added in the vertical case should result in a spec change or a code change.
> I still need to (a) write tests for the vertical case (b) figure out whether that FIXME I
> added in the vertical case should result in a spec change or a code change.
Given that IE and Blink at least are following the spec, I'd say code change. That's happening in bug 1100073.
(In reply to David Baron [:dbaron] ⌚️UTC-7 (review requests must explain patch) from comment #4)
> This fixes the two tests mentioned above (which are also in the CSS 2.1 test
> suite, with no passing implementations, although every implementation I've
> checked fails differently).
Firefox 46 and Chrome 50 pass these 2 tests.