div align="center" rendering problem
https://bugs.webkit.org/show_bug.cgi?id=4860
Reviewed by David Hyatt.
Source/WebCore:
When an inline element with absolute position was the sole or first child of a render block with
centred alignment, it wasn't obeying its parent's alignment. However it would obey the
alignment if it was preceded by some text. The problem was that the element's render object
was getting skipped as leading white space, so it was not included in a normal line block in
a bidi run. Instead, its position was getting set by RenderBlockLineLayout::setStaticPositions()
which does not pay attention to alignment. Preceding the element with some text allowed the object
to get included in a Bidi run and so get a linebox which would get properly aligned.
The fix is to get RenderBlockLineLayout::setStaticPositions() to obey the alignment specified by
the object's container. This allows WebKit to get the same result on the test as Firefox and IE.
Opera has the same bug as unpatched WebKit.
Tests: fast/css/bug4860-absolute-block-child-does-not-inherit-alignment.html
- Ensure positioned block elements inherit alignment.
fast/css/bug4860-absolute-inline-child-inherits-alignment.html
- Ensure positioned inline elements inherit alignment.
fast/inline/absolute-positioned-inline-in-centred-block.html
- Ensure positioned inline element that's the sole or first child of a rendered block
obeys parents alignment.
fast/inline/absolute-positioned-block-in-centred-block.html
- As above, but a positioned block should not inherit alignment.
* rendering/RenderBlock.h:
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::updateLogicalWidthForAlignment):
(WebCore::RenderBlock::computeInlineDirectionPositionsForLine): Move the alignment check to updateLogicalWidthForAlignment.
(WebCore::setStaticPositions): use startAlignedOffsetForLine and use startAlignedOffsetForBlock
(WebCore::RenderBlock::startAlignedOffsetForLine): New function, find the aligned offset using updateLogicalWidthForAlignment
LayoutTests:
* fast/css/bug4860-absolute-block-child-does-not-inherit-alignment-expected.png: Added.
* fast/css/bug4860-absolute-block-child-does-not-inherit-alignment-expected.txt: Added.
* fast/css/bug4860-absolute-block-child-does-not-inherit-alignment.html: Added.
* fast/css/bug4860-absolute-inline-child-inherits-alignment-expected.png: Added.
* fast/css/bug4860-absolute-inline-child-inherits-alignment-expected.txt: Added.
* fast/css/bug4860-absolute-inline-child-inherits-alignment.html: Added.
* fast/inline/absolute-positioned-block-in-centred-block-expected.png: Added.
* fast/inline/absolute-positioned-block-in-centred-block-expected.txt: Added.
* fast/inline/absolute-positioned-block-in-centred-block.html: Added.
* fast/inline/absolute-positioned-inline-in-centred-block-expected.png: Added.
* fast/inline/absolute-positioned-inline-in-centred-block-expected.txt: Added.
* fast/inline/absolute-positioned-inline-in-centred-block.html: Added.
* platform/chromium-linux/fast/repaint/block-layout-inline-children-float-positioned-expected.png:
* platform/chromium-linux/fast/repaint/block-layout-inline-children-float-positioned-expected.txt:
Both of these two tests were based on the incorrect behaviour of ignoring the alignment specified
by the container of an element absolute position when there was no text preceding the element.
The updated results agree with Firefox and IE.
* fast/css/absolute-child-with-percent-height-inside-relative-parent-expected.txt:
* platform/chromium-win/fast/css/absolute-child-with-percent-height-inside-relative-parent-expected.png:
This test expected the wrong alignment of the red block - it should be centred, not aligned to the left.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@94492 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed