Changeset 140613 in webkit


Ignore:
Timestamp:
Jan 23, 2013 4:33:06 PM (11 years ago)
Author:
rniwa@webkit.org
Message:

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.
Location:
trunk
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r140610 r140613  
     12012-12-12  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        REGRESSION: WebKit does not render selection in non-first ruby text nodes.
     4        https://bugs.webkit.org/show_bug.cgi?id=92818
     5
     6        Reviewed by Levi Weintraub.
     7
     8        Add a test, authored by Sukolsak Sakshuwong.
     9
     10        * fast/ruby/select-ruby.html: Added.
     11        * platform/mac/fast/ruby/ruby-base-merge-block-children-crash-expected.png: Added.
     12        * platform/mac/fast/ruby/select-ruby-expected.png: Added.
     13        * platform/mac/fast/ruby/select-ruby-expected.txt: Added.
     14
    1152013-01-23  Martin Robinson  <mrobinson@igalia.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r140611 r140613  
     12012-12-12  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        REGRESSION: WebKit does not render selection in non-first ruby text nodes.
     4        https://bugs.webkit.org/show_bug.cgi?id=92818
     5
     6        Reviewed by Levi Weintraub.
     7
     8        The patch is based on the one submitted by Sukolsak Sakshuwong.
     9
     10        The bug was caused by the fact isSelectionRoot was returning false on RenderRubyRun even though
     11        it doesn't lay down its children in block direction.
     12
     13        The selection painting code assumes that all blocks in each selection root are laid down in
     14        the containing block direction. In particular, InlineTextBox::paintSelection calls
     15        RootInlineBox::selectionTopAdjustedForPrecedingBlock in order to determine the end of the previous
     16        line, which in turn calls blockBeforeWithinSelectionRoot. blockBeforeWithinSelectionRoot goes
     17        through block nodes that appears before "this" block, and selectionTopAdjustedForPrecedingBlock
     18        assumes that to compute the end of the previous line.
     19
     20        Now suppose we have markup such as <ruby>Ichi<rt>One</rt></ruby><ruby>Ni<rt>Two</rt></ruby>. When
     21        selectionTopAdjustedForPrecedingBlock is called on the line box generated for "Two", it tries to
     22        determine the bottom of the inline box above that of "Two", which blockBeforeWithinSelectionRoot
     23        determines to be that of "One". At this point, everything goes wrong and the selection height is
     24        computed to be 0.
     25
     26        The fix to this problem is to allow RenderRubyRun to be a selection root. Since RenderRubyRun is
     27        already an inline-block, it suffices to bypass the !nonPseudoNode() check. In fact, there is no
     28        need to check this condition anymore as far as I can tell. The check was added in
     29        http://trac.webkit.org/changeset/12986 but all tests added by this change set as well as the rest
     30        of layout tests pass without this condition.
     31
     32        Test: fast/ruby/select-ruby.html
     33
     34        * rendering/RenderBlock.cpp:
     35        (WebCore::RenderBlock::isSelectionRoot):
     36
    1372013-01-23  Kentaro Hara  <haraken@chromium.org>
    238
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r140576 r140613  
    32533253bool RenderBlock::isSelectionRoot() const
    32543254{
    3255     if (!nonPseudoNode())
     3255    if (isPseudoElement())
    32563256        return false;
     3257    ASSERT(node() || isAnonymous());
    32573258       
    32583259    // FIXME: Eventually tables should have to learn how to fill gaps between cells, at least in simple non-spanning cases.
Note: See TracChangeset for help on using the changeset viewer.