REGRESSION: WebKit does not render selection in non-first ruby text nodes.
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Jan 2013 00:33:06 +0000 (00:33 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Jan 2013 00:33:06 +0000 (00:33 +0000)
commit5684abafdd752b20664f9c2f8b3b0d30f6118c11
treed30ea37a2e06e726fac66f49f2b0492bee804ff4
parent0ee473274552938c754d56a0db7a3865e6a310b5
REGRESSION: WebKit does not render selection in non-first ruby text nodes.
https://bugs.webkit.org/show_bug.cgi?id=92818

Reviewed by Levi Weintraub.

Source/WebCore:

The patch is based on the one submitted by Sukolsak Sakshuwong.

The bug was caused by the fact isSelectionRoot was returning false on RenderRubyRun even though
it doesn't lay down its children in block direction.

The selection painting code assumes that all blocks in each selection root are laid down in
the containing block direction. In particular, InlineTextBox::paintSelection calls
RootInlineBox::selectionTopAdjustedForPrecedingBlock in order to determine the end of the previous
line, which in turn calls blockBeforeWithinSelectionRoot. blockBeforeWithinSelectionRoot goes
through block nodes that appears before "this" block, and selectionTopAdjustedForPrecedingBlock
assumes that to compute the end of the previous line.

Now suppose we have markup such as <ruby>Ichi<rt>One</rt></ruby><ruby>Ni<rt>Two</rt></ruby>. When
selectionTopAdjustedForPrecedingBlock is called on the line box generated for "Two", it tries to
determine the bottom of the inline box above that of "Two", which blockBeforeWithinSelectionRoot
determines to be that of "One". At this point, everything goes wrong and the selection height is
computed to be 0.

The fix to this problem is to allow RenderRubyRun to be a selection root. Since RenderRubyRun is
already an inline-block, it suffices to bypass the !nonPseudoNode() check. In fact, there is no
need to check this condition anymore as far as I can tell. The check was added in
http://trac.webkit.org/changeset/12986 but all tests added by this change set as well as the rest
of layout tests pass without this condition.

Test: fast/ruby/select-ruby.html

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::isSelectionRoot):

LayoutTests:

Add a test, authored by Sukolsak Sakshuwong.

* fast/ruby/select-ruby.html: Added.
* platform/mac/fast/ruby/ruby-base-merge-block-children-crash-expected.png: Added.
* platform/mac/fast/ruby/select-ruby-expected.png: Added.
* platform/mac/fast/ruby/select-ruby-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@140613 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/ruby/select-ruby.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/ruby/ruby-base-merge-block-children-crash-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/ruby/select-ruby-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/ruby/select-ruby-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.cpp