Title: [291852] trunk
Revision
291852
Author
[email protected]
Date
2022-03-25 02:15:51 -0700 (Fri, 25 Mar 2022)

Log Message

Improve rebuilding of ruby subtrees
https://bugs.webkit.org/show_bug.cgi?id=238365

Source/WebCore:

Patch by Frédéric Wang <[email protected]> on 2022-03-25
Reviewed by Alan Bujtas.

Don't collapse generated Ruby subtree when tearing down children and take into account the
fact that anonymous before/after node can belong to a display: content child.

* rendering/updating/RenderTreeBuilder.cpp:
(WebCore::RenderTreeBuilder::destroyAndCleanUpAnonymousWrappers): Don't collapse.
* rendering/updating/RenderTreeBuilderRuby.cpp:
(WebCore::lastRubyRun): Child can be also be an anonymous after content.
(WebCore::RenderTreeBuilder::Ruby::findOrCreateParentForChild): When beforeChild is
an anonymous before/after, just fallback to appending to the last ruby run.

LayoutTests:

Patch by Frederic Wang <[email protected]> on 2022-03-25
Reviewed by Alan Bujtas.

Expectation for rubyDOM-remove-text2.html is updated now that we don't collapse anonymous
RenderRubyBase nodes.

* platform/gtk/fast/ruby/rubyDOM-remove-text2-expected.txt: Updated.
* platform/ios/fast/ruby/rubyDOM-remove-text2-expected.txt: Updated.
* platform/mac/fast/ruby/rubyDOM-remove-text2-expected.txt: Updated.
* platform/win/fast/ruby/rubyDOM-remove-text2-expected.txt: Updated.
* platform/wincairo/fast/ruby/rubyDOM-remove-text2-expected.txt: Updated.
* platform/wpe/fast/ruby/rubyDOM-remove-text2-expected.txt: Updated.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (291851 => 291852)


--- trunk/LayoutTests/ChangeLog	2022-03-25 08:54:16 UTC (rev 291851)
+++ trunk/LayoutTests/ChangeLog	2022-03-25 09:15:51 UTC (rev 291852)
@@ -1,3 +1,20 @@
+2022-03-25  Frederic Wang  <[email protected]>
+
+        Improve rebuilding of ruby subtrees
+        https://bugs.webkit.org/show_bug.cgi?id=238365
+
+        Reviewed by Alan Bujtas.
+
+        Expectation for rubyDOM-remove-text2.html is updated now that we don't collapse anonymous
+        RenderRubyBase nodes.
+
+        * platform/gtk/fast/ruby/rubyDOM-remove-text2-expected.txt: Updated.
+        * platform/ios/fast/ruby/rubyDOM-remove-text2-expected.txt: Updated.
+        * platform/mac/fast/ruby/rubyDOM-remove-text2-expected.txt: Updated.
+        * platform/win/fast/ruby/rubyDOM-remove-text2-expected.txt: Updated.
+        * platform/wincairo/fast/ruby/rubyDOM-remove-text2-expected.txt: Updated.
+        * platform/wpe/fast/ruby/rubyDOM-remove-text2-expected.txt: Updated.
+
 2022-03-24  Myles C. Maxfield  <[email protected]>
 
         [Cocoa] REGRESSION(r281291): When accessibility bold is enabled, font-family:system-ui is supposed to be bold

Modified: trunk/LayoutTests/platform/gtk/fast/ruby/rubyDOM-remove-text2-expected.txt (291851 => 291852)


--- trunk/LayoutTests/platform/gtk/fast/ruby/rubyDOM-remove-text2-expected.txt	2022-03-25 08:54:16 UTC (rev 291851)
+++ trunk/LayoutTests/platform/gtk/fast/ruby/rubyDOM-remove-text2-expected.txt	2022-03-25 09:15:51 UTC (rev 291852)
@@ -20,6 +20,7 @@
             RenderRubyText {RT} at (0,-10) size 114x10
               RenderText {#text} at (0,0) size 114x10
                 text run at (0,0) width 114: "Hyper-text Markup Language"
+            RenderRubyBase (anonymous) at (0,0) size 114x0
           RenderRubyRun (anonymous) at (268,0) size 9x18
             RenderRubyBase (anonymous) at (0,0) size 8x18
               RenderText {#text} at (0,0) size 8x17

Modified: trunk/LayoutTests/platform/ios/fast/ruby/rubyDOM-remove-text2-expected.txt (291851 => 291852)


--- trunk/LayoutTests/platform/ios/fast/ruby/rubyDOM-remove-text2-expected.txt	2022-03-25 08:54:16 UTC (rev 291851)
+++ trunk/LayoutTests/platform/ios/fast/ruby/rubyDOM-remove-text2-expected.txt	2022-03-25 09:15:51 UTC (rev 291852)
@@ -20,6 +20,7 @@
             RenderRubyText {RT} at (0,-11) size 108x12
               RenderText {#text} at (0,0) size 108x11
                 text run at (0,0) width 108: "Hyper-text Markup Language"
+            RenderRubyBase (anonymous) at (0,0) size 108x0
           RenderRubyRun (anonymous) at (265,0) size 9x20
             RenderRubyBase (anonymous) at (0,0) size 8x20
               RenderText {#text} at (0,0) size 8x19

Modified: trunk/LayoutTests/platform/mac/fast/ruby/rubyDOM-remove-text2-expected.txt (291851 => 291852)


--- trunk/LayoutTests/platform/mac/fast/ruby/rubyDOM-remove-text2-expected.txt	2022-03-25 08:54:16 UTC (rev 291851)
+++ trunk/LayoutTests/platform/mac/fast/ruby/rubyDOM-remove-text2-expected.txt	2022-03-25 09:15:51 UTC (rev 291852)
@@ -20,6 +20,7 @@
             RenderRubyText {RT} at (0,-10) size 108x10
               RenderText {#text} at (0,0) size 108x10
                 text run at (0,0) width 108: "Hyper-text Markup Language"
+            RenderRubyBase (anonymous) at (0,0) size 108x0
           RenderRubyRun (anonymous) at (264,0) size 9x18
             RenderRubyBase (anonymous) at (0,0) size 8x18
               RenderText {#text} at (0,0) size 8x18

Modified: trunk/LayoutTests/platform/win/fast/ruby/rubyDOM-remove-text2-expected.txt (291851 => 291852)


--- trunk/LayoutTests/platform/win/fast/ruby/rubyDOM-remove-text2-expected.txt	2022-03-25 08:54:16 UTC (rev 291851)
+++ trunk/LayoutTests/platform/win/fast/ruby/rubyDOM-remove-text2-expected.txt	2022-03-25 09:15:51 UTC (rev 291852)
@@ -20,6 +20,7 @@
             RenderRubyText {RT} at (0,-10) size 112x10
               RenderText {#text} at (0,0) size 112x10
                 text run at (0,0) width 112: "Hyper-text Markup Language"
+            RenderRubyBase (anonymous) at (0,0) size 112x0
           RenderRubyRun (anonymous) at (267,0) size 8x18
             RenderRubyBase (anonymous) at (0,0) size 8x18
               RenderText {#text} at (0,0) size 8x18

Modified: trunk/LayoutTests/platform/wincairo/fast/ruby/rubyDOM-remove-text2-expected.txt (291851 => 291852)


--- trunk/LayoutTests/platform/wincairo/fast/ruby/rubyDOM-remove-text2-expected.txt	2022-03-25 08:54:16 UTC (rev 291851)
+++ trunk/LayoutTests/platform/wincairo/fast/ruby/rubyDOM-remove-text2-expected.txt	2022-03-25 09:15:51 UTC (rev 291852)
@@ -20,6 +20,7 @@
             RenderRubyText {RT} at (0,-12) size 113x12
               RenderText {#text} at (0,0) size 113x12
                 text run at (0,0) width 113: "Hyper-text Markup Language"
+            RenderRubyBase (anonymous) at (0,0) size 113x0
           RenderRubyRun (anonymous) at (259,0) size 8x20
             RenderRubyBase (anonymous) at (0,0) size 8x20
               RenderText {#text} at (0,0) size 8x19

Modified: trunk/LayoutTests/platform/wpe/fast/ruby/rubyDOM-remove-text2-expected.txt (291851 => 291852)


--- trunk/LayoutTests/platform/wpe/fast/ruby/rubyDOM-remove-text2-expected.txt	2022-03-25 08:54:16 UTC (rev 291851)
+++ trunk/LayoutTests/platform/wpe/fast/ruby/rubyDOM-remove-text2-expected.txt	2022-03-25 09:15:51 UTC (rev 291852)
@@ -20,6 +20,7 @@
             RenderRubyText {RT} at (0,-10) size 114x10
               RenderText {#text} at (0,0) size 114x10
                 text run at (0,0) width 114: "Hyper-text Markup Language"
+            RenderRubyBase (anonymous) at (0,0) size 114x0
           RenderRubyRun (anonymous) at (269,0) size 8x18
             RenderRubyBase (anonymous) at (0,0) size 8x18
               RenderText {#text} at (0,0) size 8x17

Modified: trunk/Source/WebCore/ChangeLog (291851 => 291852)


--- trunk/Source/WebCore/ChangeLog	2022-03-25 08:54:16 UTC (rev 291851)
+++ trunk/Source/WebCore/ChangeLog	2022-03-25 09:15:51 UTC (rev 291852)
@@ -1,3 +1,20 @@
+2022-03-25  Frédéric Wang  <[email protected]>
+
+        Improve rebuilding of ruby subtrees
+        https://bugs.webkit.org/show_bug.cgi?id=238365
+
+        Reviewed by Alan Bujtas.
+
+        Don't collapse generated Ruby subtree when tearing down children and take into account the
+        fact that anonymous before/after node can belong to a display: content child.
+
+        * rendering/updating/RenderTreeBuilder.cpp:
+        (WebCore::RenderTreeBuilder::destroyAndCleanUpAnonymousWrappers): Don't collapse.
+        * rendering/updating/RenderTreeBuilderRuby.cpp:
+        (WebCore::lastRubyRun): Child can be also be an anonymous after content.
+        (WebCore::RenderTreeBuilder::Ruby::findOrCreateParentForChild): When beforeChild is
+        an anonymous before/after, just fallback to appending to the last ruby run.
+
 2022-03-25  Don Olmstead  <[email protected]>
 
         Mismatched forward declaration of GraphicsContextState

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp (291851 => 291852)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp	2022-03-25 08:54:16 UTC (rev 291851)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp	2022-03-25 09:15:51 UTC (rev 291852)
@@ -865,7 +865,7 @@
     }
 
     auto isAnonymousAndSafeToDelete = [] (const auto& renderer) {
-        return renderer.isAnonymous() && !renderer.isRenderView() && !renderer.isRenderFragmentedFlow();
+        return renderer.isAnonymous() && !is<RenderRubyBase>(renderer) && !renderer.isRenderView() && !renderer.isRenderFragmentedFlow();
     };
 
     auto destroyRootIncludingAnonymous = [&] () -> RenderObject& {

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp (291851 => 291852)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp	2022-03-25 08:54:16 UTC (rev 291851)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp	2022-03-25 09:15:51 UTC (rev 291852)
@@ -105,18 +105,6 @@
     return newBlock;
 }
 
-static RenderRubyRun* lastRubyRun(const RenderElement* ruby)
-{
-    RenderObject* child = ruby->lastChild();
-    if (child && !is<RenderRubyRun>(*child))
-        child = child->previousSibling();
-    if (!is<RenderRubyRun>(child)) {
-        ASSERT(!child || child->isBeforeContent() || child == rubyBeforeBlock(ruby) || child->isRenderMultiColumnFlow() || child->isRenderMultiColumnSet());
-        return nullptr;
-    }
-    return downcast<RenderRubyRun>(child);
-}
-
 RenderTreeBuilder::Ruby::Ruby(RenderTreeBuilder& builder)
     : m_builder(builder)
 {
@@ -288,7 +276,7 @@
     if (child.isRubyRun())
         return parent;
 
-    if (beforeChild && !parent.isAfterContent(beforeChild)) {
+    if (beforeChild && !parent.isBeforeOrAfterContent(beforeChild)) {
         // insert child into run
         ASSERT(!beforeChild->isRubyRun());
         auto* run = beforeChild->parent();
@@ -303,7 +291,7 @@
     // If the new child would be appended, try to add the child to the previous run
     // if possible, or create a new run otherwise.
     // (The RenderRubyRun object will handle the details)
-    auto* lastRun = lastRubyRun(&parent);
+    auto* lastRun = childrenOfType<RenderRubyRun>(parent).last();
     if (!lastRun || lastRun->hasRubyText()) {
         auto newRun = RenderRubyRun::staticCreateRubyRun(&parent);
         lastRun = newRun.get();
@@ -350,7 +338,7 @@
     if (child.isRubyRun())
         return parent;
 
-    if (beforeChild && !parent.isAfterContent(beforeChild)) {
+    if (beforeChild && !parent.isBeforeOrAfterContent(beforeChild)) {
         // insert child into run
         ASSERT(!beforeChild->isRubyRun());
         auto* run = beforeChild->parent();
@@ -365,7 +353,7 @@
     // If the new child would be appended, try to add the child to the previous run
     // if possible, or create a new run otherwise.
     // (The RenderRubyRun object will handle the details)
-    auto* lastRun = lastRubyRun(&parent);
+    auto* lastRun = childrenOfType<RenderRubyRun>(parent).last();
     if (!lastRun || lastRun->hasRubyText()) {
         auto newRun = RenderRubyRun::staticCreateRubyRun(&parent);
         lastRun = newRun.get();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to