Title: [140613] trunk
Revision
140613
Author
[email protected]
Date
2013-01-23 16:33:06 -0800 (Wed, 23 Jan 2013)

Log 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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (140612 => 140613)


--- trunk/LayoutTests/ChangeLog	2013-01-24 00:32:09 UTC (rev 140612)
+++ trunk/LayoutTests/ChangeLog	2013-01-24 00:33:06 UTC (rev 140613)
@@ -1,3 +1,17 @@
+2012-12-12  Ryosuke Niwa  <[email protected]>
+
+        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.
+
+        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.
+
 2013-01-23  Martin Robinson  <[email protected]>
 
         WebKit should support decoding multi-byte entities in XML content

Added: trunk/LayoutTests/fast/ruby/select-ruby.html (0 => 140613)


--- trunk/LayoutTests/fast/ruby/select-ruby.html	                        (rev 0)
+++ trunk/LayoutTests/fast/ruby/select-ruby.html	2013-01-24 00:33:06 UTC (rev 140613)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+body {
+    font-family: Ahem;
+    font-size: 16px;
+    -webkit-font-smoothing: none;
+    color: rgba(0, 0, 0, 0.1);
+}
+</style>
+</head>
+<body>
+<!-- All texts inside the ruby should be highlighted. -->
+a<ruby>1<rt>1</rt>2<rt>2</rt>3<rt>3</rt>4<rt>4</rt></ruby>b
+<script>
+var range = document.createRange();
+range.selectNodeContents(document.body);
+window.getSelection().addRange(range);
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/platform/mac/fast/ruby/ruby-base-merge-block-children-crash-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/fast/ruby/ruby-base-merge-block-children-crash-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/mac/fast/ruby/select-ruby-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/fast/ruby/select-ruby-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/mac/fast/ruby/select-ruby-expected.txt (0 => 140613)


--- trunk/LayoutTests/platform/mac/fast/ruby/select-ruby-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/ruby/select-ruby-expected.txt	2013-01-24 00:33:06 UTC (rev 140613)
@@ -0,0 +1,41 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x40
+  RenderBlock {HTML} at (0,0) size 800x40
+    RenderBody {BODY} at (8,8) size 784x24 [color=#00000019]
+      RenderText {#text} at (0,8) size 16x16
+        text run at (0,8) width 16: "a"
+      RenderRuby (inline) {RUBY} at (0,0) size 64x16
+        RenderRubyRun (anonymous) at (16,8) size 16x16
+          RenderRubyText {RT} at (0,-8) size 16x8
+            RenderText {#text} at (4,0) size 8x8
+              text run at (4,0) width 8: "1"
+          RenderRubyBase (anonymous) at (0,0) size 16x16
+            RenderText {#text} at (0,0) size 16x16
+              text run at (0,0) width 16: "1"
+        RenderRubyRun (anonymous) at (32,8) size 16x16
+          RenderRubyText {RT} at (0,-8) size 16x8
+            RenderText {#text} at (4,0) size 8x8
+              text run at (4,0) width 8: "2"
+          RenderRubyBase (anonymous) at (0,0) size 16x16
+            RenderText {#text} at (0,0) size 16x16
+              text run at (0,0) width 16: "2"
+        RenderRubyRun (anonymous) at (48,8) size 16x16
+          RenderRubyText {RT} at (0,-8) size 16x8
+            RenderText {#text} at (4,0) size 8x8
+              text run at (4,0) width 8: "3"
+          RenderRubyBase (anonymous) at (0,0) size 16x16
+            RenderText {#text} at (0,0) size 16x16
+              text run at (0,0) width 16: "3"
+        RenderRubyRun (anonymous) at (64,8) size 16x16
+          RenderRubyText {RT} at (0,-8) size 16x8
+            RenderText {#text} at (4,0) size 8x8
+              text run at (4,0) width 8: "4"
+          RenderRubyBase (anonymous) at (0,0) size 16x16
+            RenderText {#text} at (0,0) size 16x16
+              text run at (0,0) width 16: "4"
+      RenderText {#text} at (80,8) size 16x16
+        text run at (80,8) width 16: "b"
+      RenderText {#text} at (0,0) size 0x0
+selection start: position 1 of child 2 {#text} of body
+selection end:   position 1 of child 4 {#text} of body

Modified: trunk/Source/WebCore/ChangeLog (140612 => 140613)


--- trunk/Source/WebCore/ChangeLog	2013-01-24 00:32:09 UTC (rev 140612)
+++ trunk/Source/WebCore/ChangeLog	2013-01-24 00:33:06 UTC (rev 140613)
@@ -1,3 +1,39 @@
+2012-12-12  Ryosuke Niwa  <[email protected]>
+
+        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.
+
+        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):
+
 2013-01-23  Kentaro Hara  <[email protected]>
 
         [V8] Reduce usage of deprecatedV8String() and deprecatedV8Integer()

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (140612 => 140613)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2013-01-24 00:32:09 UTC (rev 140612)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2013-01-24 00:33:06 UTC (rev 140613)
@@ -3252,8 +3252,9 @@
 
 bool RenderBlock::isSelectionRoot() const
 {
-    if (!nonPseudoNode())
+    if (isPseudoElement())
         return false;
+    ASSERT(node() || isAnonymous());
         
     // FIXME: Eventually tables should have to learn how to fill gaps between cells, at least in simple non-spanning cases.
     if (isTable())
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to