Title: [237293] trunk/Source/WebCore
Revision
237293
Author
[email protected]
Date
2018-10-19 10:28:13 -0700 (Fri, 19 Oct 2018)

Log Message

[LFC][IFC] RenderReplaced renderer should create InlineBox
https://bugs.webkit.org/show_bug.cgi?id=190720

Reviewed by Antti Koivisto.

* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::TreeBuilder::createSubTree):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (237292 => 237293)


--- trunk/Source/WebCore/ChangeLog	2018-10-19 17:25:38 UTC (rev 237292)
+++ trunk/Source/WebCore/ChangeLog	2018-10-19 17:28:13 UTC (rev 237293)
@@ -1,5 +1,15 @@
 2018-10-19  Zalan Bujtas  <[email protected]>
 
+        [LFC][IFC] RenderReplaced renderer should create InlineBox
+        https://bugs.webkit.org/show_bug.cgi?id=190720
+
+        Reviewed by Antti Koivisto.
+
+        * layout/layouttree/LayoutTreeBuilder.cpp:
+        (WebCore::Layout::TreeBuilder::createSubTree):
+
+2018-10-19  Zalan Bujtas  <[email protected]>
+
         [LFC][IFC] Inline replaced width should default to 300px only if width is auto.
         https://bugs.webkit.org/show_bug.cgi?id=190722
 

Modified: trunk/Source/WebCore/layout/layouttree/LayoutBlockContainer.h (237292 => 237293)


--- trunk/Source/WebCore/layout/layouttree/LayoutBlockContainer.h	2018-10-19 17:25:38 UTC (rev 237292)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBlockContainer.h	2018-10-19 17:28:13 UTC (rev 237293)
@@ -39,13 +39,10 @@
 class BlockContainer : public Container {
     WTF_MAKE_ISO_ALLOCATED(BlockContainer);
 public:
-    friend class TreeBuilder;
+    BlockContainer(std::optional<ElementAttributes>, RenderStyle&&, BaseTypeFlags = BlockContainerFlag);
 
     bool establishesInlineFormattingContext() const final;
 
-protected:
-    BlockContainer(std::optional<ElementAttributes>, RenderStyle&&, BaseTypeFlags = BlockContainerFlag);
-
 };
 
 }

Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.h (237292 => 237293)


--- trunk/Source/WebCore/layout/layouttree/LayoutBox.h	2018-10-19 17:25:38 UTC (rev 237292)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.h	2018-10-19 17:28:13 UTC (rev 237293)
@@ -42,8 +42,32 @@
 class Box : public CanMakeWeakPtr<Box> {
     WTF_MAKE_ISO_ALLOCATED(Box);
 public:
-    friend class TreeBuilder;
+    enum class ElementType {
+        Document,
+        Body,
+        TableColumn,
+        TableRow,
+        TableColumnGroup,
+        TableRowGroup,
+        TableHeaderGroup,
+        TableFooterGroup,
+        GenericElement
+    };
 
+    struct ElementAttributes {
+        ElementType elementType;
+    };
+
+    enum BaseTypeFlag {
+        ContainerFlag         = 1 << 0,
+        BlockContainerFlag    = 1 << 1,
+        InlineBoxFlag         = 1 << 2,
+        InlineContainerFlag   = 1 << 3,
+        LineBreakBoxFlag      = 1 << 4
+    };
+    typedef unsigned BaseTypeFlags;
+
+    Box(std::optional<ElementAttributes>, RenderStyle&&, BaseTypeFlags);
     virtual ~Box();
 
     bool establishesFormattingContext() const;
@@ -91,7 +115,6 @@
     const Box* previousInFlowSibling() const;
     const Box* previousInFlowOrFloatingSibling() const;
 
-    typedef unsigned BaseTypeFlags;
     bool isContainer() const { return m_baseTypeFlags & ContainerFlag; }
     bool isBlockContainer() const { return m_baseTypeFlags & BlockContainerFlag; }
     bool isInlineBox() const { return m_baseTypeFlags & InlineBoxFlag; }
@@ -105,37 +128,11 @@
 
     std::optional<const Replaced> replaced() const { return m_replaced; }
 
-protected:
-    enum class ElementType {
-        Document,
-        Body,
-        TableColumn,
-        TableRow,
-        TableColumnGroup,
-        TableRowGroup,
-        TableHeaderGroup,
-        TableFooterGroup,
-        GenericElement
-    };
-
-    struct ElementAttributes {
-        ElementType elementType;
-    };
-
-    enum BaseTypeFlag {
-        ContainerFlag         = 1 << 0,
-        BlockContainerFlag    = 1 << 1,
-        InlineBoxFlag         = 1 << 2,
-        InlineContainerFlag   = 1 << 3,
-        LineBreakBoxFlag      = 1 << 4
-    };
-    Box(std::optional<ElementAttributes>, RenderStyle&&, BaseTypeFlags);
-
-private:
     void setParent(Container& parent) { m_parent = &parent; }
     void setNextSibling(Box& nextSibling) { m_nextSibling = &nextSibling; }
     void setPreviousSibling(Box& previousSibling) { m_previousSibling = &previousSibling; }
 
+private:
     RenderStyle m_style;
     std::optional<ElementAttributes> m_elementAttributes;
 

Modified: trunk/Source/WebCore/layout/layouttree/LayoutContainer.h (237292 => 237293)


--- trunk/Source/WebCore/layout/layouttree/LayoutContainer.h	2018-10-19 17:25:38 UTC (rev 237292)
+++ trunk/Source/WebCore/layout/layouttree/LayoutContainer.h	2018-10-19 17:28:13 UTC (rev 237293)
@@ -40,7 +40,7 @@
 class Container : public Box {
     WTF_MAKE_ISO_ALLOCATED(Container);
 public:
-    friend class TreeBuilder;
+    Container(std::optional<ElementAttributes>, RenderStyle&&, BaseTypeFlags);
 
     const Box* firstChild() const { return m_firstChild; }
     const Box* firstInFlowChild() const;
@@ -55,14 +55,11 @@
 
     const Vector<WeakPtr<const Box>>& outOfFlowDescendants() const { return m_outOfFlowDescendants; }
 
-protected:
-    Container(std::optional<ElementAttributes>, RenderStyle&&, BaseTypeFlags);
-
-private:
     void setFirstChild(Box&);
     void setLastChild(Box&);
     void addOutOfFlowDescendant(const Box&);
 
+private:
     Box* m_firstChild { nullptr };
     Box* m_lastChild { nullptr };
     Vector<WeakPtr<const Box>> m_outOfFlowDescendants;

Modified: trunk/Source/WebCore/layout/layouttree/LayoutInlineContainer.h (237292 => 237293)


--- trunk/Source/WebCore/layout/layouttree/LayoutInlineContainer.h	2018-10-19 17:25:38 UTC (rev 237292)
+++ trunk/Source/WebCore/layout/layouttree/LayoutInlineContainer.h	2018-10-19 17:28:13 UTC (rev 237293)
@@ -39,9 +39,6 @@
 class InlineContainer : public Container {
     WTF_MAKE_ISO_ALLOCATED(InlineContainer);
 public:
-    friend class TreeBuilder;
-
-protected:
     InlineContainer(std::optional<ElementAttributes>, RenderStyle&&, BaseTypeFlags = InlineContainerFlag);
 };
 

Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (237292 => 237293)


--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2018-10-19 17:25:38 UTC (rev 237292)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2018-10-19 17:28:13 UTC (rev 237293)
@@ -83,23 +83,25 @@
     };
 
     for (auto& child : childrenOfType<RenderObject>(rootRenderer)) {
-        Box* box = nullptr;
+        std::unique_ptr<Box> box;
 
-        if (is<RenderElement>(child)) {
+        if (is<RenderText>(child)) {
+            box = std::make_unique<InlineBox>(std::optional<Box::ElementAttributes>(), RenderStyle::createAnonymousStyleWithDisplay(rootRenderer.style(), DisplayType::Inline));
+            downcast<InlineBox>(*box).setTextContent(downcast<RenderText>(child).originalText());
+        } else if (is<RenderReplaced>(child)) {
+            auto& renderer = downcast<RenderReplaced>(child);
+            box = std::make_unique<InlineBox>(elementAttributes(renderer), RenderStyle::clone(renderer.style()));
+        } else if (is<RenderElement>(child)) {
             auto& renderer = downcast<RenderElement>(child);
             auto display = renderer.style().display();
             if (display == DisplayType::Block)
-                box = new BlockContainer(elementAttributes(renderer), RenderStyle::clone(renderer.style()));
+                box = std::make_unique<BlockContainer>(elementAttributes(renderer), RenderStyle::clone(renderer.style()));
             else if (display == DisplayType::Inline)
-                box = new InlineContainer(elementAttributes(renderer), RenderStyle::clone(renderer.style()));
+                box = std::make_unique<InlineContainer>(elementAttributes(renderer), RenderStyle::clone(renderer.style()));
             else {
                 ASSERT_NOT_IMPLEMENTED_YET();
                 continue;
             }
-
-        } 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();
             continue;
@@ -123,8 +125,10 @@
             auto& containingBlockFormattingContextRoot = box->containingBlock()->formattingContextRoot();
             const_cast<Container&>(containingBlockFormattingContextRoot).addOutOfFlowDescendant(*box);
         }
-        if (is<RenderElement>(child))
+        if (is<Container>(*box))
             createSubTree(downcast<RenderElement>(child), downcast<Container>(*box));
+        // Temporary
+        box.release();
     }
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to