Title: [233482] trunk/Source/WebCore
Revision
233482
Author
[email protected]
Date
2018-07-03 15:28:41 -0700 (Tue, 03 Jul 2018)

Log Message

[LFC] Generate anonymous inline box for text content.
https://bugs.webkit.org/show_bug.cgi?id=187301

Reviewed by Antti Koivisto.

Always have a inline container for text content (and no dedicated text renderer).

* layout/layouttree/LayoutInlineBox.cpp:
(WebCore::Layout::InlineBox::InlineBox):
* layout/layouttree/LayoutInlineBox.h:
(WebCore::Layout::InlineBox::setContent):
* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::TreeBuilder::createSubTree):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (233481 => 233482)


--- trunk/Source/WebCore/ChangeLog	2018-07-03 21:38:22 UTC (rev 233481)
+++ trunk/Source/WebCore/ChangeLog	2018-07-03 22:28:41 UTC (rev 233482)
@@ -1,3 +1,19 @@
+2018-07-03  Zalan Bujtas  <[email protected]>
+
+        [LFC] Generate anonymous inline box for text content.
+        https://bugs.webkit.org/show_bug.cgi?id=187301
+
+        Reviewed by Antti Koivisto.
+
+        Always have a inline container for text content (and no dedicated text renderer).
+
+        * layout/layouttree/LayoutInlineBox.cpp:
+        (WebCore::Layout::InlineBox::InlineBox):
+        * layout/layouttree/LayoutInlineBox.h:
+        (WebCore::Layout::InlineBox::setContent):
+        * layout/layouttree/LayoutTreeBuilder.cpp:
+        (WebCore::Layout::TreeBuilder::createSubTree):
+
 2018-07-03  Basuke Suzuki  <[email protected]>
 
         [Curl] Embed certificate information into ResourceResponse.

Modified: trunk/Source/WebCore/layout/layouttree/LayoutInlineBox.cpp (233481 => 233482)


--- trunk/Source/WebCore/layout/layouttree/LayoutInlineBox.cpp	2018-07-03 21:38:22 UTC (rev 233481)
+++ trunk/Source/WebCore/layout/layouttree/LayoutInlineBox.cpp	2018-07-03 22:28:41 UTC (rev 233482)
@@ -36,8 +36,8 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(InlineBox);
 
-InlineBox::InlineBox(std::optional<ElementAttributes> attributes, RenderStyle&& style, BaseTypeFlags baseTypeFlags)
-    : Box(attributes, WTFMove(style), baseTypeFlags | InlineBoxFlag)
+InlineBox::InlineBox(std::optional<ElementAttributes> attributes, RenderStyle&& style)
+    : Box(attributes, WTFMove(style), InlineBoxFlag)
 {
 }
 

Modified: trunk/Source/WebCore/layout/layouttree/LayoutInlineBox.h (233481 => 233482)


--- trunk/Source/WebCore/layout/layouttree/LayoutInlineBox.h	2018-07-03 21:38:22 UTC (rev 233481)
+++ trunk/Source/WebCore/layout/layouttree/LayoutInlineBox.h	2018-07-03 22:28:41 UTC (rev 233482)
@@ -39,7 +39,12 @@
 class InlineBox : public Box {
     WTF_MAKE_ISO_ALLOCATED(InlineBox);
 public:
-    InlineBox(std::optional<ElementAttributes>, RenderStyle&&, BaseTypeFlags);
+    InlineBox(std::optional<ElementAttributes>, RenderStyle&&);
+
+    void setTextContent(String text) { m_textContent = text; }
+
+private:
+    String m_textContent;
 };
 
 }

Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (233481 => 233482)


--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2018-07-03 21:38:22 UTC (rev 233481)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2018-07-03 22:28:41 UTC (rev 233482)
@@ -81,15 +81,19 @@
         return std::nullopt;
     };
 
-    // Skip RenderText (and some others) for now.
-    for (auto& child : childrenOfType<RenderElement>(rootRenderer)) {
+    for (auto& child : childrenOfType<RenderObject>(rootRenderer)) {
         Box* box = nullptr;
 
-        if (is<RenderBlock>(child))
-            box = new BlockContainer(elementAttributes(child), RenderStyle::clone(child.style()));
-        else if (is<RenderInline>(child))
-            box = new InlineContainer(elementAttributes(child), RenderStyle::clone(child.style()));
-        else
+        if (is<RenderElement>(child)) {
+            auto& renderer = downcast<RenderElement>(child);
+            if (is<RenderBlock>(renderer))
+                box = new BlockContainer(elementAttributes(renderer), RenderStyle::clone(renderer.style()));
+            else if (is<RenderInline>(renderer))
+                box = new InlineContainer(elementAttributes(renderer), RenderStyle::clone(renderer.style()));
+        } else if (is<RenderText>(child)) {
+            box = new InlineBox( { }, RenderStyle::createAnonymousStyleWithDisplay(rootRenderer.style(), DisplayType::Inline));
+            downcast<InlineBox>(*box).setTextContent(downcast<RenderText>(child).originalText());
+        } else
             ASSERT_NOT_IMPLEMENTED_YET();
 
         if (!rootContainer.hasChild()) {
@@ -108,7 +112,8 @@
             // Collect the out-of-flow descendants at the formatting root lever (as opposed to at the containing block level, though they might be the same).
             const_cast<Container&>(box->formattingContextRoot()).addOutOfFlowDescendant(*box);
         }
-        createSubTree(child, downcast<Container>(*box));
+        if (is<RenderElement>(child))
+            createSubTree(downcast<RenderElement>(child), downcast<Container>(*box));
     }
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to